Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
319b8e9
cli: git agent trace attribution plan
davidabram Mar 4, 2026
fb6d01e
sce: Finalize Agent Trace implementation contract baseline
davidabram Mar 4, 2026
bf5ad10
cli: Implement Agent Trace schema adapter mapping contract
davidabram Mar 4, 2026
567b3e9
cli: Implement Agent Trace payload builder and compliance validation…
davidabram Mar 4, 2026
c4c4f78
cli Implement staged-only pre-commit hooks checkpoint
davidabram Mar 4, 2026
f981f2f
cli: Implement commit-msg canonical SCE co-author trailer policy
davidabram Mar 4, 2026
585865d
cli: Implement post-commit Agent Trace dual-write finalization
davidabram Mar 4, 2026
267d766
cli: Implement hook rollout doctor readiness checks
davidabram Mar 4, 2026
07fe4fa
hooks: Implement post-rewrite remap ingestion pipeline
davidabram Mar 4, 2026
169b4c6
hooks: Implement rewritten commit trace finalization semantics
davidabram Mar 4, 2026
497d003
agent-trace: Implement core local schema migrations
davidabram Mar 4, 2026
1eff2b8
agent-trace: Add reconciliation schema for hosted rewrite ingestion
davidabram Mar 4, 2026
9f94f38
agent-trace: Implement hosted webhook intake and replay-safe run orch…
davidabram Mar 4, 2026
a919ed2
agent-trace: Implement deterministic rewrite mapping engine
davidabram Mar 4, 2026
41ef523
agent-trace: Implement retry replay and reconciliation observability
davidabram Mar 4, 2026
a51d592
agent-trace: mark agent-trace-attribution-no-git-wrapper as done
davidabram Mar 4, 2026
b55a63d
sce: Define setup git-hooks install contract
davidabram Mar 4, 2026
835f789
setup: Implement embedded git-hook asset packaging for setup
davidabram Mar 4, 2026
f312cbf
setup: Implement required git-hook install flow with idempotent outco…
davidabram Mar 4, 2026
4a4350e
setup: Add --hooks setup mode with optional --repo targeting
davidabram Mar 4, 2026
c5d18b5
doctor: Resolve hook checks against inspected repository root
davidabram Mar 4, 2026
93abbf7
hosted-reconciliation: Replace handwritten crypto with hmac and sha2
davidabram Mar 4, 2026
6eca244
hosted-reconciliation: Replace webhook string scanning with structure…
davidabram Mar 4, 2026
f0bdf82
hosted-reconciliation: Use epsilon tie window for rewrite score ranking
davidabram Mar 4, 2026
e3ce44f
local_db: Eliminate lossy DB path conversion in Turso target handling
davidabram Mar 4, 2026
ae7e72b
agent_trace: Remove crate-level dead_code suppression
davidabram Mar 4, 2026
24118fd
cli: Remove top-level parser tail_args clone
davidabram Mar 5, 2026
2e982ac
sync: Simplify shared runtime initialization with OnceLock get_or_init
davidabram Mar 5, 2026
0ef5cd9
services: Refactor hooks and setup test suites into dedicated test mo…
davidabram Mar 5, 2026
9c66e74
cli: Add clippy app and check in Nix flake
davidabram Mar 5, 2026
67f8d08
agent-trace: Freeze local hooks MVP contract and gap matrix
davidabram Mar 5, 2026
f02b2f4
hooks: Implement sce hooks subcommand routing entrypoints
davidabram Mar 5, 2026
4edb400
hooks: Implement pre-commit runtime staged attribution checkpoint per…
davidabram Mar 5, 2026
2509cd0
hooks: Wire commit-msg runtime to apply co-author trailer policy
davidabram Mar 5, 2026
9863467
hooks: Implement post-commit trace finalization runtime adapters
davidabram Mar 5, 2026
b585dde
hooks: Implement persistent local DB bootstrap for post-commit traces
davidabram Mar 5, 2026
09a5dd8
hooks: Implement post-rewrite remap ingestion and rewrite trace final…
davidabram Mar 5, 2026
7473d29
hooks: Wire runtime retry replay into post-commit and post-rewrite hooks
davidabram Mar 5, 2026
8a899f0
services: Remove placeholder hook-event scaffolding and harden local …
davidabram Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
680 changes: 677 additions & 3 deletions cli/Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ categories = ["command-line-utilities", "development-tools"]

[dependencies]
anyhow = "1"
hmac = "0.12"
inquire = "0.7"
lexopt = "0.3"
serde_json = "1"
sha2 = "0.10"
tokio = { version = "1", default-features = false, features = ["rt"] }
turso = "0"

[dev-dependencies]
jsonschema = "0.33"
45 changes: 33 additions & 12 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# sce CLI (placeholder foundation)
# sce CLI (foundation)

This crate provides the early command-surface scaffold for the Shared Context
Engineering CLI (`sce`).

Current scope is intentionally narrow: deterministic command dispatch, an
implemented repository `setup` flow, and explicit placeholders for commands
that are still deferred.
Current scope is intentionally narrow: deterministic command dispatch,
implemented repository `setup` flows (including hook installation),
implemented local rollout health checks via `doctor`, production local
`hooks` runtime execution, and explicit placeholders for commands that are
still deferred.

## Quick start

```bash
cargo run --manifest-path cli/Cargo.toml -- --help
cargo run --manifest-path cli/Cargo.toml -- setup
cargo run --manifest-path cli/Cargo.toml -- doctor
cargo run --manifest-path cli/Cargo.toml -- mcp
cargo run --manifest-path cli/Cargo.toml -- hooks
cargo run --manifest-path cli/Cargo.toml -- hooks pre-commit
cargo run --manifest-path cli/Cargo.toml -- hooks commit-msg .git/COMMIT_EDITMSG
cargo run --manifest-path cli/Cargo.toml -- sync
```

Expand Down Expand Up @@ -56,26 +60,43 @@ Crates.io is prepared but intentionally disabled in this phase.
`config/.claude/**`
- installation writes to repository-root `.opencode/` and/or `.claude/`
using backup-and-replace safety with rollback on swap failures
- required local hooks can be installed with `sce setup --hooks` (optionally
`--repo <path>`) with deterministic per-hook
`installed`/`updated`/`skipped` outcomes
- `doctor` is implemented and validates hook rollout readiness:
- detects effective hooks directory for default, per-repo `core.hooksPath`,
and global `core.hooksPath` installs
- validates required hooks (`pre-commit`, `commit-msg`, `post-commit`) for
presence and executable permissions
- reports actionable diagnostics for missing or misconfigured hooks
- `mcp` is a placeholder for future file-cache tooling contracts
(`cache-put`/`cache-get`).
- `hooks` is a placeholder for future git hook event and generated-region
tracking integration.
- `hooks` is implemented for local Git hook execution:
- `sce hooks pre-commit` captures staged-only checkpoint attribution
- `sce hooks commit-msg <message-file>` enforces canonical co-author trailer
policy when runtime gates pass
- `sce hooks post-commit` finalizes Agent Trace records and performs
notes+DB persistence with retry fallback
- `sce hooks post-rewrite <amend|rebase|other>` ingests rewrite pairs from
STDIN, applies rewrite remap + rewritten-trace finalization, and runs
bounded retry replay
- `sync` is a placeholder that runs a local Turso smoke check, then reports a
deferred cloud-sync plan.

## Safety and limitations

- `mcp`, `hooks`, and `sync` remain placeholders and do not perform MCP
transport, hook installation, or cloud sync.
- `mcp` and `sync` remain placeholders and do not perform MCP transport or
cloud sync.
- `sync` only validates local adapter wiring and does not require remote auth.
- This crate is scaffolding for incremental delivery and should not be treated
as production-ready workflow automation.
- Hosted reconciliation intake/mapping paths are not wired to public CLI
commands yet.

## Near-term roadmap mapping

- Repository setup automation seam: `cli/src/services/setup.rs`
- Hook install health validation seam: `cli/src/services/doctor.rs`
- MCP file-cache seam: `cli/src/services/mcp.rs`
- Hook event and generated-region seam: `cli/src/services/hooks.rs`
- Local hook runtime + persistence seam: `cli/src/services/hooks.rs`
- Cloud sync seam + local Turso gate: `cli/src/services/sync.rs`
- Command catalog and placeholder status: `cli/src/command_surface.rs`

Expand Down
4 changes: 4 additions & 0 deletions cli/assets/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu

exec sce hooks commit-msg "$@"
4 changes: 4 additions & 0 deletions cli/assets/hooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu

exec sce hooks post-commit "$@"
4 changes: 4 additions & 0 deletions cli/assets/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu

exec sce hooks pre-commit "$@"
5 changes: 5 additions & 0 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const TARGETS: &[TargetSpec] = &[
relative_root: "config/.claude",
include_prefix: "/../config/.claude/",
},
TargetSpec {
const_name: "HOOK_EMBEDDED_ASSETS",
relative_root: "cli/assets/hooks",
include_prefix: "/assets/hooks/",
},
];

struct TargetSpec {
Expand Down
49 changes: 48 additions & 1 deletion cli/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
};

rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rustfmt" ];
extensions = [
"rustfmt"
"clippy"
];
};

rustPlatform = pkgs.makeRustPlatform {
Expand Down Expand Up @@ -65,6 +68,18 @@
};
};

apps.clippy = {
type = "app";
program = toString (
pkgs.writeShellScript "sce-clippy" ''
exec ${rustToolchain}/bin/cargo clippy --manifest-path cli/Cargo.toml --all-targets --all-features "$@"
''
);
meta = {
description = "Run clippy for the sce CLI crate";
};
};

checks.cli-setup-command-surface = rustPlatform.buildRustPackage {
pname = "sce-cli-setup-command-surface-check";
version = "0.1.0";
Expand Down Expand Up @@ -99,6 +114,38 @@
runHook postInstall
'';
};

checks.cli-clippy = rustPlatform.buildRustPackage {
pname = "sce-cli-clippy-check";
version = "0.1.0";
inherit src;
sourceRoot = "source/cli";

cargoLock = {
lockFile = ../cli/Cargo.lock;
};

nativeBuildInputs = [ rustToolchain ];

buildPhase = ''
runHook preBuild
runHook postBuild
'';

checkPhase = ''
runHook preCheck

cargo clippy --all-targets --all-features

runHook postCheck
'';

installPhase = ''
runHook preInstall
mkdir -p "$out"
runHook postInstall
'';
};
}
);
}
Loading