概要
🗺️ 🧭 Semantic code intelligence
AI・機械学習計測したスター増加
- 24時間
- +1
- 7日間
- +1
- 15日間
- +1
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナル
gitshaman.com
GitShaman is a static-first Next.js source browser. It combines curated guides, a VS Code-like workspace, indexed search, Monaco navigation, and semantic graphs. The GitShaman CLI brings source analysis and a local browser workspace to your own Git repositories.
CLI
Analysis and search are structural by default: they parse source and build symbol/call indexes
without loading an embedding model or making a model request. A Rust core parses C, C++, Rust,
Go, Python, JavaScript, TypeScript, Java, and PHP; other eligible text remains searchable.
Native and browser WASM search share the ranking implementation. Results include source citations
and fit a configurable cl100k_base token budget.
Build and get started
Requires Git and Node.js 22.22.2 or newer. Building from source also requires the Rust toolchain and WASM target pinned in rust-toolchain.toml. Packaged CLI archives include the native executable and browser runtime, so end users do not need Rust.
From this checkout:
npm install
npm run cli:build
node packages/cli/dist/cli.js --help
# Initialize and analyze a Git worktree, then open its local workspace.
node packages/cli/dist/cli.js init --repo /path/to/repository
node packages/cli/dist/cli.js analyze --repo /path/to/repository
node packages/cli/dist/cli.js query "where are tokens validated?" \
--repo /path/to/repository --max-tokens 2048
node packages/cli/dist/cli.js viz --repo /path/to/repository
To make the gitshaman command available, run npm link ./packages/cli from this checkout.
The following examples use that command inside the target repository. For CLI development, use
npm run cli -- <command> --repo /path/to/repository; build first so the native engine and
packaged workspace assets are available.
init creates gitshaman.json and .gitshamanignore, and adds .gitshaman/ to .gitignore.
Configuration and extra ignore patterns can be committed; generated indexes and caches live in
.gitshaman/. The generated configuration starts with:
{
"version": 1,
"analysis": {
"exclude": [],
"languages": [],
"enrichment": "off"
},
"embeddings": {
"provider": "ollama",
"model": "embeddinggemma",
"endpoint": "http://127.0.0.1:11434"
}
}
An empty languages list includes all detected languages. Use identifiers such as c, cpp,
rust, go, python, javascript, typescript, java, or php to restrict analysis. Add Git-style
ignore patterns to analysis.exclude or .gitshamanignore. Set analysis.enrichment to auto
to opt into compiler enrichment of the compatibility SQLite index.
| Command | Purpose |
|---|---|
gitshaman init |
Initialize the current Git worktree. |
gitshaman analyze |
Build structural indexes without embedding requests. |
gitshaman query <text> |
Retrieve cited source within a token budget, or navigate symbols. |
gitshaman mcp |
Serve read-only agent tools over stdio. |
gitshaman viz |
Serve the local workspace and graph, and open a browser. |
gitshaman parser [path] |
Inspect extracted symbols for a repository-relative file or directory. |
gitshaman embed |
Generate or refresh optional embeddings for the current snapshot. |
gitshaman version |
Show component versions. |
gitshaman verify |
Check packaged assets, index integrity, and embedding compatibility. |
gitshaman checksum |
Refresh observed source checksums. |
gitshaman share |
Contribute a public commit through a GitHub PR. |
All commands accept --repo <directory> and --help; --json is also available.
Search, snapshots, and watch mode
gitshaman query "where is the token validated?" --max-tokens 2048
gitshaman query authenticate --mode definition
gitshaman query authenticate --mode callers
gitshaman query "token validation" --anchors authenticate --scope src --max-tokens 1024
gitshaman analyze --watch
Query modes are structural, hybrid, entities, definition, references, callers, and callees.
Use gitshaman query "*" --mode entities to obtain the bounded entity catalog and its confirmed
relationships as JSON, or query a symbol name or stable ID with that mode.
--anchors accepts comma-separated symbols; --scope restricts retrieval to a repository-relative
file or directory. Hybrid mode requires compatible embeddings for the current snapshot.
Analysis reads the working tree by default. Use --committed to analyze HEAD, --force to
rebuild, or --with-embeddings to request optional embeddings. --no-embed remains supported.
Unchanged files reuse parsed records. Each successful analysis publishes an immutable generation;
failed or cancelled analysis keeps the previous generation. Older version 1 snapshots are retained.
Run analyze after edits, or keep analyze --watch running for automatic updates. Watch mode
serializes rebuilds and excludes generated state from its source-directory watchers.
Queries cite the indexed snapshot. MCP read returns that snapshot's source; use MCP status
to compare it with the working tree. Ordinary queries report unknown working-tree freshness.
Source-only resolution is partial: references currently cover resolved call sites, and ambiguous
or unknown receiver types remain unresolved.
viz binds to 127.0.0.1 on an available port; use --port 3001 to select a port or --no-open
to print the URL without opening a browser. It provides the shared editor, search, entities,
guides, themes, and status bar through an authenticated local server. The workspace reports
source changes since analysis. Stop the server or watcher with Ctrl+C.
MCP setup
Start the stdio server directly with gitshaman mcp --repo /path/to/repository, or configure
an MCP client to launch it:
{
"mcpServers": {
"gitshaman": {
"command": "gitshaman",
"args": ["mcp", "--repo", "/absolute/path/to/repository"]
}
}
}
Initialize and analyze the repository before connecting. Available tools are query, definition,
references, callers, callees, read, status, files, symbols, and search. All are read-only. Query arguments include
anchors, knownSymbols, scope, maxTokens, and mode; navigation tools also accept
sourcePath and line for call-site disambiguation. Stdout carries JSON-RPC protocol messages.
Use files to discover indexed paths, symbols to explore definitions and their resolved call
graph, and search to find literal text with one-based line and column citations. These tools
read the indexed snapshot, so re-run analysis to include working-tree edits.
| Tool | Example arguments | Behavior |
|---|---|---|
files |
{"scope":"src","limit":50,"offset":0} |
Sorted paths, total count, and nextOffset. |
symbols |
{"scope":"src/auth.ts"} |
Symbol catalog; optional query filters definitions. Accepts the shared query arguments except mode. |
search |
{"query":"verifyToken(token)","scope":"src","caseSensitive":true,"limit":50} |
Literal matches, one per line, with previews capped at 2000 characters and nextOffset. |
For files and search, limit defaults to 100 (maximum 200). Pass nextOffset as offset
for another page; null means the last page. Pagination assumes the same snapshot: restart if
the returned snapshot signature changes. scope selects an exact file or directory and its
descendants. Omit it to cover all indexed files. Search is case-sensitive by default and treats
punctuation literally.
Optional embeddings
Structural analysis and queries make no provider requests. To enable semantic recall, configure
a provider and generate embeddings explicitly with embed or analyze --with-embeddings.
The default optional provider is Ollama at http://127.0.0.1:11434, using embeddinggemma:
ollama pull embeddinggemma
gitshaman embed
gitshaman query "where are failed connections retried?" --mode hybrid --max-tokens 2048
Run analysis again after source changes before embedding. embed uses the existing snapshot.
Stable symbol-context chunks are cached by content, provider, model, and preprocessing. Vectors
use compact SQ8 storage, with IVF candidate selection above 50,000 rows, and publish atomically.
Quantization and IVF are approximate; their corpus-scale recall still needs measurement.
If Ollama is unavailable during an explicitly requested embedding step in analyze, structural
analysis remains usable and embeddings are reported as skipped. To use OpenRouter, set
embeddings.provider to openrouter, configure endpoint and model, and set apiKeyEnv to
the name of an environment variable containing the API key. Source chunks are sent to that
provider when embeddings run; hybrid queries also send the query for embedding. Keep credentials
in the environment.
See the engine documentation for artifact formats, migration, and resolution limits, and the benchmark instructions for reproducible runs.
Share a public repository
Sharing requires analysis of the current committed snapshot and a commit already accessible in
a public GitHub repository. Install the GitHub CLI and run gh auth login before submitting:
gitshaman analyze --committed
gitshaman share --dry-run
gitshaman share
--dry-run validates the public source and prints the proposed contribution without creating a PR.
Use --source owner/repo to override remote detection, --name, --description, and --slug
to customize metadata, or --guide path/to/guide.md to include a validated guide. --no-open
suppresses opening the result in a browser. Sharing contributes a reproducible recipe and summary;
local vectors and credentials are not included. After review and merge, GitShaman rebuilds and
publishes the curated corpus. The community workflow validates
contributions on pull requests, rebuilds pinned sources after merge to main, and publishes through
the community-publication environment. Publication requires configured R2 credentials and a
Cloudflare Pages deploy hook.
Local development
npm install
npm run dev # http://localhost:3000
Development builds the native/WASM engine and bundled JavaScript worker, prepares the SQL.js
runtime, and exposes the local corpus under public/repos.
Run npm run corpus:sync to populate or refresh local curated snapshots. This corpus is separate
from the .gitshaman/ analysis created by the CLI in a target repository.
See .env.example for public content-origin settings; put local overrides
in .env.local. Guides live in docs/; start a new guide with
docs/_template.md. Run npm run guides to validate the guide registry, prose,
and repository references. See CONTRIBUTING.md for the guide format.
Android platform snapshots
Stock AOSP, LineageOS, and GrapheneOS track the shared android-17.0.0_r1 baseline.
Workspace builds check the manifest's upstream Blueprint revision against that baseline
before downloading projects. Distribution forks retain their own locked commits.
Stock AOSP's manifest and projects are fetched directly from android.googlesource.com.
AOSP, LineageOS, and GrapheneOS have manifest-backed workspaces. Run npm run repo:sync to download
their manifest repositories and configured core platform projects and build the website search
indexes. This uses shallow Git fetches and pinned component commits, reuses current snapshots,
and does not require the Android repo tool or create a full developer checkout.
npm run repo:sync
npm run repo:sync -- --only=LineageOS/android
npm run repo:sync -- --list
npm run corpus:sync includes these Android sources alongside all other curated repositories.
To rebuild only
Android workspaces after their manifests are present, run npm run corpus:android.
Use -- --only=aosp-mirror/platform_manifest, -- --only=LineageOS/android, or
-- --only=GrapheneOS/platform_manifest to select one.
Project commits are recorded in src/curated/android-locks/ and reused on later builds.
Update those commits deliberately with npm run corpus:android -- --refresh, review the
lockfile changes, and run npm run corpus:check before release. Each completed workspace
has immutable source and project-index artifacts under its manifest revision's
android/snapshots/ directory. The corpus deployment uploads and verifies those artifacts
before publishing android/workspace.json; running the build does not deploy anything.
The browser opens the Android source tree by default and exposes the manifest as a separate view. Search covers the listed core projects, with optional project scoping. Files larger than 2 MiB, binary files, and filesystem symlinks are excluded; manifest copy/link mappings are resolved within the hosted source. Rebuilt project indexes emit native structural artifacts; composite Android navigation continues through its existing adapter, where references are text occurrences and Java, Kotlin, and AIDL type definitions use text heuristics. The initial selection excludes device trees, kernels, and prebuilts.
Testing
Install the Playwright browsers once before running browser tests:
npx playwright install chromium firefox
Run the Node and browser test suites:
npm test
The command runs Node tests followed by Playwright in Chromium, Firefox, and mobile Chromium.
Its preparation step builds the CLI and bundled workspace. To run only CLI checks, use
npm run test:cli, which builds the package and runs CLI Node and workspace browser tests.
This includes command subprocesses, analysis and retrieval, failure cleanup,
and the shared workspace UI. Run npm run test:cli:coverage for source-level CLI line, branch, and
function coverage from the Node suites; browser tests run separately under test:cli.
Playwright loads .env.local with Next.js environment loading, prepares local assets, and starts a
development server automatically. Browser test reports and failure artifacts are written under out/.
Run npm run lint separately for type, ESLint, formatting, guide prose, and Markdown checks.
Build and deployment
npm run build builds the native/WASM runtime and JavaScript worker, generates the guide registry,
refreshes an out-of-date local corpus when needed,
validates guides, stages shell assets, runs the static Next.js export, and writes a build report.
Cloudflare Pages sets CF_PAGES=1. When Cargo is missing, the build installs rustup into
.cache/cargo and .cache/rustup; rust-toolchain.toml selects the pinned Rust version and WASM
target. Pages skips local corpus generation and publishes the static shell. The deployed shell
reads curated snapshots and indexes from the configured public R2 origin
(NEXT_PUBLIC_R2_PUBLIC_BASE_URL; see .env.example).
Set EXPLORAR_SKIP_CORPUS_BUILD=0 to force corpus generation in that environment.
# Refresh cached repository snapshots without compiler enrichment.
npm run corpus:sync
# Prepare compilation databases for semantic enrichment.
npm run corpus:semantic
# Check cached SQLite indexes.
npm run corpus:check
# Upload changed/missing files from the prepared local corpus to R2.
npm run corpus:deploy
Cloudflare Pages publishes the website shell separately. corpus:deploy uploads only the current
curated repository revisions, using content hashes rather than timestamps or file sizes.
It lists each current remote prefix on every run to repair missing objects, but uploads only
the diff. Unchanged runs perform no uploads, including deployment metadata. Missing metadata is
recreated without re-uploading matching single-part objects. Old revisions remain untouched.
Local hashes are cached under .cache/r2-deploy;
the first run reads every local file, while later runs reuse hashes when file metadata matches.
Set R2_DEPLOY_VERIFY=1 to force rehashing. Remote multipart objects without a recorded content
hash may need a one-time upload to establish an inventory. Per-repository logs report scan,
upload, verification times, and skipped/uploaded file counts. R2_SYNC_CONCURRENCY controls
concurrent repositories (default 2); AWS CLI transfer settings control each upload pool.
Building the local corpus uses the pinned Rust indexer and requires Node.js 22.22.2 or newer
for native better-sqlite3. Immutable blocks upload before engine manifests; Android project
manifests are verified before the workspace pointer is published.
Cloudflare Pages serves exported routes and assets before its 404.html fallback. Unknown GitHub
repository URLs reach the client app through ?github_path=.... Do not add catch-all
/:owner/:repo rewrites: they also capture Next.js route-data files and images. After changing
routing, purge cached redirects and verify in a fresh browser context.
To use the URL-hacking workflow, replace github.com with gitshaman.com in a repository URL.
Architecture
Curated repositories are analyzed before deployment. Hosted search fetches verified immutable index blocks on demand in a JavaScript worker and ranks them with WASM. Local CLI and MCP queries use the same ranking core natively. Compatible SQLite artifacts remain available for symbol-only entity fallback, older snapshots, and optional compiler enrichment.
Exploration Graph
Open Exploration Graph in the right sidebar beside Guide. Nodes represent repositories visited during exploration and their declared dependencies; revisiting a repository restores its saved workspace. Navigation order does not create edges. Edges require direct dependency evidence from manifests, version declarations, Git submodules, or equivalent checked-in build declarations. Historical derivation, architectural similarity, and indirect dependencies do not create edges.
This repository graph is separate from the source-level Semantic Graph described below.
Entity relationships
Open Entities to explore symbols, functions, types, and other indexed definitions as a directed graph. The repository index manifest references a compact entity catalog; the view loads it without scanning guide-linked source files. Search by symbol or path, select a node to inspect its signature, then use Explore connections to query its neighborhood or Open source to jump to its line. Fit graph, zoom controls, and Overview help navigate larger results.
Nodes retain stable symbol IDs, so same-named functions in different files stay distinct. Arrows represent resolved calls with indexed call-site evidence; recursion and disconnected entities remain visible. Graph queries are bounded and show a limited-view indicator when more results exist. Older SQLite indexes can supply symbol nodes, but file-level relationships are not converted into symbol edges. Rebuild those indexes to get the native entity catalog and confirmed relationships.
Build and corpus pipeline
flowchart TB
subgraph Build["Prepare artifacts"]
Guides["Markdown guides"] --> Registry["Guide registry"]
Config["Curated repository config"] --> Snapshot["Source snapshots and manifests"]
Snapshot --> Analyze["Rust / Tree-sitter analysis"]
Analyze --> Native["Version 2 manifest and immutable blocks"]
Analyze --> Index["Compatibility code-index.sqlite"]
Snapshot --> Clangd["Optional clangd enrichment"]
Commands["Native or generated compilation commands"] --> Clangd
Clangd -->|definitions, references, hover, diagnostics, calls| Index
Registry --> Shell["Static Next.js shell"]
Runtime["WASM runtime and bundled JavaScript worker"] --> Shell
Snapshot --> Corpus["Prepared corpus"]
Index --> Corpus
Native --> Corpus
end
subgraph Publish["Serve artifacts"]
Local["Local /repos symlink"]
R2["Public Cloudflare R2 origin"]
Pages["Cloudflare Pages"]
end
Corpus -->|local development| Local
Corpus -->|corpus:deploy| R2
Shell -->|website deployment| Pages
The compatibility SQLite schema supports files, symbols, references, file relationships, guide links,
concepts, diagnostics, capability records, and full-text search. code-index.sqlite is versioned;
the browser accepts compatible versions. Existing source downloads can be reindexed without
downloading them again. Deployment verifies immutable blocks before publishing their index manifest;
Android workspace pointers follow the verified project manifests.
Browser workspace
flowchart TB
Route["Repository route or GitHub URL fallback"] --> Workspace["Repository workspace"]
subgraph Content["Curated repository content"]
Source{"Content source"}
Source -->|local development| Local["Local /repos"]
Source -->|production or remote preview| R2["Public R2 origin"]
Local --> Artifacts["Source, manifests, immutable blocks, compatibility SQLite"]
R2 --> Artifacts
Artifacts --> Files["Source files and manifests"]
Artifacts --> SQLJS["Compatibility SQL.js index"]
Artifacts --> Structural["JavaScript worker / WASM structural engine"]
end
Workspace --> Source
subgraph Features["Workspace features"]
Editor["Monaco editor"]
Search["File and symbol search"]
Graph["Semantic graph: loaded on selection"]
Guide["Guide panel"]
end
Workspace --> Editor
Workspace --> Search
Workspace --> Graph
Workspace --> Guide
Editor -->|read source| Files
Editor --> Service["SemanticQueryService"]
Service --> StructuralBackend["StructuralLanguageBackend"]
StructuralBackend --> Structural
Service --> Indexed["Legacy IndexedLanguageBackend"]
Service --> Heuristic["HeuristicLanguageBackend"]
Indexed --> SQLJS
Search --> Structural
Graph --> SQLJS
The workspace can switch curated content between local staged files and a configured R2 origin while developing. In production, it uses the public R2 origin. The code-index cache is keyed by repository, revision, and source mode so local and remote artifacts do not overlap.
Semantic query flow
sequenceDiagram
participant Editor as Monaco editor
participant Service as SemanticQueryService
participant Structural as Structural backend
participant Engine as Native API or WASM worker
participant Legacy as SQLite / heuristic backends
Editor->>Service: Query with language and source context
alt Structural source available
Service->>Structural: Definition, references, hover, symbols, or relationships
Structural->>Engine: Query indexed snapshot
Engine-->>Structural: Cited records and unresolved-call information
Structural-->>Service: Partial source-only result
else Older artifact or structural source unavailable
Service->>Legacy: Query supported capabilities
Legacy-->>Service: Indexed or best-effort result
end
Service-->>Editor: Locations, hover, symbols, or relationships
SemanticQueryService orders registered backends by capability and priority, isolates provider
failures, and exposes a shared query contract. Definitions, hover, and document symbols use the first
useful result. References, relationships, and diagnostics merge and deduplicate provider results.
Type members and include chains require indexed data; diagnostics are available when the loaded index supports them.
The structural backend parses C, C++, Rust, Go, Python, JavaScript, TypeScript, Java, and PHP. Source-only symbol resolution is partial and leaves ambiguous receivers unresolved. The existing SQLite backend remains available for older artifacts and symbol-only entity fallback. Optional compiler enrichment currently targets C-family repositories and enriches that compatibility view.
Semantic graph
The Semantic Graph tab loads only when selected. It reads bounded relationship data from the SQLite index during idle time, classifies edges as calls, data flow, dependencies, or other relationships, and renders them with provider and confidence metadata. This keeps large indexes out of the critical workspace path.
Current scope and boundaries
- Structural search supports nine source grammars. Non-call references and language-specific import/receiver resolution are incomplete; ambiguous calls stay unresolved.
- Incremental builds reuse parsing, but resolution and block export still run across the current index. Affected-subgraph-only updates remain an optimization gate.
- Saved benchmark reports cover a fixture and pinned cJSON source. They are small development judgments, not proof of superiority over Eulix. Matched Eulix comparisons, kernel-scale speed and memory, and broad IVF recall remain unverified release gates.
- C and C++ have the first compiler-backed enrichment path through
clangd. - Generated source-only compilation commands are explicitly partial; native compilation databases in
build/orout/take precedence. - Data-flow relationships are intraprocedural and best effort, not alias, interprocedural, or taint analysis.
- Repositories without a usable index continue with source browsing and heuristic editor behavior.
- The semantic graph loads on selection and does not block initial workspace loading.
関連プロジェクトを探す
読み込み中…