# Knowledge sources

Granit can turn a public web page, Wikipedia article, or RSS/Atom feed into a
normal Markdown note. Source notes live in the vault rather than in a separate
database, so the existing Explorer, Universal Search, backlinks, graph,
Dataview-style queries, and enabled local-AI tools can use them immediately.

## Import from the TUI

Open the command palette with `F7`, search for **Import Knowledge Source**, or
type `/source` while editing, and enter an HTTPS URL. Granit shows a clear
URL → Review → Save flow. Before saving, review the normalized preview and edit
the title, destination folder, tags, or content format. `Sources/` is the
default; destinations must remain inside the vault and an existing filename is
never silently overwritten.

For a connected import, select a URL or the surrounding prose and press
`Alt+Enter`/`F11` → **Import URL or feed**. After saving, Granit replaces the
selection with a wikilink to the imported source, pins the originating note on
the right, and opens the source on the left. This keeps research attached to
the sentence, project, or Daybook entry that motivated it.

The former **Web Clipper** command is the same workflow under its clearer name.
Its page-clipping behavior remains available, and it now also understands
Wikipedia plus RSS/Atom.

## Import from the CLI

```bash
granit source add https://en.wikipedia.org/wiki/Personal_knowledge_management
granit source add https://example.com/feed.xml --limit 10
granit source add https://example.com/article --vault ~/Notes
```

CLI imports use a stable filename derived from the title and URL. Re-importing
the same URL will not overwrite the note accidentally:

```bash
granit source add https://example.com/article --update
```

Useful options:

| Option | Purpose |
|---|---|
| `--vault`, `-v` | choose the target vault; defaults to `GRANIT_VAULT` or the last-used vault |
| `--folder`, `-f` | choose a vault-relative folder; defaults to `Sources` |
| `--limit 1-50` | limit entries retained from an RSS/Atom feed |
| `--update` | refresh the stable note for an already imported URL |
| `--json` | return a machine-readable result for scripts |

## Source-note contract

A full import has portable YAML metadata followed by readable content and a
place for your own notes:

```markdown
---
type: source
source_kind: "wikipedia"
source_url: "https://en.wikipedia.org/wiki/Personal_knowledge_management"
source_title: "Personal knowledge management"
retrieved_at: "2026-09-22T12:00:00Z"
tags:
  - source
  - wikipedia
---

# Personal knowledge management

...

## Notes
```

`source_kind` is `web`, `wikipedia`, `feed`, or `text`. The original URL and
retrieval time remain visible so generated summaries and later notes can link
back to their provenance.

## Search and AI workflow

After import, no separate indexing step is required for textual search:

1. Import the source.
2. Use Quick Open, Content Search, or Universal Search to find its title,
   entries, and readable text.
3. Add wikilinks from a project, note, or Daybook entry.
4. Optionally use the Research Agent, Note Chat, semantic search, or another
   enabled local-AI command to summarize and connect it.
5. Keep conclusions in your own note and preserve the source link for review.

AI remains optional. Import and normal search work without Ollama, an API key,
or a hosted account.

## Network safety

The shared importer is intentionally conservative:

- public HTTPS URLs are the default;
- redirects are limited and revalidated;
- loopback, private, link-local, multicast, documentation, benchmarking, and
  other reserved IP ranges are rejected;
- response size, readable text, and feed-entry counts are capped;
- embedded URL credentials are rejected;
- destination paths must remain inside the vault;
- note writes are atomic.

For a source you control on a trusted LAN, the CLI provides explicit escape
hatches:

```bash
granit source add http://192.168.1.20/feed.xml --allow-http --allow-private
```

Those flags relax network protections for that invocation. The TUI keeps the
public-HTTPS policy and does not silently reach local services.

Granit stores a readable snapshot, not a live subscription. Run the command
again with `--update` when you want to refresh a feed or page. Respect the
source site's terms and copyright when storing or republishing material.
