sourcecode 1.33.1__tar.gz → 1.33.2__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.
- {sourcecode-1.33.1 → sourcecode-1.33.2}/PKG-INFO +3 -3
- {sourcecode-1.33.1 → sourcecode-1.33.2}/README.md +2 -2
- {sourcecode-1.33.1 → sourcecode-1.33.2}/pyproject.toml +1 -1
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/__init__.py +1 -1
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/cache.py +71 -4
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/cli.py +67 -4
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/ris.py +25 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/.github/workflows/build-windows.yml +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/.gitignore +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/.ruff.toml +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/CHANGELOG.md +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/CONTRIBUTING.md +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/LICENSE +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/SECURITY.md +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/raw +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/adaptive_scanner.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/architecture_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/architecture_summary.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/ast_extractor.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/cache.tmp_new +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/canonical_ir.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/classifier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/code_notes_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/confidence_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/context_scorer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/context_summarizer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/contract_model.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/contract_pipeline.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/coverage_parser.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/dependency_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/__init__.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/base.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/csproj_parser.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/dart.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/dotnet.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/elixir.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/go.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/heuristic.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/hybrid.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/java.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/jvm_ext.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/nodejs.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/parsers.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/php.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/project.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/python.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/ruby.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/rust.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/systems.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/terraform.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/detectors/tooling.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/doc_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/entrypoint_classifier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/env_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/file_classifier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/flow_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/git_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/graph_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/license.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/__init__.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/onboarding/__init__.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/onboarding/applier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/onboarding/backup.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/onboarding/detector.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/onboarding/planner.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/runner.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp/server.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/mcp_nudge.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/metrics_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/output_budget.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/path_filters.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/pr_comment_renderer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/prepare_context.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/progress.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/ranking_engine.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/redactor.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/relevance_scorer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/repo_classifier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/repository_ir.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/runtime_classifier.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/scanner.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/schema.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/semantic_analyzer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/serializer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/summarizer.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/__init__.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/config.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/consent.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/events.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/filters.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/telemetry/transport.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/tree_utils.py +0 -0
- {sourcecode-1.33.1 → sourcecode-1.33.2}/src/sourcecode/workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sourcecode
|
|
3
|
-
Version: 1.33.
|
|
3
|
+
Version: 1.33.2
|
|
4
4
|
Summary: Persistent structural context and ultra-fast repeated analysis for AI coding agents
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Keywords: agents,ai,codebase,context,developer-tools,llm
|
|
@@ -39,7 +39,7 @@ Description-Content-Type: text/markdown
|
|
|
39
39
|
|
|
40
40
|
**Persistent structural context and ultra-fast repeated analysis for AI coding agents.**
|
|
41
41
|
|
|
42
|
-

|
|
43
43
|

|
|
44
44
|
|
|
45
45
|
---
|
|
@@ -113,7 +113,7 @@ pipx install sourcecode
|
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
115
|
sourcecode version
|
|
116
|
-
# sourcecode 1.33.
|
|
116
|
+
# sourcecode 1.33.2
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
---
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Persistent structural context and ultra-fast repeated analysis for AI coding agents.**
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|

|
|
7
7
|
|
|
8
8
|
---
|
|
@@ -76,7 +76,7 @@ pipx install sourcecode
|
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
78
|
sourcecode version
|
|
79
|
-
# sourcecode 1.33.
|
|
79
|
+
# sourcecode 1.33.2
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
---
|
|
@@ -57,6 +57,7 @@ import hashlib
|
|
|
57
57
|
import json
|
|
58
58
|
import os
|
|
59
59
|
import re
|
|
60
|
+
import subprocess
|
|
60
61
|
from datetime import datetime, timezone
|
|
61
62
|
from pathlib import Path
|
|
62
63
|
from typing import Any, Optional
|
|
@@ -110,6 +111,24 @@ _CORE_RE = re.compile(r"^core-([0-9a-f]+)-[0-9a-f]+\.json\.gz$")
|
|
|
110
111
|
_VIEW_RE = re.compile(r"^view-([0-9a-f]{16})-[0-9a-f]+\.json\.gz$")
|
|
111
112
|
|
|
112
113
|
|
|
114
|
+
# ---------------------------------------------------------------------------
|
|
115
|
+
# Internal helpers
|
|
116
|
+
# ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
def _get_git_head(repo_root: Path) -> str:
|
|
119
|
+
"""Return short git HEAD SHA, or '' on any error."""
|
|
120
|
+
try:
|
|
121
|
+
r = subprocess.run(
|
|
122
|
+
["git", "-C", str(repo_root), "rev-parse", "--short", "HEAD"],
|
|
123
|
+
capture_output=True, text=True, timeout=2,
|
|
124
|
+
)
|
|
125
|
+
if r.returncode == 0:
|
|
126
|
+
return r.stdout.strip()
|
|
127
|
+
except Exception:
|
|
128
|
+
pass
|
|
129
|
+
return ""
|
|
130
|
+
|
|
131
|
+
|
|
113
132
|
# ---------------------------------------------------------------------------
|
|
114
133
|
# Public API — location helpers
|
|
115
134
|
# ---------------------------------------------------------------------------
|
|
@@ -138,15 +157,51 @@ def cache_dir(repo_root: Path) -> Path:
|
|
|
138
157
|
def status(repo_root: Path) -> dict[str, Any]:
|
|
139
158
|
"""Return a stats dict describing the current cache state for *repo_root*.
|
|
140
159
|
|
|
141
|
-
Keys: ``cache_dir``, ``cores``, ``
|
|
142
|
-
``total_size_bytes``, ``total_size_mb
|
|
160
|
+
Keys: ``cache_dir``, ``cores``, ``views``, ``cas_blobs``,
|
|
161
|
+
``total_size_bytes``, ``total_size_mb``, ``ris_exists``, ``ris_git_head``,
|
|
162
|
+
``ris_last_updated_at``, ``ris_is_stale``, ``current_git_head``.
|
|
163
|
+
|
|
164
|
+
Note: ``snapshots`` is a legacy v1 field — always 0 in v2 (kept for
|
|
165
|
+
backward compatibility; v2 writes ``core-*`` and ``view-*`` files only).
|
|
143
166
|
"""
|
|
144
167
|
cache_d = cache_dir(repo_root)
|
|
168
|
+
current_head = _get_git_head(repo_root)
|
|
169
|
+
|
|
170
|
+
# RIS metadata (lazy import to avoid circular dependency)
|
|
171
|
+
ris_fields: dict[str, Any]
|
|
172
|
+
try:
|
|
173
|
+
from sourcecode.ris import load_ris as _load_ris # noqa: PLC0415
|
|
174
|
+
_ris = _load_ris(repo_root)
|
|
175
|
+
if _ris is not None:
|
|
176
|
+
_ris_stale = bool(current_head and _ris.git_head and current_head != _ris.git_head)
|
|
177
|
+
ris_fields = {
|
|
178
|
+
"ris_exists": True,
|
|
179
|
+
"ris_git_head": _ris.git_head,
|
|
180
|
+
"ris_last_updated_at": _ris.last_updated_at,
|
|
181
|
+
"ris_is_stale": _ris_stale,
|
|
182
|
+
}
|
|
183
|
+
else:
|
|
184
|
+
ris_fields = {
|
|
185
|
+
"ris_exists": False,
|
|
186
|
+
"ris_git_head": None,
|
|
187
|
+
"ris_last_updated_at": None,
|
|
188
|
+
"ris_is_stale": False,
|
|
189
|
+
}
|
|
190
|
+
except Exception:
|
|
191
|
+
ris_fields = {
|
|
192
|
+
"ris_exists": False,
|
|
193
|
+
"ris_git_head": None,
|
|
194
|
+
"ris_last_updated_at": None,
|
|
195
|
+
"ris_is_stale": False,
|
|
196
|
+
}
|
|
197
|
+
|
|
145
198
|
if not cache_d.exists():
|
|
146
199
|
return {
|
|
147
200
|
"cache_dir": str(cache_d),
|
|
148
201
|
"cores": 0, "snapshots": 0, "views": 0, "cas_blobs": 0,
|
|
149
202
|
"total_size_bytes": 0, "total_size_mb": 0.0,
|
|
203
|
+
"current_git_head": current_head,
|
|
204
|
+
**ris_fields,
|
|
150
205
|
}
|
|
151
206
|
cores = list(cache_d.glob("core-*.json.gz"))
|
|
152
207
|
snapshots = list(cache_d.glob("snapshot-*.json.gz"))
|
|
@@ -162,11 +217,18 @@ def status(repo_root: Path) -> dict[str, Any]:
|
|
|
162
217
|
"cas_blobs": len(cas_blobs),
|
|
163
218
|
"total_size_bytes": total_bytes,
|
|
164
219
|
"total_size_mb": round(total_bytes / (1024 * 1024), 2),
|
|
220
|
+
"current_git_head": current_head,
|
|
221
|
+
**ris_fields,
|
|
165
222
|
}
|
|
166
223
|
|
|
167
224
|
|
|
168
|
-
def clear(repo_root: Path) -> int:
|
|
169
|
-
"""Delete
|
|
225
|
+
def clear(repo_root: Path, *, clear_ris: bool = False) -> int:
|
|
226
|
+
"""Delete cache files for *repo_root*. Returns the number of files removed.
|
|
227
|
+
|
|
228
|
+
By default, RIS (``ris.json.gz``) is preserved across clears — it is the
|
|
229
|
+
persistent structural index used by cold-start bootstrapping. Pass
|
|
230
|
+
``clear_ris=True`` (CLI: ``--include-ris``) to also delete the RIS.
|
|
231
|
+
"""
|
|
170
232
|
cache_d = cache_dir(repo_root)
|
|
171
233
|
if not cache_d.exists():
|
|
172
234
|
return 0
|
|
@@ -180,6 +242,11 @@ def clear(repo_root: Path) -> int:
|
|
|
180
242
|
for f in cas_d.glob("*.gz"):
|
|
181
243
|
_safe_unlink(f)
|
|
182
244
|
removed += 1
|
|
245
|
+
if clear_ris:
|
|
246
|
+
ris_file = cache_d / "ris.json.gz"
|
|
247
|
+
if ris_file.exists():
|
|
248
|
+
_safe_unlink(ris_file)
|
|
249
|
+
removed += 1
|
|
183
250
|
return removed
|
|
184
251
|
|
|
185
252
|
|
|
@@ -1058,6 +1058,22 @@ def main(
|
|
|
1058
1058
|
code_notes = True
|
|
1059
1059
|
architecture = True
|
|
1060
1060
|
|
|
1061
|
+
def _inject_cache_meta(raw: str, meta: dict) -> str:
|
|
1062
|
+
"""Inject ``_cache`` provenance block into a JSON dict string.
|
|
1063
|
+
|
|
1064
|
+
Parses *raw* as JSON, adds ``_cache`` key, re-serialises. Returns *raw*
|
|
1065
|
+
unchanged on any parse failure or non-dict JSON (YAML pass-through, etc.).
|
|
1066
|
+
"""
|
|
1067
|
+
try:
|
|
1068
|
+
import json as _jm
|
|
1069
|
+
obj = _jm.loads(raw)
|
|
1070
|
+
if isinstance(obj, dict):
|
|
1071
|
+
obj["_cache"] = meta
|
|
1072
|
+
return _jm.dumps(obj, indent=2, ensure_ascii=False)
|
|
1073
|
+
except Exception:
|
|
1074
|
+
pass
|
|
1075
|
+
return raw
|
|
1076
|
+
|
|
1061
1077
|
# ── Two-layer cache ────────────────────────────────────────────────────────
|
|
1062
1078
|
# L1 (core): (repo, commit, analysis_flags) → pre-computed view data dict
|
|
1063
1079
|
# key = core-<git_sha>-<analysis_hash>.json.gz
|
|
@@ -1202,6 +1218,23 @@ def main(
|
|
|
1202
1218
|
|
|
1203
1219
|
if _cache_hit_content is not None:
|
|
1204
1220
|
from sourcecode.serializer import write_output
|
|
1221
|
+
if format == "json":
|
|
1222
|
+
try:
|
|
1223
|
+
from sourcecode.ris import _has_uncommitted_changes as _huc
|
|
1224
|
+
_uncommitted = _huc(target)
|
|
1225
|
+
except Exception:
|
|
1226
|
+
_uncommitted = False
|
|
1227
|
+
_hit_source = "L2_view" if (_view_key and _core_hash) else "L1_core"
|
|
1228
|
+
_data_scope = "COMPACT" if compact else ("AGENT" if agent else "FULL")
|
|
1229
|
+
_cache_hit_content = _inject_cache_meta(_cache_hit_content, {
|
|
1230
|
+
"cache_source": _hit_source,
|
|
1231
|
+
"git_head_at_generation": _git_sha,
|
|
1232
|
+
"current_git_head": _git_sha,
|
|
1233
|
+
"is_stale": False,
|
|
1234
|
+
"has_uncommitted_changes": _uncommitted,
|
|
1235
|
+
"generated_at": None,
|
|
1236
|
+
"data_scope": _data_scope,
|
|
1237
|
+
})
|
|
1205
1238
|
write_output(_cache_hit_content, output=output)
|
|
1206
1239
|
if copy and not output:
|
|
1207
1240
|
_copy_to_clipboard(_cache_hit_content)
|
|
@@ -2082,6 +2115,23 @@ def main(
|
|
|
2082
2115
|
|
|
2083
2116
|
# 6. Write output (CLI-04)
|
|
2084
2117
|
_progress.finish()
|
|
2118
|
+
if format == "json":
|
|
2119
|
+
try:
|
|
2120
|
+
from sourcecode.ris import _has_uncommitted_changes as _huc_fresh
|
|
2121
|
+
_uncommitted_fresh = _huc_fresh(target)
|
|
2122
|
+
except Exception:
|
|
2123
|
+
_uncommitted_fresh = False
|
|
2124
|
+
import datetime as _dt
|
|
2125
|
+
_data_scope_fresh = "COMPACT" if compact else ("AGENT" if agent else "FULL")
|
|
2126
|
+
content = _inject_cache_meta(content, {
|
|
2127
|
+
"cache_source": "fresh",
|
|
2128
|
+
"git_head_at_generation": _git_sha,
|
|
2129
|
+
"current_git_head": _git_sha,
|
|
2130
|
+
"is_stale": False,
|
|
2131
|
+
"has_uncommitted_changes": _uncommitted_fresh,
|
|
2132
|
+
"generated_at": _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
2133
|
+
"data_scope": _data_scope_fresh,
|
|
2134
|
+
})
|
|
2085
2135
|
write_output(content, output=output)
|
|
2086
2136
|
|
|
2087
2137
|
# Persist to two-layer cache (git SHA unchanged → re-use on next run).
|
|
@@ -4231,23 +4281,36 @@ def cache_status_cmd(
|
|
|
4231
4281
|
else:
|
|
4232
4282
|
typer.echo(f"Cache dir: {stats['cache_dir']}")
|
|
4233
4283
|
typer.echo(f"Cores: {stats['cores']}")
|
|
4234
|
-
typer.echo(f"Snapshots: {stats['snapshots']}")
|
|
4235
4284
|
typer.echo(f"Views: {stats['views']}")
|
|
4236
4285
|
typer.echo(f"CAS blobs: {stats['cas_blobs']}")
|
|
4237
4286
|
typer.echo(f"Total size: {stats['total_size_mb']} MB")
|
|
4287
|
+
# RIS section
|
|
4288
|
+
if stats.get("ris_exists"):
|
|
4289
|
+
_stale_tag = " [STALE]" if stats.get("ris_is_stale") else ""
|
|
4290
|
+
typer.echo(f"RIS: exists HEAD={stats.get('ris_git_head', '?')}{_stale_tag} updated={stats.get('ris_last_updated_at', '?')}")
|
|
4291
|
+
else:
|
|
4292
|
+
typer.echo("RIS: none (run analysis to build)")
|
|
4293
|
+
if stats.get("current_git_head"):
|
|
4294
|
+
typer.echo(f"Current HEAD:{stats['current_git_head']}")
|
|
4238
4295
|
|
|
4239
4296
|
|
|
4240
4297
|
@cache_app.command("clear")
|
|
4241
4298
|
def cache_clear_cmd(
|
|
4242
4299
|
path: Path = typer.Argument(Path("."), help="Repository path (default: current directory)"),
|
|
4243
4300
|
yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt."),
|
|
4301
|
+
include_ris: bool = typer.Option(False, "--include-ris", help="Also delete the RIS snapshot (ris.json.gz). By default, RIS is preserved across clears."),
|
|
4244
4302
|
) -> None:
|
|
4245
|
-
"""Delete
|
|
4303
|
+
"""Delete cached snapshots for a repository.
|
|
4304
|
+
|
|
4305
|
+
By default, RIS (ris.json.gz) is preserved — it is the persistent structural
|
|
4306
|
+
index used for cold-start bootstrapping. Use --include-ris to also clear it.
|
|
4307
|
+
"""
|
|
4246
4308
|
from sourcecode import cache as _cm
|
|
4247
4309
|
target = Path(path).resolve()
|
|
4248
4310
|
if not yes:
|
|
4249
|
-
|
|
4250
|
-
|
|
4311
|
+
_ris_note = " (including RIS)" if include_ris else " (RIS preserved — use --include-ris to also clear it)"
|
|
4312
|
+
typer.confirm(f"Delete all cache files for {target}{_ris_note}?", abort=True)
|
|
4313
|
+
removed = _cm.clear(target, clear_ris=include_ris)
|
|
4251
4314
|
typer.echo(f"Removed {removed} file(s).")
|
|
4252
4315
|
|
|
4253
4316
|
|
|
@@ -349,6 +349,26 @@ def _current_git_head(repo_root: Path) -> str:
|
|
|
349
349
|
return ""
|
|
350
350
|
|
|
351
351
|
|
|
352
|
+
def _has_uncommitted_changes(repo_root: Path) -> bool:
|
|
353
|
+
"""Return True if working tree has staged or unstaged changes.
|
|
354
|
+
|
|
355
|
+
Uses ``git status --porcelain`` — any non-empty output means the working
|
|
356
|
+
tree diverges from HEAD. Returns False on any error (non-git dirs, etc.).
|
|
357
|
+
"""
|
|
358
|
+
try:
|
|
359
|
+
result = subprocess.run(
|
|
360
|
+
["git", "-C", str(repo_root), "status", "--porcelain"],
|
|
361
|
+
capture_output=True,
|
|
362
|
+
text=True,
|
|
363
|
+
timeout=2,
|
|
364
|
+
)
|
|
365
|
+
if result.returncode == 0:
|
|
366
|
+
return bool(result.stdout.strip())
|
|
367
|
+
except Exception:
|
|
368
|
+
pass
|
|
369
|
+
return False
|
|
370
|
+
|
|
371
|
+
|
|
352
372
|
def get_cold_start_context(repo_root: Path) -> dict:
|
|
353
373
|
"""Return a lightweight bootstrap object from the persisted RIS.
|
|
354
374
|
|
|
@@ -361,14 +381,19 @@ def get_cold_start_context(repo_root: Path) -> dict:
|
|
|
361
381
|
|
|
362
382
|
current_head = _current_git_head(repo_root)
|
|
363
383
|
stale = bool(current_head and ris.git_head and current_head != ris.git_head)
|
|
384
|
+
uncommitted = _has_uncommitted_changes(repo_root)
|
|
364
385
|
|
|
365
386
|
endpoints = ris.api_surface.get("endpoints", [])
|
|
366
387
|
result: dict = {
|
|
367
388
|
"status": "cold_start_stale" if stale else "cold_start_ready",
|
|
368
389
|
"repo_id": ris.repo_id,
|
|
369
390
|
"git_head": ris.git_head,
|
|
391
|
+
"current_git_head": current_head,
|
|
370
392
|
"stale": stale,
|
|
393
|
+
"has_uncommitted_changes": uncommitted,
|
|
371
394
|
"last_updated_at": ris.last_updated_at,
|
|
395
|
+
"cache_source": "RIS",
|
|
396
|
+
"data_scope": "RIS_BOOTSTRAP",
|
|
372
397
|
"summary": ris.compact_summary,
|
|
373
398
|
"entrypoints": ris.structural_map.get("entrypoints", []),
|
|
374
399
|
"endpoints": endpoints,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|