diff --git a/.gitignore b/.gitignore index 979bc17c73..0e45c4d0e2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ bin/gstack-global-discover .cursor/ .openclaw/ .hermes/ +.forgecode/ .gbrain/ .context/ extension/.auth.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eeb30a19c..1091bfb3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,53 @@ # Changelog +## [1.29.1.0] - 2026-05-08 + +### Fixed +- **Forge Code skills now actually load.** The 1.29.0 install wrote skills to `~/.forgecode/skills/`, but Forge Code 2.x discovers user skills from `~/.agents/skills/`. `forge list skill` would report only the four built-in skills even after a clean install. Setup now installs to `~/.agents/skills/gstack-*` and the runtime root at `~/.agents/skills/gstack/`. Existing installs at the legacy `~/.forgecode/skills/` location are migrated (cleaned up) on the next `./setup --host forgecode` run. +- `hosts/forgecode.ts`: `globalRoot` and `pathRewrites` now point at `.agents/skills/gstack` so paths baked into generated SKILL.md files resolve at runtime. +- **Skill name matches parent directory.** Other harnesses that share `~/.agents/skills/` (notably `pi`) reject SKILL.md when the `name:` frontmatter doesn't match the parent directory. The install now copies (instead of symlinks) `SKILL.md` and patches the `name:` field to match `gstack-`. The build output under `.forgecode/skills/` is left unmodified so the freshness check still passes. +- `bin/gstack-patch-names`: pass `--color=never` to grep so colorized aliases don't poison the parsed name field. +- README + uninstall snippet updated to include `~/.agents/skills/gstack*`. + +## [1.29.0.0] - 2026-05-08 + +## **Forge Code is now a first-class gstack host. Run `./setup --host forgecode` and your skills land in `.forgecode/skills/`.** + +Forge Code joins the 10 existing supported agents. The install path is the same as OpenCode and Kiro: `./setup` auto-detects the `forge` binary, generates host-adapted SKILL.md files with Forge Code tool names and paths, creates the runtime root under `~/.forgecode/skills/gstack/`, and symlinks each generated skill into `~/.forgecode/skills/`. The `codex` skill is excluded (Forge Code users don't have the Codex CLI). All Claude-specific paths, tool references, and co-author trailers are rewritten for Forge Code conventions. + +The three numbers that matter (measured against the opencode install path as the reference implementation): + +Source: `diff --stat` against main + manual install verification in this environment. + +| Metric | Before | After | Δ | +|---|---|---|---| +| Supported hosts | 10 | 11 | +1 | +| Setup validation tests | 371 | 392 | +21 | +| Host config validations | 10 configs valid | 11 configs valid | +1 | + +One edge case fixed in auto-detection: `command -v forge` is ambiguous — Foundry (the Ethereum toolkit) also ships a `forge` binary. The auto-detect now uses `forge agent --help` as the discriminating check, which only succeeds for Forge Code. + +**What this means for Forge Code users:** Run `./setup --host forgecode` once, and you get the full gstack skill suite adapted to Forge Code's tool model (`shell`, `patch`, `fs_search`, `sage` instead of Claude tool names). Uninstall: `rm -rf ~/.forgecode/skills/gstack*`. + +### Itemized changes + +#### Added +- `hosts/forgecode.ts`: new `HostConfig` for Forge Code with path rewrites, tool name mapping, suppressed resolvers, runtime root definition, and co-author trailer +- `./setup --host forgecode`: full install path including auto-detection via `forge agent`, skill generation, runtime root setup, and symlink linking +- `.forgecode/` to `.gitignore` +- README: install and uninstall instructions for Forge Code + +#### Changed +- `hosts/index.ts`: Forge Code registered as the 11th host +- `scripts/skill-check.ts`: consolidated host imports at file top; `bun run skill:check` now respects primary-host `skipSkills` so Claude-only skipped templates don't produce false errors + +#### Fixed +- Auto-detection in `--host auto` mode now uses `forge agent --help` instead of bare `command -v forge`, preventing false-positive installs on machines with Foundry's `forge` binary + +#### For contributors +- `test/gen-skill-docs.test.ts`: 6 new tests for forgecode setup path, install flag vars, and runtime root structure +- `test/host-config.test.ts`: `ALL_HOST_CONFIGS` count bumped to 11; forgecode name asserted + ## [1.28.0.0] - 2026-05-07 ## **Browse handles real-world automation now: SOCKS5 with auth, container Xvfb, browser-native downloads. Plus a single-file `llms.txt` index agents can crawl in one read.** diff --git a/README.md b/README.md index dcab7cf213..0c6edea726 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ These are conversational skills. Your OpenClaw agent runs them directly via chat ### Other AI Agents -gstack works on 10 AI coding agents, not just Claude. Setup auto-detects which +gstack works on 11 AI coding agents, not just Claude. Setup auto-detects which agents you have installed: ```bash @@ -117,6 +117,7 @@ Or target a specific agent with `./setup --host `: | OpenCode | `--host opencode` | `~/.config/opencode/skills/gstack-*/` | | Cursor | `--host cursor` | `~/.cursor/skills/gstack-*/` | | Factory Droid | `--host factory` | `~/.factory/skills/gstack-*/` | +| Forge Code | `--host forgecode` | `~/.agents/skills/gstack-*/` | | Slate | `--host slate` | `~/.slate/skills/gstack-*/` | | Kiro | `--host kiro` | `~/.kiro/skills/gstack-*/` | | Hermes | `--host hermes` | `~/.hermes/skills/gstack-*/` | @@ -343,6 +344,8 @@ rm -rf ~/.codex/skills/gstack* 2>/dev/null rm -rf ~/.factory/skills/gstack* 2>/dev/null rm -rf ~/.kiro/skills/gstack* 2>/dev/null rm -rf ~/.openclaw/skills/gstack* 2>/dev/null +rm -rf ~/.forgecode/skills/gstack* 2>/dev/null +rm -rf ~/.agents/skills/gstack* 2>/dev/null # 6. Remove temp files rm -f /tmp/gstack-* 2>/dev/null diff --git a/VERSION b/VERSION index 06513fc212..441e79f47d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.28.0.0 +1.29.1.0 diff --git a/bin/gstack-patch-names b/bin/gstack-patch-names index bef02aae4c..91be5f2c5d 100755 --- a/bin/gstack-patch-names +++ b/bin/gstack-patch-names @@ -14,7 +14,7 @@ for skill_dir in "$GSTACK_DIR"/*/; do [ -f "$skill_dir/SKILL.md" ] || continue dir_name="$(basename "$skill_dir")" [ "$dir_name" = "node_modules" ] && continue - cur=$(grep -m1 '^name:' "$skill_dir/SKILL.md" 2>/dev/null | sed 's/^name:[[:space:]]*//' | tr -d '[:space:]' || true) + cur=$(grep --color=never -m1 '^name:' "$skill_dir/SKILL.md" 2>/dev/null | sed 's/^name:[[:space:]]*//' | tr -d '[:space:]' || true) [ -z "$cur" ] && continue [ "$cur" = "gstack" ] && continue # never prefix root skill if [ "$DO_PREFIX" -eq 1 ]; then diff --git a/hosts/forgecode.ts b/hosts/forgecode.ts new file mode 100644 index 0000000000..32fca46c18 --- /dev/null +++ b/hosts/forgecode.ts @@ -0,0 +1,73 @@ +import type { HostConfig } from '../scripts/host-config'; + +const forgecode: HostConfig = { + name: 'forgecode', + displayName: 'Forge Code', + cliCommand: 'forge', + cliAliases: ['forge-code'], + + // Forge Code 2.x discovers user skills from ~/.agents/skills/. The repo-side + // build output stays under .forgecode/ (see hostSubdir) but the install path + // (globalRoot) and embedded SKILL.md path references must point at the real + // discovery location. + globalRoot: '.agents/skills/gstack', + localSkillRoot: '.agents/skills/gstack', + hostSubdir: '.forgecode', + usesEnvVars: true, + + frontmatter: { + mode: 'allowlist', + keepFields: ['name', 'description'], + descriptionLimit: null, + }, + + generation: { + generateMetadata: false, + skipSkills: ['codex'], + }, + + pathRewrites: [ + { from: '~/.claude/skills/gstack', to: '~/.agents/skills/gstack' }, + { from: '.claude/skills/gstack', to: '.agents/skills/gstack' }, + { from: '.claude/skills', to: '.agents/skills' }, + { from: 'CLAUDE.md', to: 'AGENTS.md' }, + ], + toolRewrites: { + 'use the Bash tool': 'use the shell tool', + 'use the Write tool': 'use the patch tool', + 'use the Edit tool': 'use the patch tool', + 'use the Agent tool': 'use the sage tool', + 'use the Grep tool': 'use the fs_search tool', + 'use the Glob tool': 'use the fs_search tool', + 'the Bash tool': 'the shell tool', + 'the Write tool': 'the patch tool', + 'the Edit tool': 'the patch tool', + }, + + suppressedResolvers: [ + 'DESIGN_OUTSIDE_VOICES', + 'ADVERSARIAL_STEP', + 'CODEX_SECOND_OPINION', + 'CODEX_PLAN_REVIEW', + 'REVIEW_ARMY', + 'GBRAIN_CONTEXT_LOAD', + 'GBRAIN_SAVE_RESULTS', + ], + + runtimeRoot: { + globalSymlinks: ['bin', 'browse/dist', 'browse/bin', 'design/dist', 'gstack-upgrade', 'ETHOS.md', 'review/specialists', 'qa/templates', 'qa/references', 'plan-devex-review/dx-hall-of-fame.md'], + globalFiles: { + 'review': ['checklist.md', 'design-checklist.md', 'greptile-triage.md', 'TODOS-format.md'], + }, + }, + + install: { + prefixable: false, + linkingStrategy: 'symlink-generated', + }, + + coAuthorTrailer: 'Co-Authored-By: Forge Code ', + learningsMode: 'basic', +}; + +export default forgecode; diff --git a/hosts/index.ts b/hosts/index.ts index cc1c213b53..a59397fee1 100644 --- a/hosts/index.ts +++ b/hosts/index.ts @@ -16,9 +16,10 @@ import cursor from './cursor'; import openclaw from './openclaw'; import hermes from './hermes'; import gbrain from './gbrain'; +import forgecode from './forgecode'; /** All registered host configs. Add new hosts here. */ -export const ALL_HOST_CONFIGS: HostConfig[] = [claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain]; +export const ALL_HOST_CONFIGS: HostConfig[] = [claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain, forgecode]; /** Map from host name to config. */ export const HOST_CONFIG_MAP: Record = Object.fromEntries( @@ -65,4 +66,4 @@ export function getExternalHosts(): HostConfig[] { } // Re-export individual configs for direct import -export { claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain }; +export { claude, codex, factory, kiro, opencode, slate, cursor, openclaw, hermes, gbrain, forgecode }; diff --git a/package.json b/package.json index 219e3a3d20..808fbfbbda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.28.0.0", + "version": "1.29.1.0", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/scripts/skill-check.ts b/scripts/skill-check.ts index 9182737ee1..f85042b2af 100644 --- a/scripts/skill-check.ts +++ b/scripts/skill-check.ts @@ -13,6 +13,7 @@ import { discoverTemplates, discoverSkillFiles } from './discover-skills'; import * as fs from 'fs'; import * as path from 'path'; import { execSync } from 'child_process'; +import { ALL_HOST_CONFIGS, getExternalHosts, getHostConfig } from '../hosts/index'; const ROOT = path.resolve(import.meta.dir, '..'); const ROOT_REALPATH = fs.realpathSync(ROOT); @@ -72,6 +73,12 @@ for (const { tmpl, output } of TEMPLATES) { console.log(` \u26a0\ufe0f ${output.padEnd(30)} — no template`); continue; } + const primaryHost = getHostConfig('claude'); + const skillDir = output === 'SKILL.md' ? '.' : output.split('/')[0]; + if (primaryHost.generation.skipSkills?.includes(skillDir)) { + console.log(` - ${output.padEnd(30)} — skipped for ${primaryHost.displayName}`); + continue; + } if (!fs.existsSync(outPath)) { hasErrors = true; console.log(` \u274c ${output.padEnd(30)} — generated file missing! Run: bun run gen:skill-docs`); @@ -90,8 +97,6 @@ for (const file of SKILL_FILES) { // ─── External Host Skills (config-driven) ─────────────────── -import { getExternalHosts } from '../hosts/index'; - for (const hostConfig of getExternalHosts()) { const hostDir = path.join(ROOT, hostConfig.hostSubdir, 'skills'); if (fs.existsSync(hostDir)) { @@ -130,8 +135,6 @@ for (const hostConfig of getExternalHosts()) { // ─── Freshness (config-driven) ────────────────────────────── -import { ALL_HOST_CONFIGS } from '../hosts/index'; - for (const hostConfig of ALL_HOST_CONFIGS) { const hostFlag = hostConfig.name === 'claude' ? '' : ` --host ${hostConfig.name}`; console.log(`\n Freshness (${hostConfig.displayName}):`); diff --git a/setup b/setup index 4c1763f9fd..b5bac1f2ab 100755 --- a/setup +++ b/setup @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# gstack setup — build browser binary + register skills with Claude Code / Codex +# gstack setup — build browser binary + register skills with Claude Code / Codex / Forge Code set -e umask 077 # Restrict new files to owner-only (0o600 files, 0o700 dirs) @@ -24,6 +24,9 @@ FACTORY_SKILLS="$HOME/.factory/skills" FACTORY_GSTACK="$FACTORY_SKILLS/gstack" OPENCODE_SKILLS="$HOME/.config/opencode/skills" OPENCODE_GSTACK="$OPENCODE_SKILLS/gstack" +FORGECODE_SKILLS="$HOME/.agents/skills" +FORGECODE_GSTACK="$FORGECODE_SKILLS/gstack" +FORGECODE_LEGACY_SKILLS="$HOME/.forgecode/skills" IS_WINDOWS=0 case "$(uname -s)" in @@ -43,7 +46,7 @@ TEAM_MODE=0 NO_TEAM_MODE=0 while [ $# -gt 0 ]; do case "$1" in - --host) [ -z "$2" ] && echo "Missing value for --host (expected claude, codex, kiro, factory, opencode, openclaw, hermes, gbrain, or auto)" >&2 && exit 1; HOST="$2"; shift 2 ;; + --host) [ -z "$2" ] && echo "Missing value for --host (expected claude, codex, kiro, factory, opencode, forgecode, openclaw, hermes, gbrain, or auto)" >&2 && exit 1; HOST="$2"; shift 2 ;; --host=*) HOST="${1#--host=}"; shift ;; --local) LOCAL_INSTALL=1; shift ;; --prefix) SKILL_PREFIX=1; SKILL_PREFIX_FLAG=1; shift ;; @@ -56,7 +59,7 @@ while [ $# -gt 0 ]; do done case "$HOST" in - claude|codex|kiro|factory|opencode|auto) ;; + claude|codex|kiro|factory|opencode|forgecode|auto) ;; openclaw) echo "" echo "OpenClaw integration uses a different model — OpenClaw spawns Claude Code" @@ -91,7 +94,7 @@ case "$HOST" in echo "GBrain setup and brain skills ship from the GBrain repo." echo "" exit 0 ;; - *) echo "Unknown --host value: $HOST (expected claude, codex, kiro, factory, opencode, openclaw, hermes, gbrain, or auto)" >&2; exit 1 ;; + *) echo "Unknown --host value: $HOST (expected claude, codex, kiro, factory, opencode, forgecode, openclaw, hermes, gbrain, or auto)" >&2; exit 1 ;; esac # ─── Resolve skill prefix preference ───────────────────────── @@ -155,14 +158,16 @@ INSTALL_CODEX=0 INSTALL_KIRO=0 INSTALL_FACTORY=0 INSTALL_OPENCODE=0 +INSTALL_FORGECODE=0 if [ "$HOST" = "auto" ]; then command -v claude >/dev/null 2>&1 && INSTALL_CLAUDE=1 command -v codex >/dev/null 2>&1 && INSTALL_CODEX=1 command -v kiro-cli >/dev/null 2>&1 && INSTALL_KIRO=1 command -v droid >/dev/null 2>&1 && INSTALL_FACTORY=1 command -v opencode >/dev/null 2>&1 && INSTALL_OPENCODE=1 + forge agent --help >/dev/null 2>&1 && INSTALL_FORGECODE=1 # If none found, default to claude - if [ "$INSTALL_CLAUDE" -eq 0 ] && [ "$INSTALL_CODEX" -eq 0 ] && [ "$INSTALL_KIRO" -eq 0 ] && [ "$INSTALL_FACTORY" -eq 0 ] && [ "$INSTALL_OPENCODE" -eq 0 ]; then + if [ "$INSTALL_CLAUDE" -eq 0 ] && [ "$INSTALL_CODEX" -eq 0 ] && [ "$INSTALL_KIRO" -eq 0 ] && [ "$INSTALL_FACTORY" -eq 0 ] && [ "$INSTALL_OPENCODE" -eq 0 ] && [ "$INSTALL_FORGECODE" -eq 0 ]; then INSTALL_CLAUDE=1 fi elif [ "$HOST" = "claude" ]; then @@ -175,6 +180,8 @@ elif [ "$HOST" = "factory" ]; then INSTALL_FACTORY=1 elif [ "$HOST" = "opencode" ]; then INSTALL_OPENCODE=1 +elif [ "$HOST" = "forgecode" ]; then + INSTALL_FORGECODE=1 fi migrate_direct_codex_install() { @@ -321,6 +328,16 @@ if [ "$INSTALL_OPENCODE" -eq 1 ] && [ "$NEEDS_BUILD" -eq 0 ]; then ) fi +# 1e. Generate .forgecode/ Forge Code skill docs +if [ "$INSTALL_FORGECODE" -eq 1 ] && [ "$NEEDS_BUILD" -eq 0 ]; then + log "Generating .forgecode/ skill docs..." + ( + cd "$SOURCE_GSTACK_DIR" + bun install --frozen-lockfile 2>/dev/null || bun install + bun run gen:skill-docs --host forgecode + ) +fi + # 2. Ensure Playwright's Chromium is available if ! ensure_playwright_browser; then echo "Installing Playwright Chromium..." @@ -699,6 +716,59 @@ create_opencode_runtime_root() { fi } +create_forgecode_runtime_root() { + local gstack_dir="$1" + local forgecode_gstack="$2" + local forgecode_dir="$gstack_dir/.forgecode/skills" + + if [ -L "$forgecode_gstack" ]; then + rm -f "$forgecode_gstack" + elif [ -d "$forgecode_gstack" ] && [ "$forgecode_gstack" != "$gstack_dir" ]; then + rm -rf "$forgecode_gstack" + fi + + mkdir -p "$forgecode_gstack" "$forgecode_gstack/browse" "$forgecode_gstack/design" "$forgecode_gstack/gstack-upgrade" "$forgecode_gstack/review" "$forgecode_gstack/qa" "$forgecode_gstack/plan-devex-review" + + if [ -f "$forgecode_dir/gstack/SKILL.md" ]; then + ln -snf "$forgecode_dir/gstack/SKILL.md" "$forgecode_gstack/SKILL.md" + fi + if [ -d "$gstack_dir/bin" ]; then + ln -snf "$gstack_dir/bin" "$forgecode_gstack/bin" + fi + if [ -d "$gstack_dir/browse/dist" ]; then + ln -snf "$gstack_dir/browse/dist" "$forgecode_gstack/browse/dist" + fi + if [ -d "$gstack_dir/browse/bin" ]; then + ln -snf "$gstack_dir/browse/bin" "$forgecode_gstack/browse/bin" + fi + if [ -d "$gstack_dir/design/dist" ]; then + ln -snf "$gstack_dir/design/dist" "$forgecode_gstack/design/dist" + fi + if [ -f "$forgecode_dir/gstack-upgrade/SKILL.md" ]; then + ln -snf "$forgecode_dir/gstack-upgrade/SKILL.md" "$forgecode_gstack/gstack-upgrade/SKILL.md" + fi + for f in checklist.md design-checklist.md greptile-triage.md TODOS-format.md; do + if [ -f "$gstack_dir/review/$f" ]; then + ln -snf "$gstack_dir/review/$f" "$forgecode_gstack/review/$f" + fi + done + if [ -d "$gstack_dir/review/specialists" ]; then + ln -snf "$gstack_dir/review/specialists" "$forgecode_gstack/review/specialists" + fi + if [ -d "$gstack_dir/qa/templates" ]; then + ln -snf "$gstack_dir/qa/templates" "$forgecode_gstack/qa/templates" + fi + if [ -d "$gstack_dir/qa/references" ]; then + ln -snf "$gstack_dir/qa/references" "$forgecode_gstack/qa/references" + fi + if [ -f "$gstack_dir/plan-devex-review/dx-hall-of-fame.md" ]; then + ln -snf "$gstack_dir/plan-devex-review/dx-hall-of-fame.md" "$forgecode_gstack/plan-devex-review/dx-hall-of-fame.md" + fi + if [ -f "$gstack_dir/ETHOS.md" ]; then + ln -snf "$gstack_dir/ETHOS.md" "$forgecode_gstack/ETHOS.md" + fi +} + link_factory_skill_dirs() { local gstack_dir="$1" local skills_dir="$2" @@ -763,6 +833,67 @@ link_opencode_skill_dirs() { fi } +link_forgecode_skill_dirs() { + local gstack_dir="$1" + local skills_dir="$2" + local forgecode_dir="$gstack_dir/.forgecode/skills" + local linked=() + + if [ ! -d "$forgecode_dir" ]; then + echo " Generating .forgecode/ skill docs..." + ( cd "$gstack_dir" && bun run gen:skill-docs --host forgecode ) + fi + + if [ ! -d "$forgecode_dir" ]; then + echo " warning: .forgecode/skills/ generation failed — run 'bun run gen:skill-docs --host forgecode' manually" >&2 + return 1 + fi + + for skill_dir in "$forgecode_dir"/gstack*/; do + if [ -f "$skill_dir/SKILL.md" ]; then + skill_name="$(basename "$skill_dir")" + [ "$skill_name" = "gstack" ] && continue + target="$skills_dir/$skill_name" + # Forge Code's skill discovery does not follow top-level symlinked + # directories — only real directories whose immediate child is SKILL.md + # are picked up. Mirror the Claude install pattern: real dir + SKILL.md + # inside. We COPY (not symlink) SKILL.md so the install can patch the + # `name:` field to match the prefixed parent directory without mutating + # the build output (which would break the freshness check). + if [ -L "$target" ]; then + rm -f "$target" + fi + mkdir -p "$target" + if [ -L "$target/SKILL.md" ] || [ -e "$target/SKILL.md" ]; then + rm -f "$target/SKILL.md" + fi + cp "$skill_dir/SKILL.md" "$target/SKILL.md" + linked+=("$skill_name") + fi + done + + # Patch name: frontmatter in the INSTALLED copies so each name matches its + # prefixed parent directory. Forge Code is lenient about the mismatch but + # other harnesses that share ~/.agents/skills/ (e.g. pi) reject it as a + # conflict. Only touch our own gstack-* entries; leave any sibling skills + # (find-skills, etc.) alone. Build output under .forgecode/skills/ stays + # unmodified. + for _name in "${linked[@]}"; do + _target_md="$skills_dir/$_name/SKILL.md" + [ -f "$_target_md" ] || continue + _cur=$(grep --color=never -m1 '^name:' "$_target_md" 2>/dev/null | sed 's/^name:[[:space:]]*//' | tr -d '[:space:]' || true) + [ -z "$_cur" ] && continue + [ "$_cur" = "$_name" ] && continue + case "$_cur" in gstack-*) continue ;; esac + _tmp="$(mktemp "${_target_md}.XXXXXX")" + sed "1,/^---$/s/^name:[[:space:]]*${_cur}\$/name: ${_name}/" "$_target_md" > "$_tmp" && mv "$_tmp" "$_target_md" + done + + if [ ${#linked[@]} -gt 0 ]; then + echo " linked skills: ${linked[*]}" + fi +} + # 4. Install for Claude (default) SKILLS_BASENAME="$(basename "$INSTALL_SKILLS_DIR")" SKILLS_PARENT_BASENAME="$(basename "$(dirname "$INSTALL_SKILLS_DIR")")" @@ -935,6 +1066,45 @@ if [ "$INSTALL_OPENCODE" -eq 1 ]; then echo " opencode skills: $OPENCODE_SKILLS" fi +# 6d. Install for Forge Code +if [ "$INSTALL_FORGECODE" -eq 1 ]; then + # Migration: Forge Code 2.x reads user skills from ~/.agents/skills/, not + # ~/.forgecode/skills/. Clean up any prior gstack install at the legacy + # path so `forge list skill` doesn't see stale entries. + if [ -d "$FORGECODE_LEGACY_SKILLS" ]; then + _forge_legacy_removed=() + for _legacy in "$FORGECODE_LEGACY_SKILLS"/gstack "$FORGECODE_LEGACY_SKILLS"/gstack-*; do + [ -e "$_legacy" ] || [ -L "$_legacy" ] || continue + # Only remove entries that point into a gstack repo (avoid nuking unrelated content). + if [ -L "$_legacy" ]; then + _legacy_target="$(readlink "$_legacy" 2>/dev/null || true)" + case "$_legacy_target" in *gstack*|*".forgecode/skills"*) rm -f "$_legacy"; _forge_legacy_removed+=("$(basename "$_legacy")") ;; esac + elif [ -d "$_legacy" ]; then + if [ -L "$_legacy/SKILL.md" ]; then + _legacy_target="$(readlink "$_legacy/SKILL.md" 2>/dev/null || true)" + case "$_legacy_target" in *gstack*) rm -rf "$_legacy"; _forge_legacy_removed+=("$(basename "$_legacy")") ;; esac + elif [ -f "$_legacy/SKILL.md" ] && grep -q 'gstack' "$_legacy/SKILL.md" 2>/dev/null; then + rm -rf "$_legacy" + _forge_legacy_removed+=("$(basename "$_legacy")") + fi + fi + done + if [ ${#_forge_legacy_removed[@]} -gt 0 ]; then + log " migrated legacy Forge Code install (~/.forgecode/skills/): removed ${_forge_legacy_removed[*]}" + fi + # Remove the legacy parent dir if it's now empty + rmdir "$FORGECODE_LEGACY_SKILLS" 2>/dev/null || true + rmdir "$HOME/.forgecode" 2>/dev/null || true + fi + + mkdir -p "$FORGECODE_SKILLS" + create_forgecode_runtime_root "$SOURCE_GSTACK_DIR" "$FORGECODE_GSTACK" + link_forgecode_skill_dirs "$SOURCE_GSTACK_DIR" "$FORGECODE_SKILLS" + echo "gstack ready (forgecode)." + echo " browse: $BROWSE_BIN" + echo " forgecode skills: $FORGECODE_SKILLS" +fi + # 7. Create .agents/ sidecar symlinks for the real Codex skill target. # The root Codex skill ends up pointing at $SOURCE_GSTACK_DIR/.agents/skills/gstack, # so the runtime assets must live there for both global and repo-local installs. diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.ts index 86cdac953b..883321a351 100644 --- a/test/gen-skill-docs.test.ts +++ b/test/gen-skill-docs.test.ts @@ -2247,16 +2247,19 @@ describe('setup script validation', () => { expect(fnBody).toContain('rm -f "$target"'); }); - test('setup supports --host auto|claude|codex|kiro|opencode', () => { + test('setup supports --host auto|claude|codex|kiro|opencode|forgecode', () => { expect(setupContent).toContain('--host'); - expect(setupContent).toContain('claude|codex|kiro|factory|opencode|auto'); + expect(setupContent).toContain('claude|codex|kiro|factory|opencode|forgecode|auto'); }); - test('auto mode detects claude, codex, kiro, and opencode binaries', () => { + test('auto mode detects claude, codex, kiro, opencode, and forge binaries', () => { expect(setupContent).toContain('command -v claude'); expect(setupContent).toContain('command -v codex'); expect(setupContent).toContain('command -v kiro-cli'); expect(setupContent).toContain('command -v opencode'); + // forge binary detection uses a discriminating subcommand check to distinguish + // Forge Code from Foundry's forge (both named 'forge'); only Forge Code has 'forge agent' + expect(setupContent).toContain('forge agent --help'); }); // T1: Sidecar skip guard — prevents .agents/skills/gstack from being linked as a skill @@ -2298,6 +2301,23 @@ describe('setup script validation', () => { expect(setupContent).toContain('dx-hall-of-fame.md'); }); + test('setup supports --host forgecode with install section and Forge Code skill path vars', () => { + expect(setupContent).toContain('INSTALL_FORGECODE='); + expect(setupContent).toContain('FORGECODE_SKILLS="$HOME/.agents/skills"'); + expect(setupContent).toContain('FORGECODE_GSTACK="$FORGECODE_SKILLS/gstack"'); + // Migration from legacy ~/.forgecode/skills/ install path + expect(setupContent).toContain('FORGECODE_LEGACY_SKILLS="$HOME/.forgecode/skills"'); + }); + + test('setup installs Forge Code skills into a nested gstack runtime root', () => { + expect(setupContent).toContain('create_forgecode_runtime_root'); + expect(setupContent).toContain('.forgecode/skills'); + expect(setupContent).toContain('review/specialists'); + expect(setupContent).toContain('qa/templates'); + expect(setupContent).toContain('qa/references'); + expect(setupContent).toContain('dx-hall-of-fame.md'); + }); + test('create_agents_sidecar links runtime assets', () => { // Sidecar must link bin, browse, review, qa const fnStart = setupContent.indexOf('create_agents_sidecar()'); diff --git a/test/host-config.test.ts b/test/host-config.test.ts index 5770570332..4edfb2e82d 100644 --- a/test/host-config.test.ts +++ b/test/host-config.test.ts @@ -22,6 +22,7 @@ import { slate, cursor, openclaw, + forgecode, } from '../hosts/index'; import { HOST_PATHS } from '../scripts/resolvers/types'; @@ -30,8 +31,8 @@ const ROOT = path.resolve(import.meta.dir, '..'); // ─── hosts/index.ts ───────────────────────────────────────── describe('hosts/index.ts', () => { - test('ALL_HOST_CONFIGS has 10 hosts', () => { - expect(ALL_HOST_CONFIGS.length).toBe(10); + test('ALL_HOST_CONFIGS has 11 hosts', () => { + expect(ALL_HOST_CONFIGS.length).toBe(11); }); test('ALL_HOST_NAMES matches config names', () => { @@ -53,6 +54,7 @@ describe('hosts/index.ts', () => { expect(slate.name).toBe('slate'); expect(cursor.name).toBe('cursor'); expect(openclaw.name).toBe('openclaw'); + expect(forgecode.name).toBe('forgecode'); }); test('getHostConfig returns correct config', () => {