@shadowclone/cli 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,16 @@
11
11
  ]
12
12
  }
13
13
  ],
14
+ "SubagentStart": [
15
+ {
16
+ "hooks": [
17
+ {
18
+ "type": "command",
19
+ "command": "bun run \"${CLAUDE_PLUGIN_ROOT}/dist/shadowclone.js\" hook session-start"
20
+ }
21
+ ]
22
+ }
23
+ ],
14
24
  "SessionEnd": [
15
25
  {
16
26
  "hooks": [
package/README.md CHANGED
@@ -1,191 +1,104 @@
1
1
  # shadowclone
2
2
 
3
- Memory and alignment compiler for AI coding agents.
3
+ Shadowclone learns engineering preferences from coding-agent sessions you choose to share with it. It turns explicit guidance and corrections into an editable profile, and keeps a portable personal skill library in sync. Claude Code, Codex, Cursor, and Antigravity can receive that profile in ordinary sessions. Supported delegated runs use the same guidance.
4
4
 
5
- Shadowclone reads historical coding sessions already on your disk (Claude Code, Codex, Cursor), mines your steering habits without sending raw transcripts to any server, and compiles an editable profile into the agents you already use.
5
+ The profile adds context to an existing model; it does not train a new one or guarantee that every instruction will be followed. With separate learning consent, useful sessions can update the guidance for later work. [Why I built it](docs/motivation.md).
6
6
 
7
- Developers who install the profile see a measurable action delta against unprofiled runs on their held-out corpus: the agent stops asking for confirmations you never gave, runs the tests you run, and avoids the tools you refuse.
7
+ ## Privacy comes first
8
8
 
9
- Verify the delta directly on your own machine:
9
+ Every source has its own setting, defaults off, and appears by name before consent. The default setup asks one grouped question for detected session sources, Git remote names, and existing agent context. It asks separately about skills and background learning. `init --advanced` offers individual source choices. The paths that may be read are:
10
10
 
11
- ```bash
12
- shadowclone eval --sessions 10
13
- ```
14
-
15
- ## Architectural scope: what shadowclone is and is not
16
-
17
- **Not an agent runtime.**
18
- Shadowclone does not provide an LLM chat loop, an autonomous worker daemon, or an IDE extension. It compiles behavioral profiles and subagents for the agent CLIs you already install, authenticate, and pay for.
19
-
20
- **A memory and alignment compiler.**
21
- Every turn where you interrupted an agent, refused a tool, corrected a proposal, or chose one implementation over another is an alignment signal. Shadowclone indexes those moments locally and distills them into plain markdown rules scoped by repository origin.
22
-
23
- ## The pipeline
24
-
25
- ```
26
- observe -> index -> signal -> distill -> profile -> dispatch / eval
27
- | |
28
- zero tokens user's subscription
29
- ```
30
-
31
- | Stage | Module | Function |
32
- | --- | --- | --- |
33
- | observe | `src/observe/` | Normalizes agent transcripts into one incremental event stream |
34
- | index | `src/index/` | Rebuildable SQLite cache of byte offsets and event kinds, never text |
35
- | signal | `src/signal/` | Detects interruptions, plan changes, and tool refusals in pure code |
36
- | distill | `src/distill/` | Distills high-signal moments into rules via your installed agent CLI |
37
- | profile | `src/profile/` | Plain markdown rules and subagents scoped to git origins |
38
- | dispatch | `src/dispatch/` | Executes unattended tasks on isolated worktrees with receipts |
39
- | eval | `src/eval/` | Replays historical prompts through baseline vs clone to score behavioral deltas |
40
-
41
- Model calls run through `claude`, `codex`, or `cursor-agent`. There is no shadowclone API key, no telemetry, and no hosted server.
42
-
43
- ## Quickstart
44
-
45
- Install the global CLI:
46
-
47
- ```bash
48
- npm i -g @shadowclone/cli
49
- ```
50
-
51
- Verify your environment and supported provider CLIs:
52
-
53
- ```bash
54
- shadowclone doctor
55
- ```
56
-
57
- Grant consent for desired transcript sources:
58
-
59
- ```bash
60
- shadowclone init
61
- ```
62
-
63
- Index your historical sessions and build your profile:
11
+ | Source | Path |
12
+ | --- | --- |
13
+ | Claude Code sessions | `~/.claude/projects/` |
14
+ | Claude prompt history | `~/.claude/history.jsonl` |
15
+ | Codex sessions | `~/.codex/sessions/` or `$CODEX_HOME/sessions/` when set |
16
+ | Cursor chats | `~/.cursor/chats/` |
17
+ | Antigravity logs | `~/.gemini/antigravity-cli/brain/` |
18
+ | Shell history | `~/.zsh_history`, `~/.bash_history` |
19
+ | Repository guidance | root `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, and direct `SKILL.md` files under `.claude/skills/` and `.agents/skills/` |
20
+ | Agent context | `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, `~/.codex/AGENTS.override.md`, supported personal and repository skill roots, and `~/.claude/projects/<repo>/memory/` or `~/.codex/memories/`, only for consented evaluation |
21
+ | Skill library | `~/.claude/skills/`, `~/.agents/skills/`, `~/.codex/skills/`, `~/.cursor/skills/`, `~/.gemini/config/skills/`, configured repository roots, and selected provider plugin caches |
22
+ | Git metadata | repository Git remote names |
64
23
 
65
- ```bash
66
- shadowclone learn
67
- ```
24
+ Source detection checks whether a configured root has content. A directory check reads at most one entry to establish that fact and retains no name before consent. Agent transcripts can contain private code, credentials, internal hosts, and customer data. Shadowclone never copies raw transcripts into its store. Its SQLite index holds pointers and event kinds. Eligible excerpts pass through `resolveRedacted`, the single secret-redaction gate, before a model receives them. Tool results, file-read contents, thinking blocks, and data-access results are excluded from learning by category.
68
25
 
69
- To preview without writing files or databases:
26
+ Learning sends eligible redacted excerpts through your own authenticated agent CLI. Evaluation also gives that CLI access to a disposable repository snapshot and sends generated code to judges without redaction. Use only repositories you are authorized to send to that provider. A remote action from `shadowclone run` needs separate approval for that run. There is no Shadowclone service, API key, account, or telemetry. The profile is Markdown under `~/.shadowclone/profile/`; you can read, edit, or delete it. `shadowclone forget --all` removes Shadowclone's local state and recorded integrations, preserving unrelated content and stopping on conflicting edits. Your original transcripts remain where your agents wrote them. [Privacy design](docs/architecture/05-privacy.md).
70
27
 
71
- ```bash
72
- shadowclone learn --dry-run
73
- ```
74
-
75
- To enable deep distillation through your authenticated agent CLI:
28
+ ## Start from this checkout
76
29
 
77
30
  ```bash
78
- shadowclone learn --deep
31
+ bun install
32
+ bun run cli init
79
33
  ```
80
34
 
81
- Install the compiled profile into the current repository:
35
+ The package release follows the evaluation and packaging gates. The commands below use `shadowclone`, the installed binary name; from this checkout, use `bun run cli` in its place.
82
36
 
83
- ```bash
84
- shadowclone install
85
- ```
86
-
87
- This writes `.claude/agents/shadowclone.md` and excludes it from git tracking.
88
-
89
- ## Replay evaluation
90
-
91
- Shadowclone provides a reproducible fitness function to measure profile impact:
92
-
93
- ```bash
94
- shadowclone eval --sessions 5 --max-budget-usd 0.50
95
- ```
37
+ `init` shows the detected agents and source paths, then asks three questions, each defaulting to yes:
96
38
 
97
- The evaluator replays historical user prompts through two isolated runs:
98
- 1. **Baseline run:** unprofiled agent invocation without system prompt customization.
99
- 2. **Clone run:** agent invocation with the compiled project profile injected.
39
+ 1. Learn how you work from these sessions?
40
+ 2. Keep your skills in sync across the detected agents?
41
+ 3. Keep improving in the background as you work?
100
42
 
101
- Replays are compared against historical developer actions across four dimensions:
102
- - **Tools:** Jaccard similarity of invoked tools.
103
- - **Verification:** Jaccard similarity of two-token bash verification commands (e.g. `bun test`, `cargo check`).
104
- - **Files:** Jaccard similarity of posix repository-relative edited paths.
105
- - **Planning:** Match on whether planning tools were invoked before the first file edit.
43
+ Only detected transcript sources are enabled by the first answer. Setup then imports supported repository guidance if present, synchronizes consented skills, runs a first learning pass when background learning is enabled, and installs global native guidance for detected agents. The first pass selects recent unprocessed steering and limits model calls to 12 or 90 seconds; scanning local transcripts can take longer. Reaching a model budget does not block setup. Later sessions continue bounded learning when the agent marks a useful session. No extra `learn` command is required to finish setup.
106
44
 
107
- Evaluation receipts are written to `~/.shadowclone/eval/<evalId>.json`.
45
+ Use `shadowclone init --advanced` for individual source choices and the seed guidance wizard. Run `shadowclone wizard` later to change seed preferences and starter skills. Run `shadowclone skills configure --global` or `--repo` to configure skill roots separately. Managed policy may limit any setting.
108
46
 
109
- ## Unattended dispatch
47
+ ## How it works
110
48
 
111
- Execute tasks in an isolated git worktree without touching your working tree:
112
-
113
- ```bash
114
- shadowclone run "fix the flaky test in src/auth.test.ts"
49
+ ```text
50
+ enabled transcripts -> local index -> steering episodes -> redacted reconciliation
51
+ -> editable profile
52
+ profile + personal skills -> native agents and clones -> new transcripts
115
53
  ```
116
54
 
117
- The default dispatch mode creates a local worktree and branch, runs verification checks, and commits locally without pushing.
118
-
119
- Remote actions (push, open PR) require both a repository ceiling in `~/.shadowclone/config.toml` and an explicit per-run approval flag:
120
-
121
- ```bash
122
- shadowclone run "prepare release notes" --approve push
123
- ```
55
+ Plain `shadowclone learn` updates the local index and prints a structural report without model calls or profile writes. `shadowclone learn --deep` works through the oldest unprocessed episodes in bounded batches, proposes changes, and asks before applying them. `--deep --apply` accepts that local write without a prompt. Explicit reusable guidance can become active from one session; inferred behavior needs three independent sessions. The processed ledger lets later runs continue through older history. `shadowclone remember --repo "Use complete variable names."` records a direct preference immediately.
124
56
 
125
- ## Ground-truth privacy
57
+ The first setup pass starts at the newest unprocessed episodes so the next session can benefit quickly. Reconciliation batches run concurrently, then apply results in their original order. Completed checkpoints let a later run reuse finished model work. All model calls use `claude`, `codex`, or `cursor-agent` under your existing authentication.
126
58
 
127
- Agent transcripts contain private code, environment variables, internal hosts, and customer data. Shadowclone protects data through structural guarantees:
59
+ Repository imports preserve your edits and rejected rules. The compiler selects global guidance, the matching Git remote owner, and the exact repository. Without Git metadata consent, working directories stay isolated. It caps compiled guidance at 16 KiB and drops whole blocks when needed.
128
60
 
129
- **Pointers instead of text copies.**
130
- The SQLite index stores file offsets, timestamps, and event kinds. Raw transcripts are never duplicated to a secondary store.
61
+ Native installation adds a small pointer and lifecycle hooks while preserving other instructions. Claude Code's `SessionStart` hook injects the current scoped profile into the main agent. Its `SubagentStart` hook gives spawned subagents that same profile without creating another learning request. Codex, Cursor, and Antigravity use their supported native delivery paths. A useful main-agent session can request bounded learning at session end. `shadowclone install --subagent` and `--auto-delegate` remain optional Claude repository modes.
131
62
 
132
- **Sliced secret redaction.**
133
- Distillation excerpts pass through a deterministic sliced replacer before reaching any model. Secrets keep identifying prefixes (such as `AKIA` or `sk_live_`) while stripping high-entropy characters, keeping code context intact without leaking credentials.
63
+ Portable skills live in `~/.agents/skills` and sync to supported provider locations. A single edited copy becomes the source for the next sync; divergent edits are reported as conflicts. Existing user skills and plugin packages are preserved. Skill assessment reads only enabled roots, sends redacted `SKILL.md` content through the chosen agent CLI, and leaves technical or routing changes for review. [Skill maintenance](docs/skill-maintenance.md).
134
64
 
135
- **Shannon entropy layer.**
136
- Unstructured tokens exceeding 4.5 bits of entropy per character are scrubbed even if they do not match known vendor regex patterns.
65
+ ## Check the result
137
66
 
138
- **Third-party tool results are excluded.**
139
- Distillation inputs allowlist user prompts and developer steering corrections. Tool outputs from database queries, log dumps, and file reads are excluded by category rather than relying on regex filtering.
67
+ `shadowclone doctor` reports installation and engine status. `shadowclone context` prints the compiled profile for the current scope. `shadowclone history` shows local revisions, and `shadowclone undo <revision-id>` restores one when no later edit conflicts.
140
68
 
141
- **Single-command wipe.**
142
- Wipe the entire local index, profile, checkpoints, and receipts:
69
+ Transfer evaluation compares three matched setups: repository guidance only, that guidance plus the existing personal skill/context library, and both plus the Shadowclone profile. It freezes a source-backed coding-preference rubric before execution and saves three blinded votes per check. Correctness is graded separately. Missing grades are reported as ungraded, and a completed evaluation does not require Clone to win. [Evaluation design](docs/architecture/09-evaluation.md).
143
70
 
144
71
  ```bash
145
- shadowclone forget --all
72
+ shadowclone eval --repo /path/to/repository --engine codex --model gpt-5.6-sol --reasoning-effort medium --tasks 3 --repeat 2
146
73
  ```
147
74
 
148
- ## Enterprise governance
149
-
150
- Security teams can enforce policy ceilings fleet-wide via root-owned managed configuration:
151
- - **macOS:** `/Library/Application Support/shadowclone/managed.json`
152
- - **Linux:** `/etc/shadowclone/managed.json`
153
-
154
- ```json
155
- {
156
- "enabled": true,
157
- "allowedSources": ["claude-code"],
158
- "allowedEngines": ["claude-code"],
159
- "distillation": "local-only",
160
- "originScope": "strict",
161
- "blockedOrigins": ["github.com/acme/security-*"],
162
- "maxActionTier": "draft"
163
- }
164
- ```
165
-
166
- Managed policies act as an absolute ceiling. Users cannot enable unapproved sources or engines, and `enabled: false` enforces an immediate stop across the machine.
75
+ `shadowclone run "fix the flaky test"` runs a headless clone in a local worktree and records a receipt. The invocation approves one worktree, branch, and local commit. Remote actions also need a matching repository policy ceiling and `--approve` for that run. No action approval carries to the next run. [Acting policy](docs/architecture/04-acting.md).
167
76
 
168
- ## CLI commands
77
+ ## Early evaluation results
169
78
 
170
- ```bash
171
- shadowclone init # Configure source consent and capabilities
172
- shadowclone learn [--deep] [--dry-run] # Index sessions and synthesize rules
173
- shadowclone doctor # Inspect active paths, engines, and policies
174
- shadowclone install # Install profile as .claude/agents/shadowclone.md
175
- shadowclone run <task> [--approve <action>] # Dispatch headless clone in a worktree
176
- shadowclone eval [--sessions N] [--json] # Measure behavioral deltas against baseline
177
- shadowclone mcp # Start stdio Model Context Protocol server
178
- shadowclone forget --all # Remove ~/.shadowclone/ completely
179
- ```
79
+ Across four small TypeScript tasks using GPT-5.6 Sol at medium reasoning effort, the recorded preference scores were:
180
80
 
181
- ## Contributing
81
+ | Repository only (Bare) | Personal skills/context (Skills) | Skills/context + profile (Clone) |
82
+ | ---: | ---: | ---: |
83
+ | 55/68 (80.9%) | 59/68 (86.8%) | 62/68 (91.2%) |
182
84
 
183
- Review `CONTRIBUTING.md` and `SECURITY.md`. All contributions must pass:
85
+ These are guideline checks passed, not correctness or productivity scores. The skills were existing user-written or user-guided instructions, potentially outdated and not tuned for this comparison. This was one implementation per arm per task, with known judging limitations. Read [the tasks, setup, results, and caveats](evals.md) before drawing broader conclusions.
184
86
 
185
- ```bash
186
- bun run check
187
- ```
87
+ ## Commands
188
88
 
189
- ## License
89
+ | Command | Use |
90
+ | --- | --- |
91
+ | `shadowclone init [--advanced]` | Set consent and install detected integrations |
92
+ | `shadowclone import`, `shadowclone wizard` | Refresh repository guidance or seed choices |
93
+ | `shadowclone learn [--deep] [--dry-run] [--apply]` | Inspect history or reconcile guidance |
94
+ | `shadowclone skills`, `shadowclone skills update` | List starter guidance or maintain consented skills |
95
+ | `shadowclone skills pending`, `show`, `apply`, `reject` | Review skill proposals |
96
+ | `shadowclone learning enable|disable|status` | Control session learning |
97
+ | `shadowclone doctor`, `shadowclone context`, `shadowclone sync` | Inspect or refresh delivery |
98
+ | `shadowclone install [--agent <agent>|all] [--global|--repo]` | Install native guidance manually |
99
+ | `shadowclone uninstall [--global]` | Remove owned integrations |
100
+ | `shadowclone remember`, `history`, `undo` | Manage direct rules and revisions |
101
+ | `shadowclone eval`, `shadowclone run <task>` | Measure transfer or run a local clone |
102
+ | `shadowclone forget --all` | Remove all recorded Shadowclone state |
190
103
 
191
- MIT. See `LICENSE`.
104
+ Contributors can run `bun install` and `bun run check`. See [the architecture](docs/architecture/README.md), [design records](docs/design/README.md), [contribution guide](CONTRIBUTING.md), and [security policy](SECURITY.md). Shadowclone is MIT licensed.