From 048dac7fee6a71da853c7e8da4077b0395aafb53 Mon Sep 17 00:00:00 2001 From: deryk Date: Tue, 17 Nov 2026 20:28:02 +0800 Subject: [PATCH 01/18] Add the Cursor akb plugin and keep shared skill scripts LF. Cursor and Claude Code use the same POSIX entry points. .gitattributes stops a Windows checkout from putting CR into those scripts, which breaks sh under WSL. The Claude plugin identity is unchanged. --- .cursor-plugin/marketplace.json | 23 + .cursor-plugin/plugin.json | 11 + .gitattributes | 3 + .github/workflows/kb-checks.yml | 6 + AGENTS.md | 16 +- CONTRIBUTING.md | 53 +- README.md | 17 + docs/cursor-plugin.md | 358 ++++++++++ rules/apollo-v4.mdc | 18 + skills/akb-lesson/SKILL.md | 114 ++- skills/akb-lesson/scripts/submit-gate.sh | 51 ++ skills/apollo-build/SKILL.md | 104 ++- skills/apollo-build/scripts/find-acd.sh | 28 +- skills/apollo-new-project/SKILL.md | 179 +++-- .../scripts/write-project-files.sh | 50 ++ tools/check_claude_plugin.py | 125 ++++ tools/check_cursor_plugin.py | 149 ++++ tools/check_links.py | 3 + tools/check_shared_workflows.py | 661 ++++++++++++++++++ tools/check_skills.py | 23 +- tools/kblib.py | 5 +- tools/resolve_kb.py | 204 ++++++ tools/submit_gate.py | 59 ++ tools/write_project_files.py | 365 ++++++++++ tools/wsl_reexec.sh | 107 +++ 25 files changed, 2599 insertions(+), 133 deletions(-) create mode 100644 .cursor-plugin/marketplace.json create mode 100644 .cursor-plugin/plugin.json create mode 100644 .gitattributes create mode 100644 docs/cursor-plugin.md create mode 100644 rules/apollo-v4.mdc create mode 100644 skills/akb-lesson/scripts/submit-gate.sh create mode 100644 skills/apollo-new-project/scripts/write-project-files.sh create mode 100644 tools/check_claude_plugin.py create mode 100644 tools/check_cursor_plugin.py create mode 100644 tools/check_shared_workflows.py create mode 100644 tools/resolve_kb.py create mode 100644 tools/submit_gate.py create mode 100644 tools/write_project_files.py create mode 100644 tools/wsl_reexec.sh diff --git a/.cursor-plugin/marketplace.json b/.cursor-plugin/marketplace.json new file mode 100644 index 0000000..a8344d3 --- /dev/null +++ b/.cursor-plugin/marketplace.json @@ -0,0 +1,23 @@ +{ + "name": "apolloknowledgebase", + "owner": { + "name": "Apollo Team" + }, + "metadata": { + "description": "ApolloKnowledgeBase for Cursor: the 68080, SAGA, ApolloOS, AmigaOS on V4, and ApolloCrossDev. This marketplace entry is the AmanitaHouse fork; the knowledge and the Claude plugin remain Apollo Team's." + }, + "plugins": [ + { + "name": "akb", + "source": ".", + "description": "Skills for Apollo V4 development: apollo-new-project, apollo-build, and akb-lesson. They read ApolloKnowledgeBase, which is this repository.", + "version": "1.0.0", + "author": { + "name": "Apollo Team" + }, + "homepage": "https://apolloknowledgebase.com", + "repository": "https://github.com/AmanitaHouse/ApolloKnowledgeBase", + "keywords": ["apollo", "vampire", "68080", "saga", "amiga", "apolloos"] + } + ] +} diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json new file mode 100644 index 0000000..92524aa --- /dev/null +++ b/.cursor-plugin/plugin.json @@ -0,0 +1,11 @@ +{ + "name": "akb", + "version": "1.0.0", + "description": "Skills for Apollo V4 development with ApolloKnowledgeBase: apollo-new-project, apollo-build, and akb-lesson. The knowledge base ships with the plugin.", + "author": { + "name": "Apollo Team" + }, + "homepage": "https://apolloknowledgebase.com", + "repository": "https://github.com/AmanitaHouse/ApolloKnowledgeBase", + "keywords": ["apollo", "vampire", "68080", "saga", "amiga", "apolloos"] +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1f374f4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# POSIX skill scripts must stay LF. A CR in the file is part of the command +# for /bin/sh, so core.autocrlf must not rewrite them on checkout. +*.sh text eol=lf diff --git a/.github/workflows/kb-checks.yml b/.github/workflows/kb-checks.yml index 318c06c..39bddf6 100644 --- a/.github/workflows/kb-checks.yml +++ b/.github/workflows/kb-checks.yml @@ -32,6 +32,12 @@ jobs: run: python tools/check_skills.py env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Shared skill workflows + run: python tools/check_shared_workflows.py + - name: Cursor plugin manifests (static) + run: python tools/check_cursor_plugin.py + - name: Claude plugin manifests (static) + run: python tools/check_claude_plugin.py - name: Markdown lint uses: DavidAnson/markdownlint-cli2-action@v25 with: diff --git a/AGENTS.md b/AGENTS.md index e55c4e6..78d9e91 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -229,14 +229,22 @@ knowledge base files it needs instead of repeating them. | `skills/apollo-build/` | Apollo V4 code is compiled, linked or assembled, flags come up, a build fails, or before presenting code | | `skills/akb-lesson/` | a project, release or milestone is done, the user asks for a summary, or an assumption from section 2 turned out wrong | -If your agent loads skills by itself (Claude Code with the `akb` plugin, -or an agent whose skills folder links to this `skills/` folder), it picks -them up from their descriptions. If it doesn't, read +If your agent loads skills by itself (Claude Code or Cursor with the `akb` +plugin, or an agent whose skills folder links to this `skills/` folder), it +picks them up from their descriptions. If it doesn't, read `skills//SKILL.md` when the task matches the table above, and follow it. Paths in a SKILL.md are relative to its own folder or, when marked `KB`, to the knowledge base root. +A project reads its own `ApolloKnowledgeBase/` submodule when that submodule +is initialized. That pin is authoritative. Otherwise the agent uses the +knowledge base bundled with the installed `akb` plugin (Claude Code or +Cursor). `tools/resolve_kb.py` prints which one, or the exact problem. The +Cursor rule `rules/apollo-v4.mdc` only points at this file and those skills. + Claude Code users install the skills once with `/plugin marketplace add ApolloTeam-dev/ApolloKnowledgeBase` and `/plugin install akb@apolloknowledgebase`; they are then called as -`/akb:apollo-build` and so on. +`/akb:apollo-build` and so on. Cursor users install the plugin as described +in [docs/cursor-plugin.md](docs/cursor-plugin.md) and call `/apollo-new-project`, +`/apollo-build`, and `/akb-lesson`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2553550..991b5a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,12 @@ Not content: `templates/` (file, repo and seed templates), `sources/` skills, step 2), `evals/` (AI benchmarks, step 5), `tools/` (CI scripts, and the V4 test runner in `tools/v4/`). +`docs/` is operational documentation: how to install or check an editor +plugin. It is not Apollo V4 knowledge, it is not written from +`templates/files/`, and it has no knowledge-base frontmatter. The Cursor +guide is `docs/cursor-plugin.md`. `rules/` holds editor rules that point +at `AGENTS.md`. Those rules are not knowledge-base content either. + Each chip folder keeps its register map in `registers.md` inside that folder. The official SAGA register documentation is generated into `core/saga-registers/` (document intake, section 11); the chip folders link @@ -147,8 +153,10 @@ hardware programming during a takeover goes in `core/`. Both use ## 4. Frontmatter -Every file starts with YAML frontmatter. CI rejects files with missing -required fields or invalid values. +Every knowledge-base content file starts with YAML frontmatter. CI rejects +content files with missing required fields or invalid values. Operational +documentation does not use this frontmatter: `docs/`, `README.md`, +`AGENTS.md` and this file (section 2). ```yaml --- @@ -407,7 +415,11 @@ On every merge to `main`, `generate_codeowners.py` regenerates `.github/CODEOWNERS.base`. The `seed/`, `sources/` and `templates/` folders are excluded from content -checks. +checks. `docs/` and `rules/` are excluded from the content frontmatter +check only (`tools/kblib.py`). They are operational documentation and +editor rules, not knowledge-base files, so they do not take knowledge-base +frontmatter. `docs/*.md` stays in the internal-link check and in Markdown +lint. `tools/check_links.py` does not skip `docs/`. Run the checks locally before opening a pull request: @@ -415,6 +427,10 @@ Run the checks locally before opening a pull request: pip install pyyaml python tools/check_frontmatter.py python tools/check_links.py +python tools/check_skills.py +python tools/check_shared_workflows.py +python tools/check_cursor_plugin.py +python tools/check_claude_plugin.py ``` --- @@ -485,20 +501,35 @@ skill points to it. - **Format:** the open Agent Skills format. One folder per skill, `skills//SKILL.md`, with frontmatter `name` (equal to the folder name: lowercase letters, digits and single hyphens) and `description` - (what the skill does and when to use it, at most 1024 characters). No - other frontmatter fields, so every agent can read it. + (what the skill does and when to use it, at most 1024 characters, on one + line). No other frontmatter fields, so every agent can read it. - **Description:** the agent decides from it alone whether to use the skill. Name the tasks and the words developers use, and say "even when it looks like ordinary m68k or Amiga work" where AGENTS.md section 2 applies. - **Body:** at most 500 lines. Point to knowledge base files as `KB `; don't copy their content. Files of the skill itself (`scripts/`, `assets/`) are referenced relative to its folder. -- **Scripts:** POSIX `sh`, no Claude-specific variables. Code in `assets/` - must build with ApolloCrossDev without warnings. +- **Scripts:** POSIX `sh`, no Claude-specific variables. The file in + `skills//scripts/` is the entry point the skill runs. It may call + one shared program in `tools/` written with the Python standard library. + Both plugins use that same entry point. Do not put a second copy of the + program under `skills/`, and do not replace the `sh` entry point with a + Python script. Code in `assets/` must build with ApolloCrossDev without + warnings. - **New skills** are listed in AGENTS.md section 9 in the same pull request. -- Claude Code installs `skills/` as the plugin `akb` (`.claude-plugin/`); - other agents read it through AGENTS.md section 9. +- Claude Code installs `skills/` as the plugin `akb` (`.claude-plugin/`). +- Cursor installs the same `skills/` as the plugin `akb` + (`.cursor-plugin/`). See [docs/cursor-plugin.md](docs/cursor-plugin.md). + The skill files stay the canonical workflow; do not keep a second copy + for one editor. +- Other agents read the skills through AGENTS.md section 9. CI runs `tools/check_skills.py` on every pull request: frontmatter, name, -description length, body length, and that every `KB ` and file of -the skill exists. +description length, a single-line description, body length, and that every +`KB ` and file of the skill exists. It also runs +`tools/check_shared_workflows.py` (those entry points, in a temporary +directory), `tools/check_cursor_plugin.py` and +`tools/check_claude_plugin.py` (plugin manifests). The manifest checks are +static: they do not load Cursor or Claude Code. The workflow check prints +`NOT VERIFIED` for a guided build when ApolloCrossDev is absent, and that +line is not a successful compile. diff --git a/README.md b/README.md index 1411b4a..ddc63c5 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,23 @@ execution mode (`os-friendly` or `os-takeover`) and V4 model it applies to. AI agents working in that repository then find and follow the knowledge base automatically. +Claude Code and Cursor load the same three skills as the plugin `akb`. +These are the entry points. The procedures stay in the skill files. + +- Claude Code: `/plugin marketplace add ApolloTeam-dev/ApolloKnowledgeBase`, + then `/plugin install akb@apolloknowledgebase`. The skills are + `/akb:apollo-new-project`, `/akb:apollo-build` and `/akb:akb-lesson`. + On this fork, point that marketplace at + `AmanitaHouse/ApolloKnowledgeBase` when you want these adaptations. + The marketplace name stays `apolloknowledgebase` (`AGENTS.md` section 9). +- Cursor: install `akb` as described in + [docs/cursor-plugin.md](docs/cursor-plugin.md), then + `/apollo-new-project`, `/apollo-build` and `/akb-lesson`. + +`apollo-new-project` on this fork tracks +`https://github.com/AmanitaHouse/ApolloKnowledgeBase` unless the developer +asks for `https://github.com/ApolloTeam-dev/ApolloKnowledgeBase`. + --- ## Contributing diff --git a/docs/cursor-plugin.md b/docs/cursor-plugin.md new file mode 100644 index 0000000..0155de4 --- /dev/null +++ b/docs/cursor-plugin.md @@ -0,0 +1,358 @@ +# Cursor plugin + +This file is operational documentation for the Cursor plugin. It is not +Apollo V4 knowledge and it has no knowledge-base frontmatter +(`CONTRIBUTING.md` sections 2 and 4). + +The `akb` plugin packages ApolloKnowledgeBase for Cursor. It is the same +knowledge base and the same three skills as the Claude Code plugin. Cursor +discovers them from `.cursor-plugin/plugin.json`, `skills/`, and `rules/`. + +Apollo Team wrote the knowledge base and the original skills. This repository +is the AmanitaHouse fork. The fork adds the Cursor package and points new +projects at this fork unless you ask for the Apollo Team repository. + +## What it does + +After installation, Cursor Agent can run three skills: + +| Skill | Invocation | What it does | +|---|---|---| +| `apollo-new-project` | `/apollo-new-project` | Guided or basic setup of an Apollo V4 project | +| `apollo-build` | `/apollo-build` | Find ApolloCrossDev, build with `make compile`, fix the cause of diagnostics | +| `akb-lesson` | `/akb-lesson` | Draft a lesson, validate it, and submit only after you approve | + +The plugin does not copy the knowledge base into the prompt. The agent reads +`AGENTS.md` and then the files that document says to read. + +A short rule, `rules/apollo-v4.mdc`, is available when the work is about the +68080, SAGA, ApolloOS, AmigaOS on V4, or ApolloCrossDev. It is not applied to +unrelated projects. + +## Requirements and platforms + +- Cursor with local plugin imports allowed. On Enterprise, an admin controls + this under Dashboard, Settings, Security and Identity, Marketplace and Plugins. +- Python 3. `tools/check_frontmatter.py` and `tools/check_links.py` + also need [PyYAML](https://pypi.org/project/PyYAML/). The skill entry + points do not import PyYAML. `tools/submit_gate.py` uses the standard + library only. Do not install PyYAML into a system or distro Python + unless the developer agrees. The host-launch section says how to run + the checkers with an interpreter that already has it, or with an + isolated virtual environment. +- Git, for a project submodule. +- A POSIX shell (`sh`) on Linux, macOS, WSL, and Git Bash. Skill scripts + are `sh` entry points, the same rule as `CONTRIBUTING.md` section 12. + Two of them call Python 3 standard-library programs in `tools/`: + `tools/write_project_files.py` and `tools/submit_gate.py`. There is one + copy of each program. On Git Bash (`MSYSTEM` is set) those entry points, + and `find-acd.sh`, re-exec under WSL when `wsl.exe -e python3` works. + A Git Bash path `/x/...` or a Windows path `X:\...` becomes `/mnt/x/...` + with `MSYS_NO_PATHCONV=1`, because WSL Python cannot open an `X:/...` + path. A Git Bash path that exists in that shell, such as `/tmp/...`, is + mapped with `cygpath -w` first. A WSL path that Git Bash cannot see, + such as `/home//ApolloCrossDev`, is left unchanged. Flags, + slugs and URLs are not rewritten. + `APOLLOCROSSDEV` is forwarded only when it is already set. + If WSL Python is not usable the entry point prints `PROBLEM=` and + `RECOVERY=` and does not pretend the Windows Store `python3` alias ran. + Windows PowerShell is not one of those shells. Use the host-launch + section. Do not call `sh`, `python`, or `python3` from PowerShell. +- ApolloCrossDev (GCC 6.5 with the 68080 patches, and vasm) when you want to + compile. Its install scripts support macOS and Linux. Windows is not a + build host; a Linux environment such as WSL is, when ApolloCrossDev is + installed there. +- The `gh` command only if you later ask to open a lesson pull request. + +The agent must not run `sudo`, edit your shell startup files, change git +remotes, or upload to the V4 unless you agree in the conversation. + +## Host launch + +The same three skills run in Claude Code and in Cursor. Their entry points +stay the `sh` scripts. Their programs stay the Python files in `tools/`. +Nothing in this section adds a Windows or Claude copy of those programs. + +| Shell | How to run an entry point | How to run a Python program the skill names | +|---|---|---| +| Linux, macOS, a shell that is already WSL | `sh