// Generated by scripts/gen-skills.py from skills/; do not edit.
// Regenerate with `make skills` or `python3 scripts/gen-skills.py`.

///|
let skill_group_0 : Array[SkillFile] = [
  {
    skill: "serbox",
    path: "SKILL.md",
    body: "---\nname: serbox\ndescription: Use when the user wants an isolated Linux box on this server with the `serbox` CLI - create, exec or shell into, copy files, run background jobs, publish a port, save or restore a snapshot, pause and resume, set secrets, use a remote server, or delete the box.\nmetadata:\n  installed-by: serbox\n---\n\n# serbox CLI\n\n`serbox` runs disposable Linux boxes as Docker containers on the machine where it\nis installed. There is no account and no hosted service: `serbox` talks to the\nlocal Docker daemon, keeps its state under `~/.serbox` (override with\n`SERBOX_HOME`), and works the same on any Linux server.\n\nA box has a writable root filesystem and a persistent `/data` disk. `HOME` is\n`/data/home`, so files under `/data` survive pause, resume, snapshot and fork.\nEach box is its own container; processes, installed packages and files stay\ninside it. Everything the CLI prints is meant for an agent: add `--json` for a\nmachine-readable document.\n\nSafety rules to state before acting:\n\n- `serbox rm NAME` deletes the container and its `/data`. Save a snapshot\n  first if the box matters.\n- `serbox port publish` exposes a container port on this host. Anyone who can\n  reach the host and port can use it; use `--private` to bind loopback only.\n- Secrets are plain environment variables inside the box; code running there\n  can read them.\n\n## Create and inspect\n\n```sh\nserbox create --name work --template alpine       # fast, small\nserbox create --name work --template ubuntu --publish 3000 --secrets TOKEN\nserbox ls                                         # state, template, age\nserbox get work --json                            # one box as JSON\nserbox templates                                  # known image aliases\nserbox doctor                                     # Docker and state checks\n```\n\n`create` waits until the box accepts commands unless `--no-wait` is given.\n`--setup-file PATH` runs a script after creation; `--env K=V`, `--secrets NAME`,\n`--publish PORT` and `--auto-suspend 30m` are also accepted. Names are\nlowercase letters, digits and `-`, at most 63 characters.\n\n## Run commands\n\n```sh\nserbox exec work -- uname -a                      # exact argv\nserbox exec work -- 'apt-get update && apt-get install -y git'   # one string: shell\nserbox exec work --stdin -- 'cat > /data/note'     # pipe stdin\nserbox exec work --timeout 120 -- ./build.sh       # 1..600 seconds\nserbox exec work --json -- 'echo hi'               # stdout, stderr, exitCode\nserbox shell work                                  # interactive shell\nserbox ssh work                                    # same, for muscle memory\n```\n\nExit codes are the command's own; 124 means `--timeout` expired, 130 means\ninterrupted. Use `--workdir DIR` and `--env K=V` for one command.\n\n## Files and secrets\n\n```sh\nserbox push work ./src /data/home/src              # local -> box\nserbox pull work /data/home/src ./src              # box -> local\nserbox files work /data/home                       # list\nserbox cp work:/data/home/a.txt ./a.txt            # either direction\n```\n\n`cp` accepts `BOX:/path` on one side and a local path on the other.\n\n```sh\nprintf '%s' \"$TOKEN\" | serbox secrets set GITHUB_TOKEN\nserbox secrets ls                                  # names only, never values\nserbox secrets push work                           # /data/.serbox/secrets.env, mode 0600\nserbox create --name work2 --secrets GITHUB_TOKEN\n```\n\nNever echo a secret value into logs or commit it. To use a secret in a later\n`exec`, pass `--env NAME` (it reads the stored value) or source\n`/data/.serbox/secrets.env` inside the box.\n\n## Background jobs\n\n```sh\nserbox exec work --background -- 'make test > /data/test.log 2>&1'\nserbox jobs ls work\nserbox jobs logs work JOB_ID --follow\nserbox jobs wait work JOB_ID --timeout 600\nserbox jobs kill work JOB_ID --signal TERM\n```\n\n`--background` prints the job id. Jobs keep running inside the box after the\nCLI exits; `jobs wait` returns the job's exit code.\n\n## Ports\n\n```sh\nserbox port publish work 3000                     # host picks a free port\nserbox port publish work 3000 --host 8080 --private\nserbox port ls\nserbox port unpublish work 3000\n```\n\nA forwarder runs on the host and connects to the container address. It stops\nwhen the box is removed or the port is unpublished.\n\n## Pause, snapshot, remove\n\n```sh\nserbox suspend work            # processes stop, disks stay\nserbox resume work\nserbox stop work               # stop the container\nserbox start work\nserbox snapshot save work --name work-ready\nserbox snapshot ls\nserbox fork work --name work2 --count 2\nserbox rename work work-old\nserbox rm work --yes\n```\n\n`fork` copies the box's disks; `snapshot restore` copies a snapshot into an\nexisting box (its current `/data` is replaced). `--root-only` is not\nimplemented: serbox snapshots always include `/data`.\n\nSee the `serbox-snapshots` skill for the full snapshot workflow, and\n`serbox-move-repo` / `serbox-basic-setup` for moving a repository or dotfiles\ninto a box.\n\n## Remote servers\n\n```sh\nserbox host add prod me@server.example.com --install   # installs and tunnels\nserbox host use prod                                  # current server\nserbox create --name work                             # runs on prod\nserbox exec work -- uptime                            # through the ssh tunnel\nserbox -H prod ls                                     # one-off override\nserbox host ls\nserbox host current\nserbox host rm prod\n```\n\nHosts added with `--address 127.0.0.1:7373 --token T` skip ssh and talk to a\ndaemon reached some other way. On the server, `serbox serve` runs the daemon;\nit listens on loopback and keeps its token in `~/.serbox/serve-token`. Rotate it\nwith `serbox serve --rotate-token`, and re-authorize a client with\n`serbox host add NAME USER@HOST --force`.\n\n`push`, `pull` and `cp` need an ssh-added host: the remote daemon cannot read\nyour local disk. Run interactive shells with `serbox shell`; it uses `ssh -t`.\n\n## Housekeeping\n\n```sh\nserbox usage\nserbox gc --max-age 7d --max-run 8h --dry-run\nserbox logs work --tail 100\nserbox metrics work\nserbox history\nserbox completion bash\n```\n\n`gc` reaps boxes with `--delete-after`, runs due setup files and auto-suspends\nidle boxes. `--max-run 0` disables the limit.\n",
  },
]

///|
let skill_group_1 : Array[SkillFile] = [
  {
    skill: "serbox-basic-setup",
    path: "SKILL.md",
    body: "---\nname: serbox-basic-setup\ndescription: Use when the user wants a serbox box set up like their machine - \"put my tokens, git config and editor config in the box\", \"set up my box like my laptop\", \"move my dotfiles to serbox\". Stores credentials as serbox secrets and copies approved git/editor config; moves no repository code (use serbox-move-repo for that).\nmetadata:\n  installed-by: serbox\n---\n\n# Set up a serbox box like the user's machine\n\nThis skill has two separate parts. Credentials become serbox **secrets**;\nordinary configuration files are **copied** into the box. Keeping them separate\nmeans a token is never written into a dotfile the user might share, and a\n`.vimrc` is never mistaken for a secret.\n\nNothing here invents values. The scripts list names and sizes only; the user\napproves what moves, and secret values are read with a hidden prompt (or piped\nfrom the user's own command) and never printed.\n\nPaths assume this skill is installed at `~/.agents/skills/serbox-basic-setup`;\nadjust `S` if needed.\n\n## 1. Inventory (read-only)\n\n```sh\nset -euo pipefail\nS=\"$HOME/.agents/skills/serbox-basic-setup/scripts\"\nBOX=\"${BOX:-work}\"\nnode \"$S/scan.mjs\" --json\n```\n\nThe report contains:\n\n- `files`: known git and editor config that exists, with `path`, `size` and\n  `symlink` (symlinks are reported but never copied).\n- `env`: **names** of environment variables that look like credentials\n  (`*TOKEN*`, `*KEY*`, `*SECRET*`, `*PASSWORD*`, ...). No values.\n- `suggested`: one line per group.\n\nShow the user the names and let them choose. Do not read or echo the values.\n\n## 2. Store credentials as secrets\n\nPrefer a hidden prompt; the value never appears in shell history or logs:\n\n```sh\nread -r -s -p \"Value for GITHUB_TOKEN: \" VALUE; echo\nprintf '%s' \"$VALUE\" | serbox secrets set GITHUB_TOKEN\nunset VALUE\nserbox secrets ls                       # names only\n```\n\nIf the user already has the value in an environment variable, pipe it without\nprinting it:\n\n```sh\nprintf '%s' \"${GITHUB_TOKEN:?not set}\" | serbox secrets set GITHUB_TOKEN\n```\n\nApply secrets to boxes:\n\n```sh\nserbox create --name \"$BOX\" --secrets GITHUB_TOKEN,OPENAI_API_KEY\nserbox secrets push \"$BOX\"               # /data/.serbox/secrets.env, mode 0600\n```\n\nA box only receives a secret at `create` time when it is named in `--secrets`,\nor later through `secrets push`. Adding a secret to the store does not change a\nbox that is already running. To use the pushed file:\n\n```sh\nserbox exec \"$BOX\" -- 'set -a; . /data/.serbox/secrets.env; set +a; env | grep -c TOKEN'\n```\n\nThe last command prints a count, not values.\n\n## 3. Copy config files\n\nStart with the files the user approved:\n\n```sh\nbash \"$S/copy.sh\" \"$BOX\" --dry-run \\\n  .gitconfig .config/git/config .vimrc .tmux.conf .bash_aliases\nbash \"$S/copy.sh\" \"$BOX\" \\\n  .gitconfig .config/git/config .vimrc .tmux.conf .bash_aliases\n```\n\n`copy.sh` refuses symlinks, creates parent directories, copies through\n`serbox push` and sets mode `0600` on the copied files. Without a file list it\ncopies the existing defaults from the scan. It does not copy directories\nwholesale: nvim plugin checkouts and caches are deliberately excluded.\n\nVerify:\n\n```sh\nserbox exec \"$BOX\" -- 'git config --global user.name; git config --global user.email'\nserbox exec \"$BOX\" -- 'test -f /data/home/.vimrc && echo vimrc-ok'\n```\n\n## 4. Tell the user what still needs a manual step\n\n- Git push/pull needs an SSH key or token inside the box. A `.gitconfig` alone\n  does not authenticate. For HTTPS, a credential helper or a token in the\n  remote URL is required; for SSH, generate a key in the box and add it to the\n  user's account. Never copy the host's private keys unless the user explicitly\n  asks and understands the risk.\n- Secrets in the environment are visible to every process in the box. A\n  compromised dependency can read them.\n- `serbox rm BOX` destroys the box's `/data`; snapshots saved earlier remain.\n- Config copied now is a snapshot in time. The local machine and the box do not\n  stay in sync.\n\n## Security rules\n\n- Never print a secret value, a credential-bearing config file, or the output of\n  `env`/`printenv` that may contain secrets.\n- Do not copy `.ssh` private keys, cloud credential files (`.aws/credentials`,\n  `.config/gcloud/...`), browser profiles or keychains by default. Name them to\n  the user and require explicit approval; prefer creating fresh credentials in\n  the box.\n- Do not paste tokens into a command line where `ps` can see them. Use stdin as\n  shown above.\n",
  },
  {
    skill: "serbox-basic-setup",
    path: "scripts/copy.sh",
    body: "#!/usr/bin/env bash\n# Copy approved config files into a serbox box.\n# usage: copy.sh BOX [--dry-run] [FILE...]   (paths are relative to $HOME)\nset -euo pipefail\nbox=\"${1:?usage: copy.sh BOX [--dry-run] [FILE...]}\"\nshift\ndry=0\nfiles=()\nfor arg in \"$@\"; do\n  case \"$arg\" in\n    --dry-run) dry=1 ;;\n    -h|--help) sed -n '2,3p' \"$0\"; exit 0 ;;\n    -*) echo \"copy.sh: unknown option $arg\" >&2; exit 2 ;;\n    *) files+=(\"$arg\") ;;\n  esac\ndone\nif [ ${#files[@]} -eq 0 ]; then\n  files=(.gitconfig .config/git/config .vimrc .tmux.conf .bash_aliases .zshrc)\nfi\n\nfor rel in \"${files[@]}\"; do\n  case \"$rel\" in\n    /*|*..*) echo \"copy.sh: unsafe path $rel\" >&2; exit 2 ;;\n  esac\n  src=\"$HOME/$rel\"\n  if [ -L \"$src\" ]; then\n    echo \"skip $rel (symlink)\" >&2\n    continue\n  fi\n  if [ ! -f \"$src\" ]; then\n    echo \"skip $rel (not a regular file)\" >&2\n    continue\n  fi\n  dest=\"/data/home/$rel\"\n  if [ \"$dry\" = 1 ]; then\n    echo \"would copy $rel -> $box:$dest\"\n    continue\n  fi\n  serbox exec \"$box\" -- \"mkdir -p '$(dirname \"$dest\")'\"\n  serbox push \"$box\" \"$src\" \"$dest\" >/dev/null\n  serbox exec \"$box\" -- \"chmod 600 '$dest'\"\n  echo \"copied $rel\"\ndone\n",
  },
  {
    skill: "serbox-basic-setup",
    path: "scripts/scan.mjs",
    body: "#!/usr/bin/env node\n// Read-only inventory for serbox-basic-setup. Names and sizes only.\nimport { existsSync, lstatSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\nconst DEFAULT_FILES = [\n  '.gitconfig',\n  '.config/git/config',\n  '.gitignore_global',\n  '.vimrc',\n  '.config/nvim/init.vim',\n  '.config/nvim/init.lua',\n  '.tmux.conf',\n  '.bashrc',\n  '.bash_aliases',\n  '.zshrc',\n  '.inputrc',\n];\n\nconst CREDENTIAL = /(TOKEN|SECRET|PASSWORD|PASSWD|API[_-]?KEY|ACCESS[_-]?KEY|PRIVATE[_-]?KEY|CREDENTIAL)/i;\n\nconst args = process.argv.slice(2);\nif (args.includes('-h') || args.includes('--help')) {\n  process.stdout.write('usage: scan.mjs [--json]\\n');\n  process.exit(0);\n}\nif (args.some((a) => a !== '--json')) {\n  process.stderr.write('scan.mjs: unknown argument\\n');\n  process.exit(2);\n}\n\nconst home = homedir();\nconst files = [];\nfor (const rel of DEFAULT_FILES) {\n  const full = join(home, rel);\n  if (!existsSync(full)) continue;\n  let stat;\n  try {\n    stat = lstatSync(full);\n  } catch {\n    continue;\n  }\n  files.push({\n    path: rel,\n    size: stat.isSymbolicLink() ? 0 : stat.size,\n    symlink: stat.isSymbolicLink(),\n  });\n}\n\nconst env = Object.keys(process.env)\n  .filter((name) => CREDENTIAL.test(name))\n  .sort();\n\nconst report = {\n  home,\n  files,\n  env,\n  suggested: [\n    files.length\n      ? `copy ${files.filter((f) => !f.symlink).length} config file(s) with copy.sh`\n      : 'no known config files found',\n    env.length\n      ? `store ${env.length} credential name(s) with serbox secrets set NAME`\n      : 'no credential-like environment variables found',\n  ],\n};\nprocess.stdout.write(JSON.stringify(report, null, 2) + '\\n');\n",
  },
]

///|
let skill_group_2 : Array[SkillFile] = [
  {
    skill: "serbox-move-repo",
    path: "SKILL.md",
    body: "---\nname: serbox-move-repo\ndescription: Use when the user wants to move the repository they are working in into a serbox box - \"move this repo to a box\", \"continue this work in the box\", \"copy my project into serbox\". Copies the checkout, its worktrees, uncommitted and stashed work, then installs dependencies inside the box.\nmetadata:\n  installed-by: serbox\n---\n\n# Move a local repository into a serbox box\n\nThis moves the git checkout of the current directory into one box and leaves\nthe local copy untouched. After it finishes the box has the same HEAD, index,\nbranches, stashes and worktrees, plus untracked files that git does not ignore.\nConversation history from agent tools is **not** copied; this skill only moves\nthe repository.\n\nPaths in the examples assume this skill is installed at\n`~/.agents/skills/serbox-move-repo` (or `~/.claude/skills/...`); adjust `S` if\nyours is elsewhere.\n\nPrerequisites: `git`, `tar`, `node` (for the file plan) and a working `serbox`\nbox. Run the steps in one shell session so `S`, `ROOT`, `BOX` and `DEST` stay\nset.\n\n## 1. Pick the box and destination\n\n```sh\nset -euo pipefail\nS=\"$HOME/.agents/skills/serbox-move-repo/scripts\"\nROOT=\"$(git rev-parse --show-toplevel)\"\nBOX=\"${BOX:-work}\"\nDEST=\"${DEST:-/data/home/$(basename \"$ROOT\")}\"\nserbox get \"$BOX\" >/dev/null || serbox create --name \"$BOX\" --template alpine\n```\n\nIf the box does not exist, create it with the template the project needs\n(`ubuntu`, `node`, `python`, ...; see `serbox templates`). A wrong template\nmeans missing runtimes later.\n\n## 2. See the plan\n\n```sh\nnode \"$S/repo-files.mjs\" --json \"$ROOT\"\n```\n\nThe plan lists the files that will move and the size. Build output and\ndependency directories (`node_modules`, `target`, `dist`, `.venv`, caches, ...)\nare skipped even when they are untracked; **tracked** files are always kept so\n`git status` matches. Use `--keep NAME` to include an excluded directory by\nliteral name (for example a source tree that really lives in `build/`).\n\nBefore moving, tell the user:\n\n- Git push and pull will not work in the box until credentials are configured\n  there; environment secrets and git config are separate steps (see the\n  `serbox-basic-setup` skill).\n- Copying `.git/config` copies any remote URL, including an embedded token.\n- Untracked `.env` files that git ignores are **not** copied. Move their values\n  with `serbox secrets set`, never by printing them.\n\n## 3. Copy the repository and its git data\n\n```sh\nnode \"$S/repo-files.mjs\" --list0 \"$ROOT\" > /tmp/serbox-move.list\ntar -C \"$ROOT\" --null -cf /tmp/serbox-move.tar -T /tmp/serbox-move.list\ntar -C \"$ROOT\" -rf /tmp/serbox-move.tar .git\nserbox push \"$BOX\" /tmp/serbox-move.tar /tmp/serbox-move.tar\nserbox exec \"$BOX\" -- sh -c \"mkdir -p '$DEST' && tar -xf /tmp/serbox-move.tar -C '$DEST' && rm /tmp/serbox-move.tar\"\nrm -f /tmp/serbox-move.list /tmp/serbox-move.tar\n```\n\nThe second `tar -rf` adds `.git` (all branches, stashes, index and worktree\nmetadata) while the file list stays manageable. If the user does not want git\nhistory in the box, omit that line and add `--no-git` when running\n`move.sh` below.\n\n## 4. Verify and install dependencies\n\n```sh\nserbox exec \"$BOX\" --workdir \"$DEST\" -- 'git status --short; git log -1 --oneline'\nbash \"$S/deps.sh\" \"$BOX\" \"$DEST\"\n```\n\n`deps.sh` detects `package.json`, lockfiles, `Cargo.toml`, `go.mod`,\n`requirements.txt`, `pyproject.toml` and `Gemfile`, and runs the matching\ninstall command with the tool already present in the box. It does not install\nmissing runtimes; if a tool is absent, tell the user which template or package\nto add.\n\n## Shortcut\n\n`move.sh` wraps steps 3 and 4:\n\n```sh\nbash \"$S/move.sh\" \"$ROOT\" \"$BOX\"            # keeps .git, installs deps\nbash \"$S/move.sh\" \"$ROOT\" \"$BOX\" --no-git   # code only\n```\n\nThe box and the local checkout are independent after the move. Nothing keeps\nthem in sync; later changes need another `push` or a git remote.\n",
  },
  {
    skill: "serbox-move-repo",
    path: "scripts/deps.sh",
    body: "#!/usr/bin/env bash\n# Install a moved project's dependencies inside a serbox box.\n# usage: deps.sh BOX DIR\nset -euo pipefail\nbox=\"${1:?usage: deps.sh BOX DIR}\"\ndir=\"${2:?usage: deps.sh BOX DIR}\"\nrun() { serbox exec \"$box\" --workdir \"$dir\" -- \"$@\"; }\nhave() { serbox exec \"$box\" -- \"command -v '$1' >/dev/null 2>&1\"; }\n\nif serbox exec \"$box\" -- \"test -f '$dir/package.json'\"; then\n  if serbox exec \"$box\" -- \"test -f '$dir/pnpm-lock.yaml'\"; then\n    have pnpm && run pnpm install --frozen-lockfile || echo \"note: pnpm is not installed in the box\"\n  elif serbox exec \"$box\" -- \"test -f '$dir/yarn.lock'\"; then\n    have yarn && run yarn install --frozen-lockfile || echo \"note: yarn is not installed in the box\"\n  elif serbox exec \"$box\" -- \"test -f '$dir/package-lock.json'\"; then\n    have npm && run npm ci || echo \"note: npm is not installed in the box\"\n  else\n    have npm && run npm install || echo \"note: npm is not installed in the box\"\n  fi\nfi\n\nif serbox exec \"$box\" -- \"test -f '$dir/Cargo.toml'\"; then\n  have cargo && run cargo fetch || echo \"note: cargo is not installed in the box\"\nfi\nif serbox exec \"$box\" -- \"test -f '$dir/go.mod'\"; then\n  have go && run go mod download || echo \"note: go is not installed in the box\"\nfi\nif serbox exec \"$box\" -- \"test -f '$dir/requirements.txt'\"; then\n  have python3 && run python3 -m pip install -r requirements.txt ||\n    echo \"note: python3/pip is not installed in the box\"\nfi\nif serbox exec \"$box\" -- \"test -f '$dir/pyproject.toml'\"; then\n  have python3 && run python3 -m pip install -e . ||\n    echo \"note: python3/pip is not installed in the box\"\nfi\nif serbox exec \"$box\" -- \"test -f '$dir/Gemfile'\"; then\n  have bundle && run bundle install || echo \"note: bundler is not installed in the box\"\nfi\n",
  },
  {
    skill: "serbox-move-repo",
    path: "scripts/move.sh",
    body: "#!/usr/bin/env bash\n# Copy a git checkout into a serbox box (shortcut for the steps in SKILL.md).\n# usage: move.sh REPO BOX [--dest PATH] [--no-git]\nset -euo pipefail\nroot=\"${1:?usage: move.sh REPO BOX [--dest PATH] [--no-git]}\"\nbox=\"${2:?usage: move.sh REPO BOX [--dest PATH] [--no-git]}\"\nshift 2\ndest=\"\"\ngit=1\nwhile [ $# -gt 0 ]; do\n  case \"$1\" in\n    --dest) dest=\"${2:?--dest needs a path}\"; shift 2 ;;\n    --no-git) git=0; shift ;;\n    -h|--help) sed -n '2,3p' \"$0\"; exit 0 ;;\n    *) echo \"move.sh: unknown argument $1\" >&2; exit 2 ;;\n  esac\ndone\nS=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\nroot=\"$(git -C \"$root\" rev-parse --show-toplevel)\"\n[ -n \"$dest\" ] || dest=\"/data/home/$(basename \"$root\")\"\nwork=\"$(mktemp -d)\"\ntrap 'rm -rf \"$work\"' EXIT\n\nnode \"$S/repo-files.mjs\" --list0 \"$root\" > \"$work/files\"\ntar -C \"$root\" --null -cf \"$work/repo.tar\" -T \"$work/files\"\nif [ \"$git\" = 1 ]; then\n  tar -C \"$root\" -rf \"$work/repo.tar\" .git\nfi\nserbox push \"$box\" \"$work/repo.tar\" /tmp/serbox-move.tar >/dev/null\nserbox exec \"$box\" -- sh -c \"mkdir -p '$dest' && tar -xf /tmp/serbox-move.tar -C '$dest' && rm /tmp/serbox-move.tar\"\nif [ \"$git\" = 1 ]; then\n  serbox exec \"$box\" --workdir \"$dest\" -- 'git status --short'\nfi\nbash \"$S/deps.sh\" \"$box\" \"$dest\"\necho \"moved $root to $box:$dest\"\n",
  },
  {
    skill: "serbox-move-repo",
    path: "scripts/repo-files.mjs",
    body: "#!/usr/bin/env node\n// Plan which files of a git checkout move into a serbox box.\n// Prints names and sizes only; never reads file contents.\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, statSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\n\nconst EXCLUDED_DIRS = new Set([\n  'node_modules', 'target', 'dist', 'build', 'out', '.next', '.nuxt',\n  '.svelte-kit', '.turbo', '.cache', 'coverage', '__pycache__', '.venv',\n  'venv', '.tox', '.mypy_cache', '.pytest_cache', '.gradle', '.idea',\n  '.vscode', 'bazel-bin', 'bazel-out', 'bazel-testlogs', '.dart_tool',\n  '.terraform', '.serverless', '.parcel-cache', '.angular', '.expo',\n]);\n\nfunction usage(message) {\n  if (message) process.stderr.write(`repo-files: ${message}\\n`);\n  process.stderr.write('usage: repo-files.mjs [--json|--list0] [--keep NAME] [ROOT]\\n');\n  process.exit(2);\n}\n\nconst argv = process.argv.slice(2);\nlet mode = 'json';\nlet keep = new Set();\nlet rootArg = '';\nfor (let i = 0; i < argv.length; i++) {\n  const a = argv[i];\n  if (a === '--json') mode = 'json';\n  else if (a === '--list0') mode = 'list0';\n  else if (a === '--keep') {\n    if (i + 1 >= argv.length) usage('--keep needs a name');\n    keep.add(argv[++i]);\n  } else if (a === '-h' || a === '--help') usage();\n  else if (a.startsWith('-')) usage(`unknown option ${a}`);\n  else if (!rootArg) rootArg = a;\n  else usage(`unexpected argument ${a}`);\n}\n\nconst cwd = resolve(rootArg || '.');\nconst root = spawnSync('git', ['-C', cwd, 'rev-parse', '--show-toplevel'], {\n  encoding: 'utf8',\n});\nif (root.status !== 0) usage(`${cwd} is not inside a git checkout`);\nconst rootDir = root.stdout.trim();\n\nconst listed = spawnSync(\n  'git',\n  ['-C', rootDir, 'ls-files', '-z', '--cached', '--others', '--exclude-standard'],\n  { encoding: 'buffer', maxBuffer: 1024 * 1024 * 512 },\n);\nif (listed.status !== 0) {\n  process.stderr.write(listed.stderr?.toString() || 'git ls-files failed\\n');\n  process.exit(1);\n}\n\nconst parts = listed.stdout.toString('utf8').split('\\0').filter(Boolean);\nconst tracked = new Set(\n  spawnSync('git', ['-C', rootDir, 'ls-files', '-z', '--cached'], {\n    encoding: 'buffer',\n    maxBuffer: 1024 * 1024 * 512,\n  }).stdout.toString('utf8').split('\\0').filter(Boolean),\n);\n\nfunction excluded(rel) {\n  const segments = rel.split('/');\n  for (const segment of segments) {\n    if (EXCLUDED_DIRS.has(segment)) return !keep.has(segment);\n    if (/\\.egg-info$/.test(segment) || /^bazel-/.test(segment)) {\n      return !keep.has(segment);\n    }\n  }\n  const base = segments[segments.length - 1];\n  if (/\\.(o|so|pyc|pyo|class|dylib|dll|exe|a)$/.test(base)) {\n    return !keep.has(base);\n  }\n  return false;\n}\n\nconst files = [];\nlet bytes = 0;\nfor (const rel of parts) {\n  if (!tracked.has(rel) && excluded(rel)) continue;\n  const full = join(rootDir, rel);\n  if (!existsSync(full)) continue;\n  let size = 0;\n  try {\n    size = statSync(full).size;\n  } catch {\n    continue;\n  }\n  files.push({ path: rel, size, tracked: tracked.has(rel) });\n  bytes += size;\n}\n\nif (mode === 'list0') {\n  process.stdout.write(files.map((f) => f.path).join('\\0') + '\\0');\n} else {\n  const skipped = parts.length - files.length;\n  process.stdout.write(\n    JSON.stringify({\n      root: rootDir,\n      total: files.length,\n      bytes,\n      skipped,\n      excludedDirs: [...EXCLUDED_DIRS].sort(),\n      files,\n    }, null, 2) + '\\n',\n  );\n}\n",
  },
]

///|
let skill_group_3 : Array[SkillFile] = [
  {
    skill: "serbox-snapshots",
    path: "SKILL.md",
    body: "---\nname: serbox-snapshots\ndescription: Use when the user wants to save a serbox box's state and load it later - \"save a snapshot\", \"checkpoint this box\", \"restore from a snapshot\", \"start a new box from my setup\", \"clone this box\". Covers serbox snapshot save/ls/restore/rm/import, fork and create from a saved image.\nmetadata:\n  installed-by: serbox\n---\n\n# serbox snapshots: save, restore, fork\n\nA snapshot is a Docker image made from a box with `docker commit`. It contains\nthe box's whole filesystem: system files, installed packages and `/data`\n(including `HOME`). It does **not** contain running processes, memory, open\nconnections or host-side port forwards. A box restored from a snapshot is a\npower-cut copy: files are exactly as they were, processes are not running.\n\nSnapshots stay on the machine, need no registry and no account. They are listed\nunder `~/.serbox/snapshots` (or `SERBOX_HOME`) and stored as local Docker\nimages tagged `serbox-snapshot/:latest`.\n\n## Save\n\n```sh\nserbox snapshot save work --name work-ready --description \"deps installed\"\nserbox snapshot save work                    # name: work-\nserbox snapshot ls\n```\n\n- A running box is committed live. The command waits for Docker to finish, so\n  when it returns the snapshot is ready. Stop the box only when a program must\n  flush its data first (a database mid-write); `docker commit` also works on a\n  stopped box.\n- Names are 1 to 80 characters from `a-z`, `A-Z`, `0-9`, `.`, `_` and `-`, must\n  start with a letter or digit, and cannot start with `sn_` or `im_`. They must\n  be unique on the machine.\n- A snapshot can contain credentials that applications wrote to disk (git\n  credentials, cloud CLI state, `.netrc`, shell history). Treat a snapshot as\n  sensitive: do not publish or share the machine's images without review.\n\n## Restore and load\n\n```sh\nserbox snapshot restore work --snapshot work-ready --yes   # in place\nserbox create --name work2 --snapshot work-ready           # a new box\nserbox fork work --name work2 --count 2                    # copies of a box\n```\n\n`snapshot restore` replaces the box's container with the snapshot image. The\nbox keeps its name, `--env` values, secret names and published ports, but every\nfile changed since the snapshot is lost. Without `--snapshot` it uses the most\nrecent snapshot whose source is that box.\n\n`create --snapshot NAME` creates a new box from a snapshot without touching the\nsource. `fork BOX` commits the current state under a temporary tag and creates\n`BOX-copy` boxes from it; the temporary image is not listed as a snapshot.\n\nSnapshots are per-machine. To move one to another host, save the image, copy\nit, load it there, then record it as a snapshot:\n\n```sh\ndocker save serbox-snapshot/work-ready:latest -o work-ready.tar\n# copy work-ready.tar to the other host, then:\ndocker load -i work-ready.tar\nserbox snapshot import serbox-snapshot/work-ready:latest --name work-ready\n```\n\n`snapshot import IMAGE --name NAME` records an image reference that is already\npresent locally or that Docker can pull; `--name` is required.\n\n## Remove\n\n```sh\nserbox snapshot rm work-ready --yes\n```\n\nThis deletes the snapshot record and its Docker image. Boxes already created\nfrom it are unaffected. Removing a box never removes its snapshots; remove\nthose explicitly when they are no longer needed.\n\n## Safety\n\n- Deleting a snapshot is irreversible. Confirm the name with `snapshot ls`\n  before running `rm`.\n- A snapshot of a box with secrets in its environment does not store the\n  environment, but files the box wrote (`.env`, tokens in config files) are\n  included. Rotate credentials before sharing an image.\n- Published ports are host configuration, not part of the snapshot; a new box\n  needs its own `port publish`.\n",
  },
]

///|
pub fn bundled_skill_files() -> Array[SkillFile] {
  let files : Array[SkillFile] = []
  for file in skill_group_0 {
    files.push(file)
  }
  for file in skill_group_1 {
    files.push(file)
  }
  for file in skill_group_2 {
    files.push(file)
  }
  for file in skill_group_3 {
    files.push(file)
  }
  files
}