check_ok.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago
| 1 | """``ok check-ok`` — scaffold (optional) + same ``review --freeze`` engine. |
| 2 | |
| 3 | ``check-if-ok`` remains a CLI synonym for one release. |
| 4 | """ |
| 5 | |
| 6 | from __future__ import annotations |
| 7 | |
| 8 | from argparse import Namespace |
| 9 | |
| 10 | from adapters.config import load_config |
| 11 | from adapters.errors import ConfigError |
| 12 | from cli.commands.review import run_review |
| 13 | from cli.context import CliContext |
| 14 | from cli.paths import PathEscapeError, confine_path, resolve_config_path, resolve_repo_root |
| 15 | from cli.sanitize import format_config_error |
| 16 | from tools.check_ok.scaffold import scaffold_side_check |
| 17 | |
| 18 | |
| 19 | def run_check_ok(args: Namespace, ctx: CliContext, *, raw_argv: list[str] | None = None) -> int: |
| 20 | """Scaffold a side-check artifact when needed, then run freeze review. |
| 21 | |
| 22 | Semantic review / build-verification loops stay in portable skills |
| 23 | (``/check-ok``, ``/freeze-review-loop``, ``/build-verification-review``) under |
| 24 | ``.cursor/skills/`` and ``.claude/skills/``. This CLI path is the tool-agnostic |
| 25 | mechanical gate — identical engine to ``ok review --freeze``. |
| 26 | """ |
| 27 | del raw_argv # reserved for parity with review; no extra flag bans yet |
| 28 | repo_root = resolve_repo_root(cwd=ctx.cwd, repo_arg=args.repo, command="check-ok") |
| 29 | overseer_dir = repo_root / ".overseer" |
| 30 | if not overseer_dir.is_dir(): |
| 31 | ctx.output.error("not initialized — run ok init first") |
| 32 | return 2 |
| 33 | |
| 34 | config_path = resolve_config_path(repo_root, args.config) |
| 35 | try: |
| 36 | load_config(config_path) |
| 37 | except ConfigError as exc: |
| 38 | ctx.output.error(format_config_error(exc, repo_root)) |
| 39 | return 2 |
| 40 | |
| 41 | path_arg = args.path |
| 42 | if path_arg: |
| 43 | try: |
| 44 | confined = confine_path(repo_root, path_arg) |
| 45 | path_arg = confined.relative_to(repo_root.resolve()).as_posix() |
| 46 | except (PathEscapeError, ValueError): |
| 47 | ctx.output.error("refused: artifact path") |
| 48 | return 4 |
| 49 | |
| 50 | try: |
| 51 | result = scaffold_side_check( |
| 52 | repo_root, |
| 53 | path=path_arg, |
| 54 | topic=args.topic, |
| 55 | scope=args.scope or "", |
| 56 | overwrite=bool(args.force_scaffold), |
| 57 | ) |
| 58 | except ValueError as exc: |
| 59 | if str(exc) == "path-escape": |
| 60 | ctx.output.error("refused: artifact path") |
| 61 | return 4 |
| 62 | raise |
| 63 | |
| 64 | if result.created: |
| 65 | ctx.output.emit(f"check-ok: scaffolded {result.rel_path}") |
| 66 | else: |
| 67 | ctx.output.emit(f"check-ok: reusing {result.rel_path}") |
| 68 | |
| 69 | if args.scaffold_only: |
| 70 | if ctx.output.json_mode: |
| 71 | ctx.output.emit_json( |
| 72 | { |
| 73 | "command": "check-ok", |
| 74 | "rel_path": result.rel_path, |
| 75 | "created": result.created, |
| 76 | "scaffold_only": True, |
| 77 | "exit_code": 0, |
| 78 | } |
| 79 | ) |
| 80 | return 0 |
| 81 | |
| 82 | review_args = Namespace( |
| 83 | repo=args.repo, |
| 84 | config=args.config, |
| 85 | freeze_path=result.rel_path, |
| 86 | dry_run=bool(args.dry_run), |
| 87 | no_stamp=bool(args.no_stamp), |
| 88 | mode=args.mode, |
| 89 | provider=args.provider, |
| 90 | model=args.model, |
| 91 | checklist=args.checklist, |
| 92 | ) |
| 93 | return run_review(review_args, ctx, raw_argv=["review", "--freeze", result.rel_path]) |
| 94 | |
| 95 | |
| 96 | # Back-compat import name used by older call sites / docs mid-rename. |
| 97 | run_check_if_ok = run_check_ok |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago