open-design/apps/daemon/tests/plugins-bundled-atom-prompts-default.test.ts
Cursor Agent b7f0fc0d96
feat(daemon): flip OD_BUNDLED_ATOM_PROMPTS default to ON (Phase 4)
Plan V1 / spec §23.4.

The bundled SKILL.md fragment library now covers every Phase 6/7/8
atom impl shipped this changeset (build-test, code-import,
design-extract, figma-extract, token-map, rewrite-plan, patch-edit,
diff-review, handoff). The §3.M3-M5 audit-block on flipping the
default-active flag is therefore lifted.

The new policy:

  default:                      ON   (activeStageBlocks render)
  OD_BUNDLED_ATOM_PROMPTS unset ON
  OD_BUNDLED_ATOM_PROMPTS=''    ON
  OD_BUNDLED_ATOM_PROMPTS=1     ON
  OD_BUNDLED_ATOM_PROMPTS=0     OFF  (explicit opt-out for
                                      snapshot replay against
                                      pre-§3.V1 daemons + regression
                                      bisects that need byte-equal
                                      pre-flip prompts)
  OD_BUNDLED_ATOM_PROMPTS=*     ON   (forward-compat)

Effect: a run with a plugin snapshot whose pipeline carries any
of the bundled atoms now ALWAYS gets the matching SKILL.md fragments
spliced in as 'Active stage' blocks ahead of the rest of the prompt,
without operators having to set the env var. Runs without a
snapshot keep byte-equal prompts (the snapshotId guard short-
circuits the build).

Daemon tests: 1661 \u2192 1666 (+5 cases on
plugins-bundled-atom-prompts-default: ON when unset / empty / '1'
/ unknown values; OFF only when explicit '0').

Co-authored-by: Tom Huang <1043269994@qq.com>
2026-05-09 16:15:31 +00:00

41 lines
1.7 KiB
TypeScript

// Plan §3.V1 — OD_BUNDLED_ATOM_PROMPTS default is now ON.
//
// This test pins the contract: a daemon that never sets the env var
// behaves as if the flag is enabled. Setting it to '0' explicitly
// is the documented opt-out (e.g. for snapshot-replay against an
// older daemon, or for regression bisects that need byte-equal
// pre-§3.V1 prompts).
import { describe, expect, it } from 'vitest';
// The check used in apps/daemon/src/server.ts to decide whether to
// build activeStageBlocks. We pin the exact predicate so a future
// PR can't silently flip the default back to opt-in by tightening
// the comparison without updating this test.
function bundledAtomPromptsEnabled(env: Record<string, string | undefined>): boolean {
return env.OD_BUNDLED_ATOM_PROMPTS !== '0';
}
describe('OD_BUNDLED_ATOM_PROMPTS default policy', () => {
it('is ON when the env var is unset', () => {
expect(bundledAtomPromptsEnabled({})).toBe(true);
});
it("is ON when the env var is empty (treated as 'not opted out')", () => {
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: '' })).toBe(true);
});
it("is ON when the env var is explicitly '1'", () => {
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: '1' })).toBe(true);
});
it("is OFF when the env var is explicitly '0' (documented opt-out)", () => {
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: '0' })).toBe(false);
});
it("is ON for any non-'0' value (forward-compat)", () => {
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: 'true' })).toBe(true);
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: 'false' })).toBe(true);
expect(bundledAtomPromptsEnabled({ OD_BUNDLED_ATOM_PROMPTS: 'yes' })).toBe(true);
});
});