opencode-harness-kit 0.4.3 → 0.4.5
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/CHANGELOG.md +569 -18
- package/CONTRIBUTING.md +249 -0
- package/GLOBAL.md +34 -5
- package/MIGRATION.md +151 -0
- package/README.md +354 -66
- package/SECURITY.md +30 -0
- package/bin/baseline.mjs +15 -7
- package/bin/git-hooks/pre-commit +41 -9
- package/bin/oc-harness.mjs +1268 -82
- package/dist/config.d.ts +127 -0
- package/dist/denylist.d.ts +33 -0
- package/dist/effort.d.ts +64 -0
- package/dist/guard.d.ts +23 -0
- package/dist/health.d.ts +43 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +532 -149
- package/dist/plugin.d.ts +15 -0
- package/dist/profile.d.ts +399 -0
- package/dist/project.d.ts +8 -0
- package/dist/prune.d.ts +6 -0
- package/dist/router.d.ts +3 -0
- package/dist/rules.d.ts +109 -0
- package/dist/safe.d.ts +7 -0
- package/dist/telemetry-store.d.ts +12 -0
- package/dist/telemetry.d.ts +3 -0
- package/docs/EXIT-CODES.md +83 -0
- package/docs/KNOWN-LIMITS.md +45 -21
- package/docs/RESEARCH.md +20 -5
- package/docs/ROUTING.md +191 -31
- package/eval/RESULTS.md +457 -0
- package/eval/ab.mjs +743 -0
- package/eval/attribute.mjs +170 -0
- package/eval/flags.mjs +88 -0
- package/eval/measure-install.mjs +331 -0
- package/eval/measure-prune.mjs +339 -0
- package/eval/metrics.js +79 -0
- package/eval/models.mjs +302 -0
- package/eval/premises.mjs +200 -0
- package/eval/prepare.mjs +233 -0
- package/eval/run.mjs +376 -0
- package/eval/tasks-self.json +81 -0
- package/eval/tasks-ts.json +50 -0
- package/eval/tasks.json +83 -0
- package/eval/thresholds.mjs +134 -0
- package/eval/verify.mjs +287 -0
- package/package.json +44 -17
- package/profiles/fleet-all.json +6 -1
- package/profiles/fleet-safe.json +7 -3
- package/profiles/schema.json +182 -51
- package/prompts/build.md +4 -2
- package/skills/space-build/SKILL.md +4 -2
- package/skills/space-finish/SKILL.md +6 -2
- package/skills/space-plan/reference/task-template.md +13 -5
- package/src/config.js +182 -32
- package/src/denylist.js +95 -0
- package/src/driver/run.mjs +81 -16
- package/src/effort.js +15 -4
- package/src/guard.ts +165 -13
- package/src/health.js +80 -0
- package/src/index.ts +15 -4
- package/src/lane-usage.js +72 -18
- package/src/plugin-type-check.ts +38 -0
- package/src/plugin.ts +39 -0
- package/src/profile.js +225 -26
- package/src/project.js +47 -0
- package/src/prune.ts +110 -31
- package/src/router.ts +32 -63
- package/src/rules.js +99 -7
- package/src/safe.ts +27 -0
- package/src/sqlite.js +144 -0
- package/src/tasks.js +112 -29
- package/src/telemetry-store.ts +62 -0
- package/src/telemetry.ts +60 -57
- package/src/trust.js +70 -9
package/bin/baseline.mjs
CHANGED
|
@@ -19,18 +19,24 @@ const wantJson = args.includes("--json")
|
|
|
19
19
|
const dbArg = args.indexOf("--db")
|
|
20
20
|
const DB = dbArg >= 0 ? args[dbArg + 1] : join(homedir(), ".local/share/opencode/opencode.db")
|
|
21
21
|
|
|
22
|
+
const { canQuerySqlite, sqliteMissingMessage, query: queryDb } = await import("../src/sqlite.js")
|
|
23
|
+
|
|
22
24
|
if (!existsSync(DB)) {
|
|
23
25
|
console.error(`opencode database not found: ${DB}`)
|
|
24
26
|
console.error("pass --db <path> or run opencode at least once first")
|
|
25
27
|
process.exit(1)
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
// The sqlite3 CLI, not the library. A missing tool is a thing a person can
|
|
31
|
+
// fix, and the failure used to be a raw `spawnSync sqlite3 ENOENT` stack
|
|
32
|
+
// trace.
|
|
33
|
+
if (!canQuerySqlite()) {
|
|
34
|
+
console.error(sqliteMissingMessage())
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
function query(sql) {
|
|
29
|
-
|
|
30
|
-
encoding: "utf8",
|
|
31
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
32
|
-
}).trim()
|
|
33
|
-
return out ? JSON.parse(out) : []
|
|
39
|
+
return queryDb(DB, sql)
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
const ASSISTANT = `json_extract(data,'$.role')='assistant'`
|
|
@@ -163,7 +169,9 @@ const topAskers = () => {
|
|
|
163
169
|
// allowlist, which meant the number it reported was whatever the list looked
|
|
164
170
|
// like when the copy was last edited. Every tuning decision in this project is
|
|
165
171
|
// supposed to rest on this measurement, so it has to measure the real list.
|
|
166
|
-
const { BASH_ALLOWLIST } = await import(
|
|
172
|
+
const { BASH_ALLOWLIST } = await import(
|
|
173
|
+
new URL("../src/config.js", import.meta.url).href,
|
|
174
|
+
)
|
|
167
175
|
const kitAllowlist = BASH_ALLOWLIST
|
|
168
176
|
const currentAllow = [
|
|
169
177
|
"git status *", "git log *", "git diff *", "grep *",
|
|
@@ -184,7 +192,7 @@ const paidEquivalent =
|
|
|
184
192
|
//
|
|
185
193
|
// This exists because the kit once shipped max_lines 200 / max_bytes 8192 on
|
|
186
194
|
// the reasoning that tight truncation "saves context", and a later install
|
|
187
|
-
// measured 415 of 2,
|
|
195
|
+
// measured 415 of 2,966 reads exceeding 8 KB against 423 reads issued with an
|
|
188
196
|
// `offset`. Truncation causes the re-read roughly one for one, and at the
|
|
189
197
|
// measured ~17s median per request that round trip is more expensive than the
|
|
190
198
|
// tokens it saves. Re-run this before changing these numbers again.
|
package/bin/git-hooks/pre-commit
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
# Installed by `oc-harness install`. Remove with: rm .git/hooks/pre-commit
|
|
3
3
|
#
|
|
4
|
-
#
|
|
5
|
-
# left out: measure and attribute read ~/.local/share/opencode, which is slow,
|
|
6
|
-
# machine-specific, and irrelevant to whether a commit broke the kit.
|
|
4
|
+
# It runs the PROJECT's own checks, and only if the project has any.
|
|
7
5
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# The previous version ran `npm run test:all`, which is a script of THIS KIT,
|
|
7
|
+
# not of the project the hook was installed into. So in every project that
|
|
8
|
+
# installed the kit, every commit failed with:
|
|
9
|
+
#
|
|
10
|
+
# npm error Missing script: "test:all"
|
|
11
|
+
#
|
|
12
|
+
# until the author reached for --no-verify. A gate that blocks every commit
|
|
13
|
+
# is not a gate.
|
|
14
|
+
#
|
|
15
|
+
# The kit's own repository is the exception, and it is handled by the script
|
|
16
|
+
# list below: `test:all` is there, so the kit gates itself.
|
|
17
|
+
#
|
|
18
|
+
# The live-install half is deliberately left out: measure and attribute read
|
|
19
|
+
# ~/.local/share/opencode, which is slow, machine-specific, and irrelevant to
|
|
20
|
+
# whether a commit broke anything.
|
|
10
21
|
|
|
11
22
|
set -e
|
|
12
23
|
|
|
@@ -18,13 +29,34 @@ if [ -n "$SKIP_SPACE_HARNESS_HOOK" ]; then
|
|
|
18
29
|
exit 0
|
|
19
30
|
fi
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
if !
|
|
32
|
+
# No package.json, no JavaScript project, no gate.
|
|
33
|
+
if [ ! -f package.json ]; then
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# The gate is the project's own test script, if it has one. The kit's own
|
|
38
|
+
# repository has `test:all`, which is the offline half of its gate.
|
|
39
|
+
gate=""
|
|
40
|
+
if node -e "process.exit(require('./package.json').scripts?.['test:all'] ? 0 : 1)" 2>/dev/null; then
|
|
41
|
+
gate="test:all"
|
|
42
|
+
elif node -e "process.exit(require('./package.json').scripts?.test ? 0 : 1)" 2>/dev/null; then
|
|
43
|
+
gate="test"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
if [ -z "$gate" ]; then
|
|
47
|
+
# Nothing to run. A hook that blocks every commit because the project has
|
|
48
|
+
# no test script is worse than no hook.
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
log="${TMPDIR:-/tmp}/space-harness-hook.log"
|
|
53
|
+
echo "pre-commit: npm run $gate"
|
|
54
|
+
if ! npm run "$gate" >"$log" 2>&1; then
|
|
23
55
|
echo "pre-commit: FAILED. Last lines:"
|
|
24
|
-
tail -30
|
|
56
|
+
tail -30 "$log"
|
|
25
57
|
echo ""
|
|
26
58
|
echo "Fix it, or commit with --no-verify if you are certain it is not yours."
|
|
27
59
|
exit 1
|
|
28
60
|
fi
|
|
29
61
|
|
|
30
|
-
exit 0
|
|
62
|
+
exit 0
|