crewhaus 0.1.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/advice-apply.d.ts +182 -0
- package/dist/advice-apply.js +286 -0
- package/dist/advise-rules.d.ts +348 -0
- package/dist/advise-rules.js +905 -0
- package/dist/alert-sink.d.ts +48 -0
- package/dist/alert-sink.js +86 -0
- package/dist/approval-gate.d.ts +127 -0
- package/dist/approval-gate.js +254 -0
- package/dist/audit-verify.d.ts +69 -0
- package/dist/audit-verify.js +97 -0
- package/dist/autodistill.d.ts +113 -0
- package/dist/autodistill.js +256 -0
- package/dist/channel-provision.d.ts +360 -0
- package/dist/channel-provision.js +881 -0
- package/dist/ci-scaffold.d.ts +31 -0
- package/dist/ci-scaffold.js +343 -0
- package/dist/compile-check.d.ts +90 -0
- package/dist/compile-check.js +285 -0
- package/dist/compliance-schedule.d.ts +35 -0
- package/dist/compliance-schedule.js +36 -0
- package/dist/context-pressure.d.ts +80 -0
- package/dist/context-pressure.js +166 -0
- package/dist/dataset-mine.d.ts +173 -0
- package/dist/dataset-mine.js +404 -0
- package/dist/datasets.d.ts +124 -0
- package/dist/datasets.js +260 -0
- package/dist/deploy-canary.d.ts +83 -0
- package/dist/deploy-canary.js +87 -0
- package/dist/doctor-checks.d.ts +33 -0
- package/dist/doctor-checks.js +92 -0
- package/dist/doctor-detect.d.ts +108 -0
- package/dist/doctor-detect.js +214 -0
- package/dist/doctor-fix.d.ts +81 -0
- package/dist/doctor-fix.js +164 -0
- package/dist/egress-triage.d.ts +121 -0
- package/dist/egress-triage.js +261 -0
- package/dist/eval-bridge.d.ts +114 -0
- package/dist/eval-bridge.js +158 -0
- package/dist/eval-coverage.d.ts +140 -0
- package/dist/eval-coverage.js +428 -0
- package/dist/eval-history.d.ts +48 -0
- package/dist/eval-history.js +157 -0
- package/dist/eval-matrix.d.ts +80 -0
- package/dist/eval-matrix.js +182 -0
- package/dist/eval-sentinel.d.ts +65 -0
- package/dist/eval-sentinel.js +132 -0
- package/dist/faq.d.ts +68 -0
- package/dist/faq.js +168 -0
- package/dist/feedback.d.ts +9 -2
- package/dist/feedback.js +17 -7
- package/dist/fewshot.d.ts +83 -0
- package/dist/fewshot.js +158 -0
- package/dist/fleet.d.ts +207 -0
- package/dist/fleet.js +488 -0
- package/dist/flywheel.d.ts +193 -0
- package/dist/flywheel.js +519 -0
- package/dist/graders-suggest.d.ts +186 -0
- package/dist/graders-suggest.js +658 -0
- package/dist/incident.d.ts +99 -0
- package/dist/incident.js +217 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +11664 -963
- package/dist/init-interactive.d.ts +105 -0
- package/dist/init-interactive.js +208 -0
- package/dist/intents.d.ts +105 -0
- package/dist/intents.js +292 -0
- package/dist/judge-calibrate.d.ts +137 -0
- package/dist/judge-calibrate.js +247 -0
- package/dist/justification-calibrate.d.ts +150 -0
- package/dist/justification-calibrate.js +262 -0
- package/dist/justification-gate.d.ts +27 -6
- package/dist/justification-gate.js +30 -6
- package/dist/knowledge-sync.d.ts +179 -0
- package/dist/knowledge-sync.js +551 -0
- package/dist/lessons.d.ts +87 -0
- package/dist/lessons.js +207 -0
- package/dist/lint.d.ts +127 -0
- package/dist/lint.js +226 -0
- package/dist/loadtest.d.ts +114 -0
- package/dist/loadtest.js +196 -0
- package/dist/marketplace-cli.d.ts +110 -0
- package/dist/marketplace-cli.js +250 -0
- package/dist/mcp-doctor.d.ts +121 -0
- package/dist/mcp-doctor.js +249 -0
- package/dist/model-scan.d.ts +116 -0
- package/dist/model-scan.js +226 -0
- package/dist/onchain-tune.d.ts +164 -0
- package/dist/onchain-tune.js +346 -0
- package/dist/permissions-suggest.d.ts +126 -0
- package/dist/permissions-suggest.js +333 -0
- package/dist/pii-tune.d.ts +107 -0
- package/dist/pii-tune.js +122 -0
- package/dist/propose.d.ts +117 -0
- package/dist/propose.js +184 -0
- package/dist/refresh-goldens.d.ts +82 -0
- package/dist/refresh-goldens.js +221 -0
- package/dist/regression-pin.d.ts +160 -0
- package/dist/regression-pin.js +281 -0
- package/dist/retention.d.ts +193 -0
- package/dist/retention.js +607 -0
- package/dist/retire.d.ts +118 -0
- package/dist/retire.js +291 -0
- package/dist/right-size.d.ts +100 -0
- package/dist/right-size.js +123 -0
- package/dist/route.d.ts +19 -0
- package/dist/route.js +90 -0
- package/dist/scaffold-evals.d.ts +138 -0
- package/dist/scaffold-evals.js +410 -0
- package/dist/scope-audit-drift.d.ts +139 -0
- package/dist/scope-audit-drift.js +260 -0
- package/dist/security-corpus.d.ts +237 -0
- package/dist/security-corpus.js +516 -0
- package/dist/security-digest.d.ts +174 -0
- package/dist/security-digest.js +656 -0
- package/dist/sessions-index.d.ts +27 -0
- package/dist/sessions-index.js +51 -0
- package/dist/slo-doctor.d.ts +67 -0
- package/dist/slo-doctor.js +119 -0
- package/dist/slo-sink.d.ts +96 -0
- package/dist/slo-sink.js +107 -0
- package/dist/spec-changelog.d.ts +102 -0
- package/dist/spec-changelog.js +237 -0
- package/dist/state-backup.d.ts +223 -0
- package/dist/state-backup.js +648 -0
- package/dist/tools-cli.d.ts +170 -0
- package/dist/tools-cli.js +300 -0
- package/dist/triage.d.ts +202 -0
- package/dist/triage.js +403 -0
- package/dist/upgrade.d.ts +57 -0
- package/dist/upgrade.js +113 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +27 -0
- package/dist/voice-eval.d.ts +138 -0
- package/dist/voice-eval.js +309 -0
- package/dist/watch.d.ts +58 -0
- package/dist/watch.js +97 -0
- package/package.json +90 -65
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item 4 — `crewhaus graders suggest`: draft grader suites from the failure
|
|
3
|
+
* rationale that already accumulates on disk, instead of hand-authoring
|
|
4
|
+
* gotcha-prone graders.yaml files from scratch.
|
|
5
|
+
*
|
|
6
|
+
* Evidence sources (all read-side, none mutated):
|
|
7
|
+
* - Per-sample grader rationale from recent eval run dirs (the grades.json
|
|
8
|
+
* the runner persists next to results.json), located via the item-3
|
|
9
|
+
* run-history index for the cwd spec.
|
|
10
|
+
* - Judge criterionScores where present in grades.json (GradeResult carries
|
|
11
|
+
* no structured output today, so this is a defensive parse that lights up
|
|
12
|
+
* as soon as a judge grader persists them).
|
|
13
|
+
* - User feedback comments (`extractFeedbackRecords` rows) — down-rated
|
|
14
|
+
* comments join the failure evidence; up-rated turns join the pass
|
|
15
|
+
* exemplars.
|
|
16
|
+
*
|
|
17
|
+
* Pipeline: failure texts cluster into themes DETERMINISTICALLY (normalized
|
|
18
|
+
* token overlap — no model call needed to cluster); each theme then gets a
|
|
19
|
+
* deterministic draft grader (tool_call_sequence / json_path / regex /
|
|
20
|
+
* contains, in that priority order) derived from the observed up-rated
|
|
21
|
+
* outputs; with `--model`/credentials one complete llm_judge rubric (all
|
|
22
|
+
* five anchors) is additionally drafted from real good/bad exemplars — the
|
|
23
|
+
* model call itself lives in the CLI entry file, this module owns the pure
|
|
24
|
+
* prompt builder + response parser.
|
|
25
|
+
*
|
|
26
|
+
* The output is a REVIEW file (never auto-applied) whose header documents
|
|
27
|
+
* the hard-AND collapse: `crewhaus eval` combines stacked graders with
|
|
28
|
+
* eval-grader's `all(...)` (min-score, every-grader-must-pass), so the file
|
|
29
|
+
* tells the user to adopt ONE grader rather than the whole stack.
|
|
30
|
+
*
|
|
31
|
+
* Kept in a side-effect-free module (the CLI entry file runs an argv switch
|
|
32
|
+
* on import) mirroring `feedback.ts` / `triage.ts`.
|
|
33
|
+
*/
|
|
34
|
+
import type { LoadedRun } from "@crewhaus/eval-report";
|
|
35
|
+
import { type FeedbackRecord, type GraderSpecObject, type GradersConfigObject, type SessionTurn } from "./feedback";
|
|
36
|
+
/** Thrown on malformed flags / unusable evidence. The CLI entry file routes
|
|
37
|
+
* it through `die()`; tests assert on `.message`. */
|
|
38
|
+
export declare class GradersSuggestError extends Error {
|
|
39
|
+
readonly name = "GradersSuggestError";
|
|
40
|
+
}
|
|
41
|
+
/** How many recent runs (for the cwd spec) feed the suggestion by default. */
|
|
42
|
+
export declare const DEFAULT_SUGGEST_RUNS = 10;
|
|
43
|
+
/** Default output path for the review file. */
|
|
44
|
+
export declare const DEFAULT_SUGGESTED_GRADERS_FILE = "graders-suggested.yaml";
|
|
45
|
+
/** One-liner printed by `crewhaus distill` when it falls back to the floor
|
|
46
|
+
* grader (see {@link isFloorGraderConfig}). */
|
|
47
|
+
export declare const FLOOR_GRADER_HINT = "hint: draft sharper graders from recent eval failures and ratings with `crewhaus graders suggest`";
|
|
48
|
+
/** True when a synthesized config is exactly the non-empty-answer floor
|
|
49
|
+
* grader `synthesizeGraders` emits when the ratings carry no signal — the
|
|
50
|
+
* trigger for the {@link FLOOR_GRADER_HINT} suggestion hook. */
|
|
51
|
+
export declare function isFloorGraderConfig(config: GradersConfigObject): boolean;
|
|
52
|
+
export type RunsSelector = {
|
|
53
|
+
kind: "dir";
|
|
54
|
+
dir: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "last";
|
|
57
|
+
n: number;
|
|
58
|
+
};
|
|
59
|
+
/** Parse `--runs`: `last:N` / `last N` selects the N most recent indexed
|
|
60
|
+
* runs; anything else is a run directory path. */
|
|
61
|
+
export declare function parseRunsFlag(value: string): RunsSelector;
|
|
62
|
+
/** One failing grader verdict (or down-rated comment), joined to its sample. */
|
|
63
|
+
export type FailureEvidence = {
|
|
64
|
+
readonly sampleId: string;
|
|
65
|
+
/** runId, or "feedback" for rating comments. */
|
|
66
|
+
readonly runId: string;
|
|
67
|
+
/** Grader name, `<grader>:criterion`, or "user_feedback". */
|
|
68
|
+
readonly source: string;
|
|
69
|
+
/** Cleaned rationale/comment text — the clustering signal. */
|
|
70
|
+
readonly text: string;
|
|
71
|
+
/** The failing output, when known (discriminative-token drafting). */
|
|
72
|
+
readonly output?: string;
|
|
73
|
+
};
|
|
74
|
+
/** One up-rated output — a passing eval sample or a thumbs-up turn. */
|
|
75
|
+
export type PassExemplar = {
|
|
76
|
+
readonly sampleId: string;
|
|
77
|
+
readonly runId: string;
|
|
78
|
+
readonly output: string;
|
|
79
|
+
readonly toolNames: ReadonlyArray<string>;
|
|
80
|
+
};
|
|
81
|
+
export type SuggestEvidence = {
|
|
82
|
+
readonly failures: ReadonlyArray<FailureEvidence>;
|
|
83
|
+
readonly passes: ReadonlyArray<PassExemplar>;
|
|
84
|
+
};
|
|
85
|
+
/** Mirror of eval-runner's per-sample dir sanitizer — the key LoadedRun's
|
|
86
|
+
* perSample map uses. Keep in sync with run-sample.ts. */
|
|
87
|
+
export declare function sanitizeSampleId(id: string): string;
|
|
88
|
+
/** Unique tool names (first-seen order) from a per-sample events.jsonl —
|
|
89
|
+
* `tool_call_end` trace events carry the runtime tool name. Tolerant of
|
|
90
|
+
* torn/corrupt lines. */
|
|
91
|
+
export declare function toolNamesFromEventsJsonl(text: string): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Strip runner/judge boilerplate from a grader rationale so clustering sees
|
|
94
|
+
* the substance: the `[name: ✗]` combinator markers, the `judge=N (need
|
|
95
|
+
* ≥M):` prefix. Infra noise ("grader threw: …", "agent invocation error:
|
|
96
|
+
* …") returns "" — an outage is not a failure theme.
|
|
97
|
+
*/
|
|
98
|
+
export declare function cleanRationale(rationale: string): string;
|
|
99
|
+
/** Defensive parse of a raw grades.json for judge criterionScores (not part
|
|
100
|
+
* of GradeResult today — see the module doc). Criteria scored ≤ 2 of 5
|
|
101
|
+
* become failure evidence in their own right. */
|
|
102
|
+
export declare function criterionEvidence(gradesText: string, sampleId: string, runId: string): FailureEvidence[];
|
|
103
|
+
/**
|
|
104
|
+
* Extract failure evidence + pass exemplars from one loaded eval run.
|
|
105
|
+
* Samples are visited in sampleId order (determinism), errored/grader-threw
|
|
106
|
+
* samples are skipped wholesale (infra noise, not a failure theme — the
|
|
107
|
+
* same posture as triage's pin guards).
|
|
108
|
+
*/
|
|
109
|
+
export declare function evidenceFromRun(run: LoadedRun): SuggestEvidence;
|
|
110
|
+
/**
|
|
111
|
+
* Fold user ratings into the evidence: down-rated comments become failure
|
|
112
|
+
* evidence, up-rated turns become pass exemplars (their outputs + observed
|
|
113
|
+
* tool names). Positive comments are returned separately — they season the
|
|
114
|
+
* llm_judge rubric prompt, not the clustering.
|
|
115
|
+
*/
|
|
116
|
+
export declare function evidenceFromFeedback(turns: ReadonlyArray<SessionTurn>, records: ReadonlyArray<FeedbackRecord>, minScore: number): SuggestEvidence & {
|
|
117
|
+
positiveComments: string[];
|
|
118
|
+
};
|
|
119
|
+
/** Normalized token list for one evidence text: lowercase, alphanumeric,
|
|
120
|
+
* length ≥ 3, non-stopword, unique, in first-seen order. */
|
|
121
|
+
export declare function normalizeEvidenceTokens(text: string): string[];
|
|
122
|
+
export type FailureTheme = {
|
|
123
|
+
/** Top tokens joined — the human handle for the theme. */
|
|
124
|
+
readonly label: string;
|
|
125
|
+
readonly tokens: ReadonlyArray<string>;
|
|
126
|
+
readonly items: ReadonlyArray<FailureEvidence>;
|
|
127
|
+
readonly sampleIds: ReadonlyArray<string>;
|
|
128
|
+
readonly runIds: ReadonlyArray<string>;
|
|
129
|
+
readonly sources: ReadonlyArray<string>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Deterministic greedy clustering by normalized token overlap — no model
|
|
133
|
+
* call. Items are visited in a stable sort order (runId, sampleId, source,
|
|
134
|
+
* text) and joined to the best existing cluster when the Jaccard overlap
|
|
135
|
+
* with its SEED item's tokens reaches `threshold` (seed comparison keeps a
|
|
136
|
+
* cluster from drifting as it grows); otherwise they seed a new cluster.
|
|
137
|
+
* Themes come back largest-first, labelled by their most frequent tokens.
|
|
138
|
+
*/
|
|
139
|
+
export declare function clusterFailures(items: ReadonlyArray<FailureEvidence>, opts?: {
|
|
140
|
+
threshold?: number;
|
|
141
|
+
}): FailureTheme[];
|
|
142
|
+
export type SuggestedGrader = {
|
|
143
|
+
readonly spec: GraderSpecObject;
|
|
144
|
+
/** Comment lines (without the leading `# `) citing the evidence. */
|
|
145
|
+
readonly evidence: ReadonlyArray<string>;
|
|
146
|
+
};
|
|
147
|
+
export type DraftResult = {
|
|
148
|
+
readonly suggestions: ReadonlyArray<SuggestedGrader>;
|
|
149
|
+
/** Themes no deterministic grader could be drafted for. */
|
|
150
|
+
readonly undrafted: ReadonlyArray<FailureTheme>;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Draft one deterministic grader per failure theme from the observed
|
|
154
|
+
* up-rated outputs, in priority order: tool_call_sequence (theme mentions
|
|
155
|
+
* tools + passes share tools) → json_path (all pass outputs are JSON
|
|
156
|
+
* objects with a common key) → regex (shared output prefix) → contains
|
|
157
|
+
* (discriminative pass token). Themes with no deterministic signal come
|
|
158
|
+
* back in `undrafted` so the review file can note them.
|
|
159
|
+
*/
|
|
160
|
+
export declare function draftGradersForThemes(themes: ReadonlyArray<FailureTheme>, passes: ReadonlyArray<PassExemplar>): DraftResult;
|
|
161
|
+
/** System block for the one-shot rubric drafting call. */
|
|
162
|
+
export declare const RUBRIC_SUGGESTION_SYSTEM = "You design eval rubrics for AI agent harnesses. You will receive real GOOD exemplars (outputs users or graders rated up), real BAD evidence (grader rationales / user complaints), and the clustered failure themes. Write one llm_judge rubric criterion that separates the good from the bad.\n\nHard rules:\n- Output exactly one JSON object: {\"name\": \"...\", \"description\": \"...\", \"anchors\": {\"1\": \"...\", \"2\": \"...\", \"3\": \"...\", \"4\": \"...\", \"5\": \"...\"}, \"passing_score\": 3}. No text outside the JSON.\n- \"name\" is a short snake_case identifier.\n- The five anchors must be concrete, observable behaviors grounded in the exemplars \u2014 1 is the worst observed failure mode, 5 is the best observed behavior.\n- Do not quote any exemplar verbatim for more than a short phrase.";
|
|
163
|
+
/** The user message for the rubric call: clipped good/bad exemplars + the
|
|
164
|
+
* deterministic theme labels. */
|
|
165
|
+
export declare function buildRubricSuggestionPrompt(goodOutputs: ReadonlyArray<string>, badEvidence: ReadonlyArray<FailureEvidence>, themes: ReadonlyArray<FailureTheme>): string;
|
|
166
|
+
/**
|
|
167
|
+
* Tolerant parse of the rubric response into a complete single-criterion
|
|
168
|
+
* `llm_judge` GraderSpecObject (all five anchors required). Returns
|
|
169
|
+
* undefined on ANY shape failure — the caller keeps the deterministic
|
|
170
|
+
* suggestions and notes the skipped rubric.
|
|
171
|
+
*/
|
|
172
|
+
export declare function parseRubricSuggestion(raw: string, model?: string): GraderSpecObject | undefined;
|
|
173
|
+
export type RenderSuggestionsOptions = {
|
|
174
|
+
readonly specName?: string;
|
|
175
|
+
readonly runsSeen: number;
|
|
176
|
+
readonly failureCount: number;
|
|
177
|
+
readonly feedbackCount: number;
|
|
178
|
+
readonly undraftedLabels: ReadonlyArray<string>;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Render the review file: a hard-AND-aware header, then a valid graders.yaml
|
|
182
|
+
* (parseable by `parseGradersConfig`, so a reviewed grader can be copied —
|
|
183
|
+
* or the file trimmed to one grader and used directly), with each grader
|
|
184
|
+
* preceded by a `# evidence:` comment citing what it was drafted from.
|
|
185
|
+
*/
|
|
186
|
+
export declare function renderSuggestedGradersYaml(suggestions: ReadonlyArray<SuggestedGrader>, opts: RenderSuggestionsOptions): string;
|