@brawnen/agent-harness-protocol 0.1.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 +21 -0
- package/README.md +61 -0
- package/README.zh-CN.md +22 -0
- package/adapters/claude-code/hooks.json +27 -0
- package/adapters/claude-code/rules-injection.md +14 -0
- package/adapters/codex/rules-injection.md +16 -0
- package/adapters/gemini-cli/rules-injection.md +9 -0
- package/package.json +34 -0
- package/rules/base.md +54 -0
- package/rules/full.md +104 -0
- package/schemas/audit-log.schema.json +90 -0
- package/schemas/harness-config.schema.json +427 -0
- package/schemas/intake-result.schema.json +96 -0
- package/schemas/report.schema.json +245 -0
- package/schemas/state-index.schema.json +67 -0
- package/schemas/task-draft.schema.json +141 -0
- package/schemas/task-state.schema.json +200 -0
- package/templates/bug.md +58 -0
- package/templates/explore.md +57 -0
- package/templates/feature.md +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 brawnen
|
|
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,61 @@
|
|
|
1
|
+
# @brawnen/agent-harness-protocol
|
|
2
|
+
|
|
3
|
+
[中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
`@brawnen/agent-harness-protocol` contains the protocol-layer assets of `agent-harness`.
|
|
6
|
+
|
|
7
|
+
It currently includes:
|
|
8
|
+
|
|
9
|
+
- `rules/` for protocol rules
|
|
10
|
+
- `schemas/` for JSON Schema files
|
|
11
|
+
- `templates/` for task templates
|
|
12
|
+
- `adapters/` for host integration examples and guidance
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
This package exists so the protocol can be reused independently from the CLI.
|
|
17
|
+
|
|
18
|
+
That means:
|
|
19
|
+
|
|
20
|
+
- the protocol must remain usable on its own
|
|
21
|
+
- rules must not exist only inside the CLI
|
|
22
|
+
- the CLI may depend on `protocol`
|
|
23
|
+
- `protocol` must not depend on `cli`
|
|
24
|
+
|
|
25
|
+
## Current Status
|
|
26
|
+
|
|
27
|
+
The current repository already places the protocol resources here:
|
|
28
|
+
|
|
29
|
+
- `schemas/`
|
|
30
|
+
- `templates/`
|
|
31
|
+
- `rules/base.md`
|
|
32
|
+
- `rules/full.md`
|
|
33
|
+
- `adapters/` for host-specific notes and example configuration
|
|
34
|
+
|
|
35
|
+
## Typical Use
|
|
36
|
+
|
|
37
|
+
If you only want the behavior contract, without installing the full CLI:
|
|
38
|
+
|
|
39
|
+
1. Copy `rules/base.md` or `rules/full.md` into `AGENTS.md`, `CLAUDE.md`, or `GEMINI.md`
|
|
40
|
+
2. Reuse task templates from `templates/`
|
|
41
|
+
3. Reuse schemas from `schemas/`
|
|
42
|
+
4. Use `adapters/` as host-specific reference material
|
|
43
|
+
|
|
44
|
+
## Scope
|
|
45
|
+
|
|
46
|
+
This package is responsible for:
|
|
47
|
+
|
|
48
|
+
- protocol rules
|
|
49
|
+
- schemas
|
|
50
|
+
- task templates
|
|
51
|
+
- host adapter examples
|
|
52
|
+
|
|
53
|
+
This package is not responsible for:
|
|
54
|
+
|
|
55
|
+
- project initialization
|
|
56
|
+
- task state persistence
|
|
57
|
+
- audit log writing
|
|
58
|
+
- gate execution
|
|
59
|
+
- report generation
|
|
60
|
+
|
|
61
|
+
Those responsibilities belong to `@brawnen/agent-harness-cli`.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @brawnen/agent-harness-protocol
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
这个包承载 `agent-harness` 的协议层资源:
|
|
6
|
+
|
|
7
|
+
- `rules/`:协议规则文本
|
|
8
|
+
- `schemas/`:JSON Schema
|
|
9
|
+
- `templates/`:任务模板
|
|
10
|
+
- `adapters/`:宿主适配示例
|
|
11
|
+
|
|
12
|
+
设计约束:
|
|
13
|
+
|
|
14
|
+
- 这个包必须可独立使用
|
|
15
|
+
- 协议规则不能只存在于 CLI 内部
|
|
16
|
+
- CLI 可以依赖这个包,但这个包不能反向依赖 CLI
|
|
17
|
+
|
|
18
|
+
当前状态:
|
|
19
|
+
|
|
20
|
+
- `schemas/` 与 `templates/` 已进入 `packages/protocol`
|
|
21
|
+
- `rules/` 已拆出 `base.md` 与 `full.md`
|
|
22
|
+
- `adapters/` 先提供宿主接入说明和示例配置
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Claude Code hooks template for the future Node.js CLI. This file is an adapter example, not a final contract.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"PreToolUse": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": "Write|Edit|Bash|NotebookEdit",
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "agent-harness gate before-tool --tool \"$TOOL_NAME\""
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PostToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": ".*",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "agent-harness state update --tool \"$TOOL_NAME\" --exit-code \"$EXIT_CODE\""
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Codex Rules Injection
|
|
2
|
+
|
|
3
|
+
建议将 `rules/full.md` 或 `rules/base.md` 注入项目根目录 `AGENTS.md`。
|
|
4
|
+
|
|
5
|
+
当前阶段:
|
|
6
|
+
|
|
7
|
+
- Codex 仍以 L2 规则约束为基础
|
|
8
|
+
- 当前仓库已经内置 repo-local `.codex/hooks.json`
|
|
9
|
+
- 当前仓库也已通过 `.codex/config.toml` 默认设置 `features.codex_hooks = true`
|
|
10
|
+
- 自动 intake 通过 `UserPromptSubmit` 接入,active task 恢复通过 `SessionStart` 接入
|
|
11
|
+
- 使用前需启用 `codex_hooks` feature flag
|
|
12
|
+
- 若项目为 trusted project,可直接依赖项目级配置,无需每次手动 `--enable`
|
|
13
|
+
- 当前最小 hooks 方案优先接 `UserPromptSubmit` 和 `SessionStart`
|
|
14
|
+
- 自动 intake 失败时应降级到 `task intake` / `task suspend-active`
|
|
15
|
+
- 宿主级执行/完成门禁仍依赖后续 CLI 与宿主能力演进
|
|
16
|
+
- `@brawnen/agent-harness-cli init --host codex` 后续应负责自动写入 `AGENTS.md` 与 `.codex/hooks.json`
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brawnen/agent-harness-protocol",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Protocol assets for agent-harness: rules, schemas, templates, and adapter examples.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"rules",
|
|
8
|
+
"schemas",
|
|
9
|
+
"templates",
|
|
10
|
+
"adapters",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"README.md",
|
|
13
|
+
"README.zh-CN.md"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agent",
|
|
17
|
+
"ai",
|
|
18
|
+
"protocol",
|
|
19
|
+
"schema",
|
|
20
|
+
"workflow"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/brawnen/agent-harness.git",
|
|
25
|
+
"directory": "packages/protocol"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/brawnen/agent-harness/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/brawnen/agent-harness/tree/main/packages/protocol",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/rules/base.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Agent Harness Base Rules
|
|
2
|
+
|
|
3
|
+
## Intake
|
|
4
|
+
|
|
5
|
+
每次收到新任务,先内部收敛:
|
|
6
|
+
|
|
7
|
+
- `intent`
|
|
8
|
+
- `goal`
|
|
9
|
+
- `scope`
|
|
10
|
+
- `acceptance`
|
|
11
|
+
|
|
12
|
+
字段已闭合且无阻断问题,才能进入 `plan`。
|
|
13
|
+
|
|
14
|
+
## Clarify
|
|
15
|
+
|
|
16
|
+
只在以下情况追问用户,且每次只问一个最高价值问题:
|
|
17
|
+
|
|
18
|
+
1. scope 不清,可能越界
|
|
19
|
+
2. acceptance 无法判断完成
|
|
20
|
+
3. 命中高风险区域
|
|
21
|
+
4. 存在高成本路径分叉
|
|
22
|
+
|
|
23
|
+
## Execute Gate
|
|
24
|
+
|
|
25
|
+
以下情况禁止直接执行工具调用或修改文件:
|
|
26
|
+
|
|
27
|
+
1. `intent / goal / scope / acceptance` 未确定
|
|
28
|
+
2. 当前任务处于 `needs_clarification`
|
|
29
|
+
3. 执行动作明显超出 scope
|
|
30
|
+
4. 存在未处理的阻断问题
|
|
31
|
+
|
|
32
|
+
## Completion Gate
|
|
33
|
+
|
|
34
|
+
以下情况禁止宣称完成:
|
|
35
|
+
|
|
36
|
+
- bug / feature:没有验证证据
|
|
37
|
+
- refactor:没有证明行为未破坏
|
|
38
|
+
- explore:没有结论、依据、风险和下一步
|
|
39
|
+
- prototype:没有标注未验证范围
|
|
40
|
+
|
|
41
|
+
## Interaction Contract
|
|
42
|
+
|
|
43
|
+
每轮任务相关输出至少包含:
|
|
44
|
+
|
|
45
|
+
- 我的理解
|
|
46
|
+
- 当前假设
|
|
47
|
+
- 阻断缺口
|
|
48
|
+
- 下一步动作
|
|
49
|
+
|
|
50
|
+
## Interaction Rhythm
|
|
51
|
+
|
|
52
|
+
- 确认前:先给方案,再等待用户确认
|
|
53
|
+
- 确认后:直接执行,不重复上一轮完整方案
|
|
54
|
+
- 最终结果:只做一次收口,不把中间总结原样再说一遍
|
package/rules/full.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Agent Harness Full Rules
|
|
2
|
+
|
|
3
|
+
## Intake
|
|
4
|
+
|
|
5
|
+
每次收到新任务输入时,必须先在内部完成以下推断,再决定下一步动作:
|
|
6
|
+
|
|
7
|
+
- **intent**:bug / feature / explore / refactor / prototype
|
|
8
|
+
- **goal**:一句话描述要达成的结果
|
|
9
|
+
- **scope**:允许修改或分析的文件/模块边界
|
|
10
|
+
- **acceptance**:什么算完成(可执行的验收标准)
|
|
11
|
+
- **constraints**:不允许做的事(用户显式或隐式要求)
|
|
12
|
+
- **assumptions**:已采用但未经用户确认的假设
|
|
13
|
+
|
|
14
|
+
推断完成后,根据字段完整性和风险信号决定 `next_action`:
|
|
15
|
+
|
|
16
|
+
- 所有必填字段已闭合且无阻断问题 → `plan`
|
|
17
|
+
- scope 有方向但需先阅读代码确认边界 → `observe`
|
|
18
|
+
- 存在阻断缺口 → `clarify`
|
|
19
|
+
|
|
20
|
+
## Clarify
|
|
21
|
+
|
|
22
|
+
只在以下情况追问用户,且每次只问一个最高价值问题:
|
|
23
|
+
|
|
24
|
+
1. scope 不清,可能越过 protected_paths 或影响范围过大
|
|
25
|
+
2. acceptance 无法判断完成
|
|
26
|
+
3. 存在高成本路径分叉
|
|
27
|
+
4. 命中高风险区域
|
|
28
|
+
5. 任务依赖外部资源或权限
|
|
29
|
+
|
|
30
|
+
禁止追问:
|
|
31
|
+
|
|
32
|
+
- 可以通过阅读代码自行确认的技术细节
|
|
33
|
+
- 已有合理默认值的可选配置
|
|
34
|
+
- 与当前阻断无关的低优先级问题
|
|
35
|
+
|
|
36
|
+
## Observe
|
|
37
|
+
|
|
38
|
+
当 `next_action = observe` 时:
|
|
39
|
+
|
|
40
|
+
- 只允许只读动作
|
|
41
|
+
- 禁止修改文件和运行有副作用的命令
|
|
42
|
+
- observe 结束后必须更新任务理解
|
|
43
|
+
|
|
44
|
+
## Execute Gate
|
|
45
|
+
|
|
46
|
+
以下情况禁止直接执行工具调用或修改文件:
|
|
47
|
+
|
|
48
|
+
1. `intent / goal / scope / acceptance` 尚未全部确定
|
|
49
|
+
2. 当前任务处于 `needs_clarification`
|
|
50
|
+
3. 执行动作明显超出已确认 scope
|
|
51
|
+
4. 命中高风险范围但未获确认
|
|
52
|
+
5. 存在未处理的阻断问题
|
|
53
|
+
|
|
54
|
+
## Completion Gate
|
|
55
|
+
|
|
56
|
+
以下情况禁止宣称任务完成:
|
|
57
|
+
|
|
58
|
+
- bug:至少一条命令或测试证明问题不再复现
|
|
59
|
+
- feature:至少一条命令或验证动作证明新能力可运行
|
|
60
|
+
- refactor:至少一条测试证明行为未破坏
|
|
61
|
+
- explore:必须给出结论、依据、风险与下一步建议
|
|
62
|
+
- prototype:可无强制验证,但必须明确标注未验证范围
|
|
63
|
+
|
|
64
|
+
通用阻断条件:
|
|
65
|
+
|
|
66
|
+
- 必需 evidence 未产生
|
|
67
|
+
- acceptance 与实际结果不匹配
|
|
68
|
+
- 仍存在未关闭的阻断问题
|
|
69
|
+
|
|
70
|
+
## Force Override
|
|
71
|
+
|
|
72
|
+
用户可以显式要求跳过某个门禁。
|
|
73
|
+
|
|
74
|
+
Override 允许跳过:
|
|
75
|
+
|
|
76
|
+
- clarify 追问
|
|
77
|
+
- 高风险确认提示
|
|
78
|
+
- 非强制验证要求
|
|
79
|
+
|
|
80
|
+
Override 不能跳过:
|
|
81
|
+
|
|
82
|
+
- protected_paths 写入限制
|
|
83
|
+
- 文件系统或平台硬权限限制
|
|
84
|
+
|
|
85
|
+
## Interaction Contract
|
|
86
|
+
|
|
87
|
+
每轮任务相关输出必须包含:
|
|
88
|
+
|
|
89
|
+
1. 我的理解
|
|
90
|
+
2. 当前假设
|
|
91
|
+
3. 阻断缺口
|
|
92
|
+
4. 下一步动作
|
|
93
|
+
|
|
94
|
+
## Interaction Rhythm
|
|
95
|
+
|
|
96
|
+
- 在 `plan` 阶段给出方案后,应等待用户确认
|
|
97
|
+
- 用户确认后,进入 `execute`,不重复上一轮完整方案
|
|
98
|
+
- 最终收口只输出一次结果,不重复中间进度总结
|
|
99
|
+
|
|
100
|
+
## Multi-Task
|
|
101
|
+
|
|
102
|
+
- 新输入默认先判断是否属于当前活跃任务
|
|
103
|
+
- 若明显是新任务,新建任务并将当前任务挂起
|
|
104
|
+
- 无法确定时,主动询问用户是在延续旧任务还是新任务
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://harness.local/schemas/audit-log.schema.json",
|
|
4
|
+
"title": "Harness Audit Log",
|
|
5
|
+
"description": "门禁违规、force_override、补救动作的审计日志。",
|
|
6
|
+
"$defs": {
|
|
7
|
+
"audit_entry": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"required": [
|
|
11
|
+
"event_type",
|
|
12
|
+
"task_id",
|
|
13
|
+
"phase",
|
|
14
|
+
"signal",
|
|
15
|
+
"description",
|
|
16
|
+
"timestamp"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"event_type": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": [
|
|
22
|
+
"force_override",
|
|
23
|
+
"gate_violation",
|
|
24
|
+
"remediation",
|
|
25
|
+
"state_recovery",
|
|
26
|
+
"manual_confirmation"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"task_id": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"phase": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": [
|
|
35
|
+
"intake",
|
|
36
|
+
"clarify",
|
|
37
|
+
"plan",
|
|
38
|
+
"execute",
|
|
39
|
+
"verify",
|
|
40
|
+
"report",
|
|
41
|
+
"close"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"signal": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "触发此事件的控制信号名,例如 block_plan、block_execution"
|
|
47
|
+
},
|
|
48
|
+
"description": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "事件描述:被跳过的门禁、违规内容、补救措施"
|
|
51
|
+
},
|
|
52
|
+
"user_input": {
|
|
53
|
+
"type": ["string", "null"],
|
|
54
|
+
"description": "触发 override 的用户原文,非 override 事件可为 null"
|
|
55
|
+
},
|
|
56
|
+
"risk_at_time": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": [
|
|
59
|
+
"low",
|
|
60
|
+
"medium",
|
|
61
|
+
"high",
|
|
62
|
+
"unknown"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"timestamp": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"format": "date-time"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"required": [
|
|
75
|
+
"schema_version",
|
|
76
|
+
"entries"
|
|
77
|
+
],
|
|
78
|
+
"properties": {
|
|
79
|
+
"schema_version": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"const": "0.3"
|
|
82
|
+
},
|
|
83
|
+
"entries": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"items": {
|
|
86
|
+
"$ref": "#/$defs/audit_entry"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|