codex-harness-kit 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 +201 -0
- package/README.md +279 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +84 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/check-state.d.ts +4 -0
- package/dist/src/commands/check-state.js +15 -0
- package/dist/src/commands/check-state.js.map +1 -0
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +138 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/validate-harness.d.ts +4 -0
- package/dist/src/commands/validate-harness.js +9 -0
- package/dist/src/commands/validate-harness.js.map +1 -0
- package/dist/src/harness.d.ts +13 -0
- package/dist/src/harness.js +572 -0
- package/dist/src/harness.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/templates.d.ts +16 -0
- package/dist/src/templates.js +208 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/types.d.ts +54 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export const DEFAULT_CONFIG_PATH = "docs/harness-config.json";
|
|
2
|
+
export const HARNESS_MARKER_START = "<!-- codex-harness-kit:start -->";
|
|
3
|
+
export const HARNESS_MARKER_END = "<!-- codex-harness-kit:end -->";
|
|
4
|
+
export const HARNESS_BRIDGE_MARKER_START = "<!-- codex-harness-kit:bridge:start -->";
|
|
5
|
+
export const HARNESS_BRIDGE_MARKER_END = "<!-- codex-harness-kit:bridge:end -->";
|
|
6
|
+
export function createDefaultConfig() {
|
|
7
|
+
return {
|
|
8
|
+
version: 1,
|
|
9
|
+
paths: {
|
|
10
|
+
stateFile: "docs/harness-state.json",
|
|
11
|
+
memoryFile: "docs/project-memory.md",
|
|
12
|
+
decisionsFile: "docs/decisions.md",
|
|
13
|
+
contractsDir: "docs/contracts"
|
|
14
|
+
},
|
|
15
|
+
commands: {
|
|
16
|
+
verifyQuick: "",
|
|
17
|
+
verifyFull: "",
|
|
18
|
+
docsGenerate: ""
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
maxRepeatedFailures: 2
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function createDefaultState(now = new Date()) {
|
|
26
|
+
return {
|
|
27
|
+
currentGoal: "",
|
|
28
|
+
status: "idle",
|
|
29
|
+
currentContract: "docs/contracts/example-contract.md",
|
|
30
|
+
blockers: [],
|
|
31
|
+
nextStep: "Update the current goal and contract before making code changes.",
|
|
32
|
+
lastUpdated: now.toISOString(),
|
|
33
|
+
verification: {
|
|
34
|
+
lastCommand: "",
|
|
35
|
+
lastResult: "unknown",
|
|
36
|
+
notes: "No verification has been recorded yet."
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function renderJsonFile(value) {
|
|
41
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
42
|
+
}
|
|
43
|
+
export function renderAgentsTemplate(configPath = DEFAULT_CONFIG_PATH) {
|
|
44
|
+
return `${HARNESS_MARKER_START}
|
|
45
|
+
# AGENTS
|
|
46
|
+
|
|
47
|
+
## Codex Harness Workflow
|
|
48
|
+
|
|
49
|
+
1. Before changing code, read \`${configPath}\` first.
|
|
50
|
+
2. Then use the configured paths from that file instead of assuming fixed \`docs/...\` locations:
|
|
51
|
+
- read \`paths.stateFile\`
|
|
52
|
+
- read the active contract referenced by \`currentContract\` inside the state file
|
|
53
|
+
- read \`paths.decisionsFile\`
|
|
54
|
+
- read \`paths.memoryFile\`
|
|
55
|
+
- use \`paths.contractsDir\` for contract discovery
|
|
56
|
+
3. Use the configured validation commands from \`commands.verifyQuick\` and \`commands.verifyFull\` when they are set.
|
|
57
|
+
4. Restore state before editing. Do not jump straight into implementation.
|
|
58
|
+
5. Keep the contract current. If scope or acceptance changes, update the contract before more code changes.
|
|
59
|
+
6. After edits, run the smallest meaningful verification command and record the result in the file pointed to by \`paths.stateFile\`.
|
|
60
|
+
7. If the same class of failure reaches the configured repeated-failure limit in \`rules.maxRepeatedFailures\`, stop trial-and-error and write a short diagnosis with evidence, suspected root cause, and the safest next move.
|
|
61
|
+
8. Capture durable context:
|
|
62
|
+
- long-lived preferences and quirks go in \`paths.memoryFile\`
|
|
63
|
+
- explicit trade-offs and architectural choices go in \`paths.decisionsFile\`
|
|
64
|
+
9. Final responses must always say:
|
|
65
|
+
- what changed
|
|
66
|
+
- what verification ran
|
|
67
|
+
- what verification did not run
|
|
68
|
+
|
|
69
|
+
## Restore Prompt
|
|
70
|
+
|
|
71
|
+
When a new Codex thread starts, begin by reading the harness files above. A good prompt is:
|
|
72
|
+
|
|
73
|
+
> Restore state and continue from the harness files before making changes.
|
|
74
|
+
|
|
75
|
+
## Guardrails
|
|
76
|
+
|
|
77
|
+
- Prefer the existing repo layout over inventing a new framework.
|
|
78
|
+
- Keep this harness lightweight; do not turn it into a platform.
|
|
79
|
+
- If validation is not configured yet, say so explicitly instead of claiming full verification.
|
|
80
|
+
${HARNESS_MARKER_END}
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
export function renderAgentsHarnessSupplement(configPath = DEFAULT_CONFIG_PATH) {
|
|
84
|
+
return `${HARNESS_MARKER_START}
|
|
85
|
+
# AGENTS Harness Supplement
|
|
86
|
+
|
|
87
|
+
This file is active only when \`AGENTS.md\` contains the codex-harness-kit bridge block.
|
|
88
|
+
|
|
89
|
+
## Harness Rules
|
|
90
|
+
|
|
91
|
+
1. Read \`${configPath}\` first.
|
|
92
|
+
2. Resolve the working files from \`paths.stateFile\`, \`paths.memoryFile\`, \`paths.decisionsFile\`, and \`paths.contractsDir\`.
|
|
93
|
+
3. Open the active contract from \`currentContract\` in the state file before writing code.
|
|
94
|
+
4. Restore state before editing, then keep the contract current as scope changes.
|
|
95
|
+
5. After edits, run the smallest meaningful verification command from the config and record the result back into the configured state file.
|
|
96
|
+
6. If repeated failures hit the configured limit in \`rules.maxRepeatedFailures\`, stop guessing and produce a diagnosis instead of trying random fixes.
|
|
97
|
+
7. Write durable preferences to the memory file and explicit trade-offs to the decisions file.
|
|
98
|
+
8. Final responses must say what changed, what verification ran, and what verification did not run.
|
|
99
|
+
${HARNESS_MARKER_END}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
export function renderAgentsActivationBridge(configPath = DEFAULT_CONFIG_PATH) {
|
|
103
|
+
return `${HARNESS_BRIDGE_MARKER_START}
|
|
104
|
+
## Codex Harness Activation
|
|
105
|
+
|
|
106
|
+
This repository uses \`codex-harness-kit\`.
|
|
107
|
+
|
|
108
|
+
Keep the existing instructions in this file, and additionally treat \`AGENTS.harness.md\` as active instructions.
|
|
109
|
+
|
|
110
|
+
Before making code changes:
|
|
111
|
+
|
|
112
|
+
1. Read \`${configPath}\` first.
|
|
113
|
+
2. Use the file paths from the config \`paths\` object instead of assuming fixed \`docs/...\` paths.
|
|
114
|
+
3. Follow the harness workflow in \`AGENTS.harness.md\` together with the rest of this file.
|
|
115
|
+
${HARNESS_BRIDGE_MARKER_END}
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
export function renderProjectMemoryTemplate() {
|
|
119
|
+
return `# Project Memory
|
|
120
|
+
|
|
121
|
+
Use this file for durable context that should survive across threads.
|
|
122
|
+
|
|
123
|
+
## Product and Repo Context
|
|
124
|
+
|
|
125
|
+
- What this repository is for.
|
|
126
|
+
- Constraints that matter every time.
|
|
127
|
+
|
|
128
|
+
## Working Preferences
|
|
129
|
+
|
|
130
|
+
- Coding style choices that are stable over time.
|
|
131
|
+
- Review preferences or release expectations.
|
|
132
|
+
|
|
133
|
+
## Known Pitfalls
|
|
134
|
+
|
|
135
|
+
- Repeated mistakes, flaky areas, or environment traps.
|
|
136
|
+
|
|
137
|
+
## Open Questions Worth Tracking
|
|
138
|
+
|
|
139
|
+
- Questions that are not blockers today but should not disappear.
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
export function renderDecisionsTemplate() {
|
|
143
|
+
return `# Decisions
|
|
144
|
+
|
|
145
|
+
Record notable technical or product decisions here so they do not live only in chat history.
|
|
146
|
+
|
|
147
|
+
## Entry Template
|
|
148
|
+
|
|
149
|
+
### YYYY-MM-DD - Short Decision Title
|
|
150
|
+
|
|
151
|
+
- Context:
|
|
152
|
+
- Decision:
|
|
153
|
+
- Consequences:
|
|
154
|
+
- Follow-up:
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
export function renderContractsReadmeTemplate() {
|
|
158
|
+
return `# Contracts
|
|
159
|
+
|
|
160
|
+
Contracts define the current unit of work before code changes begin.
|
|
161
|
+
|
|
162
|
+
Each contract should answer:
|
|
163
|
+
|
|
164
|
+
1. What is being changed right now?
|
|
165
|
+
2. What is explicitly out of scope?
|
|
166
|
+
3. How will we know it is done?
|
|
167
|
+
4. What is the smallest verification that proves progress?
|
|
168
|
+
|
|
169
|
+
Suggested flow:
|
|
170
|
+
|
|
171
|
+
1. Update or create a contract.
|
|
172
|
+
2. Point \`currentContract\` in your configured state file at that contract.
|
|
173
|
+
3. Implement against the contract.
|
|
174
|
+
4. Run verification.
|
|
175
|
+
5. Update state and decisions.
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
export function renderExampleContractTemplate() {
|
|
179
|
+
return `# Example Contract
|
|
180
|
+
|
|
181
|
+
## Goal
|
|
182
|
+
|
|
183
|
+
Describe the current objective in one or two sentences.
|
|
184
|
+
|
|
185
|
+
## In Scope
|
|
186
|
+
|
|
187
|
+
- The smallest changes that count as success.
|
|
188
|
+
|
|
189
|
+
## Out of Scope
|
|
190
|
+
|
|
191
|
+
- Anything intentionally deferred.
|
|
192
|
+
|
|
193
|
+
## Acceptance Criteria
|
|
194
|
+
|
|
195
|
+
- A reader can tell whether the task is done.
|
|
196
|
+
- Validation steps are explicit.
|
|
197
|
+
|
|
198
|
+
## Verification Plan
|
|
199
|
+
|
|
200
|
+
- Quick check:
|
|
201
|
+
- Full check:
|
|
202
|
+
|
|
203
|
+
## Notes
|
|
204
|
+
|
|
205
|
+
- Risks, assumptions, or sequencing notes.
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/templates.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,yCAAyC,CAAC;AACrF,MAAM,CAAC,MAAM,yBAAyB,GAAG,uCAAuC,CAAC;AAEjF,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,OAAO,EAAE,CAAC;QACV,KAAK,EAAE;YACL,SAAS,EAAE,yBAAyB;YACpC,UAAU,EAAE,wBAAwB;YACpC,aAAa,EAAE,mBAAmB;YAClC,YAAY,EAAE,gBAAgB;SAC/B;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,EAAE;YACf,UAAU,EAAE,EAAE;YACd,YAAY,EAAE,EAAE;SACjB;QACD,KAAK,EAAE;YACL,mBAAmB,EAAE,CAAC;SACvB;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE;IACjD,OAAO;QACL,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,MAAM;QACd,eAAe,EAAE,oCAAoC;QACrD,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,kEAAkE;QAC5E,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE;QAC9B,YAAY,EAAE;YACZ,WAAW,EAAE,EAAE;YACf,UAAU,EAAE,SAAS;YACrB,KAAK,EAAE,wCAAwC;SAChD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAU,GAAG,mBAAmB;IACnE,OAAO,GAAG,oBAAoB;;;;;kCAKE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B1C,kBAAkB;CACnB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,UAAU,GAAG,mBAAmB;IAC5E,OAAO,GAAG,oBAAoB;;;;;;;YAOpB,UAAU;;;;;;;;EAQpB,kBAAkB;CACnB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,UAAU,GAAG,mBAAmB;IAC3E,OAAO,GAAG,2BAA2B;;;;;;;;;YAS3B,UAAU;;;EAGpB,yBAAyB;CAC1B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;CAqBR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO;;;;;;;;;;;;CAYR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO;;;;;;;;;;;;;;;;;;CAkBR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface HarnessConfig {
|
|
2
|
+
version: number;
|
|
3
|
+
paths: {
|
|
4
|
+
stateFile: string;
|
|
5
|
+
memoryFile: string;
|
|
6
|
+
decisionsFile: string;
|
|
7
|
+
contractsDir: string;
|
|
8
|
+
};
|
|
9
|
+
commands: {
|
|
10
|
+
verifyQuick: string;
|
|
11
|
+
verifyFull: string;
|
|
12
|
+
docsGenerate: string;
|
|
13
|
+
};
|
|
14
|
+
rules: {
|
|
15
|
+
maxRepeatedFailures: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface HarnessState {
|
|
19
|
+
currentGoal: string;
|
|
20
|
+
status: string;
|
|
21
|
+
currentContract: string;
|
|
22
|
+
blockers: string[];
|
|
23
|
+
nextStep: string;
|
|
24
|
+
lastUpdated: string;
|
|
25
|
+
verification: {
|
|
26
|
+
lastCommand: string;
|
|
27
|
+
lastResult: string;
|
|
28
|
+
notes: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ValidationIssue {
|
|
32
|
+
level: "error" | "warning";
|
|
33
|
+
path?: string;
|
|
34
|
+
message: string;
|
|
35
|
+
suggestion?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ValidationReport {
|
|
38
|
+
ok: boolean;
|
|
39
|
+
repoRoot: string;
|
|
40
|
+
agentsFile: string | null;
|
|
41
|
+
issues: ValidationIssue[];
|
|
42
|
+
config?: HarnessConfig;
|
|
43
|
+
state?: HarnessState;
|
|
44
|
+
}
|
|
45
|
+
export interface FileAction {
|
|
46
|
+
file: string;
|
|
47
|
+
status: "created" | "updated" | "unchanged" | "skipped";
|
|
48
|
+
reason?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface InitResult {
|
|
51
|
+
repoRoot: string;
|
|
52
|
+
actions: FileAction[];
|
|
53
|
+
notes: string[];
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-harness-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lightweight CLI and scaffold for Codex-style harness workflows in any repository.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/src/index.js",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"codex-harness-kit": "dist/src/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/src",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.18"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
22
|
+
"prepack": "npm run build",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
24
|
+
"test": "npm run build && node --test dist/tests/*.test.js",
|
|
25
|
+
"verify": "npm run typecheck && npm test"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"codex",
|
|
29
|
+
"harness",
|
|
30
|
+
"cli",
|
|
31
|
+
"typescript",
|
|
32
|
+
"agent"
|
|
33
|
+
],
|
|
34
|
+
"license": "Apache-2.0",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/lonelyreader/codex-harness-kit.git"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^24.6.0",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|