opencode-self-improvement 0.22.1 → 0.23.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/README.md +3 -18
- package/command/repo-init.md +4 -5
- package/package.json +1 -4
- package/src/capture/candidates.ts +14 -0
- package/src/capture/checked.ts +128 -0
- package/src/capture/policy.ts +52 -0
- package/src/capture/prompt.ts +39 -0
- package/src/capture/runtime.ts +120 -1
- package/src/capture/triggers.ts +14 -0
- package/src/core/config/paths.ts +0 -25
- package/src/core/tags.ts +7 -0
- package/src/gate/gate.ts +49 -0
- package/src/gate/resolver.ts +1 -2
- package/src/gate/value-conflict.ts +300 -0
- package/src/init/detect.ts +8 -77
- package/src/init/format.ts +2 -9
- package/src/init/run.ts +8 -48
- package/src/inject/format.ts +9 -1
- package/src/store/model/provenance.ts +79 -0
- package/src/tools/init.ts +1 -2
- package/src/tools/schema.ts +0 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Provenance: how a row was obtained (#393).
|
|
2
|
+
//
|
|
3
|
+
// R4 (`benchmark-tests/ocsi/results-poison-x5/`, n=5) is why this exists. With an
|
|
4
|
+
// empty store the agent produced no artifact in 3 of 5 runs and never invented a
|
|
5
|
+
// rate — the honest failure. With ONE plausible wrong row it shipped a WRONG
|
|
6
|
+
// artifact in 4 of 5 (2475, 2100, 3100, 1750) and flagged no uncertainty in any
|
|
7
|
+
// run. A false row is not neutral: it converts "I cannot proceed" into "I shipped
|
|
8
|
+
// something wrong". The rows used were real capture output with the values and
|
|
9
|
+
// targets swapped, so this is the same shape, same confidence, same specificity —
|
|
10
|
+
// not a strawman.
|
|
11
|
+
//
|
|
12
|
+
// The fix cannot be "check it against the tree", and the measurement says so:
|
|
13
|
+
// `findConstant(base4, "fallbackVatBps")` returns null — the fixture leaves the
|
|
14
|
+
// value UNSET, which is precisely why the poison had somewhere to go. A check that
|
|
15
|
+
// refuses a claim when the tree contradicts it refuses nothing here, and a check
|
|
16
|
+
// that refuses when the tree is silent also refuses the transport fact (empty
|
|
17
|
+
// store 0/5, seeded 5/5), which is the one measured benefit memory has.
|
|
18
|
+
//
|
|
19
|
+
// So provenance is a LABEL the reader discounts by, not a filter that decides.
|
|
20
|
+
// It is derived, and the derivation is total. A rule of the form "a row with no
|
|
21
|
+
// provenance is not injected" is only safe if nothing falls through it, and the
|
|
22
|
+
// real store says why: of 1014 rows, 109 carry `auto-capture`, 18 carry
|
|
23
|
+
// `user-guided`, none carry `import`, and **905 carry none of those** — they came
|
|
24
|
+
// through the tool path, which is a provenance and not an absence of one.
|
|
25
|
+
// Excluding untagged rows would have dropped 89% of the store from injection,
|
|
26
|
+
// which is a recall loss wearing a safety badge.
|
|
27
|
+
|
|
28
|
+
export type Provenance =
|
|
29
|
+
/** The user said it; the row may carry the verbatim quote. */
|
|
30
|
+
| "user-stated"
|
|
31
|
+
/** Mined from a transcript by auto-capture. Untrusted until checked. */
|
|
32
|
+
| "capture-inferred"
|
|
33
|
+
/** Arrived through `memory_import` from a file another machine produced. */
|
|
34
|
+
| "imported"
|
|
35
|
+
/** Written by the agent or the user through a tool, in this repo. */
|
|
36
|
+
| "elicited";
|
|
37
|
+
|
|
38
|
+
export interface ProvenanceInfo {
|
|
39
|
+
kind: Provenance;
|
|
40
|
+
/**
|
|
41
|
+
* True when the row has been checked against something outside the text that
|
|
42
|
+
* produced it — today, a numeric claim that agreed with the working tree.
|
|
43
|
+
* This is the bit the injected line turns into `[code-checked]` versus
|
|
44
|
+
* `[unverified]`.
|
|
45
|
+
*/
|
|
46
|
+
checked: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Total by construction: every row gets a class, so injection never loses a row
|
|
51
|
+
* to a missing label. Order matters — a guided row that capture also mined is
|
|
52
|
+
* USER-stated, because the user's authority is the stronger claim of the two.
|
|
53
|
+
*/
|
|
54
|
+
export function provenanceOf(
|
|
55
|
+
tags: readonly string[] | undefined,
|
|
56
|
+
): ProvenanceInfo {
|
|
57
|
+
const t = tags ?? [];
|
|
58
|
+
if (t.includes("user-guided")) return { kind: "user-stated", checked: false };
|
|
59
|
+
if (t.includes("import")) return { kind: "imported", checked: false };
|
|
60
|
+
if (t.includes("auto-capture"))
|
|
61
|
+
return { kind: "capture-inferred", checked: t.includes("code-checked") };
|
|
62
|
+
return { kind: "elicited", checked: false };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The marker that rides the injected line. Kept SHORT and kept SEPARATE from the
|
|
67
|
+
* existing `[via …]` marker, whose exact text several tests pin: those tests are
|
|
68
|
+
* the reason this is an appended token and not a rewrite.
|
|
69
|
+
*
|
|
70
|
+
* `elicited` and `user-stated` render nothing. Both are the user's own authority
|
|
71
|
+
* in this repository, and decorating 905 of 1014 rows with a warning would teach
|
|
72
|
+
* the model to ignore the warning.
|
|
73
|
+
*/
|
|
74
|
+
export function provenanceMarker(info: ProvenanceInfo): string {
|
|
75
|
+
if (info.checked) return " [code-checked]";
|
|
76
|
+
if (info.kind === "capture-inferred") return " [unverified]";
|
|
77
|
+
if (info.kind === "imported") return "";
|
|
78
|
+
return "";
|
|
79
|
+
}
|
package/src/tools/init.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
19
19
|
validated(InitArgs, {
|
|
20
20
|
name: "memory_init",
|
|
21
21
|
description:
|
|
22
|
-
"Initialize repository memory: re-derives build/lint/test/typecheck command memories through the write gate and stores an init stamp keyed on git HEAD. Idempotent: a no-op when the stamp matches HEAD, unless force=true (refresh after a refactor).
|
|
22
|
+
"Initialize repository memory: re-derives build/lint/test/typecheck command memories through the write gate and stores an init stamp keyed on git HEAD. Idempotent: a no-op when the stamp matches HEAD, unless force=true (refresh after a refactor).",
|
|
23
23
|
options: direct,
|
|
24
24
|
async execute(args, context): Promise<{ content: string }> {
|
|
25
25
|
const { sid } = toolIds(context);
|
|
@@ -29,7 +29,6 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
29
29
|
const summary = await runInit({
|
|
30
30
|
liveRoot: gateContext(sid).liveRoot,
|
|
31
31
|
force: args.force,
|
|
32
|
-
mode: args.mode,
|
|
33
32
|
sessionID: sid,
|
|
34
33
|
});
|
|
35
34
|
return { content: formatInit(summary) };
|
package/src/tools/schema.ts
CHANGED
|
@@ -74,10 +74,6 @@ export const InitArgs = z.object({
|
|
|
74
74
|
.boolean()
|
|
75
75
|
.describe("Re-run even if initialized (refresh after drift)")
|
|
76
76
|
.optional(),
|
|
77
|
-
mode: z
|
|
78
|
-
.enum(["fast", "moderate", "full"])
|
|
79
|
-
.describe("codebase-memory index mode (default moderate)")
|
|
80
|
-
.optional(),
|
|
81
77
|
});
|
|
82
78
|
|
|
83
79
|
export const RecallArgs = z.object({
|