# Knowledge sources

Where the agents' knowledge comes from, grouped by door: the environment itself, sampled data, files and links people shared, answers they gave. Each source says when it was last read and whether that's overdue; a failed read says why.

- Registry name: `knowledge-sources` (`@candor/knowledge-sources`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/knowledge-sources

## Install

```bash
npx candor-ui add knowledge-sources
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/knowledge-sources`.
It brings in: button, freshness-stamp, know, locale, status-dot, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import type { KnowSource } from "@/lib/know"
import { KnowledgeSources } from "@/components/knowledge-sources"

const ago = (m: number) => new Date(Date.now() - m * 60_000).toISOString()

const sources: KnowSource[] = [
  { id: "k1", door: "config", label: "Staging: code and schema", readAt: ago(60 * 5), everyHours: 24, status: "succeeded", extent: "4 repos · 86 tables · 142 migrations" },
  { id: "k2", door: "config", label: "Production: code and schema", readAt: ago(60 * 52), everyHours: 24, status: "succeeded", extent: "4 repos · 86 tables · 139 migrations" },
  { id: "k3", door: "file", label: "Data model notes v3.pdf", addedBy: "Priya", readAt: ago(60 * 24 * 12), status: "succeeded", extent: "24 pages" },
  { id: "k4", door: "file", label: "Data residency rules.xlsx", addedBy: "Dana", readAt: null, status: "running" },
  { id: "k5", door: "link", label: "wiki.acme.example/platform/handbook", addedBy: "Maya", readAt: ago(60 * 24 * 3), status: "failed", error: "The page needs a sign-in Keel doesn't have. Export it as PDF and add it as a file." },
  { id: "k6", door: "answer", label: "“partner tier is being replaced by region”", addedBy: "Priya", readAt: ago(60 * 24 * 9), status: "succeeded" },
]

export default function Example() {
  return <KnowledgeSources className="max-w-xl" sources={sources} onAdd={() => {}} onReread={() => {}} />
}
```

## <KnowledgeSources>

Props:

- `sources: KnowSource[]`: Every source, grouped by where it came from, each with when it was last read and any error.
- `onAdd?: (() => void) | undefined`: Shows an Add button; called when it's clicked.
- `onReread?: ((id: string) => void) | undefined`: Shows a read-again button on each source not already being read; called with its id.
- `className?: string | undefined`

## Strings (`knowledgeSources`)

The fixed words, English by default. Override any of them under `knowledgeSources` in `<LocaleProvider strings={{ knowledgeSources: { … } }}>`; the table is exported as `knowledgeSourcesStrings`.

- `label`: Knowledge sources
- `sources`: Sources
- `add`: Add
- `empty`: Nothing has been read yet.
- `readingNow`: Reading now
- `from`: from {name}
- `reread`: Re-read
- `rereadSource`: Re-read {name}
- `doorConfig`: Configuration
- `doorData`: Data, sampled
- `doorFile`: Files
- `doorLink`: Links
- `doorAnswer`: Answers you gave
- `doorReleaseNotes`: Release notes

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
