Exported functions in state/lib/corpus.ts. .md file to compare - side-by-side diff against corpus
corpus
description: "Triggers on prompt mention of 'corpus'."
What it does for you
Keeps a searchable record of everything said in your meetings.
What it produces
A recent result, so you can see the kind of work it returns.
loading…
How to get it
These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.
For developers how this skill is built, graded, and how it runs
at a glance- the short version
what's inside - the parts that make up a skill 3/4 present
A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.
state/skills/corpus/SKILL.md
present
state/lib/corpus.ts
present
state/bin/corpus/
not present
state/skills/corpus/AGENTS.md
present
how it's graded - what counts as a good run 4 criteria · 4 deterministic
Each row is one thing a good run has to get right. deterministic means a quick check decides, pass or fail. judge means the AI reads the result and rates it. Grading each piece on its own (instead of one overall score) shows exactly where a run fell short, so the fix is obvious.
how it runs - the shared frame every skill uses 5/5 present
Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.
state/log/evals.ndjson what it has learned - fixes written back in over time sample
When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.
- Loading feedback rows…
how the work flows- who makes it, who checks it
see `state/skills/corpus/SKILL.md` Steps section
SKILL.md- the skill, written out in plain English
corpus
Krisp transcript corpus operations for all snappy-* skills.
Ported from kernel snappy-corpus in Phase 0.5. See state/lib/corpus.ts for the full API surface.
Steps
listTranscripts()- seestate/lib/corpus.tsreadTranscript()- seestate/lib/corpus.tssearchCorpus()- seestate/lib/corpus.ts
Eval
Actor: the exported functions in state/lib/corpus.ts. Auditor: none wired yet - eval is manual (Robert review). File a state/log/pending-eval.ndjson row on each run.
Score convention:
| Outcome | Score |
|---|---|
| Pass on first try | 1.0 |
| Failed first, auto-fix applied, re-check passed | 0.5 |
| Still failing or unrecoverable | 0.0 |
Gotchas
via the Phase 0.5 driver. Only these rewrites were applied: already in state/lib/)
realpathSync(process.argv[1])CLI guard wrapped in try/catch
- See the kernel SKILL.md for the original long-form guidance if you need it
(read-only reference at the kernel path above).
Graduation
This skill is prose. Graduate by defining a deterministic auditor and flipping eval: auto.
Rubric
criteria:
- name: corpus_function_returns_nonzero
kind: deterministic
check: "Called function returns non-null result. listTranscripts returns array.length > 0. readTranscript returns {id, content, ...}. searchCorpus returns array with matches."
- name: function_executes_no_errors
kind: deterministic
check: "Function completes with exit code 0; stderr empty or warnings-only. No auth/auth_expired or timeout errors."
- name: result_matches_schema
kind: deterministic
check: "listTranscripts returns array of {id, title, date, ...}. readTranscript returns {id, text, speakers, ...}. searchCorpus returns {query, results: [...]}"
- name: eval_row_logged
kind: deterministic
check: "state/log/evals.ndjson or state/log/pending-eval.ndjson receives row with skill='corpus', score, item_count."AGENTS.md- what the AI loads when this skill comes up
corpus - loader
Per-turn rules for the corpus skill. Full reference: state/skills/corpus/SKILL.md. Do not skip these.
Critical Rules
_(no failures recorded yet - this skill has not produced hard-won rules. Read state/skills/corpus/SKILL.md before invoking.)_
Commands
|invoke: see state/skills/corpus/SKILL.md Steps section |eval log: state/log/evals.ndjson (skill: "corpus")
Self-Test
An agent reading this should correctly:
- [ ] Know which lib/bin artifact backs this skill (or that it is prose-only)
- [ ] Know what to write to
state/log/evals.ndjsonafter invoking - [ ] Know the eval mode (auto / shape / manual) from the .md frontmatter
Self-report
If this loader fell short, append a line:
echo "[$(date -u +%FT%TZ)] corpus: <what was missing>" >> state/log/loader-feedback.log
<!-- footer-injection-point -->
api.ts- the code it can call
#!/usr/bin/env npx tsx
/**
* snappy-corpus/api.ts -- Krisp transcript corpus operations for all snappy-* skills.
*
* Usage:
* npx tsx api.ts list # list all transcripts
* npx tsx api.ts list 2026 04 # list transcripts for April 2026
* npx tsx api.ts read <path> [offset] [limit] # read transcript in chunks
* npx tsx api.ts search <query> # grep across all transcripts
*
* Or import as module:
* import { listTranscripts, readTranscript, searchCorpus } from "./corpus.ts";
*/
import { existsSync, readFileSync, realpathSync } from "fs";
import { join, resolve, relative } from "path";
import { execSync, execFileSync } from "child_process";
import { env } from "./env.ts";
const CORPUS_ROOT = join(process.env.HOME!, ".claude/corpus/krisp");
/** Lists transcript .md files, optionally filtered by year/month. Excludes .summary.md and .nuggets.json. */
export function listTranscripts(year?: string, month?: string): string[] {
// Validate year and month parameters to prevent injection
if (year && !/^\d{4}$/.test(year)) throw new Error("year must be YYYY format");
if (month && !/^\d{2}$/.test(month)) throw new Error("month must be MM format");
const pattern = year && month
? `${CORPUS_ROOT}/${year}/${month}/*.md`
: year
? `${CORPUS_ROOT}/${year}/**/*.md`
: `${CORPUS_ROOT}/**/*.md`;
try {
const output = execSync(`ls ${pattern} 2>/dev/null || true`, { encoding: "utf-8" });
return output
.split("\n")
.filter((f: string) => f.endsWith(".md") && !f.endsWith(".summary.md"))
.sort();
} catch {
return [];
}
}
/** Reads a transcript file in chunks. Default: first 200 lines. */
export function readTranscript(path: string, offset = 0, limit = 200): { lines: string[]; total: number } {
// Reject absolute paths
if (path.startsWith("/")) throw new Error("absolute paths not allowed");
// Resolve and verify path is within CORPUS_ROOT
const absPath = resolve(CORPUS_ROOT, path);
const rel = relative(CORPUS_ROOT, absPath);
if (rel.startsWith("..")) throw new Error("path traversal not allowed");
if (!existsSync(absPath)) throw new Error(`Transcript not found: ${absPath}`);
const content = readFileSync(absPath, "utf-8");
const allLines = content.split("\n");
return {
lines: allLines.slice(offset, offset + limit),
total: allLines.length,
};
}
/** Greps across all transcripts for a query string. Returns matching file:line pairs. */
export function searchCorpus(query: string): { file: string; line: number; text: string }[] {
try {
const output = execFileSync(
"grep",
["-rni", "--include=*.md", "--", query, CORPUS_ROOT + "/"],
{ encoding: "utf-8", timeout: 30_000 }
);
return output
.split("\n")
.filter((line) => line.length > 0 && !line.includes(".summary.md"))
.slice(0, 100)
.map((line) => {
const firstColon = line.indexOf(":");
const secondColon = line.indexOf(":", firstColon + 1);
return {
file: line.slice(0, firstColon),
line: parseInt(line.slice(firstColon + 1, secondColon), 10) || 0,
text: line.slice(secondColon + 1).trim(),
};
});
} catch {
return [];
}
}
// --- CLI ---
if ((() => { try { return import.meta.url === `file://${realpathSync(process.argv[1])}`; } catch { return false; } })()) {
(async () => {
const [, , cmd, ...args] = process.argv;
switch (cmd) {
case "list": {
const [year, month] = args;
const files = listTranscripts(year, month);
console.log(`${files.length} transcripts:`);
for (const f of files) console.log(` ${f}`);
break;
}
case "read": {
const [path, offsetStr, limitStr] = args;
if (!path) { console.error("Usage: api.ts read <path> [offset] [limit]"); process.exit(1); }
const result = readTranscript(path, parseInt(offsetStr) || 0, parseInt(limitStr) || 200);
console.log(`Lines ${parseInt(offsetStr) || 0}-${(parseInt(offsetStr) || 0) + result.lines.length} of ${result.total}:`);
console.log(result.lines.join("\n"));
break;
}
case "search": {
const query = args.join(" ");
if (!query) { console.error("Usage: api.ts search <query>"); process.exit(1); }
const results = searchCorpus(query);
console.log(`${results.length} matches:`);
for (const r of results) {
console.log(` ${r.file}:${r.line}\t${r.text.slice(0, 120)}`);
}
break;
}
default:
console.log("Usage: npx tsx api.ts [list|read|search] ...");
}
})();
}
scripts- helper scripts it can run
prose-only skill - 1 inline code block live in SKILL.md above (no state/bin/ sidecar yet).
how we check it- the checks, plus the last 10 runs
no recent runs logged - the eval contract is declared but nothing has been graded yet