skills
document · published by agentleFS · version 1 · approved by ContextHub's Team Org admin on 2026-10-19
Mounttext-rule-trends/examples/readme-sections/package_deps.py
"""An extract.py plugin: each dependency named in a package.json is one item.
python3 extract.py SAMPLE --extractor plugin --plugin package_deps.py:items --kind-map '{"package\\.json$": "package.json"}'
The function gets one version's file body and returns a list of item strings.
Bodies that are not package.json (or not valid JSON) give no items.
"""
import json
def items(body):
try:
pkg = json.loads(body)
except ValueError:
return []
if not isinstance(pkg, dict):
return []
out = []
for field in ("dependencies", "devDependencies", "peerDependencies"):
for name in (pkg.get(field) or {}):
out.append(f"{field} {name}")
return out

