@0xkobold/pi-secret-guardian
Secret detection and pi-share-hf integration for pi-coding-agent. Scans projects, sessions, and environment for secrets, syncs to pi-share-hf workspace, and manages the collection/upload pipeline.
Package details
Install @0xkobold/pi-secret-guardian from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@0xkobold/pi-secret-guardian- Package
@0xkobold/pi-secret-guardian- Version
0.1.0- Published
- Apr 9, 2026
- Downloads
- 227/mo ยท 31/wk
- Author
- moikapy
- License
- MIT
- Types
- extension
- Size
- 87.9 KB
- Dependencies
- 0 dependencies ยท 2 peers
Pi manifest JSON
{
"extensions": [
"./dist/index.js"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
๐ก๏ธ pi-secret-guardian
Secret detection and pi-share-hf integration for pi.
Part of the 0xKobold ecosystem.
What it does
- Scans project files, pi sessions, and environment for secrets (API keys, tokens, passwords)
- Runs TruffleHog for verified secret detection as a backstop
- Syncs discovered secrets to pi-share-hf's
secrets.txtfor deterministic redaction - Patches pi-share-hf to load pi-ollama during LLM review (patches
--no-extensions) - Manages the full collect โ review โ upload pipeline
Installation
Bundled (recommended)
pi install npm:@0xkobold/pi-kobold
# pi-secret-guardian loaded as sub-extension automatically
Standalone
pi install npm:@0xkobold/pi-secret-guardian
# Or in pi-config.ts
{
extensions: [
'npm:@0xkobold/pi-secret-guardian'
]
}
# Or temporary (testing)
pi -e npm:@0xkobold/pi-secret-guardian
External dependencies
# TruffleHog (required for verified secret detection)
brew install trufflehog
# pi-share-hf (required for HF sync/upload)
npm install -g pi-share-hf
Tools
| Tool | Description |
|---|---|
secret_scan |
Scan project/sessions/env for secrets (pattern + TruffleHog) |
secret_sync_hf |
Sync secrets to pi-share-hf workspace + run collect |
secret_report |
Report on pi-share-hf workspace status |
secret_upload |
Upload reviewed sessions to HuggingFace |
Commands
| Command | Description |
|---|---|
/secret-scan |
Quick scan for secrets |
/hf-status |
Show pi-share-hf workspace status |
Usage
1. Scan for secrets
Run secret_scan with scope=all and includeTruffleHog=true
2. Sync and collect
Run secret_sync_hf to sync secrets and run pi-share-hf collect
3. Review and upload
Run secret_report to check uploadable sessions
Run secret_upload to upload to HuggingFace
API / Library Usage
Types and utility functions are available for programmatic use:
// Import from shared module (recommended)
import {
type SecretFinding,
type TruffleHogFinding,
type ScanResult,
maskSecret,
parseEnvFile,
parseNpmrc,
scanWithPatterns,
SECRET_PATTERNS,
ENV_FILES,
} from "@0xkobold/pi-secret-guardian/shared";
// Or from the main entry (convenience re-exports)
import { maskSecret, type SecretFinding } from "@0xkobold/pi-secret-guardian";
// Mask a secret for safe display
maskSecret("ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
// โ "ghp_****890"
// Parse an .env file for secrets
const findings = parseEnvFile(envContent, "/path/to/.env");
// Scan content against known patterns
const patternHits = scanWithPatterns(sourceCode, "/path/to/file.ts", "project-file");
pi-share-hf Ollama Patch
pi-share-hf's LLM review subprocess uses pi --no-extensions, which prevents pi-ollama from loading. This extension includes a patch script that adds -e <pi-ollama-path> after --no-extensions so the review can use your ollama models.
The patch is applied automatically by secret_sync_hf. To apply manually:
bash packages/pi-secret-guardian/scripts/pi-share-hf-patch.sh
Re-run after any npm update -g pi-share-hf.
Configuration
| File | Purpose |
|---|---|
.pi/hf-sessions/secrets.txt |
Auto-managed list of secrets to redact |
.pi/hf-sessions/deny.txt |
Regex patterns to reject sessions |
.pi/hf-sessions/workspace.json |
pi-share-hf workspace config |
Architecture
src/
โโโ index.ts # Extension factory (4 tools + 2 commands + lifecycle hooks)
โโโ shared.ts # Types, patterns, and utility functions (library API)
scripts/
โโโ pi-share-hf-patch.sh # Patches pi-share-hf for ollama support
Integrated into pi-kobold as a sub-extension with duplicate-load guard.
Related Packages
@0xkobold/pi-koboldโ Meta-extension that bundles this and other sub-extensions@0xkobold/pi-ollamaโ Ollama integration (required for HF review patch)
Local Development
git clone https://github.com/0xKobold/pi-secret-guardian
cd pi-secret-guardian
npm install
npm run build
pi install ./
License
MIT ยฉ 0xKobold