Skip to content

Commit 534d1b8

Browse files
authored
sync: merge upstream v1.1.28 into shuvcode-dev (#319)
1 parent 791a26a commit 534d1b8

94 files changed

Lines changed: 4744 additions & 1478 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,29 @@ on:
99
workflow_dispatch:
1010
jobs:
1111
test:
12-
runs-on: blacksmith-4vcpu-ubuntu-2404
12+
name: test (${{ matrix.settings.name }})
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
settings:
17+
- name: linux
18+
host: blacksmith-4vcpu-ubuntu-2404
19+
playwright: bunx playwright install --with-deps
20+
workdir: .
21+
command: |
22+
git config --global user.email "bot@opencode.ai"
23+
git config --global user.name "opencode"
24+
bun turbo typecheck
25+
bun turbo test
26+
- name: windows
27+
host: windows-latest
28+
playwright: bunx playwright install
29+
workdir: packages/app
30+
command: bun test:e2e
31+
runs-on: ${{ matrix.settings.host }}
32+
defaults:
33+
run:
34+
shell: bash
1335
steps:
1436
- name: Checkout repository
1537
uses: actions/checkout@v4
@@ -21,42 +43,63 @@ jobs:
2143

2244
- name: Install Playwright browsers
2345
working-directory: packages/app
24-
run: bunx playwright install --with-deps
46+
run: ${{ matrix.settings.playwright }}
47+
48+
- name: Set OS-specific paths
49+
run: |
50+
if [ "${{ runner.os }}" = "Windows" ]; then
51+
printf '%s\n' "OPENCODE_E2E_ROOT=${{ runner.temp }}\\opencode-e2e" >> "$GITHUB_ENV"
52+
printf '%s\n' "OPENCODE_TEST_HOME=${{ runner.temp }}\\opencode-e2e\\home" >> "$GITHUB_ENV"
53+
printf '%s\n' "XDG_DATA_HOME=${{ runner.temp }}\\opencode-e2e\\share" >> "$GITHUB_ENV"
54+
printf '%s\n' "XDG_CACHE_HOME=${{ runner.temp }}\\opencode-e2e\\cache" >> "$GITHUB_ENV"
55+
printf '%s\n' "XDG_CONFIG_HOME=${{ runner.temp }}\\opencode-e2e\\config" >> "$GITHUB_ENV"
56+
printf '%s\n' "XDG_STATE_HOME=${{ runner.temp }}\\opencode-e2e\\state" >> "$GITHUB_ENV"
57+
printf '%s\n' "MODELS_DEV_API_JSON=${{ github.workspace }}\\packages\\opencode\\test\\tool\\fixtures\\models-api.json" >> "$GITHUB_ENV"
58+
else
59+
printf '%s\n' "OPENCODE_E2E_ROOT=${{ runner.temp }}/opencode-e2e" >> "$GITHUB_ENV"
60+
printf '%s\n' "OPENCODE_TEST_HOME=${{ runner.temp }}/opencode-e2e/home" >> "$GITHUB_ENV"
61+
printf '%s\n' "XDG_DATA_HOME=${{ runner.temp }}/opencode-e2e/share" >> "$GITHUB_ENV"
62+
printf '%s\n' "XDG_CACHE_HOME=${{ runner.temp }}/opencode-e2e/cache" >> "$GITHUB_ENV"
63+
printf '%s\n' "XDG_CONFIG_HOME=${{ runner.temp }}/opencode-e2e/config" >> "$GITHUB_ENV"
64+
printf '%s\n' "XDG_STATE_HOME=${{ runner.temp }}/opencode-e2e/state" >> "$GITHUB_ENV"
65+
printf '%s\n' "MODELS_DEV_API_JSON=${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json" >> "$GITHUB_ENV"
66+
fi
2567
2668
- name: Seed opencode data
2769
working-directory: packages/opencode
2870
run: bun script/seed-e2e.ts
2971
env:
30-
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
72+
MODELS_DEV_API_JSON: ${{ env.MODELS_DEV_API_JSON }}
3173
OPENCODE_DISABLE_MODELS_FETCH: "true"
3274
OPENCODE_DISABLE_SHARE: "true"
3375
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
3476
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
3577
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
36-
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
37-
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
38-
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
39-
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
40-
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
78+
OPENCODE_TEST_HOME: ${{ env.OPENCODE_TEST_HOME }}
79+
XDG_DATA_HOME: ${{ env.XDG_DATA_HOME }}
80+
XDG_CACHE_HOME: ${{ env.XDG_CACHE_HOME }}
81+
XDG_CONFIG_HOME: ${{ env.XDG_CONFIG_HOME }}
82+
XDG_STATE_HOME: ${{ env.XDG_STATE_HOME }}
4183
OPENCODE_E2E_PROJECT_DIR: ${{ github.workspace }}
4284
OPENCODE_E2E_SESSION_TITLE: "E2E Session"
4385
OPENCODE_E2E_MESSAGE: "Seeded for UI e2e"
4486
OPENCODE_E2E_MODEL: "opencode/gpt-5-nano"
4587

4688
- name: Run opencode server
47-
run: bun run dev -- --print-logs --log-level WARN serve --port 4096 --hostname 0.0.0.0 &
89+
working-directory: packages/opencode
90+
run: bun dev -- --print-logs --log-level WARN serve --port 4096 --hostname 0.0.0.0 &
4891
env:
49-
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
92+
MODELS_DEV_API_JSON: ${{ env.MODELS_DEV_API_JSON }}
5093
OPENCODE_DISABLE_MODELS_FETCH: "true"
5194
OPENCODE_DISABLE_SHARE: "true"
5295
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
5396
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
5497
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
55-
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
56-
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
57-
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
58-
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
59-
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
98+
OPENCODE_TEST_HOME: ${{ env.OPENCODE_TEST_HOME }}
99+
XDG_DATA_HOME: ${{ env.XDG_DATA_HOME }}
100+
XDG_CACHE_HOME: ${{ env.XDG_CACHE_HOME }}
101+
XDG_CONFIG_HOME: ${{ env.XDG_CONFIG_HOME }}
102+
XDG_STATE_HOME: ${{ env.XDG_STATE_HOME }}
60103
OPENCODE_CLIENT: "app"
61104

62105
- name: Wait for opencode server
@@ -68,24 +111,21 @@ jobs:
68111
exit 1
69112
70113
- name: run
71-
run: |
72-
git config --global user.email "bot@opencode.ai"
73-
git config --global user.name "opencode"
74-
bun turbo typecheck
75-
bun turbo test
114+
working-directory: ${{ matrix.settings.workdir }}
115+
run: ${{ matrix.settings.command }}
76116
env:
77117
CI: true
78-
MODELS_DEV_API_JSON: ${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json
118+
MODELS_DEV_API_JSON: ${{ env.MODELS_DEV_API_JSON }}
79119
OPENCODE_DISABLE_MODELS_FETCH: "true"
80120
OPENCODE_DISABLE_SHARE: "true"
81121
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
82122
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true"
83123
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "true"
84-
OPENCODE_TEST_HOME: ${{ runner.temp }}/opencode-e2e/home
85-
XDG_DATA_HOME: ${{ runner.temp }}/opencode-e2e/share
86-
XDG_CACHE_HOME: ${{ runner.temp }}/opencode-e2e/cache
87-
XDG_CONFIG_HOME: ${{ runner.temp }}/opencode-e2e/config
88-
XDG_STATE_HOME: ${{ runner.temp }}/opencode-e2e/state
124+
OPENCODE_TEST_HOME: ${{ env.OPENCODE_TEST_HOME }}
125+
XDG_DATA_HOME: ${{ env.XDG_DATA_HOME }}
126+
XDG_CACHE_HOME: ${{ env.XDG_CACHE_HOME }}
127+
XDG_CONFIG_HOME: ${{ env.XDG_CONFIG_HOME }}
128+
XDG_STATE_HOME: ${{ env.XDG_STATE_HOME }}
89129
PLAYWRIGHT_SERVER_HOST: "localhost"
90130
PLAYWRIGHT_SERVER_PORT: "4096"
91131
VITE_OPENCODE_SERVER_HOST: "localhost"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Update Nix Hashes
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
paths:
10+
- "bun.lock"
11+
- "package.json"
12+
- "packages/*/package.json"
13+
- "flake.lock"
14+
- ".github/workflows/update-nix-hashes.yml"
15+
pull_request:
16+
paths:
17+
- "bun.lock"
18+
- "package.json"
19+
- "packages/*/package.json"
20+
- "flake.lock"
21+
- ".github/workflows/update-nix-hashes.yml"
22+
23+
jobs:
24+
update-node-modules-hashes:
25+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
26+
runs-on: blacksmith-4vcpu-ubuntu-2404
27+
env:
28+
TITLE: node_modules hashes
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v6
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
fetch-depth: 0
36+
ref: ${{ github.head_ref || github.ref_name }}
37+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
38+
39+
- name: Setup Nix
40+
uses: nixbuild/nix-quick-install-action@v34
41+
42+
- name: Configure git
43+
run: |
44+
git config --global user.email "action@github.com"
45+
git config --global user.name "Github Action"
46+
47+
- name: Pull latest changes
48+
env:
49+
TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
50+
run: |
51+
BRANCH="${TARGET_BRANCH:-${GITHUB_REF_NAME}}"
52+
git pull --rebase --autostash origin "$BRANCH"
53+
54+
- name: Compute all node_modules hashes
55+
run: |
56+
set -euo pipefail
57+
58+
HASH_FILE="nix/hashes.json"
59+
SYSTEMS="x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin"
60+
61+
if [ ! -f "$HASH_FILE" ]; then
62+
mkdir -p "$(dirname "$HASH_FILE")"
63+
echo '{"nodeModules":{}}' > "$HASH_FILE"
64+
fi
65+
66+
for SYSTEM in $SYSTEMS; do
67+
echo "Computing hash for ${SYSTEM}..."
68+
BUILD_LOG=$(mktemp)
69+
trap 'rm -f "$BUILD_LOG"' EXIT
70+
71+
# The updater derivations use fakeHash, so they will fail and reveal the correct hash
72+
UPDATER_ATTR=".#packages.x86_64-linux.${SYSTEM}_node_modules"
73+
74+
nix build "$UPDATER_ATTR" --no-link 2>&1 | tee "$BUILD_LOG" || true
75+
76+
CORRECT_HASH="$(grep -E 'got:\s+sha256-[A-Za-z0-9+/=]+' "$BUILD_LOG" | awk '{print $2}' | head -n1 || true)"
77+
78+
if [ -z "$CORRECT_HASH" ]; then
79+
CORRECT_HASH="$(grep -A2 'hash mismatch' "$BUILD_LOG" | grep 'got:' | awk '{print $2}' | sed 's/sha256:/sha256-/' || true)"
80+
fi
81+
82+
if [ -z "$CORRECT_HASH" ]; then
83+
echo "Failed to determine correct node_modules hash for ${SYSTEM}."
84+
cat "$BUILD_LOG"
85+
exit 1
86+
fi
87+
88+
echo " ${SYSTEM}: ${CORRECT_HASH}"
89+
jq --arg sys "$SYSTEM" --arg h "$CORRECT_HASH" \
90+
'.nodeModules[$sys] = $h' "$HASH_FILE" > "${HASH_FILE}.tmp"
91+
mv "${HASH_FILE}.tmp" "$HASH_FILE"
92+
done
93+
94+
echo "All hashes computed:"
95+
cat "$HASH_FILE"
96+
97+
- name: Commit ${{ env.TITLE }} changes
98+
env:
99+
TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
100+
run: |
101+
set -euo pipefail
102+
103+
HASH_FILE="nix/hashes.json"
104+
echo "Checking for changes..."
105+
106+
summarize() {
107+
local status="$1"
108+
{
109+
echo "### Nix $TITLE"
110+
echo ""
111+
echo "- ref: ${GITHUB_REF_NAME}"
112+
echo "- status: ${status}"
113+
} >> "$GITHUB_STEP_SUMMARY"
114+
if [ -n "${GITHUB_SERVER_URL:-}" ] && [ -n "${GITHUB_REPOSITORY:-}" ] && [ -n "${GITHUB_RUN_ID:-}" ]; then
115+
echo "- run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> "$GITHUB_STEP_SUMMARY"
116+
fi
117+
echo "" >> "$GITHUB_STEP_SUMMARY"
118+
}
119+
120+
FILES=("$HASH_FILE")
121+
STATUS="$(git status --short -- "${FILES[@]}" || true)"
122+
if [ -z "$STATUS" ]; then
123+
echo "No changes detected."
124+
summarize "no changes"
125+
exit 0
126+
fi
127+
128+
echo "Changes detected:"
129+
echo "$STATUS"
130+
git add "${FILES[@]}"
131+
git commit -m "chore: update nix node_modules hashes"
132+
133+
BRANCH="${TARGET_BRANCH:-${GITHUB_REF_NAME}}"
134+
git pull --rebase --autostash origin "$BRANCH"
135+
git push origin HEAD:"$BRANCH"
136+
echo "Changes pushed successfully"
137+
138+
summarize "committed $(git rev-parse --short HEAD)"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: bun-file-io
3+
description: Use this when you are working on file operations like reading, writing, scanning, or deleting files. It summarizes the preferred file APIs and patterns used in this repo. It also notes when to use filesystem helpers for directories.
4+
---
5+
6+
## Use this when
7+
8+
- Editing file I/O or scans in `packages/opencode`
9+
- Handling directory operations or external tools
10+
11+
## Bun file APIs (from Bun docs)
12+
13+
- `Bun.file(path)` is lazy; call `text`, `json`, `stream`, `arrayBuffer`, `bytes`, `exists` to read.
14+
- Metadata: `file.size`, `file.type`, `file.name`.
15+
- `Bun.write(dest, input)` writes strings, buffers, Blobs, Responses, or files.
16+
- `Bun.file(...).delete()` deletes a file.
17+
- `file.writer()` returns a FileSink for incremental writes.
18+
- `Bun.Glob` + `Array.fromAsync(glob.scan({ cwd, absolute, onlyFiles, dot }))` for scans.
19+
- Use `Bun.which` to find a binary, then `Bun.spawn` to run it.
20+
- `Bun.readableStreamToText/Bytes/JSON` for stream output.
21+
22+
## When to use node:fs
23+
24+
- Use `node:fs/promises` for directories (`mkdir`, `readdir`, recursive operations).
25+
26+
## Repo patterns
27+
28+
- Prefer Bun APIs over Node `fs` for file access.
29+
- Check `Bun.file(...).exists()` before reading.
30+
- For binary/large files use `arrayBuffer()` and MIME checks via `file.type`.
31+
- Use `Bun.Glob` + `Array.fromAsync` for scans.
32+
- Decode tool stderr with `Bun.readableStreamToText`.
33+
- For large writes, use `Bun.write(Bun.file(path), text)`.
34+
35+
## Quick checklist
36+
37+
- Use Bun APIs first.
38+
- Use `path.join`/`path.resolve` for paths.
39+
- Prefer promise `.catch(...)` over `try/catch` when possible.

.opencode/skill/test-skill/SKILL.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Server mode is opt-in only. When enabled, set `OPENCODE_SERVER_PASSWORD` to requ
2424
| **Sandbox escapes** | The permission system is not a sandbox (see above) |
2525
| **LLM provider data handling** | Data sent to your configured LLM provider is governed by their policies |
2626
| **MCP server behavior** | External MCP servers you configure are outside our trust boundary |
27+
| **Malicious config files** | Users control their own config; modifying it is not an attack vector |
2728

2829
---
2930

0 commit comments

Comments
 (0)