Skip to content

[wip] cf-os api: generate from upstream's API schema, and print its declarations - #23

Closed
Maximo-Guk wants to merge 3 commits into
cf-os-apifrom
cf-os-api-schema
Closed

Maximo-Guk wants to merge 3 commits into
cf-os-apifrom
cf-os-api-schema

Conversation

@Maximo-Guk

@Maximo-Guk Maximo-Guk commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

WIP

Stacked on #19. Builds on cloudflare/cloudflare-os#860, which moves the API schema extractor upstream into packages/api-schema.

  • The cf-os api generator reads the pin's packages/api-schema/generated/workshop-api.schema.json instead of extracting api.ts itself. That removes generator/extract.ts and typescript6 from this repository. The CLI emitter and the runtime stay here. A pin without that file, or a schema in a format other than capnweb-schema/0, fails with an error naming it.
  • Unchanged:
    • the stdout contract that cf-os update reads
    • --check and --since, including against a commit whose schema is still in the old format
    • the command table: commands.ts differs only in its header line
  • main.test.ts now also checks that nothing cf-os api loads can reach @gadgets/*.
  • New cf-os api types [<service>]: prints upstream's agent declarations, either the whole file or one service's fragment. It reads a copy generated beside the command table, so the declarations always match the commands. The copy adds about 78 KB to the gzipped tarball.

Preview pin. 02a2860 pins #860's branch with cf-os update --preview --to pull/860. Before this merges, the pin has to move to #860's commit on upstream's main.

Testing

  • pnpm lint and pnpm test pass.
  • pnpm api:generate reports no added, removed or changed commands.
  • pnpm cf-os api types AdminApi matches upstream's fragment. An unknown service exits 2 and lists the services.
  • pnpm cf-os update --dry-run --upstream still runs.

🤖 Generated with Claude Code

Maximo-Guk and others added 2 commits October 21, 2026 20:55
Pins cloudflare/cloudflare-os#860 at f6bf761 so `cf-os api` can be built
on its generated schema. A preview pin, not for merging: it moves to the
commit on upstream's main once #860 lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions

The generator reads the pin's packages/api-schema/generated/
workshop-api.schema.json (cloudflare/cloudflare-os#860) instead of
extracting api.ts itself, so the extractor and typescript6 leave this
repository; the CLI emitter and the runtime stay. A pin without the file,
or a schema in another format, fails naming it. The stdout contract,
--check and --since are unchanged, and the command table is the same.

`cf-os api types [<service>]` prints upstream's agent declarations, whole
or one service's fragment, from a copy generated beside the command table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ask-bonk

ask-bonk Bot commented Oct 22, 2026

Copy link
Copy Markdown

LGTM!

github run

@Maximo-Guk Maximo-Guk changed the title cf-os api: generate from upstream's API schema, and print its declarations [wip] cf-os api: generate from upstream's API schema, and print its declarations Oct 22, 2026
`cf-os api create-account <username> [--display-name <name>]` creates a
user to act as with `--username`, on a local dev server or test harness
(real deployments usually sign users in through Access). The password
comes only from CFOS_API_PASSWORD, hashed as password sign-in hashes it,
and never reaches argv, output or --dry-run; createAccount stays out of
the generated commands, and `create-account` is a reserved root name.

`cf-os api --help` and `search` now find it ("create a test user") and the
sign-in line for a local instance ("log in as bob"), so an agent learns
both from the CLI alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ask-bonk

ask-bonk Bot commented Oct 23, 2026

Copy link
Copy Markdown

LGTM!

github run

@Maximo-Guk

Copy link
Copy Markdown
Member Author

Superseded: the cf-os api CLI and its generator moved upstream into cloudflare-os as packages/api-cli (cloudflare/cloudflare-os#860), where its commands regenerate with the API. The starter's cf-os api becomes a thin delegate that runs the pinned submodule's copy; that change is on the cf-os-api-upstream branch.

@Maximo-Guk Maximo-Guk closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant