@tachikomagundam/abathur 0.2.2 → 0.2.4
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.md +36 -18
- package/config/genomes/historian.example.jsonc +9 -4
- package/dist/bench/adapter.js +22 -4
- package/dist/bench/fixture.js +8 -4
- package/dist/bench/toy.js +3 -3
- package/dist/commands/status.js +6 -1
- package/dist/core/evolve/run-bench.js +2 -1
- package/dist/test/bench-adapter.test.js +24 -0
- package/dist/test/bench-fixture.test.js +6 -2
- package/dist/test/bench-reporoot.test.js +197 -0
- package/dist/test/historian-grader-integrity.test.js +438 -0
- package/dist/test/historian-grader-io.test.js +277 -1
- package/dist/test/historian-run-scenario.test.js +205 -0
- package/dist/test/opencode.test.js +21 -0
- package/dist/test/status-repo.test.js +72 -0
- package/graders/historian/grader-core.d.mts +43 -0
- package/graders/historian/grader-core.mjs +215 -5
- package/graders/historian/grader-support.d.mts +11 -0
- package/graders/historian/grader-support.mjs +28 -0
- package/graders/historian/grader.mjs +62 -5
- package/graders/historian/mutate.sh +6 -3
- package/graders/historian/run-scenario.sh +39 -3
- package/graders/historian/seed-wrapped.sh +1 -1
- package/package.json +1 -1
- package/plugin/abathur.ts +47 -7
package/plugin/abathur.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// abathur-opencode-plugin v0.2.
|
|
1
|
+
// abathur-opencode-plugin v0.2.4
|
|
2
2
|
// Official opencode plugin adapter for the abathur evolution harness.
|
|
3
3
|
// Registers ONE agent tool, `abathur`, that shells out to the abathur CLI —
|
|
4
4
|
// argv-only (node:child_process execFile, never a shell), top-level commands
|
|
@@ -9,17 +9,19 @@
|
|
|
9
9
|
// server(input, options) resolves to Hooks; Hooks.tool is a
|
|
10
10
|
// { [name]: ToolDefinition } record (see @opencode-ai/plugin).
|
|
11
11
|
// This file is shipped as-is (package.json "files") and reaches a session by
|
|
12
|
-
// two routes, neither compiling it through abathur's tsc
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// opencode
|
|
12
|
+
// two routes, neither compiling it through abathur's tsc. Both deliver the
|
|
13
|
+
// tool AND the /abathur slash command:
|
|
14
|
+
// (A) copied into ~/.config/opencode/plugins/ by `abathur opencode install`,
|
|
15
|
+
// which also drops commands/abathur.md; "@opencode-ai/plugin" then
|
|
16
|
+
// resolves in opencode's config-directory node_modules.
|
|
16
17
|
// (B) served as the package's "./server" export when the npm package name is
|
|
17
18
|
// listed in opencode.jsonc "plugin" — opencode's arborist install places
|
|
18
19
|
// @opencode-ai/plugin (runtime dependency) next to the package in its
|
|
19
|
-
// cache, so the same import resolves there too.
|
|
20
|
+
// cache, so the same import resolves there too; with no commands/abathur.md
|
|
21
|
+
// on disk, the config hook below self-registers the command instead.
|
|
20
22
|
|
|
21
23
|
import { execFile } from "node:child_process";
|
|
22
|
-
import { tool } from "@opencode-ai/plugin";
|
|
24
|
+
import { tool, type Config } from "@opencode-ai/plugin";
|
|
23
25
|
|
|
24
26
|
/** Spawn cap: a CLI call that outlives this is killed and reported, never awaited forever. */
|
|
25
27
|
const TIMEOUT_MS = 120_000;
|
|
@@ -114,9 +116,47 @@ function runCli(bin: string, argv: readonly string[]): Promise<CliResult> {
|
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* /abathur slash-command template, injected into cfg.command.abathur by the
|
|
122
|
+
* config hook for installs without a commands/abathur.md on disk (Route B).
|
|
123
|
+
* Byte-mirror of plugin/abathur-command.md minus its first-line marker —
|
|
124
|
+
* src/test/opencode.test.ts pins the equality.
|
|
125
|
+
*/
|
|
126
|
+
const COMMAND_TEMPLATE = `Drive the abathur evolution harness through the \`abathur\` tool on this machine.
|
|
127
|
+
|
|
128
|
+
User request: $ARGUMENTS
|
|
129
|
+
|
|
130
|
+
Interpret the request as one \`abathur\` CLI invocation: the first word is the
|
|
131
|
+
top-level command (\`genome\`, \`run\`, \`status\`, \`bundle\`, \`graft\`, \`self-eval\`,
|
|
132
|
+
\`kernel\`, or \`--help\`) and the rest are argv tokens. Call the \`abathur\` tool
|
|
133
|
+
with \`command\` set to the first word and \`extra\` set to the remaining tokens,
|
|
134
|
+
then report the CLI exit code (0 ok / 1 blocked decision / 2 cannot-answer)
|
|
135
|
+
and the relevant lines of its output. If no request was given, call the tool
|
|
136
|
+
with \`command: "--help"\` and summarize the command list. \`promote\` and
|
|
137
|
+
\`tombstone\` cannot be called through the tool at all — the tool refuses them.
|
|
138
|
+
They are human gates that belong to a terminal: if the user asks for one,
|
|
139
|
+
tell them to run \`abathur promote …\` / \`abathur tombstone …\` there.
|
|
140
|
+
`;
|
|
141
|
+
|
|
117
142
|
export default {
|
|
118
143
|
id: "abathur",
|
|
119
144
|
server: async () => ({
|
|
145
|
+
// Self-registering /abathur: opencode calls hook.config(cfg) once per
|
|
146
|
+
// instance after ALL config sources are merged — file-based commands are
|
|
147
|
+
// already in cfg.command by then (config.ts merges {command,commands}/**/*.md;
|
|
148
|
+
// the hook fires from plugin/index.ts after config.get()). `??=` keeps a
|
|
149
|
+
// Route-A commands/abathur.md authoritative (identical behaviour to 0.2.2)
|
|
150
|
+
// and only fills the gap for Route B; the command map is keyed by name, so
|
|
151
|
+
// a same-name file + injection never duplicates the entry. Proven upstream
|
|
152
|
+
// mechanism: opencode-acp registers its /acp command exactly this way.
|
|
153
|
+
config: async (cfg: Config) => {
|
|
154
|
+
cfg.command ??= {};
|
|
155
|
+
cfg.command.abathur ??= {
|
|
156
|
+
description: "Drive the abathur evolution harness (usage: /abathur <command> [args...])",
|
|
157
|
+
template: COMMAND_TEMPLATE,
|
|
158
|
+
};
|
|
159
|
+
},
|
|
120
160
|
tool: {
|
|
121
161
|
abathur: tool({
|
|
122
162
|
description:
|