opencode-self-improvement 0.22.0 → 0.22.1
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 +1 -1
- package/package.json +1 -1
- package/src/consolidate/render.ts +8 -2
- package/src/gate/gate.ts +2 -1
- package/src/init/detect.ts +10 -0
- package/src/init/run.ts +21 -2
- package/src/portable/export.ts +8 -3
package/README.md
CHANGED
|
@@ -250,7 +250,7 @@ Limits worth knowing:
|
|
|
250
250
|
- It can miss hex-only secrets, low-diversity passwords, and credentials written in prose without an assignment.
|
|
251
251
|
- Credential-shaped `scope`, `tags` or `issue` metadata is rejected rather than silently rewritten.
|
|
252
252
|
- `memory_remember` still replies `Remembered` when content was redacted, so the stored text can differ from what was sent.
|
|
253
|
-
- Redaction is forward-only: existing stores are not scrubbed
|
|
253
|
+
- Redaction is forward-only: existing stores are not scrubbed. `memory_export` scrubs credentials out of `content`, `issue`, `scope`, `tags` and `kw` as it serialises, so the file that leaves the machine carries `[redacted]` where a stored row still holds a token; the store itself is untouched, and origin stamps (`repo`, `repoPath`) are written as stored. The scrubber is a best-effort sweep over known token families and high-entropy credential-shaped values — an exotic credential can survive it, so an export is still a file you hand out deliberately.
|
|
254
254
|
|
|
255
255
|
## Export and move between machines
|
|
256
256
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-self-improvement",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// render — split from src/consolidate.ts (#168 domain restructure). Declaration bodies are unchanged.
|
|
2
2
|
|
|
3
3
|
import { type ProposalReport } from "./propose.ts";
|
|
4
|
+
import { flattenMemoryText } from "../store/sanitize.ts";
|
|
4
5
|
|
|
5
6
|
/** Human-readable proposal list. Ends with the exact command to resolve one. */
|
|
6
7
|
export function renderProposals(report: ProposalReport): string {
|
|
@@ -13,8 +14,13 @@ export function renderProposals(report: ProposalReport): string {
|
|
|
13
14
|
out.push(
|
|
14
15
|
`${p.id} ${p.type}/${p.scope} ${p.losers.length + 1} rows → 1`,
|
|
15
16
|
` keep ${p.survivor.ts}`,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
// Row prose is multiline in the store and flattened only here (#299):
|
|
18
|
+
// one row is one output line, the same rule memory_recall follows.
|
|
19
|
+
` ${flattenMemoryText(p.survivor.content.slice(0, 160))}`,
|
|
20
|
+
...p.losers.map(
|
|
21
|
+
(l) =>
|
|
22
|
+
` absorb ${l.ts} ${flattenMemoryText(l.content.slice(0, 120))}`,
|
|
23
|
+
),
|
|
18
24
|
` reads ${p.reads.length} logged · best member alone ${p.bestMemberBefore} · merged ${p.readsAfter}`,
|
|
19
25
|
` budget ${p.bytesBefore}c → ${p.bytesAfter}c for this cluster`,
|
|
20
26
|
` resolve: memory_merge_review(loser="${p.losers[0]!.ts}", survivor="${p.survivor.ts}", reason="consolidate ${p.id}")`,
|
package/src/gate/gate.ts
CHANGED
|
@@ -824,7 +824,8 @@ export async function runWriteGate(
|
|
|
824
824
|
// on the read path (it covers every consumer, the viewer included), and this
|
|
825
825
|
// is the seam where the value becomes a model-facing sentence.
|
|
826
826
|
const why =
|
|
827
|
-
redactSecrets(rejection.tombstone.reason) ||
|
|
827
|
+
flattenMemoryText(redactSecrets(rejection.tombstone.reason)) ||
|
|
828
|
+
"no reason recorded";
|
|
828
829
|
const tch = rejection.tombstone.ch;
|
|
829
830
|
// The escape-hatch tail is shared by BOTH kinds. An earlier draft put it
|
|
830
831
|
// only on the near-match branch, which left the COMMON case — a byte-exact
|
package/src/init/detect.ts
CHANGED
|
@@ -73,6 +73,15 @@ async function readText(root: string, file: string): Promise<string | null> {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// A script key becomes the command a later session is told to run, so it may
|
|
77
|
+
// only be an identifier: no whitespace and no shell metacharacter can survive
|
|
78
|
+
// into `npm run <key>`. `:` and `.` are allowed because `test:ci` and
|
|
79
|
+
// `lint.fix` are ordinary npm keys (this is wider than #301's literal
|
|
80
|
+
// `[A-Za-z0-9_-]+`, which would drop them; the rejection this ticket is about —
|
|
81
|
+
// `test && echo SYNTHETIC` — is rejected either way). Make/Just targets use the
|
|
82
|
+
// narrower class already, and a Make target cannot contain `:` in any case.
|
|
83
|
+
const SCRIPT_KEY = /^[A-Za-z0-9_.:-]+$/;
|
|
84
|
+
|
|
76
85
|
async function detectPackageScripts(
|
|
77
86
|
root: string,
|
|
78
87
|
records: ScriptRecord[],
|
|
@@ -89,6 +98,7 @@ async function detectPackageScripts(
|
|
|
89
98
|
const seen = new Set<string>();
|
|
90
99
|
for (const name of Object.keys(pkg.scripts as Record<string, unknown>)) {
|
|
91
100
|
if (seen.has(name) || !isNotable(name.toLowerCase())) continue;
|
|
101
|
+
if (!SCRIPT_KEY.test(name)) continue; // crafted key: skip the record
|
|
92
102
|
seen.add(name);
|
|
93
103
|
records.push({ key: name, cmd: `npm run ${name}`, source: "package.json" });
|
|
94
104
|
}
|
package/src/init/run.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { runWriteGate, type GateContext } from "../gate/gate.ts";
|
|
|
19
19
|
import { captureEvidenceContext, record } from "../evidence/record.ts";
|
|
20
20
|
import { writeEvidence, hasGateCheck } from "../capture/triggers.ts";
|
|
21
21
|
import { writeTarget } from "../identity/repokey.ts";
|
|
22
|
+
import { quarantineCandidate } from "../store/quarantine/quarantine.ts";
|
|
22
23
|
import { graphEnabled } from "../core/config/paths.ts";
|
|
23
24
|
import { getCurrent } from "../core/state.ts";
|
|
24
25
|
import {
|
|
@@ -174,8 +175,18 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
|
|
|
174
175
|
let unaudited = 0;
|
|
175
176
|
for (const s of scripts) {
|
|
176
177
|
const content = `${scope} ${s.key} command: run "${s.cmd}" from the repo root (${s.source}).`;
|
|
178
|
+
// Auto-capture and import both screen their candidate for injection-shaped
|
|
179
|
+
// text; init's rows are external text too — the scope is the checkout
|
|
180
|
+
// directory basename and the command comes from the manifest — so they get
|
|
181
|
+
// the same scan (#302). A match is still stored, tagged `quarantine`, and
|
|
182
|
+
// withheld from recall and injection.
|
|
177
183
|
const outcome = await runWriteGate(
|
|
178
|
-
{
|
|
184
|
+
quarantineCandidate({
|
|
185
|
+
type: "pattern",
|
|
186
|
+
scope,
|
|
187
|
+
content,
|
|
188
|
+
tags: ["init", s.source],
|
|
189
|
+
}),
|
|
179
190
|
gateCtx,
|
|
180
191
|
);
|
|
181
192
|
if (outcome.action === "promoted") {
|
|
@@ -187,7 +198,15 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
|
|
|
187
198
|
|
|
188
199
|
const stampContent = `Init stamp: repo=${scope}, head=${head}, graph=${graph.action}, mode=${graph.mode}, scripts=${scripts.length}`;
|
|
189
200
|
const stampOutcome = await runWriteGate(
|
|
190
|
-
|
|
201
|
+
// Same screen as the script rows: the stamp interpolates the directory
|
|
202
|
+
// basename, so an injection-shaped checkout name matches here too. Withheld
|
|
203
|
+
// from recall, still readable by initStamp(), so idempotency is unaffected.
|
|
204
|
+
quarantineCandidate({
|
|
205
|
+
type: "context",
|
|
206
|
+
scope,
|
|
207
|
+
content: stampContent,
|
|
208
|
+
tags: ["init-stamp"],
|
|
209
|
+
}),
|
|
191
210
|
gateCtx,
|
|
192
211
|
);
|
|
193
212
|
const stampTs = stampOutcome.ts ?? prior?.ts;
|
package/src/portable/export.ts
CHANGED
|
@@ -166,15 +166,20 @@ export async function exportMemories(
|
|
|
166
166
|
// stored before the write-side redaction existed (#74 slice 1). Redaction is
|
|
167
167
|
// applied to the value being serialised, never to the row: export stays a
|
|
168
168
|
// read path, and the store remains the byte-of-record for memory_undo.
|
|
169
|
+
// #300 extends the same rule to the metadata fields: `scope`, `tags` and `kw`
|
|
170
|
+
// are free prose a row can carry, and a legacy or hand-edited row can hold a
|
|
171
|
+
// credential in them even though new writes refuse it. `repo`/`repoPath` stay
|
|
172
|
+
// as stored — they are derived stamps, not prose, and rewriting them would
|
|
173
|
+
// break the import-side validation that keeps a portable file honest.
|
|
169
174
|
const lines = mems.map((m) =>
|
|
170
175
|
JSON.stringify({
|
|
171
176
|
ts: m.ts,
|
|
172
177
|
type: m.type,
|
|
173
|
-
scope: m.scope,
|
|
178
|
+
scope: redactSecrets(m.scope),
|
|
174
179
|
content: redactSecrets(m.content),
|
|
175
180
|
status: m.status,
|
|
176
|
-
tags: m.tags,
|
|
177
|
-
kw: m.kw,
|
|
181
|
+
tags: m.tags?.map(redactSecrets),
|
|
182
|
+
kw: m.kw?.map(redactSecrets),
|
|
178
183
|
issue: m.issue === undefined ? m.issue : redactSecrets(m.issue),
|
|
179
184
|
// Origin stamps ride along so a same-repo machine hop can retain them.
|
|
180
185
|
// Import validates them against its current repo before promotion.
|