Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "flowapi",
"owner": {
"name": "Localix Lab"
},
"description": "flowapi's agent plugin, installed from flowapi's own repository.",
"plugins": [
{
"name": "flowapi",
"source": "./plugins/flowapi",
"description": "Types and SDKs from API descriptions with flowapi: the library's documentation for any agent, and a pipeline that writes a TypeScript SDK repository from an OpenAPI description, checked by a deterministic judge."
}
]
}
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ concurrency:

jobs:
# scripts/check as it runs locally: formatting, the lints, the tests, the wasm build and the
# oracles (O3 for both targets, O5, O2, O8 for both SDKs, the ledger's report); then the npm
# oracles (O3 for both targets, O5, O2, O8 for both SDKs, the ledger's report) and the agent
# plugin's tests (plugins/flowapi); then the npm
# package, built and held to the Rust command byte for byte. The benchmarks are not run here.
check:
runs-on: ubuntu-24.04
Expand Down
15 changes: 14 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ work here.
license, `repo/texts.rs` the scripts, CI, release-please and the repository's `AGENTS.md`,
`repo/mock.rs` the mock server's routes, `repo/suite.rs` a test per resource, `repo/readme.rs`
`README.md` and `api.md`, `repo/example.rs` a schema's example value, `repo/lock.rs`
`.flowapi/lock.json` (the shape the `sdk-anything` plugin reads), `repo/plan.rs` what writing the
`.flowapi/lock.json` (the shape the agent plugin reads), `repo/plan.rs` what writing the
repository changes on disk (`plan`: by the lock and what the host found at each path; every host
runs it, none decides alone); `repo/files/` the texts printed
as they are (scripts, `server.mjs`, the licenses); `sha256.rs` our own SHA-256.
Expand Down Expand Up @@ -105,6 +105,16 @@ work here.
TypeScript compiler they check with (`ts/`), and their results (`results/`, `REPORT.md`).
- `bench/`: the benchmarks against the other generators, their budgets and results
([bench/README.md](bench/README.md)); `bench/competitors/` the other tools, pinned.
- `plugins/flowapi/`: the agent plugin `flowapi`, a Claude Code plugin and an Agent Plugins
1.1.0 core package in one folder ([plugins/flowapi/AGENTS.md](plugins/flowapi/AGENTS.md) is
its guide): the `flowapi` skill (how to use flowapi), the `sdk` skill (`/flowapi:sdk`, an SDK
repository from a description, checked by its judge), the guard hook that keeps generated
files out of hand edits, and Node tests. Its version is the workspace's, held by its tests.
The `flowapi` skill's `references/` are copies of the README, `npm/README.md` and the commands'
help, written by `plugins/flowapi/scripts/docs.mjs`: an installed plugin cannot read outside
its folder, so after changing one of those, run the script (its test fails until you do).
- `.claude-plugin/marketplace.json`: this repository as a Claude Code marketplace, its one entry
`plugins/flowapi` (`claude plugin marketplace add localixai/flowapi`).

## Commands

Expand Down Expand Up @@ -135,6 +145,9 @@ cargo test -p flowapi-sdk --test repo # the repositories kept i
cargo test -p flowapi-cli --test generate_cli # generate's writing rules as the command runs them
node crates/flowapi-sdk/tests/tsc.mjs # them type-checked after --sdk; after cargo build --release
cargo run --release -p flowapi-cli -- <description.json> -o types.ts
(cd plugins/flowapi && npm test) # the agent plugin; its e2e on target/release/flowapi
(cd plugins/flowapi && npm run docs) # the flowapi skill's references, after a docs change
claude plugin validate . --strict # the marketplace; in plugins/flowapi, the plugin
bench/run.sh # the benchmarks, then held to bench/budgets.json
```

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

- The agent plugin `flowapi` (`plugins/flowapi`), installed from this repository as a
marketplace (`claude plugin marketplace add localixai/flowapi`, then
`claude plugin install flowapi@flowapi`). It is a Claude Code plugin and an Agent Plugins 1.1.0
core package in one folder. The `flowapi` skill covers how to use flowapi, with its docs
copied as references. The `sdk` skill, `/flowapi:sdk`, writes an SDK repository from a
description with `flowapi-sdk.yml`, `generate` and a judge (determinism, typecheck, lint,
build, the built types, the package, the tests). `/flowapi:refine`, `update` and `release`
take it further, and a guard hook refuses hand edits of the files `.flowapi/lock.json` lists.
Its version is flowapi's.

## 0.2.0 — 2026-11-26

- `flowapi generate <flowapi-sdk.yml> --out <dir> [--check]` writes a TypeScript SDK's whole
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ npx @localix-ai/flowapi openapi.json -o types.ts
```

It has the commands for an SDK's config too (`summary`, `config draft|schema|check`, below), with
the Rust command's output byte for byte; `generate` is the Rust command's alone for now.
the Rust command's output byte for byte, and `generate` (below) the same files, lock included.

The Rust command, built from a release tag:

Expand Down Expand Up @@ -221,7 +221,7 @@ and a boundary RFC 2046 does not allow or a part holds (`boundary`). A header's
operation, with a warning. The output imports nothing: the runtime is a few functions
printed once. With `--sdk` the base URL and any authentication are still yours to add: the
command does not print `servers`, `securitySchemes` or `security`. The SDK layer
(`crates/flowapi-sdk`, not yet behind a command) reads them, Swagger 2.0's `host`, `basePath` and
(`crates/flowapi-sdk`, the one `generate` writes a client with) reads them, Swagger 2.0's `host`, `basePath` and
`schemes` included, and prints a table to put after this output: the servers with their
variables, the security schemes, and each operation's method, path, own servers, security and
how each response body is read. Every row of the specification's
Expand Down Expand Up @@ -322,6 +322,30 @@ written and it exits 1; `src/lib/` and `examples/` are the user's, `CHANGELOG.md
and a file the lock does not list is never touched. A file no longer generated is deleted unless
changed. Every write is staged first, so a refusal leaves the folder as it was.

## Use it from an agent

This repository is also a plugin marketplace. Its plugin, `flowapi`, gives a coding agent
flowapi's documentation and the SDK pipeline above:

```sh
claude plugin marketplace add localixai/flowapi
claude plugin install flowapi@flowapi
```

In Claude Code 2.1.275 or later, one step does both: `/plugin install flowapi --marketplace localixai/flowapi`.

- The `flowapi` skill says which output fits which need (types, `--sdk` functions, a whole SDK
repository) and carries this README's usage, the npm package's API and the commands' help.
- The `sdk` skill, `/flowapi:sdk <description> [folder]`, makes an SDK repository: summary, a
drafted `flowapi-sdk.yml` the agent edits, `config check`, `generate`, then a judge
(determinism, typecheck, lint, build, the built types, the package, the tests against the mock
server), and around again until the judge passes. `/flowapi:refine`, `/flowapi:update` and
`/flowapi:release` take it further; a hook refuses hand edits of generated files.

The same folder is an Agent Plugins 1.1.0 core package, so a core client loads the skills and
the hook too. Node 20 or newer must be on `PATH`. More in
[plugins/flowapi/README.md](plugins/flowapi/README.md).

## How it works

The core (`crates/flowapi`) reads the documents into a graph of types that belongs to no
Expand Down
4 changes: 2 additions & 2 deletions crates/flowapi-sdk/src/repo/lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `.flowapi/lock.json`: the state of a generated repository, in the shape the `sdk-anything`
//! plugin reads (its `docs/lock.md`): the lock's format version, the flowapi that wrote it, the
//! `.flowapi/lock.json`: the state of a generated repository, in the shape the agent plugin
//! reads (`plugins/flowapi/docs/lock.md`): the lock's format version, the flowapi that wrote it, the
//! hashes of the description and the config, the methods the config maps, every generated file
//! with the SHA-256 of its bytes, and the names pinned when two would collide. Printed as stable
//! JSON (keys in a fixed order, files sorted, two spaces), read back from JSON text.
Expand Down
21 changes: 21 additions & 0 deletions plugins/flowapi/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "flowapi",
"displayName": "flowapi",
"version": "0.2.0",
"description": "Types and SDKs from API descriptions with flowapi: the library's documentation for any agent, and a pipeline that writes a TypeScript SDK repository from an OpenAPI description, checked by a deterministic judge.",
"author": {
"name": "Localix Lab"
},
"homepage": "https://github.com/localixai/flowapi",
"repository": "https://github.com/localixai/flowapi",
"license": "MIT",
"keywords": [
"openapi",
"json-schema",
"typescript",
"rust",
"sdk",
"codegen",
"agents"
]
}
72 changes: 72 additions & 0 deletions plugins/flowapi/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# AGENTS.md: the flowapi plugin

flowapi's plugin for coding agents, in flowapi's repository (`plugins/flowapi`), installed from
its marketplace (`.claude-plugin/marketplace.json` at the repository root). It carries flowapi's
documentation (the `flowapi` skill) and the SDK pipeline: an agent writes `flowapi-sdk.yml`,
flowapi (`bin/flowapi`: `npx -y @localix-ai/flowapi@<lib/flowapi-version>`) generates a
TypeScript SDK repository from an OpenAPI description and that config, a deterministic judge
checks it, and the agent fixes the config until the judge passes. The repository's rules
(`../../AGENTS.md`) bind here too; this file adds the plugin's.

## Layout

| Path | What it is |
| --- | --- |
| `.claude-plugin/plugin.json`, `hooks/hooks.json` | The Claude Code form: the manifest and its hooks |
| `plugin.json`, `hooks.json` | The Agent Plugins 1.1.0 core form: the same plugin for a core client. A client that reads both loads the Claude Code form alone (Agent Plugins Extended §1.3.1) |
| `hooks/guard.mjs` | The guard, one script for both: no argument is Claude Code's PreToolUse on Edit, Write, MultiEdit, NotebookEdit, answering `hookSpecificOutput` with `permissionDecision: "deny"`; `core` reads the core's `file.modify` tool profile and answers `{ "decision": "deny", "reason" }` (core §7.3.6). Silence is no opinion: it never answers `allow`. Exit code 0 always |
| `lib/guard.mjs` | The guard's decision: `decide` (Claude Code's event), `decideCore` (the core's), the nearest `.flowapi/lock.json`, its `files`, the custom zones |
| `bin/judge.mjs` | The judge's command line: `judge.mjs <sdk-dir> [--steps] [--json] [--keep-going] [--generate] [--timeout]` |
| `lib/judge.mjs` | The judge's steps 0-6 and the report |
| `bin/flowapi`, `lib/flowapi-version` | flowapi at the one pinned version, through `npx`; `FLOWAPI_PLUGIN_FLOWAPI` runs another flowapi instead |
| `lib/run.mjs`, `lib/tree.mjs`, `lib/tools.mjs` | Running a command with a time limit; comparing two trees; the pinned tool versions (flowapi's read from `lib/flowapi-version`) and `FLOWAPI_PLUGIN_NPX` |
| `skills/flowapi/` | How to use flowapi. `references/*.md` are generated (below) |
| `skills/sdk/` | The SDK pipeline, `/flowapi:sdk`, and `references/config.md`, the config's catalogue. A skill, not a command: a command of the same name would hide it (Extended §4.6.1), and a core client loads skills but no commands |
| `commands/`, `agents/sdk-reviewer.md` | `/flowapi:refine`, `update`, `release`; the read-only reviewer. Claude Code's alone |
| `docs/lock.md` | The lock's shape the plugin relies on |
| `scripts/docs.mjs` | Writes `skills/flowapi/references/` from flowapi's docs; `--check` writes nothing and exits 1 when one differs |
| `test/` | Node tests (`npm test`): the guard in both forms and as a hook, the two packagings and the version, the references, the judge on a stand-in SDK, and the pipeline end to end on `test/fixtures/pets.json` with a real flowapi (skipped without one) |

## The references are copies

The `flowapi` skill's references are flowapi's own docs: the README's "Use" and "How it holds to
the specification", `npm/README.md`, and the commands' help (`crates/flowapi-cli/src/args.rs`,
`npm/src/cli.ts`). Those stay the source of truth. An installed plugin is a copy of this folder
alone and cannot read a file outside it (core §4.1), so the skill carries copies, each with a
first line naming its source. After a change to a source, run `node scripts/docs.mjs`; never edit
a reference by hand. `test/docs.test.mjs` fails when one differs from what the script writes.

## Commands

| Command | |
| --- | --- |
| `npm test` | Every test, fast and offline: `npx` is a stand-in (`FLOWAPI_PLUGIN_NPX`); the end-to-end test uses `FLOWAPI_PLUGIN_FLOWAPI` or the repository's `target/release/flowapi` and runs judge step 0 only |
| `npm run test:e2e` | The end-to-end test with judge steps 0-6 (`FLOWAPI_PLUGIN_E2E=1`: installs the SDK's TypeScript, fetches publint and attw) |
| `npm run docs` | Writes the `flowapi` skill's references; `node scripts/docs.mjs --check` checks them |
| `npm run validate` | `claude plugin validate . --strict`; at the repository root, the same validates the marketplace |
| `claude --plugin-dir plugins/flowapi` | The working tree in a real session |

## Rules

- **The agent never edits generated SDK files.** Everything listed in the lock's `files` outside
`src/lib/` and `examples/` is changed through `flowapi-sdk.yml` and `generate`. Every command,
skill and agent here says so, and the guard enforces it.
- **The guard fails open and stays cheap.** It reads the event and the lock, starts no process,
prints nothing but a denial, and exits 0 on any error: a broken lock must not block the person.
- **The judge is deterministic and never passes silently.** A missing script is `skip` with its
reason; the verdict is `pass` only when every step run passed. It installs nothing, publishes
nothing, and reaches the network only through `npx` fetching a pinned tool.
- **Tool versions are pinned** in `lib/tools.mjs`; the flowapi version comes from the lock.
- **Both forms stay equivalent.** The two manifests carry the same fields (the core one adds
`$schema`); an event added to `hooks/hooks.json` that the core defines is added to `hooks.json`;
skills use the Agent Skills fields alone, so both forms read them alike. `test/manifest.test.mjs`
and `test/hooks.test.mjs` hold this.
- **One version.** The plugin's version is flowapi's (`[workspace.package] version` in
`Cargo.toml`): both manifests, `package.json` and `lib/flowapi-version` change with it, and a
test fails when they differ. `bin/flowapi` then runs that release from npm, so a version is
raised here when its npm package is published.
- **No dependencies.** Node 20 or newer, ES modules (`.mjs`), the standard library only.
- **Every user-visible change** gets a line in `CHANGELOG.md` under `## Unreleased`, and in the
repository's `CHANGELOG.md`.
- No source file over 300 lines of working code. English only. No marketing words, and in the plugin's own
prose no other generator or company named (the references copy flowapi's docs as they are). Commit only when asked; never push unasked.
19 changes: 19 additions & 0 deletions plugins/flowapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

## Unreleased

- The plugin, on flowapi 0.2.0, as a Claude Code plugin and an Agent Plugins 1.1.0 core package
in one folder, installed from flowapi's repository (`flowapi@flowapi`).
- The `flowapi` skill: how to use flowapi, with flowapi's own docs as its references, copied by
`scripts/docs.mjs` and held to their sources by a test.
- The `sdk` skill (`/flowapi:sdk`): summary, draft, config, check, generate, install, judge;
the config's catalogue (`references/config.md`). `/flowapi:refine`, `update` and `release`;
the read-only `sdk-reviewer` agent.
- `bin/flowapi`, flowapi at the version in `lib/flowapi-version` through `npx`, or
`FLOWAPI_PLUGIN_FLOWAPI`.
- The guard hook, which refuses a hand edit of a file listed in `.flowapi/lock.json` (outside
`src/lib/` and `examples/`) and of the lock itself: in Claude Code on Edit, Write, MultiEdit
and NotebookEdit, in a core client on the `file.modify` tool profile.
- The judge, `bin/judge.mjs`, with steps 0-6 (determinism, typecheck, lint, build, dist types,
package, test) and a JSON report; the lock's shape in `docs/lock.md`; an end-to-end test of the
pipeline (`npm run test:e2e`).
21 changes: 21 additions & 0 deletions plugins/flowapi/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 LocalixAI and flowapi contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading