|
38 | 38 | "description": "Apply the latest staged proposal to CLAUDE.md/SKILL.md (backs up first)."}, |
39 | 39 | {"name": "sleep_harvest", "action": "harvest", |
40 | 40 | "description": "Debug: list the recurring tasks mined from recent sessions."}, |
| 41 | + {"name": "sleep_schedule", "action": "schedule", |
| 42 | + "description": "Install a nightly cron entry to run the sleep cycle automatically."}, |
| 43 | + {"name": "sleep_unschedule", "action": "unschedule", |
| 44 | + "description": "Remove the nightly cron entry for a project."}, |
41 | 45 | ] |
42 | 46 | _BY_NAME = {t["name"]: t for t in TOOLS} |
43 | 47 |
|
44 | 48 | _TOOL_SCHEMA = { |
45 | 49 | "type": "object", |
46 | 50 | "properties": { |
47 | | - "project": {"type": "string", "description": "Project dir to evolve (default: cwd)."}, |
| 51 | + "project": {"type": "string", |
| 52 | + "description": "Project dir to evolve (default: cwd)."}, |
48 | 53 | "backend": {"type": "string", "enum": ["mock", "claude", "codex", "copilot"], |
49 | 54 | "description": "mock = no API spend (default); claude/codex/copilot = real."}, |
50 | | - "scope": {"type": "string", "enum": ["invoked", "all"]}, |
| 55 | + "scope": {"type": "string", "enum": ["invoked", "all"], |
| 56 | + "description": "Harvest scope (default: invoked project only)."}, |
| 57 | + "source": {"type": "string", "enum": ["claude", "codex", "auto"], |
| 58 | + "description": "Transcript source (default: claude)."}, |
| 59 | + "model": {"type": "string", |
| 60 | + "description": "Backend-specific model override."}, |
| 61 | + "tasks_file": {"type": "string", |
| 62 | + "description": "Path to reviewed TaskRecord JSON (skips harvest)."}, |
| 63 | + "target_skill_path": {"type": "string", |
| 64 | + "description": "Explicit SKILL.md path to evolve/stage/adopt."}, |
| 65 | + "progress": {"type": "boolean", |
| 66 | + "description": "Print phase progress to stderr."}, |
| 67 | + "max_sessions": {"type": "integer", |
| 68 | + "description": "Cap harvested sessions per run."}, |
| 69 | + "max_tasks": {"type": "integer", |
| 70 | + "description": "Cap mined tasks per run."}, |
| 71 | + "lookback_hours": {"type": "integer", |
| 72 | + "description": "Harvest window in hours (default: 72)."}, |
| 73 | + "auto_adopt": {"type": "boolean", |
| 74 | + "description": "Auto-adopt if gate passes (default: false)."}, |
| 75 | + "json": {"type": "boolean", |
| 76 | + "description": "Return machine-readable JSON output."}, |
| 77 | + "edit_budget": {"type": "integer", |
| 78 | + "description": "Max bounded edits per night (default: 4)."}, |
| 79 | + "hour": {"type": "integer", |
| 80 | + "description": "Hour for schedule (0-23, default: 3)."}, |
| 81 | + "minute": {"type": "integer", |
| 82 | + "description": "Minute for schedule (0-59, default: 17)."}, |
51 | 83 | }, |
52 | 84 | "additionalProperties": False, |
53 | 85 | } |
|
56 | 88 | def _run_engine(action: str, args: dict) -> str: |
57 | 89 | py = sys.executable or "python3" |
58 | 90 | cmd = [py, "-m", "skillopt_sleep", action] |
59 | | - if args.get("project"): |
60 | | - cmd += ["--project", str(args["project"])] |
61 | | - if args.get("backend"): |
62 | | - cmd += ["--backend", str(args["backend"])] |
63 | | - if args.get("scope"): |
64 | | - cmd += ["--scope", str(args["scope"])] |
| 91 | + # String-valued flags |
| 92 | + for flag, key in [ |
| 93 | + ("--project", "project"), ("--backend", "backend"), |
| 94 | + ("--scope", "scope"), ("--source", "source"), |
| 95 | + ("--model", "model"), ("--tasks-file", "tasks_file"), |
| 96 | + ("--target-skill-path", "target_skill_path"), |
| 97 | + ]: |
| 98 | + val = args.get(key) |
| 99 | + if val: |
| 100 | + cmd += [flag, str(val)] |
| 101 | + # Integer-valued flags |
| 102 | + for flag, key in [ |
| 103 | + ("--max-sessions", "max_sessions"), ("--max-tasks", "max_tasks"), |
| 104 | + ("--lookback-hours", "lookback_hours"), ("--edit-budget", "edit_budget"), |
| 105 | + ("--hour", "hour"), ("--minute", "minute"), |
| 106 | + ]: |
| 107 | + val = args.get(key) |
| 108 | + if val is not None: |
| 109 | + cmd += [flag, str(int(val))] |
| 110 | + # Boolean flags |
| 111 | + for flag, key in [ |
| 112 | + ("--progress", "progress"), ("--auto-adopt", "auto_adopt"), |
| 113 | + ("--json", "json"), |
| 114 | + ]: |
| 115 | + if args.get(key): |
| 116 | + cmd.append(flag) |
65 | 117 | try: |
66 | 118 | proc = subprocess.run(cmd, cwd=REPO_ROOT, capture_output=True, text=True, timeout=3600) |
67 | | - except Exception as e: # noqa: BLE001 |
| 119 | + except Exception as e: |
68 | 120 | return f"[error] failed to run engine: {e}" |
69 | 121 | out = (proc.stdout or "").strip() |
70 | 122 | err = (proc.stderr or "").strip() |
|
0 commit comments