Kp source
Add sources to a knowledge project, check for updates, and track provenance. Use when the user runs /kp-source, wants to add a PDF, URL, CSV, database dump, or any document to sources/, needs to check the status of ingested sources, or wants to detect whether a previously ingested source has changed. "kps" is the short name for this project (Knowledge Project Skills) - also activate when the user says "kps ingestion" or "kps ingest".From its SKILL.md
npx -y skills add rangzen/knowledge-project-skills --skill kp-sourceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.9 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
Instructions
When to activate
Activate when the user invokes /kp-source add, /kp-source status,
or /kp-source check-updates, or asks to add a document or source file
to the project.
Sub-commands
add <path-or-url>
If <path> is a directory:
- Run
<skill-dir>/scripts/ingest.py --list-dir <path>to discover files. The script walks recursively (skipping hidden files and dirs), hashes each file, and checks against existing sources for duplicates. All file types are included - no extension filtering. - Count files where
duplicate_ofisnull(new files to ingest). - If that count exceeds the threshold (default 50, override with
--threshold N):
If the user answers N (or gives no answer), abort with zero sources created. PassFound N files. This will create N sources. Continue? [y/N]--yesto skip this prompt for scripted use (--threshold 0also bypasses it). - For each non-duplicate file, run the single-file ingestion steps below
(derive slug, create directory, copy, run ingest.py, handle
--sensitive). - After all files are processed, print a summary:
Added: N Duplicate: N (already ingested as <source-id>) Failed: N
If <path> is a single file or a URL:
- Assign a
source-idslug:- Derive a short kebab-case slug from the filename or URL
(e.g.
cairn-annual-report,privacy-policy-2024). - For YouTube URLs, derive the slug from the video title if available, or
fall back to
youtube-<video-id>(e.g.youtube-dQw4w9WgXcQ). - Keep it concise: 2-4 meaningful words, lowercase, hyphens only.
- Check uniqueness against existing directory names in
sources/. - If the slug already exists, append
-2,-3, etc. until unique.
- Derive a short kebab-case slug from the filename or URL
(e.g.
- Create
sources/<source-id>/. - Fetch content into
sources/<source-id>/:- YouTube URL (
youtube.com/watch?v=oryoutu.be/): runuv run <skill-dir>/scripts/fetch_youtube.py <url> sources/<source-id>/. This writestranscript.txt(timestamped plain text, one line per caption) and attempts to write<title>.info.jsonvia yt-dlp (best-effort). The primary content file for extraction istranscript.txt. - Other URL: download with
curl -L -o <filename>. - Local file: copy into the directory.
- YouTube URL (
- Run
<skill-dir>/scripts/ingest.py --source-id <source-id> --origin <path-or-url>:- Computes SHA-256 hash.
- Detects type (
pdf,csv,url,db-dump,markdown,image,other). - Reads page count for PDFs.
- Writes
sources/<source-id>/.meta.json.
- If
--sensitive: appendsources/<source-id>/to.gitignore. - Print the assigned
source-idand confirm.
.meta.json schema:
{
"source_id": "generated-source-slug",
"origin": "<path-or-url>",
"type": "pdf",
"ingested_at": "<ISO datetime>",
"hash": "sha256:<hex>",
"page_count": 42,
"sensitive": false,
"extraction": {"status": "pending"},
"stale": false
}
status
For each directory in sources/, read .meta.json and print a table:
| source-id | type | origin | ingested-at | extraction.status | stale |
|---|
check-updates
For each source in sources/:
- Run
<skill-dir>/scripts/ingest.py --check-update --source-id <source-id>. - The script recomputes the hash (or re-fetches for URLs) and compares to the stored hash.
- If changed: set
stale: truein.meta.jsonand print a warning.
Flags
| Flag | Effect |
|---|---|
--sensitive | Adds sources/<source-id>/ to .gitignore. |
--threshold N | Override the file-count confirmation threshold (default 50). Set to 0 to disable. |
--yes | Skip the directory file-count confirmation prompt. |
Edge cases
- URL download fails: report the error, do not create a partial
sources/<source-id>/. - YouTube transcript unavailable (private video, no captions):
fetch_youtube.pyexits non-zero; report the error and do not create a partial source directory. - File not found: report clearly, suggest checking the path.
- Project not initialized (
.knowledge-projectmissing): prompt the user to run/kp-initfirst. - Empty directory: report zero files found.
- Duplicate file in directory input: log it in the summary (
Duplicate: N) with the existingsource-id; do not re-ingest.
What ships with it: 3 files
10.2 KB alongside SKILL.md, 2 of them executable
scripts/
- fetch_youtube.pyruns2.6 KB
- .gitkeep0 B
- ingest.pyruns7.6 KB