harness-evolve 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 Ricky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ <div align="center">
2
+
3
+ # harness-evolve
4
+
5
+ [![npm version](https://img.shields.io/npm/v/harness-evolve?style=flat-square)](https://www.npmjs.com/package/harness-evolve)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/r1ckyIn/harness-evolve/ci.yml?branch=main&style=flat-square&label=CI)](https://github.com/r1ckyIn/harness-evolve/actions/workflows/ci.yml)
7
+ [![Tests](https://img.shields.io/github/actions/workflow/status/r1ckyIn/harness-evolve/ci.yml?branch=main&style=flat-square&label=Tests)](https://github.com/r1ckyIn/harness-evolve/actions/workflows/ci.yml)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-3178C6?style=flat-square&logo=typescript)](https://typescriptlang.org)
9
+ [![Node.js](https://img.shields.io/badge/Node.js-22_LTS-339933?style=flat-square&logo=node.js)](https://nodejs.org)
10
+ [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
11
+
12
+ **A self-iteration engine for Claude Code -- automatically detects usage patterns and routes optimization recommendations to the right configuration tool.**
13
+
14
+ [English](#english) | [中文](#中文)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## English
21
+
22
+ ### Problem
23
+
24
+ Claude Code users accumulate inefficiencies over time -- typing the same commands repeatedly, approving the same tool permissions, and missing configuration optimizations. These patterns are invisible until you manually audit your workflow. harness-evolve makes the invisible visible by automatically detecting patterns and routing fixes to the right configuration target.
25
+
26
+ ### Overview
27
+
28
+ harness-evolve observes how you interact with Claude Code, detects patterns, and outputs optimization recommendations routed to the most appropriate configuration tool -- hooks, skills, rules, CLAUDE.md, memory, settings, or permissions.
29
+
30
+ You shouldn't need to notice that you've typed the same command 20 times before creating a hook. The system surfaces that insight and suggests the fix.
31
+
32
+ ### Installation
33
+
34
+ ```bash
35
+ # Install from npm
36
+ npm install -g harness-evolve
37
+
38
+ # Or use locally in a project
39
+ npm install harness-evolve
40
+ ```
41
+
42
+ ### How It Works
43
+
44
+ ```
45
+ Capture -> Store -> Pre-Process -> Classify -> Route -> Deliver -> Track Outcomes
46
+ ```
47
+
48
+ 1. **Capture** -- 5 lifecycle hooks silently record prompts, tool usage, permissions, and failures
49
+ 2. **Store** -- JSONL logs with 14-pattern secret scrubbing and atomic counter
50
+ 3. **Pre-Process** -- Cross-session aggregation compresses logs into <50KB summaries
51
+ 4. **Classify** -- 8 classifiers detect patterns (repeated prompts, long workflows, permission habits, code corrections, personal info, config drift, ecosystem features, onboarding level)
52
+ 5. **Route** -- Each pattern maps to the best config target via an extensible decision tree
53
+ 6. **Deliver** -- Non-invasive notification + `/evolve` command + optional full-auto mode
54
+ 7. **Track** -- Outcome tracking adjusts future recommendation confidence
55
+
56
+ ### Routing Targets
57
+
58
+ | Pattern | Target | Example |
59
+ |---------|--------|---------|
60
+ | Same short command repeated 10+ times | **Hook** | Auto-create a shell hook |
61
+ | Long prompt (200+ words) repeated 3+ times | **Skill** | Suggest a reusable skill |
62
+ | Tool approved 15+ times across sessions | **Settings** | Add to `allowedTools` |
63
+ | Recurring code correction pattern | **Rule** | Create a `.claude/rules/` entry |
64
+ | Personal/contextual information | **Memory** | Suggest a memory entry |
65
+ | Project-level configuration pattern | **CLAUDE.md** | Update project CLAUDE.md |
66
+ | Config contradictions or redundancy | **Cleanup** | Flag drift for review |
67
+
68
+ ### Key Features
69
+
70
+ - **Zero-config** -- works immediately with sensible defaults
71
+ - **Environment-agnostic** -- dynamically discovers installed tools (GSD, Cog, plugins) and adapts routing
72
+ - **Non-invasive** -- recommends at natural breakpoints, never interrupts active tasks
73
+ - **Full-auto mode** -- opt-in auto-apply for HIGH-confidence recommendations
74
+ - **Tiered onboarding** -- adapts to newcomers vs power users
75
+ - **Feedback loop** -- tracks whether recommendations persist or get reverted, adjusting future confidence
76
+ - **Secret scrubbing** -- 14-pattern detection ensures no sensitive data is logged
77
+
78
+ ### Tech Stack
79
+
80
+ | Technology | Purpose |
81
+ |------------|---------|
82
+ | TypeScript 6.0 | Type safety with strict mode |
83
+ | Node.js 22 LTS | Runtime |
84
+ | Zod v4 | Schema validation (14x faster than v3) |
85
+ | tsup | Build & bundling |
86
+ | Vitest 4 | Testing framework |
87
+ | proper-lockfile | Cross-process file locking |
88
+
89
+ ### Architecture
90
+
91
+ ```
92
+ Claude Code Session
93
+ |
94
+ +-- 5 Lifecycle Hooks
95
+ | UserPromptSubmit, PreToolUse, PostToolUse
96
+ | PermissionRequest, Stop
97
+ |
98
+ +-- JSONL Event Store
99
+ | 14-pattern secret scrubbing
100
+ | Atomic counter for ordering
101
+ | Cross-session aggregation -> <50KB summaries
102
+ |
103
+ +-- 8 Pattern Classifiers
104
+ | Repeated prompts, Long workflows
105
+ | Permission habits, Code corrections
106
+ | Personal info, Config drift
107
+ | Ecosystem features, Onboarding level
108
+ |
109
+ +-- Routing Decision Tree
110
+ | -> Hook, Skill, Rule, CLAUDE.md
111
+ | -> Memory, Settings, Permissions, Cleanup
112
+ |
113
+ +-- Delivery + Outcome Tracking
114
+ Non-invasive notifications
115
+ /evolve command
116
+ Full-auto mode (opt-in)
117
+ ```
118
+
119
+ ### Quick Start
120
+
121
+ ```bash
122
+ # Install globally
123
+ npm install -g harness-evolve
124
+
125
+ # Or clone for development
126
+ git clone git@github.com:r1ckyIn/harness-evolve.git
127
+ cd harness-evolve
128
+
129
+ # Install dependencies
130
+ npm install
131
+
132
+ # Build
133
+ npm run build
134
+
135
+ # Test
136
+ npm test
137
+ ```
138
+
139
+ ### Register Hooks
140
+
141
+ Add to your Claude Code `settings.json`:
142
+
143
+ ```json
144
+ {
145
+ "hooks": {
146
+ "UserPromptSubmit": [
147
+ { "type": "command", "command": "node /path/to/harness-evolve/dist/hooks/user-prompt-submit.js" }
148
+ ],
149
+ "PreToolUse": [
150
+ { "type": "command", "command": "node /path/to/harness-evolve/dist/hooks/pre-tool-use.js" }
151
+ ],
152
+ "PostToolUse": [
153
+ { "type": "command", "command": "node /path/to/harness-evolve/dist/hooks/post-tool-use.js" }
154
+ ],
155
+ "PermissionRequest": [
156
+ { "type": "command", "command": "node /path/to/harness-evolve/dist/hooks/permission-request.js" }
157
+ ],
158
+ "Stop": [
159
+ { "type": "command", "command": "node /path/to/harness-evolve/dist/hooks/stop.js" }
160
+ ]
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Project Stats
166
+
167
+ | Metric | Value |
168
+ |--------|-------|
169
+ | Source Code | 3,765 LOC TypeScript |
170
+ | Tests | 7,968 LOC across 37 test files |
171
+ | Test Count | 600+ passing tests |
172
+ | Classifiers | 8 pattern classifiers |
173
+ | Routing Targets | 7+ configuration tools |
174
+ | Total Commits | 96 |
175
+
176
+ ---
177
+
178
+ ## 中文
179
+
180
+ ### 问题背景
181
+
182
+ Claude Code 用户随时间积累低效操作 -- 反复输入相同命令、反复批准相同工具权限、遗漏配置优化。这些模式在手动审计工作流之前是不可见的。harness-evolve 通过自动检测模式并将修复路由到正确的配置目标,让不可见的变得可见。
183
+
184
+ ### 项目概述
185
+
186
+ harness-evolve 是 Claude Code 的自迭代引擎。它观察用户与 Claude Code 的交互方式,检测使用模式,并将优化建议路由到最合适的配置工具 -- hooks、skills、rules、CLAUDE.md、memory、settings 或 permissions。
187
+
188
+ 你不应该需要自己发现"我已经敲了同一条命令 20 次了,该建个 hook" -- 系统会自动捕捉到这个模式并建议修复方案。
189
+
190
+ ### 安装
191
+
192
+ ```bash
193
+ # 从 npm 安装
194
+ npm install -g harness-evolve
195
+
196
+ # 或在项目中本地安装
197
+ npm install harness-evolve
198
+ ```
199
+
200
+ ### 工作原理
201
+
202
+ ```
203
+ 捕获 -> 存储 -> 预处理 -> 分类 -> 路由 -> 交付 -> 跟踪结果
204
+ ```
205
+
206
+ 1. **捕获** -- 5 个生命周期 hooks 静默记录 prompts、工具使用、权限审批和失败
207
+ 2. **存储** -- JSONL 日志,带 14 种模式的密钥擦除和原子计数器
208
+ 3. **预处理** -- 跨 session 聚合,将日志压缩到 <50KB 摘要
209
+ 4. **分类** -- 8 个分类器检测模式(重复 prompt、长工作流、权限习惯、代码纠正偏好、个人信息、配置漂移、生态系统特性、新手等级)
210
+ 5. **路由** -- 每个模式通过可扩展决策树映射到最佳配置目标
211
+ 6. **交付** -- 非侵入式通知 + `/evolve` 命令 + 可选全自动模式
212
+ 7. **跟踪** -- 结果跟踪调整未来建议的置信度
213
+
214
+ ### 功能特点
215
+
216
+ - **零配置** -- 开箱即用,无需手动设置
217
+ - **环境无关** -- 动态发现已安装工具(GSD、Cog、插件)并适配路由
218
+ - **非侵入式** -- 在自然间断点推荐,不中断活跃任务
219
+ - **全自动模式** -- 可选自动应用高置信度建议
220
+ - **分层引导** -- 适配新手和资深用户
221
+ - **反馈闭环** -- 跟踪建议是否被采纳或回退,调整未来置信度
222
+
223
+ ### 快速开始
224
+
225
+ ```bash
226
+ # 全局安装
227
+ npm install -g harness-evolve
228
+
229
+ # 或克隆开发
230
+ git clone git@github.com:r1ckyIn/harness-evolve.git
231
+ cd harness-evolve
232
+
233
+ # 安装依赖
234
+ npm install
235
+
236
+ # 构建
237
+ npm run build
238
+
239
+ # 运行测试
240
+ npm test
241
+ ```
242
+
243
+ ---
244
+
245
+ ## License
246
+
247
+ MIT License
248
+
249
+ ## Author
250
+
251
+ **Ricky Yuan** - CS + Mathematics @ University of Sydney
252
+
253
+ [![GitHub](https://img.shields.io/badge/GitHub-r1ckyIn-181717?style=flat-square&logo=github)](https://github.com/r1ckyIn)
254
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-rickyyyyy-0A66C2?style=flat-square&logo=linkedin)](https://linkedin.com/in/rickyyyyy)