Local directories
The local code host makes directories on this machine available as repositories. Nothing is cloned and nothing is written: the working trees are read where they are. It needs no token and no network, which makes it the shortest way to try code search, and the right choice when the code is checked out by something else.
Profile entry
- id: disk
type: local
path: ./codeEvery immediate subdirectory of path is a repository:
$ safran repos --profile /work/acme/safran.yaml
repo host groups teams cloned indexed
ledger disk – – yes not indexed
payments-api disk – – yes not indexed
2 repos, 2 not indexed → safran sync --profile /work/acme/safran.yamlsafran sync then indexes them in place. There is no fetch step for a local repository; a second run only looks at files whose content changed:
$ safran sync --profile /work/acme/safran.yaml
ledger scanning files
ledger indexing 1/1 files 100%
payments-api scanning files
payments-api indexing 1/1 files 100%
repo status changed unchanged chunks time detail
✔ ledger ok 0 1 0 16 ms no changes
✔ payments-api ok 0 1 0 9 ms no changes
2 repos: 2 ok in 29 msimport { createSafran } from "@safran/core";
await using safran = await createSafran({ profile: "/work/acme/safran.yaml" });
for (const repo of await safran.repos.list()) console.log(repo.name, repo.dir, repo.defaultBranch);
await safran.repos.sync();
const { hits } = await safran.code.search("partial refund");
for (const hit of hits) console.log(hit.repo, hit.path, hit.startLine);Individual directories
- id: disk
type: local
repos:
- path: /work/acme/code/payments-api
- name: ledger
path: ../checkouts/ledger-mainrepos lists single directories; name defaults to the directory name. path and repos can be combined. When a directory is reached both ways, the explicit entry (and its name) wins.
Path rules
-
A path is absolute, or relative to the directory of the profile file.
./codein/work/acme/safran.yamlis/work/acme/code, whatever directory the command is run from. -
~is not expanded. A path that starts with~fails validation:$ safran profile check --profile /work/acme/safran.yaml ✘ The profile has 1 configuration problem: - code.hosts.0.path: `~` is not expanded; write an absolute path, or a path relative to the profile file → Fix these entries in the profile. `safran plugins` lists the available types and their fields. -
A relative path in a profile that was not loaded from a file (a profile object passed to
createSafran) has nothing to be resolved against. The instance is still built; the first use of the host fails withINVALID_INPUT. Use absolute paths there.
Configuration reference
| Field | Type | Default | Required | Meaning |
|---|---|---|---|---|
id | string | yes | Name of this entry; the host of its repositories. | |
include | string[] | [] | no | Glob patterns on repository names. Empty means all. |
exclude | string[] | [] | no | Glob patterns on repository names. Exclude wins over include. |
type | "local" | yes | Selects this plugin. | |
path | string | one of the two | A directory whose immediate subdirectories are repositories. | |
repos | object[] | one of the two | Individual directories. At least one when present. | |
repos[].name | string | the directory name | no | Short name of the repository. Two entries may not share a name (compared case-insensitively). |
repos[].path | string | yes | The directory. |
At least one of path and repos must be set.
How repositories are listed and named
- Under
path, only directories count; files are ignored, and so are directories whose name starts with a dot (.git,.cache). A symbolic link to a directory counts. - A directory does not have to be a git repository.
- The same directory reached twice (through a link, or listed both ways) appears once.
- The name is the explicit
name, else the directory name. When two directories share a name, each becomesparent/name, and the absolute path if that still collides. fullNameandcloneUrlare the absolute path.ManagedRepo.diris that same path: the source itself, not a copy.defaultBranchis the branch currently checked out, read from the.gitdirectory without running git (linked worktrees and submodules included). It isLOCAL_DETACHED_HEAD(HEAD) when a commit is checked out instead of a branch, andLOCAL_NO_BRANCH(-) for a directory that is not a git repository.
Problems are logged as warnings, not thrown: when path cannot be read, no repositories are listed from it; an explicit repos entry that is not a directory is skipped. The CLI prints the warning:
$ safran repos --profile /work/acme/safran.yaml
No repos. Add a code host under `code.hosts:` in the profile.
! local: the directory cannot be read; no repositories listed from it (path=/work/acme/missing)include and exclude work as for every code host, on the short name and on fullName, which here is the absolute path:
- id: disk
type: local
path: ./code
exclude: ["*-archive", "tmp-*"]What a local host cannot do
It has no capabilities: no pull-requests, no remote-head, no git credentials, no fileUrl.
No pull requests means no work history. safran links refresh reads merged pull requests from code hosts, and a local directory has none. With only local hosts in the profile:
$ safran links refresh --profile /work/acme/safran.yaml
No repo to refresh: none of the code hosts lists pull requests.
→ Ticket ↔ code links come from merged pull requests on azure-repos, github or gitlab hosts.Naming a local repository explicitly reports it as failed with UNSUPPORTED. Everything that depends on the link store (past work for a ticket, discovery, the golden set for evaluation) needs one of the hosted code hosts.
Other consequences of reading in place:
- Safran never fetches, pulls or checks out anything in a local directory. What is indexed is what is on disk, including uncommitted changes. Keeping it current is up to you.
safran sync --fetch-onlyskips local repositories.--data-dirholds the index, but no working trees for this host.
Known caveats
Nothing in this connector is marked UNVERIFIED; it talks to no service. Its limits are the ones above: no work history, no freshness guarantee, and warnings instead of errors for unreadable paths.
See also
- Quickstart for a first run end to end.
- Repos in the SDK and code search.
- Connectors overview for the rules shared by all connectors.