From d4eb4cc435b999d852bf3deb71f6b2ca0c0c4e52 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 3 Mar 2026 19:12:13 -0500 Subject: [PATCH 1/2] feat: add codegen-react and codegen-html embedded skills MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add two new code generation skills for frontend UI scaffolding: - codegen-react: Vite + React 19 with Tailwind CSS, 4 tools (scaffold, run, read, write). The run tool handles npm install and starts the dev server with browser auto-open. - codegen-html: Preact + HTM via CDN with Tailwind CSS, 3 tools (scaffold, read, write). Zero dependencies — just open index.html. Both skills include Forge dark theme defaults, path traversal prevention, and strong LLM guardrails to prevent common errors (rewriting main.jsx, using default exports, inventing index.css). Updates docs/skills.md with complete skill table and detailed sections for both new skills. --- docs/skills.md | 77 +++++- .../local/embedded/codegen-html/SKILL.md | 190 ++++++++++++++ .../codegen-html/scripts/codegen-html-read.sh | 90 +++++++ .../scripts/codegen-html-scaffold.sh | 219 ++++++++++++++++ .../scripts/codegen-html-write.sh | 85 +++++++ .../local/embedded/codegen-react/SKILL.md | 236 ++++++++++++++++++ .../scripts/codegen-react-read.sh | 92 +++++++ .../scripts/codegen-react-run.sh | 81 ++++++ .../scripts/codegen-react-scaffold.sh | 197 +++++++++++++++ .../scripts/codegen-react-write.sh | 85 +++++++ forge-skills/local/registry_embedded_test.go | 6 +- 11 files changed, 1351 insertions(+), 7 deletions(-) create mode 100644 forge-skills/local/embedded/codegen-html/SKILL.md create mode 100755 forge-skills/local/embedded/codegen-html/scripts/codegen-html-read.sh create mode 100755 forge-skills/local/embedded/codegen-html/scripts/codegen-html-scaffold.sh create mode 100755 forge-skills/local/embedded/codegen-html/scripts/codegen-html-write.sh create mode 100644 forge-skills/local/embedded/codegen-react/SKILL.md create mode 100755 forge-skills/local/embedded/codegen-react/scripts/codegen-react-read.sh create mode 100755 forge-skills/local/embedded/codegen-react/scripts/codegen-react-run.sh create mode 100755 forge-skills/local/embedded/codegen-react/scripts/codegen-react-scaffold.sh create mode 100755 forge-skills/local/embedded/codegen-react/scripts/codegen-react-write.sh diff --git a/docs/skills.md b/docs/skills.md index 32cc2a4..bbf2fc5 100644 --- a/docs/skills.md +++ b/docs/skills.md @@ -99,7 +99,7 @@ For skills **without** scripts (binary-backed skills like `k8s-incident-triage`) │ LLM Tool Registry │ ├─────────────────┬───────────────────────────────┤ │ Builtins │ web_search, http_request │ -│ Skill Tools │ tavily_research, ... │ ← auto-registered from scripts +│ Skill Tools │ tavily_research, codegen_* │ ← auto-registered from scripts │ read_skill │ load any SKILL.md on demand │ │ cli_execute │ run approved binaries │ ├─────────────────┴───────────────────────────────┤ @@ -143,10 +143,18 @@ forge skills list --tags kubernetes,incident-response ## Built-in Skills -| Skill | Description | Scripts | -|-------|-------------|---------| -| `tavily-research` | Deep multi-source research via Tavily API | `tavily-research.sh`, `tavily-research-poll.sh` | -| `k8s-incident-triage` | Read-only Kubernetes incident triage using kubectl | — (binary-backed) | +| Skill | Category | Description | Scripts | +|-------|----------|-------------|---------| +| `github` | — | Create issues, PRs, and query repositories | — (binary-backed) | +| `weather` | — | Get weather data for a location | — (binary-backed) | +| `tavily-search` | — | Search the web using Tavily AI search API | `tavily-search.sh` | +| `tavily-research` | — | Deep multi-source research via Tavily API | `tavily-research.sh`, `tavily-research-poll.sh` | +| `k8s-incident-triage` | sre | Read-only Kubernetes incident triage using kubectl | — (binary-backed) | +| `code-review` | dev | AI-powered code review for diffs and files | `code-review-diff.sh`, `code-review-file.sh` | +| `code-review-standards` | dev | Initialize and manage code review standards | — (template-based) | +| `code-review-github` | dev | Post code review results to GitHub PRs | — (binary-backed) | +| `codegen-react` | developer | Scaffold and iterate on Vite + React apps | `codegen-react-scaffold.sh`, `codegen-react-read.sh`, `codegen-react-write.sh`, `codegen-react-run.sh` | +| `codegen-html` | developer | Scaffold standalone Preact + HTM apps (zero dependencies) | `codegen-html-scaffold.sh`, `codegen-html-read.sh`, `codegen-html-write.sh` | ### Tavily Research Skill @@ -210,6 +218,65 @@ The skill accepts two input modes: Requires: `kubectl`, optional `KUBECONFIG`, `K8S_API_DOMAIN`, `DEFAULT_NAMESPACE` environment variables. +### Codegen React Skill + +The `codegen-react` skill scaffolds and iterates on **Vite + React** applications with Tailwind CSS: + +```bash +forge skills add codegen-react +``` + +This registers four tools: + +| Tool | Purpose | Behavior | +|------|---------|----------| +| `codegen_react_scaffold` | Create a new project | Generates package.json, Vite config, React components with Tailwind CSS and Forge dark theme | +| `codegen_react_run` | Start the dev server | Runs `npm install` + `npm run dev`, auto-opens browser, returns server URL and PID | +| `codegen_react_read` | Read project files | Returns file content or directory listing (excludes `node_modules/`, `.git/`) | +| `codegen_react_write` | Write/update files | Creates or updates files with path traversal prevention; Vite hot-reloads automatically | + +**Iteration workflow:** + +1. Scaffold the project with `codegen_react_scaffold` +2. Start the dev server with `codegen_react_run` — installs deps, opens browser +3. Read/write files with `codegen_react_read` / `codegen_react_write` — Vite hot-reloads on save +4. Repeat step 3 to iterate on the UI + +**Scaffold output:** `package.json` (React 19, Vite 6), `vite.config.js`, `index.html` (with Tailwind CDN), `src/main.jsx`, `src/App.jsx` (Tailwind utility classes), `src/App.css`, `.gitignore`. + +**Safety:** Output directories must be under `$HOME` or `/tmp`. Path traversal (`..`, absolute paths) is rejected. Non-empty directories require `force: true`. + +Requires: `node`, `npx`, `jq`. Egress: `registry.npmjs.org`, `cdn.jsdelivr.net`, `cdn.tailwindcss.com`. + +### Codegen HTML Skill + +The `codegen-html` skill scaffolds standalone **Preact + HTM** applications with zero local dependencies: + +```bash +forge skills add codegen-html +``` + +This registers three tools: + +| Tool | Purpose | Behavior | +|------|---------|----------| +| `codegen_html_scaffold` | Create a new project | Generates HTML with Preact + HTM via CDN and Tailwind CSS; supports single-file and multi-file modes | +| `codegen_html_read` | Read project files | Returns file content or directory listing | +| `codegen_html_write` | Write/update files | Creates or updates files with path traversal prevention | + +**Two scaffold modes:** + +| Mode | Files | Use Case | +|------|-------|----------| +| `single-file` | One `index.html` with inline JS | Quick prototypes, shareable demos | +| `multi-file` | `index.html`, `app.js`, `components/Counter.js` | Larger apps with component separation | + +**Key differences from codegen-react:** No Node.js required. No build step. No `npm install`. Just open `index.html` in a browser. Uses `class` (not `className`) since HTM maps directly to DOM attributes. + +**Safety:** Same restrictions as codegen-react — output under `$HOME` or `/tmp`, path traversal prevention, `force: true` for non-empty directories. + +Requires: `jq`. Egress: `cdn.tailwindcss.com`, `esm.sh`. + ## Skill Instructions in System Prompt Forge injects the **full body** of each skill's SKILL.md into the LLM system prompt. This means all detailed operational instructions — triage steps, detection heuristics, output structure, safety constraints — are directly available in the LLM's context without requiring an extra `read_skill` tool call. diff --git a/forge-skills/local/embedded/codegen-html/SKILL.md b/forge-skills/local/embedded/codegen-html/SKILL.md new file mode 100644 index 0000000..4d8b8b4 --- /dev/null +++ b/forge-skills/local/embedded/codegen-html/SKILL.md @@ -0,0 +1,190 @@ +--- +name: codegen-html +category: developer +tags: + - code-generation + - frontend + - html + - preact + - ui + - zero-dependency +description: Scaffold and iterate on standalone Preact + HTM applications with zero build dependencies +metadata: + forge: + requires: + bins: + - jq + env: + required: [] + one_of: [] + optional: [] + egress_domains: + - cdn.tailwindcss.com + - esm.sh + timeout_hint: 60 +--- + +# Codegen HTML Skill + +Scaffold and iteratively build standalone HTML applications using Preact + HTM via CDN. Zero local dependencies — no Node.js, no npm, no build step. Just open the HTML file in a browser. + +## Quick Start + +```bash +# Scaffold a single-file app +./scripts/codegen-html-scaffold.sh '{"project_name": "my-app", "output_dir": "/tmp/my-app", "mode": "single-file"}' + +# Scaffold a multi-file app +./scripts/codegen-html-scaffold.sh '{"project_name": "my-app", "output_dir": "/tmp/my-app", "mode": "multi-file"}' + +# Read a file or list the project +./scripts/codegen-html-read.sh '{"project_dir": "/tmp/my-app", "file_path": "."}' + +# Write/update a file +./scripts/codegen-html-write.sh '{"project_dir": "/tmp/my-app", "file_path": "index.html", "content": "..."}' +``` + +## CRITICAL: Scaffold Conventions (DO NOT VIOLATE) + +These rules prevent runtime errors: + +1. **Use `class` (not `className`)** — HTM maps directly to DOM attributes +2. **Use Tailwind CSS utility classes** for all styling (loaded via CDN in `index.html`) +3. **Do NOT create `