repo-harness 0.4.2 → 0.4.3
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/README.es.md +2 -2
- package/README.fr.md +2 -2
- package/README.ja.md +2 -2
- package/README.md +71 -41
- package/README.zh-CN.md +48 -38
- package/assets/hooks/anti-simplification.sh +4 -22
- package/assets/hooks/first-principles-guard.sh +72 -0
- package/assets/hooks/post-edit-guard.sh +4 -2
- package/assets/hooks/stop-orchestrator.sh +32 -1
- package/assets/reference-configs/global-working-rules.md +18 -1
- package/assets/reference-configs/handoff-protocol.md +8 -7
- package/assets/reference-configs/harness-overview.md +19 -0
- package/assets/reference-configs/hook-operations.md +11 -1
- package/assets/skill-version.json +6 -2
- package/assets/templates/helpers/check-task-workflow.sh +28 -0
- package/assets/templates/helpers/ensure-task-workflow.sh +4 -1
- package/assets/templates/helpers/workflow-contract.ts +9 -0
- package/assets/workflow-contract.v1.json +9 -0
- package/package.json +1 -2
- package/scripts/check-npm-release.sh +3 -0
- package/scripts/check-task-workflow.sh +28 -0
- package/scripts/create-project-dirs.sh +2 -11
- package/scripts/ensure-task-workflow.sh +4 -1
- package/scripts/init-project.sh +2 -11
- package/scripts/lib/project-init-lib.sh +114 -4
- package/scripts/workflow-contract.ts +9 -0
- package/src/cli/commands/docs.ts +103 -0
- package/src/cli/commands/doctor.ts +73 -0
- package/src/cli/commands/init-hook.ts +602 -0
- package/src/cli/commands/init.ts +11 -0
- package/src/cli/commands/status.ts +1 -1
- package/src/cli/index.ts +7 -0
- package/assets/reference-configs/AGENTS.md +0 -13
- package/assets/reference-configs/CLAUDE.md +0 -13
- package/docs/reference-configs/AGENTS.md +0 -13
- package/docs/reference-configs/CLAUDE.md +0 -13
- package/docs/reference-configs/agentic-development-flow.md +0 -84
- package/docs/reference-configs/ai-workflows.md +0 -14
- package/docs/reference-configs/changelog-versioning.md +0 -13
- package/docs/reference-configs/coding-standards.md +0 -14
- package/docs/reference-configs/development-protocol.md +0 -21
- package/docs/reference-configs/document-generation.md +0 -37
- package/docs/reference-configs/evaluator-rubric.md +0 -19
- package/docs/reference-configs/external-tooling.md +0 -329
- package/docs/reference-configs/git-strategy.md +0 -14
- package/docs/reference-configs/global-working-rules.md +0 -47
- package/docs/reference-configs/handoff-protocol.md +0 -40
- package/docs/reference-configs/harness-overview.md +0 -76
- package/docs/reference-configs/heartbeat-triage.md +0 -57
- package/docs/reference-configs/hook-operations.md +0 -86
- package/docs/reference-configs/loop-engine-cutover-gate.md +0 -39
- package/docs/reference-configs/loop-engine-nl-decision-table.md +0 -137
- package/docs/reference-configs/release-deploy.md +0 -40
- package/docs/reference-configs/spa-day-protocol.md +0 -14
- package/docs/reference-configs/sprint-contracts.md +0 -65
- package/docs/reference-configs/workflow-orchestration.md +0 -14
package/README.es.md
CHANGED
|
@@ -345,8 +345,8 @@ Guards habituales:
|
|
|
345
345
|
|
|
346
346
|
## Release actual
|
|
347
347
|
|
|
348
|
-
- npm package: `repo-harness@0.4.
|
|
349
|
-
- Generated workflow stamp: `repo-harness@0.4.
|
|
348
|
+
- npm package: `repo-harness@0.4.3`
|
|
349
|
+
- Generated workflow stamp: `repo-harness@0.4.3+template@0.4.3`
|
|
350
350
|
- GitHub repository: `Ancienttwo/repo-harness`
|
|
351
351
|
- Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
|
|
352
352
|
|
package/README.fr.md
CHANGED
|
@@ -350,8 +350,8 @@ Guards courants :
|
|
|
350
350
|
|
|
351
351
|
## Release actuelle
|
|
352
352
|
|
|
353
|
-
- npm package : `repo-harness@0.4.
|
|
354
|
-
- Generated workflow stamp : `repo-harness@0.4.
|
|
353
|
+
- npm package : `repo-harness@0.4.3`
|
|
354
|
+
- Generated workflow stamp : `repo-harness@0.4.3+template@0.4.3`
|
|
355
355
|
- GitHub repository : `Ancienttwo/repo-harness`
|
|
356
356
|
- Release history : [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
|
|
357
357
|
|
package/README.ja.md
CHANGED
|
@@ -312,8 +312,8 @@ hook がブロックしたときは、まず terminal の構造化された出
|
|
|
312
312
|
|
|
313
313
|
## 現在の Release
|
|
314
314
|
|
|
315
|
-
- npm package:`repo-harness@0.4.
|
|
316
|
-
- Generated workflow stamp:`repo-harness@0.4.
|
|
315
|
+
- npm package:`repo-harness@0.4.3`
|
|
316
|
+
- Generated workflow stamp:`repo-harness@0.4.3+template@0.4.3`
|
|
317
317
|
- GitHub repository:`Ancienttwo/repo-harness`
|
|
318
318
|
- Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
|
|
319
319
|
|
package/README.md
CHANGED
|
@@ -34,20 +34,29 @@ This repository now dogfoods its own tasks-first contract. It is both:
|
|
|
34
34
|
read a 1KB capability contract or query the index instead of spending thousands of
|
|
35
35
|
tokens rediscovering structure.
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
In an adopted repo, the surface area is intentionally small:
|
|
38
|
+
|
|
39
|
+
| Surface | Purpose |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `docs/spec.md` and `docs/reference-configs/` | Shared standards and stable product intent that every agent session can read. |
|
|
42
|
+
| `plans/`, `plans/prds/`, and `plans/sprints/` | Decision-complete work packages before implementation starts. |
|
|
43
|
+
| `tasks/contracts/`, `tasks/reviews/`, and `.ai/harness/checks/` | Scope, verification, and review evidence for proving the work is done. |
|
|
44
|
+
| `.ai/harness/handoff/` and `tasks/current.md` | Session journal and resumable status, derived from workflow artifacts instead of chat memory. |
|
|
45
|
+
|
|
46
|
+
## What's New in 0.4.3
|
|
47
|
+
|
|
48
|
+
- **Runtime docs lookup.** `repo-harness docs list|path|show` resolves bundled
|
|
49
|
+
runtime/reference docs from the installed package instead of requiring copied
|
|
50
|
+
repo prose.
|
|
51
|
+
- **Init-hook bootstrap audit.** `repo-harness init-hook --json` reports concrete
|
|
52
|
+
Agent actions for missing working rules, adapter drift, stale CLI installs,
|
|
53
|
+
and tooling readiness.
|
|
54
|
+
- **First-principles edit guard.** Managed hook routes now include
|
|
55
|
+
anti-overengineering guidance for implementation edits while keeping the guard
|
|
56
|
+
advisory.
|
|
57
|
+
- **Slimmer generated reference docs.** Generated and migrated repos write
|
|
58
|
+
deterministic `docs/reference-configs/*.md` pointer stubs while `.ai/harness/*`
|
|
59
|
+
and `.ai/context/*` remain local runtime artifacts.
|
|
51
60
|
|
|
52
61
|
## What repo-harness Does
|
|
53
62
|
|
|
@@ -200,9 +209,11 @@ concrete sprint instead of reinterpreting the original chat.
|
|
|
200
209
|
## First 5 Minutes
|
|
201
210
|
|
|
202
211
|
This is the fastest path for an AI tooling owner evaluating whether the workflow is
|
|
203
|
-
safe to adopt in a real repo.
|
|
212
|
+
safe to adopt in a real repo. It separates the machine-level runtime bootstrap
|
|
213
|
+
from the repo-local contract install, so a dry run can show exactly what will
|
|
214
|
+
change before anything is applied.
|
|
204
215
|
|
|
205
|
-
###
|
|
216
|
+
### 1. Bootstrap the host runtime once
|
|
206
217
|
|
|
207
218
|
```bash
|
|
208
219
|
npx -y repo-harness init
|
|
@@ -214,27 +225,36 @@ user-level hook adapters, configures Waza runtime skills, persists a brain root
|
|
|
214
225
|
under `~/.repo-harness/config.json`, and configures CodeGraph MCP. It does not
|
|
215
226
|
apply repo-local workflow files to the current directory.
|
|
216
227
|
|
|
217
|
-
|
|
228
|
+
For an Agent-owned, read-only bootstrap audit, run `npx -y repo-harness
|
|
229
|
+
init-hook --json` or add `--check-updates` for version advisories. `init-hook`
|
|
230
|
+
is not a runtime hook: it does not write user-level files, install updates, or
|
|
231
|
+
register adapters. It emits `agent_actions` with the reason, risk, target files,
|
|
232
|
+
optional command, and verification surface for the Agent to execute deliberately.
|
|
233
|
+
|
|
234
|
+
### 2. Preview the repo-local contract
|
|
218
235
|
|
|
219
236
|
```bash
|
|
220
237
|
npx -y repo-harness update --dry-run
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Run the dry run from the target repository root. It reports the specs, task
|
|
241
|
+
state, helper runtime, hook adapter target, and verification files that would be
|
|
242
|
+
created or refreshed. It should not create an application stack; existing repos
|
|
243
|
+
use `repo-harness update`, while new projects or modules use
|
|
244
|
+
`repo-harness-scaffold`.
|
|
245
|
+
|
|
246
|
+
### 3. Apply, then prove the workflow
|
|
247
|
+
|
|
248
|
+
```bash
|
|
221
249
|
npx -y repo-harness update
|
|
250
|
+
bash scripts/check-task-workflow.sh --strict
|
|
251
|
+
bun test
|
|
222
252
|
```
|
|
223
253
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
The npm package and generated workflow stamp now share the `0.4.x` release line.
|
|
229
|
-
The `0.4.2` package keeps first-run
|
|
230
|
-
global bootstrap (`repo-harness init`) separate from repo-local refresh
|
|
231
|
-
(`repo-harness update`) while adding the PRD-to-Sprint planning hierarchy,
|
|
232
|
-
isolated generated-project helper runtime, subagent return-channel guard, and
|
|
233
|
-
release-path alignment on top of the `0.4.0` loop-engine surfaces.
|
|
234
|
-
These sit on top of the renamed `repo-harness` CLI, user-level hook
|
|
235
|
-
adapter bootstrap, AI-native scaffold overlays, the typed prompt-guard decision
|
|
236
|
-
engine, plan-stem task artifact naming, `REPO_HARNESS_*` runtime aliases, Waza
|
|
237
|
-
runtime skill sync, and the maintainer release gate.
|
|
254
|
+
After apply, the repo should have a reviewable file-backed contract rather than
|
|
255
|
+
tool-specific chat setup. Agents should be able to find the stable intent in
|
|
256
|
+
`docs/spec.md`, execution state in `plans/` and `tasks/`, and resume state in
|
|
257
|
+
`.ai/harness/handoff/`.
|
|
238
258
|
|
|
239
259
|
Only maintainers editing the package need a source checkout:
|
|
240
260
|
|
|
@@ -293,13 +313,6 @@ The command should end with `=== Migration Report ===` and summarize:
|
|
|
293
313
|
- `Helper runtime:` to show `.ai/harness/scripts/*` implementations and `scripts/*` compatibility wrappers after apply
|
|
294
314
|
- `--- External Tooling ---` to show default gstack/Waza/gbrain routing plus advisory install/update hints
|
|
295
315
|
|
|
296
|
-
### Next two commands
|
|
297
|
-
|
|
298
|
-
```bash
|
|
299
|
-
bash scripts/check-task-workflow.sh --strict
|
|
300
|
-
bun test
|
|
301
|
-
```
|
|
302
|
-
|
|
303
316
|
If the dry-run output looks wrong, stop there and inspect
|
|
304
317
|
[`docs/reference-configs/hook-operations.md`](docs/reference-configs/hook-operations.md)
|
|
305
318
|
before applying anything.
|
|
@@ -381,8 +394,8 @@ Most common guards:
|
|
|
381
394
|
|
|
382
395
|
## Current Release
|
|
383
396
|
|
|
384
|
-
- npm package: `repo-harness@0.4.
|
|
385
|
-
- Generated workflow stamp: `repo-harness@0.4.
|
|
397
|
+
- npm package: `repo-harness@0.4.3`
|
|
398
|
+
- Generated workflow stamp: `repo-harness@0.4.3+template@0.4.3`
|
|
386
399
|
- GitHub repository: `Ancienttwo/repo-harness`
|
|
387
400
|
- Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
|
|
388
401
|
|
|
@@ -527,6 +540,22 @@ bun scripts/inspect-project-state.ts --repo . --format text
|
|
|
527
540
|
bash scripts/migrate-project-template.sh --repo . --dry-run
|
|
528
541
|
```
|
|
529
542
|
|
|
543
|
+
### Runtime reference docs
|
|
544
|
+
|
|
545
|
+
Generic repo-harness runtime/reference docs live in the installed package under
|
|
546
|
+
`assets/reference-configs/` and are resolved through the CLI:
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
repo-harness docs list
|
|
550
|
+
repo-harness docs path harness-overview
|
|
551
|
+
repo-harness docs show harness-overview
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Generated and migrated repos still keep `docs/reference-configs/*.md`, but
|
|
555
|
+
those files are deterministic pointer stubs. Repo-local workflow state,
|
|
556
|
+
policy, checks, runs, handoff packets, context maps, and helper snapshots stay
|
|
557
|
+
under `.ai/`.
|
|
558
|
+
|
|
530
559
|
### Explicit template assembly
|
|
531
560
|
|
|
532
561
|
```bash
|
|
@@ -556,8 +585,9 @@ bun run benchmark:skills --eval repair-agents-task-sync
|
|
|
556
585
|
- Plan mapping: `assets/plan-map.json`
|
|
557
586
|
- Question-pack: `assets/initializer-question-pack.v4.json`
|
|
558
587
|
- Shared hooks: `assets/hooks/`
|
|
588
|
+
- Runtime reference docs: `assets/reference-configs/` via `repo-harness docs`
|
|
559
589
|
- Workflow contract: `assets/workflow-contract.v1.json`
|
|
560
|
-
-
|
|
590
|
+
- Source repo reference docs: `docs/reference-configs/*.md`
|
|
561
591
|
- Template assembler: `scripts/assemble-template.ts`
|
|
562
592
|
- Question inference helper: `scripts/initializer-question-pack.ts`
|
|
563
593
|
- State inspector: `scripts/inspect-project-state.ts`
|
package/README.zh-CN.md
CHANGED
|
@@ -23,19 +23,27 @@ repo-local workflow 的自托管样例。
|
|
|
23
23
|
做渐进式上下文加载:一份小而稳定的 root context(约 12KB),加上只在改到对应文件时才加载的
|
|
24
24
|
capability 块。agent 读一份 1KB 的 capability 合约或查索引,而不是花上千 token 重新摸清结构。
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- **
|
|
38
|
-
|
|
26
|
+
接入后的仓库只需要理解几个 surface:
|
|
27
|
+
|
|
28
|
+
| Surface | 作用 |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `docs/spec.md` 和 `docs/reference-configs/` | 共享标准和稳定产品意图,每个 agent 会话都能读取。 |
|
|
31
|
+
| `plans/`、`plans/prds/`、`plans/sprints/` | 实现前先沉淀 decision-complete work package。 |
|
|
32
|
+
| `tasks/contracts/`、`tasks/reviews/`、`.ai/harness/checks/` | 证明完成所需的 scope、verification 和 review evidence。 |
|
|
33
|
+
| `.ai/harness/handoff/` 和 `tasks/current.md` | session journal 与可恢复状态,从 workflow artifacts 派生,而不是依赖聊天记忆。 |
|
|
34
|
+
|
|
35
|
+
## 0.4.3 新特性
|
|
36
|
+
|
|
37
|
+
- **Runtime docs lookup。** `repo-harness docs list|path|show` 从已安装 package
|
|
38
|
+
解析 bundled runtime/reference docs,不再要求把完整 repo prose 复制到下游。
|
|
39
|
+
- **Init-hook bootstrap audit。** `repo-harness init-hook --json` 会把缺失的
|
|
40
|
+
working rules、adapter drift、stale CLI install 和 tooling readiness 汇成
|
|
41
|
+
具体 Agent actions。
|
|
42
|
+
- **First-principles edit guard。** Managed hook routes 增加实现编辑时的
|
|
43
|
+
anti-overengineering guidance,同时保持 advisory,不把风格判断变成硬拦截。
|
|
44
|
+
- **更轻的 generated reference docs。** 生成和迁移的仓库写入确定性的
|
|
45
|
+
`docs/reference-configs/*.md` pointer stubs,`.ai/harness/*` 和 `.ai/context/*`
|
|
46
|
+
继续作为 repo-local runtime artifacts。
|
|
39
47
|
|
|
40
48
|
## 产品做什么
|
|
41
49
|
|
|
@@ -166,9 +174,11 @@ source of truth,Codex Goal mode 只围绕具体 sprint 恢复和推进,而
|
|
|
166
174
|
|
|
167
175
|
## 前 5 分钟
|
|
168
176
|
|
|
169
|
-
这是评估一个真实仓库是否适合接入该 workflow
|
|
177
|
+
这是评估一个真实仓库是否适合接入该 workflow 的最快路径。它把机器级 runtime
|
|
178
|
+
bootstrap 和 repo-local contract install 分开,所以 dry-run 能先展示会改什么,
|
|
179
|
+
再决定是否应用。
|
|
170
180
|
|
|
171
|
-
###
|
|
181
|
+
### 1. 先做一次 host runtime bootstrap
|
|
172
182
|
|
|
173
183
|
```bash
|
|
174
184
|
npx -y repo-harness init
|
|
@@ -179,27 +189,34 @@ skill aliases,安装 user-level hook adapters,配置 Waza runtime skills,
|
|
|
179
189
|
root 持久化到 `~/.repo-harness/config.json`,并配置 CodeGraph MCP。它不会把当前目录
|
|
180
190
|
默认迁移成 repo-local workflow。
|
|
181
191
|
|
|
182
|
-
|
|
192
|
+
如果要让 Agent 做只读 bootstrap audit,运行 `npx -y repo-harness init-hook
|
|
193
|
+
--json`;需要版本提示时加 `--check-updates`。`init-hook` 不是 runtime hook:
|
|
194
|
+
它不会写 user-level files、安装更新或注册 adapters,只输出带 reason、risk、
|
|
195
|
+
targets、可选 command 和 verification 的 `agent_actions`,由 Agent 再显式执行。
|
|
196
|
+
|
|
197
|
+
### 2. 预览 repo-local contract
|
|
183
198
|
|
|
184
199
|
```bash
|
|
185
200
|
npx -y repo-harness update --dry-run
|
|
186
|
-
npx -y repo-harness update
|
|
187
201
|
```
|
|
188
202
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
repo-
|
|
203
|
+
在目标仓库根目录运行 dry-run。它会报告将要创建或刷新的 spec、task state、
|
|
204
|
+
helper runtime、hook adapter target 和 verification files。它不会创建应用技术栈;
|
|
205
|
+
已有仓库走 `repo-harness update`,新项目或新模块走 `repo-harness-scaffold`。
|
|
192
206
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
runtime aliases、Waza runtime skill sync,以及 maintainer 发布 npm 前使用的 release gate 之上。
|
|
207
|
+
### 3. 应用后验证 workflow
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npx -y repo-harness update
|
|
211
|
+
bash scripts/check-task-workflow.sh --strict
|
|
212
|
+
bun test
|
|
213
|
+
```
|
|
201
214
|
|
|
202
|
-
|
|
215
|
+
应用后,目标仓库应该得到一套可审查的 file-backed contract,而不是 tool-specific
|
|
216
|
+
聊天配置。agent 应该能在 `docs/spec.md` 找到稳定意图,在 `plans/` 和 `tasks/`
|
|
217
|
+
找到执行状态,在 `.ai/harness/handoff/` 找到可恢复状态。
|
|
218
|
+
|
|
219
|
+
只有维护者编辑 package 源码时才需要 source checkout:
|
|
203
220
|
|
|
204
221
|
```bash
|
|
205
222
|
git clone https://github.com/Ancienttwo/repo-harness.git ~/Projects/repo-harness
|
|
@@ -253,13 +270,6 @@ npx -y repo-harness update
|
|
|
253
270
|
- `Helper scripts:`:应用后会得到的操作工具链
|
|
254
271
|
- `--- External Tooling ---`:gstack/Waza/gbrain 路由以及 advisory 安装/更新提示
|
|
255
272
|
|
|
256
|
-
### 接着跑的两个命令
|
|
257
|
-
|
|
258
|
-
```bash
|
|
259
|
-
bash scripts/check-task-workflow.sh --strict
|
|
260
|
-
bun test
|
|
261
|
-
```
|
|
262
|
-
|
|
263
273
|
如果 dry-run 输出不对,先停在这里,阅读
|
|
264
274
|
[`docs/reference-configs/hook-operations.md`](docs/reference-configs/hook-operations.md)。
|
|
265
275
|
|
|
@@ -333,8 +343,8 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
|
|
|
333
343
|
|
|
334
344
|
## 当前 Release
|
|
335
345
|
|
|
336
|
-
- npm package:`repo-harness@0.4.
|
|
337
|
-
- Generated workflow stamp:`repo-harness@0.4.
|
|
346
|
+
- npm package:`repo-harness@0.4.3`
|
|
347
|
+
- Generated workflow stamp:`repo-harness@0.4.3+template@0.4.3`
|
|
338
348
|
- GitHub repository:`Ancienttwo/repo-harness`
|
|
339
349
|
- Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
|
|
340
350
|
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Warns when changes suggest compatibility debt or unnecessary branch complexity.
|
|
2
|
+
# Compatibility wrapper for the renamed First-Principles Guard.
|
|
4
3
|
|
|
5
4
|
set -eo pipefail
|
|
6
5
|
|
|
7
6
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
-
# shellcheck source=/dev/null
|
|
9
|
-
. "$SCRIPT_DIR/hook-input.sh"
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
15
|
-
exit 0
|
|
8
|
+
if [[ -f "$SCRIPT_DIR/first-principles-guard.sh" ]]; then
|
|
9
|
+
exec bash "$SCRIPT_DIR/first-principles-guard.sh" "$@"
|
|
16
10
|
fi
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
[[ -z "$DIFF_CONTENT" ]] && exit 0
|
|
20
|
-
|
|
21
|
-
if echo "$DIFF_CONTENT" | grep -E '^\+.*(legacy|compat|backward|polyfill|shim)' >/dev/null; then
|
|
22
|
-
echo "[AntiSimplification] Compatibility-like additions detected in $FILE_PATH"
|
|
23
|
-
echo " Prefer clean upgrades and rewrite-over-patch instead of legacy branches."
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
branch_additions="$(echo "$DIFF_CONTENT" | grep -E '^\+.*\b(if|else if|switch)\b' | wc -l | tr -d ' ')"
|
|
27
|
-
if [[ "$branch_additions" -ge 4 ]]; then
|
|
28
|
-
echo "[AntiSimplification] Branch-heavy additions detected in $FILE_PATH ($branch_additions new branch lines)"
|
|
29
|
-
echo " Re-check data structures before adding more control-flow branches."
|
|
30
|
-
fi
|
|
12
|
+
exit 0
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# First-Principles Guard — PostToolUse on Edit|Write
|
|
3
|
+
# Warns when diffs add likely overengineering. Advisory only.
|
|
4
|
+
|
|
5
|
+
set -eo pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
# shellcheck source=/dev/null
|
|
9
|
+
. "$SCRIPT_DIR/hook-input.sh"
|
|
10
|
+
|
|
11
|
+
FILE_PATH="$(hook_get_file_path "${1:-}")"
|
|
12
|
+
[[ -z "$FILE_PATH" ]] && exit 0
|
|
13
|
+
|
|
14
|
+
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
DIFF_CONTENT="$(git diff -- "$FILE_PATH" 2>/dev/null || true)"
|
|
19
|
+
[[ -z "$DIFF_CONTENT" ]] && exit 0
|
|
20
|
+
|
|
21
|
+
ADDED_LINES="$(printf '%s\n' "$DIFF_CONTENT" | grep -E '^\+[^+]' | sed 's/^+//' || true)"
|
|
22
|
+
[[ -z "$ADDED_LINES" ]] && exit 0
|
|
23
|
+
|
|
24
|
+
warned=0
|
|
25
|
+
|
|
26
|
+
count_matches() {
|
|
27
|
+
local pattern="$1"
|
|
28
|
+
{ printf '%s\n' "$ADDED_LINES" | grep -Ei "$pattern" || true; } | wc -l | tr -d ' '
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
emit_warning() {
|
|
32
|
+
local category="$1"
|
|
33
|
+
local detail="$2"
|
|
34
|
+
warned=1
|
|
35
|
+
echo "[FirstPrinciples] ${category} in $FILE_PATH"
|
|
36
|
+
echo " Re-check: must this exist, does platform/stdlib/current dependency already cover it, can the diff collapse?"
|
|
37
|
+
[[ -n "$detail" ]] && echo " Trigger: $detail"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
compat_count="$(count_matches '(^|[^[:alnum:]_])(legacy|compat|backward|polyfill|shim)([^[:alnum:]_]|$)')"
|
|
41
|
+
if [[ "$compat_count" -gt 0 ]]; then
|
|
42
|
+
emit_warning "Compatibility debt additions detected" "${compat_count} compatibility-like line(s)"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
branch_count="$(count_matches '(^|[^[:alnum:]_])(if|else[[:space:]]+if|switch|case)([^[:alnum:]_]|$)')"
|
|
46
|
+
if [[ "$branch_count" -ge 4 ]]; then
|
|
47
|
+
emit_warning "Branch-heavy additions detected" "${branch_count} new branch/control-flow line(s)"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
abstraction_count="$(count_matches '(^|[^[:alnum:]_])(interface|abstract[[:space:]]+class|factory|adapter|provider|strategy|manager|orchestrator|dispatcher|registry)([^[:alnum:]_]|$)')"
|
|
51
|
+
if [[ "$abstraction_count" -gt 0 ]]; then
|
|
52
|
+
emit_warning "Abstraction-heavy additions detected" "${abstraction_count} abstraction-like line(s)"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
dependency_count="$(count_matches '(^|[[:space:]])(import[[:space:]].*from[[:space:]]*["'\''][^./]|import[[:space:]]*["'\''][^./]|require\(["'\''][^./]|"(dependencies|devDependencies|peerDependencies|optionalDependencies)"[[:space:]]*:|"[@A-Za-z0-9._/-]+"[[:space:]]*:[[:space:]]*"[~^0-9])')"
|
|
56
|
+
if [[ "$dependency_count" -gt 0 ]]; then
|
|
57
|
+
emit_warning "Dependency-surface additions detected" "${dependency_count} dependency/import line(s)"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
config_count="$(count_matches '(^|[^[:alnum:]_])(process\.env|import\.meta\.env|feature[-_ ]?flag|FEATURE_|Config|config|Settings|settings)([^[:alnum:]_]|$)')"
|
|
61
|
+
if [[ "$config_count" -gt 1 ]]; then
|
|
62
|
+
emit_warning "Config-surface additions detected" "${config_count} config/env/flag line(s)"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
state_machine_count="$(count_matches '(^|[^[:alnum:]_])(state[[:space:]_-]?machine|lifecycle|workflow|route|routing|registry|orchestrator)([^[:alnum:]_]|$)')"
|
|
66
|
+
if [[ "$state_machine_count" -gt 1 ]]; then
|
|
67
|
+
emit_warning "Local orchestration additions detected" "${state_machine_count} orchestration-like line(s)"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
if [[ "$warned" -eq 1 ]]; then
|
|
71
|
+
echo " Boundary: keep trust-boundary validation, data-loss prevention, security, accessibility, and explicit user-requested behavior."
|
|
72
|
+
fi
|
|
@@ -148,9 +148,11 @@ if [[ "$BASENAME" =~ ^wrangler.*\.toml$ ]]; then
|
|
|
148
148
|
echo " Check: docs/guides/cf-deployment.md bindings/routes may need updating"
|
|
149
149
|
fi
|
|
150
150
|
|
|
151
|
-
# Aggregated
|
|
151
|
+
# Aggregated advisories (route-registry keeps one PostToolUse edit entry; the
|
|
152
152
|
# dispatcher-level aggregation lives here).
|
|
153
|
-
if [[ -
|
|
153
|
+
if [[ -f "$SCRIPT_DIR/first-principles-guard.sh" ]]; then
|
|
154
|
+
bash "$SCRIPT_DIR/first-principles-guard.sh" "$FILE_PATH" </dev/null || true
|
|
155
|
+
elif [[ -f "$SCRIPT_DIR/anti-simplification.sh" ]]; then
|
|
154
156
|
bash "$SCRIPT_DIR/anti-simplification.sh" "$FILE_PATH" </dev/null || true
|
|
155
157
|
fi
|
|
156
158
|
|
|
@@ -79,6 +79,36 @@ plan_completeness_record_signature() {
|
|
|
79
79
|
EOF_STATE
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
plan_completeness_shell_quote() {
|
|
83
|
+
printf '%q' "$1"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
plan_completeness_capture_guidance() {
|
|
87
|
+
local kind prompt_slug source_ref title source_arg
|
|
88
|
+
|
|
89
|
+
kind="$(workflow_pending_orchestration_field kind 2>/dev/null || true)"
|
|
90
|
+
prompt_slug="$(workflow_pending_orchestration_field prompt_slug 2>/dev/null || true)"
|
|
91
|
+
source_ref="$(workflow_pending_orchestration_field source_ref 2>/dev/null || true)"
|
|
92
|
+
|
|
93
|
+
kind="${kind:-host-plan}"
|
|
94
|
+
prompt_slug="${prompt_slug:-planning}"
|
|
95
|
+
title="${source_ref:-$prompt_slug}"
|
|
96
|
+
source_arg=""
|
|
97
|
+
if [[ -n "$source_ref" ]]; then
|
|
98
|
+
source_arg=" --source-ref $(plan_completeness_shell_quote "$source_ref")"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
cat <<EOF_GUIDANCE
|
|
102
|
+
If the planning answer is decision-complete, capture the final plan body before stopping:
|
|
103
|
+
printf '%s\n' '<decision-complete plan body>' | bash scripts/capture-plan.sh --slug $(plan_completeness_shell_quote "$prompt_slug") --title $(plan_completeness_shell_quote "$title") --status Draft --source $(plan_completeness_shell_quote "$kind") --orchestration-kind $(plan_completeness_shell_quote "$kind") --route planning${source_arg}
|
|
104
|
+
|
|
105
|
+
If the user already approved implementation, use:
|
|
106
|
+
printf '%s\n' '<approved plan body>' | bash scripts/capture-plan.sh --slug $(plan_completeness_shell_quote "$prompt_slug") --title $(plan_completeness_shell_quote "$title") --status Approved --source $(plan_completeness_shell_quote "$kind") --orchestration-kind $(plan_completeness_shell_quote "$kind") --route planning --execute${source_arg}
|
|
107
|
+
|
|
108
|
+
If the plan is not decision-complete, revise once for: goal/success criteria, scope/non-scope, constraints, P1/P2/P3, fragile assumption, rejected alternative, public API/config/file-interface changes, external dependency/API key requirements, tests, rollback/failure handling, phase independence, and no placeholders. Do not implement until capture succeeds.
|
|
109
|
+
EOF_GUIDANCE
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
assistant_message_looks_like_plan() {
|
|
83
113
|
local message="$1"
|
|
84
114
|
local length
|
|
@@ -133,8 +163,9 @@ if should_run_plan_completeness_gate "$stop_hook_active" "$last_assistant_messag
|
|
|
133
163
|
if [[ "$(plan_completeness_last_signature 2>/dev/null || true)" != "$signature" ]]; then
|
|
134
164
|
plan_completeness_record_signature "$signature"
|
|
135
165
|
summary="$(workflow_pending_orchestration_summary)"
|
|
166
|
+
guidance="$(plan_completeness_capture_guidance)"
|
|
136
167
|
emit_stop_block_json "[PlanCompletenessGate] A first planning answer was produced while pending orchestration is still open: ${summary}
|
|
137
168
|
|
|
138
|
-
|
|
169
|
+
${guidance}"
|
|
139
170
|
fi
|
|
140
171
|
fi
|
|
@@ -5,7 +5,7 @@ Use this content for user-level `~/.codex/AGENTS.md` and `~/.claude/CLAUDE.md` w
|
|
|
5
5
|
```md
|
|
6
6
|
# Global Working Rules
|
|
7
7
|
|
|
8
|
-
- Use
|
|
8
|
+
- Use Chinese by default for this user; keep technical terms in English. If the user writes in another language, mirror that language.
|
|
9
9
|
- Act as an engineering collaborator: finish the concrete task, verify it, then report conclusion, actual change, reason, verification, and residual risk.
|
|
10
10
|
- Prefer direct execution over repeated confirmation. Stop to ask only when continuing would likely produce output contrary to the user's intent.
|
|
11
11
|
|
|
@@ -41,6 +41,23 @@ For architecture reviews, bug hunts, risky refactors, deployment issues, auth/pa
|
|
|
41
41
|
|
|
42
42
|
Reports must be concise and grounded in files, commands, runtime behavior, observed code, or verified system state.
|
|
43
43
|
|
|
44
|
+
## Completion Summary Rule
|
|
45
|
+
|
|
46
|
+
For non-trivial completed tasks, include a short `下一刀` section at the end of the final delivery report unless there is genuinely no meaningful follow-up.
|
|
47
|
+
For non-trivial completed tasks, include a short `下一刀` section only when verified state shows a concrete next bottleneck, unresolved risk, failing check, deployment gap, review gap, or active-plan item that materially affects the user's stated goal.
|
|
48
|
+
|
|
49
|
+
Do not manufacture follow-up work just to keep slicing. If the task is reasonably complete and the remaining work would be speculative, low-value polish, or over-engineering, omit `下一刀` and stop at the completion report.
|
|
50
|
+
|
|
51
|
+
The recommendation is not a question. It must be one concrete, bounded next slice derived from verified state: active plan, todo, handoff, failing checks, review gaps, deployment state, unresolved risk, or observed system behavior.
|
|
52
|
+
When included, the recommendation is not a question. It must be one concrete, bounded next slice derived from verified state: active plan, todo, handoff, failing checks, review gaps, deployment state, unresolved risk, or observed system behavior.
|
|
53
|
+
|
|
54
|
+
Format:
|
|
55
|
+
|
|
56
|
+
**下一刀**
|
|
57
|
+
建议切 `<具体方向>`。理由是 `<最影响推进的未闭环点>`。入口是 `<路径/命令/验证面>`。
|
|
58
|
+
|
|
59
|
+
The recommendation must also explain why this is the next bottleneck, why the slice is sufficient rather than an open-ended continuation, and the entrypoint file, command, route, artifact, or verification surface.
|
|
60
|
+
|
|
44
61
|
## Research Delegation
|
|
45
62
|
|
|
46
63
|
When a task requires broad research, repo archaeology, multi-source synthesis, or background surveys, delegate or isolate the research pass when the runtime supports it. Keep the main thread focused on planning, integration, and decisions.
|
|
@@ -24,13 +24,14 @@ Handoffs make long-running work resumable without trusting chat history.
|
|
|
24
24
|
## Restore Flow
|
|
25
25
|
|
|
26
26
|
1. Start a fresh Codex session instead of relying on auto-compact or `codex resume` when the old session is near the limit.
|
|
27
|
-
2.
|
|
28
|
-
3. Read `.ai/harness/handoff/
|
|
29
|
-
4. Read
|
|
30
|
-
5. Read
|
|
31
|
-
6. Read the
|
|
32
|
-
7. Read
|
|
33
|
-
8.
|
|
27
|
+
2. If the current user message lists files under `# Files mentioned by the user`, references `pasted-text.txt`, or includes an explicit attachment/file path, read those current-input files before repo recovery artifacts.
|
|
28
|
+
3. Read `.ai/harness/handoff/resume.md`.
|
|
29
|
+
4. Read `.ai/harness/handoff/current.md`.
|
|
30
|
+
5. Read `tasks/current.md` as an orientation snapshot only; in a non-target worktree, compare it with `git show <target>:tasks/current.md`.
|
|
31
|
+
6. Read the active plan and sprint contract.
|
|
32
|
+
7. Read the latest review file if one exists.
|
|
33
|
+
8. Read `.ai/harness/checks/latest.json`.
|
|
34
|
+
9. Resume from the exact next step.
|
|
34
35
|
|
|
35
36
|
## Source Of Truth
|
|
36
37
|
|
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
This repo uses a shared long-running harness. The durable workflow lives in repo-local artifacts, not in chat memory.
|
|
4
4
|
|
|
5
|
+
## Adoption Model
|
|
6
|
+
|
|
7
|
+
Use this file as the first onboarding map after `repo-harness update` installs
|
|
8
|
+
or refreshes a repo. The harness gives agents three durable surfaces:
|
|
9
|
+
|
|
10
|
+
- **Shared standards**: `docs/spec.md`, `docs/reference-configs/`, root
|
|
11
|
+
`AGENTS.md`, and root `CLAUDE.md` explain stable product intent, coding
|
|
12
|
+
rules, and local workflow boundaries.
|
|
13
|
+
- **Task contracts**: `plans/`, `tasks/contracts/`, `tasks/reviews/`, and
|
|
14
|
+
`.ai/harness/checks/` turn a request into scoped implementation work with
|
|
15
|
+
evidence-backed completion.
|
|
16
|
+
- **Session journal**: `.ai/harness/handoff/`, `tasks/current.md`, and
|
|
17
|
+
`.ai/harness/events.jsonl` let a new agent session resume from repo state
|
|
18
|
+
without treating chat history as authority.
|
|
19
|
+
|
|
20
|
+
The install is not an app scaffold or an agent gateway. It adds a reviewable
|
|
21
|
+
workflow contract around an existing repo, then leaves product code ownership
|
|
22
|
+
with the project.
|
|
23
|
+
|
|
5
24
|
## Roles
|
|
6
25
|
|
|
7
26
|
- **Planner** updates `docs/spec.md`, researches constraints, and writes or approves `plans/plan-*.md`.
|
|
@@ -36,7 +36,17 @@ repo-harness security scan --json
|
|
|
36
36
|
|
|
37
37
|
`PostToolUse.always` runs one merged observer, `post-tool-observer.sh` (JSONL trace + lightweight advisories); the trace file `.claude/.trace.jsonl` is the single tool-trace record.
|
|
38
38
|
|
|
39
|
-
`PostToolUse.edit` runs
|
|
39
|
+
`PostToolUse.edit` runs local edit reminders, the FirstPrinciples
|
|
40
|
+
anti-overengineering advisory, then the downstream sync chain: architecture
|
|
41
|
+
drift record, context contract sync, capability-context queueing, repo-to-brain
|
|
42
|
+
mirror sync, and active contract verification. These stages remain advisory. A
|
|
43
|
+
failed downstream stage must emit one `[SyncChain] WARN: ...` line and let the
|
|
44
|
+
edit hook exit 0 so local editing is not blocked by maintenance drift. The
|
|
45
|
+
FirstPrinciples advisory reviews only the current file diff and asks whether new
|
|
46
|
+
dependencies, compatibility branches, abstractions, config surfaces, or
|
|
47
|
+
branch-heavy logic truly need to exist; it must not override trust-boundary
|
|
48
|
+
validation, data-loss prevention, security, accessibility, or explicit
|
|
49
|
+
user-requested behavior.
|
|
40
50
|
|
|
41
51
|
`.ai/harness/scripts/sync-brain-docs.sh --changed <path>` is hot-path optimized: the PostEdit hook starts it only when the changed repo path appears in the brain manifest. The script still owns authoritative JSON parsing and containment checks. Source files that resolve outside the repo, or brain targets that resolve outside the configured brain root through symlinks, are rejected.
|
|
42
52
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.4.
|
|
3
|
-
"templateVersion": "0.4.
|
|
2
|
+
"version": "0.4.3",
|
|
3
|
+
"templateVersion": "0.4.3",
|
|
4
4
|
"skillName": "repo-harness",
|
|
5
5
|
"contractId": "tasks-first-harness-v1",
|
|
6
6
|
"retiredAliases": [
|
|
@@ -119,6 +119,10 @@
|
|
|
119
119
|
{
|
|
120
120
|
"version": "0.4.2",
|
|
121
121
|
"description": "Adds the PRD-to-Sprint planning hierarchy, isolates generated-project helper runtime under .ai/harness/scripts, and installs the subagent return-channel guard"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"version": "0.4.3",
|
|
125
|
+
"description": "Adds bundled runtime docs lookup, init-hook bootstrap audit guidance, first-principles edit guard coverage, and slimmer generated reference-doc assets"
|
|
122
126
|
}
|
|
123
127
|
],
|
|
124
128
|
"generatedProjectStamp": {
|