@aryasaatvik/scratchpad 0.6.0 → 0.6.2

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.
@@ -29719,7 +29719,8 @@ var DEFAULT_LAYOUT = {
29719
29719
  "decisions",
29720
29720
  "delivery",
29721
29721
  "maintenance",
29722
- "artifacts"
29722
+ "artifacts",
29723
+ "codemaps"
29723
29724
  ],
29724
29725
  files: ["README.md", "STATE.md"]
29725
29726
  };
@@ -51973,8 +51974,8 @@ var bundleHtml = async (options) => {
51973
51974
  // package.json
51974
51975
  var package_default = {
51975
51976
  name: "@aryasaatvik/scratchpad",
51976
- version: "0.6.0",
51977
- description: "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
51977
+ version: "0.6.2",
51978
+ description: "Working memory for coding agents: project notes shared across worktrees, instruction feedback, note search and lifecycle cleanup, plus GitHub backlog sync, hosted artifacts and codemaps.",
51978
51979
  keywords: [
51979
51980
  "bun",
51980
51981
  "cli",
@@ -52013,8 +52014,7 @@ var package_default = {
52013
52014
  "LICENSE",
52014
52015
  "CHANGELOG.md",
52015
52016
  "SECURITY.md",
52016
- "docs/adr",
52017
- "docs/release.md"
52017
+ "docs"
52018
52018
  ],
52019
52019
  type: "module",
52020
52020
  publishConfig: {
@@ -55722,6 +55722,13 @@ var assertRebuildAvailable = async (path) => {
55722
55722
 
55723
55723
  // packages/cli/src/search/index.ts
55724
55724
  var hash3 = (value) => createHash12("sha256").update(value).digest("hex");
55725
+ var VECTOR_WRITE_BATCH = 1024;
55726
+ var inBatches = (items, write) => {
55727
+ const results = [];
55728
+ for (let i = 0;i < items.length; i += VECTOR_WRITE_BATCH)
55729
+ results.push(...write(items.slice(i, i + VECTOR_WRITE_BATCH)));
55730
+ return results;
55731
+ };
55725
55732
  var Metadata = Struct({
55726
55733
  title: optional2(String5),
55727
55734
  kind: optional2(String5)
@@ -55842,7 +55849,7 @@ var run6 = fn2("Search.run")(function* (options, query) {
55842
55849
  if (docs.length) {
55843
55850
  store.invalidateVectors(docs.map((doc) => doc.id));
55844
55851
  store.trackVectors(docs.map((doc) => doc.id));
55845
- const failed = vectorWriter.upsertSync(docs).find((s) => !s.ok);
55852
+ const failed = inBatches(docs, (batch) => vectorWriter.upsertSync(batch)).find((s) => !s.ok);
55846
55853
  if (failed)
55847
55854
  throw new SearchError({ message: `Vector upsert failed: ${failed.message}` });
55848
55855
  }
@@ -55867,7 +55874,7 @@ var run6 = fn2("Search.run")(function* (options, query) {
55867
55874
  const live = new Set(store.chunks().map((c) => c.id));
55868
55875
  const removed = store.vectorIds().filter((id) => !live.has(id));
55869
55876
  if (removed.length) {
55870
- const failed = vectorWriter.deleteSync(removed).find((s) => !s.ok && s.code !== "ZVEC_NOT_FOUND");
55877
+ const failed = inBatches(removed, (batch) => vectorWriter.deleteSync(batch)).find((s) => !s.ok && s.code !== "ZVEC_NOT_FOUND");
55871
55878
  if (failed)
55872
55879
  throw new SearchError({ message: `Vector delete failed: ${failed.message}` });
55873
55880
  store.forgetVectors(removed);
@@ -56114,8 +56121,9 @@ nested files the same way.
56114
56121
  - Treat GitHub as authoritative for PR state and Scratchpad as the planning-to-delivery map.
56115
56122
  - In a project with a \`scratchpad.config.ts\`, \`scratchpad sync\` also mirrors these files to GitHub
56116
56123
  issues and milestones. A status whose first word is in the config's \`backlog.closedStatuses\`
56117
- (default: done, complete(d), closed, merged, landed, delivered, cancel(l)ed, superseded,
56118
- implemented, historical, moved) syncs as closed. Preview with \`scratchpad sync --dry-run\` first.
56124
+ (default: done, complete, completed, closed, merged, landed, delivered, cancelled, canceled,
56125
+ superseded, implemented, historical, moved) syncs as closed. Preview with
56126
+ \`scratchpad sync --dry-run\` first.
56119
56127
  - Keep completed material active while it is useful for delivery; retire it through this skill's
56120
56128
  \`archive\` mode (a Trash move with a receipt) when it no longer supports current work.
56121
56129
 
@@ -56159,10 +56167,10 @@ For multi-worktree or multi-harness work:
56159
56167
  releasing the worker lease or removing its worktree.
56160
56168
 
56161
56169
  For durable user-visible tasks, the coordinator owns one Markdown-table registry at
56162
- \`.scratchpad/backlog/handoffs/task-registry.md\`; it records the stable task ID/title, stream,
56163
- current delivery, worktree/branch/PR, last verified base, next-ready work, exclusions, and write
56164
- allowlist. Treat the registry as a recovery aid: task runtime, Git, GitHub, tests, and providers
56165
- remain authoritative.
56170
+ \`.scratchpad/handoffs/task-registry.md\`; it records the stable task ID/title, stream, current
56171
+ delivery, worktree/branch/PR, last verified base, next-ready work, exclusions, and write allowlist.
56172
+ Treat the registry as a recovery aid: task runtime, Git, GitHub, tests, and providers remain
56173
+ authoritative.
56166
56174
 
56167
56175
  Treat coordination notes as advisory. Recheck actual worker, Git, and runtime state before assigning
56168
56176
  or closing work.
@@ -56286,12 +56294,14 @@ reported by the harness; do not infer a model from writing style or a product na
56286
56294
 
56287
56295
  ### Classification
56288
56296
 
56289
- When a classifier is configured (\`scratchpad doctor\` reports it), \`feedback new\` classifies the
56290
- redacted text after writing the file and adds a \`classification\` block (\`scope\`: project, global, or
56291
- tool; \`kind\`; \`actionable\`; \`confidence\`; \`model\`) to the front matter. \`status\` becomes
56292
- \`classified\`, or \`review\` when confidence is below 0.7. Without a classifier, or when classification
56293
- fails, the file stays \`status: new\` and the command still succeeds. Classification is triage
56294
- metadata; it never edits the body and does not replace a review disposition.
56297
+ When a classifier is configured (\`scratchpad doctor\` reports it; \`SCRATCHPAD_CLASSIFIER=none\` or
56298
+ \`classifier.model: "none"\` turns it off, and \`SCRATCHPAD_CLASSIFIER\` otherwise overrides the model),
56299
+ \`feedback new\` classifies the redacted text after writing the file and adds a \`classification\` block
56300
+ (\`scope\`: project, global, or tool; \`kind\`; \`actionable\`; \`confidence\`; \`model\`) to the front
56301
+ matter. \`status\` becomes \`classified\`, or \`review\` when confidence is below 0.7. Without a
56302
+ classifier, or when classification fails, the file stays \`status: new\` and the command still
56303
+ succeeds. Classification is triage metadata; it never edits the body and does not replace a review
56304
+ disposition.
56295
56305
 
56296
56306
  \`scratchpad route "<correction>"\` asks the classifier which folder owns a correction (project, or
56297
56307
  global for global and tool scope) and writes nothing; it fails when no classifier is configured.
@@ -56483,11 +56493,13 @@ scratchpad search "instruction feedback" --global
56483
56493
  Without an embedding key, search falls back to FTS-only keyword matching and prints a notice on
56484
56494
  stderr; it still works, so use distinctive terms. Hybrid search needs
56485
56495
  \`SCRATCHPAD_OPENROUTER_API_KEY\` or the key in \`~/.config/scratchpad/secrets/openrouter-api-key\`
56486
- (mode \`0600\`). Never print or record the key. With a key, the note title, heading, and chunk text of
56487
- every indexed note, and each query, are sent to OpenRouter (\`qwen/qwen3-embedding-8b\`). Before
56488
- searching notes that hold secrets, customer data, or anything the user would not share with that
56489
- provider, set \`search: { embeddings: false }\` in \`scratchpad.config.ts\` (discovered upward,
56490
- including ancestor configs), which stays FTS-only even when a key is present.
56496
+ (keep it \`0600\` and its directory \`0700\`; the CLI does not check). The path honors an absolute
56497
+ \`$XDG_CONFIG_HOME\` (default \`~/.config\`). Never print or record the key. With a key, the note title,
56498
+ heading, and chunk text of every indexed note, and each query, are sent to OpenRouter
56499
+ (\`qwen/qwen3-embedding-8b\`). Before searching notes that hold secrets, customer data, or anything
56500
+ the user would not share with that provider, set \`search: { embeddings: false }\` in
56501
+ \`scratchpad.config.ts\` (discovered upward, including ancestor configs), which stays FTS-only even
56502
+ when a key is present.
56491
56503
 
56492
56504
  ## Initialize
56493
56505
 
@@ -56500,6 +56512,9 @@ first use. The root index should explain:
56500
56512
  - where the latest handoff lives;
56501
56513
  - which checkout or worktree owns shared coordination state.
56502
56514
 
56515
+ This mode organizes notes; the CLI \`scratchpad init\` only scaffolds \`scratchpad.config.ts\` and
56516
+ backlog mounts for GitHub sync.
56517
+
56503
56518
  Do not create placeholder files or elaborate taxonomy without an immediate use. Read the
56504
56519
  \`organization\` reference when choosing a layout or retention policy.
56505
56520
 
@@ -56711,8 +56726,10 @@ scratchpad review [paths...] [--apply] [--json] [--limit 100]
56711
56726
  placeholder. Set \`lifecycle.notes.estimatedCostPerCall\` for that fallback.
56712
56727
  - Classification uses OpenRouter Decisions with pinned default model \`typesafe/jev-1.14\`. Set
56713
56728
  \`classifier.model\` to \`~typesafe/jev-latest\` only when a moving alias is wanted. It shares
56714
- \`SCRATCHPAD_OPENROUTER_API_KEY\` or \`~/.config/scratchpad/secrets/openrouter-api-key\` (0600) with
56715
- search embeddings. \`classifier.model\` names an OpenRouter model ID.
56729
+ \`SCRATCHPAD_OPENROUTER_API_KEY\` or \`~/.config/scratchpad/secrets/openrouter-api-key\` (keep
56730
+ it 0600) with search embeddings. \`classifier.model\` names an OpenRouter model ID;
56731
+ \`SCRATCHPAD_CLASSIFIER\` overrides it. Set \`SCRATCHPAD_CLASSIFIER=none\` or
56732
+ \`classifier.model: "none"\` to turn classification off even when a key is present.
56716
56733
  - Without a classifier key, \`review\` says \`classifier disabled\` and exits 0, and \`sweep\` handles
56717
56734
  artifacts only. \`scratchpad doctor\` shows whether a classifier is configured; enable it with
56718
56735
  \`SCRATCHPAD_OPENROUTER_API_KEY\` or the XDG secret the README describes.
@@ -56766,30 +56783,38 @@ reorganize other repositories merely to match this example.
56766
56783
  \`\`\`text
56767
56784
  .scratchpad/
56768
56785
  \u251C\u2500\u2500 README.md
56769
- \u251C\u2500\u2500 feedback/
56770
- \u251C\u2500\u2500 research/
56786
+ \u251C\u2500\u2500 STATE.md
56771
56787
  \u251C\u2500\u2500 backlog/
56772
56788
  \u2502 \u251C\u2500\u2500 issues/
56773
56789
  \u2502 \u251C\u2500\u2500 milestones/
56774
- \u2502 \u251C\u2500\u2500 handoffs/
56775
56790
  \u2502 \u2514\u2500\u2500 parking-lot.md
56791
+ \u251C\u2500\u2500 research/
56776
56792
  \u251C\u2500\u2500 reference/
56777
- \u2514\u2500\u2500 maintenance/
56793
+ \u251C\u2500\u2500 feedback/
56794
+ \u251C\u2500\u2500 handoffs/
56795
+ \u251C\u2500\u2500 decisions/
56796
+ \u251C\u2500\u2500 delivery/
56797
+ \u251C\u2500\u2500 maintenance/
56798
+ \u251C\u2500\u2500 artifacts/
56799
+ \u2514\u2500\u2500 codemaps/
56778
56800
  \`\`\`
56779
56801
 
56802
+ Create only what the work needs: \`STATE.md\` and the folders are made on first use, not up front.
56803
+
56780
56804
  - Keep \`README.md\` as a small index of active work and important continuity pointers.
56781
56805
  - Put instruction-friction occurrences in \`feedback/\` (the \`instruction-feedback\` reference covers
56782
56806
  global and project routing). The home-level \`~/.scratchpad/feedback/\` holds shared feedback.
56783
56807
  - Put investigations, comparisons, and temporary findings in \`research/\`.
56784
56808
  - Put executable work and delivery groupings in \`backlog/\`; the CLI reads issues and milestones only
56785
56809
  from \`backlog/issues/\` and \`backlog/milestones/\`, at any depth beneath them.
56786
- - Put session-continuity artifacts in \`backlog/handoffs/\`.
56810
+ - Put session-continuity artifacts, including \`task-registry.md\`, in the top-level \`handoffs/\`.
56787
56811
  - Put unsettled working contracts in \`reference/\`.
56788
56812
  - Retire inactive working memory with \`scratchpad archive\`, which moves it to the OS Trash and
56789
56813
  records a receipt in \`maintenance/trash-log.md\`. There is no \`archive/\` folder.
56790
56814
  - Keep only declared top-level folders; \`scratchpad doctor\` reports the rest against \`layout\` in
56791
56815
  \`scratchpad.config.ts\`. Built-in folders: \`backlog\`, \`research\`, \`reference\`, \`feedback\`,
56792
- \`handoffs\`, \`decisions\`, \`delivery\`, \`maintenance\`, \`artifacts\`; files: \`README.md\`, \`STATE.md\`.
56816
+ \`handoffs\`, \`decisions\`, \`delivery\`, \`maintenance\`, \`artifacts\`, \`codemaps\`; files: \`README.md\`,
56817
+ \`STATE.md\`.
56793
56818
 
56794
56819
  This is a convention, not a required schema. Follow an existing repository layout instead of
56795
56820
  rewriting it to match this example.
@@ -56801,7 +56826,7 @@ responsibilities, not a universal schema:
56801
56826
 
56802
56827
  | Category | Use when the project needs it |
56803
56828
  | -------------- | ------------------------------------------------------------- |
56804
- | \`backlog/\` | Issues, milestones, deferred decisions, and handoffs |
56829
+ | \`backlog/\` | Issues, milestones, and deferred work |
56805
56830
  | \`delivery/\` | Delivery plans and current execution evidence |
56806
56831
  | \`research/\` | Investigations and comparisons |
56807
56832
  | \`reference/\` | Working reference material not yet suitable for tracked docs |
@@ -56813,6 +56838,11 @@ responsibilities, not a universal schema:
56813
56838
  | \`maintenance/\` | Trash receipts (\`trash-log.md\`) written by the CLI |
56814
56839
  | \`tmp/\` | Explicitly disposable experiments, not authoritative evidence |
56815
56840
 
56841
+ Folders outside the default layout (\`marketing/\`, \`incidents/\`, \`validation/\`, \`web-audits/\`,
56842
+ \`tmp/\`) must be declared in \`layout.folders\` in \`scratchpad.config.ts\`, or \`scratchpad doctor\` flags
56843
+ them. Prefer the defaults: validation reports to \`maintenance/\`, incidents to \`decisions/\` or
56844
+ \`delivery/\`, temporary output to \`artifacts/\` (which \`sweep\` expires).
56845
+
56816
56846
  Keep the root index short and link to owning records. A record's status and evidence matter more
56817
56847
  than its folder name. Shared storage does not require one giant state file: assign task-specific
56818
56848
  files and one writer per file.
@@ -56848,7 +56878,8 @@ description:
56848
56878
  evidence authoritative. Owns .scratchpad only \u2014 not README, docs/, AGENTS.md, project-local
56849
56879
  skills, or Claude Code / Codex auto-memory."
56850
56880
  argument-hint:
56851
- "[status | explore | search | init | backlog | feedback | sync | reconcile | archive | extract]"
56881
+ "[status | explore | search | init | backlog | feedback | review | sync | reconcile | archive |
56882
+ extract]"
56852
56883
  metadata:
56853
56884
  opencode/slash: "true"
56854
56885
  ---
@@ -56980,6 +57011,10 @@ it. Keep analysis local. Treat static analyzer output as evidence, never as the
56980
57011
  \`.scratchpad/codemaps/<name>/\`; let the CLI own timestamped bundles.
56981
57012
  - Never inspect, copy, upload to, or invoke Foglamp. This workflow implements the independent
56982
57013
  Scratchpad product contract.
57014
+ - \`codemaps/\` is part of the default Scratchpad layout. Age-based artifact expiry in
57015
+ \`scratchpad sweep\` skips \`codemap.json\` beside \`codemap.html\` but expires leftover draft files;
57016
+ delete or regenerate drafts instead of relying on them. The HTML is still a note, so a \`stale\` or
57017
+ \`superseded\` review verdict can sweep it; add \`codemaps/**\` to \`lifecycle.protect\` to keep bundles.
56983
57018
  - Do not install a skill globally, publish a codemap, or modify tracked repository files.
56984
57019
  - Keep the overview at no more than 40 nodes and 80 meaningful edges. Aim below the caps so the map
56985
57020
  remains legible.
@@ -57717,7 +57752,7 @@ var withConsoleBuffer = (program) => acquireUseRelease2(sync2(() => {
57717
57752
  }
57718
57753
  state.buffer.length = 0;
57719
57754
  }));
57720
- var app = make39("scratchpad").pipe(withDescription4("Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps"), withSubcommands([
57755
+ var app = make39("scratchpad").pipe(withDescription4("Working memory for coding agents: project notes shared across worktrees, instruction feedback, note search and lifecycle cleanup, plus GitHub backlog sync, hosted artifacts and codemaps."), withSubcommands([
57721
57756
  init,
57722
57757
  path,
57723
57758
  doctor,
@@ -33,6 +33,13 @@ domain documents; GitHub DTOs do not cross the `GithubClientShape` or
33
33
  documents into GitHub requests, resolves milestone slug-to-number linking, and
34
34
  maps GitHub failures to `ProviderError`.
35
35
 
36
+ Translation from wire DTOs to domain documents lives in pure mapping functions in
37
+ `github/client.ts`, beside the DTO schemas, called from the client's decode helpers. Schema handles only
38
+ wire encoding (dates, numbers); the mapping stays a function rather than a
39
+ `Schema` transformation, because it renames fields, derives values such as slugs,
40
+ and builds nested objects (`providerRef`, `sync`) that do not exist on the wire.
41
+ A transformation would also need an `encode` direction nothing uses.
42
+
36
43
  Repo identity comes from `scratchpad.config.ts` (`owner/name`), not from git
37
44
  remotes. Auth resolves `GITHUB_TOKEN` / `GH_TOKEN`, then `gh auth token`.
38
45
  Transport details are documented in
@@ -1,6 +1,7 @@
1
1
  # 0008 — The CLI classifies notes with an optional decision model
2
2
 
3
- Status: Accepted
3
+ Status: Accepted. Superseded in part by [0010](0010-openrouter-decisions-and-note-lifecycle.md),
4
+ which replaces the transport and default model.
4
5
 
5
6
  ## Context
6
7
 
@@ -0,0 +1,71 @@
1
+ # 0010 — OpenRouter Decisions and note lifecycle
2
+
3
+ Status: Accepted
4
+
5
+ ## Context
6
+
7
+ [ADR 0008](0008-cli-decision-model.md) gave the CLI an optional `Classifier` over Effect's
8
+ `DecisionModel`, served by TypeSafe's Jev model over its direct API. Two things changed. Notes
9
+ need lifecycle judgment as well as feedback routing: is a note still fresh, stale, or superseded
10
+ by newer work? And search embeddings arrived ([ADR 0012](0012-local-hybrid-search.md)), which
11
+ made a second provider key a cost for the user. OpenRouter serves both decision models and
12
+ embeddings under one key.
13
+
14
+ ## Decision
15
+
16
+ **Transport.** The classifier calls OpenRouter's Decisions API through `@effect/ai-openrouter`.
17
+ Decision models are listed by `GET https://openrouter.ai/api/v1/models?output_modalities=decisions`.
18
+ The model still comes from `SCRATCHPAD_CLASSIFIER`, then `classifier.model`, then the default;
19
+ `none` disables it. One OpenRouter key serves classification, lifecycle review, and search
20
+ embeddings.
21
+
22
+ **Pinned default.** The default is `typesafe/jev-1.14`, an exact version, so cached verdicts stay
23
+ valid until the model is deliberately changed. The moving `~typesafe/jev-latest` alias is opt-in
24
+ through `classifier.model`. `typesafe/jev-router` is a chat model, not a decision model, and is
25
+ not valid.
26
+
27
+ **Confidence.** Confidence is the probability of the chosen label, taken from the Decisions API,
28
+ independent of kind probability and the provider's separate confidence metric. Per-label
29
+ probabilities are returned and cached with each review.
30
+
31
+ **Review.** `scratchpad review` asks one four-label question per note (`fresh`, `stale`,
32
+ `superseded`, `expired`) with repository evidence. Verdicts are cached in the project state
33
+ database, keyed by content, evidence, model, and question revision. A question revision therefore
34
+ invalidates old verdicts. `review --apply` writes only lifecycle front matter.
35
+
36
+ **Sweep consumes the cache.** `sweep` never calls the model. It trashes only cached
37
+ stale/superseded verdicts at or above `lifecycle.notes.autoTrashConfidence` (default 0.9), and
38
+ protects:
39
+
40
+ - README and STATE indexes,
41
+ - backlog and feedback,
42
+ - notes updated within `minFreshDays` (default 7),
43
+ - notes linked from a live (non-stale) note,
44
+ - paths matching `lifecycle.protect` globs.
45
+
46
+ An expired model verdict alone never auto-trashes a note.
47
+
48
+ ## Calibration evidence
49
+
50
+ The original four-label question was compared with three sharper prompts on 31 sample notes. The
51
+ original matched 5 of 5 evidence anchors; the three sharper prompts misjudged live or durable
52
+ notes. The whole experiment cost about $0.023. The sharper prompts were not adopted.
53
+
54
+ ## Consequences
55
+
56
+ - Classification, lifecycle review, and embeddings depend on one provider account and one key
57
+ location (`~/.config/scratchpad/secrets/openrouter-api-key`, or
58
+ `SCRATCHPAD_OPENROUTER_API_KEY`). Without it, every command still works; review reports that
59
+ the classifier is disabled and sweep handles artifacts only.
60
+ - Moving to a new default model invalidates cached verdicts and is a visible change.
61
+ - The 0008 rules about redaction, writes-first behavior, and deterministic tests are unchanged.
62
+ `TYPESAFE_API_KEY` is no longer used.
63
+
64
+ ## Alternatives
65
+
66
+ - **Keep the direct TypeSafe API.** Rejected: a second key beside OpenRouter embeddings, and no
67
+ shared model catalog.
68
+ - **A moving alias as the default.** Rejected: silent model changes would shift verdicts that
69
+ sweep acts on.
70
+ - **A chat model with a free-text verdict.** Rejected: untyped output, no per-label
71
+ probabilities, no calibrated confidence.
@@ -0,0 +1,46 @@
1
+ # 0011 — Trash instead of archive folders
2
+
3
+ Status: Accepted
4
+
5
+ ## Context
6
+
7
+ Retiring a note used to mean moving it into a dated directory under `archive/`. Those folders
8
+ grew without bound and nothing cleaned them, so retired notes and expired artifacts kept
9
+ occupying disk and showing up in the notes root.
10
+
11
+ ## Decision
12
+
13
+ `archive` and `sweep --apply` move files to the operating system's Trash: `/usr/bin/trash` on
14
+ macOS and `gio trash` on Linux. Other platforms report an unsupported-platform error. Trash is
15
+ recoverable and the OS reclaims its space.
16
+
17
+ Each move is receipted in `maintenance/trash-log.md`. The CLI writes and flushes a `pending`
18
+ receipt first, then appends `trashed`, `failed`, or `skipped-changed` with the same id. An
19
+ unmatched `pending` means a crash or interruption between the two and needs a human to reconcile
20
+ the source path against the Trash; the CLI never retries it automatically. A later failure does
21
+ not undo earlier moves.
22
+
23
+ `archive` acts on the paths it is given immediately; it has no preview. `sweep` previews by
24
+ default and moves nothing without `--apply`, and `sweep --json` reports exactly what an apply run
25
+ would do (see [lifecycle.md](../lifecycle.md)).
26
+
27
+ `.md` and `.html` files are notes, never artifacts: artifact expiry does not remove them. Notes
28
+ leave only through `archive` or the cached-verdict rules of
29
+ [ADR 0010](0010-openrouter-decisions-and-note-lifecycle.md).
30
+ The GitHub archive mount of [ADR 0005](0005-closed-object-archive.md) is a separate, read-only
31
+ projection and is unaffected.
32
+
33
+ ## Consequences
34
+
35
+ - Retirement is reversible from the OS Trash for as long as the user keeps it.
36
+ - The pending-then-final receipt protocol makes crashes visible instead of silent.
37
+ - Existing `archive/` contents are left alone and may contain expired artifacts, which `sweep`
38
+ can still pick up.
39
+ - Trash behavior differs per platform and is unavailable on others.
40
+
41
+ ## Alternatives
42
+
43
+ - **Keep dated archive directories.** Rejected: unbounded growth and no cleanup.
44
+ - **Delete permanently.** Rejected: not recoverable.
45
+ - **A Scratchpad-owned trash directory.** Rejected: it would repeat the unbounded-folder problem
46
+ and skip the OS's own recovery and space reclamation.
@@ -0,0 +1,46 @@
1
+ # 0012 — Local hybrid note search
2
+
3
+ Status: Accepted
4
+
5
+ ## Context
6
+
7
+ Agents need to find earlier decisions, handoffs, and feedback in a notes root that grows with
8
+ every session. Grep misses paraphrases. A hosted index would store every note on another service
9
+ and make search depend on it. Embedding calls send chunk text to OpenRouter, while the index itself
10
+ stays on the machine; what the provider retains is governed by its policy, not by this design.
11
+
12
+ ## Decision
13
+
14
+ `scratchpad search` runs a local hybrid index:
15
+
16
+ - **Text:** SQLite FTS5.
17
+ - **Vectors:** zvec with a FLAT index and cosine distance.
18
+ - **Fusion:** reciprocal rank fusion of the two result lists; the score is reported with each
19
+ result.
20
+ - **Embeddings:** OpenRouter's `qwen/qwen3-embedding-8b` at 1024 dimensions, using the same key as
21
+ the classifier ([ADR 0010](0010-openrouter-decisions-and-note-lifecycle.md)). Note title,
22
+ heading, and chunk text, and queries, are sent there.
23
+
24
+ The index is derived and rebuildable. It lives under the XDG state directory, per project and per
25
+ selected notes root, and is refreshed by content hash before each query, so edits and removals are
26
+ visible without a daemon. `index --rebuild` recreates a scope's stores, including corrupt ones.
27
+
28
+ Without a key, or with `search.embeddings: false`, ordinary searches are FTS-only and say so on
29
+ stderr without loading native bindings. `index --rebuild` still loads zvec when the scope has
30
+ existing vector state, even without a key. The compiled binary embeds the zvec bindings. zvec
31
+ write batches are capped at 1024 documents.
32
+
33
+ ## Consequences
34
+
35
+ - Search sends note text only when embeddings are enabled; `search.embeddings: false` opts out,
36
+ including through ancestor config. Lifecycle review sends note text separately; disable it with
37
+ `classifier.model: "none"` or `SCRATCHPAD_CLASSIFIER=none`.
38
+ - Concurrent writers return a busy error rather than corrupting the index.
39
+ - Linux x64 vector search needs an AVX2-capable CPU.
40
+ - Changing the embedding model or dimensions means rebuilding the index.
41
+
42
+ ## Alternatives
43
+
44
+ - **FTS only.** Rejected as the only mode: it misses paraphrased queries. It remains the fallback.
45
+ - **A hosted vector store.** Rejected: keeps every note off the machine and adds a service to run.
46
+ - **Vector search only.** Rejected: exact identifiers and rare terms retrieve better with FTS.
@@ -10,5 +10,8 @@ Durable record of the decisions behind Scratchpad. Active planning lives in
10
10
  - [0005 — Closed-object archive projection](0005-closed-object-archive.md)
11
11
  - [0006 — GitHub transport: Octokit, GraphQL for issues, REST for milestones](0006-octokit-graphql-and-rest.md)
12
12
  - [0007 — Explicit remote delete](0007-explicit-remote-delete.md)
13
- - [0008 — The CLI classifies notes with an optional decision model](0008-cli-decision-model.md)
13
+ - [0008 — The CLI classifies notes with an optional decision model (superseded in part by 0010)](0008-cli-decision-model.md)
14
14
  - [0009 — Worker-proxied multipart uploads](0009-worker-multipart-uploads.md)
15
+ - [0010 — OpenRouter Decisions and note lifecycle](0010-openrouter-decisions-and-note-lifecycle.md)
16
+ - [0011 — Trash instead of archive folders](0011-trash-instead-of-archive-folders.md)
17
+ - [0012 — Local hybrid note search](0012-local-hybrid-search.md)
@@ -0,0 +1,79 @@
1
+ # Artifacts and uploads
2
+
3
+ The hosted Worker (for example `scratchpad.arya.sh`) serves immutable Markdown/HTML artifact
4
+ revisions with review, share, Trash, and export/import, plus unlisted file uploads. Both require a
5
+ deployment profile (or `--url` on each command). Hosted artifacts are immutable presentation and
6
+ review surfaces over the delivery graph.
7
+
8
+ ## Artifact commands
9
+
10
+ ```
11
+ scratchpad artifact profile set <name> --url <https://…> [--default]
12
+ scratchpad artifact push <path> --slug <slug> [--kind delivery] [--review] [--wait]
13
+ scratchpad artifact list | show <slug>
14
+ scratchpad artifact open <slug>
15
+ scratchpad artifact wait <slug> --json
16
+ scratchpad artifact share | unshare <slug>
17
+ scratchpad artifact delete | restore <slug>
18
+ scratchpad artifact prune --slug <slug> # or --sweep-orphans for abandoned uploads
19
+ scratchpad artifact pull <slug> [--revision <n>]
20
+ scratchpad artifact export | import <zip>
21
+ scratchpad artifact annotations <slug>
22
+ scratchpad artifact resolve <slug> <ordinal> [--dismiss|--reopen] [--reply <text>]
23
+ ```
24
+
25
+ Soft-deleted artifacts go to Trash via `artifact delete`.
26
+
27
+ ## Profiles
28
+
29
+ Profiles live at `$XDG_CONFIG_HOME/scratchpad/deployments.json` and may include Cloudflare Access
30
+ service-token fields for non-interactive CLI auth. See [deploy.md](deploy.md) for the Worker and
31
+ Access bypass rules, and [production-smoke.md](production-smoke.md) for an end-to-end checklist.
32
+
33
+ ## Uploads
34
+
35
+ Unlisted public file URLs (for example PR screenshots) on the same Worker as artifacts. Also
36
+ require a profile or `--url`.
37
+
38
+ ```
39
+ scratchpad upload <file...> [--name <name>] [--ttl-days <n>] [--profile <name>]
40
+ scratchpad upload <file> --resume <session-id> # repeat the original name/type/TTL options
41
+ scratchpad uploads list [--json]
42
+ scratchpad uploads delete <id>
43
+ ```
44
+
45
+ Most commands accept `--json` for machine-readable output.
46
+
47
+ ### Size limits and multipart
48
+
49
+ Files up to 1 GiB can be uploaded from the CLI or Files view. The existing single-request path
50
+ handles files up to 100 MiB; larger files stream through the Worker in 32 MiB parts. A public link
51
+ appears only after R2 verifies the whole file's SHA-256. Browser hashing reads bounded slices, and
52
+ text previews keep their separate 100 MiB ceiling.
53
+
54
+ Multipart sessions expire after 24 hours, or earlier if their `--ttl-days` deadline passes.
55
+ Requests retry transient failures without duplicating the link. If a part's storage result is
56
+ ambiguous, cancellation and a fresh upload are safer than replacing a possibly in-flight part.
57
+ Completion receipts let API callers retry completion with the same session ID after a lost
58
+ response. The CLI's `--resume` flag resumes one unchanged file with its original options and
59
+ authenticated identity. Browser uploads retry in-process; they do not persist a resumable session
60
+ across page reloads. `artifact prune --sweep-orphans` retries staging cleanup and removes old,
61
+ cleaned session records. See [the multipart upload design](adr/0009-worker-multipart-uploads.md).
62
+
63
+ ### Serving, TTL, and expiry
64
+
65
+ Uploaded bodies are served under `/f/*`. With `--ttl-days`, a link expires that many days after
66
+ registration, stops serving, and disappears from upload listings. Expiring links use
67
+ `Cache-Control: no-store` so subsequent requests recheck the expiration; links without a TTL
68
+ retain their one-year immutable caching policy. Expiration cannot revoke copies already downloaded
69
+ or responses cached under an older cache policy.
70
+
71
+ Expiration is logical, not immediate storage deletion. Run `artifact prune --sweep-orphans` to
72
+ remove expired upload records and reclaim unreferenced blobs after the orphan grace period. Blobs
73
+ shared by another upload or artifact remain available to that reference.
74
+
75
+ ## Deployment
76
+
77
+ Worker deploy steps are in [deploy.md](deploy.md); the production checklist is
78
+ [production-smoke.md](production-smoke.md). The Worker's web UI follows the
79
+ [design system](../DESIGN.md).
@@ -0,0 +1,97 @@
1
+ # Backlog sync with GitHub
2
+
3
+ Scratchpad can project a repository's GitHub issues and milestones to Markdown files with typed
4
+ YAML front matter, and push local edits back. This is optional: it needs `scratchpad init` and a
5
+ `scratchpad.config.ts` with `repo` set. The notes commands in [notes.md](notes.md) work without it.
6
+
7
+ ## Commands
8
+
9
+ ```
10
+ scratchpad init # scaffold scratchpad.config.ts + mount dirs + local store
11
+ scratchpad status # repo, mounts, pending pushes, open conflicts
12
+ scratchpad pull # GitHub -> Markdown files (incremental, by cursor)
13
+ scratchpad push # queued local changes -> GitHub
14
+ scratchpad sync # pull then push
15
+ scratchpad watch # daemon: turn local file edits into queued changes
16
+ scratchpad repair # resolve conflicts (interactive, or --take-local/--take-remote)
17
+ scratchpad delete # explicitly delete a mapped remote issue/milestone (--remote)
18
+ ```
19
+
20
+ ## Workflow
21
+
22
+ In a project directory run `scratchpad init`, edit `scratchpad.config.ts` and set `repo` to
23
+ `owner/name`, then pull:
24
+
25
+ ```sh
26
+ bunx @aryasaatvik/scratchpad init
27
+ bunx @aryasaatvik/scratchpad pull
28
+ ```
29
+
30
+ Make local edits under the configured `.scratchpad/backlog` mount, then preview and apply the
31
+ provider updates:
32
+
33
+ ```sh
34
+ bunx @aryasaatvik/scratchpad push --dry-run
35
+ bunx @aryasaatvik/scratchpad push
36
+ ```
37
+
38
+ The repository includes a basic example, `examples/basic`:
39
+
40
+ ```sh
41
+ cd examples/basic
42
+ bun run status
43
+ bun run plan
44
+ ```
45
+
46
+ `plan` runs `scratchpad push --dry-run`, so it shows the GitHub create operations Scratchpad would
47
+ perform without calling the provider.
48
+
49
+ ## Dry runs
50
+
51
+ `pull` / `push` / `sync` accept `--dry-run`, which prints the planned actions without mutating
52
+ files, the queue, or the provider.
53
+
54
+ ## Delete semantics
55
+
56
+ Deleting a tracked backlog file is non-destructive remotely: `push` closes the issue or archives
57
+ the milestone. Hard provider deletion is deliberately separate: `scratchpad delete --file <path>
58
+ --remote` deletes the mapped remote object, removes the local file, and removes the projection
59
+ mapping. Live remote deletes require `--yes` or an interactive TTY confirmation; `--dry-run`
60
+ reports the planned delete without mutating anything. Remote deletion is available only through
61
+ this explicit command, not through filesystem removal. See
62
+ [ADR 0007](adr/0007-explicit-remote-delete.md).
63
+
64
+ ## Backlog file contract
65
+
66
+ Backlog files follow the Scratchpad skill's contract: `status` is free text in the repository's
67
+ own vocabulary, the title is the first `# ` heading, and `milestone` / `depends_on` are paths
68
+ relative to the file that contains them, so issues and milestones may be nested in subfolders of
69
+ `backlog/issues/` and `backlog/milestones/`.
70
+
71
+ A status whose first word is in `backlog.closedStatuses` (default `done`, `complete(d)`,
72
+ `closed`, `merged`, `landed`, `delivered`, `cancel(l)ed`, `superseded`, `implemented`,
73
+ `historical`, `moved`) syncs as closed; anything else is open. Files in the older shape (`title`,
74
+ `state: open|closed` in front matter) still read, and are rewritten in the new shape on the next
75
+ sync.
76
+
77
+ `scratchpad backlog new` and `backlog validate | graph` create and check these files; see
78
+ [notes.md](notes.md#backlog-notes).
79
+
80
+ ## Archive mount
81
+
82
+ The backlog mount holds open work only. With an optional `archive` block, objects closed within
83
+ `closedWithinDays` project to a separate read-only mount (older closures project nowhere, and
84
+ aged-out files are pruned on the next `pull`). Editing or deleting an archived file does nothing;
85
+ only the backlog mount is writable. See [ADR 0005](adr/0005-closed-object-archive.md). Config
86
+ keys: [configuration.md](configuration.md#mounts).
87
+
88
+ ## Auth
89
+
90
+ Auth resolves `GITHUB_TOKEN` / `GH_TOKEN`, then `gh auth token`.
91
+
92
+ ## Local store
93
+
94
+ The SQLite store lives under `$XDG_STATE_HOME/scratchpad/<project-hash>/store.db`, never in the
95
+ repo. It is local durability (mappings, cursors, outbox, conflicts), not product truth: the
96
+ Markdown files and the provider are the system of record for backlog sync. Every checkout of a
97
+ project whose mounts resolve to the same files shares one store.