mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 14:06:50 +01:00
* fix(make-pdf,design): real TOC page numbers and anchors; design models move to gpt-5.5 + gpt-image-2 (#2903, #2807) * ci: pin every action to a SHA, Scorecard, checksummed Bun, scoped Codex CLI in the CI image, macOS named-regressions job (#1948, #1706, #1997) * fix(cso,browse): Windows/macOS lease identity, retention skips bad runs, truthful 'not assessed' reports, env.kv false positive, Windows browse spawn fixes (#2894, #2912, #2048, #2637, #2805) * fix(outside-voice): one Codex model precedence for probe and dispatch, bounded timeouts with KILL escalation, probe cache identity, guarded mktemp, skills hidden in nested Codex (#2776, #2914, #2787, #2881, #2847) * feat(setup): install registry, ./setup --status, staged activation, per-scope migrations, host tiers and conformance kit, OpenCode/Hermes fixes, Copilot CLI (experimental), disabled_skills, slimmer CLAUDE.md (#1925, #2879, #2347, #2338, #2626, #2629, #2825, #2015, #393, #1206, #2096) Co-authored-by: Andrey Esipov <61357035+andrey-esipov@users.noreply.github.com> Co-authored-by: Matthew Williams <5863886+ridermw@users.noreply.github.com> Co-authored-by: Rocky Wu <92764750+lolisaigao1234@users.noreply.github.com> * fix(preamble): skills start in worktree-isolated Claude Code sessions — one literal skill-start line, context-recovery helper, no eval in skill blocks, $N token tripwire, honest plan-mode precedence (#2763, #2896, #2851) * fix(setup): per-install renders for renamed, vendored and custom-config installs, space-safe alias roots, per-host /cso launcher path (#1882, #2906) * test: free tests never write the real HOME (home-write tripwire), no orphaned browse daemons, symlinked-TMPDIR (macOS) fixes, gbrain-on-PATH isolation (#2895, #2816, #2829, #2841, #2982, #2911, #2909, #2908, #2910) * chore: integrate wave follow-ups — regenerate all hosts, README model docs, TODOS, touchfiles, duration seeds, Bun 1.3 telemetry test fix, replay fixtures pinned to their recorded bytes * v1.91.14.0: release metadata * test(browse): group-kill cleanup falls back to the leader when macOS returns EPERM for a live group * ci: Codex login steps run under bash (the CI container's default sh rejects pipefail) * fix: full-suite repairs — private state roots for 7 real-HOME writers, truthful home-guard attribution with --attribute-home, gstack-paths shim in ship-hook fixtures, Copilot in team-init probes, test-of-test detector, cookie review fixture pinned to the approved excerpt * fix(windows): LF for Dockerfiles, normalized home-guard exclusions, path.relative fixture containment, ship push test spawn timeouts * test(design-detect): widen the whole-scan budget test's timing margins so a loaded macOS runner can't time out the single-batch call * fix(evals): qa protocol names defined for the judge, async PTY judge so overlapping sessions keep their cleanup deadline, bws setup cases use the standard JUDGE_MS tier * test(pty): the non-blocking judge case is POSIX-only (its fake judge is a shebang script, like the PTY harness it covers) * test(evals): ship-coverage-audit names absolute skill paths, uses Read, and skips the Step 7 artifact nothing consumes (removes the mechanism behind 3 of 4 historical timeouts) * test: deflake terminal-agent concurrent startup (write the placeholder record before spawning, like the product) and qa-evidence resumed pipe (barrier on a full high-water mark instead of a sleep) * fix(design): daemon log stream handles open errors instead of crashing the daemon; shutdown test awaits the stubbed exit * test(evals): skillify checks the product's resolved state root (no GSTACK_HOME bypass), negative cases check every root; tpa shims live outside the agent's cwd and answer consistently * test(evals): coverage-audit detector splits parallel columns at │ rails and [+] groups; coverage prompts name absolute skill paths; TODOs from the gate eval census * fix(plan-eng-review): scope gate always sends the menu (no headless 'Scope pending' exit); PTY harness ends idle turn-ends and API-error panels promptly with a precise diagnostic * test(evals): one position-bound coverage-read rule credits read-only && chains (labels, context ranges, git displays in either order) and still rejects forged output * fix(ship): documentation section has one saved source inserted by cat (never retyped); spawned-marker evidence is the child output; refreshed codex/factory ship goldens * test(docsync): the byte-exact insert positive is POSIX-only (the bash-command observer refuses backslash paths by design) * test(evals): plan-design-with-ui focus-title rule accepts the comma-less 'dimensions or focus' wording (replayed on the captured CI run, negative controls kept) * fix(qa-callers): exploratory preflight says the scope/method Reads come after exploratory.md; design-review scan check credits an executed scan proven by one engine run over the changed files --------- Co-authored-by: Andrey Esipov <61357035+andrey-esipov@users.noreply.github.com> Co-authored-by: Matthew Williams <5863886+ridermw@users.noreply.github.com> Co-authored-by: Rocky Wu <92764750+lolisaigao1234@users.noreply.github.com>
217 lines
8.7 KiB
Bash
Executable File
217 lines
8.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-team-init — generate repo-level bootstrap files for team mode
|
|
#
|
|
# Usage:
|
|
# gstack-team-init optional # gentle CLAUDE.md suggestion, one-time offer
|
|
# gstack-team-init required # CLAUDE.md enforcement + PreToolUse hook
|
|
#
|
|
# Run from the root of your team's repo (not from the gstack directory).
|
|
|
|
# Heredoc delivery guard. bash 5.2+ writes a heredoc body <=64KiB through a
|
|
# pipe in the forked child before exec, with no reader on the other end. On
|
|
# macOS under pipe-KVA pressure a fresh pipe gets a 512-byte buffer, so any
|
|
# body >=512B blocks write() forever and the script hangs at startup with no
|
|
# output. Compat level 50 restores the tempfile path. These scripts are
|
|
# bash-3.2-clean, so the compat level costs them nothing. Not exported: the
|
|
# guard is per-script, and it survives `bash script.sh` call sites that
|
|
# bypass the shebang.
|
|
BASH_COMPAT=50
|
|
|
|
set -euo pipefail
|
|
|
|
MODE="${1:-}"
|
|
|
|
if [ "$MODE" != "optional" ] && [ "$MODE" != "required" ]; then
|
|
echo "Usage: gstack-team-init {optional|required}" >&2
|
|
echo "" >&2
|
|
echo " optional — suggest gstack install once per developer (gentle)" >&2
|
|
echo " required — enforce gstack install, block work without it" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Must be in a git repo
|
|
if ! git rev-parse --show-toplevel >/dev/null 2>&1; then
|
|
echo "Error: not in a git repository. Run from your project root." >&2
|
|
exit 1
|
|
fi
|
|
|
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
CLAUDE_MD="$REPO_ROOT/CLAUDE.md"
|
|
GENERATED=()
|
|
|
|
# ── Migrate vendored copy if present ──────────────────────────
|
|
|
|
if [ -d "$REPO_ROOT/.claude/skills/gstack" ] && [ ! -L "$REPO_ROOT/.claude/skills/gstack" ]; then
|
|
if [ -f "$REPO_ROOT/.claude/skills/gstack/VERSION" ] || [ -d "$REPO_ROOT/.claude/skills/gstack/.git" ]; then
|
|
echo " Found vendored gstack copy at $REPO_ROOT/.claude/skills/gstack"
|
|
echo " Team mode uses the global install — removing vendored copy..."
|
|
( cd "$REPO_ROOT" && git rm -r --cached .claude/skills/gstack/ 2>/dev/null ) || true
|
|
if [ -f "$REPO_ROOT/.gitignore" ]; then
|
|
if ! grep -qF '.claude/skills/gstack/' "$REPO_ROOT/.gitignore" 2>/dev/null; then
|
|
echo '.claude/skills/gstack/' >> "$REPO_ROOT/.gitignore"
|
|
fi
|
|
else
|
|
echo '.claude/skills/gstack/' > "$REPO_ROOT/.gitignore"
|
|
fi
|
|
rm -rf "$REPO_ROOT/.claude/skills/gstack"
|
|
GENERATED+=(".gitignore")
|
|
echo " Removed vendored copy and added .claude/skills/gstack/ to .gitignore"
|
|
fi
|
|
fi
|
|
|
|
# ── CLAUDE.md snippet ──────────────────────────────────────────
|
|
|
|
if [ "$MODE" = "optional" ]; then
|
|
SNIPPET='## gstack (recommended)
|
|
|
|
This project uses [gstack](https://github.com/garrytan/gstack) for AI-assisted workflows.
|
|
Install it for the best experience:
|
|
|
|
```bash
|
|
git clone --depth 1 https://github.com/garrytan/gstack.git ~/.claude/skills/gstack
|
|
cd ~/.claude/skills/gstack && ./setup --team
|
|
```
|
|
|
|
Skills like /qa, /ship, /review, /investigate, and /browse become available after install.
|
|
Use /browse for all web browsing (Aside first, the bundled gstack browser as fallback). Use ~/.claude/skills/gstack/... for gstack file paths.'
|
|
else
|
|
SNIPPET='## gstack (REQUIRED — global install)
|
|
|
|
**Before doing ANY work, verify gstack is installed:**
|
|
|
|
```bash
|
|
_GS=""
|
|
for _D in "${GSTACK_ROOT:-}" "$HOME/.claude/skills/gstack" "$HOME/.codex/skills/gstack" "$HOME/.factory/skills/gstack" "$HOME/.kiro/skills/gstack" "$HOME/.config/opencode/skills/gstack" "$HOME/.slate/skills/gstack" "$HOME/.cursor/skills/gstack" "$HOME/.openclaw/skills/gstack" "$HOME/.hermes/skills/gstack" "$HOME/.gbrain/skills/gstack" "$HOME/.copilot/skills/gstack" "$HOME/.gstack/repos/gstack"; do
|
|
[ -z "$_GS" ] && [ -n "$_D" ] && [ -d "$_D/bin" ] && _GS="$_D"
|
|
done
|
|
[ -n "$_GS" ] && echo "GSTACK_OK: $_GS" || echo "GSTACK_MISSING"
|
|
```
|
|
|
|
If GSTACK_MISSING: STOP. Do not proceed. Tell the user:
|
|
|
|
> gstack is required for all AI-assisted work in this repo.
|
|
> Install it:
|
|
> ```bash
|
|
> git clone --depth 1 https://github.com/garrytan/gstack.git ~/.claude/skills/gstack
|
|
> cd ~/.claude/skills/gstack && ./setup --team
|
|
> ```
|
|
> Then restart your AI coding tool.
|
|
|
|
Do not skip skills, ignore gstack errors, or work around missing gstack.
|
|
|
|
Using gstack skills: After install, skills like /qa, /ship, /review, /investigate,
|
|
and /browse are available. Use /browse for all web browsing (Aside first, the bundled gstack browser as fallback).
|
|
Use the resolved install path above for gstack file paths
|
|
(default: ~/.claude/skills/gstack).'
|
|
fi
|
|
|
|
# Check if CLAUDE.md already has a gstack section
|
|
if [ -f "$CLAUDE_MD" ] && grep -q "## gstack" "$CLAUDE_MD" 2>/dev/null; then
|
|
echo "CLAUDE.md already has a gstack section. Skipping CLAUDE.md update."
|
|
echo " To replace it, remove the existing ## gstack section and re-run."
|
|
else
|
|
if [ -f "$CLAUDE_MD" ]; then
|
|
echo "" >> "$CLAUDE_MD"
|
|
fi
|
|
echo "$SNIPPET" >> "$CLAUDE_MD"
|
|
GENERATED+=("CLAUDE.md")
|
|
echo " + CLAUDE.md — added gstack $MODE section"
|
|
fi
|
|
|
|
# ── Required mode: enforcement hook ────────────────────────────
|
|
|
|
if [ "$MODE" = "required" ]; then
|
|
HOOKS_DIR="$REPO_ROOT/.claude/hooks"
|
|
SETTINGS="$REPO_ROOT/.claude/settings.json"
|
|
|
|
# Create enforcement hook script
|
|
mkdir -p "$HOOKS_DIR"
|
|
cat > "$HOOKS_DIR/check-gstack.sh" << 'HOOK_EOF'
|
|
#!/bin/bash
|
|
# Block skill usage when gstack is not installed globally.
|
|
#
|
|
# Resolve the install root the way gstack skill preambles do: the GSTACK_ROOT
|
|
# env var first, then every host's global install location, then the migrated
|
|
# repo location. Block only when NONE exist (#2500 — hardcoding
|
|
# ~/.claude/skills/gstack false-blocked Codex-host and migrated-repo installs).
|
|
_GSTACK_ROOT=""
|
|
for _D in "${GSTACK_ROOT:-}" "$HOME/.claude/skills/gstack" "$HOME/.codex/skills/gstack" "$HOME/.factory/skills/gstack" "$HOME/.kiro/skills/gstack" "$HOME/.config/opencode/skills/gstack" "$HOME/.slate/skills/gstack" "$HOME/.cursor/skills/gstack" "$HOME/.openclaw/skills/gstack" "$HOME/.hermes/skills/gstack" "$HOME/.gbrain/skills/gstack" "$HOME/.copilot/skills/gstack" "$HOME/.gstack/repos/gstack"; do
|
|
[ -z "$_GSTACK_ROOT" ] && [ -n "$_D" ] && [ -d "$_D/bin" ] && _GSTACK_ROOT="$_D"
|
|
done
|
|
|
|
if [ -z "$_GSTACK_ROOT" ]; then
|
|
cat >&2 <<'MSG'
|
|
BLOCKED: gstack is not installed globally.
|
|
|
|
gstack is required for AI-assisted work in this repo.
|
|
|
|
Install it:
|
|
git clone --depth 1 https://github.com/garrytan/gstack.git ~/.claude/skills/gstack
|
|
cd ~/.claude/skills/gstack && ./setup --team
|
|
|
|
Then restart your AI coding tool.
|
|
MSG
|
|
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"gstack is required but not installed. See stderr for install instructions."}}'
|
|
exit 2
|
|
fi
|
|
|
|
echo '{}'
|
|
HOOK_EOF
|
|
chmod +x "$HOOKS_DIR/check-gstack.sh"
|
|
GENERATED+=(".claude/hooks/check-gstack.sh")
|
|
echo " + .claude/hooks/check-gstack.sh — enforcement hook"
|
|
|
|
# Add hook to project-level settings.json
|
|
if command -v bun >/dev/null 2>&1; then
|
|
GSTACK_SETTINGS_PATH="$SETTINGS" bun -e "
|
|
const fs = require('fs');
|
|
const settingsPath = process.env.GSTACK_SETTINGS_PATH;
|
|
|
|
let settings = {};
|
|
try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch {}
|
|
|
|
if (!settings.hooks) settings.hooks = {};
|
|
if (!settings.hooks.PreToolUse) settings.hooks.PreToolUse = [];
|
|
|
|
// Dedup
|
|
const exists = settings.hooks.PreToolUse.some(entry =>
|
|
entry.matcher === 'Skill' &&
|
|
entry.hooks && entry.hooks.some(h => h.command && h.command.includes('check-gstack'))
|
|
);
|
|
|
|
if (!exists) {
|
|
settings.hooks.PreToolUse.push({
|
|
matcher: 'Skill',
|
|
hooks: [{
|
|
type: 'command',
|
|
command: '\"\$CLAUDE_PROJECT_DIR/.claude/hooks/check-gstack.sh\"'
|
|
}]
|
|
});
|
|
}
|
|
|
|
const tmp = settingsPath + '.tmp';
|
|
fs.writeFileSync(tmp, JSON.stringify(settings, null, 2) + '\n');
|
|
fs.renameSync(tmp, settingsPath);
|
|
" 2>/dev/null
|
|
GENERATED+=(".claude/settings.json")
|
|
echo " + .claude/settings.json — PreToolUse hook registered"
|
|
else
|
|
echo " ! bun not found — manually add the PreToolUse hook to .claude/settings.json"
|
|
fi
|
|
fi
|
|
|
|
# ── Summary ────────────────────────────────────────────────────
|
|
|
|
echo ""
|
|
echo "Team mode ($MODE) initialized."
|
|
echo ""
|
|
if [ ${#GENERATED[@]} -gt 0 ]; then
|
|
echo "Commit the generated files:"
|
|
echo " git add ${GENERATED[*]}"
|
|
echo " git commit -m \"chore: require gstack for AI-assisted work\""
|
|
fi
|
|
echo ""
|
|
echo "Each developer then runs:"
|
|
echo " git clone --depth 1 https://github.com/garrytan/gstack.git ~/.claude/skills/gstack"
|
|
echo " cd ~/.claude/skills/gstack && ./setup --team"
|