2 min read
kevin-wiki / scripts
Purpose
The maintenance and integration layer: standalone TypeScript CLIs (run via npx tsx) that build the index, lint and health-check the wiki, ingest and sync
external sources into raw/, run automations, and serve the MCP/voice servers.
Every script updates state.json so freshness tracking stays accurate.
Mental model & key files
- Wiki maintenance:
build-index.ts(rebuilds_index.md+_backlinks.json+ README stats),lint.ts,wiki-status.ts,wiki-breakdown.ts,doctor.ts(5-doctor health check),section-quality-audit.ts(section-level editorial triage),wiki-quality-audit.ts(read-first/router/source/skill-load quality audit),audit-agent-pack-corpus.ts(page-by-page pack/capsule decision ledger),generate-agent-packs.ts(deterministic portable workflow pack generator that enriches packs from current wiki markdown/frontmatter),check-freshness.ts(session-start staleness). - Ingestion/sync:
ingest.ts,sync-*.ts(calendar, email, meetings, google-takeout),enrich-x-bookmarks.ts. - Servers:
serve-mcp.ts,voice-server.ts. Automations:run-automation.tsandaudit-automation-readiness.ts(non-secret CLI/auth/session/scheduler readiness). lib/— shared helpers (seescripts/lib/SKILL.md).agent-docs/— the Agent-Docs Mesh kit (seescripts/agent-docs/SKILL.md).
Patterns to follow / invariants
- ESM (
"type": "module"): local relative imports use a.jsextension. - Tests use the Node built-in runner:
node --import tsx --test <file>. - Pure, testable functions live in
lib/; CLIs are thin wrappers over them. - Scripts call
updateState(...)after meaningful work; never hand-editstate.json. - Use
rg, nevergrep.
Common tasks → first action
- Add a maintenance command → write
scripts/<name>.ts, factor logic intolib/, add an npm script, add alib/__tests__/*.test.ts. - Debug freshness →
npx tsx scripts/check-freshness.ts. - Audit automation tools, credentials, and live scheduler drift →
npm run audit:automations. - Audit wiki agent-load/source quality →
npx tsx scripts/wiki-quality-audit.ts(add--network --limit 40for sampled live source checks). - Audit every wiki page for pack/capsule routing →
npm run agent-packs:audit; refresh audit-fed packs withnpm run agent-packs:refresh. - Regenerate portable workflow packs →
npm run agent-packs; verify drift withnpm run agent-packs:check. - Rebuild everything →
npx tsx scripts/build-index.ts.
Gotchas
- These scripts read/write repo files directly — guard
statSync/readdirSyncagainst symlinks and missing paths (see the mesh'slib/repo-walk.ts). build-index.tsowns the<!-- ...auto... -->regions inREADME.md/_index.md.