crewhaus 0.1.8 → 0.2.0
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 +172 -0
- package/dist/dataset-mine.js +403 -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 +11601 -964
- 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/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 +173 -0
- package/dist/security-digest.js +650 -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 +298 -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 +89 -65
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** Thrown for operational failures. The CLI routes the message through
|
|
2
|
+
* `die()`; tests assert on `.message`. */
|
|
3
|
+
export declare class KnowledgeSyncError extends Error {
|
|
4
|
+
readonly name = "KnowledgeSyncError";
|
|
5
|
+
}
|
|
6
|
+
export declare const SHARED_DIR_DEFAULT = ".crewhaus-shared";
|
|
7
|
+
export declare const KNOWLEDGE_MARKER_RELPATH = ".crewhaus/knowledge.json";
|
|
8
|
+
/** sha256 hex of a normalized memory (text + sorted, deduped tags) — the
|
|
9
|
+
* dedupe key, independent of tag order or the memory's own id/timestamp. */
|
|
10
|
+
export declare function memoryContentHash(text: string, tags: ReadonlyArray<string>): string;
|
|
11
|
+
/** sha256 hex of a file fragment's bytes (grader/prompt), trimmed. */
|
|
12
|
+
export declare function fragmentContentHash(bytes: string): string;
|
|
13
|
+
export type Provenance = {
|
|
14
|
+
/** The harness that pushed the artifact. */
|
|
15
|
+
readonly harness: string;
|
|
16
|
+
readonly pushedAt: string;
|
|
17
|
+
};
|
|
18
|
+
export type SharedMemory = {
|
|
19
|
+
readonly contentHash: string;
|
|
20
|
+
readonly text: string;
|
|
21
|
+
readonly tags: ReadonlyArray<string>;
|
|
22
|
+
readonly provenance: Provenance;
|
|
23
|
+
};
|
|
24
|
+
export type SharedFragment = {
|
|
25
|
+
readonly contentHash: string;
|
|
26
|
+
readonly kind: "grader" | "prompt";
|
|
27
|
+
readonly filename: string;
|
|
28
|
+
readonly contents: string;
|
|
29
|
+
readonly provenance: Provenance;
|
|
30
|
+
};
|
|
31
|
+
export type RedactionOutcome = {
|
|
32
|
+
readonly text: string;
|
|
33
|
+
/** True when a credential-shaped token remained AFTER redaction (drop it). */
|
|
34
|
+
readonly secretRemains: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** Redactor seam: redact a string for pushing to the shared store. Production
|
|
37
|
+
* wraps `@crewhaus/pii-redactor` + a token detector; tests inject a stub. */
|
|
38
|
+
export type Redactor = (text: string) => Promise<RedactionOutcome>;
|
|
39
|
+
/** A pass-through redactor (tests / --no-redact). Never flags tokens. */
|
|
40
|
+
export declare const IDENTITY_REDACTOR: Redactor;
|
|
41
|
+
/** The credential token shapes, each a global RegExp so `replace` masks every
|
|
42
|
+
* occurrence. Order matters only for the PEM block (masked whole, first). */
|
|
43
|
+
export declare const KNOWLEDGE_SECRET_DETECTORS: ReadonlyArray<{
|
|
44
|
+
kind: string;
|
|
45
|
+
regex: RegExp;
|
|
46
|
+
}>;
|
|
47
|
+
/** True when `text` still contains something credential-shaped — used as the
|
|
48
|
+
* `secretRemains` verdict AFTER redaction so anything suspicious is dropped. */
|
|
49
|
+
export declare function looksLikeSecret(text: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Mask every credential-shaped token in `text` with `***`. PEM blocks are
|
|
52
|
+
* masked whole. Pure + synchronous — the PII pass is layered on top by
|
|
53
|
+
* {@link buildKnowledgeRedactor}.
|
|
54
|
+
*/
|
|
55
|
+
export declare function maskKnowledgeSecrets(text: string): string;
|
|
56
|
+
/** Primitive PII pass injected into {@link buildKnowledgeRedactor}: redact PII
|
|
57
|
+
* and return the cleaned text. Production wraps `@crewhaus/pii-redactor`;
|
|
58
|
+
* tests can inject an identity pass to exercise only the credential layer. */
|
|
59
|
+
export type PiiPass = (text: string) => Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Build the production knowledge redactor: run a PII pass, then mask every
|
|
62
|
+
* credential-shaped token, then re-scan the result with the STRICT
|
|
63
|
+
* {@link looksLikeSecret} heuristic — anything that still looks like a secret
|
|
64
|
+
* sets `secretRemains` so the caller DROPS the artifact rather than share a
|
|
65
|
+
* leaked credential.
|
|
66
|
+
*
|
|
67
|
+
* The `piiPass` is injected so this is unit-testable without the redactor
|
|
68
|
+
* package (the CLI wires the real `@crewhaus/pii-redactor` pass).
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildKnowledgeRedactor(piiPass: PiiPass): Redactor;
|
|
71
|
+
/** Whether a harness has opted into knowledge sharing (marker file with
|
|
72
|
+
* `{ share: true }`). */
|
|
73
|
+
export declare function harnessOptedIn(harnessDir: string): boolean;
|
|
74
|
+
type RawMemory = {
|
|
75
|
+
text: string;
|
|
76
|
+
tags: ReadonlyArray<string>;
|
|
77
|
+
};
|
|
78
|
+
/** Read every memory-store entry across a harness's `.crewhaus/memories/*.jsonl`. */
|
|
79
|
+
export declare function readHarnessMemories(harnessDir: string): RawMemory[];
|
|
80
|
+
/** Read a harness's grader fragment (first of the candidate paths present). */
|
|
81
|
+
export declare function readHarnessGraders(harnessDir: string): {
|
|
82
|
+
filename: string;
|
|
83
|
+
contents: string;
|
|
84
|
+
} | undefined;
|
|
85
|
+
/** Read a harness's prompt fragments (`.crewhaus/prompts/*.md`). */
|
|
86
|
+
export declare function readHarnessPrompts(harnessDir: string): Array<{
|
|
87
|
+
filename: string;
|
|
88
|
+
contents: string;
|
|
89
|
+
}>;
|
|
90
|
+
/** Upper bound on a shared memory's text length. A shared store is untrusted
|
|
91
|
+
* input on pull; an absurdly long "memory" is a poisoning / DoS vector, never
|
|
92
|
+
* a real lesson. 64 KiB is far above any genuine memory. */
|
|
93
|
+
export declare const MAX_SHARED_MEMORY_TEXT: number;
|
|
94
|
+
/**
|
|
95
|
+
* Validate one parsed shared-memory record (F6). A pulled record is UNTRUSTED:
|
|
96
|
+
* the file could have been hand-edited to poison the harness's dedupe (a lying
|
|
97
|
+
* `contentHash` so a malicious `text` masquerades as an already-trusted entry)
|
|
98
|
+
* or to bloat it (oversized text / malformed tags). Returns the record when it
|
|
99
|
+
* is a well-formed {@link SharedMemory} whose stored `contentHash` MATCHES the
|
|
100
|
+
* recomputed hash of its own text+tags; otherwise a `reason` for the skip.
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateSharedMemory(rec: unknown): {
|
|
103
|
+
ok: true;
|
|
104
|
+
memory: SharedMemory;
|
|
105
|
+
} | {
|
|
106
|
+
ok: false;
|
|
107
|
+
reason: string;
|
|
108
|
+
};
|
|
109
|
+
/** Read the shared memories.jsonl. Missing → []. Each record is validated as a
|
|
110
|
+
* proper {@link SharedMemory} with a matching content hash (F6); invalid
|
|
111
|
+
* records are SKIPPED with a warning to stderr, never loaded. */
|
|
112
|
+
export declare function readSharedMemories(sharedDir: string): SharedMemory[];
|
|
113
|
+
/** Read the shared fragments of a kind (`graders/` or `prompts/`). */
|
|
114
|
+
export declare function readSharedFragments(sharedDir: string, kind: "grader" | "prompt"): SharedFragment[];
|
|
115
|
+
/** A fragment file carries a first-line provenance comment
|
|
116
|
+
* `#! crewhaus-knowledge {json}`; split it from the body. */
|
|
117
|
+
export declare function splitProvenanceHeader(contents: string): {
|
|
118
|
+
provenance?: Provenance;
|
|
119
|
+
body: string;
|
|
120
|
+
};
|
|
121
|
+
/** Prepend a provenance header line to a fragment body. */
|
|
122
|
+
export declare function withProvenanceHeader(body: string, provenance: Provenance): string;
|
|
123
|
+
export type PushPlan = {
|
|
124
|
+
readonly memories: ReadonlyArray<SharedMemory>;
|
|
125
|
+
readonly fragments: ReadonlyArray<SharedFragment>;
|
|
126
|
+
/** Memories dropped because a token survived redaction. */
|
|
127
|
+
readonly droppedSecrets: ReadonlyArray<string>;
|
|
128
|
+
/** Artifacts already present in the shared store (deduped away). */
|
|
129
|
+
readonly skippedDuplicates: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Plan a push: redact each harness memory, drop any whose text still carries a
|
|
133
|
+
* credential-shaped token, hash the rest, and keep only artifacts whose
|
|
134
|
+
* content hash is NEW to the shared store. Pure over the injected redactor +
|
|
135
|
+
* the current shared hashes. Grader/prompt fragments are redacted too (a
|
|
136
|
+
* lesson can quote a key).
|
|
137
|
+
*/
|
|
138
|
+
export declare function planPush(opts: {
|
|
139
|
+
readonly harness: string;
|
|
140
|
+
readonly memories: ReadonlyArray<RawMemory>;
|
|
141
|
+
readonly graders?: {
|
|
142
|
+
filename: string;
|
|
143
|
+
contents: string;
|
|
144
|
+
} | undefined;
|
|
145
|
+
readonly prompts: ReadonlyArray<{
|
|
146
|
+
filename: string;
|
|
147
|
+
contents: string;
|
|
148
|
+
}>;
|
|
149
|
+
readonly existingMemoryHashes: ReadonlySet<string>;
|
|
150
|
+
readonly existingFragmentHashes: ReadonlySet<string>;
|
|
151
|
+
readonly redact: Redactor;
|
|
152
|
+
readonly now: () => Date;
|
|
153
|
+
}): Promise<PushPlan>;
|
|
154
|
+
/** Write a push plan into the shared store (append memories, write fragment
|
|
155
|
+
* files, append the manifest log). Not called in --dry-run. */
|
|
156
|
+
export declare function applyPush(sharedDir: string, plan: PushPlan, now: () => Date): void;
|
|
157
|
+
export type PullPlan = {
|
|
158
|
+
/** Shared memories NOT already present in the harness. */
|
|
159
|
+
readonly memories: ReadonlyArray<SharedMemory>;
|
|
160
|
+
readonly fragments: ReadonlyArray<SharedFragment>;
|
|
161
|
+
readonly skippedDuplicates: number;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Plan a pull: shared artifacts whose content hash the harness does not
|
|
165
|
+
* already have. Pure over the harness's existing hashes.
|
|
166
|
+
*/
|
|
167
|
+
export declare function planPull(opts: {
|
|
168
|
+
readonly sharedMemories: ReadonlyArray<SharedMemory>;
|
|
169
|
+
readonly sharedFragments: ReadonlyArray<SharedFragment>;
|
|
170
|
+
readonly harnessMemoryHashes: ReadonlySet<string>;
|
|
171
|
+
readonly harnessFragmentHashes: ReadonlySet<string>;
|
|
172
|
+
}): PullPlan;
|
|
173
|
+
/** Write a pull plan into a harness: append memories to a shared-memories
|
|
174
|
+
* JSONL the memory-store already reads, and drop fragment files into
|
|
175
|
+
* `.crewhaus/prompts` / a `graders.shared.yaml`. Not called in --dry-run. */
|
|
176
|
+
export declare function applyPull(harnessDir: string, plan: PullPlan, now: () => Date): void;
|
|
177
|
+
export declare function formatPushReport(harness: string, plan: PushPlan, dryRun: boolean): ReadonlyArray<string>;
|
|
178
|
+
export declare function formatPullReport(harness: string, plan: PullPlan, dryRun: boolean): ReadonlyArray<string>;
|
|
179
|
+
export {};
|