Skip to content

@ogygia/flags

Flag manifest

Every build with flags() writes an inventory of the app's flag() calls to node_modules/.ogygia/flags-manifest.json, so CI can diff it per release and catch flags that outlived their purpose.

On this page

Flags go stale. A rollout reaches 100% and nobody deletes the flag, an experiment ends and both branches stay, and a year later nobody knows which flags still matter. Because ogygia’s flags are declared in code, the build can list them all. Every vite build with flags() listed writes that list, and the build prints where:

flags manifest: 12 flag(s) → node_modules/.ogygia/flags-manifest.json

Contents

The manifest has every flag() call site in the app’s source, and the sorted list of names. A call site is { name, kind, file, line }, where file is relative to the project root and kind is always 'flag'. A name declared in two places appears twice in flags and once in names.

{
  "flags": [
    {
      "name": "hero",
      "kind": "flag",
      "file": "src/lib/flags.ts",
      "line": 3
    },
    {
      "name": "new-checkout",
      "kind": "flag",
      "file": "src/lib/flags.ts",
      "line": 4
    }
  ],
  "names": ["hero", "new-checkout"]
}

What it finds

The inventory reads the source, so it lists every module that imports @ogygia/flags, used by a route or not, and needs no request to have run. It parses each module rather than searching its text:

  • named, renamed (import { flag as f }) and namespace (import * as og from '@ogygia/flags') imports all count;
  • an unrelated function that happens to be called flag doesn’t;
  • <script> blocks in .svelte files count, with the line numbers of the file;
  • a call whose first argument isn’t a string literal (flag(name), a template with ${}) is skipped, since its name isn’t known until it runs;
  • a local declaration that shadows an imported flag inside a nested scope isn’t told apart, and still counts.

Without the plugin

Without flags() there’s no manifest, and the build says plugin_not_listed once, naming the first module that imports @ogygia/flags. A file system the build can’t write to never fails the build over the manifest; it’s skipped. The dev server writes none.

CI checks

Keep the manifest as a CI artifact and diff it per release: a flag that appeared, one that went away, and one that’s still there. A flag has no expiry date in code, so keep one next to it, a comment or a table in your repo, and fail the build when a name lives past its date. Retiring a flag stays a human edit: delete the flag, keep the branch that won.

The ogygia_flags tool of ogygia’s MCP server lists every flag() call site in the project and compares them with the last build’s manifest, so an agent can find dead flags for you.

import { readFileSync } from 'node:fs';

const manifest = JSON.parse(
  readFileSync(
    'node_modules/.ogygia/flags-manifest.json',
    'utf8'
  )
) as {
  names: string[];
};
// each flag's retirement date, kept by hand in the repo
const retire = JSON.parse(
  readFileSync('flags-retire.json', 'utf8')
) as Record<string, string>;

const overdue = manifest.names.filter(
  (n) => retire[n] && new Date(retire[n]) < new Date()
);
if (overdue.length) {
  console.error(
    `flags past their retirement date: ${overdue.join(', ')}`
  );
  process.exit(1);
}