scc-sdk 0.1.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.
- scc_sdk-0.1.0/PKG-INFO +13 -0
- scc_sdk-0.1.0/pyproject.toml +25 -0
- scc_sdk-0.1.0/scc_sdk.egg-info/PKG-INFO +13 -0
- scc_sdk-0.1.0/scc_sdk.egg-info/SOURCES.txt +6 -0
- scc_sdk-0.1.0/scc_sdk.egg-info/dependency_links.txt +1 -0
- scc_sdk-0.1.0/scc_sdk.egg-info/top_level.txt +1 -0
- scc_sdk-0.1.0/scc_sdk.py +224 -0
- scc_sdk-0.1.0/setup.cfg +4 -0
scc_sdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scc-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Thin Python SDK for the scc (System Context Compiler) CLI
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/carterlasalle/system_ir
|
|
7
|
+
Project-URL: Repository, https://github.com/carterlasalle/system_ir
|
|
8
|
+
Keywords: scc,system-context,coding-agents,mcp
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scc-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Thin Python SDK for the scc (System Context Compiler) CLI"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
keywords = ["scc", "system-context", "coding-agents", "mcp"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Topic :: Software Development :: Libraries",
|
|
17
|
+
]
|
|
18
|
+
dependencies = []
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/carterlasalle/system_ir"
|
|
22
|
+
Repository = "https://github.com/carterlasalle/system_ir"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools]
|
|
25
|
+
py-modules = ["scc_sdk"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scc-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Thin Python SDK for the scc (System Context Compiler) CLI
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/carterlasalle/system_ir
|
|
7
|
+
Project-URL: Repository, https://github.com/carterlasalle/system_ir
|
|
8
|
+
Keywords: scc,system-context,coding-agents,mcp
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scc_sdk
|
scc_sdk-0.1.0/scc_sdk.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""Thin Python SDK for the ``scc`` (System Context Compiler) CLI.
|
|
2
|
+
|
|
3
|
+
Every method shells out to the ``scc`` binary with ``--root <cwd>`` and
|
|
4
|
+
``--json``, and parses the emitted context pack. The binary is resolved from
|
|
5
|
+
the ``bin`` constructor argument, then the ``SCC_BIN`` environment variable,
|
|
6
|
+
then ``scc`` on PATH. A non-zero exit raises :class:`SCCError` with the
|
|
7
|
+
process's stderr.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import subprocess
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
# trace:v1 id=impl.scc.sdk.python work=WORK-SCC-014 satisfies=REQ-SCC-IR
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SCCError(Exception):
|
|
21
|
+
"""Raised when the ``scc`` CLI exits with a non-zero status."""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# trace:v1 id=impl.sdk-python-scc-sdk.scc work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
25
|
+
class SCC:
|
|
26
|
+
"""Client for the ``scc`` CLI (thin subprocess wrapper)."""
|
|
27
|
+
|
|
28
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.init work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
29
|
+
def __init__(self, bin: str | None = None, cwd: str | None = None) -> None:
|
|
30
|
+
self._bin = bin or os.environ.get("SCC_BIN") or "scc"
|
|
31
|
+
self._cwd = cwd or os.getcwd()
|
|
32
|
+
|
|
33
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.run work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
34
|
+
def _run(self, args: list[str]) -> subprocess.CompletedProcess:
|
|
35
|
+
proc = subprocess.run(
|
|
36
|
+
[self._bin, "--root", self._cwd, *args],
|
|
37
|
+
capture_output=True,
|
|
38
|
+
text=True,
|
|
39
|
+
check=False,
|
|
40
|
+
)
|
|
41
|
+
if proc.returncode != 0:
|
|
42
|
+
message = (
|
|
43
|
+
proc.stderr.strip() or f"{self._bin} exited with code {proc.returncode}"
|
|
44
|
+
)
|
|
45
|
+
raise SCCError(message)
|
|
46
|
+
return proc
|
|
47
|
+
|
|
48
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.run-json work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
49
|
+
def _run_json(self, args: list[str]) -> dict[str, Any]:
|
|
50
|
+
proc = self._run(args)
|
|
51
|
+
return json.loads(proc.stdout)
|
|
52
|
+
|
|
53
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.system-overview work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
54
|
+
def systemOverview(self) -> dict[str, Any]:
|
|
55
|
+
"""Compile the system overview capsule."""
|
|
56
|
+
return self._run_json(["overview", "--json"])
|
|
57
|
+
|
|
58
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.task-context work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
59
|
+
def taskContext(
|
|
60
|
+
self,
|
|
61
|
+
goal: str,
|
|
62
|
+
files: list[str] | None = None,
|
|
63
|
+
symbols: list[str] | None = None,
|
|
64
|
+
tokenBudget: int | None = None,
|
|
65
|
+
) -> dict[str, Any]:
|
|
66
|
+
"""Compile the complete task context artifact for a goal: the enriched
|
|
67
|
+
task pack plus its task-personalized Surface delta.
|
|
68
|
+
|
|
69
|
+
Returns the CLI's `scc context task --json` output verbatim:
|
|
70
|
+
``{"pack": {...}, "delta": "...", "delta_ids": [...],
|
|
71
|
+
"token_count": N}`` — ``pack`` is the flat task pack (keys
|
|
72
|
+
``kind``, ``content``, ``entity_ids``, ...); ``delta`` is the
|
|
73
|
+
task-personalized Surface delta; ``delta_ids`` are the delta's
|
|
74
|
+
rendered entry ids. Never flattened: consumers read
|
|
75
|
+
``result["pack"]["content"]``, not ``result["content"]``.
|
|
76
|
+
"""
|
|
77
|
+
args = ["context", "task", goal]
|
|
78
|
+
if files:
|
|
79
|
+
args.extend(["--files", " ".join(files)])
|
|
80
|
+
if symbols:
|
|
81
|
+
args.extend(["--symbols", " ".join(symbols)])
|
|
82
|
+
if tokenBudget is not None:
|
|
83
|
+
args.extend(["--budget", str(tokenBudget)])
|
|
84
|
+
args.append("--json")
|
|
85
|
+
return self._run_json(args)
|
|
86
|
+
|
|
87
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.component-context work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
88
|
+
def componentContext(self, id: str) -> dict[str, Any]:
|
|
89
|
+
"""Compile the context pack for one component (by id or name)."""
|
|
90
|
+
return self._run_json(["context", "component", id, "--json"])
|
|
91
|
+
|
|
92
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.flow-context work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
93
|
+
def flowContext(self, id: str) -> dict[str, Any]:
|
|
94
|
+
"""Compile the context pack for one flow (by id or name)."""
|
|
95
|
+
return self._run_json(["context", "flow", id, "--json"])
|
|
96
|
+
|
|
97
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.impact-context work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
98
|
+
def impactContext(
|
|
99
|
+
self, files: list[str] | None = None, symbols: list[str] | None = None
|
|
100
|
+
) -> dict[str, Any]:
|
|
101
|
+
"""Compile an impact analysis pack for a set of files/symbols."""
|
|
102
|
+
args = ["impact"]
|
|
103
|
+
if files:
|
|
104
|
+
args.extend(files)
|
|
105
|
+
if symbols:
|
|
106
|
+
args.extend(["--symbols", " ".join(symbols)])
|
|
107
|
+
args.append("--json")
|
|
108
|
+
return self._run_json(args)
|
|
109
|
+
|
|
110
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.verify-context work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
111
|
+
def verifyContext(self) -> dict[str, Any]:
|
|
112
|
+
"""Run the freshness/evidence verification.
|
|
113
|
+
|
|
114
|
+
``scc verify`` has no JSON mode, so the pack is synthesized from its
|
|
115
|
+
markdown output.
|
|
116
|
+
"""
|
|
117
|
+
proc = self._run(["verify"])
|
|
118
|
+
revision = ""
|
|
119
|
+
for line in proc.stdout.splitlines():
|
|
120
|
+
if line.startswith("Revision:"):
|
|
121
|
+
revision = line.split(":", 1)[1].strip()
|
|
122
|
+
break
|
|
123
|
+
return {
|
|
124
|
+
"kind": "verify",
|
|
125
|
+
"repository_revision": revision,
|
|
126
|
+
"content": proc.stdout,
|
|
127
|
+
"entity_ids": [],
|
|
128
|
+
"evidence_summary": {},
|
|
129
|
+
"warnings": [],
|
|
130
|
+
"tokens": 0,
|
|
131
|
+
"budget": 0,
|
|
132
|
+
"truncated": False,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.context-startup work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
136
|
+
def contextStartup(self, budget: int | None = None) -> dict[str, Any]:
|
|
137
|
+
"""Compile the fused session-startup artifact (Atlas + Surface +
|
|
138
|
+
coverage + omissions).
|
|
139
|
+
|
|
140
|
+
``scc context startup`` has no JSON mode, so the pack is synthesized
|
|
141
|
+
from its markdown output.
|
|
142
|
+
"""
|
|
143
|
+
args = ["context", "startup"]
|
|
144
|
+
if budget is not None:
|
|
145
|
+
args.extend(["--budget", str(budget)])
|
|
146
|
+
proc = self._run(args)
|
|
147
|
+
return {
|
|
148
|
+
"kind": "startup",
|
|
149
|
+
"repository_revision": "",
|
|
150
|
+
"content": proc.stdout,
|
|
151
|
+
"entity_ids": [],
|
|
152
|
+
"evidence_summary": {},
|
|
153
|
+
"warnings": [],
|
|
154
|
+
"tokens": 0,
|
|
155
|
+
"budget": budget or 0,
|
|
156
|
+
"truncated": False,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.surface-map work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
160
|
+
def surfaceMap(
|
|
161
|
+
self, goal: str | None = None, budget: int | None = None
|
|
162
|
+
) -> dict[str, Any]:
|
|
163
|
+
"""Compile the System Surface Map, global or task-personalized.
|
|
164
|
+
|
|
165
|
+
``scc surface`` has no JSON mode, so the pack is synthesized from
|
|
166
|
+
its markdown output.
|
|
167
|
+
"""
|
|
168
|
+
args = ["surface"]
|
|
169
|
+
if goal:
|
|
170
|
+
args.extend(["--task", goal])
|
|
171
|
+
if budget is not None:
|
|
172
|
+
args.extend(["--budget", str(budget)])
|
|
173
|
+
proc = self._run(args)
|
|
174
|
+
return {
|
|
175
|
+
"kind": "surface",
|
|
176
|
+
"repository_revision": "",
|
|
177
|
+
"content": proc.stdout,
|
|
178
|
+
"entity_ids": [],
|
|
179
|
+
"evidence_summary": {},
|
|
180
|
+
"warnings": [],
|
|
181
|
+
"tokens": 0,
|
|
182
|
+
"budget": budget or 0,
|
|
183
|
+
"truncated": False,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.structural-source work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
187
|
+
def structuralSource(
|
|
188
|
+
self,
|
|
189
|
+
files: list[str] | None = None,
|
|
190
|
+
goal: str | None = None,
|
|
191
|
+
budget: int | None = None,
|
|
192
|
+
) -> dict[str, Any]:
|
|
193
|
+
"""Compile the Structural Source representation of files (explicit
|
|
194
|
+
``files`` or the files matched to a ``goal`` via the PPR->Surface
|
|
195
|
+
pipeline).
|
|
196
|
+
|
|
197
|
+
``scc context structural`` has no JSON mode, so the pack is
|
|
198
|
+
synthesized from its markdown output.
|
|
199
|
+
"""
|
|
200
|
+
args = ["context", "structural"]
|
|
201
|
+
if files:
|
|
202
|
+
args.extend(["--files", " ".join(files)])
|
|
203
|
+
if goal:
|
|
204
|
+
args.extend(["--task", goal])
|
|
205
|
+
if budget is not None:
|
|
206
|
+
args.extend(["--budget", str(budget)])
|
|
207
|
+
proc = self._run(args)
|
|
208
|
+
return {
|
|
209
|
+
"kind": "structural",
|
|
210
|
+
"repository_revision": "",
|
|
211
|
+
"content": proc.stdout,
|
|
212
|
+
"entity_ids": [],
|
|
213
|
+
"evidence_summary": {},
|
|
214
|
+
"warnings": [],
|
|
215
|
+
"tokens": 0,
|
|
216
|
+
"budget": budget or 0,
|
|
217
|
+
"truncated": False,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
# trace:v1 id=impl.sdk-python-scc-sdk-scc.index work=WORK-task-context-transport-parity satisfies=REQ-SCC-IR
|
|
221
|
+
def index(self) -> dict[str, bool]:
|
|
222
|
+
"""Index the repository (idempotent; incremental after the first run)."""
|
|
223
|
+
self._run(["index"])
|
|
224
|
+
return {"ok": True}
|
scc_sdk-0.1.0/setup.cfg
ADDED