@jovianops/cortex 0.3.0 → 1.0.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/.agents/plugins/marketplace.json +7 -7
- package/.claude-plugin/marketplace.json +8 -8
- package/.claude-plugin/plugin.json +2 -2
- package/.cursor-plugin/marketplace.json +3 -3
- package/.cursor-plugin/plugin.json +2 -2
- package/.github/plugin/marketplace.json +146 -0
- package/.github/plugin.json +59 -0
- package/AGENTS.md +1 -1
- package/GEMINI.md +4 -4
- package/README.md +103 -26
- package/checksums.json +65 -51
- package/evals/skill_evals.json +2 -2
- package/gemini-extension.json +2 -2
- package/package.json +6 -3
- package/packs.json +1 -1
- package/plugin.json +2 -2
- package/premium-skills/accessibility-auditor/SKILL.md +1 -1
- package/premium-skills/api-designer/SKILL.md +1 -1
- package/premium-skills/code-migration/SKILL.md +3 -1
- package/premium-skills/code-migration/scripts/migration_inventory.py +62 -0
- package/premium-skills/db-optimizer/SKILL.md +3 -1
- package/premium-skills/db-optimizer/scripts/lint_sql.py +99 -0
- package/premium-skills/devops-pipeline/SKILL.md +1 -1
- package/premium-skills/docker-generator/SKILL.md +1 -1
- package/premium-skills/incident-response/SKILL.md +3 -1
- package/premium-skills/incident-response/scripts/incident_timeline.py +78 -0
- package/premium-skills/observability-setup/SKILL.md +3 -1
- package/premium-skills/observability-setup/scripts/check_slo.py +81 -0
- package/premium-skills/performance-profiler/SKILL.md +3 -1
- package/premium-skills/performance-profiler/scripts/bench_compare.py +62 -0
- package/premium-skills/refactoring-assistant/SKILL.md +3 -1
- package/premium-skills/refactoring-assistant/scripts/complexity_scan.py +69 -0
- package/premium-skills/release-engineering/SKILL.md +1 -1
- package/premium-skills/release-engineering/scripts/semver_bump.py +0 -1
- package/premium-skills/security-auditor/SKILL.md +1 -1
- package/premium-skills/security-auditor/scripts/secret_scan.py +6 -0
- package/premium-skills/terraform-generator/SKILL.md +3 -1
- package/premium-skills/terraform-generator/scripts/lint_terraform.py +111 -0
- package/premium-skills/unit-test-generator/SKILL.md +3 -1
- package/premium-skills/unit-test-generator/scripts/test_skeleton.py +58 -0
- package/schemas/checksums.schema.json +42 -0
- package/schemas/cortex-lock.schema.json +28 -0
- package/schemas/packs.schema.json +31 -0
- package/scripts/__pycache__/eval_skills.cpython-312.pyc +0 -0
- package/scripts/__pycache__/install_skills.cpython-312.pyc +0 -0
- package/scripts/__pycache__/package_skills.cpython-312.pyc +0 -0
- package/scripts/bump_version.py +119 -0
- package/scripts/cortex.py +253 -14
- package/scripts/install_skills.py +63 -13
- package/scripts/package_skills.py +1 -1
- package/scripts/validate_manifests.py +7 -0
- package/scripts/validate_skills.py +0 -1
- package/scripts/validate_yaml.py +45 -16
- package/scripts/verify_site.py +104 -0
- package/skills/academic-assistant/SKILL.md +3 -1
- package/skills/academic-assistant/scripts/citation_check.py +54 -0
- package/skills/anti-hallucination/SKILL.md +3 -1
- package/skills/anti-hallucination/scripts/verify_claims.py +57 -0
- package/skills/blender-3d-modeling/SKILL.md +1 -1
- package/skills/code-review-assistant/SKILL.md +3 -1
- package/skills/code-review-assistant/scripts/diff_review.py +76 -0
- package/skills/college-report-card/SKILL.md +1 -1
- package/skills/documentation-generator/SKILL.md +1 -1
- package/skills/memory-manager/SKILL.md +1 -1
- package/skills/python-coding-assistant/SKILL.md +3 -1
- package/skills/python-coding-assistant/scripts/check_python_ast.py +77 -0
- package/skills/testing-automation/SKILL.md +3 -1
- package/skills/testing-automation/scripts/check_test_coverage_map.py +65 -0
- package/skills/web-scraper/SKILL.md +3 -1
- package/skills/web-scraper/scripts/check_robots.py +50 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jovianops.github.io/cortex/schemas/cortex-lock.schema.json",
|
|
4
|
+
"title": "Cortex Installation Lockfile (.cortex-lock.json v1.0.0)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema_version", "skills"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
9
|
+
"release_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?$" },
|
|
10
|
+
"skills": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"additionalProperties": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"required": ["version", "dir", "installed_at", "files"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"version": { "type": "string" },
|
|
17
|
+
"dir": { "type": "string", "enum": ["skills", "premium-skills"] },
|
|
18
|
+
"installed_at": { "type": "string", "format": "date-time" },
|
|
19
|
+
"files": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": ["SKILL.md"],
|
|
22
|
+
"additionalProperties": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jovianops.github.io/cortex/schemas/packs.schema.json",
|
|
4
|
+
"title": "Cortex Role-Based Skill Packs Manifest (v1.0.0)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schema_version", "release_version", "packs"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
10
|
+
"release_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?$" },
|
|
11
|
+
"packs": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"minProperties": 1,
|
|
14
|
+
"additionalProperties": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": ["label", "description", "skills"],
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"properties": {
|
|
19
|
+
"label": { "type": "string", "minLength": 1 },
|
|
20
|
+
"description": { "type": "string", "minLength": 1 },
|
|
21
|
+
"skills": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"minItems": 1,
|
|
24
|
+
"uniqueItems": true,
|
|
25
|
+
"items": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Atomically bump Cortex release version across all skills, manifests, CLI scripts, ZIPs, checksums, and index.html."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
13
|
+
SEMVER_RE = re.compile(r"^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$")
|
|
14
|
+
|
|
15
|
+
JSON_FILES = (
|
|
16
|
+
"package.json",
|
|
17
|
+
"packs.json",
|
|
18
|
+
"plugin.json",
|
|
19
|
+
"gemini-extension.json",
|
|
20
|
+
".claude-plugin/plugin.json",
|
|
21
|
+
".claude-plugin/marketplace.json",
|
|
22
|
+
".github/plugin.json",
|
|
23
|
+
".github/plugin/marketplace.json",
|
|
24
|
+
".agents/plugins/marketplace.json",
|
|
25
|
+
".cursor-plugin/plugin.json",
|
|
26
|
+
".cursor-plugin/marketplace.json",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
TEXT_FILES = (
|
|
30
|
+
"scripts/cortex.py",
|
|
31
|
+
"scripts/install_skills.py",
|
|
32
|
+
"scripts/package_skills.py",
|
|
33
|
+
"AGENTS.md",
|
|
34
|
+
"GEMINI.md",
|
|
35
|
+
".github/copilot-instructions.md",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def bump_all(new_version: str) -> None:
|
|
40
|
+
pkg_path = ROOT / "package.json"
|
|
41
|
+
old_version = json.loads(pkg_path.read_text(encoding="utf-8"))["version"]
|
|
42
|
+
|
|
43
|
+
# 1. Bump all SKILL.md frontmatter versions
|
|
44
|
+
for folder in ("skills", "premium-skills"):
|
|
45
|
+
for md in sorted((ROOT / folder).glob("*/SKILL.md")):
|
|
46
|
+
text = md.read_text(encoding="utf-8")
|
|
47
|
+
updated, count = re.subn(r"^version:\s*\S+$", f"version: {new_version}", text, count=1, flags=re.M)
|
|
48
|
+
if count != 1:
|
|
49
|
+
raise RuntimeError(f"Could not update version frontmatter in {md}")
|
|
50
|
+
md.write_text(updated, encoding="utf-8")
|
|
51
|
+
|
|
52
|
+
# 2. Bump all JSON manifests + package.json + packs.json
|
|
53
|
+
for rel in JSON_FILES:
|
|
54
|
+
path = ROOT / rel
|
|
55
|
+
updated = path.read_text(encoding="utf-8").replace(old_version, new_version)
|
|
56
|
+
json.loads(updated)
|
|
57
|
+
path.write_text(updated, encoding="utf-8")
|
|
58
|
+
|
|
59
|
+
# 3. Update evals/skill_evals.json metadata (preserving embedded release-engineering prompt fixtures)
|
|
60
|
+
eval_path = ROOT / "evals/skill_evals.json"
|
|
61
|
+
eval_data = json.loads(eval_path.read_text(encoding="utf-8"))
|
|
62
|
+
eval_data["schema_version"] = new_version
|
|
63
|
+
eval_data["description"] = eval_data["description"].replace(f"v{old_version}", f"v{new_version}")
|
|
64
|
+
eval_path.write_text(json.dumps(eval_data, indent=2) + "\n", encoding="utf-8")
|
|
65
|
+
|
|
66
|
+
# 4. Update CLI scripts and agent docs
|
|
67
|
+
for rel in TEXT_FILES:
|
|
68
|
+
path = ROOT / rel
|
|
69
|
+
if path.is_file():
|
|
70
|
+
path.write_text(path.read_text(encoding="utf-8").replace(old_version, new_version), encoding="utf-8")
|
|
71
|
+
|
|
72
|
+
# 5. Rebuild deterministic ZIP archives & checksums.json
|
|
73
|
+
subprocess.run([sys.executable, str(ROOT / "scripts" / "package_skills.py")], cwd=ROOT, check=True)
|
|
74
|
+
|
|
75
|
+
# 6. Sync index.html chrome version, script paths, and all 24 SKILL.md + ZIP SHA-256 digests
|
|
76
|
+
checksums = json.loads((ROOT / "checksums.json").read_text(encoding="utf-8"))
|
|
77
|
+
html_path = ROOT / "index.html"
|
|
78
|
+
html = html_path.read_text(encoding="utf-8")
|
|
79
|
+
for pattern in (
|
|
80
|
+
f"v{old_version}",
|
|
81
|
+
f'<span class="kv-v">{old_version}</span>',
|
|
82
|
+
):
|
|
83
|
+
html = html.replace(pattern, pattern.replace(old_version, new_version))
|
|
84
|
+
|
|
85
|
+
for slug, meta in checksums["skills"].items():
|
|
86
|
+
script_files = [f for f in meta["files"] if f != "SKILL.md"]
|
|
87
|
+
script_val = json.dumps(script_files[0]) if script_files else "null"
|
|
88
|
+
pat = re.compile(
|
|
89
|
+
r'("slug"\s*:\s*"' + re.escape(slug) + r'"[\s\S]*?"script"\s*:\s*)(null|"[^"]*")([\s\S]*?"sha256"\s*:\s*")([0-9a-f]{64})("[\s\S]*?"zipSha256"\s*:\s*")([0-9a-f]{64})(")'
|
|
90
|
+
)
|
|
91
|
+
m = pat.search(html)
|
|
92
|
+
if not m:
|
|
93
|
+
raise RuntimeError(f"Missing skill entry in index.html: {slug}")
|
|
94
|
+
html = (
|
|
95
|
+
html[: m.start(2)]
|
|
96
|
+
+ script_val
|
|
97
|
+
+ html[m.end(2) : m.start(4)]
|
|
98
|
+
+ meta["files"]["SKILL.md"]
|
|
99
|
+
+ html[m.end(4) : m.start(6)]
|
|
100
|
+
+ meta["zip_sha256"]
|
|
101
|
+
+ html[m.end(6) :]
|
|
102
|
+
)
|
|
103
|
+
html_path.write_text(html, encoding="utf-8")
|
|
104
|
+
print(f"Bumped Cortex {old_version} -> {new_version} across all skills, manifests, ZIPs, checksums.json, and index.html.")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def main(argv: list[str] | None = None) -> int:
|
|
108
|
+
parser = argparse.ArgumentParser(description="Atomically bump Cortex release version and rebuild checksums.")
|
|
109
|
+
parser.add_argument("version", help="Target SemVer version (e.g., 1.0.0).")
|
|
110
|
+
args = parser.parse_args(argv)
|
|
111
|
+
if not SEMVER_RE.match(args.version):
|
|
112
|
+
print(f"ERROR: Invalid SemVer version {args.version!r}", file=sys.stderr)
|
|
113
|
+
return 2
|
|
114
|
+
bump_all(args.version)
|
|
115
|
+
return 0
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
raise SystemExit(main())
|
package/scripts/cortex.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""Cortex Unified CLI (
|
|
2
|
+
"""Cortex Unified CLI (v1.0.0) — detect agents, diagnose installs, search skills, install packs, and scaffold new skills.
|
|
3
3
|
|
|
4
4
|
Zero external dependencies (Python 3 stdlib only). Works on Linux, macOS, and Windows.
|
|
5
5
|
|
|
@@ -18,7 +18,6 @@ import argparse
|
|
|
18
18
|
import hashlib
|
|
19
19
|
import importlib.util
|
|
20
20
|
import json
|
|
21
|
-
import os
|
|
22
21
|
import re
|
|
23
22
|
import shutil
|
|
24
23
|
import subprocess
|
|
@@ -27,14 +26,15 @@ from pathlib import Path
|
|
|
27
26
|
|
|
28
27
|
ROOT = Path(__file__).resolve().parents[1]
|
|
29
28
|
SCRIPTS = ROOT / "scripts"
|
|
30
|
-
VERSION = "0.
|
|
29
|
+
VERSION = "1.0.0"
|
|
31
30
|
|
|
32
31
|
AGENT_PROBES: tuple[tuple[str, str, str, str, tuple[str, ...]], ...] = (
|
|
33
32
|
("claude-code", "Claude Code", ".claude", ".claude", ("claude",)),
|
|
34
33
|
("codex", "OpenAI Codex CLI", ".codex", ".agents", ("codex",)),
|
|
35
34
|
("gemini-cli", "Gemini CLI", ".gemini", ".gemini", ("gemini",)),
|
|
36
35
|
("cursor", "Cursor", ".cursor", ".cursor", ("cursor",)),
|
|
37
|
-
("
|
|
36
|
+
("vscode", "Visual Studio Code", ".vscode", ".vscode", ("code", "code-insiders")),
|
|
37
|
+
("copilot", "GitHub Copilot", ".copilot", ".github", ("copilot",)),
|
|
38
38
|
("opencode", "OpenCode", ".config/opencode", ".opencode", ("opencode",)),
|
|
39
39
|
("openclaw", "OpenClaw", ".openclaw", ".openclaw", ("openclaw",)),
|
|
40
40
|
("goose", "Goose", ".config/goose", ".goose", ("goose",)),
|
|
@@ -90,7 +90,12 @@ def detect_agents(project_dir: Path) -> list[dict]:
|
|
|
90
90
|
|
|
91
91
|
# Count locked Cortex skills if present
|
|
92
92
|
locked = 0
|
|
93
|
-
|
|
93
|
+
lock_candidates = (
|
|
94
|
+
(home / ".copilot" / "skills" / ".cortex-lock.json", project_dir / ".github" / "skills" / ".cortex-lock.json")
|
|
95
|
+
if key == "vscode"
|
|
96
|
+
else (global_dir / "skills" / ".cortex-lock.json", project_marker_dir / "skills" / ".cortex-lock.json")
|
|
97
|
+
)
|
|
98
|
+
for candidate in lock_candidates:
|
|
94
99
|
if candidate.is_file():
|
|
95
100
|
try:
|
|
96
101
|
locked += len(json.loads(candidate.read_text(encoding="utf-8")).get("skills", {}))
|
|
@@ -398,23 +403,243 @@ Implement minimal targeted changes, re-run verification checks, and report any r
|
|
|
398
403
|
return 0
|
|
399
404
|
|
|
400
405
|
|
|
406
|
+
def detect_project_stack(project_dir: Path) -> tuple[str, list[str]]:
|
|
407
|
+
"""Recommend a Cortex role pack based on files present in project_dir."""
|
|
408
|
+
signals: list[str] = []
|
|
409
|
+
has_tf = any(project_dir.glob("*.tf")) or (project_dir / "terraform").is_dir()
|
|
410
|
+
has_docker = (project_dir / "Dockerfile").is_file() or (project_dir / "docker-compose.yml").is_file()
|
|
411
|
+
has_ci = (project_dir / ".github" / "workflows").is_dir()
|
|
412
|
+
has_node = (project_dir / "package.json").is_file()
|
|
413
|
+
has_py = (project_dir / "pyproject.toml").is_file() or (project_dir / "requirements.txt").is_file() or (project_dir / "setup.py").is_file()
|
|
414
|
+
|
|
415
|
+
if has_tf:
|
|
416
|
+
signals.append("terraform")
|
|
417
|
+
if has_docker:
|
|
418
|
+
signals.append("docker")
|
|
419
|
+
if has_ci:
|
|
420
|
+
signals.append("github-actions")
|
|
421
|
+
if has_node:
|
|
422
|
+
signals.append("node/web")
|
|
423
|
+
if has_py:
|
|
424
|
+
signals.append("python")
|
|
425
|
+
|
|
426
|
+
if has_tf or (has_docker and has_ci and not has_node):
|
|
427
|
+
return "devops-sre", signals
|
|
428
|
+
if has_py and not has_node:
|
|
429
|
+
return "python-pro", signals
|
|
430
|
+
return "fullstack", signals
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def cmd_init(args: argparse.Namespace) -> int:
|
|
434
|
+
project_dir = args.project_dir.resolve()
|
|
435
|
+
detected = detect_agents(project_dir)
|
|
436
|
+
recommended_pack, stack_signals = detect_project_stack(project_dir)
|
|
437
|
+
pack = args.pack or recommended_pack
|
|
438
|
+
|
|
439
|
+
if args.agent:
|
|
440
|
+
chosen_agents = list(args.agent)
|
|
441
|
+
else:
|
|
442
|
+
installer = load_script("install_skills")
|
|
443
|
+
supported = set(installer.AGENT_TARGETS.keys())
|
|
444
|
+
chosen_agents = [a["agent"] for a in detected if a["detected"] and a["agent"] in supported]
|
|
445
|
+
if not chosen_agents:
|
|
446
|
+
chosen_agents = ["vscode"]
|
|
447
|
+
|
|
448
|
+
install_argv: list[str] = []
|
|
449
|
+
for ag in chosen_agents:
|
|
450
|
+
install_argv.extend(["--agent", ag])
|
|
451
|
+
install_argv.extend(["--pack", pack, "--scope", args.scope, "--project-dir", str(project_dir)])
|
|
452
|
+
if "vscode" in chosen_agents:
|
|
453
|
+
install_argv.append("--write-vscode-settings")
|
|
454
|
+
if "aider" in chosen_agents:
|
|
455
|
+
install_argv.append("--write-aider-conf")
|
|
456
|
+
if args.dry_run:
|
|
457
|
+
install_argv.append("--dry-run")
|
|
458
|
+
|
|
459
|
+
if args.as_json:
|
|
460
|
+
buf_res = subprocess.run(
|
|
461
|
+
[sys.executable, str(SCRIPTS / "install_skills.py"), *install_argv],
|
|
462
|
+
cwd=project_dir,
|
|
463
|
+
check=False,
|
|
464
|
+
capture_output=True,
|
|
465
|
+
text=True,
|
|
466
|
+
)
|
|
467
|
+
print(json.dumps({
|
|
468
|
+
"version": VERSION,
|
|
469
|
+
"project_dir": project_dir.as_posix(),
|
|
470
|
+
"stack_signals": stack_signals,
|
|
471
|
+
"pack": pack,
|
|
472
|
+
"agents": chosen_agents,
|
|
473
|
+
"scope": args.scope,
|
|
474
|
+
"dry_run": args.dry_run,
|
|
475
|
+
"ok": buf_res.returncode == 0,
|
|
476
|
+
"output": buf_res.stdout.strip(),
|
|
477
|
+
"error": buf_res.stderr.strip(),
|
|
478
|
+
}, indent=2))
|
|
479
|
+
return buf_res.returncode
|
|
480
|
+
|
|
481
|
+
print(f"Cortex v{VERSION} — Project Initialization ({project_dir})")
|
|
482
|
+
print(f" Stack signals : {', '.join(stack_signals) or 'generic'}")
|
|
483
|
+
print(f" Selected pack : {pack}")
|
|
484
|
+
print(f" Target agents : {', '.join(chosen_agents)}")
|
|
485
|
+
return delegate("install_skills", install_argv)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
def cmd_info(args: argparse.Namespace) -> int:
|
|
489
|
+
slug = args.slug.strip().lower()
|
|
490
|
+
skill_dir: Path | None = None
|
|
491
|
+
tier = ""
|
|
492
|
+
folder_name = ""
|
|
493
|
+
for folder, t in (("skills", "core"), ("premium-skills", "extended")):
|
|
494
|
+
candidate = ROOT / folder / slug
|
|
495
|
+
if (candidate / "SKILL.md").is_file():
|
|
496
|
+
skill_dir = candidate
|
|
497
|
+
tier = t
|
|
498
|
+
folder_name = folder
|
|
499
|
+
break
|
|
500
|
+
|
|
501
|
+
if skill_dir is None:
|
|
502
|
+
print(f"ERROR: Unknown skill {args.slug!r}. Run `cortex search` to list all skills.", file=sys.stderr)
|
|
503
|
+
return 2
|
|
504
|
+
|
|
505
|
+
meta = parse_skill_frontmatter(skill_dir / "SKILL.md")
|
|
506
|
+
scripts = sorted(
|
|
507
|
+
p.relative_to(skill_dir).as_posix()
|
|
508
|
+
for p in (skill_dir / "scripts").glob("*.py")
|
|
509
|
+
) if (skill_dir / "scripts").is_dir() else []
|
|
510
|
+
|
|
511
|
+
checksums = json.loads((ROOT / "checksums.json").read_text(encoding="utf-8")) if (ROOT / "checksums.json").is_file() else {}
|
|
512
|
+
c_entry = checksums.get("skills", {}).get(slug, {})
|
|
513
|
+
packs_data = json.loads((ROOT / "packs.json").read_text(encoding="utf-8")) if (ROOT / "packs.json").is_file() else {}
|
|
514
|
+
member_packs = [pid for pid, pinfo in packs_data.get("packs", {}).items() if slug in pinfo.get("skills", [])]
|
|
515
|
+
|
|
516
|
+
info = {
|
|
517
|
+
"slug": slug,
|
|
518
|
+
"tier": tier,
|
|
519
|
+
"dir": folder_name,
|
|
520
|
+
"version": meta.get("version", VERSION),
|
|
521
|
+
"description": meta.get("description", ""),
|
|
522
|
+
"tags": meta.get("tags", []),
|
|
523
|
+
"scripts": scripts,
|
|
524
|
+
"packs": member_packs,
|
|
525
|
+
"skill_sha256": c_entry.get("files", {}).get("SKILL.md", ""),
|
|
526
|
+
"zip_sha256": c_entry.get("zip_sha256", ""),
|
|
527
|
+
"install_cmd": f"npx @jovianops/cortex install --agent vscode --skill {slug} --scope project",
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if args.as_json:
|
|
531
|
+
print(json.dumps(info, indent=2))
|
|
532
|
+
return 0
|
|
533
|
+
|
|
534
|
+
print(f"{info['slug']} (v{info['version']} · {info['tier']})")
|
|
535
|
+
print(f" Description : {info['description']}")
|
|
536
|
+
print(f" Path : {info['dir']}/{info['slug']}/SKILL.md")
|
|
537
|
+
print(f" Script : {', '.join(info['scripts']) or 'none'}")
|
|
538
|
+
print(f" Role packs : {', '.join(info['packs']) or 'none'}")
|
|
539
|
+
if info["skill_sha256"]:
|
|
540
|
+
print(f" SKILL SHA256: {info['skill_sha256']}")
|
|
541
|
+
if info["zip_sha256"]:
|
|
542
|
+
print(f" ZIP SHA256 : {info['zip_sha256']}")
|
|
543
|
+
print(f" Install : {info['install_cmd']}")
|
|
544
|
+
return 0
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def cmd_verify(args: argparse.Namespace) -> int:
|
|
548
|
+
project_dir = args.project_dir.resolve()
|
|
549
|
+
checks: list[dict] = []
|
|
550
|
+
|
|
551
|
+
def run_check(name: str, script_name: str, extra: list[str]) -> bool:
|
|
552
|
+
res = subprocess.run(
|
|
553
|
+
[sys.executable, str(SCRIPTS / f"{script_name}.py"), *extra],
|
|
554
|
+
cwd=ROOT,
|
|
555
|
+
check=False,
|
|
556
|
+
capture_output=True,
|
|
557
|
+
text=True,
|
|
558
|
+
)
|
|
559
|
+
checks.append({
|
|
560
|
+
"name": name,
|
|
561
|
+
"ok": res.returncode == 0,
|
|
562
|
+
"detail": (res.stdout.strip() or res.stderr.strip()).splitlines()[-1] if (res.stdout.strip() or res.stderr.strip()) else "",
|
|
563
|
+
})
|
|
564
|
+
return res.returncode == 0
|
|
565
|
+
|
|
566
|
+
all_ok = True
|
|
567
|
+
if (ROOT / "zips").is_dir() and (ROOT / "premium-zips").is_dir():
|
|
568
|
+
all_ok &= run_check("package_checksums", "package_skills", ["--check"])
|
|
569
|
+
elif (ROOT / "checksums.json").is_file():
|
|
570
|
+
manifest = json.loads((ROOT / "checksums.json").read_text(encoding="utf-8"))
|
|
571
|
+
bad: list[str] = []
|
|
572
|
+
for slug, meta in manifest.get("skills", {}).items():
|
|
573
|
+
base_dir = ROOT / meta["dir"] / slug
|
|
574
|
+
for rel, expected in meta.get("files", {}).items():
|
|
575
|
+
fp = base_dir / rel
|
|
576
|
+
if not fp.is_file() or hashlib.sha256(fp.read_bytes().replace(b"\r\n", b"\n")).hexdigest() != expected:
|
|
577
|
+
bad.append(f"{slug}/{rel}")
|
|
578
|
+
ok = not bad
|
|
579
|
+
all_ok &= ok
|
|
580
|
+
checks.append({
|
|
581
|
+
"name": "bundled_checksums",
|
|
582
|
+
"ok": ok,
|
|
583
|
+
"detail": f"Verified {len(manifest.get('skills', {}))} bundled skills." if ok else f"Mismatch: {', '.join(bad)}",
|
|
584
|
+
})
|
|
585
|
+
|
|
586
|
+
all_ok &= run_check("manifests", "validate_manifests", [])
|
|
587
|
+
all_ok &= run_check("evals_and_audit", "eval_skills", [])
|
|
588
|
+
|
|
589
|
+
# Check installed lockfiles under project_dir
|
|
590
|
+
installer = load_script("install_skills")
|
|
591
|
+
lock_issues = 0
|
|
592
|
+
locks_checked = 0
|
|
593
|
+
seen_dests: set[Path] = set()
|
|
594
|
+
for target in installer.AGENT_TARGETS.values():
|
|
595
|
+
dest = installer.destination_dir(target, "project", project_dir)
|
|
596
|
+
if dest in seen_dests:
|
|
597
|
+
continue
|
|
598
|
+
seen_dests.add(dest)
|
|
599
|
+
if (dest / installer.LOCKFILE_NAME).is_file():
|
|
600
|
+
locks_checked += 1
|
|
601
|
+
if installer.cmd_status([target], "project", project_dir) != 0:
|
|
602
|
+
lock_issues += 1
|
|
603
|
+
if locks_checked:
|
|
604
|
+
ok = lock_issues == 0
|
|
605
|
+
all_ok &= ok
|
|
606
|
+
checks.append({
|
|
607
|
+
"name": "project_lockfiles",
|
|
608
|
+
"ok": ok,
|
|
609
|
+
"detail": f"Checked {locks_checked} project lockfile(s), {lock_issues} issue(s).",
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
if args.as_json:
|
|
613
|
+
print(json.dumps({"version": VERSION, "ok": all_ok, "checks": checks}, indent=2))
|
|
614
|
+
else:
|
|
615
|
+
for c in checks:
|
|
616
|
+
tag = "OK" if c["ok"] else "FAIL"
|
|
617
|
+
print(f"[{tag:<4}] {c['name']}: {c['detail']}")
|
|
618
|
+
return 0 if all_ok else 1
|
|
619
|
+
|
|
620
|
+
|
|
401
621
|
def delegate(script_name: str, extra_args: list[str], *, use_root_cwd: bool = False) -> int:
|
|
402
622
|
run_cwd = ROOT if use_root_cwd else Path.cwd()
|
|
403
|
-
res = subprocess.run([sys.executable, str(SCRIPTS / f"{script_name}.py"), *extra_args], cwd=run_cwd)
|
|
623
|
+
res = subprocess.run([sys.executable, str(SCRIPTS / f"{script_name}.py"), *extra_args], check=False, cwd=run_cwd)
|
|
404
624
|
return res.returncode
|
|
405
625
|
|
|
406
626
|
|
|
407
627
|
def main(argv: list[str] | None = None) -> int:
|
|
408
628
|
raw = argv if argv is not None else sys.argv[1:]
|
|
629
|
+
if raw and raw[0] in {"-V", "--version"}:
|
|
630
|
+
print(f"cortex {VERSION}")
|
|
631
|
+
return 0
|
|
409
632
|
if not raw or raw[0] in {"-h", "--help"}:
|
|
410
633
|
print(
|
|
411
634
|
f"Cortex CLI v{VERSION} — Multi-Agent Skill Platform\n\n"
|
|
412
635
|
"Commands:\n"
|
|
636
|
+
" init Auto-detect stack & agents, install recommended pack with SHA-256 checks\n"
|
|
413
637
|
" detect Auto-detect installed AI agents & locked Cortex skills\n"
|
|
414
638
|
" doctor Run environment, lockfile SHA-256, checksum & manifest diagnostics\n"
|
|
639
|
+
" info <slug> Inspect a skill's metadata, bundled script, packs, and SHA-256 hashes\n"
|
|
415
640
|
" search Search all 24 skills by keyword, tier, or bundled script\n"
|
|
416
641
|
" packs List all 6 curated role-based skill packs (packs.json)\n"
|
|
417
|
-
" new <slug> Scaffold a 100/100 audit-ready
|
|
642
|
+
f" new <slug> Scaffold a 100/100 audit-ready v{VERSION} skill (+ optional script)\n"
|
|
418
643
|
" install Install skills/packs locally or --remote (SHA-256 verified)\n"
|
|
419
644
|
" status Verify installed skills against .cortex-lock.json\n"
|
|
420
645
|
" upgrade Upgrade installed skills to latest catalog\n"
|
|
@@ -422,12 +647,28 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
422
647
|
" audit Run 100-point structural quality audit on all skills\n"
|
|
423
648
|
" eval Validate or --run live A/B benchmarks\n"
|
|
424
649
|
" package Rebuild or --check reproducible ZIPs and checksums.json\n"
|
|
425
|
-
" verify Run full manifest
|
|
650
|
+
" verify Run full checksum, manifest, eval & lockfile verification (--json)\n"
|
|
426
651
|
)
|
|
427
652
|
return 0
|
|
428
653
|
|
|
429
654
|
cmd, rest = raw[0], raw[1:]
|
|
430
655
|
|
|
656
|
+
if cmd == "init":
|
|
657
|
+
p = argparse.ArgumentParser(prog="cortex init")
|
|
658
|
+
p.add_argument("--project-dir", type=Path, default=Path.cwd())
|
|
659
|
+
p.add_argument("--agent", "-a", action="append", default=[])
|
|
660
|
+
p.add_argument("--pack", "-p", default=None)
|
|
661
|
+
p.add_argument("--scope", choices=("project", "global"), default="project")
|
|
662
|
+
p.add_argument("--dry-run", action="store_true")
|
|
663
|
+
p.add_argument("--json", action="store_true", dest="as_json")
|
|
664
|
+
return cmd_init(p.parse_args(rest))
|
|
665
|
+
|
|
666
|
+
if cmd == "info":
|
|
667
|
+
p = argparse.ArgumentParser(prog="cortex info")
|
|
668
|
+
p.add_argument("slug", help="Skill slug (e.g., security-auditor).")
|
|
669
|
+
p.add_argument("--json", action="store_true", dest="as_json")
|
|
670
|
+
return cmd_info(p.parse_args(rest))
|
|
671
|
+
|
|
431
672
|
if cmd == "detect":
|
|
432
673
|
p = argparse.ArgumentParser(prog="cortex detect")
|
|
433
674
|
p.add_argument("--project-dir", type=Path, default=Path.cwd())
|
|
@@ -477,12 +718,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
477
718
|
if cmd == "package":
|
|
478
719
|
return delegate("package_skills", rest, use_root_cwd=True)
|
|
479
720
|
if cmd == "verify":
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
rc |= delegate("eval_skills", [], use_root_cwd=True)
|
|
485
|
-
return 1 if rc else 0
|
|
721
|
+
p = argparse.ArgumentParser(prog="cortex verify")
|
|
722
|
+
p.add_argument("--project-dir", type=Path, default=Path.cwd())
|
|
723
|
+
p.add_argument("--json", action="store_true", dest="as_json")
|
|
724
|
+
return cmd_verify(p.parse_args(rest))
|
|
486
725
|
|
|
487
726
|
print(f"ERROR: Unknown cortex subcommand {cmd!r}. Run `cortex --help`.", file=sys.stderr)
|
|
488
727
|
return 2
|