7Registry-native inspect commands.
11Expose read-only registry inspection commands at the top-level registry CLI.
15- Wire ``show``, ``status``, and ``whoami`` commands.
16- Resolve registry paths through standard discovery.
17- Format read-model dataclasses for humans or JSON.
29- Every command in this module is read-only.
30- Missing explicit plan lookups exit non-zero with a clear message.
34- oc_diagnostics (structured debug logging via _dbg)
35- oc_chat.registry.backends.sqlite (SQLite backend)
36- oc_chat.registry.discovery (registry path discovery)
37- oc_chat.registry.readers (typed read projections)
38- oc_chat.registry (Registry facade the read projections query)
40from __future__
import annotations
45from oc_diagnostics
import _dbg
53_dbg(
"OC_CHAT.MAIN",
"module",
"loaded", 4)
57 """Attach top-level read-only inspect commands."""
59 show = subcommands.add_parser(
"show", help=
"Show a projected plan row")
60 show.add_argument(
"plan_id")
61 show.add_argument(
"--registry", help=
"Registry SQLite path.")
62 show.add_argument(
"--json", action=
"store_true")
63 show.set_defaults(handler=_cmd_show)
65 status = subcommands.add_parser(
"status", help=
"Show registry status")
66 status.add_argument(
"--registry", help=
"Registry SQLite path.")
67 status.add_argument(
"--json", action=
"store_true")
68 status.set_defaults(handler=_cmd_status)
70 identity = subcommands.add_parser(
"whoami", help=
"Show actor metadata")
71 identity.add_argument(
"actor_slot")
72 identity.add_argument(
"--registry", help=
"Registry SQLite path.")
73 identity.add_argument(
"--json", action=
"store_true")
74 identity.set_defaults(handler=_cmd_whoami)
79 view = show_plan(registry, args.plan_id)
81 print(f
"plan not found: {args.plan_id}")
83 _print(view.__dict__, args.json)
89 status = current_status(registry)
90 _print(status.__dict__, args.json)
96 actor = whoami(registry, args.actor_slot)
97 _print(actor.__dict__, args.json)
102 location = discover_registry_location(registry_path=registry_path)
106def _print(payload: dict[str, object], as_json: bool) ->
None:
108 print(json.dumps(payload, indent=2, sort_keys=
True))
110 for key, value
in payload.items():
111 print(f
"{key}: {value}")
int _cmd_status(argparse.Namespace args)
int _cmd_whoami(argparse.Namespace args)
int _cmd_show(argparse.Namespace args)
Registry _registry(str|None registry_path)
None add_inspect_subcommands(argparse._SubParsersAction subcommands)
None _print(dict[str, object] payload, bool as_json)