2828from typing import Any
2929
3030from .config import PROJECTS_SUBDIR , get_home_dir , is_archived_bucket
31+ from .managed_skills .publish import codex_skills_dir
32+ from .skill_synthesis .inventory import read_skills_inventory
3133
3234HOOK_MARKER = "codex-self-evolution-plugin managed"
3335LAUNCHD_LABEL = "com.codex-self-evolution.preflight"
36+ SKILL_SYNTHESIS_LAUNCHD_LABEL = "com.codex-self-evolution.skill-synthesis"
3437
3538# Keys we recognize from .env.provider.example. Not exhaustive — other env
3639# vars a user might add (custom MINIMAX_BASE_URL etc.) are reported as
@@ -66,6 +69,8 @@ def collect_status(
6669 "legacy_user_hooks" : legacy_hooks ,
6770 "plugin_hooks" : _check_plugin_hook_bundle (),
6871 "scheduler" : _check_scheduler (),
72+ "skill_synthesis" : _check_skill_synthesis (home_dir ),
73+ "skills" : _check_skill_counts (),
6974 "env_provider" : _check_env_provider (home_dir ),
7075 "tools" : _check_tools (),
7176 "buckets" : _list_buckets (home_dir ),
@@ -215,9 +220,15 @@ def _commands_for_hook_event(entries: Any) -> list[str]:
215220
216221
217222def _check_scheduler () -> dict [str , Any ]:
223+ return _check_launchd_label (LAUNCHD_LABEL )
224+
225+
226+ def _check_launchd_label (label : str ) -> dict [str , Any ]:
218227 plist_path = Path .home () / "Library" / "LaunchAgents" / f"{ LAUNCHD_LABEL } .plist"
228+ if label != LAUNCHD_LABEL :
229+ plist_path = Path .home () / "Library" / "LaunchAgents" / f"{ label } .plist"
219230 result : dict [str , Any ] = {
220- "label" : LAUNCHD_LABEL ,
231+ "label" : label ,
221232 "plist_path" : str (plist_path ),
222233 "plist_exists" : plist_path .exists (),
223234 "loaded" : False ,
@@ -243,12 +254,44 @@ def _check_scheduler() -> dict[str, Any]:
243254 # "does our label appear", not about PID or status — launchd might have
244255 # our job loaded but not currently running (between ticks).
245256 for line in proc .stdout .splitlines ():
246- if line .strip ().endswith (LAUNCHD_LABEL ):
257+ if line .strip ().endswith (label ):
247258 result ["loaded" ] = True
248259 break
249260 return result
250261
251262
263+ def _check_skill_synthesis (home_dir : Path ) -> dict [str , Any ]:
264+ root = home_dir / "skill_synthesis"
265+ return {
266+ "root" : str (root ),
267+ "exists" : root .exists (),
268+ "scheduler" : _check_launchd_label (SKILL_SYNTHESIS_LAUNCHD_LABEL ),
269+ "last_receipt" : _read_skill_synthesis_receipt (root / "last_receipt.json" ),
270+ }
271+
272+
273+ def _check_skill_counts () -> dict [str , Any ]:
274+ root = codex_skills_dir ()
275+ inventory = read_skills_inventory (root )
276+ synth = inventory ["synth" ]
277+ legacy = [
278+ item for item in inventory ["non_synth" ]
279+ if Path (item ["path" ]).parent .name .startswith ("csep-" )
280+ ]
281+ return {
282+ "skills_root" : str (root ),
283+ "synthesized" : {
284+ "active" : sum (1 for item in synth if not item .get ("invalid_marker" ) and item .get ("csep_status" ) != "retired" ),
285+ "invalid" : sum (1 for item in synth if item .get ("invalid_marker" )),
286+ "retired" : sum (1 for item in synth if item .get ("csep_status" ) == "retired" ),
287+ },
288+ "compiler_legacy" : {
289+ "active" : len (legacy ),
290+ "note" : "legacy; compiler no longer creates or updates skills" ,
291+ },
292+ }
293+
294+
252295# ---------- .env.provider key presence ----------------------------------
253296
254297
@@ -409,6 +452,39 @@ def _read_last_receipt(receipt_path: Path) -> dict[str, Any] | None:
409452 }
410453
411454
455+ def _read_skill_synthesis_receipt (receipt_path : Path ) -> dict [str , Any ] | None :
456+ if not receipt_path .is_file ():
457+ return None
458+ try :
459+ data = json .loads (receipt_path .read_text (encoding = "utf-8" ))
460+ except (OSError , ValueError ):
461+ return None
462+ try :
463+ mtime = receipt_path .stat ().st_mtime
464+ timestamp = datetime .fromtimestamp (mtime , tz = timezone .utc ).strftime (
465+ "%Y-%m-%dT%H:%M:%SZ"
466+ )
467+ except OSError :
468+ timestamp = None
469+ return {
470+ "path" : str (receipt_path ),
471+ "timestamp" : timestamp ,
472+ "status" : data .get ("status" ),
473+ "run_id" : data .get ("run_id" ),
474+ "mode" : data .get ("mode" ),
475+ "dry_run" : data .get ("dry_run" ),
476+ "evidence_count" : data .get ("evidence_count" ),
477+ "valid_count" : len (data .get ("valid" ) or []),
478+ "invalid_count" : len (data .get ("invalid" ) or []),
479+ "retired_count" : len (data .get ("retired" ) or []),
480+ "mismatch" : data .get ("mismatch" ),
481+ "dry_run_leak" : data .get ("dry_run_leak" ),
482+ "result_missing" : data .get ("result_missing" ),
483+ "result_invalid" : data .get ("result_invalid" ),
484+ "error" : data .get ("error" ),
485+ }
486+
487+
412488# ---------- recent activity from plugin.log -----------------------------
413489
414490# Fields we actually care about when rolling up the log. Anything outside
0 commit comments