Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/manus_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ def _run_variants(argv: list[str]) -> int:
"poc-search",
"changelog",
"blast-radius",
"temporal-priority",
}


Expand Down Expand Up @@ -1935,6 +1936,69 @@ def _run_blast_radius(argv: list[str]) -> int:
return 0


# ---------------------------------------------------------------------------
# temporal-priority subcommand
# ---------------------------------------------------------------------------


def _build_temporal_priority_parser() -> argparse.ArgumentParser:
p = argparse.ArgumentParser(
prog="manus-agent temporal-priority",
description=(
"Compute a 0–100 temporal priority (urgency) score for a CVE combining\n"
"CVSS base score, current EPSS, EPSS spike recency, CISA KEV membership,\n"
"patch availability, and CVE age."
),
add_help=True,
)
p.add_argument("cve_id", metavar="CVE-ID", help="CVE identifier, e.g. CVE-2024-3094")
p.add_argument(
"--output",
choices=["text", "json"],
default="text",
help="Output format (default: text)",
)
return p


def _run_temporal_priority(argv: list[str]) -> int:
import json as _json

parser = _build_temporal_priority_parser()
args = parser.parse_args(argv)
cve_id = args.cve_id.strip()
if not cve_id:
parser.error("CVE-ID is required")

try:
from manus_agent.tools.get_temporal_priority import (
compute_temporal_priority,
render_text,
)
except ImportError as exc: # pragma: no cover
print(f"[error] missing dependencies: {exc}", file=sys.stderr)
return 1

import re as _re

if not _re.match(r"^CVE-\d{4}-\d{4,}$", cve_id, _re.IGNORECASE):
print(f"[error] Invalid CVE format: '{cve_id}'. Expected: CVE-YYYY-NNNNN", file=sys.stderr)
return 1

try:
result = compute_temporal_priority(cve_id)
except Exception as exc:
print(f"[error] Failed to compute temporal priority: {exc}", file=sys.stderr)
return 1

if args.output == "json":
print(_json.dumps(result, indent=2))
return 0

print(render_text(result))
return 0


def _build_run_parser() -> argparse.ArgumentParser:
"""Build the top-level run/interactive parser."""
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -2269,6 +2333,10 @@ def main() -> None:
idx = argv.index("blast-radius")
sys.exit(_run_blast_radius(argv[idx + 1 :]))

if first_positional == "temporal-priority":
idx = argv.index("temporal-priority")
sys.exit(_run_temporal_priority(argv[idx + 1 :]))

if first_positional == "discover":
idx = argv.index("discover")
discover_args = _build_discover_parser().parse_args(argv[idx + 1 :])
Expand Down
Loading
Loading