Skip to content

Commit 7dcb120

Browse files
Add package distribution workflows and harden Daytona OpenCode E2E
1 parent 734a43a commit 7dcb120

24 files changed

+1906
-29
lines changed

.github/workflows/check.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
push:
77
branches: [main]
88

9+
env:
10+
DAYTONA_API_KEY: ${{ secrets.DAYTONA_API_KEY }}
11+
DAYTONA_API_URL: ${{ vars.DAYTONA_API_URL }}
12+
ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }}
13+
914
jobs:
1015
Check:
1116
name: Check
@@ -27,3 +32,79 @@ jobs:
2732

2833
- name: TypeScript typecheck
2934
run: bun run typecheck
35+
36+
- name: Unit tests
37+
run: bun test
38+
39+
- name: CLI smoke checks
40+
run: |
41+
bun run analyze -- --help
42+
bun run start -- --help
43+
bun run setup -- --help
44+
45+
BuildPackage:
46+
name: Build Package Artifact
47+
runs-on: blacksmith-4vcpu-ubuntu-2404
48+
needs: Check
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Setup Node
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: "20"
57+
58+
- name: Setup Bun
59+
uses: oven-sh/setup-bun@v2
60+
with:
61+
bun-version: 1.3.8
62+
63+
- name: Install dependencies
64+
run: bun install --frozen-lockfile
65+
66+
- name: Build package
67+
run: bun run build
68+
69+
- name: Pack tarball
70+
run: |
71+
mkdir -p artifacts
72+
npm pack --pack-destination artifacts
73+
ls -la artifacts
74+
75+
- name: Upload package artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: npm-package
79+
path: artifacts/*.tgz
80+
if-no-files-found: error
81+
82+
PackageE2E:
83+
name: Package Install E2E
84+
runs-on: blacksmith-4vcpu-ubuntu-2404
85+
needs: BuildPackage
86+
steps:
87+
- name: Setup Node
88+
uses: actions/setup-node@v4
89+
with:
90+
node-version: "20"
91+
92+
- name: Download package artifact
93+
uses: actions/download-artifact@v4
94+
with:
95+
name: npm-package
96+
path: artifacts
97+
98+
- name: Install package into clean project
99+
run: |
100+
mkdir e2e-install
101+
cd e2e-install
102+
npm init -y
103+
npm install ../artifacts/*.tgz
104+
105+
- name: Run installed CLI binaries
106+
run: |
107+
cd e2e-install
108+
./node_modules/.bin/opencode-sandboxed-research-analyze --help
109+
./node_modules/.bin/opencode-sandboxed-research-start --help
110+
./node_modules/.bin/opencode-sandboxed-research-setup --help

.github/workflows/daytona-e2e.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Daytona E2E
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
repo_url:
7+
description: "Repository URL to analyze"
8+
required: false
9+
default: "https://github.com/octocat/Hello-World"
10+
model:
11+
description: "Model to use"
12+
required: false
13+
default: "zai-coding-plan/glm-4.7-flash"
14+
analyze_timeout_sec:
15+
description: "Analyze timeout seconds"
16+
required: false
17+
default: "600"
18+
install_timeout_sec:
19+
description: "Install timeout seconds"
20+
required: false
21+
default: "300"
22+
23+
env:
24+
DAYTONA_API_KEY: ${{ secrets.DAYTONA_API_KEY }}
25+
DAYTONA_API_URL: ${{ vars.DAYTONA_API_URL }}
26+
ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }}
27+
28+
jobs:
29+
E2E:
30+
name: Run Daytona Analyze E2E
31+
runs-on: blacksmith-8vcpu-ubuntu-2404
32+
timeout-minutes: 45
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Setup Bun
38+
uses: oven-sh/setup-bun@v2
39+
with:
40+
bun-version: 1.3.8
41+
42+
- name: Install dependencies
43+
run: bun install --frozen-lockfile
44+
45+
- name: Validate required environment
46+
run: |
47+
if [ -z "${DAYTONA_API_KEY:-}" ]; then
48+
echo "DAYTONA_API_KEY is required" >&2
49+
exit 1
50+
fi
51+
52+
- name: Run analyze e2e
53+
run: |
54+
mkdir -p .memory/daytona-e2e
55+
bun run analyze -- \
56+
--out-dir .memory/daytona-e2e/findings \
57+
--model "${{ inputs.model }}" \
58+
--install-timeout-sec "${{ inputs.install_timeout_sec }}" \
59+
--analyze-timeout-sec "${{ inputs.analyze_timeout_sec }}" \
60+
"${{ inputs.repo_url }}"
61+
62+
- name: Upload findings artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: daytona-e2e-findings
66+
path: .memory/daytona-e2e/findings
67+
if-no-files-found: error
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
Publish:
15+
name: Publish To GitHub Packages
16+
runs-on: blacksmith-4vcpu-ubuntu-2404
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "20"
25+
26+
- name: Setup Bun
27+
uses: oven-sh/setup-bun@v2
28+
with:
29+
bun-version: 1.3.8
30+
31+
- name: Install dependencies
32+
run: bun install --frozen-lockfile
33+
34+
- name: Validate package
35+
run: |
36+
bun run check
37+
bun run typecheck
38+
bun test
39+
bun run build
40+
41+
- name: Publish package
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: npm publish --registry https://npm.pkg.github.com
45+
46+
VerifyInstall:
47+
name: Verify Registry Install
48+
runs-on: blacksmith-4vcpu-ubuntu-2404
49+
needs: Publish
50+
permissions:
51+
contents: read
52+
packages: read
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Setup Node
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: "20"
61+
62+
- name: Configure npm for GitHub Packages
63+
env:
64+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
npm config set @shpitdev:registry https://npm.pkg.github.com
67+
npm config set //npm.pkg.github.com/:_authToken "$NODE_AUTH_TOKEN"
68+
npm config set always-auth true
69+
70+
- name: Install published package
71+
env:
72+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
PACKAGE_NAME=$(node -p "require('./package.json').name")
75+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
76+
PACKAGE_REF="${PACKAGE_NAME}@${PACKAGE_VERSION}"
77+
78+
mkdir -p e2e-install
79+
cd e2e-install
80+
npm init -y
81+
82+
for attempt in 1 2 3 4 5 6; do
83+
if npm install "$PACKAGE_REF"; then
84+
break
85+
fi
86+
if [ "$attempt" -eq 6 ]; then
87+
echo "Failed to install $PACKAGE_REF after retries" >&2
88+
exit 1
89+
fi
90+
sleep 10
91+
done
92+
93+
- name: Run installed CLI binaries
94+
run: |
95+
cd e2e-install
96+
./node_modules/.bin/opencode-sandboxed-research-analyze --help
97+
./node_modules/.bin/opencode-sandboxed-research-start --help
98+
./node_modules/.bin/opencode-sandboxed-research-setup --help

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_modules/
1010
dist/
1111
coverage/
1212
.turbo/
13+
.memory/
1314

1415
# Logs
1516
*.log

.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.memory

README.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ This project automates Daytona sandbox setup and OpenCode execution.
2727

2828
- [What is this?](#what-is-this)
2929
- [Prerequisites](#prerequisites)
30+
- [Install On New Machine](#install-on-new-machine)
3031
- [Quick Start](#quick-start)
32+
- [Installer & Obsidian Cataloging](#installer--obsidian-cataloging)
3133
- [Commands](#commands)
3234
- [Repository Audit Workflow](#repository-audit-workflow)
3335
- [Output Layout](#output-layout)
@@ -42,6 +44,24 @@ This project automates Daytona sandbox setup and OpenCode execution.
4244
- `DAYTONA_API_KEY`
4345
- `DAYTONA_API_URL` for self-hosted Daytona (example: `https://daytona.example.com/api`)
4446
- Optional but recommended: `OPENCODE_SERVER_PASSWORD`
47+
- Optional: `obsidian` command in `PATH` (for Obsidian note cataloging/open)
48+
49+
---
50+
51+
## Install On New Machine
52+
53+
Use the bootstrap installer:
54+
55+
```bash
56+
curl -fsSL https://raw.githubusercontent.com/shpitdev/opencode-sandboxed-ad-hoc-research/main/scripts/install-gh-package.sh | bash
57+
```
58+
59+
It will:
60+
61+
- ask for (or reuse) a GitHub token with `read:packages`
62+
- configure `~/.npmrc` for GitHub Packages
63+
- install `@shpitdev/opencode-sandboxed-ad-hoc-research` globally
64+
- launch the guided setup flow for Daytona/model credentials
4565

4666
---
4767

@@ -58,13 +78,50 @@ Stop with `Ctrl+C`.
5878

5979
---
6080

81+
## Installer & Obsidian Cataloging
82+
83+
Run the guided installer:
84+
85+
```bash
86+
bun run setup
87+
```
88+
89+
It sets up:
90+
91+
- `~/.config/opencode/shpit.toml` for shared preferences
92+
- `~/.config/opencode/.env` for optional credential storage
93+
94+
No provider API key is required if you only use free `opencode/*` models (for example `opencode/minimax-m2.5-free`).
95+
96+
`analyze` automatically catalogs findings to Obsidian when enabled in `shpit.toml`.
97+
98+
Example config:
99+
100+
```toml
101+
[obsidian]
102+
enabled = true
103+
command = "obsidian"
104+
vault_path = "/absolute/path/to/vault"
105+
notes_root = "Research/OpenCode"
106+
catalog_mode = "date" # date | repo
107+
open_after_catalog = false
108+
```
109+
110+
Project-level `shpit.toml` or `.shpit.toml` overrides global config.
111+
The configured command must be `obsidian` (not `obs`).
112+
113+
---
114+
61115
## Commands
62116

63117
| Command | Purpose |
64118
|---|---|
119+
| `scripts/install-gh-package.sh` | Bootstrap install from GitHub Packages on a new machine |
120+
| `bun run setup` | Guided setup for shared config/env and Obsidian cataloging |
65121
| `bun run start` | Launch OpenCode web in a Daytona sandbox |
66122
| `bun run analyze -- --input example.md` | Analyze repos listed in a file |
67123
| `bun run analyze -- <url1> <url2>` | Analyze direct repo URLs |
124+
| `bun run build` | Compile distributable CLI files into `dist/` |
68125
| `bun run lint` | Lint with Biome |
69126
| `bun run format` | Format with Biome |
70127
| `bun run check` | Run Biome checks |
@@ -94,17 +151,22 @@ bun run start -- --no-open
94151

95152
### Defaults and behavior
96153

97-
- Default model: `opencode/gpt-5-nano`
154+
- Default model selection:
155+
- Standard: `zai-coding-plan/glm-4.7-flash`
156+
- Vision mode (`--vision`): `zai-coding-plan/glm-4.6v`
157+
- Override with `--model`, `--variant`, `OPENCODE_ANALYZE_MODEL`, or `OPENCODE_ANALYZE_VARIANT`
98158
- Auto-installs missing `git` and `node/npm` inside sandbox
99-
- Forwards provider env vars (`OPENAI_*`, `ANTHROPIC_*`, `XAI_*`, `OPENROUTER_*`, etc.)
159+
- Forwards provider env vars (`OPENAI_*`, `ANTHROPIC_*`, `XAI_*`, `OPENROUTER_*`, `ZHIPU_*`, `MINIMAX_*`, etc.)
100160
- Syncs local OpenCode config files from `~/.config/opencode` when present
161+
- Auto-catalogs findings into Obsidian when enabled via `shpit.toml`
101162

102163
### Examples
103164

104165
```bash
105166
bun run analyze -- --input example.md
106167
bun run analyze -- https://github.com/owner/repo-one https://github.com/owner/repo-two
107-
bun run analyze -- --out-dir findings --model openai/gpt-5 --target us
168+
bun run analyze -- --out-dir findings --model zai-coding-plan/glm-4.7-flash --target us
169+
bun run analyze -- --vision
108170
bun run analyze -- --analyze-timeout-sec 3600 --keep-sandbox
109171
```
110172

@@ -141,6 +203,7 @@ Project config files:
141203
- `biome.json`
142204
- `.zed/settings.json`
143205
- `.zed/tasks.json`
206+
- `tsconfig.build.json`
144207

145208
---
146209

bin/analyze.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import "../dist/analyze-repos.js";

bin/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import "../dist/install.js";

bin/start.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import "../dist/start-opencode-daytona.js";

0 commit comments

Comments
 (0)