@aryasaatvik/scratchpad 0.3.5 → 0.4.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/CHANGELOG.md +25 -0
- package/README.md +1 -0
- package/dist/scratchpad.js +288 -39
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## @aryasaatvik/scratchpad@0.4.0
|
|
2
|
+
|
|
3
|
+
### Clearer archive and upload failures
|
|
4
|
+
|
|
5
|
+
`scratchpad archive` now explains that paths are relative to the notes root and suggests removing a leading `.scratchpad/` when a file cannot be found. Upload connection failures identify the target host and underlying network cause without exposing credentials or signed URLs.
|
|
6
|
+
|
|
7
|
+
Repository checks now skip tests inside Claude worktrees and runtime Scratchpad notes. The local worker integration check follows the current HTML review controls, and the unused worker TypeScript configuration has been removed.
|
|
8
|
+
|
|
9
|
+
### Adopt legacy feedback and review undecided reports
|
|
10
|
+
|
|
11
|
+
Use `scratchpad feedback normalize --global --dry-run --json` to preview adoption of older feedback
|
|
12
|
+
files, then omit `--dry-run` to apply. Normalization adds the current header while preserving body
|
|
13
|
+
bytes and legacy metadata. It derives dates from legacy `recorded` fields or filenames, reports
|
|
14
|
+
unknown metadata, and leaves unsafe files unchanged. Omit `--global` for project feedback.
|
|
15
|
+
|
|
16
|
+
`feedback review` now shows every occurrence with no disposition or disposition `open`, regardless
|
|
17
|
+
of classification status. Deferred and source-fixed reports stay out of that queue. `feedback list`
|
|
18
|
+
keeps its existing filters.
|
|
19
|
+
|
|
20
|
+
## @aryasaatvik/scratchpad@0.3.6
|
|
21
|
+
|
|
22
|
+
### `feedback list` hides installed fixes by default
|
|
23
|
+
|
|
24
|
+
`scratchpad feedback list` and `scratchpad feedback review` now leave out occurrences whose disposition is `installed`, as they already did for `dismissed` and `verified`. An installed fix is in place and waits only on a behavioral check, so it no longer fills the default listing. Pass `--all` to include them, or `--disposition installed` to list only them.
|
|
25
|
+
|
|
1
26
|
## @aryasaatvik/scratchpad@0.3.5
|
|
2
27
|
|
|
3
28
|
### `feedback list` shows review dispositions
|
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ scratchpad skills get <name> [--full | --ref <reference>]
|
|
|
140
140
|
scratchpad backlog new <issue|milestone> "<title>" [--milestone <slug>] [--depends-on <path>]
|
|
141
141
|
scratchpad backlog validate | graph # decode, check fields, links and cycles; show the tree
|
|
142
142
|
scratchpad feedback new "<text>" [--global] [--harness <h>] [--model <m>] [--session <id>]
|
|
143
|
+
scratchpad feedback normalize [--global] [--dry-run] [--json]
|
|
143
144
|
scratchpad feedback review [--global] [--classify] [--json]
|
|
144
145
|
scratchpad feedback list [--global] [--status <s>] [--disposition <d>]... [--all]
|
|
145
146
|
scratchpad feedback resolve <id|file|path> --disposition <d> --review <name|path> [--evidence <e>]...
|
package/dist/scratchpad.js
CHANGED
|
@@ -45471,8 +45471,31 @@ class ArtifactClient {
|
|
|
45471
45471
|
} : {}
|
|
45472
45472
|
};
|
|
45473
45473
|
}
|
|
45474
|
+
async request(url, init) {
|
|
45475
|
+
try {
|
|
45476
|
+
return await fetch(url, init);
|
|
45477
|
+
} catch (cause) {
|
|
45478
|
+
const details = [];
|
|
45479
|
+
const seen = new Set;
|
|
45480
|
+
for (let error = cause;error instanceof Error && !seen.has(error); error = error.cause) {
|
|
45481
|
+
seen.add(error);
|
|
45482
|
+
const code = "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
45483
|
+
let detail = `${error.message}${code && /^[A-Z][A-Z0-9_]+$/.test(code) ? ` (${code})` : ""}`;
|
|
45484
|
+
detail = detail.replace(/https?:\/\/\S+/giu, "[URL]");
|
|
45485
|
+
for (const secret of [this.options.access?.clientId, this.options.access?.clientSecret]) {
|
|
45486
|
+
if (secret)
|
|
45487
|
+
detail = detail.replaceAll(secret, "[REDACTED]");
|
|
45488
|
+
}
|
|
45489
|
+
details.push(detail.replace(/[\r\n\t]/g, " ").slice(0, 300));
|
|
45490
|
+
if (details.length === 4)
|
|
45491
|
+
break;
|
|
45492
|
+
}
|
|
45493
|
+
const TransportError = cause instanceof TypeError ? TypeError : Error;
|
|
45494
|
+
throw new TransportError(`Cannot reach ${new URL(url).origin}: ${details.join(": ") || "unknown transport failure"}`, { cause });
|
|
45495
|
+
}
|
|
45496
|
+
}
|
|
45474
45497
|
async rpc(method, body, signal) {
|
|
45475
|
-
const response = await
|
|
45498
|
+
const response = await this.request(`${this.options.baseUrl}/api/rpc/${method}`, {
|
|
45476
45499
|
method: "POST",
|
|
45477
45500
|
headers: this.headers(),
|
|
45478
45501
|
body: JSON.stringify(body),
|
|
@@ -45486,7 +45509,7 @@ class ArtifactClient {
|
|
|
45486
45509
|
return this.rpc("prepareUpload", input);
|
|
45487
45510
|
}
|
|
45488
45511
|
async upload(uploadUrl, content, contentHash, contentType = "text/markdown") {
|
|
45489
|
-
const response = await
|
|
45512
|
+
const response = await this.request(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
|
|
45490
45513
|
method: "PUT",
|
|
45491
45514
|
headers: {
|
|
45492
45515
|
...this.headers(false),
|
|
@@ -45517,7 +45540,7 @@ class ArtifactClient {
|
|
|
45517
45540
|
return decodeUnknownSync(UploadSession)(await this.rpc("abortUploadSession", { sessionId }, signal));
|
|
45518
45541
|
}
|
|
45519
45542
|
async uploadPart(sessionId, partNumber, content, signal) {
|
|
45520
|
-
const response = await
|
|
45543
|
+
const response = await this.request(`${this.options.baseUrl}/api/upload/sessions/${encodeURIComponent(sessionId)}/parts/${partNumber}`, {
|
|
45521
45544
|
method: "PUT",
|
|
45522
45545
|
headers: {
|
|
45523
45546
|
...this.headers(false),
|
|
@@ -45615,7 +45638,7 @@ class ArtifactClient {
|
|
|
45615
45638
|
return this.rpc("deleteUpload", { id });
|
|
45616
45639
|
}
|
|
45617
45640
|
async uploadFile(uploadUrl, content, contentHash, contentType) {
|
|
45618
|
-
const response = await
|
|
45641
|
+
const response = await this.request(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
|
|
45619
45642
|
method: "PUT",
|
|
45620
45643
|
headers: {
|
|
45621
45644
|
...this.headers(false),
|
|
@@ -45659,7 +45682,7 @@ class ArtifactClient {
|
|
|
45659
45682
|
return this.rpc("readArchiveExportPage", input);
|
|
45660
45683
|
}
|
|
45661
45684
|
async downloadArchiveBlob(snapshotId, hash) {
|
|
45662
|
-
const response = await
|
|
45685
|
+
const response = await this.request(`${this.options.baseUrl}/api/archive/export/${encodeURIComponent(snapshotId)}/sha256/${hash}`, { headers: this.headers(false) });
|
|
45663
45686
|
if (!response.ok)
|
|
45664
45687
|
throw new Error(`archive blob download failed (${response.status}): ${await response.text()}`);
|
|
45665
45688
|
return new Uint8Array(await response.arrayBuffer());
|
|
@@ -45674,7 +45697,7 @@ class ArtifactClient {
|
|
|
45674
45697
|
return this.rpc("stageArchiveImport", { importId, records });
|
|
45675
45698
|
}
|
|
45676
45699
|
async uploadArchiveBlob(importId, blob, bytes) {
|
|
45677
|
-
const response = await
|
|
45700
|
+
const response = await this.request(`${this.options.baseUrl}/api/archive/import/${encodeURIComponent(importId)}/sha256/${blob.hash}`, {
|
|
45678
45701
|
method: "PUT",
|
|
45679
45702
|
headers: {
|
|
45680
45703
|
...this.headers(false),
|
|
@@ -47280,7 +47303,7 @@ var archiveFiles = (input) => gen2(function* () {
|
|
|
47280
47303
|
if (!(yield* fs.exists(source))) {
|
|
47281
47304
|
return yield* fail6(new NotesCommandError({
|
|
47282
47305
|
reason: "not_found",
|
|
47283
|
-
message: `Archive path does not exist: ${argument}`
|
|
47306
|
+
message: `Archive path does not exist: ${argument}. Archive paths are relative to the notes root (${root}).${argument.startsWith(".scratchpad/") ? ` Use ${argument.slice(".scratchpad/".length)} instead (omit the leading .scratchpad/).` : ""}`
|
|
47284
47307
|
}));
|
|
47285
47308
|
}
|
|
47286
47309
|
const canonical = yield* fs.realPath(source);
|
|
@@ -48408,7 +48431,7 @@ var bundleHtml = async (options) => {
|
|
|
48408
48431
|
// package.json
|
|
48409
48432
|
var package_default = {
|
|
48410
48433
|
name: "@aryasaatvik/scratchpad",
|
|
48411
|
-
version: "0.
|
|
48434
|
+
version: "0.4.0",
|
|
48412
48435
|
description: "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
|
|
48413
48436
|
keywords: [
|
|
48414
48437
|
"bun",
|
|
@@ -50392,6 +50415,11 @@ var dispositions = [
|
|
|
50392
50415
|
"installed",
|
|
50393
50416
|
"verified"
|
|
50394
50417
|
];
|
|
50418
|
+
var hiddenByDefault = [
|
|
50419
|
+
"dismissed",
|
|
50420
|
+
"installed",
|
|
50421
|
+
"verified"
|
|
50422
|
+
];
|
|
50395
50423
|
var FeedbackClassification = Struct({
|
|
50396
50424
|
scope: Literals(scopes),
|
|
50397
50425
|
kind: Literals(kinds),
|
|
@@ -50526,9 +50554,33 @@ var feedbackClassification2 = (result) => {
|
|
|
50526
50554
|
model: result.model
|
|
50527
50555
|
};
|
|
50528
50556
|
};
|
|
50529
|
-
var
|
|
50557
|
+
var withFeedbackLock = (file, effect) => gen2(function* () {
|
|
50558
|
+
const fs = yield* FileSystem;
|
|
50559
|
+
const canonical = yield* fs.realPath(file);
|
|
50560
|
+
const lock = `${canonical}.lock`;
|
|
50561
|
+
return yield* acquireUseRelease2(fs.makeDirectory(lock, { mode: 448 }).pipe(mapError2((error2) => isAlreadyExists(error2) ? new NotesCommandError({
|
|
50562
|
+
reason: "conflict",
|
|
50563
|
+
message: "Feedback occurrence is locked by another writer; retry after it finishes. If it exited, inspect and remove the stale .lock directory first."
|
|
50564
|
+
}) : error2)), () => effect, () => fs.remove(lock, { recursive: true }).pipe(orDie2));
|
|
50565
|
+
});
|
|
50566
|
+
var replaceFeedbackContent = (file, original, updated) => scoped2(gen2(function* () {
|
|
50530
50567
|
const fs = yield* FileSystem;
|
|
50531
50568
|
const path = yield* Path;
|
|
50569
|
+
const directory = yield* fs.makeTempDirectoryScoped({
|
|
50570
|
+
directory: path.dirname(file),
|
|
50571
|
+
prefix: `.${path.basename(file)}.tmp-`
|
|
50572
|
+
});
|
|
50573
|
+
const temporary = path.join(directory, "occurrence");
|
|
50574
|
+
const { mode } = yield* fs.stat(file);
|
|
50575
|
+
yield* fs.writeFileString(temporary, updated, { flag: "wx", mode: 384 });
|
|
50576
|
+
yield* fs.chmod(temporary, mode & 4095);
|
|
50577
|
+
if ((yield* fs.readFileString(file)) !== original)
|
|
50578
|
+
return false;
|
|
50579
|
+
yield* fs.rename(temporary, file);
|
|
50580
|
+
return true;
|
|
50581
|
+
}));
|
|
50582
|
+
var rewriteFeedbackFrontmatter = (file, update) => withFeedbackLock(file, gen2(function* () {
|
|
50583
|
+
const fs = yield* FileSystem;
|
|
50532
50584
|
for (let attempt = 0;attempt < 5; attempt += 1) {
|
|
50533
50585
|
const content = yield* fs.readFileString(file);
|
|
50534
50586
|
const { values, rawBody } = yield* parseFeedbackContent(content);
|
|
@@ -50548,27 +50600,161 @@ var rewriteFeedbackFrontmatter = (file, update) => gen2(function* () {
|
|
|
50548
50600
|
const updatedContent = `---
|
|
50549
50601
|
${yaml}
|
|
50550
50602
|
---${rawBody}`;
|
|
50551
|
-
if ((yield*
|
|
50552
|
-
if (attempt === 4) {
|
|
50553
|
-
return yield* new NotesCommandError({
|
|
50554
|
-
reason: "conflict",
|
|
50555
|
-
message: "Feedback occurrence kept changing while it was being updated"
|
|
50556
|
-
});
|
|
50557
|
-
}
|
|
50603
|
+
if (!(yield* replaceFeedbackContent(file, content, updatedContent)))
|
|
50558
50604
|
continue;
|
|
50559
|
-
}
|
|
50560
|
-
const random = yield* next;
|
|
50561
|
-
const suffix = Math.floor(random * 4294967296).toString(16).padStart(8, "0");
|
|
50562
|
-
const temporary = path.join(path.dirname(file), `.${path.basename(file)}.${suffix}.tmp`);
|
|
50563
|
-
const { mode } = yield* fs.stat(file);
|
|
50564
|
-
yield* fs.writeFileString(temporary, updatedContent, { flag: "wx" });
|
|
50565
|
-
yield* fs.chmod(temporary, mode & 4095).pipe(andThen2(fs.rename(temporary, file)), tapError2(() => fs.remove(temporary).pipe(ignore2)));
|
|
50566
50605
|
return;
|
|
50567
50606
|
}
|
|
50568
50607
|
return yield* new NotesCommandError({
|
|
50569
50608
|
reason: "conflict",
|
|
50570
50609
|
message: "Feedback occurrence kept changing while it was being updated"
|
|
50571
50610
|
});
|
|
50611
|
+
}));
|
|
50612
|
+
var metadataKeys = ["project", "host", "harness", "model", "session"];
|
|
50613
|
+
var filenameDate = (name) => {
|
|
50614
|
+
const match = /^(\d{4})-?(\d{2})-?(\d{2})(?:T(\d{2})-?(\d{2})(?:-?(\d{2}))?Z)?(?=[-.]|$)/u.exec(name);
|
|
50615
|
+
if (match === null)
|
|
50616
|
+
return;
|
|
50617
|
+
const [, year, month, day, hour, minute, second] = match;
|
|
50618
|
+
const value = `${year}-${month}-${day}T${hour ?? "00"}:${minute ?? "00"}:${second ?? "00"}Z`;
|
|
50619
|
+
const millis = Date.parse(value);
|
|
50620
|
+
if (!Number.isFinite(millis) || new Date(millis).toISOString() !== value.replace("Z", ".000Z")) {
|
|
50621
|
+
return;
|
|
50622
|
+
}
|
|
50623
|
+
return {
|
|
50624
|
+
value,
|
|
50625
|
+
source: hour === undefined ? "filename-day-midnight-UTC" : "filename"
|
|
50626
|
+
};
|
|
50627
|
+
};
|
|
50628
|
+
var legacyHeader = (yaml) => {
|
|
50629
|
+
try {
|
|
50630
|
+
return decodeUnknownSync(FeedbackYaml)(Bun.YAML.parse(yaml));
|
|
50631
|
+
} catch {
|
|
50632
|
+
const values = {};
|
|
50633
|
+
for (const line of yaml.split(/\r?\n/u)) {
|
|
50634
|
+
if (line.trim() === "")
|
|
50635
|
+
continue;
|
|
50636
|
+
const match = /^([A-Za-z_][A-Za-z0-9_-]*):[ \t]*(.*)$/u.exec(line);
|
|
50637
|
+
if (match === null || Object.hasOwn(values, match[1]))
|
|
50638
|
+
return;
|
|
50639
|
+
const key = match[1];
|
|
50640
|
+
const raw = match[2];
|
|
50641
|
+
const plainColonStatus = key === "status" && /^[A-Za-z0-9][^\r\n]*: /u.test(raw);
|
|
50642
|
+
try {
|
|
50643
|
+
const value = Bun.YAML.parse(raw);
|
|
50644
|
+
if (!isScalar(value)) {
|
|
50645
|
+
if (!plainColonStatus)
|
|
50646
|
+
return;
|
|
50647
|
+
values[key] = raw;
|
|
50648
|
+
} else {
|
|
50649
|
+
values[key] = value;
|
|
50650
|
+
}
|
|
50651
|
+
} catch {
|
|
50652
|
+
if (!plainColonStatus)
|
|
50653
|
+
return;
|
|
50654
|
+
values[key] = raw;
|
|
50655
|
+
}
|
|
50656
|
+
}
|
|
50657
|
+
return typeof values.recorded === "string" && values.kind === undefined ? values : undefined;
|
|
50658
|
+
}
|
|
50659
|
+
};
|
|
50660
|
+
var normalizeFeedback = (input) => gen2(function* () {
|
|
50661
|
+
const fs = yield* FileSystem;
|
|
50662
|
+
const path = yield* Path;
|
|
50663
|
+
const project = input.global ? undefined : yield* Project;
|
|
50664
|
+
const root = path.join(input.global ? globalNotesRoot() : project.notesRoot, "feedback");
|
|
50665
|
+
const items = [];
|
|
50666
|
+
if (!(yield* fs.exists(root)))
|
|
50667
|
+
return { items, unchanged: 0 };
|
|
50668
|
+
let unchanged = 0;
|
|
50669
|
+
for (const name of (yield* fs.readDirectory(root)).filter((entry) => entry.endsWith(".md")).sort()) {
|
|
50670
|
+
const file = path.join(root, name);
|
|
50671
|
+
if (isSuccess2(yield* result2(fs.readLink(file))) || (yield* fs.stat(file)).type !== "File")
|
|
50672
|
+
continue;
|
|
50673
|
+
const normalizeFile = gen2(function* () {
|
|
50674
|
+
for (let attempt = 0;attempt < 5; attempt += 1) {
|
|
50675
|
+
const bytes = yield* fs.readFile(file);
|
|
50676
|
+
const decoded = yield* result2(try_3(() => new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes)));
|
|
50677
|
+
if (isFailure2(decoded)) {
|
|
50678
|
+
items.push({
|
|
50679
|
+
path: file,
|
|
50680
|
+
class: "other-undecodable",
|
|
50681
|
+
inferred: [],
|
|
50682
|
+
unknown: [],
|
|
50683
|
+
action: "refused",
|
|
50684
|
+
reason: "invalid UTF-8"
|
|
50685
|
+
});
|
|
50686
|
+
break;
|
|
50687
|
+
}
|
|
50688
|
+
const content = decoded.success;
|
|
50689
|
+
if (isSuccess2(yield* result2(parseFeedbackContent(content)))) {
|
|
50690
|
+
unchanged += 1;
|
|
50691
|
+
break;
|
|
50692
|
+
}
|
|
50693
|
+
const block = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(content);
|
|
50694
|
+
const values = block === null ? {} : legacyHeader(block[1]);
|
|
50695
|
+
const classification = block === null ? content.startsWith("---") ? "other-undecodable" : "no-front-matter" : values?.kind === undefined && typeof values?.recorded === "string" ? "legacy-recorded" : values?.kind === "instruction-feedback" && values.occurred_at === undefined ? "missing-occurred_at" : "other-undecodable";
|
|
50696
|
+
const inferred = values?.kind === "instruction-feedback" ? ["status"] : ["kind", "status"];
|
|
50697
|
+
const unknown = metadataKeys.filter((key) => typeof values?.[key] !== "string");
|
|
50698
|
+
const base = { path: file, class: classification, inferred, unknown };
|
|
50699
|
+
const recorded = values?.recorded;
|
|
50700
|
+
const date = typeof recorded === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/u.test(recorded) && Number.isFinite(Date.parse(recorded)) && new Date(Date.parse(recorded)).toISOString().slice(0, 19) === recorded.slice(0, 19) ? { value: recorded, source: "recorded" } : filenameDate(name);
|
|
50701
|
+
if (classification === "other-undecodable" || values === undefined || date === undefined) {
|
|
50702
|
+
items.push({
|
|
50703
|
+
...base,
|
|
50704
|
+
action: "refused",
|
|
50705
|
+
reason: classification === "other-undecodable" || values === undefined ? "header cannot be safely adopted" : "no derivable occurred_at"
|
|
50706
|
+
});
|
|
50707
|
+
break;
|
|
50708
|
+
}
|
|
50709
|
+
inferred.push("occurred_at");
|
|
50710
|
+
const header = {
|
|
50711
|
+
kind: "instruction-feedback",
|
|
50712
|
+
occurred_at: date.value
|
|
50713
|
+
};
|
|
50714
|
+
for (const key of metadataKeys)
|
|
50715
|
+
header[key] = typeof values[key] === "string" ? values[key] : "unknown";
|
|
50716
|
+
header.status = "new";
|
|
50717
|
+
let collision = false;
|
|
50718
|
+
for (const [key, value] of Object.entries(values)) {
|
|
50719
|
+
const preservedKey = key === "status" || Object.hasOwn(header, key) && header[key] !== value ? `legacy_${key}` : key;
|
|
50720
|
+
if (preservedKey !== key && Object.hasOwn(values, preservedKey)) {
|
|
50721
|
+
collision = true;
|
|
50722
|
+
break;
|
|
50723
|
+
}
|
|
50724
|
+
header[preservedKey] = value;
|
|
50725
|
+
}
|
|
50726
|
+
if (collision || isFailure2(yield* result2(decodeUnknownEffect2(FeedbackFrontmatter)(header)))) {
|
|
50727
|
+
items.push({
|
|
50728
|
+
...base,
|
|
50729
|
+
action: "refused",
|
|
50730
|
+
reason: "legacy fields conflict with adoption header"
|
|
50731
|
+
});
|
|
50732
|
+
break;
|
|
50733
|
+
}
|
|
50734
|
+
const item = { ...base, occurredAt: date.value, dateSource: date.source };
|
|
50735
|
+
if (input.dryRun) {
|
|
50736
|
+
items.push({ ...item, action: "would-normalize" });
|
|
50737
|
+
break;
|
|
50738
|
+
}
|
|
50739
|
+
const body = block === null ? content : content.slice(block[0].length);
|
|
50740
|
+
if (!(yield* replaceFeedbackContent(file, content, `---
|
|
50741
|
+
${emitFeedbackYaml(header)}
|
|
50742
|
+
---
|
|
50743
|
+
${body}`))) {
|
|
50744
|
+
if (attempt === 4)
|
|
50745
|
+
return yield* new NotesCommandError({
|
|
50746
|
+
reason: "conflict",
|
|
50747
|
+
message: "Feedback occurrence kept changing while it was being normalized"
|
|
50748
|
+
});
|
|
50749
|
+
continue;
|
|
50750
|
+
}
|
|
50751
|
+
items.push({ ...item, action: "normalized" });
|
|
50752
|
+
break;
|
|
50753
|
+
}
|
|
50754
|
+
});
|
|
50755
|
+
yield* input.dryRun ? normalizeFile : withFeedbackLock(file, normalizeFile);
|
|
50756
|
+
}
|
|
50757
|
+
return { items, unchanged };
|
|
50572
50758
|
});
|
|
50573
50759
|
var writeFeedbackClassification = (file, classification) => rewriteFeedbackFrontmatter(file, (values) => {
|
|
50574
50760
|
values.status = classification.confidence < REVIEW_THRESHOLD ? "review" : "classified";
|
|
@@ -50799,7 +50985,7 @@ var listFeedback = (input) => gen2(function* () {
|
|
|
50799
50985
|
continue;
|
|
50800
50986
|
if (input.dispositions !== undefined && !input.dispositions.includes(disposition))
|
|
50801
50987
|
continue;
|
|
50802
|
-
if (input.dispositions === undefined && !input.all &&
|
|
50988
|
+
if (input.dispositions === undefined && !input.all && disposition !== undefined && hiddenByDefault.includes(disposition))
|
|
50803
50989
|
continue;
|
|
50804
50990
|
entries.push({
|
|
50805
50991
|
path: file,
|
|
@@ -50813,7 +50999,10 @@ var listFeedback = (input) => gen2(function* () {
|
|
|
50813
50999
|
}
|
|
50814
51000
|
return { entries, skipped };
|
|
50815
51001
|
});
|
|
50816
|
-
var listFeedbackForReview = (global2) => listFeedback({ ...global2 === undefined ? {} : { global: global2 },
|
|
51002
|
+
var listFeedbackForReview = (global2) => listFeedback({ ...global2 === undefined ? {} : { global: global2 }, all: true }).pipe(map6((listing) => ({
|
|
51003
|
+
...listing,
|
|
51004
|
+
entries: listing.entries.filter((entry) => entry.disposition === undefined || entry.disposition === "open")
|
|
51005
|
+
})));
|
|
50817
51006
|
var printListing = (listing, json, empty) => gen2(function* () {
|
|
50818
51007
|
if (json) {
|
|
50819
51008
|
return yield* printJson({
|
|
@@ -50832,6 +51021,17 @@ var printListing = (listing, json, empty) => gen2(function* () {
|
|
|
50832
51021
|
`));
|
|
50833
51022
|
}
|
|
50834
51023
|
});
|
|
51024
|
+
var normalizeCommand = make36("normalize", {
|
|
51025
|
+
global: Boolean6("global").pipe(withDefault4(false)),
|
|
51026
|
+
dryRun: Boolean6("dry-run").pipe(withDefault4(false)),
|
|
51027
|
+
json: jsonFlag
|
|
51028
|
+
}, ({ global: global2, dryRun, json }) => gen2(function* () {
|
|
51029
|
+
const result = yield* normalizeFeedback({ global: global2, dryRun });
|
|
51030
|
+
if (json)
|
|
51031
|
+
return yield* printJson({ schemaVersion: 1, dryRun, ...result });
|
|
51032
|
+
yield* log2(result.items.length === 0 ? `No feedback to normalize (${result.unchanged} already decodable)` : result.items.map((item) => `${item.action} ${item.path} (${item.class}); occurred_at: ${item.occurredAt ?? "unavailable"}${item.dateSource === undefined ? "" : ` (${item.dateSource})`}; inferred: ${item.inferred.join(", ") || "none"}; unknown: ${item.unknown.join(", ") || "none"}${item.reason === undefined ? "" : `; ${item.reason}`}`).join(`
|
|
51033
|
+
`));
|
|
51034
|
+
}).pipe(provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Adopt legacy feedback without changing bodies; preview with feedback normalize --global --dry-run --json"));
|
|
50835
51035
|
var newCommand = make36("new", {
|
|
50836
51036
|
text: String8("text"),
|
|
50837
51037
|
global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
|
|
@@ -50865,12 +51065,12 @@ var reviewCommand = make36("review", {
|
|
|
50865
51065
|
listing = yield* listFeedbackForReview(global2);
|
|
50866
51066
|
}
|
|
50867
51067
|
yield* printListing(listing, json, "No feedback to review");
|
|
50868
|
-
}).pipe(withSelectedClassifier, provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Review
|
|
51068
|
+
}).pipe(withSelectedClassifier, provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Review feedback with no disposition or an open disposition"));
|
|
50869
51069
|
var listCommand = make36("list", {
|
|
50870
51070
|
global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
|
|
50871
51071
|
status: optional4(String9("status")).pipe(withDescription3("Only list feedback with this status (new, review, classified)")),
|
|
50872
51072
|
disposition: atLeast2(Literals4("disposition", dispositions).pipe(withDescription3("Only list occurrences with this disposition; repeatable")), 0),
|
|
50873
|
-
all: Boolean6("all").pipe(withDefault4(false), withDescription3("Include dismissed and verified occurrences")),
|
|
51073
|
+
all: Boolean6("all").pipe(withDefault4(false), withDescription3("Include dismissed, installed, and verified occurrences")),
|
|
50874
51074
|
json: jsonFlag
|
|
50875
51075
|
}, ({ global: global2, status, disposition, all, json }) => gen2(function* () {
|
|
50876
51076
|
const listing = yield* listFeedback({
|
|
@@ -50889,7 +51089,13 @@ var resolveCommand = make36("resolve", {
|
|
|
50889
51089
|
global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
|
|
50890
51090
|
json: jsonFlag
|
|
50891
51091
|
}, ({ occurrence, disposition, review, evidence, global: global2, json }) => resolveFeedback({ occurrence, disposition, review, evidence, global: global2 }).pipe(flatMap3((file) => json ? printJson({ schemaVersion: 1, file, disposition }) : log2(file)), provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Record a review disposition on a feedback occurrence"));
|
|
50892
|
-
var feedback = make36("feedback").pipe(withSubcommands([
|
|
51092
|
+
var feedback = make36("feedback").pipe(withSubcommands([
|
|
51093
|
+
newCommand,
|
|
51094
|
+
normalizeCommand,
|
|
51095
|
+
reviewCommand,
|
|
51096
|
+
listCommand,
|
|
51097
|
+
resolveCommand
|
|
51098
|
+
]), withDescription4("Record and list instruction feedback"));
|
|
50893
51099
|
|
|
50894
51100
|
// packages/cli/src/runtime/store.ts
|
|
50895
51101
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
@@ -51310,6 +51516,7 @@ var instruction_feedback_default = `# Instruction feedback
|
|
|
51310
51516
|
- Capture and routing
|
|
51311
51517
|
- Occurrence format
|
|
51312
51518
|
- Worked example
|
|
51519
|
+
- Normalize legacy occurrences
|
|
51313
51520
|
- Review records and closure
|
|
51314
51521
|
|
|
51315
51522
|
## Capture and routing
|
|
@@ -51443,20 +51650,57 @@ observation supports a possible surfacing gap; it does not prove the command was
|
|
|
51443
51650
|
deliberately ignored it. Link the occurrence to the existing investigation rather than copying its
|
|
51444
51651
|
transcript. A single session with several screenshots is one incident, not one per image.
|
|
51445
51652
|
|
|
51653
|
+
## Normalize legacy occurrences
|
|
51654
|
+
|
|
51655
|
+
Use the CLI to adopt older skipped files before recording their dispositions:
|
|
51656
|
+
|
|
51657
|
+
\`\`\`bash
|
|
51658
|
+
scratchpad feedback normalize --global --dry-run --json
|
|
51659
|
+
scratchpad feedback normalize --global --json
|
|
51660
|
+
\`\`\`
|
|
51661
|
+
|
|
51662
|
+
Omit \`--global\` for the project's feedback folder. Normalization scans only \`.md\` occurrences
|
|
51663
|
+
directly inside that folder, excluding \`reviews/\`, directories, and symlinks. Already decodable
|
|
51664
|
+
files stay untouched. Preview and apply output show file, class, action, derived \`occurred_at\`, date
|
|
51665
|
+
source, inferred fields, and unknown metadata; neither prints occurrence bodies. JSON uses
|
|
51666
|
+
\`schemaVersion: 1\`, \`dryRun\`, \`items\`, and an \`unchanged\` count. Refused files appear as
|
|
51667
|
+
\`action: refused\` with a reason; other safe files can still be adopted.
|
|
51668
|
+
|
|
51669
|
+
The recognized classes are \`no-front-matter\`, \`legacy-recorded\`, and \`missing-occurred_at\`.
|
|
51670
|
+
\`other-undecodable\` files remain unchanged. The CLI derives \`occurred_at\` from legacy UTC
|
|
51671
|
+
\`recorded\`, otherwise from a filename beginning with \`YYYYMMDDThhmmssZ\`, \`YYYY-MM-DDThh-mm-ssZ\`,
|
|
51672
|
+
\`YYYY-MM-DDThhmmssZ\`, \`YYYY-MM-DDThhmmZ\`, or \`YYYY-MM-DD\`. Date-only names use midnight UTC and
|
|
51673
|
+
report \`filename-day-midnight-UTC\`. A file without a derivable date is refused.
|
|
51674
|
+
|
|
51675
|
+
Adoption adds \`kind: instruction-feedback\` and \`status: new\`. It uses legacy \`project\`, \`host\`,
|
|
51676
|
+
\`harness\`, \`model\`, and \`session\` strings where present, otherwise \`unknown\`; it never infers
|
|
51677
|
+
metadata from prose. Legacy values are retained, with conflicting canonical fields moved to
|
|
51678
|
+
\`legacy_<key>\` (for example, \`legacy_status\`). Ambiguous headers or preservation-key collisions are
|
|
51679
|
+
refused. The known legacy unquoted-colon \`status\` is quoted safely. Bodies remain byte-identical:
|
|
51680
|
+
the whole file for headerless notes, or everything after the closing front matter line otherwise.
|
|
51681
|
+
Replacement is atomic, uses private staging with cleanup on failure, preserves permissions, and
|
|
51682
|
+
re-reads after staging for concurrent changes. Normalization and other CLI front matter updates
|
|
51683
|
+
share an occurrence lock held from the initial read through replacement. A competing writer fails
|
|
51684
|
+
with \`conflict\`; retry after the active writer finishes. After a crashed writer, inspect and remove
|
|
51685
|
+
its stale \`.md.lock\` directory before retrying; the CLI never steals locks. Dry-run creates no locks
|
|
51686
|
+
or staging files. Repeating normalization is a no-op for adopted files. Only the CLI changes
|
|
51687
|
+
occurrence front matter; bodies remain immutable.
|
|
51688
|
+
|
|
51446
51689
|
## Review records and closure
|
|
51447
51690
|
|
|
51448
51691
|
An explicitly requested \`agent-rules\` feedback review owns diagnosis and fix proposals. It uses this
|
|
51449
51692
|
storage contract. Capture itself neither schedules review nor launches a remediation task.
|
|
51450
51693
|
|
|
51451
51694
|
\`scratchpad feedback list [--global] [--status <s>] [--disposition <d>]... [--all] [--json]\` lists
|
|
51452
|
-
occurrences, hiding \`dismissed\` and \`verified\` ones unless \`--all\` or \`--disposition\`
|
|
51453
|
-
Each text line starts with the occurrence's review disposition, or its triage
|
|
51454
|
-
disposition is recorded yet (\`resolve\` leaves \`status\` unchanged; \`--json\` reports
|
|
51455
|
-
without a \`status\` read as \`new\`, and files whose front matter does not decode (older
|
|
51456
|
-
notes, or a missing \`occurred_at\`) are reported as skipped with the reason, on stderr or
|
|
51457
|
-
\`skipped\` with \`--json\`, rather than silently dropped.
|
|
51458
|
-
\`scratchpad feedback review [--global] [--classify] [--json]\` lists
|
|
51459
|
-
|
|
51695
|
+
occurrences, hiding \`dismissed\`, \`installed\`, and \`verified\` ones unless \`--all\` or \`--disposition\`
|
|
51696
|
+
asks for them. Each text line starts with the occurrence's review disposition, or its triage
|
|
51697
|
+
\`status\` when no disposition is recorded yet (\`resolve\` leaves \`status\` unchanged; \`--json\` reports
|
|
51698
|
+
both). Files without a \`status\` read as \`new\`, and files whose front matter does not decode (older
|
|
51699
|
+
free-form notes, or a missing \`occurred_at\`) are reported as skipped with the reason, on stderr or
|
|
51700
|
+
under \`skipped\` with \`--json\`, rather than silently dropped.
|
|
51701
|
+
\`scratchpad feedback review [--global] [--classify] [--json]\` lists occurrences with no disposition
|
|
51702
|
+
or disposition \`open\`, whatever their triage \`status\`. Every other disposition stays out of this
|
|
51703
|
+
queue. \`--classify\` first classifies queued entries that have no classification yet.
|
|
51460
51704
|
|
|
51461
51705
|
Use \`feedback/reviews/<UTC-timestamp>-<unique-id>.md\` for each review. One reviewer owns that file.
|
|
51462
51706
|
Record inspected roots, date window, occurrence IDs, grouped issue, evidence, disposition, owner,
|
|
@@ -51490,9 +51734,12 @@ and leaves the body and every other key unchanged; resolving again replaces them
|
|
|
51490
51734
|
\`disposition_review\` is relative to the occurrence's feedback folder when the record sits under it
|
|
51491
51735
|
(\`reviews/<name>.md\`), otherwise \`~/\`-relative when it is under the home directory, else absolute.
|
|
51492
51736
|
The review record stays the authority for the reasoning; the front matter only keeps settled items
|
|
51493
|
-
out of the queue. \`feedback list\`
|
|
51494
|
-
|
|
51495
|
-
|
|
51737
|
+
out of the queue. \`feedback list\` hides \`dismissed\`, \`installed\`, and \`verified\` occurrences unless
|
|
51738
|
+
\`--all\` or a matching \`--disposition\` is passed; list installed fixes awaiting a behavioral check
|
|
51739
|
+
with \`feedback list --disposition installed\`. \`feedback review\` includes only occurrences with no
|
|
51740
|
+
disposition or \`open\`. Occurrences whose front matter does not decode cannot be resolved (the error
|
|
51741
|
+
names why); adopt supported legacy formats with \`feedback normalize\` first. For refused files, keep
|
|
51742
|
+
the disposition in the review record.
|
|
51496
51743
|
|
|
51497
51744
|
Report recurrence by distinct incident/session, affected instruction, host, harness, and known
|
|
51498
51745
|
model. Count unknown metadata separately. Multiple worker reports of the same incident count once.
|
|
@@ -51759,6 +52006,8 @@ git status --short -- .scratchpad
|
|
|
51759
52006
|
|
|
51760
52007
|
## Where notes live
|
|
51761
52008
|
|
|
52009
|
+
Archive paths are relative to the notes root; omit the leading \`.scratchpad/\`.
|
|
52010
|
+
|
|
51762
52011
|
\`scratchpad path\` prints the notes root: the checkout's \`.scratchpad\`, else the primary checkout's,
|
|
51763
52012
|
else \`$XDG_DATA_HOME/scratchpad/projects/<project-id>\`. \`scratchpad path --global\` prints the
|
|
51764
52013
|
host-wide \`~/.scratchpad\`. \`scratchpad doctor\` adds the project id, whether the root came from the
|
package/package.json
CHANGED