token-savior-recall 2.0.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.
Files changed (133) hide show
  1. token_savior_recall-2.0.0/.github/workflows/benchmark.yml +20 -0
  2. token_savior_recall-2.0.0/.github/workflows/ci.yml +31 -0
  3. token_savior_recall-2.0.0/.github/workflows/publish.yml +36 -0
  4. token_savior_recall-2.0.0/.gitignore +75 -0
  5. token_savior_recall-2.0.0/CHANGELOG.md +107 -0
  6. token_savior_recall-2.0.0/LICENSE +21 -0
  7. token_savior_recall-2.0.0/PKG-INFO +470 -0
  8. token_savior_recall-2.0.0/README.md +443 -0
  9. token_savior_recall-2.0.0/RELEASE.md +72 -0
  10. token_savior_recall-2.0.0/benchmarks/__init__.py +0 -0
  11. token_savior_recall-2.0.0/benchmarks/run_benchmarks.py +317 -0
  12. token_savior_recall-2.0.0/config-analysis-recap.html +258 -0
  13. token_savior_recall-2.0.0/config-analysis-recap.png +0 -0
  14. token_savior_recall-2.0.0/docs/superpowers/plans/2026-04-05-config-analysis.md +2473 -0
  15. token_savior_recall-2.0.0/docs/superpowers/specs/2026-04-05-config-analysis-design.md +212 -0
  16. token_savior_recall-2.0.0/glama.json +6 -0
  17. token_savior_recall-2.0.0/hooks/memory-hooks-config.json +26 -0
  18. token_savior_recall-2.0.0/hooks/memory-posttooluse.sh +166 -0
  19. token_savior_recall-2.0.0/hooks/memory-precompact.sh +57 -0
  20. token_savior_recall-2.0.0/hooks/memory-pretooluse.sh +119 -0
  21. token_savior_recall-2.0.0/hooks/memory-session-start.sh +240 -0
  22. token_savior_recall-2.0.0/hooks/memory-session-stop.sh +274 -0
  23. token_savior_recall-2.0.0/hooks/memory-userprompt.sh +157 -0
  24. token_savior_recall-2.0.0/llms-install.md +34 -0
  25. token_savior_recall-2.0.0/pyproject.toml +52 -0
  26. token_savior_recall-2.0.0/release-card.png +0 -0
  27. token_savior_recall-2.0.0/release-card.svg +149 -0
  28. token_savior_recall-2.0.0/scripts/export_markdown.py +214 -0
  29. token_savior_recall-2.0.0/scripts/export_memory.py +90 -0
  30. token_savior_recall-2.0.0/scripts/import_memory.py +166 -0
  31. token_savior_recall-2.0.0/scripts/migrate_memory_md.py +229 -0
  32. token_savior_recall-2.0.0/scripts/ts_cli.py +407 -0
  33. token_savior_recall-2.0.0/server.json +34 -0
  34. token_savior_recall-2.0.0/src/token_savior/__init__.py +3 -0
  35. token_savior_recall-2.0.0/src/token_savior/annotator.py +113 -0
  36. token_savior_recall-2.0.0/src/token_savior/brace_matcher.py +367 -0
  37. token_savior_recall-2.0.0/src/token_savior/breaking_changes.py +542 -0
  38. token_savior_recall-2.0.0/src/token_savior/c_annotator.py +697 -0
  39. token_savior_recall-2.0.0/src/token_savior/cache_ops.py +256 -0
  40. token_savior_recall-2.0.0/src/token_savior/checkpoint_ops.py +197 -0
  41. token_savior_recall-2.0.0/src/token_savior/community.py +145 -0
  42. token_savior_recall-2.0.0/src/token_savior/compact_ops.py +101 -0
  43. token_savior_recall-2.0.0/src/token_savior/complexity.py +136 -0
  44. token_savior_recall-2.0.0/src/token_savior/conf_annotator.py +94 -0
  45. token_savior_recall-2.0.0/src/token_savior/config_analyzer.py +971 -0
  46. token_savior_recall-2.0.0/src/token_savior/context_packer.py +120 -0
  47. token_savior_recall-2.0.0/src/token_savior/cross_project.py +132 -0
  48. token_savior_recall-2.0.0/src/token_savior/csharp_annotator.py +685 -0
  49. token_savior_recall-2.0.0/src/token_savior/dashboard.py +981 -0
  50. token_savior_recall-2.0.0/src/token_savior/dead_code.py +195 -0
  51. token_savior_recall-2.0.0/src/token_savior/docker_analyzer.py +296 -0
  52. token_savior_recall-2.0.0/src/token_savior/dockerfile_annotator.py +102 -0
  53. token_savior_recall-2.0.0/src/token_savior/edit_ops.py +168 -0
  54. token_savior_recall-2.0.0/src/token_savior/edit_verifier.py +161 -0
  55. token_savior_recall-2.0.0/src/token_savior/entry_points.py +90 -0
  56. token_savior_recall-2.0.0/src/token_savior/env_annotator.py +56 -0
  57. token_savior_recall-2.0.0/src/token_savior/generic_annotator.py +21 -0
  58. token_savior_recall-2.0.0/src/token_savior/git_ops.py +90 -0
  59. token_savior_recall-2.0.0/src/token_savior/git_tracker.py +248 -0
  60. token_savior_recall-2.0.0/src/token_savior/go_annotator.py +511 -0
  61. token_savior_recall-2.0.0/src/token_savior/graph_ranker.py +109 -0
  62. token_savior_recall-2.0.0/src/token_savior/hcl_annotator.py +143 -0
  63. token_savior_recall-2.0.0/src/token_savior/impacted_tests.py +261 -0
  64. token_savior_recall-2.0.0/src/token_savior/ini_annotator.py +148 -0
  65. token_savior_recall-2.0.0/src/token_savior/json_annotator.py +161 -0
  66. token_savior_recall-2.0.0/src/token_savior/markov_prefetcher.py +105 -0
  67. token_savior_recall-2.0.0/src/token_savior/memory_db.py +2345 -0
  68. token_savior_recall-2.0.0/src/token_savior/memory_schema.sql +191 -0
  69. token_savior_recall-2.0.0/src/token_savior/models.py +249 -0
  70. token_savior_recall-2.0.0/src/token_savior/program_slicer.py +160 -0
  71. token_savior_recall-2.0.0/src/token_savior/project_actions.py +274 -0
  72. token_savior_recall-2.0.0/src/token_savior/project_indexer.py +1015 -0
  73. token_savior_recall-2.0.0/src/token_savior/python_annotator.py +298 -0
  74. token_savior_recall-2.0.0/src/token_savior/query_api.py +1460 -0
  75. token_savior_recall-2.0.0/src/token_savior/rust_annotator.py +738 -0
  76. token_savior_recall-2.0.0/src/token_savior/semantic_hasher.py +92 -0
  77. token_savior_recall-2.0.0/src/token_savior/server.py +2259 -0
  78. token_savior_recall-2.0.0/src/token_savior/slot_manager.py +373 -0
  79. token_savior_recall-2.0.0/src/token_savior/symbol_hash.py +124 -0
  80. token_savior_recall-2.0.0/src/token_savior/text_annotator.py +118 -0
  81. token_savior_recall-2.0.0/src/token_savior/toml_annotator.py +105 -0
  82. token_savior_recall-2.0.0/src/token_savior/tool_schemas.py +1339 -0
  83. token_savior_recall-2.0.0/src/token_savior/typescript_annotator.py +568 -0
  84. token_savior_recall-2.0.0/src/token_savior/workflow_ops.py +174 -0
  85. token_savior_recall-2.0.0/src/token_savior/xml_annotator.py +108 -0
  86. token_savior_recall-2.0.0/src/token_savior/yaml_annotator.py +143 -0
  87. token_savior_recall-2.0.0/tests/test_annotator_protocol.py +27 -0
  88. token_savior_recall-2.0.0/tests/test_breaking_changes.py +255 -0
  89. token_savior_recall-2.0.0/tests/test_cache_ops.py +187 -0
  90. token_savior_recall-2.0.0/tests/test_checkpoint_ops.py +67 -0
  91. token_savior_recall-2.0.0/tests/test_community.py +78 -0
  92. token_savior_recall-2.0.0/tests/test_compact_ops.py +105 -0
  93. token_savior_recall-2.0.0/tests/test_complexity.py +294 -0
  94. token_savior_recall-2.0.0/tests/test_config_analyzer.py +717 -0
  95. token_savior_recall-2.0.0/tests/test_config_dispatch.py +49 -0
  96. token_savior_recall-2.0.0/tests/test_config_integration.py +73 -0
  97. token_savior_recall-2.0.0/tests/test_cross_project.py +283 -0
  98. token_savior_recall-2.0.0/tests/test_dashboard.py +168 -0
  99. token_savior_recall-2.0.0/tests/test_dead_code.py +299 -0
  100. token_savior_recall-2.0.0/tests/test_docker_analyzer.py +158 -0
  101. token_savior_recall-2.0.0/tests/test_edit_ops.py +82 -0
  102. token_savior_recall-2.0.0/tests/test_entry_points.py +64 -0
  103. token_savior_recall-2.0.0/tests/test_git_ops.py +88 -0
  104. token_savior_recall-2.0.0/tests/test_git_ops_summary.py +40 -0
  105. token_savior_recall-2.0.0/tests/test_git_tracker.py +187 -0
  106. token_savior_recall-2.0.0/tests/test_impacted_tests.py +110 -0
  107. token_savior_recall-2.0.0/tests/test_incremental.py +156 -0
  108. token_savior_recall-2.0.0/tests/test_markup_c.py +573 -0
  109. token_savior_recall-2.0.0/tests/test_markup_conf.py +185 -0
  110. token_savior_recall-2.0.0/tests/test_markup_csharp.py +487 -0
  111. token_savior_recall-2.0.0/tests/test_markup_dockerfile.py +181 -0
  112. token_savior_recall-2.0.0/tests/test_markup_env.py +159 -0
  113. token_savior_recall-2.0.0/tests/test_markup_go.py +445 -0
  114. token_savior_recall-2.0.0/tests/test_markup_hcl.py +260 -0
  115. token_savior_recall-2.0.0/tests/test_markup_ini.py +167 -0
  116. token_savior_recall-2.0.0/tests/test_markup_json.py +282 -0
  117. token_savior_recall-2.0.0/tests/test_markup_python.py +432 -0
  118. token_savior_recall-2.0.0/tests/test_markup_rust.py +538 -0
  119. token_savior_recall-2.0.0/tests/test_markup_text.py +179 -0
  120. token_savior_recall-2.0.0/tests/test_markup_toml.py +228 -0
  121. token_savior_recall-2.0.0/tests/test_markup_typescript.py +256 -0
  122. token_savior_recall-2.0.0/tests/test_markup_xml.py +185 -0
  123. token_savior_recall-2.0.0/tests/test_markup_yaml.py +135 -0
  124. token_savior_recall-2.0.0/tests/test_memory_db.py +130 -0
  125. token_savior_recall-2.0.0/tests/test_project_actions.py +119 -0
  126. token_savior_recall-2.0.0/tests/test_project_indexer.py +844 -0
  127. token_savior_recall-2.0.0/tests/test_query_api.py +781 -0
  128. token_savior_recall-2.0.0/tests/test_server_integration.py +184 -0
  129. token_savior_recall-2.0.0/tests/test_slot_manager.py +155 -0
  130. token_savior_recall-2.0.0/tests/test_tool_schemas.py +62 -0
  131. token_savior_recall-2.0.0/tests/test_usage_stats.py +303 -0
  132. token_savior_recall-2.0.0/tests/test_workflow_ops.py +133 -0
  133. token_savior_recall-2.0.0/uv.lock +1397 -0
@@ -0,0 +1,20 @@
1
+ name: Benchmarks
2
+ on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ benchmark:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-python@v5
13
+ with:
14
+ python-version: "3.12"
15
+ - run: pip install -e ".[dev]"
16
+ - run: python benchmarks/run_benchmarks.py
17
+ - uses: actions/upload-artifact@v4
18
+ with:
19
+ name: benchmark-results
20
+ path: benchmarks/results.json
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev,mcp]"
26
+
27
+ - name: Lint with ruff
28
+ run: ruff check src/ tests/
29
+
30
+ - name: Run tests
31
+ run: pytest tests/ -v
@@ -0,0 +1,36 @@
1
+ name: Publish release assets
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.11"
20
+
21
+ - name: Install build tools
22
+ run: pip install build twine
23
+
24
+ - name: Build package
25
+ run: python -m build
26
+
27
+ - name: Upload assets to release
28
+ env:
29
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
+ run: gh release upload "${{ github.event.release.tag_name }}" dist/*
31
+
32
+ - name: Publish to PyPI
33
+ env:
34
+ TWINE_USERNAME: __token__
35
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
36
+ run: twine upload dist/*
@@ -0,0 +1,75 @@
1
+ # ── Secrets & credentials ──────────────────────
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+
6
+ # ── Private assets ─────────────────────────────
7
+ assets/
8
+ .mcpregistry_*
9
+ *.pem
10
+ *.key
11
+ *.crt
12
+ *.p12
13
+ *.pfx
14
+ *.jks
15
+ credentials.json
16
+ service-account*.json
17
+ *secret*
18
+ !*secret*.py
19
+
20
+ # ── Python ─────────────────────────────────────
21
+ __pycache__/
22
+ *.py[cod]
23
+ *$py.class
24
+ *.egg-info/
25
+ dist/
26
+ build/
27
+ .eggs/
28
+ *.egg
29
+ *.so
30
+ *.whl
31
+
32
+ # ── Virtual environments ───────────────────────
33
+ .venv/
34
+ venv/
35
+ env/
36
+ ENV/
37
+
38
+ # ── IDE & editor ───────────────────────────────
39
+ .idea/
40
+ .vscode/
41
+ *.swp
42
+ *.swo
43
+ *~
44
+ .DS_Store
45
+ Thumbs.db
46
+
47
+ # ── Testing & linting ─────────────────────────
48
+ .mypy_cache/
49
+ .pytest_cache/
50
+ .ruff_cache/
51
+ .coverage
52
+ htmlcov/
53
+ .tox/
54
+
55
+ # ── Claude Code local state ───────────────────
56
+ .claude/
57
+
58
+ # ── Codebase index cache ─────────────────────
59
+ .codebase-index-cache.pkl
60
+ .codebase-index-cache.json
61
+ .token-savior-cache.json
62
+
63
+ # ── MCP local config ─────────────────────────
64
+ .mcp.json
65
+
66
+ # ── Benchmark output (scripts are tracked) ──────
67
+ benchmarks/results.json
68
+ benchmarks/report.md
69
+
70
+ # ── Misc ───────────────────────────────────────
71
+ *.log
72
+ *.bak
73
+ *.tmp
74
+ .token-savior-checkpoints/
75
+ memory-backup-*.json
@@ -0,0 +1,107 @@
1
+ # Changelog
2
+
3
+ ## v2.0.0 — Token Savior Recall (2026-04-13)
4
+
5
+ ### Memory Engine (new)
6
+
7
+ - SQLite WAL + FTS5: cross-session persistent memory
8
+ - 21 memory tools: save, search, get, delete, index, timeline, status, why, top
9
+ - 8 Claude Code lifecycle hooks: SessionStart, Stop, SessionEnd, PreCompact,
10
+ PreToolUse ×2, UserPromptSubmit, PostToolUse
11
+ - LRU scoring: `0.4 × recency + 0.3 × access + 0.3 × type_priority`
12
+ - Delta injection: only the diff since last session is re-injected at start
13
+ - Explicit TTL per observation type (command 60d, research 90d, note 60d)
14
+ - Semantic dedup: exact hash + Jaccard (~0.85 threshold)
15
+ - Auto-promotion: note × 5 accesses → convention, warning × 5 → guardrail
16
+ - Contradiction detection at save time
17
+ - Auto-linking between observations (symbol, context, tags)
18
+ - Telegram feed for critical observations (warning / guardrail / error_pattern)
19
+ - Mode system: `code`, `review`, `debug`, `infra`, `silent` with auto-detection
20
+ - Thematic corpus Q&A
21
+ - Versioned markdown export (git-tracked)
22
+ - CLI: `ts memory {status,list,search,get,save,delete,top,why,doctor,relink}`
23
+ - Dashboard Memory tab
24
+ - 12 observation types: `bugfix`, `decision`, `convention`, `warning`,
25
+ `guardrail`, `error_pattern`, `note`, `command`, `research`, `infra`,
26
+ `config`, `idea`
27
+
28
+ ### Manifest optimizations
29
+
30
+ - 80 → 69 tools (−11)
31
+ - 42,251 → 36,153 chars manifest (−14%)
32
+ - ~1,524 tokens saved per session on MCP manifest alone
33
+
34
+ ### Cleanup
35
+
36
+ - Removed DEPRECATED tools (`apply_symbol_change_validate_with_rollback`,
37
+ `get_changed_symbols_since_ref`)
38
+ - Fused 10 memory tools → 5 (`memory_mode`, `memory_archive`,
39
+ `memory_maintain`, `memory_set_global`, `memory_prompts`)
40
+
41
+ ### Core Token Savior (unchanged)
42
+
43
+ - 69 MCP tools total (53 core + 16 memory)
44
+ - 97% token savings measured across 170 real sessions
45
+ - ~$609 estimated cost saved
46
+ - 17 indexed projects
47
+ - Annotators: Python, TypeScript/JS, Rust, Go, C/C++, C#, JSON, YAML,
48
+ TOML, XML, INI, ENV, HCL, Dockerfile, Markdown
49
+
50
+ ### Rename
51
+
52
+ - Project renamed: **Token Savior → Token Savior Recall**
53
+ - MCP server identifier: `token-savior` → `token-savior-recall`
54
+ - PyPI package: `token-savior` → `token-savior-recall`
55
+
56
+ ---
57
+
58
+ ## v1.0.0 (2026-04-11)
59
+
60
+ ### Architecture
61
+
62
+ - **ProjectQueryEngine**: Refactored 705-line closure `create_project_query_functions` into a class with one method per query tool. `as_dict()` preserves backward compatibility.
63
+ - **CacheManager**: Extracted cache persistence logic from `server.py` into `src/token_savior/cache_ops.py`.
64
+ - **SlotManager**: Extracted project slot management from `server.py` into `src/token_savior/slot_manager.py`.
65
+ - **Tool schemas**: Extracted all 53 MCP tool schemas from `server.py` into `src/token_savior/tool_schemas.py`. Server reduced from 2,439 to 990 lines.
66
+ - **Brace matcher**: Factored `_find_brace_end` from 4 annotators into `src/token_savior/brace_matcher.py` with per-language variants.
67
+ - **Annotator refactoring**: Table-driven dispatch in `annotate_rust` and `annotate_csharp` to reduce complexity below 150.
68
+ - **AnnotatorProtocol**: Added `typing.Protocol` for annotator type safety in `models.py`.
69
+
70
+ ### Performance
71
+
72
+ - **LazyLines**: File lines are lazy-loaded from disk on demand instead of stored in cache. Cache size reduced by ~57%, idle RAM reduced proportionally.
73
+ - **Manual serialization**: Replaced `dataclasses.asdict()` in cache persistence with zero-copy field-by-field serialization.
74
+ - **scandir batching**: `_check_mtime_changes` uses `os.scandir()` per directory instead of individual `os.path.getmtime()` calls.
75
+ - **Regex cache**: Module-level `_WORD_BOUNDARY_CACHE` avoids recompiling patterns on every call.
76
+ - **File limits**: `ProjectIndexer` gains `max_files` param (env: `TOKEN_SAVIOR_MAX_FILES`, default 10,000).
77
+
78
+ ### Bug fixes
79
+
80
+ - **Path traversal**: `create_checkpoint` validates file paths with `os.path.commonpath` to prevent `../../../etc/passwd` attacks.
81
+ - **Triple save**: `_maybe_incremental_update` uses `_dirty` flag pattern to call `_save_cache` at most once per execution path.
82
+ - **Output truncation**: `get_dependents` and `get_change_impact` gained `max_total_chars` (default 50,000) to prevent oversized responses.
83
+
84
+ ### Tool fusions
85
+
86
+ - **get_changed_symbols**: Unified with `get_changed_symbols_since_ref` via optional `ref` parameter.
87
+ - **apply_symbol_change_and_validate**: Unified with rollback variant via `rollback_on_failure` parameter.
88
+
89
+ ### Deprecated (removal planned for v1.1.0)
90
+
91
+ - **get_changed_symbols_since_ref**: Use `get_changed_symbols(ref=...)` instead.
92
+ - **apply_symbol_change_validate_with_rollback**: Use `apply_symbol_change_and_validate(rollback_on_failure=true)` instead.
93
+
94
+ Both deprecated tools inject a `_deprecated` field in their response with migration instructions. Their schemas are marked with `"deprecated": true` in `tool_schemas.py`.
95
+
96
+ ### Tests
97
+
98
+ - `tests/test_cache_ops.py` (12 tests)
99
+ - `tests/test_slot_manager.py` (13 tests)
100
+ - `tests/test_server_integration.py` (5 end-to-end tests)
101
+ - `tests/test_annotator_protocol.py` (4 tests)
102
+ - `tests/test_tool_schemas.py` (7 tests)
103
+
104
+ ### Benchmarks
105
+
106
+ - `benchmarks/run_benchmarks.py`: Automated benchmarks on FastAPI + CPython measuring index time, RAM, query response time, and cache size.
107
+ - `.github/workflows/benchmark.yml`: GitHub Action for release benchmarks.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mibayy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.