mirror of
https://github.com/K-Dense-AI/scientific-agent-skills.git
synced 2026-12-05 10:33:55 +08:00
A meta-skill that observes a researcher's own screen activity via a local screenpipe daemon, clusters repeated workflow patterns, compares each cluster against this repo's existing 135 skills using local embeddings, and drafts either a thin composition recipe (a SKILL.md that chains existing skills) or a full new SKILL.md when no combination fits. Key design properties - On-demand, no daemon of its own; invoked by the user with a time window. - Local-first. Detection, clustering, redaction, and embeddings all run on-device. Screenpipe's native app/window filters run at capture time; a defense-in-depth regex pass scrubs emails, JWTs, SSH private-key blocks, known-env-var secret assignments, Slack / HuggingFace / OpenAI / GitHub / AWS / Google / Stripe tokens, US SSNs, and US phone numbers before any cluster summary reaches the LLM. - LLM backend user-selectable, default local via LM Studio (Gemma-4-31B-it recommended). Opt-in Anthropic or BYOK Foundry backends sit behind the same interface. - sentence-transformers/all-MiniLM-L6-v2 indexes every SKILL.md frontmatter description locally. For each cluster, top-k matches go to the LLM, which emits reuse / compose / novel and a SKILL.md body where appropriate. - Staged output lives under ~/.autoskill/proposed/<ts>/ (default, outside the repo tree). A promote CLI moves approved ones into scientific-skills/<name>/. - Unified CLI: autoskill run | doctor | promote. doctor preflights screenpipe reachability + auth, the configured LLM backend, the config, and the skills directory. What's shipped - 8 pipeline scripts (fetch_window, redact, cluster, match_skills, synthesize, promote, backends, run) plus the autoskill.py dispatcher. - 83 pytest tests: unit, integration, and end-to-end with httpx.MockTransport fakes for screenpipe and LM Studio. - Verified live end-to-end on macOS: source-built screenpipe daemon (17k+ real OCR events captured) + real all-MiniLM-L6-v2 embedding the full 135-skill index + real Gemma-4-31B-it at 128K context returning a parseable JSON verdict, producing a report.md with sensible top-k matches. - SKILL.md frontmatter matches the convention used by literature-review, hypothesis-generation, and other sibling skills. - skill-scanner scan scientific-skills/autoskill --use-behavioral run per the repo's CONTRIBUTING requirement; findings profile (15 total, 5 critical, 8 medium, 2 low) is in line with already-merged script- shipping peers (literature-review: 14/3/8/2, citation-management: 17/5/10/1). Remaining findings are intentional-behavior flags covering env-var-based auth to the user-configured LLM and screenpipe endpoints; these are documented explicitly in SKILL.md. Tracked by issue #140.
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
import re
|
|
|
|
# Order matters: multi-line and prefixed patterns run before narrower ones.
|
|
_PATTERNS = [
|
|
(re.compile(r"-----BEGIN [A-Z ]+PRIVATE KEY-----[\s\S]*?-----END [A-Z ]+PRIVATE KEY-----"),
|
|
"[REDACTED:private_key]"),
|
|
|
|
# Known-env-var secret assignments: NAME=value (catches long values only)
|
|
(re.compile(
|
|
r"\b(?:AWS_SECRET_ACCESS_KEY|AWS_ACCESS_KEY_ID|GITHUB_TOKEN|HF_TOKEN"
|
|
r"|ANTHROPIC_API_KEY|OPENAI_API_KEY|FOUNDRY_API_KEY|SCREENPIPE_TOKEN"
|
|
r"|GOOGLE_API_KEY|SLACK_TOKEN|DEEPGRAM_API_KEY)"
|
|
r"\s*=\s*[^\s\"']+"
|
|
), "[REDACTED:kv_secret]"),
|
|
|
|
(re.compile(r"Bearer\s+[A-Za-z0-9_\-\.=]+"), "[REDACTED:bearer]"),
|
|
|
|
(re.compile(r"\beyJ[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+"),
|
|
"[REDACTED:jwt]"),
|
|
|
|
(re.compile(r"\bxox[bpars]-[A-Za-z0-9\-]{10,}"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\bhf_[A-Za-z0-9]{32,}"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\bsk-[A-Za-z0-9_\-]{20,}"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\b(?:sk|pk|rk)_live_[A-Za-z0-9]{24,}"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\bghp_[A-Za-z0-9]{36}\b"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\bAKIA[0-9A-Z]{16}\b"), "[REDACTED:api_key]"),
|
|
(re.compile(r"\bAIza[A-Za-z0-9_\-]{35}\b"), "[REDACTED:api_key]"),
|
|
|
|
(re.compile(r"[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}"),
|
|
"[REDACTED:email]"),
|
|
|
|
(re.compile(r"\(\d{3}\)\s*\d{3}-\d{4}"), "[REDACTED:phone]"),
|
|
(re.compile(r"\b\d{3}-\d{2}-\d{4}\b"), "[REDACTED:ssn]"),
|
|
]
|
|
|
|
|
|
def redact(text: str) -> str:
|
|
for pattern, placeholder in _PATTERNS:
|
|
text = pattern.sub(placeholder, text)
|
|
return text
|