Product layer on top of the pure engine: a wizard to connect the apps that feed the brain, an encrypted credential vault (Fernet/PBKDF2; app logins never enter brain.db), and 3 working connectors. Connector data flows through the same credential-scrub path as the engine. Atlas Corporation proprietary.
25 lines
1 KiB
Python
25 lines
1 KiB
Python
# SecondBrain — (c) 2026 Atlas Corporation. All Rights Reserved. Proprietary; see LICENSE.
|
|
"""Connector: local files & folders (notes, code, docs)."""
|
|
import os
|
|
from .base import Connector, Field, register, _brain
|
|
|
|
@register
|
|
class FilesystemConnector(Connector):
|
|
id = "files"
|
|
name = "Files & folders"
|
|
blurb = "Index a local directory of notes / code / docs (60+ text types)."
|
|
fields = [Field("path", "Directory to index", default="~/notes")]
|
|
|
|
def test(self, cfg):
|
|
p = os.path.expanduser(cfg["path"])
|
|
if not os.path.isdir(p):
|
|
raise RuntimeError(f"not a directory: {p}")
|
|
return f"dir ok: {p}"
|
|
|
|
def sync(self, cfg):
|
|
brain = _brain()
|
|
p = os.path.expanduser(cfg["path"])
|
|
conn = brain.db(); before = conn.execute("select count(*) from chunks").fetchone()[0]; conn.close()
|
|
brain.ingest_files(p) # stages directly through scrub
|
|
conn = brain.db(); after = conn.execute("select count(*) from chunks").fetchone()[0]; conn.close()
|
|
return after - before
|