Skip to content

Commit 7ea83b3

Browse files
committed
add opencode
1 parent b8d7cf1 commit 7ea83b3

6 files changed

Lines changed: 46 additions & 50 deletions

File tree

build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ source "$DOTFILES_DIR/scripts/conf.sh"
1010
source "$DOTFILES_DIR/scripts/opencode.sh"
1111
# shellcheck source=scripts/pkg.sh
1212
source "$DOTFILES_DIR/scripts/pkg.sh"
13+
# shellcheck source=scripts/font.sh
14+
source "$DOTFILES_DIR/scripts/font.sh"
1315
# shellcheck source=scripts/kanata.sh
1416
source "$DOTFILES_DIR/scripts/kanata.sh"
1517

@@ -31,6 +33,7 @@ Commands:
3133
conf Initialize post-switch user config
3234
pkg [target] Install packages for target, defaults by distro
3335
targets: arch, deepin, termux, windows, macos
36+
fonts [target] Install fonts for target, defaults by distro
3437
sdk Run scripts/init_sdk.sh
3538
bw [args] Run scripts/bw.sh with forwarded args
3639
all [profile] Install Nix/Home Manager, switch profile, run conf; defaults to light
@@ -84,6 +87,9 @@ main() {
8487
pkg)
8588
run_pkg "${1:-}"
8689
;;
90+
fonts)
91+
install_fonts "${1:-}"
92+
;;
8793
sdk)
8894
run_sdk
8995
;;
@@ -96,6 +102,7 @@ main() {
96102
install_home_manager
97103
switch_dotfiles "$profile"
98104
init_conf "$profile"
105+
install_fonts
99106
;;
100107
nixgl)
101108
install_nixgl

conf/opencode/plugins/crg-plugin.ts

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,43 @@ import type { Plugin } from "@opencode-ai/plugin"
99
* Installed by: code-review-graph install --platform opencode
1010
*/
1111

12-
// Helper: run a shell command quietly, swallowing errors.
13-
async function run($: any, cmd: string): Promise<string> {
14-
try {
15-
const result = await $`${cmd}`.quiet()
16-
return result.stdout?.toString().trim() ?? ""
17-
} catch {
18-
return ""
19-
}
20-
}
21-
22-
export default (app: any) => {
23-
// 1. Auto-update graph after file edits
24-
app.on("file.edited", async ({ $ }: { $: any }) => {
25-
try {
26-
await $`code-review-graph update --skip-flows`.quiet()
27-
} catch {
28-
// Swallow — graph may not be built yet for this project.
29-
}
30-
})
12+
const plugin: Plugin = async ({ $ }) => {
13+
return {
14+
event: async ({ event }) => {
15+
try {
16+
if (event.type === "file.edited") {
17+
await $`code-review-graph update --skip-flows`.quiet()
18+
}
3119

32-
// 2. Show graph status when a new session starts
33-
app.on("session.created", async ({ $ }: { $: any }) => {
34-
try {
35-
const result = await $`code-review-graph status`.quiet()
36-
const output = result.stdout?.toString().trim()
37-
if (output) {
38-
console.log("[code-review-graph]", output)
20+
if (event.type === "session.created") {
21+
const result = await $`code-review-graph status`.quiet()
22+
const output = result.stdout?.toString().trim()
23+
if (output) {
24+
console.log("[code-review-graph]", output)
25+
}
26+
}
27+
} catch {
28+
// Swallow — graph commands must never block OpenCode.
3929
}
40-
} catch {
41-
// Swallow — not every project has a graph.
42-
}
43-
})
30+
},
31+
32+
"tool.execute.before": async (input, output) => {
33+
try {
34+
if (input.tool !== "bash") return
4435

45-
// 3. Detect changes before git commit commands
46-
app.on("tool.execute.before", async (ctx: any) => {
47-
try {
48-
const input = ctx?.input ?? ctx?.params ?? {}
49-
const cmd =
50-
input.command ?? input.cmd ?? input.content ?? ""
51-
if (typeof cmd === "string" && /^git\s+commit/i.test(cmd)) {
52-
const result =
53-
await ctx.$`code-review-graph detect-changes --brief`.quiet()
54-
const output = result.stdout?.toString().trim()
55-
if (output) {
56-
console.log("[code-review-graph] Pre-commit analysis:\n" + output)
36+
const command = output.args.command
37+
if (typeof command === "string" && /^git\s+commit/i.test(command)) {
38+
const result = await $`code-review-graph detect-changes --brief`.quiet()
39+
const analysis = result.stdout?.toString().trim()
40+
if (analysis) {
41+
console.log("[code-review-graph] Pre-commit analysis:\n" + analysis)
42+
}
5743
}
44+
} catch {
45+
// Swallow — never block a commit.
5846
}
59-
} catch {
60-
// Swallow — never block a commit.
61-
}
62-
})
47+
},
48+
}
6349
}
50+
51+
export default plugin

conf/opencode/skills/oh-my-opencode-slim/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Edit the active preset under `presets.<preset>.<agent>`:
131131
"model": "openai/gpt-5.6-luna",
132132
"variant": "low",
133133
"skills": [],
134-
"mcps": ["websearch", "context7", "gh_grep"]
134+
"mcps": ["context7", "gh_grep"]
135135
}
136136
}
137137
}

conf/opencode/skills/reflect/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ repeated patterns, friction, and improvement opportunities.
3737

3838
1. **Load recent sessions** - Query the SQLite database directly:
3939
```bash
40-
bun -e "import Database from 'bun:sqlite'; const db = new Database('/home/mhenke/.local/share/opencode/opencode.db'); console.log(db.query('SELECT id, directory, title, agent, model, time_created, cost, tokens_input, tokens_output FROM session ORDER BY time_created DESC LIMIT 50').all())"
40+
bun -e "import Database from 'bun:sqlite'; const db = new Database(process.env.HOME + '/.local/share/opencode/opencode.db'); console.log(db.query('SELECT id, directory, title, agent, model, time_created, cost, tokens_input, tokens_output FROM session ORDER BY time_created DESC LIMIT 50').all())"
4141
```
4242
Adjust `LIMIT 50` to `--last N` if specified.
4343

4444
**Session table columns:** `id, directory, title, agent, model, time_created, cost, tokens_input, tokens_output`
4545

4646
2. **Load session messages** - For each session ID, query the message table:
4747
```bash
48-
bun -e "import Database from 'bun:sqlite'; const db = new Database('/home/mhenke/.local/share/opencode/opencode.db'); console.log(db.query('SELECT data FROM message WHERE session_id = ?').all('ses_14de9c68effegtZtlATm42wnz7'))"
48+
bun -e "import Database from 'bun:sqlite'; const db = new Database(process.env.HOME + '/.local/share/opencode/opencode.db'); console.log(db.query('SELECT data FROM message WHERE session_id = ?').all('<session_id>'))"
4949
```
5050

5151
**Message table columns:** `id, session_id, time_created, time_updated, data` (data is JSON with role, agent, model, summary, etc.)

conf/opencode/tui.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://opencode.ai/tui.json",
3+
"theme": "catppuccin",
34
"keybinds": {
45
"leader": "ctrl+b",
56
"command_list": "ctrl+x",

conf/zsh/alias.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ oc() {
2121
local port
2222
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()')
2323
source "$HOME/.config/zsh/ai.env"
24-
OPENCODE_PORT="$port" opencode --port "$port" "$@"
24+
OPENCODE_ENABLE_EXA=1 OPENCODE_PORT="$port" opencode --port "$port" "$@"
2525
}
2626
function mkcd(){
2727
mkdir $1

0 commit comments

Comments
 (0)