diff --git a/.changeset/flags-files.md b/.changeset/flags-files.md new file mode 100644 index 000000000..f1a2728f4 --- /dev/null +++ b/.changeset/flags-files.md @@ -0,0 +1,7 @@ +--- +'flags': minor +'@flags-sdk/next': minor +'@flags-sdk/vite': minor +--- + +Flags files: declare the flags of an application in `app.flags` (`flag summerSale { key: "summer-sale", defaultValue: false }`: the name which the code imports, and the key in the flag management system), and import them with `import { summerSale } from './app.flags'`, or from their source with `import { summerSale } from 'flags:self'`, which has the flags of the source from all flags files. A flag can set its own `source`. The framework plugins compile each flags file into `defineSource` and `source.bindFlag`, without the network. `node --import flags/register` does the same without a bundler. For the types, the SDK writes `app.d.flags.ts` next to each file, for `allowArbitraryExtensions`, and TypeScript 7.1 can also read flags files with the content mapper of `flags` (`"contentMappers": [{ "package": "flags", "extensions": [".flags"] }]`). An application with flags files uses no catalogs. `flags format` formats flags files (`--check` for CI, `--stdin` for editors such as Zed), and `formatFlagsFile` of `flags/tooling` is the formatter. diff --git a/.github/workflows/tag-canary.yaml b/.github/workflows/tag-canary.yaml index 1c4f64a14..94f5117ea 100644 --- a/.github/workflows/tag-canary.yaml +++ b/.github/workflows/tag-canary.yaml @@ -47,7 +47,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version-file: ".node-version" registry-url: https://registry.npmjs.org diff --git a/.zed/settings.json b/.zed/settings.json index d033e9644..b8b34b205 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -9,7 +9,22 @@ "TSX": { "formatter": { "language_server": { "name": "biome" } } }, "JSON": { "formatter": { "language_server": { "name": "biome" } } }, "JSONC": { "formatter": { "language_server": { "name": "biome" } } }, - "CSS": { "formatter": { "language_server": { "name": "biome" } } } + "CSS": { "formatter": { "language_server": { "name": "biome" } } }, + // The formatter of the workspace package. Run `pnpm build -F flags` first + "Flags": { + "formatter": { + "external": { + "command": "node", + "arguments": [ + "packages/flags/bin/flags.js", + "format", + "--stdin", + "--stdin-filepath", + "{buffer_path}" + ] + } + } + } }, "auto_install_extensions": { "biome": true diff --git a/AGENTS.md b/AGENTS.md index 424d525a3..7d3395fc3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,3 +2,41 @@ - Always use curly braces for `if`, `else`, loop, and other control-flow bodies in newly added code, including single-statement bodies. Do not refactor existing code solely to add braces. - Avoid nested ternary expressions. Prefer explicit conditionals or small helper functions so each branch is easy to follow. + +# Repository + +pnpm (10.19) + Turborepo monorepo of the Flags SDK. Node `^22.11 || ^24 || >=26`. + +The `standard` branch holds the Flags SDK v5 rewrite ("one standard for every framework"). Its spec is `packages/flags/SPEC.md`, the normative rules are `packages/flags/STANDARD.md`, and the guide for framework authors is `packages/flags/FRAMEWORK-AUTHORS.md`. Read the relevant section of `SPEC.md` before changing v5 behavior, and update it in the same change. + +## Layout + +| Path | Contents | +| --- | --- | +| `packages/flags` | The main SDK, published as `flags` (not `@vercel/flags`, which is the old name). Exports `flags`, `flags/runtime`, `flags/explorer`, `flags/manifest`, `flags/tooling`, `flags/config`, `flags/settings`, `flags/hooks`, `flags/framework` and the `flags` CLI. | +| `packages/framework-*` | One package per framework: `@flags-sdk/next`, `vite`, `sveltekit`, `nuxt`, `tanstack-start`, `hono`, `express`. They use only the public API of `flags`. | +| `packages/adapter-*` | Provider adapters, published as `@flags-sdk/`. | +| `packages/vercel-flags-core` | `@vercel/flags-core` (keeps the `@vercel` scope): the Vercel Flags evaluation engine and `VercelProvider`. It has its own `CLAUDE.md`. | +| `packages/conformance`, `packages/prepare-flags-definitions` | Conformance tests for the standard; the build step that embeds flag definitions. | +| `apps/docs` | flags-sdk.dev (Geistdocs). Follow `apps/docs/AGENTS.md`. | +| `apps/playground`, `apps/shirt-shop-api` | Next.js apps. | +| `examples/` | `standard/*` (v5 examples), `providers/*` (one per provider), `playgrounds/*`, `shirt-shop`, `snippets`, `sveltekit-example`. | +| `tests/standard/*` | v5 integration apps per framework (next, next-cache-components, sveltekit, nuxt, tanstack-start, hono, express). `tests/` also has the older e2e apps. | +| `skills/` | Agent skills `flags-sdk` and `vercel-flags`. Keep them in line with the API when it changes (`pnpm validate-skills`). | + +## Commands + +- From the root: `pnpm build` (packages only), `pnpm test`, `pnpm type-check`, `pnpm check` (biome), `pnpm format`. +- One workspace: `pnpm