@aryasaatvik/scratchpad 0.3.6 → 0.5.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 CHANGED
@@ -1,3 +1,35 @@
1
+ ## @aryasaatvik/scratchpad@0.5.0
2
+
3
+ ### Understand sync previews and mount failures
4
+
5
+ Dry-run actions now explain why they are planned, including new mappings, changed hashes, queued
6
+ work, missing files, remote changes, and remote closures. Changed hashes show an eight-character stored/current
7
+ comparison, also available in JSON output.
8
+
9
+ Sync commands now print an actionable error when a stored mount cannot be matched to your
10
+ configuration, with a `mount_error` JSON envelope under `--json`. A missing mount directory with
11
+ stored mappings stops sync before it can mistake directory loss for requests to close issues or
12
+ archive milestones. Restore the directory or use `scratchpad repair` to inspect the state.
13
+
14
+ ## @aryasaatvik/scratchpad@0.4.0
15
+
16
+ ### Clearer archive and upload failures
17
+
18
+ `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.
19
+
20
+ 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.
21
+
22
+ ### Adopt legacy feedback and review undecided reports
23
+
24
+ Use `scratchpad feedback normalize --global --dry-run --json` to preview adoption of older feedback
25
+ files, then omit `--dry-run` to apply. Normalization adds the current header while preserving body
26
+ bytes and legacy metadata. It derives dates from legacy `recorded` fields or filenames, reports
27
+ unknown metadata, and leaves unsafe files unchanged. Omit `--global` for project feedback.
28
+
29
+ `feedback review` now shows every occurrence with no disposition or disposition `open`, regardless
30
+ of classification status. Deferred and source-fixed reports stay out of that queue. `feedback list`
31
+ keeps its existing filters.
32
+
1
33
  ## @aryasaatvik/scratchpad@0.3.6
2
34
 
3
35
  ### `feedback list` hides installed fixes by default
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>]...
@@ -43581,6 +43581,7 @@ var conflicts = sqliteTable("conflicts", {
43581
43581
  // packages/core/src/store/projection-store.ts
43582
43582
  class ProjectionStoreError extends TaggedError3()("ProjectionStoreError", {
43583
43583
  message: String4,
43584
+ reason: optional2(Literal2("mount_alias")),
43584
43585
  cause: optional2(Defect())
43585
43586
  }) {
43586
43587
  }
@@ -43606,6 +43607,7 @@ class ProjectionStore extends Service()("@scratchpad/ProjectionStore") {
43606
43607
  for (const { from, to } of aliases) {
43607
43608
  if (from.length === 0 || to.length === 0 || from === to || targets.has(from)) {
43608
43609
  return yield* new ProjectionStoreError({
43610
+ reason: "mount_alias",
43609
43611
  message: `Invalid mount alias ${from} -> ${to}`
43610
43612
  });
43611
43613
  }
@@ -43614,6 +43616,7 @@ class ProjectionStore extends Service()("@scratchpad/ProjectionStore") {
43614
43616
  for (const [from, to] of targets) {
43615
43617
  if (targets.has(to)) {
43616
43618
  return yield* new ProjectionStoreError({
43619
+ reason: "mount_alias",
43617
43620
  message: `Chained mount alias ${from} -> ${to}`
43618
43621
  });
43619
43622
  }
@@ -43632,6 +43635,7 @@ class ProjectionStore extends Service()("@scratchpad/ProjectionStore") {
43632
43635
  return JSON.stringify(leftFields) === JSON.stringify(rightFields);
43633
43636
  };
43634
43637
  const collision = (table, objectKey) => new ProjectionStoreError({
43638
+ reason: "mount_alias",
43635
43639
  message: `Cannot adopt mount aliases: conflicting ${table} rows for ${objectKey}`
43636
43640
  });
43637
43641
  const mappingGroups = Map.groupBy(mappings, key);
@@ -43822,6 +43826,11 @@ var localizeDependencies = (body, slugForExternalId, fromSlug = "") => rewriteSe
43822
43826
  // packages/core/src/sync/mounts.ts
43823
43827
  import { realpathSync } from "fs";
43824
43828
  import { basename as basename2, dirname as dirname2, join as join6, resolve as resolve5 } from "path";
43829
+ class MountError extends TaggedError3()("MountError", {
43830
+ message: String4,
43831
+ cause: optional2(Defect())
43832
+ }) {
43833
+ }
43825
43834
  function physicalMountPath(directory) {
43826
43835
  let ancestor = resolve5(directory);
43827
43836
  const remaining = [];
@@ -43858,7 +43867,7 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43858
43867
  const fs = yield* FileSystem;
43859
43868
  const config = yield* try_3({
43860
43869
  try: () => physicalMountConfig(input),
43861
- catch: (cause) => new ProjectionStoreError({ message: "Could not resolve physical mounts", cause })
43870
+ catch: (cause) => new MountError({ message: "Could not resolve physical mounts", cause })
43862
43871
  });
43863
43872
  const targets = config.mounts.flatMap((mount) => [
43864
43873
  { kind: "issue", mount: mount.issues, archive: false },
@@ -43875,7 +43884,7 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43875
43884
  continue;
43876
43885
  const physical = yield* try_3({
43877
43886
  try: () => physicalMountPath(from),
43878
- catch: (cause) => new ProjectionStoreError({ message: `Could not resolve mount alias: ${from}`, cause })
43887
+ catch: (cause) => new MountError({ message: `Could not resolve mount alias: ${from}`, cause })
43879
43888
  });
43880
43889
  if (configured.has(physical)) {
43881
43890
  aliases.push({ from, to: physical });
@@ -43889,8 +43898,8 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43889
43898
  if (yield* fs.exists(from)) {
43890
43899
  if (archived)
43891
43900
  continue;
43892
- return yield* new ProjectionStoreError({
43893
- message: `Stored mount ${from} resolves outside configured physical mounts; retained sync state unchanged.`
43901
+ return yield* new MountError({
43902
+ message: `Stored mount ${from} resolves outside configured physical mounts; retained sync state unchanged. Restore the stored mount in scratchpad.config.ts or restore its original directory before syncing.`
43894
43903
  });
43895
43904
  }
43896
43905
  let candidates = new Set(configured);
@@ -43904,7 +43913,7 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43904
43913
  const file = join6(target.mount, `${mapping.slug}.md`);
43905
43914
  if (!(yield* fs.exists(file)))
43906
43915
  continue;
43907
- const text = yield* fs.readFileString(file).pipe(mapError2((cause) => new ProjectionStoreError({
43916
+ const text = yield* fs.readFileString(file).pipe(mapError2((cause) => new MountError({
43908
43917
  message: `Could not inspect mount identity: ${file}`,
43909
43918
  cause
43910
43919
  })));
@@ -43920,13 +43929,16 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43920
43929
  if (archived && candidates.size === 0)
43921
43930
  continue;
43922
43931
  if (candidates.size !== 1) {
43923
- return yield* new ProjectionStoreError({
43932
+ return yield* new MountError({
43924
43933
  message: `Cannot prove mount alias ${from}; retained sync state unchanged. Restore its mount or resolve the alias before syncing.`
43925
43934
  });
43926
43935
  }
43927
43936
  aliases.push({ from, to: [...candidates][0] });
43928
43937
  }
43929
- const projection = yield* store.adoptMountAliases(aliases, dryRun);
43938
+ const projection = yield* store.adoptMountAliases(aliases, dryRun).pipe(mapError2((cause) => cause.reason === "mount_alias" ? new MountError({
43939
+ message: `${cause.message}. Retained sync state unchanged. Restore the original mount configuration and reconcile the conflicting records before syncing.`,
43940
+ cause
43941
+ }) : cause));
43930
43942
  const writableMounts = targets.filter((target) => !target.archive).map((target) => target.mount);
43931
43943
  const writable = new Set(writableMounts);
43932
43944
  const activeState = (row) => writable.has(row.mount);
@@ -43956,6 +43968,31 @@ var prepareMounts = fn2("Sync.prepareMounts")(function* (input, store, dryRun) {
43956
43968
  };
43957
43969
  return { config, store: scopeWrites(view) };
43958
43970
  });
43971
+ var validateMountDirectories = fn2("Sync.validateMountDirectories")(function* (config, store) {
43972
+ const fs = yield* FileSystem;
43973
+ for (const mount of config.mounts) {
43974
+ for (const [kind, directory] of [
43975
+ ["issue", mount.issues],
43976
+ ["milestone", mount.milestones]
43977
+ ]) {
43978
+ const info = yield* fs.stat(directory).pipe(catch_2((cause) => cause.reason._tag === "NotFound" ? succeed6(undefined) : fail6(new MountError({
43979
+ message: `Cannot inspect mount directory ${directory}. Restore access before syncing.`,
43980
+ cause
43981
+ }))));
43982
+ if (info?.type === "Directory")
43983
+ continue;
43984
+ if (info !== undefined)
43985
+ return yield* new MountError({
43986
+ message: `Mount path ${directory} is not a directory. Restore the directory before syncing; refusing to plan closes or archives.`
43987
+ });
43988
+ const mappings = yield* store.listMappings(kind, directory);
43989
+ if (mappings.length > 0)
43990
+ return yield* new MountError({
43991
+ message: `Mount directory ${directory} is missing with ${mappings.length} stored mapping(s). Restore the directory or run scratchpad repair before syncing; refusing to plan closes or archives.`
43992
+ });
43993
+ }
43994
+ }
43995
+ });
43959
43996
 
43960
43997
  // packages/core/src/sync/engine.ts
43961
43998
  class RemoteDeleteError extends TaggedError3()("RemoteDeleteError", {
@@ -43980,7 +44017,21 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
43980
44017
  ...slugValue === undefined ? {} : { issueSlug: slugValue }
43981
44018
  });
43982
44019
  const renderMilestone = (doc) => renderMilestoneFile(doc, frontmatterOptions);
43983
- const listSlugs = (dir) => fs.readDirectory(dir, { recursive: true }).pipe(map6((names) => names.map((name) => name.replaceAll("\\", "/")).filter((name) => name.endsWith(".md")).map((name) => name.slice(0, -3))), orElseSucceed2(() => []));
44020
+ const listSlugs = (dir) => fs.readDirectory(dir, { recursive: true }).pipe(map6((names) => names.map((name) => name.replaceAll("\\", "/")).filter((name) => name.endsWith(".md")).map((name) => name.slice(0, -3))), catch_2((cause) => gen2(function* () {
44021
+ if (cause.reason._tag === "NotFound" && !(yield* fs.exists(dir))) {
44022
+ const mount = path.resolve(dir);
44023
+ const mappings = [
44024
+ ...yield* store.listMappings("issue", mount),
44025
+ ...yield* store.listMappings("milestone", mount)
44026
+ ];
44027
+ if (mappings.length === 0)
44028
+ return [];
44029
+ }
44030
+ return yield* new MountError({
44031
+ message: `Cannot scan mount directory ${dir}. Restore the directory and read access before syncing; refusing to plan closes or archives.`,
44032
+ cause
44033
+ });
44034
+ })));
43984
44035
  const fileStatus = (frontmatter) => {
43985
44036
  if (frontmatter.status !== undefined && classifyStatus(frontmatter.status, frontmatterOptions.closedStatuses) === frontmatter.state) {
43986
44037
  return frontmatter.status;
@@ -44213,7 +44264,13 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44213
44264
  if (!opts.dryRun)
44214
44265
  yield* store.deleteObjectMapping(opts.kind, mountKey, duplicate.slug);
44215
44266
  if (duplicate.syncStatus !== "closed") {
44216
- actions.push({ kind: opts.kind, slug: duplicate.slug, externalId, op: "retire" });
44267
+ actions.push({
44268
+ kind: opts.kind,
44269
+ slug: duplicate.slug,
44270
+ externalId,
44271
+ op: "retire",
44272
+ reason: "local-missing"
44273
+ });
44217
44274
  }
44218
44275
  });
44219
44276
  let maxUpdated = since;
@@ -44245,7 +44302,8 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44245
44302
  kind: opts.kind,
44246
44303
  slug: priorMapping.slug,
44247
44304
  externalId,
44248
- op: "retire"
44305
+ op: "retire",
44306
+ reason: "remote-closed"
44249
44307
  });
44250
44308
  }
44251
44309
  }
@@ -44274,7 +44332,13 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44274
44332
  syncStatus: "archived"
44275
44333
  });
44276
44334
  }
44277
- actions.push({ kind: opts.kind, slug: archiveSlug, externalId, op: "write" });
44335
+ actions.push({
44336
+ kind: opts.kind,
44337
+ slug: archiveSlug,
44338
+ externalId,
44339
+ op: "write",
44340
+ reason: "remote-changed"
44341
+ });
44278
44342
  }
44279
44343
  }
44280
44344
  const ru = remote.frontmatter.sync?.remoteUpdatedAt;
@@ -44320,11 +44384,23 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44320
44384
  });
44321
44385
  }
44322
44386
  conflicted = true;
44323
- actions.push({ kind: opts.kind, slug: slugValue, externalId, op: "conflict" });
44387
+ actions.push({
44388
+ kind: opts.kind,
44389
+ slug: slugValue,
44390
+ externalId,
44391
+ op: "conflict",
44392
+ reason: "conflict"
44393
+ });
44324
44394
  } else if (remoteChanged) {
44325
44395
  if (!opts.dryRun)
44326
44396
  yield* writeDoc(absPath, renderRemote(remote, current, slugValue));
44327
- actions.push({ kind: opts.kind, slug: slugValue, externalId, op: "write" });
44397
+ actions.push({
44398
+ kind: opts.kind,
44399
+ slug: slugValue,
44400
+ externalId,
44401
+ op: "write",
44402
+ reason: "remote-changed"
44403
+ });
44328
44404
  }
44329
44405
  } else {
44330
44406
  if (fileExists && opts.preserveLocal !== undefined) {
@@ -44332,7 +44408,13 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44332
44408
  }
44333
44409
  if (!opts.dryRun)
44334
44410
  yield* writeDoc(absPath, renderRemote(remote, current, slugValue));
44335
- actions.push({ kind: opts.kind, slug: slugValue, externalId, op: "write" });
44411
+ actions.push({
44412
+ kind: opts.kind,
44413
+ slug: slugValue,
44414
+ externalId,
44415
+ op: "write",
44416
+ reason: fileExists ? "remote-changed" : "new-file"
44417
+ });
44336
44418
  }
44337
44419
  if (!opts.dryRun) {
44338
44420
  yield* store.putObjectMapping({
@@ -44379,6 +44461,7 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44379
44461
  kind: opts.kind,
44380
44462
  slug: mapping.slug,
44381
44463
  op: "prune",
44464
+ reason: exists ? "archive-expired" : "local-missing",
44382
44465
  ...mapping.externalId === null ? {} : { externalId: mapping.externalId }
44383
44466
  });
44384
44467
  }
@@ -44470,6 +44553,11 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44470
44553
  kind: opts.kind,
44471
44554
  slug: slugValue,
44472
44555
  op,
44556
+ reason: mapping === undefined ? "no-mapping" : "hash-changed",
44557
+ ...opts.dryRun && mapping !== undefined ? {
44558
+ ...mapping.contentHash === null ? {} : { storedHash: mapping.contentHash.slice(0, 8) },
44559
+ currentHash: hash.slice(0, 8)
44560
+ } : {},
44473
44561
  ...externalId === undefined ? {} : { externalId }
44474
44562
  });
44475
44563
  }
@@ -44498,7 +44586,8 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44498
44586
  kind: opts.kind,
44499
44587
  slug: mapping.slug,
44500
44588
  externalId: mapping.externalId,
44501
- op
44589
+ op,
44590
+ reason: "local-missing"
44502
44591
  });
44503
44592
  }
44504
44593
  return actions;
@@ -44708,6 +44797,7 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44708
44797
  kind: row.kind === "milestone" ? "milestone" : "issue",
44709
44798
  slug: row.slug,
44710
44799
  op: row.op,
44800
+ reason: "queued",
44711
44801
  ...externalId === undefined ? {} : { externalId }
44712
44802
  };
44713
44803
  }));
@@ -44843,15 +44933,15 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44843
44933
  return SyncEngine.of({
44844
44934
  pull: (opts) => {
44845
44935
  const dryRun = opts?.dryRun ?? false;
44846
- return pull(dryRun, opts?.full ?? false).pipe(map6(report(dryRun)), orDie2);
44936
+ return pull(dryRun, opts?.full ?? false).pipe(map6(report(dryRun)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error)));
44847
44937
  },
44848
44938
  push: (opts) => {
44849
44939
  const dryRun = opts?.dryRun ?? false;
44850
- return push(dryRun).pipe(map6(reportWith(dryRun)), orDie2);
44940
+ return push(dryRun).pipe(map6(reportWith(dryRun)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error)));
44851
44941
  },
44852
44942
  sync: (opts) => {
44853
44943
  const dryRun = opts?.dryRun ?? false;
44854
- return sync(dryRun, opts?.full ?? false).pipe(map6(reportWith(dryRun)), orDie2);
44944
+ return sync(dryRun, opts?.full ?? false).pipe(map6(reportWith(dryRun)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error)));
44855
44945
  },
44856
44946
  deleteRemote: (filePath, opts) => {
44857
44947
  const dryRun = opts?.dryRun ?? false;
@@ -44867,14 +44957,14 @@ class SyncEngine extends Service()("@scratchpad/SyncEngine") {
44867
44957
  const config = yield* ProjectConfig;
44868
44958
  const fs = yield* FileSystem;
44869
44959
  const path = yield* Path;
44870
- const build = (dryRun) => prepareMounts(config, store, dryRun).pipe(provideService2(FileSystem, fs), flatMap3((prepared) => SyncEngine.make.pipe(provideService2(Provider, provider), provideService2(ProjectionStore, prepared.store), provideService2(ProjectConfig, prepared.config), provideService2(FileSystem, fs), provideService2(Path, path))));
44960
+ const build = (dryRun, validateDirectories = false) => prepareMounts(config, store, dryRun).pipe(provideService2(FileSystem, fs), flatMap3((prepared) => SyncEngine.make.pipe(tap2(() => validateDirectories ? validateMountDirectories(prepared.config, prepared.store).pipe(provideService2(FileSystem, fs)) : void_3), provideService2(Provider, provider), provideService2(ProjectionStore, prepared.store), provideService2(ProjectConfig, prepared.config), provideService2(FileSystem, fs), provideService2(Path, path))));
44871
44961
  return SyncEngine.of({
44872
- pull: (opts) => build(opts?.dryRun ?? false).pipe(flatMap3((engine) => engine.pull(opts)), orDie2),
44873
- push: (opts) => build(opts?.dryRun ?? false).pipe(flatMap3((engine) => engine.push(opts)), orDie2),
44874
- sync: (opts) => build(opts?.dryRun ?? false).pipe(flatMap3((engine) => engine.sync(opts)), orDie2),
44962
+ pull: (opts) => build(opts?.dryRun ?? false, true).pipe(flatMap3((engine) => engine.pull(opts)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error))),
44963
+ push: (opts) => build(opts?.dryRun ?? false, true).pipe(flatMap3((engine) => engine.push(opts)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error))),
44964
+ sync: (opts) => build(opts?.dryRun ?? false, true).pipe(flatMap3((engine) => engine.sync(opts)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error))),
44875
44965
  deleteRemote: (file, opts) => build(opts?.dryRun ?? false).pipe(mapError2((cause) => new RemoteDeleteError({ message: cause.message, cause })), flatMap3((engine) => engine.deleteRemote(file, opts))),
44876
- listConflicts: build(true).pipe(flatMap3((engine) => engine.listConflicts), orDie2),
44877
- resolveConflict: (id, resolution) => build(false).pipe(flatMap3((engine) => engine.resolveConflict(id, resolution)), orDie2)
44966
+ listConflicts: build(true).pipe(flatMap3((engine) => engine.listConflicts), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error))),
44967
+ resolveConflict: (id, resolution) => build(false).pipe(flatMap3((engine) => engine.resolveConflict(id, resolution)), catch_2((error) => error instanceof MountError ? fail6(error) : die3(error)))
44878
44968
  });
44879
44969
  }));
44880
44970
  }
@@ -45471,8 +45561,31 @@ class ArtifactClient {
45471
45561
  } : {}
45472
45562
  };
45473
45563
  }
45564
+ async request(url, init) {
45565
+ try {
45566
+ return await fetch(url, init);
45567
+ } catch (cause) {
45568
+ const details = [];
45569
+ const seen = new Set;
45570
+ for (let error = cause;error instanceof Error && !seen.has(error); error = error.cause) {
45571
+ seen.add(error);
45572
+ const code = "code" in error && typeof error.code === "string" ? error.code : undefined;
45573
+ let detail = `${error.message}${code && /^[A-Z][A-Z0-9_]+$/.test(code) ? ` (${code})` : ""}`;
45574
+ detail = detail.replace(/https?:\/\/\S+/giu, "[URL]");
45575
+ for (const secret of [this.options.access?.clientId, this.options.access?.clientSecret]) {
45576
+ if (secret)
45577
+ detail = detail.replaceAll(secret, "[REDACTED]");
45578
+ }
45579
+ details.push(detail.replace(/[\r\n\t]/g, " ").slice(0, 300));
45580
+ if (details.length === 4)
45581
+ break;
45582
+ }
45583
+ const TransportError = cause instanceof TypeError ? TypeError : Error;
45584
+ throw new TransportError(`Cannot reach ${new URL(url).origin}: ${details.join(": ") || "unknown transport failure"}`, { cause });
45585
+ }
45586
+ }
45474
45587
  async rpc(method, body, signal) {
45475
- const response = await fetch(`${this.options.baseUrl}/api/rpc/${method}`, {
45588
+ const response = await this.request(`${this.options.baseUrl}/api/rpc/${method}`, {
45476
45589
  method: "POST",
45477
45590
  headers: this.headers(),
45478
45591
  body: JSON.stringify(body),
@@ -45486,7 +45599,7 @@ class ArtifactClient {
45486
45599
  return this.rpc("prepareUpload", input);
45487
45600
  }
45488
45601
  async upload(uploadUrl, content, contentHash, contentType = "text/markdown") {
45489
- const response = await fetch(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
45602
+ const response = await this.request(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
45490
45603
  method: "PUT",
45491
45604
  headers: {
45492
45605
  ...this.headers(false),
@@ -45517,7 +45630,7 @@ class ArtifactClient {
45517
45630
  return decodeUnknownSync(UploadSession)(await this.rpc("abortUploadSession", { sessionId }, signal));
45518
45631
  }
45519
45632
  async uploadPart(sessionId, partNumber, content, signal) {
45520
- const response = await fetch(`${this.options.baseUrl}/api/upload/sessions/${encodeURIComponent(sessionId)}/parts/${partNumber}`, {
45633
+ const response = await this.request(`${this.options.baseUrl}/api/upload/sessions/${encodeURIComponent(sessionId)}/parts/${partNumber}`, {
45521
45634
  method: "PUT",
45522
45635
  headers: {
45523
45636
  ...this.headers(false),
@@ -45615,7 +45728,7 @@ class ArtifactClient {
45615
45728
  return this.rpc("deleteUpload", { id });
45616
45729
  }
45617
45730
  async uploadFile(uploadUrl, content, contentHash, contentType) {
45618
- const response = await fetch(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
45731
+ const response = await this.request(uploadUrl.startsWith("http") ? uploadUrl : `${this.options.baseUrl}${uploadUrl}`, {
45619
45732
  method: "PUT",
45620
45733
  headers: {
45621
45734
  ...this.headers(false),
@@ -45659,7 +45772,7 @@ class ArtifactClient {
45659
45772
  return this.rpc("readArchiveExportPage", input);
45660
45773
  }
45661
45774
  async downloadArchiveBlob(snapshotId, hash) {
45662
- const response = await fetch(`${this.options.baseUrl}/api/archive/export/${encodeURIComponent(snapshotId)}/sha256/${hash}`, { headers: this.headers(false) });
45775
+ const response = await this.request(`${this.options.baseUrl}/api/archive/export/${encodeURIComponent(snapshotId)}/sha256/${hash}`, { headers: this.headers(false) });
45663
45776
  if (!response.ok)
45664
45777
  throw new Error(`archive blob download failed (${response.status}): ${await response.text()}`);
45665
45778
  return new Uint8Array(await response.arrayBuffer());
@@ -45674,7 +45787,7 @@ class ArtifactClient {
45674
45787
  return this.rpc("stageArchiveImport", { importId, records });
45675
45788
  }
45676
45789
  async uploadArchiveBlob(importId, blob, bytes) {
45677
- const response = await fetch(`${this.options.baseUrl}/api/archive/import/${encodeURIComponent(importId)}/sha256/${blob.hash}`, {
45790
+ const response = await this.request(`${this.options.baseUrl}/api/archive/import/${encodeURIComponent(importId)}/sha256/${blob.hash}`, {
45678
45791
  method: "PUT",
45679
45792
  headers: {
45680
45793
  ...this.headers(false),
@@ -47280,7 +47393,7 @@ var archiveFiles = (input) => gen2(function* () {
47280
47393
  if (!(yield* fs.exists(source))) {
47281
47394
  return yield* fail6(new NotesCommandError({
47282
47395
  reason: "not_found",
47283
- message: `Archive path does not exist: ${argument}`
47396
+ 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
47397
  }));
47285
47398
  }
47286
47399
  const canonical = yield* fs.realPath(source);
@@ -47386,7 +47499,9 @@ function formatReport(name, report) {
47386
47499
  const lines = report.actions.length === 0 ? [dim(`${prefix}: no changes`)] : [`${prefix}: ${report.actions.length} action(s)`];
47387
47500
  for (const action of report.actions.slice(0, MAX_ACTIONS)) {
47388
47501
  const ref = action.externalId === undefined ? "" : ` #${action.externalId}`;
47389
- lines.push(` ${bold2(action.op)} ${action.kind} ${action.slug}${dim(ref)}`);
47502
+ const hashes = action.storedHash !== undefined && action.currentHash !== undefined ? `: ${action.storedHash}\u2192${action.currentHash}` : "";
47503
+ const reason = report.dryRun && action.reason !== undefined ? ` (${action.reason}${hashes})` : "";
47504
+ lines.push(` ${bold2(action.op)} ${action.kind} ${action.slug}${dim(ref)}${dim(reason)}`);
47390
47505
  }
47391
47506
  const remaining = report.actions.length - Math.min(report.actions.length, MAX_ACTIONS);
47392
47507
  if (remaining > 0)
@@ -48408,7 +48523,7 @@ var bundleHtml = async (options) => {
48408
48523
  // package.json
48409
48524
  var package_default = {
48410
48525
  name: "@aryasaatvik/scratchpad",
48411
- version: "0.3.6",
48526
+ version: "0.5.0",
48412
48527
  description: "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
48413
48528
  keywords: [
48414
48529
  "bun",
@@ -50531,9 +50646,33 @@ var feedbackClassification2 = (result) => {
50531
50646
  model: result.model
50532
50647
  };
50533
50648
  };
50534
- var rewriteFeedbackFrontmatter = (file, update) => gen2(function* () {
50649
+ var withFeedbackLock = (file, effect) => gen2(function* () {
50650
+ const fs = yield* FileSystem;
50651
+ const canonical = yield* fs.realPath(file);
50652
+ const lock = `${canonical}.lock`;
50653
+ return yield* acquireUseRelease2(fs.makeDirectory(lock, { mode: 448 }).pipe(mapError2((error2) => isAlreadyExists(error2) ? new NotesCommandError({
50654
+ reason: "conflict",
50655
+ message: "Feedback occurrence is locked by another writer; retry after it finishes. If it exited, inspect and remove the stale .lock directory first."
50656
+ }) : error2)), () => effect, () => fs.remove(lock, { recursive: true }).pipe(orDie2));
50657
+ });
50658
+ var replaceFeedbackContent = (file, original, updated) => scoped2(gen2(function* () {
50535
50659
  const fs = yield* FileSystem;
50536
50660
  const path = yield* Path;
50661
+ const directory = yield* fs.makeTempDirectoryScoped({
50662
+ directory: path.dirname(file),
50663
+ prefix: `.${path.basename(file)}.tmp-`
50664
+ });
50665
+ const temporary = path.join(directory, "occurrence");
50666
+ const { mode } = yield* fs.stat(file);
50667
+ yield* fs.writeFileString(temporary, updated, { flag: "wx", mode: 384 });
50668
+ yield* fs.chmod(temporary, mode & 4095);
50669
+ if ((yield* fs.readFileString(file)) !== original)
50670
+ return false;
50671
+ yield* fs.rename(temporary, file);
50672
+ return true;
50673
+ }));
50674
+ var rewriteFeedbackFrontmatter = (file, update) => withFeedbackLock(file, gen2(function* () {
50675
+ const fs = yield* FileSystem;
50537
50676
  for (let attempt = 0;attempt < 5; attempt += 1) {
50538
50677
  const content = yield* fs.readFileString(file);
50539
50678
  const { values, rawBody } = yield* parseFeedbackContent(content);
@@ -50553,27 +50692,161 @@ var rewriteFeedbackFrontmatter = (file, update) => gen2(function* () {
50553
50692
  const updatedContent = `---
50554
50693
  ${yaml}
50555
50694
  ---${rawBody}`;
50556
- if ((yield* fs.readFileString(file)) !== content) {
50557
- if (attempt === 4) {
50558
- return yield* new NotesCommandError({
50559
- reason: "conflict",
50560
- message: "Feedback occurrence kept changing while it was being updated"
50561
- });
50562
- }
50695
+ if (!(yield* replaceFeedbackContent(file, content, updatedContent)))
50563
50696
  continue;
50564
- }
50565
- const random = yield* next;
50566
- const suffix = Math.floor(random * 4294967296).toString(16).padStart(8, "0");
50567
- const temporary = path.join(path.dirname(file), `.${path.basename(file)}.${suffix}.tmp`);
50568
- const { mode } = yield* fs.stat(file);
50569
- yield* fs.writeFileString(temporary, updatedContent, { flag: "wx" });
50570
- yield* fs.chmod(temporary, mode & 4095).pipe(andThen2(fs.rename(temporary, file)), tapError2(() => fs.remove(temporary).pipe(ignore2)));
50571
50697
  return;
50572
50698
  }
50573
50699
  return yield* new NotesCommandError({
50574
50700
  reason: "conflict",
50575
50701
  message: "Feedback occurrence kept changing while it was being updated"
50576
50702
  });
50703
+ }));
50704
+ var metadataKeys = ["project", "host", "harness", "model", "session"];
50705
+ var filenameDate = (name) => {
50706
+ const match = /^(\d{4})-?(\d{2})-?(\d{2})(?:T(\d{2})-?(\d{2})(?:-?(\d{2}))?Z)?(?=[-.]|$)/u.exec(name);
50707
+ if (match === null)
50708
+ return;
50709
+ const [, year, month, day, hour, minute, second] = match;
50710
+ const value = `${year}-${month}-${day}T${hour ?? "00"}:${minute ?? "00"}:${second ?? "00"}Z`;
50711
+ const millis = Date.parse(value);
50712
+ if (!Number.isFinite(millis) || new Date(millis).toISOString() !== value.replace("Z", ".000Z")) {
50713
+ return;
50714
+ }
50715
+ return {
50716
+ value,
50717
+ source: hour === undefined ? "filename-day-midnight-UTC" : "filename"
50718
+ };
50719
+ };
50720
+ var legacyHeader = (yaml) => {
50721
+ try {
50722
+ return decodeUnknownSync(FeedbackYaml)(Bun.YAML.parse(yaml));
50723
+ } catch {
50724
+ const values = {};
50725
+ for (const line of yaml.split(/\r?\n/u)) {
50726
+ if (line.trim() === "")
50727
+ continue;
50728
+ const match = /^([A-Za-z_][A-Za-z0-9_-]*):[ \t]*(.*)$/u.exec(line);
50729
+ if (match === null || Object.hasOwn(values, match[1]))
50730
+ return;
50731
+ const key = match[1];
50732
+ const raw = match[2];
50733
+ const plainColonStatus = key === "status" && /^[A-Za-z0-9][^\r\n]*: /u.test(raw);
50734
+ try {
50735
+ const value = Bun.YAML.parse(raw);
50736
+ if (!isScalar(value)) {
50737
+ if (!plainColonStatus)
50738
+ return;
50739
+ values[key] = raw;
50740
+ } else {
50741
+ values[key] = value;
50742
+ }
50743
+ } catch {
50744
+ if (!plainColonStatus)
50745
+ return;
50746
+ values[key] = raw;
50747
+ }
50748
+ }
50749
+ return typeof values.recorded === "string" && values.kind === undefined ? values : undefined;
50750
+ }
50751
+ };
50752
+ var normalizeFeedback = (input) => gen2(function* () {
50753
+ const fs = yield* FileSystem;
50754
+ const path = yield* Path;
50755
+ const project = input.global ? undefined : yield* Project;
50756
+ const root = path.join(input.global ? globalNotesRoot() : project.notesRoot, "feedback");
50757
+ const items = [];
50758
+ if (!(yield* fs.exists(root)))
50759
+ return { items, unchanged: 0 };
50760
+ let unchanged = 0;
50761
+ for (const name of (yield* fs.readDirectory(root)).filter((entry) => entry.endsWith(".md")).sort()) {
50762
+ const file = path.join(root, name);
50763
+ if (isSuccess2(yield* result2(fs.readLink(file))) || (yield* fs.stat(file)).type !== "File")
50764
+ continue;
50765
+ const normalizeFile = gen2(function* () {
50766
+ for (let attempt = 0;attempt < 5; attempt += 1) {
50767
+ const bytes = yield* fs.readFile(file);
50768
+ const decoded = yield* result2(try_3(() => new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes)));
50769
+ if (isFailure2(decoded)) {
50770
+ items.push({
50771
+ path: file,
50772
+ class: "other-undecodable",
50773
+ inferred: [],
50774
+ unknown: [],
50775
+ action: "refused",
50776
+ reason: "invalid UTF-8"
50777
+ });
50778
+ break;
50779
+ }
50780
+ const content = decoded.success;
50781
+ if (isSuccess2(yield* result2(parseFeedbackContent(content)))) {
50782
+ unchanged += 1;
50783
+ break;
50784
+ }
50785
+ const block = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(content);
50786
+ const values = block === null ? {} : legacyHeader(block[1]);
50787
+ 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";
50788
+ const inferred = values?.kind === "instruction-feedback" ? ["status"] : ["kind", "status"];
50789
+ const unknown = metadataKeys.filter((key) => typeof values?.[key] !== "string");
50790
+ const base = { path: file, class: classification, inferred, unknown };
50791
+ const recorded = values?.recorded;
50792
+ 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);
50793
+ if (classification === "other-undecodable" || values === undefined || date === undefined) {
50794
+ items.push({
50795
+ ...base,
50796
+ action: "refused",
50797
+ reason: classification === "other-undecodable" || values === undefined ? "header cannot be safely adopted" : "no derivable occurred_at"
50798
+ });
50799
+ break;
50800
+ }
50801
+ inferred.push("occurred_at");
50802
+ const header = {
50803
+ kind: "instruction-feedback",
50804
+ occurred_at: date.value
50805
+ };
50806
+ for (const key of metadataKeys)
50807
+ header[key] = typeof values[key] === "string" ? values[key] : "unknown";
50808
+ header.status = "new";
50809
+ let collision = false;
50810
+ for (const [key, value] of Object.entries(values)) {
50811
+ const preservedKey = key === "status" || Object.hasOwn(header, key) && header[key] !== value ? `legacy_${key}` : key;
50812
+ if (preservedKey !== key && Object.hasOwn(values, preservedKey)) {
50813
+ collision = true;
50814
+ break;
50815
+ }
50816
+ header[preservedKey] = value;
50817
+ }
50818
+ if (collision || isFailure2(yield* result2(decodeUnknownEffect2(FeedbackFrontmatter)(header)))) {
50819
+ items.push({
50820
+ ...base,
50821
+ action: "refused",
50822
+ reason: "legacy fields conflict with adoption header"
50823
+ });
50824
+ break;
50825
+ }
50826
+ const item = { ...base, occurredAt: date.value, dateSource: date.source };
50827
+ if (input.dryRun) {
50828
+ items.push({ ...item, action: "would-normalize" });
50829
+ break;
50830
+ }
50831
+ const body = block === null ? content : content.slice(block[0].length);
50832
+ if (!(yield* replaceFeedbackContent(file, content, `---
50833
+ ${emitFeedbackYaml(header)}
50834
+ ---
50835
+ ${body}`))) {
50836
+ if (attempt === 4)
50837
+ return yield* new NotesCommandError({
50838
+ reason: "conflict",
50839
+ message: "Feedback occurrence kept changing while it was being normalized"
50840
+ });
50841
+ continue;
50842
+ }
50843
+ items.push({ ...item, action: "normalized" });
50844
+ break;
50845
+ }
50846
+ });
50847
+ yield* input.dryRun ? normalizeFile : withFeedbackLock(file, normalizeFile);
50848
+ }
50849
+ return { items, unchanged };
50577
50850
  });
50578
50851
  var writeFeedbackClassification = (file, classification) => rewriteFeedbackFrontmatter(file, (values) => {
50579
50852
  values.status = classification.confidence < REVIEW_THRESHOLD ? "review" : "classified";
@@ -50818,7 +51091,10 @@ var listFeedback = (input) => gen2(function* () {
50818
51091
  }
50819
51092
  return { entries, skipped };
50820
51093
  });
50821
- var listFeedbackForReview = (global2) => listFeedback({ ...global2 === undefined ? {} : { global: global2 }, statuses: ["new", "review"] });
51094
+ var listFeedbackForReview = (global2) => listFeedback({ ...global2 === undefined ? {} : { global: global2 }, all: true }).pipe(map6((listing) => ({
51095
+ ...listing,
51096
+ entries: listing.entries.filter((entry) => entry.disposition === undefined || entry.disposition === "open")
51097
+ })));
50822
51098
  var printListing = (listing, json, empty) => gen2(function* () {
50823
51099
  if (json) {
50824
51100
  return yield* printJson({
@@ -50837,6 +51113,17 @@ var printListing = (listing, json, empty) => gen2(function* () {
50837
51113
  `));
50838
51114
  }
50839
51115
  });
51116
+ var normalizeCommand = make36("normalize", {
51117
+ global: Boolean6("global").pipe(withDefault4(false)),
51118
+ dryRun: Boolean6("dry-run").pipe(withDefault4(false)),
51119
+ json: jsonFlag
51120
+ }, ({ global: global2, dryRun, json }) => gen2(function* () {
51121
+ const result = yield* normalizeFeedback({ global: global2, dryRun });
51122
+ if (json)
51123
+ return yield* printJson({ schemaVersion: 1, dryRun, ...result });
51124
+ 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(`
51125
+ `));
51126
+ }).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"));
50840
51127
  var newCommand = make36("new", {
50841
51128
  text: String8("text"),
50842
51129
  global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
@@ -50870,7 +51157,7 @@ var reviewCommand = make36("review", {
50870
51157
  listing = yield* listFeedbackForReview(global2);
50871
51158
  }
50872
51159
  yield* printListing(listing, json, "No feedback to review");
50873
- }).pipe(withSelectedClassifier, provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Review new and low-confidence feedback"));
51160
+ }).pipe(withSelectedClassifier, provide4(Project.layer), json ? provideService2(MinimumLogLevel2, "None") : identity)).pipe(withDescription4("Review feedback with no disposition or an open disposition"));
50874
51161
  var listCommand = make36("list", {
50875
51162
  global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
50876
51163
  status: optional4(String9("status")).pipe(withDescription3("Only list feedback with this status (new, review, classified)")),
@@ -50894,7 +51181,13 @@ var resolveCommand = make36("resolve", {
50894
51181
  global: Boolean6("global").pipe(withDefault4(false), withDescription3("Use the host-wide ~/.scratchpad instead of the project notes root")),
50895
51182
  json: jsonFlag
50896
51183
  }, ({ 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"));
50897
- var feedback = make36("feedback").pipe(withSubcommands([newCommand, reviewCommand, listCommand, resolveCommand]), withDescription4("Record and list instruction feedback"));
51184
+ var feedback = make36("feedback").pipe(withSubcommands([
51185
+ newCommand,
51186
+ normalizeCommand,
51187
+ reviewCommand,
51188
+ listCommand,
51189
+ resolveCommand
51190
+ ]), withDescription4("Record and list instruction feedback"));
50898
51191
 
50899
51192
  // packages/cli/src/runtime/store.ts
50900
51193
  import { mkdirSync as mkdirSync2 } from "fs";
@@ -51315,6 +51608,7 @@ var instruction_feedback_default = `# Instruction feedback
51315
51608
  - Capture and routing
51316
51609
  - Occurrence format
51317
51610
  - Worked example
51611
+ - Normalize legacy occurrences
51318
51612
  - Review records and closure
51319
51613
 
51320
51614
  ## Capture and routing
@@ -51448,6 +51742,42 @@ observation supports a possible surfacing gap; it does not prove the command was
51448
51742
  deliberately ignored it. Link the occurrence to the existing investigation rather than copying its
51449
51743
  transcript. A single session with several screenshots is one incident, not one per image.
51450
51744
 
51745
+ ## Normalize legacy occurrences
51746
+
51747
+ Use the CLI to adopt older skipped files before recording their dispositions:
51748
+
51749
+ \`\`\`bash
51750
+ scratchpad feedback normalize --global --dry-run --json
51751
+ scratchpad feedback normalize --global --json
51752
+ \`\`\`
51753
+
51754
+ Omit \`--global\` for the project's feedback folder. Normalization scans only \`.md\` occurrences
51755
+ directly inside that folder, excluding \`reviews/\`, directories, and symlinks. Already decodable
51756
+ files stay untouched. Preview and apply output show file, class, action, derived \`occurred_at\`, date
51757
+ source, inferred fields, and unknown metadata; neither prints occurrence bodies. JSON uses
51758
+ \`schemaVersion: 1\`, \`dryRun\`, \`items\`, and an \`unchanged\` count. Refused files appear as
51759
+ \`action: refused\` with a reason; other safe files can still be adopted.
51760
+
51761
+ The recognized classes are \`no-front-matter\`, \`legacy-recorded\`, and \`missing-occurred_at\`.
51762
+ \`other-undecodable\` files remain unchanged. The CLI derives \`occurred_at\` from legacy UTC
51763
+ \`recorded\`, otherwise from a filename beginning with \`YYYYMMDDThhmmssZ\`, \`YYYY-MM-DDThh-mm-ssZ\`,
51764
+ \`YYYY-MM-DDThhmmssZ\`, \`YYYY-MM-DDThhmmZ\`, or \`YYYY-MM-DD\`. Date-only names use midnight UTC and
51765
+ report \`filename-day-midnight-UTC\`. A file without a derivable date is refused.
51766
+
51767
+ Adoption adds \`kind: instruction-feedback\` and \`status: new\`. It uses legacy \`project\`, \`host\`,
51768
+ \`harness\`, \`model\`, and \`session\` strings where present, otherwise \`unknown\`; it never infers
51769
+ metadata from prose. Legacy values are retained, with conflicting canonical fields moved to
51770
+ \`legacy_<key>\` (for example, \`legacy_status\`). Ambiguous headers or preservation-key collisions are
51771
+ refused. The known legacy unquoted-colon \`status\` is quoted safely. Bodies remain byte-identical:
51772
+ the whole file for headerless notes, or everything after the closing front matter line otherwise.
51773
+ Replacement is atomic, uses private staging with cleanup on failure, preserves permissions, and
51774
+ re-reads after staging for concurrent changes. Normalization and other CLI front matter updates
51775
+ share an occurrence lock held from the initial read through replacement. A competing writer fails
51776
+ with \`conflict\`; retry after the active writer finishes. After a crashed writer, inspect and remove
51777
+ its stale \`.md.lock\` directory before retrying; the CLI never steals locks. Dry-run creates no locks
51778
+ or staging files. Repeating normalization is a no-op for adopted files. Only the CLI changes
51779
+ occurrence front matter; bodies remain immutable.
51780
+
51451
51781
  ## Review records and closure
51452
51782
 
51453
51783
  An explicitly requested \`agent-rules\` feedback review owns diagnosis and fix proposals. It uses this
@@ -51460,8 +51790,9 @@ asks for them. Each text line starts with the occurrence's review disposition, o
51460
51790
  both). Files without a \`status\` read as \`new\`, and files whose front matter does not decode (older
51461
51791
  free-form notes, or a missing \`occurred_at\`) are reported as skipped with the reason, on stderr or
51462
51792
  under \`skipped\` with \`--json\`, rather than silently dropped.
51463
- \`scratchpad feedback review [--global] [--classify] [--json]\` lists the \`new\` and \`review\` queue,
51464
- and \`--classify\` first classifies entries that have no classification yet.
51793
+ \`scratchpad feedback review [--global] [--classify] [--json]\` lists occurrences with no disposition
51794
+ or disposition \`open\`, whatever their triage \`status\`. Every other disposition stays out of this
51795
+ queue. \`--classify\` first classifies queued entries that have no classification yet.
51465
51796
 
51466
51797
  Use \`feedback/reviews/<UTC-timestamp>-<unique-id>.md\` for each review. One reviewer owns that file.
51467
51798
  Record inspected roots, date window, occurrence IDs, grouped issue, evidence, disposition, owner,
@@ -51495,11 +51826,12 @@ and leaves the body and every other key unchanged; resolving again replaces them
51495
51826
  \`disposition_review\` is relative to the occurrence's feedback folder when the record sits under it
51496
51827
  (\`reviews/<name>.md\`), otherwise \`~/\`-relative when it is under the home directory, else absolute.
51497
51828
  The review record stays the authority for the reasoning; the front matter only keeps settled items
51498
- out of the queue. \`feedback list\` and \`feedback review\` hide \`dismissed\`, \`installed\`, and
51499
- \`verified\` occurrences unless \`--all\` or a matching \`--disposition\` is passed; list installed fixes
51500
- awaiting a behavioral check with \`feedback list --disposition installed\`. Occurrences whose front
51501
- matter does not decode cannot be resolved (the error names why); record their disposition in the
51502
- review record only.
51829
+ out of the queue. \`feedback list\` hides \`dismissed\`, \`installed\`, and \`verified\` occurrences unless
51830
+ \`--all\` or a matching \`--disposition\` is passed; list installed fixes awaiting a behavioral check
51831
+ with \`feedback list --disposition installed\`. \`feedback review\` includes only occurrences with no
51832
+ disposition or \`open\`. Occurrences whose front matter does not decode cannot be resolved (the error
51833
+ names why); adopt supported legacy formats with \`feedback normalize\` first. For refused files, keep
51834
+ the disposition in the review record.
51503
51835
 
51504
51836
  Report recurrence by distinct incident/session, affected instruction, host, harness, and known
51505
51837
  model. Count unknown metadata separately. Multiple worker reports of the same incident count once.
@@ -51633,6 +51965,42 @@ Treat QA sessions as research work units:
51633
51965
  - move actionable findings into backlog issues before archiving the session;
51634
51966
  - keep unacted findings in research rather than silently treating them as complete;
51635
51967
  - link archived sessions to the resulting issues, fixes, or durable documentation.
51968
+
51969
+ ## Sync previews and mount errors
51970
+
51971
+ Use \`scratchpad pull --dry-run\`, \`push --dry-run\`, or \`sync --dry-run\` to preview actions. Each
51972
+ action includes a short reason, for example:
51973
+
51974
+ \`\`\`text
51975
+ update issue foo #12 (hash-changed: a1b2c3d4\u2192e5f6a7b8)
51976
+ \`\`\`
51977
+
51978
+ \`no-mapping\` means the local file has no stored mapping; \`hash-changed\` means its content hash
51979
+ changed (which can include rendering changes); \`queued\` means the operation is already in the
51980
+ outbox; \`local-missing\` means a mapped file is absent. Pull also reports \`new-file\`,
51981
+ \`remote-changed\`, \`remote-closed\`, \`conflict\`, and \`archive-expired\` for its corresponding actions.
51982
+ \`--json\` includes \`reason\` and, for dry-run hash changes with a stored baseline, eight-character
51983
+ \`storedHash\` and \`currentHash\` fields. These hashes describe the comparison, not the cause of an
51984
+ edit.
51985
+
51986
+ A stored mount that cannot be matched to the configured mounts fails with an actionable \`\u2717\`
51987
+ diagnostic and exit 1. With \`--json\`, stdout contains a single
51988
+ \`{"status":"error","reason":"mount_error","message":"\u2026"}\` envelope and stderr keeps the diagnostic.
51989
+ A missing configured directory with stored mappings also refuses sync before planning closes or
51990
+ archives: restore the named directory or inspect \`scratchpad repair\`. Removing one file from an
51991
+ existing directory still plans its normal close or archive.
51992
+
51993
+ A \`retire\` with \`remote-closed\` means the provider reports a closed object: a real pull removes its
51994
+ active backlog file if present and marks its mapping closed, updating the stored remote hash and
51995
+ timestamp. A stale mapping can need this update even when its file is already absent. Archive
51996
+ projection, when configured, is separate. A \`retire\` with \`local-missing\` removes a redundant
51997
+ mapping whose duplicate file is absent; it does not close the remote object.
51998
+
51999
+ A mount path replaced by a file or an unreadable directory scan also stops sync; neither is
52000
+ interpreted as an empty mount. Restore the directory and read access before retrying. Conflicting
52001
+ stored rows during alias adoption produce \`mount_error\` too, while retaining the original state. For
52002
+ an unmatched stored mount, restore its configuration or directory first: \`scratchpad repair\`
52003
+ resolves content conflicts and cannot repair mount aliases.
51636
52004
  `;
51637
52005
 
51638
52006
  // packages/cli/skill-data/scratchpad/references/organization.md
@@ -51766,6 +52134,8 @@ git status --short -- .scratchpad
51766
52134
 
51767
52135
  ## Where notes live
51768
52136
 
52137
+ Archive paths are relative to the notes root; omit the leading \`.scratchpad/\`.
52138
+
51769
52139
  \`scratchpad path\` prints the notes root: the checkout's \`.scratchpad\`, else the primary checkout's,
51770
52140
  else \`$XDG_DATA_HOME/scratchpad/projects/<project-id>\`. \`scratchpad path --global\` prints the
51771
52141
  host-wide \`~/.scratchpad\`. \`scratchpad doctor\` adds the project id, whether the root came from the
@@ -52484,7 +52854,7 @@ var app = make36("scratchpad").pipe(withDescription4("Local-first GitHub issue a
52484
52854
  uploadCommand,
52485
52855
  uploadsCommand
52486
52856
  ]));
52487
- var main = withConsoleBuffer(run5(app, { version: CLI_VERSION }).pipe(provide4(layer13([cliLogger])), provide4(layer12), tapErrorTag2("ConfigError", renderError("config_error")), tapErrorTag2("ProjectError", renderError("project_error")), tapErrorTag2("DeleteUsageError", renderError("usage")), tapErrorTag2("RepairUsageError", renderError("usage")), tapErrorTag2("AuthMissingError", renderError("auth_missing")), tapErrorTag2("GithubApiError", renderError("github_error")), tapErrorTag2("RemoteDeleteError", renderError("delete_failed")), tapErrorTag2("SyncFailedError", renderErrorDiagnostic), tapErrorTag2("PlatformError", renderError("io_error")), tapErrorTag2("ArtifactCommandError", renderError("artifact_error")), tapErrorTag2("CodemapCommandError", (error) => renderError(error.reason)(error)), tapErrorTag2("NotesCommandError", (error) => renderError(error.reason)(error))));
52857
+ var main = withConsoleBuffer(run5(app, { version: CLI_VERSION }).pipe(provide4(layer13([cliLogger])), provide4(layer12), tapErrorTag2("ConfigError", renderError("config_error")), tapErrorTag2("ProjectError", renderError("project_error")), tapErrorTag2("DeleteUsageError", renderError("usage")), tapErrorTag2("RepairUsageError", renderError("usage")), tapErrorTag2("AuthMissingError", renderError("auth_missing")), tapErrorTag2("GithubApiError", renderError("github_error")), tapErrorTag2("MountError", renderError("mount_error")), tapErrorTag2("RemoteDeleteError", renderError("delete_failed")), tapErrorTag2("SyncFailedError", renderErrorDiagnostic), tapErrorTag2("PlatformError", renderError("io_error")), tapErrorTag2("ArtifactCommandError", renderError("artifact_error")), tapErrorTag2("CodemapCommandError", (error) => renderError(error.reason)(error)), tapErrorTag2("NotesCommandError", (error) => renderError(error.reason)(error))));
52488
52858
  runMain2(main, { disableErrorReporting: true });
52489
52859
  export {
52490
52860
  renderCodemapHtml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aryasaatvik/scratchpad",
3
- "version": "0.3.6",
3
+ "version": "0.5.0",
4
4
  "description": "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
5
5
  "keywords": [
6
6
  "bun",