@reynsu/reactlens-diagnosis-prompts
v0.2.0
Published
Canonical diagnosis prompts + Zod Diagnosis schema + pure eval-metrics for the reactlens / nativelens AI failure-diagnosis loop. Pure helpers only — no LLM SDK dep.
Readme
@reynsu/reactlens-diagnosis-prompts
Diagnosis prompts + Diagnosis Zod schema + pure eval-metrics helpers for the reactlens / nativelens AI failure-diagnosis loop.
Published under @reynsu/ because the @reactlens npm scope is unclaimed. Inside the reactlens monorepo this package is still referenced via local imports; a follow-up swap PR will switch reactlens to consume the published version (mirroring the @reynsu/nativelens-event-protocol migration).
What's in the box
DIAGNOSE_SYSTEM_PROMPT— the system message that primes the agent on its job, the schema, and the confidence calibration.CLASSIFY_BUG_RUBRIC— the long-form classification rubric (real-bug/test-bug/flaky/env-issue), including the test-bug vs flaky disambiguation that traps overconfident classifiers.DiagnosisSchema+Diagnosistype — the canonical structured output. Schema-first; consumers parse agent output withDiagnosisSchema.safeParse(...).buildUserMessage(failure)— pure user-message builder (title, spec, error fence, component snapshot, truncation). Golden-testable.degradedDiagnosis(gitCtx?)— fallback when the agent exhausts retries. Deliberately emitsenv-issue/lowso the operator notices.TruthSchema,parseTruth,compareToTruth,aggregateMetrics— pure scoring helpers for the eval harness.falseConfidenceRateis surfaced explicitly as the primary regression signal.
What's NOT in the box (kept per-host)
- Agent runner implementations (Anthropic SDK, OpenAI, etc.) — consumers provide their own.
- Sandboxing logic for the eval pipeline (loading
component.tsx/spec.tsfrom disk). - Git context gathering (host-specific paths + tooling).
- The eval cases themselves (reactlens ships its under
tests/diagnostic-eval/cases/; nativelens will ship its own).
Usage
import {
DIAGNOSE_SYSTEM_PROMPT,
CLASSIFY_BUG_RUBRIC,
DiagnosisSchema,
buildUserMessage,
degradedDiagnosis,
type FailedTest,
type Diagnosis,
} from '@reynsu/reactlens-diagnosis-prompts';
const failure: FailedTest = {
testId: 'cart-flow:tap-add',
testTitle: 'cart shows declined banner',
specFile: '/abs/path/cart.spec.ts',
errorMessage: 'Timed out waiting for [data-testid="declined-banner"]',
componentSnapshot: { /* host-shaped tree */ },
};
const userMessage = buildUserMessage(failure);
// Feed [DIAGNOSE_SYSTEM_PROMPT, CLASSIFY_BUG_RUBRIC] as system messages and
// `userMessage` as the user turn to whichever LLM-runner your host wires up.
// Parse the agent's final message with DiagnosisSchema.Versioning
Pre-1.0: minor bumps may include breaking schema changes; pin to the exact minor in dependents. The prompts themselves change without bumps (they're tuned against the eval set); only Diagnosis schema changes are semver-meaningful.
Development
pnpm install
pnpm test
pnpm typecheck
pnpm build