synap-git 0.2.0__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-0.2.0/.gitignore +24 -0
- synap_git-0.2.0/.synap.example/README.md +19 -0
- synap_git-0.2.0/CHANGELOG.md +80 -0
- synap_git-0.2.0/LICENSE.md +201 -0
- synap_git-0.2.0/PKG-INFO +251 -0
- synap_git-0.2.0/README.md +204 -0
- synap_git-0.2.0/pyproject.toml +114 -0
- synap_git-0.2.0/src/synap_git/__init__.py +5 -0
- synap_git-0.2.0/src/synap_git/api/__init__.py +5 -0
- synap_git-0.2.0/src/synap_git/api/app.py +111 -0
- synap_git-0.2.0/src/synap_git/api/static/index.html +615 -0
- synap_git-0.2.0/src/synap_git/cli/__init__.py +3 -0
- synap_git-0.2.0/src/synap_git/cli/__main__.py +4 -0
- synap_git-0.2.0/src/synap_git/cli/main.py +1174 -0
- synap_git-0.2.0/src/synap_git/config.py +169 -0
- synap_git-0.2.0/src/synap_git/diagnostics/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/diagnostics/logger.py +82 -0
- synap_git-0.2.0/src/synap_git/diagnostics/tracing.py +71 -0
- synap_git-0.2.0/src/synap_git/embeddings/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/git/__init__.py +11 -0
- synap_git-0.2.0/src/synap_git/git/state.py +139 -0
- synap_git-0.2.0/src/synap_git/indexer/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/indexer/daemon.py +143 -0
- synap_git-0.2.0/src/synap_git/indexer/engine.py +327 -0
- synap_git-0.2.0/src/synap_git/indexer/scanner.py +463 -0
- synap_git-0.2.0/src/synap_git/indexer/wiki.py +78 -0
- synap_git-0.2.0/src/synap_git/mcp/__init__.py +5 -0
- synap_git-0.2.0/src/synap_git/mcp/server.py +232 -0
- synap_git-0.2.0/src/synap_git/parser/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/parser/registry.py +209 -0
- synap_git-0.2.0/src/synap_git/provider/anthropic.py +86 -0
- synap_git-0.2.0/src/synap_git/provider/base.py +44 -0
- synap_git-0.2.0/src/synap_git/provider/factory.py +101 -0
- synap_git-0.2.0/src/synap_git/provider/gemini.py +98 -0
- synap_git-0.2.0/src/synap_git/provider/mock.py +66 -0
- synap_git-0.2.0/src/synap_git/provider/ollama.py +98 -0
- synap_git-0.2.0/src/synap_git/provider/openai.py +90 -0
- synap_git-0.2.0/src/synap_git/py.typed +1 -0
- synap_git-0.2.0/src/synap_git/retrieval/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/retrieval/engine.py +258 -0
- synap_git-0.2.0/src/synap_git/retrieval/memory.py +123 -0
- synap_git-0.2.0/src/synap_git/storage/__init__.py +3 -0
- synap_git-0.2.0/src/synap_git/storage/sqlite.py +575 -0
- synap_git-0.2.0/src/synap_git/utils/__init__.py +0 -0
- synap_git-0.2.0/src/synap_git/utils/serialization.py +68 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
Thumbs.db
|
|
3
|
+
.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
.mypy_cache/
|
|
8
|
+
.ruff_cache/
|
|
9
|
+
.coverage
|
|
10
|
+
htmlcov/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
.synap/
|
|
15
|
+
!.synap.example/
|
|
16
|
+
*.db
|
|
17
|
+
*.sqlite
|
|
18
|
+
*.sqlite3
|
|
19
|
+
*.db-journal
|
|
20
|
+
*.db-wal
|
|
21
|
+
*.db-shm
|
|
22
|
+
.env
|
|
23
|
+
.env.*
|
|
24
|
+
.env.local
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Example `.synap` Layout
|
|
2
|
+
|
|
3
|
+
Synap stores local repository intelligence and agent memory in `.synap/`. This directory is strictly ignored by Git.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
.synap/
|
|
7
|
+
synap.db # L1 (Code Graph) + L3 (Agent Memory) SQLite database
|
|
8
|
+
daemon_heartbeat.json # Active status and PID of the Synap daemon
|
|
9
|
+
objects/ # Immutable file snapshots (content-addressed)
|
|
10
|
+
logs/ # Runtime logs
|
|
11
|
+
wiki/ # L2 (Knowledge Wiki) generated Markdown
|
|
12
|
+
overview.md # Project-level summary
|
|
13
|
+
architecture.md # System design and data flow
|
|
14
|
+
modules/ # Module-level documentation
|
|
15
|
+
[module].md
|
|
16
|
+
agent/ # Rendered agent history
|
|
17
|
+
decisions.md
|
|
18
|
+
lessons.md
|
|
19
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-05-26
|
|
9
|
+
|
|
10
|
+
### Added — Final Polish & Release Readiness
|
|
11
|
+
- CLI cost management: `synap cost show` (displays Rich aggregated pricing table and summary panel) and `synap cost clear`.
|
|
12
|
+
- CLI wiki management: `synap wiki list` and `synap wiki show <filepath>` (renders page in terminal via Rich Markdown).
|
|
13
|
+
- LLM call database logging: records `prompt_tokens`, `completion_tokens`, and calculates `cost_usd` dynamically for retrieval and wiki generation passes.
|
|
14
|
+
- Real-time daemon state: heartbeats integrated into `synap status`, `synap doctor`, and the Web UI status endpoints.
|
|
15
|
+
- Premium Web UI dashboard polish: dual L3 memory (Approved vs Pending) view, real-time LLM cost analytics, and active daemon PID badge.
|
|
16
|
+
- Defensive GHA release pipeline: `.github/workflows/release.yml` automates TestPyPI and PyPI publishing, tag alignment checking, and draft release generation.
|
|
17
|
+
- Clean Typer execution wrapper: intercepts configuration and credential exceptions to output actionable suggestions (e.g. `synap setup`) instead of tracebacks.
|
|
18
|
+
|
|
19
|
+
### Added — Hardening Loop 2: MCP Stability & Protocol Polish
|
|
20
|
+
- Deterministic MCP JSON envelope: every tool response carries `ok`, `data`, `warnings`, `trace_id`, `dirty_tree`.
|
|
21
|
+
- Structured error objects with `code`, `message`, and `suggestion` fields for all failure paths.
|
|
22
|
+
- `dirty_tree` propagation: agents are warned when the working tree is ahead of the index.
|
|
23
|
+
- `get_approved_memory()` and `get_pending_memory()` MCP tools exposing lesson trust status.
|
|
24
|
+
- `synap mcp verify` command to assert full protocol contract compliance.
|
|
25
|
+
|
|
26
|
+
### Added — Hardening Loop 3: Lesson System Trust & Memory Lifecycle
|
|
27
|
+
- Formal `LessonStatus` enum enforcing explicit state machine: `PENDING → APPROVED/REJECTED`, `APPROVED → EXPIRED`.
|
|
28
|
+
- Retrieval gating: only `APPROVED`, non-expired lessons are injected into LLM context as `# APPROVED SYSTEM MEMORY`.
|
|
29
|
+
- `prune_expired_lessons()` transitions stale lessons to `EXPIRED` state on demand.
|
|
30
|
+
- `approval_actor` field on lessons for full human-governance provenance.
|
|
31
|
+
- `synap memory status` — counts of pending, approved, expired lessons.
|
|
32
|
+
- `synap memory prune` — forces expiry evaluation and prunes dead memory.
|
|
33
|
+
- `synap memory verify` — checks approved lessons' `files_affected` against current repo state; reports dangling references.
|
|
34
|
+
- `synap lessons approve <id>` and `synap lessons reject <id>` — explicit human governance over pending lessons.
|
|
35
|
+
|
|
36
|
+
### Added — Hardening Loop 4: Tracing, Git Compliance & Release Hardening
|
|
37
|
+
- `GitIgnoreSpec` glob-to-regex parser in `RepositoryScanner` respects `.gitignore` patterns.
|
|
38
|
+
- Auto-protection: `SynapRuntime.bootstrap()` automatically adds `.synap/` to `.gitignore`.
|
|
39
|
+
- Enhanced binary file detection via extension blocklist + control-character ratio analysis.
|
|
40
|
+
- Symlink traversal prevention in `RepositoryScanner` (path-containment enforcement).
|
|
41
|
+
- `TraceStore` writes structured operational traces to `.synap/trace_latest.json`.
|
|
42
|
+
- Full hybrid retrieval tracing: latency timeline, token allocation, truncation explanations, structural hops, dirty-tree warnings.
|
|
43
|
+
- `/api/v1/trace/latest` REST endpoint exposing the latest trace.
|
|
44
|
+
- Diagnostic Web UI with visual latency timeline, source provenance table, and dirty-tree badge.
|
|
45
|
+
- Daemon heartbeat file (`.synap/daemon_heartbeat.json`) with PID, uptime, and recovery metrics.
|
|
46
|
+
- Daemon self-healing: SQLite corruption detected via `PRAGMA quick_check` triggers a wipe + re-bootstrap.
|
|
47
|
+
- `synap rollback` — interactive rollback to a previous git commit with lesson preservation.
|
|
48
|
+
- `synap recover` — explicit manual DB corruption recovery flow.
|
|
49
|
+
- `py.typed` marker for PEP 561 compliance.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- CI pipeline split into 4 focused jobs: `lint`, `test`, `benchmark` (main only), `release-validation`.
|
|
53
|
+
- Release validation now runs `synap init` before `synap doctor` to ensure a valid Synap DB context.
|
|
54
|
+
- `pytest` configured with `asyncio_default_fixture_loop_scope = "function"` to eliminate deprecation warnings.
|
|
55
|
+
- Benchmark tests gated behind `benchmark` marker; skipped in fast PR CI passes.
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
- `synap doctor` in CI release validation step previously ran against an uninitialized directory.
|
|
59
|
+
- `ruff format` drift in `cli/main.py` and `indexer/daemon.py` resolved.
|
|
60
|
+
|
|
61
|
+
## [0.1.0] - 2026-05-25
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- Core deterministic indexing engine using Tree-sitter and Git content hashes.
|
|
65
|
+
- 4-stage hybrid retrieval pipeline (Temporal, Structural, Lexical, Semantic).
|
|
66
|
+
- Model Context Protocol (MCP) server for IDE integration.
|
|
67
|
+
- "Why-This-Context" retrieval tracing system.
|
|
68
|
+
- Secure secret management via `python-keyring`.
|
|
69
|
+
- `synap doctor` for system validation.
|
|
70
|
+
- Diagnostic UI dashboard.
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
- Refactored entire architecture from event-sourcing to deterministic Git projections.
|
|
74
|
+
- Consolidated storage into unified SQLite schema with Recursive CTE support.
|
|
75
|
+
- Upgraded documentation to production infrastructure standards.
|
|
76
|
+
|
|
77
|
+
### Removed
|
|
78
|
+
- Legacy "cognitive OS" and "graph operating system" abstractions.
|
|
79
|
+
- Speculative async priority queues and replay engines.
|
|
80
|
+
- Brittle regex-based parsers.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
synap_git-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: synap-git
|
|
3
|
+
Version: 0.2.0
|
|
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: keyring==25.6.0
|
|
26
|
+
Requires-Dist: markdown-it-py==3.0.0
|
|
27
|
+
Requires-Dist: mcp==1.3.0
|
|
28
|
+
Requires-Dist: msgpack==1.1.0
|
|
29
|
+
Requires-Dist: pydantic-settings==2.8.1
|
|
30
|
+
Requires-Dist: pydantic==2.10.6
|
|
31
|
+
Requires-Dist: structlog==25.1.0
|
|
32
|
+
Requires-Dist: tiktoken==0.9.0
|
|
33
|
+
Requires-Dist: tree-sitter-languages==1.10.2
|
|
34
|
+
Requires-Dist: tree-sitter==0.20.4
|
|
35
|
+
Requires-Dist: typer==0.15.1
|
|
36
|
+
Requires-Dist: uvicorn==0.34.0
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: bandit==1.8.3; extra == 'dev'
|
|
39
|
+
Requires-Dist: httpx==0.28.1; extra == 'dev'
|
|
40
|
+
Requires-Dist: mypy==1.15.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: pre-commit==4.1.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest-asyncio==0.25.3; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest-cov==6.0.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest==8.3.4; extra == 'dev'
|
|
45
|
+
Requires-Dist: ruff==0.9.9; extra == 'dev'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# Synap 🧠
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<b>The Deterministic Context Injector for AI Coding Agents.</b>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<p align="center">
|
|
55
|
+
<a href="https://github.com/saahilpal/synap-git/actions"><img src="https://img.shields.io/github/actions/workflow/status/saahilpal/synap-git/ci.yml?style=flat-square&color=3b82f6" alt="CI Status"></a>
|
|
56
|
+
<a href="LICENSE.md"><img src="https://img.shields.io/github/license/saahilpal/synap-git?style=flat-square&color=cbd5e1" alt="License"></a>
|
|
57
|
+
<a href="SYNAP_BUILD_SPEC.md"><img src="https://img.shields.io/badge/spec-v1.0-green?style=flat-square" alt="Spec Compliant"></a>
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
Synap is **NOT a RAG system.** It is a strict, deterministic background daemon that mirrors your Git state and proactively pushes exact contextual boundaries to AI coding agents via the Model Context Protocol (MCP). Agents do not query Synap—Synap *injects* reality into Agents.
|
|
63
|
+
|
|
64
|
+
## 🏛️ Philosophy & Vision
|
|
65
|
+
|
|
66
|
+
1. **DETERMINISTIC FIRST:** If the agent sees it, it exists exactly as shown in the local filesystem.
|
|
67
|
+
2. **PUSH, NOT PULL:** Agents are terrible at querying for what they don't know exists. Synap bounds their context upfront.
|
|
68
|
+
3. **NOTHING HAPPENS SILENTLY:** Every action, decision, and LLM call is tracked, costed, and logged.
|
|
69
|
+
4. **LOCAL ONLY:** Your code never leaves your machine unless you explicitly configure a remote LLM. All state is kept in `.synap/synap.db`.
|
|
70
|
+
5. **MIRROR GIT EXACTLY:** Synap's state machine is perfectly synced to `HEAD`. If you switch branches, your agent's memory switches branches instantly.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🏗️ High-Level Architecture (HLD)
|
|
75
|
+
|
|
76
|
+
Synap bridges the gap between your local file system, Git history, and the LLM via a 3-layer indexing strategy.
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
graph TD
|
|
80
|
+
subgraph Local Repository
|
|
81
|
+
FS[File System]
|
|
82
|
+
Git[Git History]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
subgraph Synap Daemon
|
|
86
|
+
I[Indexer Engine]
|
|
87
|
+
DB[(SQLite synap.db)]
|
|
88
|
+
W[Wiki Engine .synap/wiki/]
|
|
89
|
+
M[Context Injector memory.py]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
subgraph IDE / AI
|
|
93
|
+
MCP[MCP Server]
|
|
94
|
+
Agent[AI Coding Agent]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
FS -->|Change Events| I
|
|
98
|
+
Git -->|Branch/Revert Events| I
|
|
99
|
+
I -->|L1 Structural| DB
|
|
100
|
+
I -->|L2 Semantic| W
|
|
101
|
+
I -->|L3 Behavioral| DB
|
|
102
|
+
|
|
103
|
+
DB --> M
|
|
104
|
+
W --> M
|
|
105
|
+
M -->|Injection Payload| MCP
|
|
106
|
+
MCP <-->|Read/Write Tools| Agent
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 🧩 The 3 Layers of Context
|
|
112
|
+
|
|
113
|
+
Synap provides three distinct layers of context to completely ground the agent:
|
|
114
|
+
|
|
115
|
+
### 1. L1: Structural (The Truth)
|
|
116
|
+
Deterministic mapping of code architecture using **Tree-sitter**.
|
|
117
|
+
- Fast, 100% accurate symbol extraction.
|
|
118
|
+
- Graph edges mapping `Imports`, `Inherits`, `Calls`, and `References`.
|
|
119
|
+
- Primary Key: `sha256(path + content_hash)` to completely eliminate edge-case collisions.
|
|
120
|
+
|
|
121
|
+
### 2. L2: Semantic (The "Why")
|
|
122
|
+
Hierarchical generated documentation stored locally as Markdown files (`.synap/wiki/`).
|
|
123
|
+
- **File Level:** What does this file do?
|
|
124
|
+
- **Module Level:** How do these files relate?
|
|
125
|
+
- **Project Level:** `overview.md` and `architecture.md`.
|
|
126
|
+
|
|
127
|
+
### 3. L3: Behavioral (Agent Memory)
|
|
128
|
+
Synap tracks the *history* of agent actions so the AI doesn't repeat past mistakes.
|
|
129
|
+
- **Checkpoints:** The active task the agent is performing (`synap checkpoint`).
|
|
130
|
+
- **Decisions:** Architecture decisions logged by the agent.
|
|
131
|
+
- **Lessons:** Generated automatically when a developer runs `git revert` on an agent's commit!
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🔄 Low-Level Data Flows (LLD)
|
|
136
|
+
|
|
137
|
+
### Git Mirroring Flow
|
|
138
|
+
Synap's daemon watches the Git repository. The state of the repository completely drives the context.
|
|
139
|
+
|
|
140
|
+
```mermaid
|
|
141
|
+
sequenceDiagram
|
|
142
|
+
participant Dev as Developer
|
|
143
|
+
participant Git as Git Repo
|
|
144
|
+
participant Daemon as Synap Daemon
|
|
145
|
+
participant DB as SQLite DB
|
|
146
|
+
|
|
147
|
+
Dev->>Git: git checkout feature-branch
|
|
148
|
+
Git-->>Daemon: Branch Switch Event
|
|
149
|
+
Daemon->>DB: Swap active context immediately
|
|
150
|
+
|
|
151
|
+
Dev->>Git: git revert <agent-commit>
|
|
152
|
+
Git-->>Daemon: Revert Detected (20-ancestor check)
|
|
153
|
+
Daemon->>DB: Log Pending Lesson (What failed?)
|
|
154
|
+
Daemon->>Dev: Prompt interactive review of failure
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Context Injection Flow
|
|
158
|
+
When an Agent starts a task, it receives a strict, pre-packaged header injection.
|
|
159
|
+
|
|
160
|
+
```mermaid
|
|
161
|
+
sequenceDiagram
|
|
162
|
+
participant Agent
|
|
163
|
+
participant MCP as MCP Server
|
|
164
|
+
participant Memory as Context Injector
|
|
165
|
+
participant DB as SQLite DB
|
|
166
|
+
|
|
167
|
+
Agent->>MCP: Trigger Tool / Start Task
|
|
168
|
+
MCP->>Memory: build_injection_context()
|
|
169
|
+
Memory->>DB: Fetch Active Branch & Checkpoint
|
|
170
|
+
Memory->>DB: Fetch Approved Lessons
|
|
171
|
+
Memory->>DB: Check for Dirty Git Tree (Uncommitted changes)
|
|
172
|
+
Memory-->>MCP: Formatted Context Header
|
|
173
|
+
MCP-->>Agent: Proactive Context Grounding
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 🚀 Quick Start
|
|
179
|
+
|
|
180
|
+
### 1. Installation
|
|
181
|
+
Install the Synap CLI via `pip` or `uv`:
|
|
182
|
+
```bash
|
|
183
|
+
pip install synapse
|
|
184
|
+
# or using uv:
|
|
185
|
+
uv tool install synapse
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 2. Setup & Initialize
|
|
189
|
+
Interactive onboarding to set up your LLM providers (keys stored securely in your OS keyring).
|
|
190
|
+
```bash
|
|
191
|
+
synap setup .
|
|
192
|
+
```
|
|
193
|
+
Initialize the repo (Use `--skip-llm` to run in pure structural Mode A):
|
|
194
|
+
```bash
|
|
195
|
+
synap init .
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 3. Start the Daemon
|
|
199
|
+
Run the background watcher to keep Synap perfectly synced with Git:
|
|
200
|
+
```bash
|
|
201
|
+
synap start .
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 4. Connect to IDE
|
|
205
|
+
Start the MCP server to expose Synap to your AI Agent (Cursor, Windsurf, etc.):
|
|
206
|
+
```bash
|
|
207
|
+
synap mcp start .
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 💻 CLI Command Reference
|
|
213
|
+
|
|
214
|
+
Synap uses a powerful, strict CLI interface. Every destructive action prompts for approval.
|
|
215
|
+
|
|
216
|
+
### Core Lifecycle
|
|
217
|
+
- `synap init .` : Perform Pass 1 and Pass 2 indexing.
|
|
218
|
+
- `synap start .` : Launch the background polling daemon.
|
|
219
|
+
- `synap status .` : View active branch, indexed symbols, daemon state, and memory metrics.
|
|
220
|
+
- `synap rollback .` : Rollback active state to a previous commit.
|
|
221
|
+
- `synap recover .` : Recover from a corrupted database state.
|
|
222
|
+
- `synap run .` : Run all Synap services (Daemon, MCP, UI) concurrently.
|
|
223
|
+
|
|
224
|
+
### L3 Memory Management
|
|
225
|
+
- `synap memory status .` : View counts of approved, pending, and expired lessons.
|
|
226
|
+
- `synap memory prune .` : Prune expired rules and cleanup memory.
|
|
227
|
+
- `synap memory verify .` : Detect dangling file references in active memory.
|
|
228
|
+
- `synap lessons approve <id> .` : Approve a pending revert lesson to activate it.
|
|
229
|
+
- `synap lessons reject <id> .` : Reject and discard a pending lesson.
|
|
230
|
+
- `synap checkpoint create . --doing "..."` : Save the current context state.
|
|
231
|
+
- `synap checkpoint list .` : List all checkpoints for the active branch in a table.
|
|
232
|
+
- `synap checkpoint restore <id> .` : Show details of a checkpoint (or "latest").
|
|
233
|
+
|
|
234
|
+
### Developer Tools
|
|
235
|
+
- `synap wiki list .` : List all generated wiki documentation files.
|
|
236
|
+
- `synap wiki show <filepath> .` : Render a specific wiki markdown page to the console.
|
|
237
|
+
- `synap cost show .` : Display detailed aggregated LLM token usage and estimated costs.
|
|
238
|
+
- `synap cost clear .` : Purge all LLM call cost history.
|
|
239
|
+
- `synap doctor .` : Validate SQLite integrity, Tree-sitter, tokenizers, LLM providers, and daemon heartbeat.
|
|
240
|
+
- `synap mcp verify .` : Verify MCP protocol, tool schemas, and contract stability.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 🤝 Contributing
|
|
245
|
+
|
|
246
|
+
Synap is built on the philosophy that AI tools must be transparent and controllable. If you're contributing:
|
|
247
|
+
- Do not introduce implicit RAG features.
|
|
248
|
+
- Adhere to the `SYNAP_BUILD_SPEC.md` strictly.
|
|
249
|
+
- Ensure all states are stored exclusively in `synap.db` or `.synap/wiki/`.
|
|
250
|
+
|
|
251
|
+
License: [Apache 2.0](LICENSE.md)
|