@yandy-r/ycc-opencode 6.3.1 → 6.4.0
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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/registration.json +11 -0
- package/skills/mcp-parity/SKILL.md +303 -0
- package/skills/mcp-parity/references/inventory-format.md +171 -0
- package/skills/mcp-parity/references/linear-sync.md +194 -0
- package/skills/mcp-parity/references/milestones-priority.md +91 -0
- package/skills/mcp-parity/references/research-agents.md +122 -0
- package/skills/mcp-parity/scripts/capability_diff.py +525 -0
- package/skills/mcp-parity/scripts/detect-api-surface.sh +109 -0
- package/skills/mcp-parity/scripts/openapi_inventory.py +253 -0
- package/skills/mcp-parity/templates/capability-issue.md +38 -0
- package/skills/mcp-parity/templates/foundation-issue.md +35 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build an mcp-parity capability inventory from an OpenAPI 3.x document.
|
|
3
|
+
|
|
4
|
+
Usage: openapi_inventory.py SPEC [--exclude REGEX ...] [--no-default-excludes]
|
|
5
|
+
|
|
6
|
+
SPEC is JSON, or YAML when PyYAML is installed. Prints inventory JSON on stdout:
|
|
7
|
+
``{"schema": 1, "source": SPEC, "capabilities": [...], "excluded": [...]}``.
|
|
8
|
+
Operations are deterministic and sorted, so repeated runs on an unchanged spec
|
|
9
|
+
produce identical fingerprints. Exit 0 on success, 1 on invalid input.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import re
|
|
17
|
+
import sys
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
METHODS = ("get", "put", "post", "delete", "patch", "head", "options")
|
|
22
|
+
DEFAULT_EXCLUDES = (
|
|
23
|
+
r"^/(api/)?(v\d+/)?(health|healthz|livez|readyz?|ping|metrics|status)/?$",
|
|
24
|
+
r"/(oauth2?|\.well-known)(/|$)",
|
|
25
|
+
r"/auth/(login|logout|callback|refresh|token)(/|$)",
|
|
26
|
+
r"/webhooks?(/|$)",
|
|
27
|
+
)
|
|
28
|
+
ID_CLEAN_RE = re.compile(r"[^a-z0-9]+")
|
|
29
|
+
CAMEL_RE = re.compile(r"(?<=[a-z0-9])(?=[A-Z])")
|
|
30
|
+
LEADING_VERBS = frozenset(
|
|
31
|
+
"list get create update delete remove add set search patch replace upsert send run start stop".split()
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class InputError(ValueError):
|
|
36
|
+
"""Raised for unreadable or non-OpenAPI input."""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def load_spec(path: Path) -> dict[str, Any]:
|
|
40
|
+
"""Load an OpenAPI document from JSON or YAML."""
|
|
41
|
+
if not path.is_file():
|
|
42
|
+
raise InputError(f"spec not found: {path}")
|
|
43
|
+
text = path.read_text(encoding="utf-8")
|
|
44
|
+
data: Any
|
|
45
|
+
if path.suffix == ".json":
|
|
46
|
+
try:
|
|
47
|
+
data = json.loads(text)
|
|
48
|
+
except json.JSONDecodeError as exc:
|
|
49
|
+
raise InputError(f"{path} is not valid JSON: {exc}") from exc
|
|
50
|
+
else:
|
|
51
|
+
try:
|
|
52
|
+
import yaml
|
|
53
|
+
except ImportError as exc:
|
|
54
|
+
raise InputError("PyYAML is required for YAML specs (python3 -m pip install --user pyyaml)") from exc
|
|
55
|
+
try:
|
|
56
|
+
data = yaml.safe_load(text)
|
|
57
|
+
except yaml.YAMLError as exc:
|
|
58
|
+
raise InputError(f"{path} is not valid YAML: {exc}") from exc
|
|
59
|
+
if not isinstance(data, dict) or not isinstance(data.get("paths"), dict):
|
|
60
|
+
raise InputError(f"{path} has no OpenAPI 'paths' object")
|
|
61
|
+
if not str(data.get("openapi", "")).startswith("3"):
|
|
62
|
+
raise InputError(f"{path} is not OpenAPI 3.x (swagger 2 is unsupported; convert it first)")
|
|
63
|
+
return data
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _ref_name(ref: str) -> str:
|
|
67
|
+
return ref.rsplit("/", 1)[-1]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def type_name(schema: Any, depth: int = 0) -> str:
|
|
71
|
+
"""Return a short, stable type spelling for a schema."""
|
|
72
|
+
if not isinstance(schema, dict):
|
|
73
|
+
return "any"
|
|
74
|
+
if "$ref" in schema:
|
|
75
|
+
return _ref_name(str(schema["$ref"]))
|
|
76
|
+
for combo in ("oneOf", "anyOf", "allOf"):
|
|
77
|
+
if isinstance(schema.get(combo), list) and depth < 3:
|
|
78
|
+
sep = " & " if combo == "allOf" else " | "
|
|
79
|
+
return sep.join(type_name(s, depth + 1) for s in schema[combo])
|
|
80
|
+
kind = schema.get("type")
|
|
81
|
+
if isinstance(kind, list):
|
|
82
|
+
kind = "|".join(str(k) for k in kind)
|
|
83
|
+
if kind == "array":
|
|
84
|
+
return f"{type_name(schema.get('items'), depth + 1)}[]"
|
|
85
|
+
if kind == "object" or (kind is None and "properties" in schema):
|
|
86
|
+
return "object"
|
|
87
|
+
if "enum" in schema and isinstance(schema["enum"], list):
|
|
88
|
+
return "enum(" + ",".join(str(v) for v in schema["enum"]) + ")"
|
|
89
|
+
return str(kind or "any")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _resolve(spec: dict[str, Any], obj: Any) -> Any:
|
|
93
|
+
"""Resolve one local $ref (parameters, requestBodies, responses)."""
|
|
94
|
+
if isinstance(obj, dict) and isinstance(obj.get("$ref"), str) and obj["$ref"].startswith("#/"):
|
|
95
|
+
node: Any = spec
|
|
96
|
+
for part in obj["$ref"][2:].split("/"):
|
|
97
|
+
node = node.get(part) if isinstance(node, dict) else None
|
|
98
|
+
return node if node is not None else obj
|
|
99
|
+
return obj
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def make_id(method: str, path: str, op: dict[str, Any]) -> str:
|
|
103
|
+
"""Derive a durable capability id: operationId when present, else area.verb from the path."""
|
|
104
|
+
op_id = op.get("operationId")
|
|
105
|
+
if isinstance(op_id, str) and op_id.strip():
|
|
106
|
+
words = [w for w in ID_CLEAN_RE.sub(".", CAMEL_RE.sub(".", op_id.strip()).lower()).split(".") if w]
|
|
107
|
+
if len(words) > 1 and words[0] in LEADING_VERBS:
|
|
108
|
+
words = [*words[1:], words[0]] # listActivity -> activity.list
|
|
109
|
+
return ".".join(words)[:128] or "op"
|
|
110
|
+
segments = [s for s in path.strip("/").split("/") if s and not s.startswith("{")]
|
|
111
|
+
segments = [s for s in segments if not re.fullmatch(r"(api|v\d+)", s)]
|
|
112
|
+
by_id = path.rstrip("/").endswith("}")
|
|
113
|
+
verb = {
|
|
114
|
+
"get": "get" if by_id else "list",
|
|
115
|
+
"post": "create",
|
|
116
|
+
"put": "replace",
|
|
117
|
+
"patch": "update",
|
|
118
|
+
"delete": "delete",
|
|
119
|
+
}.get(method, method)
|
|
120
|
+
base = ".".join(ID_CLEAN_RE.sub("-", s.lower()).strip("-") for s in segments) or "root"
|
|
121
|
+
return f"{base}.{verb}"[:128]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _inputs(spec: dict[str, Any], path_item: dict[str, Any], op: dict[str, Any]) -> dict[str, Any]:
|
|
125
|
+
params: dict[tuple[str, str], Any] = {}
|
|
126
|
+
for raw in [*path_item.get("parameters", []), *op.get("parameters", [])]:
|
|
127
|
+
param = _resolve(spec, raw)
|
|
128
|
+
if isinstance(param, dict) and isinstance(param.get("name"), str):
|
|
129
|
+
params[(str(param.get("in", "query")), param["name"])] = param
|
|
130
|
+
inputs: dict[str, dict[str, str]] = {}
|
|
131
|
+
for (where, name), param in sorted(params.items()):
|
|
132
|
+
if where == "header" or where == "cookie":
|
|
133
|
+
continue
|
|
134
|
+
optional = "" if param.get("required") or where == "path" else "?"
|
|
135
|
+
inputs.setdefault(where, {})[name] = type_name(param.get("schema")) + optional
|
|
136
|
+
body = _resolve(spec, op.get("requestBody"))
|
|
137
|
+
if isinstance(body, dict) and isinstance(body.get("content"), dict):
|
|
138
|
+
media: Any = body["content"].get("application/json") or next(iter(body["content"].values()), {})
|
|
139
|
+
optional = "" if body.get("required") else "?"
|
|
140
|
+
inputs["body"] = {"type": type_name(media.get("schema") if isinstance(media, dict) else None) + optional}
|
|
141
|
+
return inputs
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _outputs(spec: dict[str, Any], op: dict[str, Any]) -> str:
|
|
145
|
+
responses = op.get("responses")
|
|
146
|
+
if not isinstance(responses, dict):
|
|
147
|
+
return ""
|
|
148
|
+
for code in sorted(str(c) for c in responses):
|
|
149
|
+
if not code.startswith("2"):
|
|
150
|
+
continue
|
|
151
|
+
resp = _resolve(spec, responses.get(code) or responses.get(int(code) if code.isdigit() else code))
|
|
152
|
+
content = resp.get("content") if isinstance(resp, dict) else None
|
|
153
|
+
if not isinstance(content, dict) or not content:
|
|
154
|
+
return "none" if code == "204" else ""
|
|
155
|
+
media = content.get("application/json") or next(iter(content.values()))
|
|
156
|
+
return type_name(media.get("schema") if isinstance(media, dict) else None)
|
|
157
|
+
return ""
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def auth_schemes(spec: dict[str, Any], op: dict[str, Any]) -> list[str] | None:
|
|
161
|
+
"""Security scheme names for an operation; None when the spec declares none."""
|
|
162
|
+
security = op.get("security", spec.get("security"))
|
|
163
|
+
if not isinstance(security, list):
|
|
164
|
+
return None
|
|
165
|
+
return sorted({name for req in security if isinstance(req, dict) for name in req})
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def auth_class(schemes: list[str] | None) -> str:
|
|
169
|
+
"""Collapse scheme names to the inventory auth classes."""
|
|
170
|
+
if schemes is None:
|
|
171
|
+
return "unspecified"
|
|
172
|
+
if not schemes:
|
|
173
|
+
return "public"
|
|
174
|
+
if any("admin" in name.lower() for name in schemes):
|
|
175
|
+
return "admin"
|
|
176
|
+
return "user"
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def build_inventory(spec: dict[str, Any], excludes: list[str], source: str = "") -> dict[str, Any]:
|
|
180
|
+
"""Return inventory JSON for every non-excluded, non-deprecated operation."""
|
|
181
|
+
patterns = [re.compile(p) for p in excludes]
|
|
182
|
+
caps: list[dict[str, Any]] = []
|
|
183
|
+
excluded: list[dict[str, str]] = []
|
|
184
|
+
seen: dict[str, int] = {}
|
|
185
|
+
for path in sorted(spec["paths"]):
|
|
186
|
+
path_item = spec["paths"][path]
|
|
187
|
+
if not isinstance(path_item, dict):
|
|
188
|
+
continue
|
|
189
|
+
for method in METHODS:
|
|
190
|
+
op = path_item.get(method)
|
|
191
|
+
if not isinstance(op, dict):
|
|
192
|
+
continue
|
|
193
|
+
operation = f"{method.upper()} {path}"
|
|
194
|
+
if method in ("head", "options"):
|
|
195
|
+
excluded.append({"operation": operation, "reason": "protocol method"})
|
|
196
|
+
continue
|
|
197
|
+
if op.get("deprecated") is True:
|
|
198
|
+
excluded.append({"operation": operation, "reason": "deprecated"})
|
|
199
|
+
continue
|
|
200
|
+
hit = next((p.pattern for p in patterns if p.search(path)), None)
|
|
201
|
+
if hit:
|
|
202
|
+
excluded.append({"operation": operation, "reason": f"matches {hit}"})
|
|
203
|
+
continue
|
|
204
|
+
cid = make_id(method, path, op)
|
|
205
|
+
seen[cid] = seen.get(cid, 0) + 1
|
|
206
|
+
if seen[cid] > 1:
|
|
207
|
+
cid = f"{cid}.{seen[cid]}"
|
|
208
|
+
tags = op.get("tags") if isinstance(op.get("tags"), list) else []
|
|
209
|
+
segments = [s for s in path.strip("/").split("/") if s and not s.startswith("{")]
|
|
210
|
+
area = str(tags[0]) if tags else (segments[-1] if segments else "root")
|
|
211
|
+
caps.append(
|
|
212
|
+
{
|
|
213
|
+
"id": cid,
|
|
214
|
+
"kind": "tool",
|
|
215
|
+
"operation": operation,
|
|
216
|
+
"summary": str(op.get("summary") or op.get("description") or "").strip().split("\n")[0][:200],
|
|
217
|
+
"area": ID_CLEAN_RE.sub("-", area.lower()).strip("-") or "root",
|
|
218
|
+
"inputs": _inputs(spec, path_item, op),
|
|
219
|
+
"outputs": _outputs(spec, op),
|
|
220
|
+
"mutating": method != "get",
|
|
221
|
+
"destructive": method == "delete",
|
|
222
|
+
"auth": auth_class(auth_schemes(spec, op)),
|
|
223
|
+
"authSchemes": auth_schemes(spec, op) or [],
|
|
224
|
+
"surface": "rest",
|
|
225
|
+
"source": source,
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
return {"schema": 1, "source": source, "capabilities": caps, "excluded": excluded}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def main(argv: list[str] | None = None) -> int:
|
|
232
|
+
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
233
|
+
parser.add_argument("spec", help="OpenAPI 3.x document (.json, or .yaml/.yml with PyYAML)")
|
|
234
|
+
parser.add_argument("--exclude", action="append", default=[], help="extra path regex to exclude (repeatable)")
|
|
235
|
+
parser.add_argument("--no-default-excludes", action="store_true", help="keep health/auth/webhook paths")
|
|
236
|
+
args = parser.parse_args(argv)
|
|
237
|
+
try:
|
|
238
|
+
excludes = [*([] if args.no_default_excludes else DEFAULT_EXCLUDES), *args.exclude]
|
|
239
|
+
for pattern in excludes:
|
|
240
|
+
try:
|
|
241
|
+
re.compile(pattern)
|
|
242
|
+
except re.error as exc:
|
|
243
|
+
raise InputError(f"invalid --exclude regex {pattern!r}: {exc}") from exc
|
|
244
|
+
spec = load_spec(Path(args.spec))
|
|
245
|
+
print(json.dumps(build_inventory(spec, excludes, args.spec), indent=2))
|
|
246
|
+
return 0
|
|
247
|
+
except InputError as exc:
|
|
248
|
+
print(f"openapi_inventory: {exc}", file=sys.stderr)
|
|
249
|
+
return 1
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
if __name__ == "__main__":
|
|
253
|
+
sys.exit(main())
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Capability issue body
|
|
2
|
+
|
|
3
|
+
Fill `{…}`. Drop a section only when it has nothing true to say. Keep the Agent notes
|
|
4
|
+
lines exactly: lookup and rebuild parse them.
|
|
5
|
+
|
|
6
|
+
```markdown
|
|
7
|
+
Expose `{operation}` as an MCP {kind} so agents can {summary, lowercase verb phrase}.
|
|
8
|
+
|
|
9
|
+
## Contract
|
|
10
|
+
|
|
11
|
+
- Operation: `{operation}` ({surface})
|
|
12
|
+
- MCP name: `{suggested tool/resource name, snake_case, e.g. users_list}`
|
|
13
|
+
- Inputs: {normalized inputs, one bullet per parameter with type and optional marker}
|
|
14
|
+
- Output: {outputs}
|
|
15
|
+
- Auth: {auth} — {how the MCP caller's identity maps to the app's check}
|
|
16
|
+
- Side effects: {none | mutating | destructive: what is changed or lost}
|
|
17
|
+
|
|
18
|
+
## Done when
|
|
19
|
+
|
|
20
|
+
- [ ] The {kind} calls the same code path as `{operation}`; no duplicated business logic.
|
|
21
|
+
- [ ] Input schema matches the contract above, with descriptions agents can follow.
|
|
22
|
+
- [ ] Annotations set: read-only `{true|false}`, destructive `{true|false}`, idempotent `{true|false}`.
|
|
23
|
+
- [ ] App errors and pagination map to MCP results per the foundation conventions.
|
|
24
|
+
- [ ] A contract test covers success, validation error, and unauthorized access.
|
|
25
|
+
- [ ] The parity check passes with this capability mapped.
|
|
26
|
+
|
|
27
|
+
+++ Agent notes
|
|
28
|
+
|
|
29
|
+
Issue-Kind: {capability | update | removal}
|
|
30
|
+
Capability-ID: {id}
|
|
31
|
+
Fingerprint: {fingerprint}
|
|
32
|
+
Source: {source file:line}
|
|
33
|
+
Area: {area}
|
|
34
|
+
Related existing MCP code: {path or none}
|
|
35
|
+
Depends on: foundation issues for scaffold, auth, errors-pagination.
|
|
36
|
+
|
|
37
|
+
+++
|
|
38
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Foundation issue body
|
|
2
|
+
|
|
3
|
+
Fill `{…}` from the architecture brief (researcher 2) and the MCP practice brief
|
|
4
|
+
(researcher 3). Cite sources inline. Keep the Agent notes lines exactly.
|
|
5
|
+
|
|
6
|
+
```markdown
|
|
7
|
+
{One or two sentences: what this enables for every capability issue.}
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
- Repository: {language, framework, runtime}
|
|
12
|
+
- Existing MCP code: {paths, or "none"}
|
|
13
|
+
- MCP spec revision: {revision} ({source link})
|
|
14
|
+
- SDK: {official SDK and version} ({source link})
|
|
15
|
+
|
|
16
|
+
## Approach
|
|
17
|
+
|
|
18
|
+
{Concrete recommendation for this repo: package location, transport, auth reuse,
|
|
19
|
+
error and pagination mapping, or the parity check design. Name files and commands.}
|
|
20
|
+
|
|
21
|
+
## Done when
|
|
22
|
+
|
|
23
|
+
- [ ] {verifiable outcome 1}
|
|
24
|
+
- [ ] {verifiable outcome 2}
|
|
25
|
+
- [ ] {CI or test command that proves it}
|
|
26
|
+
|
|
27
|
+
+++ Agent notes
|
|
28
|
+
|
|
29
|
+
Issue-Kind: foundation
|
|
30
|
+
Foundation-Key: {key}
|
|
31
|
+
Evidence: {file:line list from the research}
|
|
32
|
+
Open questions: {list, or none}
|
|
33
|
+
|
|
34
|
+
+++
|
|
35
|
+
```
|