* wip(programmes): the programme schema; the theme matcher moves into the app Work in progress on a branch with no pull request yet. The theme matcher (keywords and compounds of an organisation's themes) moves from scripts/lib into src/lib/domain so public programmes are matched by the same rule as foundations; the script re-exports it. The programme schema follows the investor register: every fact with its page, date and verbatim sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtMwPqoAJ2pHxdSn3t * feat(programmes): public funding programmes beside foundations and investors Seven federal, cantonal and EU programmes, read on 2026-12-01 from the operators' own pages: Innosuisse (three instruments), the EIC Accelerator via Euresearch, the federal media-literacy grants (Jugend und Medien), and the canton of Zurich's integration projects and charitable fund. Every fact carries the page, the day and the sentence it rests on; every sentence was checked against the downloaded page. What a page does not say is named with the reason; six programmes looked for and not entered are listed with why. - Table fundraising_programmes (migration 0023), import script (dry run unless --write), and a re-check script that reads every cited page again and fails when a quoted sentence is gone. - Workspace page: open programmes first, then those whose own words hit the organisation's themes, by the same keyword rule as the register screen (moved to src/lib/domain/theme-match.ts). A programme that asks for an organisation is marked for one that has no legal entity yet; programmes are now one of the kinds the legal-standing notice names. - A grant Vorhaben links to the programmes as well as the foundations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtMwPqoAJ2pHxdSn3t * feat(programmes): the seven programmes load with the deploy Migration 0024 inserts the rows of data/programmes/seed-2026-12-01.json, so the register is filled when this goes live and nobody runs an import by hand. A test keeps the migration identical to the sourced data file; ON CONFLICT DO NOTHING never puts a row back to this first reading once a later re-check has updated it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtMwPqoAJ2pHxdSn3t --------- Co-authored-by: Claude <noreply@anthropic.com>
Foundation Pipeline Scripts
CLI tools that feed the foundation database, audit data quality, and
manage the research pipeline. UI/domain code lives in src/; everything
here is operations.
The DB is the write SSOT. Foundation data flows: research → DB (
fundraising_foundations.config_data) →src/lib/db/foundations-repo.ts(cached DB read layer,unstable_cache, 1h TTL) → UI. See/AGENTS.mdfor the full data-flow diagram.
Quick reference (pnpm aliases)
| Command | Script | Purpose |
|---|---|---|
pnpm run audit |
audit-pipeline.ts |
Pipeline funnel + gap report |
pnpm run validate:foundations |
foundation-validate.ts |
Schema + duplicate + quality validation |
pnpm run foundation:add |
foundation-add.ts |
Interactive entry generator |
pnpm run esa:download |
esa-download-and-parse.ts |
Pull ESA register snapshot |
pnpm run zefix:download |
zefix-download.ts |
Pull Zefix register data |
pnpm run zefix:ingest |
zefix-ingest.ts |
Bulk-import from Zefix snapshot |
pnpm run zhaw:ingest |
zhaw-ingest.ts |
ZHAW register-text ingest |
pnpm run screen |
foundation-screen.ts |
Phase-1 LLM screening |
pnpm run screen:org -- --org <id> |
org-screen.ts |
Keyword screen of a register snapshot with one organisation's own themes (org-context/<id>/themes.json); reads and writes no database |
pnpm run investors:import -- <file> |
investor-import.ts |
Validate a hand-curated, sourced investor list; dry run unless --write |
pnpm exec tsx scripts/programme-import.ts <file> |
programme-import.ts |
Validate the hand-curated public programme list; dry run unless --write |
pnpm exec tsx scripts/programme-verify.ts <file> |
programme-verify.ts |
Read every cited programme page again; fail when a quoted sentence is gone |
pnpm run org-content:put -- --org <id> --key <key> |
org-content-put.ts |
Validate and store one block from org-context/<id>/<key>.json (themes, triage-brief, raise-profile); dry run unless --write |
pnpm run research:queue |
foundation-research-queue.ts |
Build research candidate queue |
pnpm run research:foundation |
foundation-research-assistant.ts |
Per-foundation research prompt |
pnpm run research:batch |
foundation-batch-research.ts |
Batch research prompt set |
pnpm run pipeline:incremental |
pipeline-incremental.ts |
Incremental graduation pass |
pnpm run pipeline:graduate |
pipeline-graduate.ts |
Phase-2 LLM graduation |
pnpm run pipeline:triage |
ingest-triage.ts |
Triage research-result batches |
pnpm run pipeline:upsert |
foundation-upsert.ts |
Single-foundation upsert |
pnpm run enrich:bulk |
bulk-enrich.ts |
Bulk enrichment runner |
Tools without aliases (invoke via pnpm exec tsx)
| Script | Purpose |
|---|---|
bulk-import-batches.ts |
Import all research/chatgpt-results/batch*.json files (idempotent) |
dedupe-by-uid.ts |
Merge active foundations sharing a Swiss commercial-register UID |
gesuch-audit.ts |
Quality-check Gesuch documents (bridge text, themes, contact, notes) |
auto-research.ts |
Programmatic research helper (used by pipeline-graduate.ts) |
web-enrich.ts |
Website-scrape contact extraction (used by lib/contact-extractor.ts) |
research-agent.ts |
4-phase manual enrichment (DISCOVER → VERIFY → EXTRACT → RECONCILE) |
new-org.sh |
Bootstrap onboarding for a new tenant org |
audit-themes.ts |
Audit theme assignments for P1+P2 foundations |
set-confidence.ts |
Set data_confidence from research depth (supports --dry-run) |
grant-org-membership.ts |
Attach an existing account to one or more organisations (idempotent) |
set-operator.ts |
Make an existing account the platform operator, the only one that may change the shared register (dry run unless --write) |
seed-org-content.ts |
Seed org_profiles/org_content/org_scoring rows from the ORG-SPECIFIC TS configs (idempotent upserts) |
Library code
scripts/lib/ holds shared helpers:
db.ts— pg-backedsqltagged-template client (all scripts connect through this; needs the DB tunnel from a dev machine — seedocs/DEPLOYMENT.md)groq-client.ts— Groq API wrapper for LLM callstheme-classifier.ts— Keyword-based theme classification (SSOT for theme rules)contact-extractor.ts— Email/phone extraction patterns
Data flow
zefix-download → zefix-ingest ┐
zhaw-ingest ├─→ DB (fundraising_foundations)
esa-download-and-parse │ │
research:queue → research:batch │ │
→ ChatGPT/Claude → research/chatgpt-results/batch*.json
→ bulk-import-batches.ts ┘ │
↓
src/lib/db/foundations-repo.ts (cached read layer)
↓
UI
Data integrity rules
Per /AGENTS.md:
- Never auto-write unverified data to the DB without provenance tracking
- DB is write SSOT — never hand-edit
stiftungen-generated.ts - Quality gate is enforced by
validateFoundationQualityinsrc/lib/domain/foundation-quality.ts— uses computedisResearched(f)(tier ≥ profiliert) andQUALITY_THRESHOLDSfromsrc/lib/config/fit-scoring.ts. The storedneedsResearchboolean is deprecated.
Recent cleanup
The directory was 90 scripts in early 2026-04. Three cleanup commits
(cc51c61, b2f8156, eb5675c) removed 62 dead scripts (-5,672 lines):
underscore-prefixed throwaways, dated single-batch operations,
superseded duplicates, and exploratory rescore experiments. Surviving
scripts are either invoked from package.json, called by other
scripts, or are intentional manual-run tools.