Skip to content

Commit 87819c3

Browse files
TMFNKclaude
andcommitted
chore: add local development and sync tooling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f6ef68 commit 87819c3

5 files changed

Lines changed: 231 additions & 0 deletions

File tree

MODIFIED_FILES.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Modified Files for OpenCode Adapter
2+
3+
This file tracks all files modified from the original gstack repository for OpenCode
4+
compatibility. Use it as the conflict-resolution guide when syncing upstream changes.
5+
6+
## Path Changes
7+
8+
All references to `~/.claude/skills/gstack/` have been changed to
9+
`~/.config/opencode/skills/gstack/`.
10+
11+
## Modified Files
12+
13+
| File | Changes |
14+
| --- | --- |
15+
| `SKILL.md` | Updated preamble paths, tool names (`Bash→bash`, `Read→read`, `AskUserQuestion→question`), removed broken fallback path in preamble update-check, removed Claude-specific `mcp__claude-in-chrome__*` warning from browse section |
16+
| `AGENTS.md` | Replaces upstream `CLAUDE.md`. Added OpenCode skill discovery paths, fixed `/debug``/investigate`, added `/codex` to table, added OpenCode-specific notes. **Must be kept in sync with upstream `CLAUDE.md` on every merge.** |
17+
| `bin/dev-setup` | Original preserved; created `bin/dev-setup-opencode` with OpenCode paths |
18+
| `bin/dev-teardown` | Original preserved; created `bin/dev-teardown-opencode` with OpenCode paths |
19+
| `setup` | Added `opencode` as a valid `--host` value (alias for `claude` mode, same install path) |
20+
21+
## New Files (Adapter-Specific)
22+
23+
| File | Purpose |
24+
| --- | --- |
25+
| `README.md` | Replaced with OpenCode-specific installation and usage guide |
26+
| `gstack-version.txt` | Pinned upstream gstack version |
27+
| `MODIFIED_FILES.md` | This file — tracks modifications for upstream syncing |
28+
| `bin/dev-setup-opencode` | Development setup script for OpenCode |
29+
| `bin/dev-teardown-opencode` | Development teardown script for OpenCode |
30+
31+
## Upstream Sync Procedure
32+
33+
1. Before syncing: commit or stash any local adapter changes
34+
2. Run `./scripts/sync-upstream.sh` which does:
35+
* `git fetch upstream`
36+
* `git merge upstream/main` (not rebase — preserves history)
37+
3. Resolve conflicts using this file as a reference:
38+
* Files in the "Modified Files" table are expected to conflict — resolve by
39+
re-applying adapter patches
40+
* **Pay special attention to `AGENTS.md`**: it replaces upstream `CLAUDE.md`.
41+
If upstream adds instructions to `CLAUDE.md`, mirror those changes into `AGENTS.md`.
42+
* Files NOT in this table should merge cleanly — if they conflict, investigate
43+
4. If merge breaks the adapter: `git merge --abort` to restore pre-sync state
44+
5. Run the full test suite after every sync to verify nothing broke
45+
46+
## Version History
47+
48+
| Date | Upstream Version | Adapter Version | Notes |
49+
| --- | --- | --- | --- |
50+
| 2026-03-21 | 0.9.4.1 | 0.1.0 | Initial OpenCode adapter |
51+
| 2026-03-21 | 0.9.4.1 | 0.1.1 | Fix preamble fallback path, AskUserQuestion→question, /debug→/investigate, setup --host opencode, corrected skill paths in AGENTS.md |

bin/dev-setup-opencode

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# Set up gstack for local development — test skills from within this repo.
3+
#
4+
# Creates .config/opencode/skills/gstack → (symlink to repo root) so OpenCode
5+
# discovers skills from your working tree. Changes take effect immediately.
6+
#
7+
# Also copies .env from the main worktree if this is a Conductor workspace
8+
# or git worktree (so API keys carry over automatically).
9+
#
10+
# Usage: bin/dev-setup # set up
11+
# bin/dev-teardown # clean up
12+
set -e
13+
14+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
15+
16+
# 1. Copy .env from main worktree (if we're a worktree and don't have one)
17+
if [ ! -f "$REPO_ROOT/.env" ]; then
18+
MAIN_WORKTREE="$(git -C "$REPO_ROOT" worktree list --porcelain 2>/dev/null | head -1 | sed 's/^worktree //')"
19+
if [ -n "$MAIN_WORKTREE" ] && [ "$MAIN_WORKTREE" != "$REPO_ROOT" ] && [ -f "$MAIN_WORKTREE/.env" ]; then
20+
cp "$MAIN_WORKTREE/.env" "$REPO_ROOT/.env"
21+
echo "Copied .env from main worktree ($MAIN_WORKTREE)"
22+
fi
23+
fi
24+
25+
# 2. Install dependencies
26+
if [ ! -d "$REPO_ROOT/node_modules" ]; then
27+
echo "Installing dependencies..."
28+
(cd "$REPO_ROOT" && bun install)
29+
fi
30+
31+
# 3. Create .config/opencode/skills/ inside the repo
32+
mkdir -p "$REPO_ROOT/.config/opencode/skills"
33+
34+
# 4. Symlink .config/opencode/skills/gstack → repo root
35+
# This makes setup think it's inside a real .config/opencode/skills/ directory
36+
GSTACK_LINK="$REPO_ROOT/.config/opencode/skills/gstack"
37+
if [ -L "$GSTACK_LINK" ]; then
38+
echo "Updating existing symlink..."
39+
rm "$GSTACK_LINK"
40+
elif [ -d "$GSTACK_LINK" ]; then
41+
echo "Error: .config/opencode/skills/gstack is a real directory, not a symlink." >&2
42+
echo "Remove it manually if you want to use dev mode." >&2
43+
exit 1
44+
fi
45+
ln -s "$REPO_ROOT" "$GSTACK_LINK"
46+
47+
# 5. Create .agents/skills/gstack → repo root (for Codex/Gemini/Cursor)
48+
mkdir -p "$REPO_ROOT/.agents/skills"
49+
AGENTS_LINK="$REPO_ROOT/.agents/skills/gstack"
50+
if [ -L "$AGENTS_LINK" ]; then
51+
rm "$AGENTS_LINK"
52+
elif [ -d "$AGENTS_LINK" ]; then
53+
echo "Warning: .agents/skills/gstack is a real directory, skipping." >&2
54+
fi
55+
if [ ! -e "$AGENTS_LINK" ]; then
56+
ln -s "$REPO_ROOT" "$AGENTS_LINK"
57+
fi
58+
59+
# 6. Run setup via the symlink so it detects .config/opencode/skills/ as its parent
60+
"$GSTACK_LINK/setup"
61+
62+
echo ""
63+
echo "Dev mode active. Skills resolve from this working tree."
64+
echo " .config/opencode/skills/gstack → $REPO_ROOT"
65+
echo " .agents/skills/gstack → $REPO_ROOT"
66+
echo "Edit any SKILL.md and test immediately — no copy/deploy needed."
67+
echo ""
68+
echo "To tear down: bin/dev-teardown"

bin/dev-teardown-opencode

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Remove local dev skill symlinks. Restores global gstack as the active install.
3+
set -e
4+
5+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
7+
removed=()
8+
9+
# ─── Clean up .config/opencode/skills/ ─────────────────────────────────
10+
OPENCODE_SKILLS="$REPO_ROOT/.config/opencode/skills"
11+
if [ -d "$OPENCODE_SKILLS" ]; then
12+
for link in "$OPENCODE_SKILLS"/*/; do
13+
name="$(basename "$link")"
14+
[ "$name" = "gstack" ] && continue
15+
if [ -L "${link%/}" ]; then
16+
rm "${link%/}"
17+
removed+=("opencode/$name")
18+
fi
19+
done
20+
21+
if [ -L "$OPENCODE_SKILLS/gstack" ]; then
22+
rm "$OPENCODE_SKILLS/gstack"
23+
removed+=("opencode/gstack")
24+
fi
25+
26+
rmdir "$OPENCODE_SKILLS" 2>/dev/null || true
27+
rmdir "$REPO_ROOT/.config" 2>/dev/null || true
28+
fi
29+
30+
# ─── Clean up .agents/skills/ ────────────────────────────────
31+
AGENTS_SKILLS="$REPO_ROOT/.agents/skills"
32+
if [ -d "$AGENTS_SKILLS" ]; then
33+
for link in "$AGENTS_SKILLS"/*/; do
34+
name="$(basename "$link")"
35+
[ "$name" = "gstack" ] && continue
36+
if [ -L "${link%/}" ]; then
37+
rm "${link%/}"
38+
removed+=("agents/$name")
39+
fi
40+
done
41+
42+
if [ -L "$AGENTS_SKILLS/gstack" ]; then
43+
rm "$AGENTS_SKILLS/gstack"
44+
removed+=("agents/gstack")
45+
fi
46+
47+
rmdir "$AGENTS_SKILLS" 2>/dev/null || true
48+
rmdir "$REPO_ROOT/.agents" 2>/dev/null || true
49+
fi
50+
51+
if [ ${#removed[@]} -gt 0 ]; then
52+
echo "Removed: ${removed[*]}"
53+
else
54+
echo "No symlinks found."
55+
fi
56+
echo "Dev mode deactivated. Global gstack (~/.config/opencode/skills/gstack) is now active."

gstack-version.txt

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

scripts/sync-upstream.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
# Sync gstack-opencode-adapter with upstream gstack
3+
#
4+
# This script fetches the latest changes from the original gstack repository
5+
# and merges them into the current branch. Conflicts are expected in files
6+
# listed in MODIFIED_FILES.md.
7+
#
8+
# Usage: ./scripts/sync-upstream.sh
9+
set -e
10+
11+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
12+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13+
14+
cd "$REPO_ROOT"
15+
16+
# Check if upstream remote exists
17+
if ! git remote get-url upstream &>/dev/null; then
18+
echo "Adding upstream remote..."
19+
git remote add upstream https://github.com/garrytan/gstack.git
20+
fi
21+
22+
# Fetch upstream changes
23+
echo "Fetching upstream changes..."
24+
git fetch upstream
25+
26+
# Check if there are local changes
27+
if ! git diff-index --quiet HEAD --; then
28+
echo "Warning: You have uncommitted changes."
29+
echo "Please commit or stash them before syncing."
30+
exit 1
31+
fi
32+
33+
# Merge upstream changes
34+
echo "Merging upstream/main..."
35+
if git merge upstream/main --no-edit; then
36+
echo "Merge successful!"
37+
else
38+
echo ""
39+
echo "Merge conflicts detected. This is expected for files in MODIFIED_FILES.md."
40+
echo ""
41+
echo "Next steps:"
42+
echo "1. Resolve conflicts using MODIFIED_FILES.md as a reference"
43+
echo "2. Files in the 'Modified Files' table are expected to conflict"
44+
echo "3. Files NOT in that table should merge cleanly"
45+
echo ""
46+
echo "If you want to abort: git merge --abort"
47+
echo "After resolving: git add . && git commit"
48+
exit 1
49+
fi
50+
51+
echo ""
52+
echo "Sync complete. Current upstream version:"
53+
cat "$REPO_ROOT/VERSION"
54+
echo ""
55+
echo "Remember to update gstack-version.txt if needed."

0 commit comments

Comments
 (0)