xrefkit 0.3.0__py3-none-any.whl
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.
- xrefkit/__init__.py +5 -0
- xrefkit/__main__.py +5 -0
- xrefkit/catalog_cli.py +57 -0
- xrefkit/cli.py +71 -0
- xrefkit/contracts.py +297 -0
- xrefkit/ctx.py +160 -0
- xrefkit/dashboard.py +1220 -0
- xrefkit/discovery.py +85 -0
- xrefkit/gate.py +428 -0
- xrefkit/goalstate.py +555 -0
- xrefkit/hashing.py +18 -0
- xrefkit/import_skill.py +469 -0
- xrefkit/instance.py +133 -0
- xrefkit/loaders.py +77 -0
- xrefkit/mcp/__init__.py +26 -0
- xrefkit/mcp/audit.py +168 -0
- xrefkit/mcp/bootstrap.py +337 -0
- xrefkit/mcp/catalog.py +2638 -0
- xrefkit/mcp/cli.py +173 -0
- xrefkit/mcp/client_cache.py +356 -0
- xrefkit/mcp/context_registry.py +277 -0
- xrefkit/mcp/contracts.py +243 -0
- xrefkit/mcp/dist.py +234 -0
- xrefkit/mcp/ownership.py +246 -0
- xrefkit/mcp/repository.py +217 -0
- xrefkit/mcp/schemas.py +349 -0
- xrefkit/mcp/server.py +773 -0
- xrefkit/mcp/startup_contract_pack.py +154 -0
- xrefkit/mcp_tools.py +47 -0
- xrefkit/models/__init__.py +41 -0
- xrefkit/models/common.py +185 -0
- xrefkit/models/effective_bundle.py +131 -0
- xrefkit/models/local_manifest.py +217 -0
- xrefkit/models/package_manifest.py +126 -0
- xrefkit/models/run_log.py +276 -0
- xrefkit/models/server_config.py +160 -0
- xrefkit/models/skill_definition.py +131 -0
- xrefkit/operations_cli.py +670 -0
- xrefkit/ownership.py +276 -0
- xrefkit/packmeta.py +289 -0
- xrefkit/registry.py +334 -0
- xrefkit/resolver.py +252 -0
- xrefkit/resource_provider.py +187 -0
- xrefkit/resources/base/contracts.json +178 -0
- xrefkit/resources/base/current.json +6 -0
- xrefkit/resources/base/generations/7a682a5272907354/contracts.json +178 -0
- xrefkit/resources/base/generations/7a682a5272907354/model_body.md +22 -0
- xrefkit/resources/base/generations/9929294385ccb7b0/contracts.json +178 -0
- xrefkit/resources/base/generations/9929294385ccb7b0/model_body.md +22 -0
- xrefkit/resources/base/model_body.md +22 -0
- xrefkit/runlog.py +45 -0
- xrefkit/skillmeta.py +1034 -0
- xrefkit/skillrun.py +2381 -0
- xrefkit/structure_catalog.py +199 -0
- xrefkit/tools/__init__.py +119 -0
- xrefkit/tools/__main__.py +4 -0
- xrefkit/v2_cli.py +130 -0
- xrefkit/workspace.py +117 -0
- xrefkit/xref.py +1048 -0
- xrefkit-0.3.0.dist-info/METADATA +203 -0
- xrefkit-0.3.0.dist-info/RECORD +65 -0
- xrefkit-0.3.0.dist-info/WHEEL +5 -0
- xrefkit-0.3.0.dist-info/entry_points.txt +2 -0
- xrefkit-0.3.0.dist-info/licenses/LICENSE +21 -0
- xrefkit-0.3.0.dist-info/top_level.txt +1 -0
xrefkit/mcp/schemas.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import asdict, dataclass, field
|
|
4
|
+
from typing import Any, Literal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
ExecutionLocation = Literal["server", "client"]
|
|
8
|
+
SideEffects = Literal["none", "audit_write", "repo_write", "external_write", "unknown"]
|
|
9
|
+
ResponseEnvelope = Literal["direct_object", "mcp_result_array"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class ToolContract:
|
|
14
|
+
tool_id: str
|
|
15
|
+
provider: str
|
|
16
|
+
version: str
|
|
17
|
+
execution_location: ExecutionLocation
|
|
18
|
+
side_effects: SideEffects
|
|
19
|
+
input_schema: dict[str, Any]
|
|
20
|
+
output_schema: dict[str, Any]
|
|
21
|
+
requires_workspace: bool
|
|
22
|
+
required_when: str
|
|
23
|
+
enforced_fields: tuple[str, ...] = ("execution_location", "side_effects")
|
|
24
|
+
response_envelope: ResponseEnvelope = "direct_object"
|
|
25
|
+
|
|
26
|
+
def validate(self) -> None:
|
|
27
|
+
if self.execution_location == "server" and self.side_effects not in {"none", "audit_write"}:
|
|
28
|
+
raise ValueError(
|
|
29
|
+
f"server tool {self.tool_id!r} may declare only side_effects='none' or 'audit_write'"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def to_dict(self) -> dict[str, Any]:
|
|
33
|
+
data = asdict(self)
|
|
34
|
+
data["input_json_schema"] = _json_schema_object(self.input_schema)
|
|
35
|
+
data["output_json_schema"] = _json_schema_object(self.output_schema)
|
|
36
|
+
data["schema_format"] = "json_schema"
|
|
37
|
+
return data
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class KnowledgeCatalogEntry:
|
|
42
|
+
xid: str
|
|
43
|
+
version: int
|
|
44
|
+
content_hash: str
|
|
45
|
+
revised_at: str | None
|
|
46
|
+
title: str
|
|
47
|
+
domain: str
|
|
48
|
+
summary: str
|
|
49
|
+
applies_when: list[str]
|
|
50
|
+
requires_knowledge: list[str]
|
|
51
|
+
related_skills: list[str]
|
|
52
|
+
related_capabilities: list[str]
|
|
53
|
+
path: str
|
|
54
|
+
expandable: bool = True
|
|
55
|
+
missing: list[str] = field(default_factory=list)
|
|
56
|
+
zone_metadata: dict[str, Any] = field(default_factory=dict)
|
|
57
|
+
|
|
58
|
+
def to_dict(self) -> dict[str, Any]:
|
|
59
|
+
data = asdict(self)
|
|
60
|
+
data.pop("path", None)
|
|
61
|
+
return data
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class ClosureContract:
|
|
66
|
+
closure_conditions: list[str]
|
|
67
|
+
exit_enum: list[str]
|
|
68
|
+
handoff_policy: str
|
|
69
|
+
worklist_policy: str
|
|
70
|
+
|
|
71
|
+
def to_dict(self) -> dict[str, Any]:
|
|
72
|
+
return asdict(self)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass(frozen=True)
|
|
76
|
+
class SkillCatalogEntry:
|
|
77
|
+
skill_id: str
|
|
78
|
+
title: str
|
|
79
|
+
summary: str
|
|
80
|
+
maturity: str
|
|
81
|
+
intent: list[str]
|
|
82
|
+
target_artifacts: list[str]
|
|
83
|
+
applies_when: list[str]
|
|
84
|
+
not_for: list[str]
|
|
85
|
+
required_knowledge: list[dict[str, Any]]
|
|
86
|
+
required_tools: list[dict[str, Any]]
|
|
87
|
+
inputs: list[str]
|
|
88
|
+
outputs: list[str]
|
|
89
|
+
closure_contract: ClosureContract
|
|
90
|
+
meta_content: str
|
|
91
|
+
meta_links: list[dict[str, str]]
|
|
92
|
+
skill_content: str
|
|
93
|
+
skill_links: list[dict[str, str]]
|
|
94
|
+
path: str
|
|
95
|
+
meta_path: str
|
|
96
|
+
context_size: dict[str, Any]
|
|
97
|
+
# Skill-centric consolidation (design 083/084): the capability/tuning/
|
|
98
|
+
# responsibility triad is the Skill meta identity and routing vocabulary,
|
|
99
|
+
# and preconditions/knowledge_slots are the declared needs that replace
|
|
100
|
+
# capability_refs binding and static knowledge_refs. Surfaced as an additive
|
|
101
|
+
# superset; empty until skill metas migrate to the new fields.
|
|
102
|
+
capability: str = ""
|
|
103
|
+
tuning: str = ""
|
|
104
|
+
responsibility: str = ""
|
|
105
|
+
preconditions: list[str] = field(default_factory=list)
|
|
106
|
+
knowledge_slots: list[dict[str, Any]] = field(default_factory=list)
|
|
107
|
+
missing: list[str] = field(default_factory=list)
|
|
108
|
+
zone_metadata: dict[str, Any] = field(default_factory=dict)
|
|
109
|
+
|
|
110
|
+
def to_dict(self) -> dict[str, Any]:
|
|
111
|
+
data = asdict(self)
|
|
112
|
+
data["closure_contract"] = self.closure_contract.to_dict()
|
|
113
|
+
return data
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass(frozen=True)
|
|
117
|
+
class SkillRankResult:
|
|
118
|
+
skill_id: str
|
|
119
|
+
summary: str
|
|
120
|
+
maturity: str
|
|
121
|
+
matched_facets: list[str]
|
|
122
|
+
matched_categories: dict[str, list[str]]
|
|
123
|
+
closure_preview: ClosureContract
|
|
124
|
+
required_knowledge: list[dict[str, Any]]
|
|
125
|
+
execution_readiness: dict[str, Any]
|
|
126
|
+
score: float
|
|
127
|
+
|
|
128
|
+
def to_dict(self) -> dict[str, Any]:
|
|
129
|
+
data = asdict(self)
|
|
130
|
+
data["closure_preview"] = self.closure_preview.to_dict()
|
|
131
|
+
return data
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@dataclass(frozen=True)
|
|
135
|
+
class StartupReference:
|
|
136
|
+
xid: str
|
|
137
|
+
title: str
|
|
138
|
+
layer: Literal["base_control", "xref_routing"]
|
|
139
|
+
required_at_init: bool
|
|
140
|
+
summary: str
|
|
141
|
+
content: str | None
|
|
142
|
+
links: list[dict[str, str]]
|
|
143
|
+
content_hash: str | None = None
|
|
144
|
+
cache_status: Literal["miss", "modified", "not_modified", "bypassed"] = "miss"
|
|
145
|
+
content_omitted: bool = False
|
|
146
|
+
included_in_startup_contract_pack: bool = False
|
|
147
|
+
cache_policy: dict[str, Any] = field(default_factory=dict)
|
|
148
|
+
repository_fingerprint: str | None = None
|
|
149
|
+
|
|
150
|
+
def to_dict(self) -> dict[str, Any]:
|
|
151
|
+
return asdict(self)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass(frozen=True)
|
|
155
|
+
class XRefDocument:
|
|
156
|
+
xid: str
|
|
157
|
+
title: str
|
|
158
|
+
path: str
|
|
159
|
+
summary: str
|
|
160
|
+
content: str
|
|
161
|
+
links: list[dict[str, str]]
|
|
162
|
+
content_hash: str
|
|
163
|
+
|
|
164
|
+
def to_dict(self) -> dict[str, Any]:
|
|
165
|
+
data = asdict(self)
|
|
166
|
+
data.pop("path", None)
|
|
167
|
+
return data
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@dataclass(frozen=True)
|
|
171
|
+
class RuntimeRoleContract:
|
|
172
|
+
roles: dict[str, str]
|
|
173
|
+
phases: list[str]
|
|
174
|
+
statuses: list[str]
|
|
175
|
+
invariants: list[str]
|
|
176
|
+
required_commands: list[str]
|
|
177
|
+
source_xids: list[str]
|
|
178
|
+
|
|
179
|
+
def to_dict(self) -> dict[str, Any]:
|
|
180
|
+
return asdict(self)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@dataclass(frozen=True)
|
|
184
|
+
class ClientObligation:
|
|
185
|
+
id: str
|
|
186
|
+
level: Literal["must", "should", "may"]
|
|
187
|
+
applies_when: str
|
|
188
|
+
statement: str
|
|
189
|
+
enforcement_owner: Literal["client", "server", "human"]
|
|
190
|
+
verification: str
|
|
191
|
+
|
|
192
|
+
def to_dict(self) -> dict[str, Any]:
|
|
193
|
+
return asdict(self)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@dataclass(frozen=True)
|
|
197
|
+
class ClientToolFile:
|
|
198
|
+
path: str
|
|
199
|
+
kind: Literal["python", "support", "documentation"]
|
|
200
|
+
content: str
|
|
201
|
+
content_hash: str
|
|
202
|
+
size_bytes: int
|
|
203
|
+
run_hint: str | None
|
|
204
|
+
imports: list[str] = field(default_factory=list)
|
|
205
|
+
links: list[dict[str, str]] = field(default_factory=list)
|
|
206
|
+
|
|
207
|
+
def to_dict(self) -> dict[str, Any]:
|
|
208
|
+
return asdict(self)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@dataclass(frozen=True)
|
|
212
|
+
class ClientToolManifestEntry:
|
|
213
|
+
path: str
|
|
214
|
+
kind: Literal["python", "support", "documentation"]
|
|
215
|
+
content_hash: str
|
|
216
|
+
size_bytes: int
|
|
217
|
+
run_hint: str | None
|
|
218
|
+
resolver_tool: str
|
|
219
|
+
resolver_argument: str
|
|
220
|
+
|
|
221
|
+
def to_dict(self) -> dict[str, Any]:
|
|
222
|
+
return asdict(self)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@dataclass(frozen=True)
|
|
226
|
+
class ClientToolDistribution:
|
|
227
|
+
package_id: str
|
|
228
|
+
version: str
|
|
229
|
+
execution_location: Literal["client"]
|
|
230
|
+
server_executes_tools: bool
|
|
231
|
+
install_layout: str
|
|
232
|
+
required_package_ids: list[str]
|
|
233
|
+
package_versions: dict[str, str]
|
|
234
|
+
file_hash_algorithm: str
|
|
235
|
+
version_check_tool: str
|
|
236
|
+
materialization: dict[str, Any]
|
|
237
|
+
update_policy: dict[str, Any]
|
|
238
|
+
files: list[ClientToolManifestEntry]
|
|
239
|
+
instructions: list[str]
|
|
240
|
+
|
|
241
|
+
def to_dict(self) -> dict[str, Any]:
|
|
242
|
+
return {
|
|
243
|
+
"package_id": self.package_id,
|
|
244
|
+
"version": self.version,
|
|
245
|
+
"execution_location": self.execution_location,
|
|
246
|
+
"server_executes_tools": self.server_executes_tools,
|
|
247
|
+
"install_layout": self.install_layout,
|
|
248
|
+
"required_package_ids": self.required_package_ids,
|
|
249
|
+
"package_versions": self.package_versions,
|
|
250
|
+
"file_hash_algorithm": self.file_hash_algorithm,
|
|
251
|
+
"version_check_tool": self.version_check_tool,
|
|
252
|
+
"materialization": self.materialization,
|
|
253
|
+
"update_policy": self.update_policy,
|
|
254
|
+
"files": [file.to_dict() for file in self.files],
|
|
255
|
+
"instructions": self.instructions,
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@dataclass(frozen=True)
|
|
260
|
+
class ClientToolPipPackage:
|
|
261
|
+
filename: str
|
|
262
|
+
package_id: str
|
|
263
|
+
version: str
|
|
264
|
+
package_format: Literal["zip-sdist"]
|
|
265
|
+
install_command: str
|
|
266
|
+
content_base64: str
|
|
267
|
+
content_hash: str
|
|
268
|
+
size_bytes: int
|
|
269
|
+
warnings: list[str]
|
|
270
|
+
|
|
271
|
+
def to_dict(self) -> dict[str, Any]:
|
|
272
|
+
return asdict(self)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@dataclass(frozen=True)
|
|
276
|
+
class StartupContext:
|
|
277
|
+
catalog_version: str
|
|
278
|
+
repository_identity: dict[str, str]
|
|
279
|
+
access_policy: dict[str, Any]
|
|
280
|
+
context_injection_policy: dict[str, Any]
|
|
281
|
+
session_context_deduplication: dict[str, Any]
|
|
282
|
+
core_runtime_distribution: dict[str, Any]
|
|
283
|
+
repository_zones: dict[str, Any]
|
|
284
|
+
client_instructions: list[str]
|
|
285
|
+
client_obligations: list[ClientObligation]
|
|
286
|
+
link_resolution: dict[str, str]
|
|
287
|
+
load_order: list[str]
|
|
288
|
+
startup_contract_pack: dict[str, Any]
|
|
289
|
+
references: list[StartupReference]
|
|
290
|
+
semantic_routing_references: list[dict[str, Any]]
|
|
291
|
+
missing: list[dict[str, str]]
|
|
292
|
+
|
|
293
|
+
def to_dict(self) -> dict[str, Any]:
|
|
294
|
+
return {
|
|
295
|
+
"catalog_version": self.catalog_version,
|
|
296
|
+
"repository_identity": self.repository_identity,
|
|
297
|
+
"access_policy": self.access_policy,
|
|
298
|
+
"context_injection_policy": self.context_injection_policy,
|
|
299
|
+
"session_context_deduplication": self.session_context_deduplication,
|
|
300
|
+
"core_runtime_distribution": self.core_runtime_distribution,
|
|
301
|
+
"repository_zones": self.repository_zones,
|
|
302
|
+
"client_instructions": self.client_instructions,
|
|
303
|
+
"client_obligations": [
|
|
304
|
+
obligation.to_dict() for obligation in self.client_obligations
|
|
305
|
+
],
|
|
306
|
+
"link_resolution": self.link_resolution,
|
|
307
|
+
"load_order": self.load_order,
|
|
308
|
+
"startup_contract_pack": self.startup_contract_pack,
|
|
309
|
+
"references": [reference.to_dict() for reference in self.references],
|
|
310
|
+
"semantic_routing_references": self.semantic_routing_references,
|
|
311
|
+
"missing": self.missing,
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def _json_schema_object(schema: dict[str, Any]) -> dict[str, Any]:
|
|
316
|
+
properties: dict[str, Any] = {}
|
|
317
|
+
required: list[str] = []
|
|
318
|
+
for name, descriptor in schema.items():
|
|
319
|
+
optional = isinstance(descriptor, str) and descriptor.endswith("?")
|
|
320
|
+
if not optional:
|
|
321
|
+
required.append(name)
|
|
322
|
+
properties[name] = _json_schema_for_descriptor(descriptor)
|
|
323
|
+
result: dict[str, Any] = {
|
|
324
|
+
"type": "object",
|
|
325
|
+
"properties": properties,
|
|
326
|
+
"additionalProperties": False,
|
|
327
|
+
}
|
|
328
|
+
if required:
|
|
329
|
+
result["required"] = required
|
|
330
|
+
return result
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def _json_schema_for_descriptor(descriptor: Any) -> dict[str, Any]:
|
|
334
|
+
if isinstance(descriptor, dict):
|
|
335
|
+
return descriptor
|
|
336
|
+
if not isinstance(descriptor, str):
|
|
337
|
+
return {"description": str(descriptor)}
|
|
338
|
+
base = descriptor.removesuffix("?")
|
|
339
|
+
if base == "string":
|
|
340
|
+
return {"type": "string"}
|
|
341
|
+
if base == "integer":
|
|
342
|
+
return {"type": "integer"}
|
|
343
|
+
if base == "boolean":
|
|
344
|
+
return {"type": "boolean"}
|
|
345
|
+
if base == "object":
|
|
346
|
+
return {"type": "object"}
|
|
347
|
+
if base == "array":
|
|
348
|
+
return {"type": "array"}
|
|
349
|
+
return {"description": base}
|