synap-git 1.2.2__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {synap_git-1.2.2 → synap_git-1.2.3}/CHANGELOG.md +18 -0
- synap_git-1.2.3/PKG-INFO +494 -0
- synap_git-1.2.3/README.md +444 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/__init__.py +1 -1
- synap_git-1.2.2/PKG-INFO +0 -266
- synap_git-1.2.2/README.md +0 -216
- {synap_git-1.2.2 → synap_git-1.2.3}/.gitignore +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/.synap.example/README.md +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/LICENSE.md +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/pyproject.toml +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/api/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/api/app.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/api/static/index.html +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/cli/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/cli/__main__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/cli/main.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/config.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/diagnostics/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/diagnostics/logger.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/diagnostics/tracing.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/embeddings/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/git/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/git/state.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/indexer/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/indexer/daemon.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/indexer/engine.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/indexer/scanner.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/indexer/wiki.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/mcp/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/mcp/server.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/parser/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/parser/registry.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/anthropic.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/base.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/factory.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/gemini.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/ollama.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/openai.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/provider/openrouter.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/py.typed +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/retrieval/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/retrieval/engine.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/retrieval/memory.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/storage/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/storage/sqlite.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/utils/__init__.py +0 -0
- {synap_git-1.2.2 → synap_git-1.2.3}/src/synap_git/utils/serialization.py +0 -0
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.3] - 2026-05-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Architecture Documentation Consolidation:** Merged duplicate `docs/architecture.md` into the root-level `ARCHITECTURE.md` to ensure a single, consistent source of architectural truth.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Release Version Sync:** Bumped package version in `src/synap_git/__init__.py` to `1.2.3` and updated configuration metadata to align with the release tag validation check in the pipeline.
|
|
15
|
+
|
|
16
|
+
## [1.1.2] - 2026-05-28
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **Technical Documentation (`docs/`):** Added detailed manuals for architecture, CLI reference, configuration fields, MCP tools schemas, two-path indexing, wiki queues, and memory lifecycles.
|
|
20
|
+
- **Main README:** Completely rewrote the `README.md` from scratch to align strictly with the implemented features, CLI commands, configuration options, and integration paths.
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
- **Obsolete Docs:** Purged stale `quickstart.md`, `retrieval.md`, `roadmap.md`, `diagnostics.md`, `performance.md`, `benchmarks.md`, and `security.md` documents.
|
|
24
|
+
- **Draft Files:** Removed unreferenced root files `SYNAPSE_AUDIT_REPORT.md` and `SYNAPSE_AGENT_PROMPT.md `.
|
|
25
|
+
|
|
8
26
|
## [1.1.1] - 2026-05-28
|
|
9
27
|
|
|
10
28
|
### Fixed
|
synap_git-1.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: synap-git
|
|
3
|
+
Version: 1.2.3
|
|
4
|
+
Summary: Persistent structural context infrastructure for AI coding agents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/saahilpal/synap-git
|
|
6
|
+
Project-URL: Repository, https://github.com/saahilpal/synap-git
|
|
7
|
+
Project-URL: Issues, https://github.com/saahilpal/synap-git/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/saahilpal/synap-git/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Synap contributors
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE.md
|
|
12
|
+
Keywords: ai,context,developer-tools,git,mcp,repository-indexing
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: click==8.1.8
|
|
23
|
+
Requires-Dist: fastapi==0.115.11
|
|
24
|
+
Requires-Dist: gitpython==3.1.44
|
|
25
|
+
Requires-Dist: httpx==0.28.1
|
|
26
|
+
Requires-Dist: keyring==25.6.0
|
|
27
|
+
Requires-Dist: markdown-it-py==3.0.0
|
|
28
|
+
Requires-Dist: mcp==1.3.0
|
|
29
|
+
Requires-Dist: msgpack==1.1.0
|
|
30
|
+
Requires-Dist: prompt-toolkit<3.0.44
|
|
31
|
+
Requires-Dist: pydantic-settings==2.8.1
|
|
32
|
+
Requires-Dist: pydantic==2.10.6
|
|
33
|
+
Requires-Dist: questionary==2.1.0
|
|
34
|
+
Requires-Dist: structlog==25.1.0
|
|
35
|
+
Requires-Dist: tiktoken==0.9.0
|
|
36
|
+
Requires-Dist: tree-sitter-languages==1.10.2
|
|
37
|
+
Requires-Dist: tree-sitter==0.20.4
|
|
38
|
+
Requires-Dist: typer==0.15.1
|
|
39
|
+
Requires-Dist: uvicorn==0.34.0
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: bandit==1.8.3; extra == 'dev'
|
|
42
|
+
Requires-Dist: mypy==1.15.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: pre-commit==4.1.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest-asyncio==0.25.3; extra == 'dev'
|
|
45
|
+
Requires-Dist: pytest-cov==6.0.0; extra == 'dev'
|
|
46
|
+
Requires-Dist: pytest-timeout==2.3.1; extra == 'dev'
|
|
47
|
+
Requires-Dist: pytest==8.3.4; extra == 'dev'
|
|
48
|
+
Requires-Dist: ruff==0.9.9; extra == 'dev'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# Synap
|
|
52
|
+
|
|
53
|
+
Local Git-aware structural context engine for AI coding agents.
|
|
54
|
+
|
|
55
|
+
[](https://github.com/saahilpal/synap-git/actions)
|
|
56
|
+
[](https://img.shields.io/project/synap-git/)
|
|
57
|
+
[](https://img.shields.io/project/synap-git/)
|
|
58
|
+
[](LICENSE.md)
|
|
59
|
+
|
|
60
|
+
## The Problem
|
|
61
|
+
|
|
62
|
+
Context windows of AI coding agents become cluttered when fed raw codebase dumps, causing token waste. Standard vector search systems return isolated snippets that lack import relations, class hierarchies, and file-dependency bonds. Switching branches or checking out older commits disrupts agent operations, causing repetitive code failures.
|
|
63
|
+
|
|
64
|
+
## What It Does
|
|
65
|
+
|
|
66
|
+
Synap builds a local structural code graph and a file-level markdown wiki synced to your Git commit history. It stores code symbols and dependency edges in a local SQLite database, generating L3 behavioral memory checkpoints and lessons. Coding agents receive structured, token-bounded context packages through a Model Context Protocol (MCP) server.
|
|
67
|
+
|
|
68
|
+
## High Level Design (HLD)
|
|
69
|
+
|
|
70
|
+
Synap coordinates local repository scanning, graph storage, wiki rendering, and MCP tool serving within a unified runtime daemon.
|
|
71
|
+
|
|
72
|
+
### Component Map
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
┌────────────────────────┐
|
|
76
|
+
│ synap_git.cli │
|
|
77
|
+
└───────────┬────────────┘
|
|
78
|
+
│ (invokes)
|
|
79
|
+
▼
|
|
80
|
+
┌────────────────────────┐
|
|
81
|
+
│ synap_git.indexer. │
|
|
82
|
+
│ daemon │
|
|
83
|
+
└─────┬────────────┬─────┘
|
|
84
|
+
(starts watcher) │ │ (hosts API server)
|
|
85
|
+
┌──────────────┘ └──────────────┐
|
|
86
|
+
▼ ▼
|
|
87
|
+
┌──────────────────────────┐ ┌──────────────────────────┐
|
|
88
|
+
│ synap_git.git.state │ │ synap_git.api.app │
|
|
89
|
+
└─────────────┬────────────┘ └─────────────┬────────────┘
|
|
90
|
+
│ (detects commits) │ (serves UI)
|
|
91
|
+
▼ ▼
|
|
92
|
+
┌──────────────────────────┐ ┌──────────────────────────┐
|
|
93
|
+
│ synap_git.indexer. │ │ synap_git.api.static │
|
|
94
|
+
│ engine │ └──────────────────────────┘
|
|
95
|
+
└─────┬────────────┬───────┘
|
|
96
|
+
│ │ (stores data)
|
|
97
|
+
│ ▼
|
|
98
|
+
│ ┌─────────────────────┐ ┌──────────────────────────┐
|
|
99
|
+
│ │ synap_git.storage. │◀──────│ synap_git.mcp.server │
|
|
100
|
+
│ │ sqlite │ └──────────────────────────┘
|
|
101
|
+
│ └─────────────────────┘ (connects agent)
|
|
102
|
+
│ (generates docs)
|
|
103
|
+
▼
|
|
104
|
+
┌──────────────────────────┐
|
|
105
|
+
│ synap_git.indexer. │
|
|
106
|
+
│ wiki │
|
|
107
|
+
└──────────────────────────┘
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
* **synap_git.cli** — Mounts Typer subcommands for configuration, database repair, logs tailing, and service management.
|
|
111
|
+
* **synap_git.indexer.daemon** — Runs the background loop tracking commit shifts and processes asynchronous documentation tasks.
|
|
112
|
+
* **synap_git.api.app** — Serves REST endpoints for system metrics, LLM call logging, and diagnostic event streams.
|
|
113
|
+
* **synap_git.git.state** — Extracts Git commit OIDs, untracked changes status, and branch indicators.
|
|
114
|
+
* **synap_git.indexer.engine** — Orchestrates parallel file parsing, AST traversal, and database serialization.
|
|
115
|
+
* **synap_git.parser.registry** — Parses language-specific grammar using Tree-sitter.
|
|
116
|
+
* **synap_git.storage.sqlite** — Controls SQLite databases, Write-Ahead Logging (WAL), and FTS5 search indexing.
|
|
117
|
+
* **synap_git.indexer.wiki** — Generates file, module, and project markdown documentation summaries.
|
|
118
|
+
* **synap_git.retrieval.engine** — Controls lexical, structural, and semantic search queries with token budgeting.
|
|
119
|
+
* **synap_git.mcp.server** — Serves Model Context Protocol commands via stdio.
|
|
120
|
+
|
|
121
|
+
### The Layer Model
|
|
122
|
+
|
|
123
|
+
Synap isolates structural truth from non-deterministic summaries through three defined layers:
|
|
124
|
+
|
|
125
|
+
* **L1 (Structural Graph):** Tree-sitter parsers convert code files to AST symbols and import dependencies. Imports map caller-callee relations in a database graph, fully regeneratable from HEAD.
|
|
126
|
+
* **L2 (Semantic Wiki):** Asynchronous background prompts construct markdown summaries of files and modules. Missing pages are resolved on-demand through lazy loading.
|
|
127
|
+
* **L3 (Behavioral Memory):** Stored checkpoints, technical decisions, and lessons persist through branch swaps and index rollbacks.
|
|
128
|
+
|
|
129
|
+
### Runtime Topology
|
|
130
|
+
|
|
131
|
+
On daemon execution, Synap hosts all services in a single process using the asyncio event loop:
|
|
132
|
+
* **Git Watcher Loop:** Polls repository state every 2 seconds. Identifies branch switches, commit additions, merges, and reverts.
|
|
133
|
+
* **Uvicorn Server:** Hosts the REST API and HTML dashboard on port 9876.
|
|
134
|
+
* **Wiki Worker Task:** Listens to `wiki_queue` changes, generating summaries using LLM calls.
|
|
135
|
+
|
|
136
|
+
### Data Flow
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
[Git Commit] ──▶ [Git Watcher] ──▶ [Indexer Engine] ──▶ [SQLite DB] ──▶ [MCP Client]
|
|
140
|
+
│ │ ▲
|
|
141
|
+
│ (detects revert) │ (parallel parser) │ (retrieval)
|
|
142
|
+
▼ ▼ │
|
|
143
|
+
[Pending Lesson] [Symbols & Edges] ─────────┘
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
1. **Commit Detection:** Developer checks in a change. The daemon watches the commit shift and runs incremental indexing.
|
|
147
|
+
2. **Delta Extraction:** Synap calls `git diff-tree` to extract changed files.
|
|
148
|
+
3. **AST Update:** Parser scans modified code, writes new symbols, and deletes old dependencies inside a database transaction.
|
|
149
|
+
4. **Wiki Refresh:** Wiki status flags are set to `"stale"`, enqueuing documentation refreshes in the worker queue.
|
|
150
|
+
5. **Agent Grounding:** The coding agent triggers the MCP server. Hybrid retrieval parses query words, runs graph traversal, checks approved memories, and returns packaged context.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Low Level Design (LLD)
|
|
155
|
+
|
|
156
|
+
### Database Schema
|
|
157
|
+
|
|
158
|
+
All indexing, memory, and tracing metrics are persisted under `.synap/synap.db`.
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
files
|
|
162
|
+
file_id TEXT PK sha256(path + content_hash)
|
|
163
|
+
path TEXT UQ repository-relative file path
|
|
164
|
+
git_oid TEXT git blob object identifier
|
|
165
|
+
content_hash TEXT sha256 hash of file content
|
|
166
|
+
language TEXT parsed programming language name
|
|
167
|
+
module_key TEXT dot-separated module key representation
|
|
168
|
+
updated_at TEXT timestamp string
|
|
169
|
+
|
|
170
|
+
symbols
|
|
171
|
+
symbol_id TEXT PK sha256 hash identifier
|
|
172
|
+
file_id TEXT FK references files(file_id)
|
|
173
|
+
name TEXT symbol name (class/function identifier)
|
|
174
|
+
kind TEXT syntax type (e.g. function_definition)
|
|
175
|
+
start_line INTEGER starting line number
|
|
176
|
+
end_line INTEGER ending line number
|
|
177
|
+
ast_hash TEXT stable hash value of the AST subtree
|
|
178
|
+
metadata_json TEXT serialized symbol metadata attributes
|
|
179
|
+
|
|
180
|
+
edges
|
|
181
|
+
edge_id TEXT PK sha256 edge hash identifier
|
|
182
|
+
source_symbol TEXT FK references symbols(symbol_id)
|
|
183
|
+
target_symbol TEXT FK references symbols(symbol_id)
|
|
184
|
+
edge_type TEXT relationship type (e.g. depends_on)
|
|
185
|
+
|
|
186
|
+
embeddings
|
|
187
|
+
embedding_id TEXT PK sha256 hash identifier
|
|
188
|
+
symbol_id TEXT FK references symbols(symbol_id)
|
|
189
|
+
model_name TEXT associated LLM model
|
|
190
|
+
model_version TEXT version string of model
|
|
191
|
+
prompt_version TEXT prompt design version identifier
|
|
192
|
+
vector BLOB serialized float vector arrays
|
|
193
|
+
content_hash TEXT underlying code block hash
|
|
194
|
+
|
|
195
|
+
active_state
|
|
196
|
+
branch TEXT PK git branch name
|
|
197
|
+
git_commit_hash TEXT git commit OID
|
|
198
|
+
updated_at TEXT timestamp string
|
|
199
|
+
|
|
200
|
+
decisions
|
|
201
|
+
decision_id TEXT PK UUID string
|
|
202
|
+
branch TEXT associated Git branch name
|
|
203
|
+
commit_hash TEXT associated Git commit OID
|
|
204
|
+
content TEXT technical design decision text
|
|
205
|
+
context TEXT technical reasoning text
|
|
206
|
+
agent_id TEXT agent identifiers
|
|
207
|
+
created_at INTEGER unix epoch timestamp
|
|
208
|
+
|
|
209
|
+
checkpoints
|
|
210
|
+
checkpoint_id TEXT PK UUID string
|
|
211
|
+
branch TEXT associated Git branch name
|
|
212
|
+
commit_hash TEXT associated Git commit OID
|
|
213
|
+
doing TEXT current task explanation
|
|
214
|
+
changed_files TEXT JSON list of modified file paths
|
|
215
|
+
next_step TEXT planned next action details
|
|
216
|
+
decisions TEXT associated technical decisions
|
|
217
|
+
blockers TEXT identified development obstacles
|
|
218
|
+
token_count INTEGER active token usage counts
|
|
219
|
+
created_at INTEGER unix epoch timestamp
|
|
220
|
+
|
|
221
|
+
lessons
|
|
222
|
+
lesson_id TEXT PK UUID string
|
|
223
|
+
branch TEXT associated Git branch name
|
|
224
|
+
revert_commit TEXT git revert commit hash
|
|
225
|
+
reverted_from TEXT reverted commit hash
|
|
226
|
+
what_failed TEXT explanation of failure
|
|
227
|
+
why_failed TEXT remedy rule guidelines
|
|
228
|
+
files_affected TEXT JSON list of files modified
|
|
229
|
+
status TEXT lesson status (pending, approved, expired)
|
|
230
|
+
created_at INTEGER unix epoch timestamp
|
|
231
|
+
approved_at INTEGER approval timestamp
|
|
232
|
+
expires_at INTEGER expiry timestamp
|
|
233
|
+
approval_actor TEXT approver credentials identifier
|
|
234
|
+
|
|
235
|
+
llm_calls
|
|
236
|
+
call_id TEXT PK UUID string
|
|
237
|
+
provider TEXT AI provider name
|
|
238
|
+
model TEXT LLM model name
|
|
239
|
+
input_tokens INTEGER input token count
|
|
240
|
+
output_tokens INTEGER output token count
|
|
241
|
+
purpose TEXT call category (retrieval, wiki)
|
|
242
|
+
file_path TEXT associated file path if applicable
|
|
243
|
+
created_at INTEGER unix epoch timestamp
|
|
244
|
+
```
|
|
245
|
+
*Note: Schema versioning is managed via `user_version` pragmas (currently version 3).*
|
|
246
|
+
|
|
247
|
+
### Indexing Pipeline
|
|
248
|
+
|
|
249
|
+
Indexing translates source trees to SQLite relations:
|
|
250
|
+
1. **Bootstrap Check:** Compares HEAD commit hash with database records. Passes execution to first-run indexing if blank, or incremental indexing if commit history matches.
|
|
251
|
+
2. **First-run Indexing:** Parses all files. Files are split into chunks of 500. `ProcessPoolExecutor` uses all available CPU cores to execute AST parsing in parallel.
|
|
252
|
+
3. **AST Symbol Extraction:** Tree-sitter parsers process code bytes. Traversal scripts register functions and classes.
|
|
253
|
+
4. **First-pass Database Insert:** upserted files and symbol rows are written in SQLite transactions using `executemany` arrays.
|
|
254
|
+
5. **Incremental Indexing:** Monitors file changes. Uses `git diff-tree` to isolate changes, deleting obsolete symbols and re-parsing only changed files.
|
|
255
|
+
6. **Pass 2 Edge Resolution:** Resolves imports. Compares import paths with dot-separated `module_key` columns and FTS5 symbol indexes, storing matches in the `edges` table.
|
|
256
|
+
|
|
257
|
+
### Retrieval Design
|
|
258
|
+
|
|
259
|
+
Retrieval uses a four-stage hybrid query execution loop:
|
|
260
|
+
1. **Temporal Selection:** Filters data based on active branch state.
|
|
261
|
+
2. **Lexical Searching:** Queries terms using `symbols_fts` MATCH indexing, starting candidate scores at `1.0`.
|
|
262
|
+
3. **Structural Expansion:** Traverses neighbors up to 2 hops away using SQLite recursive CTEs. Neighbors receive a starting score of `0.8^distance`.
|
|
263
|
+
4. **Semantic Ranking:** Boosts matching queries by `+0.2` if the query matches symbol names. Sorts final context entries in descending order.
|
|
264
|
+
|
|
265
|
+
### MCP Protocol Tools
|
|
266
|
+
|
|
267
|
+
MCP server communicates via stdio, packaging database actions under a JSON envelope.
|
|
268
|
+
|
|
269
|
+
* **`get_status`** — Returns indexing counts, branch details, and HEAD commit hashes.
|
|
270
|
+
* **`search`** (inputs: `query` string, `max_tokens` integer) — Returns ranked context blocks and latency timelines.
|
|
271
|
+
* **`create_checkpoint`** (inputs: `doing` string, `changed_files` list, `next_step` string, `blockers` string) — Registers new thought snapshot.
|
|
272
|
+
* **`restore_checkpoint`** — Returns the latest checkpoint detail for the active branch.
|
|
273
|
+
* **`log_decision`** (inputs: `content` string, `context_info` string) — Logs architectural decisions.
|
|
274
|
+
* **`verify_system`** — Performs SQLite quick checks.
|
|
275
|
+
* **`submit_lesson_analysis`** (inputs: `lesson_id` string, `why_failed` string) — Saves lesson details under pending status.
|
|
276
|
+
* **`get_approved_memory`** — Returns active approved memory lessons.
|
|
277
|
+
* **`get_pending_memory`** — Returns pending lessons awaiting approval.
|
|
278
|
+
* **`signal_low_context`** (inputs: `token_count` integer, `capacity` integer) — Asserts window usage thresholds, recommending checkpoints if needed.
|
|
279
|
+
|
|
280
|
+
### Key Algorithms
|
|
281
|
+
|
|
282
|
+
#### Revert Detection
|
|
283
|
+
When the daemon watcher registers a checkout transition, it runs:
|
|
284
|
+
```bash
|
|
285
|
+
git log -n 1 --pretty=format:%s
|
|
286
|
+
```
|
|
287
|
+
If the commit message starts with `"Revert "`, Synap parses the commit message to extract the reverted commit hash. It runs `git show --name-only` to identify affected paths and inserts a pending lesson row.
|
|
288
|
+
|
|
289
|
+
#### Context Packing
|
|
290
|
+
Context is packed using `tiktoken`'s `cl100k_base` tokenizer.
|
|
291
|
+
* Enforces limit of `max_tokens - 600` (reserves 600 tokens for instructions).
|
|
292
|
+
* Appends active approved memory lessons under `# APPROVED SYSTEM MEMORY`.
|
|
293
|
+
* Formats code blocks sequentially. Candidate elements exceeding the remaining budget are truncated.
|
|
294
|
+
|
|
295
|
+
#### Graph CTE Traversal
|
|
296
|
+
Recursively traverses dependencies using SQLite SQL CTEs:
|
|
297
|
+
```sql
|
|
298
|
+
WITH RECURSIVE neighborhood(id, d) AS (
|
|
299
|
+
SELECT ? as id, 0 as d
|
|
300
|
+
UNION
|
|
301
|
+
SELECT target_symbol, d + 1 FROM edges JOIN neighborhood ON source_symbol = id WHERE d < 2
|
|
302
|
+
UNION
|
|
303
|
+
SELECT source_symbol, d + 1 FROM edges JOIN neighborhood ON target_symbol = id WHERE d < 2
|
|
304
|
+
)
|
|
305
|
+
SELECT s.*, f.path as source_path, n.d as distance
|
|
306
|
+
FROM symbols s
|
|
307
|
+
JOIN files f ON s.file_id = f.file_id
|
|
308
|
+
JOIN neighborhood n ON s.symbol_id = n.id
|
|
309
|
+
ORDER BY n.d ASC
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Install
|
|
315
|
+
|
|
316
|
+
Install the python package:
|
|
317
|
+
```bash
|
|
318
|
+
pip install synap-git
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### System Requirements
|
|
322
|
+
* Python >= 3.11
|
|
323
|
+
* Git Command Line Tool
|
|
324
|
+
* SQLite (compiled with FTS5 virtual table support)
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Quick Start
|
|
329
|
+
|
|
330
|
+
### 1. Setup LLM Credentials
|
|
331
|
+
Run interactive configuration to configure your model:
|
|
332
|
+
```bash
|
|
333
|
+
synap setup .
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### 2. Run Ingestion
|
|
337
|
+
Initialize the local SQLite database index:
|
|
338
|
+
```bash
|
|
339
|
+
synap init .
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 3. Detach Watcher Daemon
|
|
343
|
+
Start background monitoring:
|
|
344
|
+
```bash
|
|
345
|
+
synap start .
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### 4. Connect IDE
|
|
349
|
+
Generate configuration settings:
|
|
350
|
+
```bash
|
|
351
|
+
synap mcp config .
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## CLI Reference
|
|
357
|
+
|
|
358
|
+
All commands support target path arguments:
|
|
359
|
+
|
|
360
|
+
* `synap setup [PATH]` — Runs provider configuration wizard.
|
|
361
|
+
* `synap init [PATH]` — Performs initial structural indexing. Supports `--skip-llm`, `--skip-wiki`.
|
|
362
|
+
* `synap wipe [PATH]` — Purges SQLite index.
|
|
363
|
+
* `synap start [PATH]` — Launches background daemon.
|
|
364
|
+
* `synap stop [PATH]` — Terminate background daemon.
|
|
365
|
+
* `synap restart [PATH]` — Restarts background daemon.
|
|
366
|
+
* `synap status [PATH]` — Prints active indexing parameters. Supports `--json`.
|
|
367
|
+
* `synap logs` — Views system logs. Supports `-t`, `-n`, `-d`.
|
|
368
|
+
* `synap update` — Upgrades Synap installation.
|
|
369
|
+
* `synap version` — Prints version.
|
|
370
|
+
* `synap rollback [PATH]` — Restores index state to previous commit. Supports `-c`, `-y`.
|
|
371
|
+
* `synap repair [PATH]` — Wipes index and rebuilds from HEAD. Supports `-y`.
|
|
372
|
+
* `synap doctor [PATH]` — Verifies database integrity and parsers.
|
|
373
|
+
* `synap run [PATH]` — Runs daemon in foreground.
|
|
374
|
+
* `synap ui [PATH]` — Launches HTML dashboard.
|
|
375
|
+
* `synap mcp start [PATH]` — Hosts MCP stdio server.
|
|
376
|
+
* `synap mcp config [PATH]` — Outputs Cursor connection blocks.
|
|
377
|
+
* `synap mcp verify [PATH]` — Asserts MCP server stability.
|
|
378
|
+
* `synap memory status [PATH]` — Lists lesson counts.
|
|
379
|
+
* `synap memory prune [PATH]` — Evaluates and deletes expired lessons.
|
|
380
|
+
* `synap memory verify [PATH]` — Checks lessons for missing files. Supports `--json`.
|
|
381
|
+
* `synap lessons approve <ID> [PATH]` — Approves a pending lesson.
|
|
382
|
+
* `synap lessons reject <ID> [PATH]` — Rejects a lesson.
|
|
383
|
+
* `synap lessons review [PATH]` — Launches interactive lesson review console.
|
|
384
|
+
* `synap checkpoint create [PATH]` — Logs progress snapshot. Supports `--doing`, `--files`, `--next-step`, `--blockers`.
|
|
385
|
+
* `synap checkpoint list [PATH]` — Renders checkpoint tables.
|
|
386
|
+
* `synap checkpoint restore <ID> [PATH]` — Displays checkpoint records.
|
|
387
|
+
* `synap usage show [PATH]` — Renders token metrics.
|
|
388
|
+
* `synap usage clear [PATH]` — Clears LLM call logs.
|
|
389
|
+
* `synap wiki list [PATH]` — Lists generated docs.
|
|
390
|
+
* `synap wiki show <FILE> [PATH]` — Renders wiki files.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Configuration
|
|
395
|
+
|
|
396
|
+
Configuration values are parsed from `~/.config/synap/config.toml`.
|
|
397
|
+
|
|
398
|
+
| Field Name | Type | Default | Description |
|
|
399
|
+
| :--- | :--- | :--- | :--- |
|
|
400
|
+
| `profile` | `string` | `"dev"` | Active environment configuration profile. |
|
|
401
|
+
| `mode` | `string` | `"active"` | Watcher polling mode selector. |
|
|
402
|
+
| `repository_path` | `string` | `"."` | Repository root directory. |
|
|
403
|
+
| `state_path` | `string` | `".synap"` | Root storage path. |
|
|
404
|
+
| `sqlite_path` | `string` | `".synap/synap.db"` | Database file location. |
|
|
405
|
+
| `object_path` | `string` | `".synap/objects"` | Directory for serialized artifacts. |
|
|
406
|
+
| `log_path` | `string` | `".synap/logs"` | Directory for logs. |
|
|
407
|
+
| `logging_mode` | `string` | `"human"` | Log output format type. |
|
|
408
|
+
| `log_level` | `string` | `"INFO"` | Minimum logging level threshold. |
|
|
409
|
+
| `max_file_bytes` | `integer` | `1000000` | Size threshold for parsed files. |
|
|
410
|
+
| `checkpoint_threshold` | `float` | `0.60` | Threshold ratio for memory warnings. |
|
|
411
|
+
| `lesson_expiry_days` | `integer` | `7` | Days before memory lessons expire. |
|
|
412
|
+
| `llm_provider` | `string` | `null` | Generative provider: `openai`, `gemini`, `anthropic`, `ollama`, `openrouter`. |
|
|
413
|
+
| `llm_model` | `string` | `null` | Named model used for prompts. |
|
|
414
|
+
| `ollama_url` | `string` | `"http://127.0.0.1:11434"` | Endpoint URL for Ollama connectivity. |
|
|
415
|
+
| `mcp_host` | `string` | `"127.0.0.1"` | Bind host for local networking. |
|
|
416
|
+
| `mcp_port` | `integer` | `9876` | Server listener port. |
|
|
417
|
+
| `daemon_poll_interval_seconds` | `float` | `2.0` | Git state polling frequency. |
|
|
418
|
+
| `shutdown_timeout_seconds` | `float` | `5.0` | Timeout threshold for shutting down. |
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## MCP Integration
|
|
423
|
+
|
|
424
|
+
Verify configurations using:
|
|
425
|
+
```bash
|
|
426
|
+
synap mcp config .
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Server Configuration Block
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"mcpServers": {
|
|
433
|
+
"synap": {
|
|
434
|
+
"command": "/usr/local/bin/python",
|
|
435
|
+
"args": ["-m", "synap_git.cli", "mcp", "start", "/Users/username/repo"],
|
|
436
|
+
"autoConnect": true
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Supported Languages
|
|
445
|
+
|
|
446
|
+
Synap processes syntax for the following formats:
|
|
447
|
+
* **Python** (`.py`)
|
|
448
|
+
* **JavaScript / JSX** (`.js`, `.jsx`)
|
|
449
|
+
* **TypeScript / TSX** (`.ts`, `.tsx`)
|
|
450
|
+
* **Go** (`.go`)
|
|
451
|
+
* **Rust** (`.rs`)
|
|
452
|
+
* **Java** (`.java`)
|
|
453
|
+
* **C / C++** (`.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`)
|
|
454
|
+
* **Ruby** (`.rb`)
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Supported Providers
|
|
459
|
+
|
|
460
|
+
* **Ollama** — Local model integration.
|
|
461
|
+
* **OpenAI** — Cloud GPT models. (Environment Variable: `SYNAP_OPENAI_API_KEY`)
|
|
462
|
+
* **Anthropic** — Cloud Claude models. (Environment Variable: `SYNAP_ANTHROPIC_API_KEY`)
|
|
463
|
+
* **Gemini** — Cloud Gemini models. (Environment Variable: `SYNAP_GEMINI_API_KEY`)
|
|
464
|
+
* **OpenRouter** — Unified cloud model routing. (Environment Variable: `SYNAP_OPENROUTER_API_KEY`)
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Limitations
|
|
469
|
+
|
|
470
|
+
* **Git workspace dependency:** Indexes and tracks metadata solely inside valid Git repositories.
|
|
471
|
+
* **Structural-only mode:** Runs without wiki generation or contextual LLM generation if `llm_provider` is unset.
|
|
472
|
+
* **Size exclusions:** Skips binary files and files larger than `max_file_bytes` (default 1MB).
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Contributing
|
|
477
|
+
|
|
478
|
+
Execute unit tests:
|
|
479
|
+
```bash
|
|
480
|
+
SYNAP_SKIP_STRESS=1 uv run pytest tests/ -x --tb=short
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Format code and check types:
|
|
484
|
+
```bash
|
|
485
|
+
uv run ruff format src/
|
|
486
|
+
uv run ruff check src/
|
|
487
|
+
uv run mypy src/
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
|
|
494
|
+
This codebase is licensed under the Apache-2.0 License. See [LICENSE.md](LICENSE.md) for details.
|