Skip to content

feat: CORTEX CLI v4.0 — operational layer with enforcement, scoring, and validation#4

Merged
WPHILLIPMACLAYNE merged 1 commit intomainfrom
agent/claude-opus-cli-implementation
Apr 14, 2026
Merged

feat: CORTEX CLI v4.0 — operational layer with enforcement, scoring, and validation#4
WPHILLIPMACLAYNE merged 1 commit intomainfrom
agent/claude-opus-cli-implementation

Conversation

@WPHILLIPMACLAYNE
Copy link
Copy Markdown
Owner

Summary

  • CORTEX CLI with 6 commands: init, doctor, status, validate, score, hooks
  • Git hooks that enforce Law 3 (branch isolation) — commits/pushes to main are blocked, not just suggested
  • Automated CSEI scoring computed from repository evidence (tests, CI, .cortex/ fill status, branch discipline, hooks)
  • Doctor command that checks installation health with actionable warnings
  • Status command that shows project state + CSEI in one glance
  • Installable via pip (pip install -e .) with cortex available on PATH
  • 34 total tests (12 installer + 22 CLI) all passing
  • Updated CI, docs, README, START.md, MANIFEST → v4.0.0

What this changes about CORTEX

Before (v3.1) After (v4.0)
"Don't commit on main" (suggestion) pre-commit hook blocks it
CSEI filled manually by agent cortex score computes from evidence
"Read 5 files to understand state" cortex status shows everything
"Check if .cortex/ is OK" cortex doctor with actionable report
No package management pip install -e . / pyproject.toml
12 tests 34 tests

New files (26 changed)

  • cli/ — full CLI package (commands, core modules, hooks)
  • pyproject.toml — Python package definition
  • tests/test_cli.py — 22 CLI tests
  • Updated: README.md, START.md, MANIFEST.yaml, docs/installing.md, docs/releasing.md, docs/templates.md, CI workflow

Test plan

  • python tests/test_installer.py — 12/12 passing
  • python tests/test_cli.py — 22/22 passing
  • python -m cli validate — PASS
  • python -m cli --version — cortex 4.0.0
  • Hook enforcement: commit on main → blocked; commit on branch → allowed
  • CI workflow runs all tests on Python 3.10/3.11/3.12

🤖 Generated with Claude Code

…alidation

Transform CORTEX from a documentation framework into a real operational
layer with a CLI that verifies, scores, and protects projects.

New CLI commands:
- cortex init: install .cortex/ (replaces standalone script)
- cortex doctor: health check of .cortex/ installation
- cortex status: quick project overview with CSEI score
- cortex validate: verify package and installation consistency
- cortex score: compute CSEI automatically from repo evidence
- cortex hooks install/remove/status: git hooks that enforce Law 3

Key changes:
- cli/core/: manifest, repo, templates, scoring modules
- cli/commands/: init, doctor, status, validate, score, hooks
- cli/hooks/: pre-commit (blocks main), pre-push (blocks main),
  post-checkout (state reminder)
- pyproject.toml: installable via pip (cortex-os)
- 22 new CLI tests (34 total with installer tests)
- Updated CI, docs, README, START.md, MANIFEST v4.0.0

CSEI is now computed by evidence, not opinion:
Structure, Clarity, Safety, Verification, Continuity,
Recoverability, and Regression Pressure — all measured
from actual repo state.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copilot AI review requested due to automatic review settings April 14, 2026 23:44
@WPHILLIPMACLAYNE WPHILLIPMACLAYNE merged commit a3c82c3 into main Apr 14, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces CORTEX CLI v4.0 as an operational layer around the existing template/manifest system, adding commands for installation, health checks, status reporting, validation, automated CSEI scoring, and git-hook based branch enforcement.

Changes:

  • Adds a new Python CLI package (cli/) with 6 commands (init, doctor, status, validate, score, hooks) plus hook scripts.
  • Implements automated CSEI scoring based on repository and .cortex/ evidence.
  • Updates docs/CI/metadata for v4.0.0 and adds a new CLI-focused test suite.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
pyproject.toml Defines packaging and console entrypoint for the new CLI.
cli/main.py CLI entrypoint and argparse command wiring.
cli/__main__.py Enables python -m cli execution.
cli/__init__.py Defines CLI version.
cli/commands/init.py Implements .cortex/ installation logic from manifest/templates.
cli/commands/doctor.py Implements installation + repo health checks with actionable output.
cli/commands/status.py Provides a combined project status + CSEI summary view.
cli/commands/validate.py Validates manifest/templates consistency and target .cortex/ state.
cli/commands/score.py Computes and optionally writes back CSEI into CURRENT_STATUS.md.
cli/commands/hooks.py Installs/removes/reports git hooks for branch enforcement.
cli/core/manifest.py Loads MANIFEST.yaml (PyYAML optional) and exposes file lists/version.
cli/core/templates.py Detects installed/missing/filled template files and reads fields/sections.
cli/core/repo.py Git inspection helpers for branch/clean/remote/commit metadata.
cli/core/scoring.py Implements evidence-based CSEI computation.
cli/hooks/pre-commit Blocks commits on main/master (Law 3 enforcement).
cli/hooks/pre-push Blocks pushes on main/master (Law 3 enforcement).
cli/hooks/post-checkout Prints status reminder on branch switches.
tests/test_cli.py Adds CLI tests covering init/doctor/status/score/hooks/validate and manifest consistency.
docs/installing.md Updates installation docs to focus on the CLI workflow.
docs/releasing.md Updates release checklist to run CLI tests/validation and version checks.
README.md Documents CLI, hooks, and CSEI automation additions.
START.md Updates the recommended first steps to use the CLI + hooks + scoring.
MANIFEST.yaml Bumps manifest version to 4.0.0.
.github/workflows/ci.yml Runs CLI tests and basic python -m cli validations in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml

[tool.setuptools.package-data]
"cli.hooks" = ["pre-commit", "pre-push", "post-checkout"]
"" = ["MANIFEST.yaml", "templates/*.md"]
Comment thread cli/core/manifest.py
Comment on lines +10 to +12
_ROOT = Path(__file__).resolve().parents[2]
MANIFEST_PATH = _ROOT / "MANIFEST.yaml"

Comment thread cli/core/scoring.py
Comment on lines +22 to +23
# 1 point for .cortex/ existing, up to 4 more based on fill ratio
score = 1 + round((filled / total) * 4)
Comment thread cli/hooks/pre-push
Comment on lines +11 to +12
echo " Push your feature branch instead:"
echo " git push -u origin $BRANCH"
Comment thread cli/commands/doctor.py
else:
warnings.append("CURRENT_STATUS.md has no next safe step defined")

stable_branch = templates.read_field(d / "CURRENT_STATUS.md", "Name")
Comment thread cli/core/scoring.py
Comment on lines +111 to +114
# CURRENT_STATUS has last stable branch
branch = templates.read_field(d / "CURRENT_STATUS.md", "Name")
if branch:
score += 1
Comment thread tests/test_cli.py
Comment on lines +25 to +32
subprocess.run(["git", "init", "-b", "main", tmp], capture_output=True)
subprocess.run(
["git", "config", "user.email", "[email protected]"],
capture_output=True, cwd=tmp,
)
subprocess.run(
["git", "config", "user.name", "Test"],
capture_output=True, cwd=tmp,
Comment thread tests/test_cli.py
Comment on lines +22 to +25
def make_git_repo():
"""Create a temporary git repo and return its path."""
tmp = tempfile.mkdtemp()
subprocess.run(["git", "init", "-b", "main", tmp], capture_output=True)
Comment thread tests/test_cli.py
Comment on lines +25 to +32
subprocess.run(["git", "init", "-b", "main", tmp], capture_output=True)
subprocess.run(
["git", "config", "user.email", "[email protected]"],
capture_output=True, cwd=tmp,
)
subprocess.run(
["git", "config", "user.name", "Test"],
capture_output=True, cwd=tmp,
Comment thread tests/test_cli.py
Comment on lines +25 to +32
subprocess.run(["git", "init", "-b", "main", tmp], capture_output=True)
subprocess.run(
["git", "config", "user.email", "[email protected]"],
capture_output=True, cwd=tmp,
)
subprocess.run(
["git", "config", "user.name", "Test"],
capture_output=True, cwd=tmp,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants