UNPKG

socraticode

Version:

SocratiCode — MCP server for local codebase indexing, semantic search, and code dependency graphs. All private, all local via Docker.

106 lines • 5.38 kB
/** * Detect the current git branch for a project path. * Returns `null` if the path is not inside a git repository or detection fails. */ export declare function detectGitBranch(projectPath: string): string | null; /** * Sanitize a git branch name for use in Qdrant collection names. * Replaces characters outside `[a-zA-Z0-9_-]` with underscores, * collapses consecutive underscores, and strips leading/trailing underscores. */ export declare function sanitizeBranchName(branch: string): string; /** * Generate a stable project ID from an absolute folder path. * Uses a short SHA-256 prefix so collection names stay Qdrant-friendly. * * Resolution order (highest precedence first): * 1. `SOCRATICODE_PROJECT_ID` env var — per-machine override. * 2. `projectId` in `.socraticode.json` — committed, shared across the * team so every checkout addresses the same Qdrant collection * regardless of where the working tree lives on disk. * 3. SHA-256 prefix of the resolved absolute path — default fallback. * * In both override paths the value must match `[a-zA-Z0-9_-]+`; invalid * characters throw. Whitespace is trimmed; empty/whitespace-only values * fall through to the next level. * * When `SOCRATICODE_BRANCH_AWARE` is `"true"` (and no explicit project ID * is set via env var or config file), the current git branch name is * appended to the hash, producing a separate set of collections per * branch. */ export declare function projectIdFromPath(folderPath: string, observedBranch?: string | null): string; /** * Core project ID: SHA-256 hash of the resolved path, without branch suffix. * Used as the default fallback when no explicit project ID is configured. */ export declare function coreProjectId(folderPath: string): string; /** * Derive a Qdrant collection name for a project's code chunks. * * The optional `QDRANT_COLLECTION_PREFIX` env var is prepended verbatim to * isolate this SocratiCode instance's collections when sharing a Qdrant * server with other applications or other SocratiCode instances. Empty * prefix (the default) preserves the legacy `codebase_<id>` form exactly. */ export declare function collectionName(projectId: string): string; /** * Derive a Qdrant collection name for a project's code graph. * See {@link collectionName} for the prefix semantics. */ export declare function graphCollectionName(projectId: string): string; /** * Derive a Qdrant collection name for a project's context artifacts. * See {@link collectionName} for the prefix semantics. */ export declare function contextCollectionName(projectId: string): string; /** Top-level metadata point for a project's symbol graph. */ export declare function symgraphMetaCollectionName(projectId: string): string; /** Per-file payloads for a project's symbol graph. */ export declare function symgraphFileCollectionName(projectId: string): string; /** Sharded indices (name index + reverse-call file index). */ export declare function symgraphIndexCollectionName(projectId: string): string; /** * Load the effective Python import roots from `.socraticode.json`. * * Entries are interpreted relative to the project root, normalised to * forward-slash project-relative paths, deduplicated in declared order, and * kept only when they resolve to an existing directory inside the project. * Absolute paths, paths that escape the project (including through symlinks), * non-directories, missing paths, malformed values, and an unusable config * file are ignored. Returning an empty list preserves the legacy resolver * exactly. */ export declare function loadPythonRoots(projectPath: string): string[]; /** * Load linked project paths from `.socraticode.json` and/or the * `SOCRATICODE_LINKED_PROJECTS` env var (comma-separated absolute or relative paths). * * Returns resolved absolute paths. Invalid/missing paths are silently skipped. */ export declare function loadLinkedProjects(projectPath: string): string[]; /** * Resolve linked projects into Qdrant collection descriptors for multi-collection search. * Returns an array of { name, label } suitable for `searchMultipleCollections()`. * The current project is always first (highest priority for dedup). * * Linked-project IDs are resolved via `effectiveBaseProjectId`, which honors * each linked project's own `.socraticode.json` `projectId` field. This * preserves symmetry — a project addresses the same Qdrant collection whether * it is the current root or a linked dependency from another project. * * Dedup compares against the *current project's full ID* (env override → file * → path-hash, with optional branch suffix). This guarantees the dedup key * matches the actual collection name being added: a linked project is skipped * only when it would resolve to the same collection that the current project * already occupies. Seeding from `effectiveBaseProjectId(resolvedRoot)` would * misalign the seed when `SOCRATICODE_PROJECT_ID` is set, causing linked * projects whose file `projectId` happens to match the current project's file * `projectId` to be silently dropped even though their data lives in a * different collection than the env-overridden current one. */ export declare function resolveLinkedCollections(projectPath: string): Array<{ name: string; label: string; }>; //# sourceMappingURL=config.d.ts.map