synapse-pkg 2.0.0a2__tar.gz → 2.0.0a4__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.
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/PKG-INFO +1 -1
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/pyproject.toml +1 -1
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/cli.py +1 -1
- synapse_pkg-2.0.0a4/synapse/commands.py +38 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/extractor.py +50 -26
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/git_manager.py +72 -7
- synapse_pkg-2.0.0a4/synapse/provider.py +8 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/PKG-INFO +1 -1
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/SOURCES.txt +1 -0
- synapse_pkg-2.0.0a2/synapse/commands.py +0 -22
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/LICENSE +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/README.md +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/setup.cfg +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/__init__.py +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/persistence.py +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse/processor.py +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/dependency_links.txt +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/entry_points.txt +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/requires.txt +0 -0
- {synapse_pkg-2.0.0a2 → synapse_pkg-2.0.0a4}/synapse_pkg.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from .persistence import initialize_synapse, save_config
|
|
2
|
+
from .processor import build_repository_context
|
|
3
|
+
from .extractor import build_compressed_context
|
|
4
|
+
from .provider import get_ollama_model
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def Setup():
|
|
8
|
+
models = get_ollama_model()
|
|
9
|
+
|
|
10
|
+
for i,model in enumerate(models,start=1):
|
|
11
|
+
print(f"{i}, {model}")
|
|
12
|
+
choice = int(input("select a model"))
|
|
13
|
+
selected_model = models[choice-1]
|
|
14
|
+
save_config(
|
|
15
|
+
{
|
|
16
|
+
"provider":"ollama",
|
|
17
|
+
"model": selected_model
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def init():
|
|
23
|
+
initialize_synapse()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def knowledge():
|
|
27
|
+
print("Initializing repository context...")
|
|
28
|
+
|
|
29
|
+
build_repository_context()
|
|
30
|
+
|
|
31
|
+
print(
|
|
32
|
+
"Repository context initialized.\n"
|
|
33
|
+
"Building compressed repository context..."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
build_compressed_context()
|
|
37
|
+
|
|
38
|
+
print("Successfully initialized compressed repository context.")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import git
|
|
2
|
-
from .persistence import load_compressed_context, save_compressed_context, load_metadata, save_metadata
|
|
2
|
+
from .persistence import load_compressed_context, save_compressed_context, load_metadata, save_metadata, load_config
|
|
3
3
|
from .git_manager import (
|
|
4
4
|
get_repository_changes,
|
|
5
5
|
split_commit_by_file
|
|
@@ -9,6 +9,8 @@ import json
|
|
|
9
9
|
|
|
10
10
|
repo = git.Repo(search_parent_directories=True)
|
|
11
11
|
|
|
12
|
+
config = load_config()
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
MAX_PROMPT_SIZE = 30000
|
|
14
16
|
MAX_FILES_PER_COMMIT = 3
|
|
@@ -24,9 +26,31 @@ VALID_KEYS = {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
|
|
29
|
+
SYSTEM_PROMPT = """
|
|
30
|
+
You are Synapse Repository Memory Builder.
|
|
31
|
+
|
|
32
|
+
Your sole responsibility is to construct and maintain a canonical Repository Memory.
|
|
33
|
+
|
|
34
|
+
Always obey the task described by the user.
|
|
35
|
+
|
|
36
|
+
Rules:
|
|
37
|
+
|
|
38
|
+
- Return ONLY valid JSON.
|
|
39
|
+
- Never return markdown.
|
|
40
|
+
- Never explain your reasoning.
|
|
41
|
+
- Never summarize code for a human.
|
|
42
|
+
- Never answer conversationally.
|
|
43
|
+
- Never invent repository knowledge.
|
|
44
|
+
- Only use information present in the input.
|
|
45
|
+
- Follow the requested JSON schema exactly.
|
|
46
|
+
- Maintain a stable repository ontology.
|
|
47
|
+
- Merge equivalent concepts instead of duplicating them.
|
|
48
|
+
- Prefer abstraction over implementation details.
|
|
49
|
+
- If uncertain, omit the information instead of hallucinating.
|
|
50
|
+
"""
|
|
51
|
+
|
|
27
52
|
|
|
28
53
|
INITIAL_PROMPT_TEMPLATE = """
|
|
29
|
-
You are Synapse Repository Memory Builder.
|
|
30
54
|
|
|
31
55
|
TASK
|
|
32
56
|
|
|
@@ -188,20 +212,6 @@ OUTPUT FORMAT
|
|
|
188
212
|
"current_capabilities": []
|
|
189
213
|
}}
|
|
190
214
|
|
|
191
|
-
IMPORTANT
|
|
192
|
-
|
|
193
|
-
The output becomes compressed_context.json.
|
|
194
|
-
|
|
195
|
-
Return only valid JSON.
|
|
196
|
-
|
|
197
|
-
Return only the JSON object shown above.
|
|
198
|
-
|
|
199
|
-
No markdown.
|
|
200
|
-
|
|
201
|
-
No explanations.
|
|
202
|
-
|
|
203
|
-
No text outside JSON.
|
|
204
|
-
|
|
205
215
|
per_commit_diff:
|
|
206
216
|
|
|
207
217
|
{initial_commit_diff}
|
|
@@ -210,7 +220,6 @@ per_commit_diff:
|
|
|
210
220
|
|
|
211
221
|
|
|
212
222
|
UPDATE_PROMPT_TEMPLATE = """
|
|
213
|
-
You are Synapse Repository Memory Maintainer.
|
|
214
223
|
|
|
215
224
|
TASK
|
|
216
225
|
|
|
@@ -525,13 +534,6 @@ OUTPUT FORMAT
|
|
|
525
534
|
"current_capabilities": []
|
|
526
535
|
}}
|
|
527
536
|
|
|
528
|
-
Return ONLY valid JSON.
|
|
529
|
-
|
|
530
|
-
Return ONLY the JSON object.
|
|
531
|
-
|
|
532
|
-
No markdown.
|
|
533
|
-
|
|
534
|
-
No explanations.
|
|
535
537
|
|
|
536
538
|
current_compressed_context:
|
|
537
539
|
|
|
@@ -568,6 +570,16 @@ def generate_update_prompt(current_compressed_context, per_commit_diff):
|
|
|
568
570
|
def clean_json_response(raw: str) -> dict:
|
|
569
571
|
text = raw.strip()
|
|
570
572
|
|
|
573
|
+
|
|
574
|
+
if not text.startswith("{") and not text.startswith("```"):
|
|
575
|
+
print("=" * 80)
|
|
576
|
+
print("[context_builder] Model ignored JSON output format.")
|
|
577
|
+
print("RAW TEXT:")
|
|
578
|
+
print(text)
|
|
579
|
+
print("=" * 80)
|
|
580
|
+
return None
|
|
581
|
+
|
|
582
|
+
|
|
571
583
|
if text.startswith("```"):
|
|
572
584
|
lines = text.splitlines()
|
|
573
585
|
inner_lines = []
|
|
@@ -615,10 +627,21 @@ def clean_json_response(raw: str) -> dict:
|
|
|
615
627
|
|
|
616
628
|
def get_response(prompt, num_predict=4096):
|
|
617
629
|
|
|
630
|
+
if config["model"]:
|
|
631
|
+
model = config["model"]
|
|
632
|
+
else:
|
|
633
|
+
print("no model configured.")
|
|
634
|
+
print("Run 'synapse setup' first.")
|
|
635
|
+
return
|
|
636
|
+
|
|
618
637
|
try:
|
|
619
638
|
response = chat(
|
|
620
|
-
model=
|
|
639
|
+
model=model,
|
|
621
640
|
messages=[
|
|
641
|
+
{
|
|
642
|
+
"role": "system",
|
|
643
|
+
"content": SYSTEM_PROMPT
|
|
644
|
+
},
|
|
622
645
|
{
|
|
623
646
|
"role": "user",
|
|
624
647
|
"content": prompt
|
|
@@ -630,9 +653,10 @@ def get_response(prompt, num_predict=4096):
|
|
|
630
653
|
"temperature": 0
|
|
631
654
|
}
|
|
632
655
|
)
|
|
633
|
-
except Exception
|
|
656
|
+
except Exception:
|
|
634
657
|
print("Failed to connect to Ollama.")
|
|
635
658
|
print("Make sure Ollama is running and the required model is installed.")
|
|
659
|
+
return None
|
|
636
660
|
|
|
637
661
|
raw = response["message"]["content"]
|
|
638
662
|
|
|
@@ -280,28 +280,93 @@ def preprocess_readme_diff(file_diff: str) -> str:
|
|
|
280
280
|
"""
|
|
281
281
|
Remove documentation sections that are not durable repository knowledge.
|
|
282
282
|
"""
|
|
283
|
-
|
|
284
283
|
ignored_sections = [
|
|
285
284
|
"# Installation",
|
|
286
285
|
"## Installation",
|
|
286
|
+
|
|
287
287
|
"# Quick Start",
|
|
288
288
|
"## Quick Start",
|
|
289
|
+
|
|
290
|
+
"# Getting Started",
|
|
291
|
+
"## Getting Started",
|
|
292
|
+
|
|
293
|
+
"# Setup",
|
|
294
|
+
"## Setup",
|
|
295
|
+
|
|
296
|
+
"# Requirements",
|
|
297
|
+
"## Requirements",
|
|
298
|
+
|
|
299
|
+
"# Prerequisites",
|
|
300
|
+
"## Prerequisites",
|
|
301
|
+
|
|
289
302
|
"# Usage",
|
|
290
303
|
"## Usage",
|
|
304
|
+
|
|
291
305
|
"# Example",
|
|
292
306
|
"## Example",
|
|
307
|
+
|
|
293
308
|
"# Examples",
|
|
294
309
|
"## Examples",
|
|
310
|
+
|
|
311
|
+
"# Demo",
|
|
312
|
+
"## Demo",
|
|
313
|
+
|
|
314
|
+
"# Screenshots",
|
|
315
|
+
"## Screenshots",
|
|
316
|
+
|
|
317
|
+
"# Benchmark",
|
|
318
|
+
"## Benchmark",
|
|
319
|
+
|
|
320
|
+
"# Benchmarks",
|
|
321
|
+
"## Benchmarks",
|
|
322
|
+
|
|
323
|
+
"# Performance",
|
|
324
|
+
"## Performance",
|
|
325
|
+
|
|
326
|
+
"# Testing",
|
|
327
|
+
"## Testing",
|
|
328
|
+
|
|
329
|
+
"# Troubleshooting",
|
|
330
|
+
"## Troubleshooting",
|
|
331
|
+
|
|
332
|
+
"# FAQ",
|
|
333
|
+
"## FAQ",
|
|
334
|
+
|
|
335
|
+
"# Changelog",
|
|
336
|
+
"## Changelog",
|
|
337
|
+
|
|
338
|
+
"# Release Notes",
|
|
339
|
+
"## Release Notes",
|
|
340
|
+
|
|
341
|
+
"# Version History",
|
|
342
|
+
"## Version History",
|
|
343
|
+
|
|
344
|
+
"# Contributing",
|
|
345
|
+
"## Contributing",
|
|
346
|
+
|
|
347
|
+
"# Authors",
|
|
348
|
+
"## Authors",
|
|
349
|
+
|
|
295
350
|
"# Author",
|
|
296
351
|
"## Author",
|
|
352
|
+
|
|
353
|
+
"# Credits",
|
|
354
|
+
"## Credits",
|
|
355
|
+
|
|
356
|
+
"# Acknowledgements",
|
|
357
|
+
"## Acknowledgements",
|
|
358
|
+
|
|
359
|
+
"# Citation",
|
|
360
|
+
"## Citation",
|
|
361
|
+
|
|
297
362
|
"# License",
|
|
298
363
|
"## License",
|
|
299
|
-
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
|
|
303
|
-
"#
|
|
304
|
-
"##
|
|
364
|
+
|
|
365
|
+
"# Contact",
|
|
366
|
+
"## Contact",
|
|
367
|
+
|
|
368
|
+
"# Support",
|
|
369
|
+
"## Support"
|
|
305
370
|
]
|
|
306
371
|
|
|
307
372
|
lines = file_diff.splitlines()
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from .persistence import initialize_synapse
|
|
2
|
-
from .processor import build_repository_context
|
|
3
|
-
from .extractor import build_compressed_context
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def init():
|
|
7
|
-
initialize_synapse()
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def knowledge():
|
|
11
|
-
print("Initializing repository context...")
|
|
12
|
-
|
|
13
|
-
build_repository_context()
|
|
14
|
-
|
|
15
|
-
print(
|
|
16
|
-
"Repository context initialized.\n"
|
|
17
|
-
"Building compressed repository context..."
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
build_compressed_context()
|
|
21
|
-
|
|
22
|
-
print("Successfully initialized compressed repository context.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|