@aryasaatvik/scratchpad 0.6.1 → 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.
@@ -0,0 +1,127 @@
1
+ # Configuration
2
+
3
+ Most agent commands need no configuration. `scratchpad.config.ts` at the project root configures
4
+ layout, lifecycle, search, the classifier, and, for backlog sync, the repository and mounts.
5
+ `scratchpad init` scaffolds it. Keys are defined in
6
+ [`packages/core/src/config.ts`](../packages/core/src/config.ts).
7
+
8
+ ```ts
9
+ export default {
10
+ repo: "owner/name",
11
+ // Optional: each list replaces the corresponding built-in layout list.
12
+ layout: {
13
+ folders: ["backlog", "research", "maintenance", "artifacts"],
14
+ files: ["README.md", "STATE.md"],
15
+ },
16
+ lifecycle: {
17
+ artifacts: {
18
+ maxAgeDays: 14,
19
+ overrides: [{ path: "artifacts/sre/**", maxAgeDays: 30 }],
20
+ },
21
+ notes: { autoTrashConfidence: 0.9, minFreshDays: 7, estimatedCostPerCall: 0.001 },
22
+ protect: ["artifacts/keep/**"],
23
+ },
24
+ search: { embeddings: true },
25
+ classifier: { model: "typesafe/jev-1.14" },
26
+ backlog: { closedStatuses: ["done", "merged"] },
27
+ mounts: [
28
+ {
29
+ provider: "github",
30
+ issues: ".scratchpad/backlog/issues",
31
+ milestones: ".scratchpad/backlog/milestones",
32
+ // Optional: project recently-closed objects to a read-only archive.
33
+ archive: {
34
+ issues: ".scratchpad/archive/issues",
35
+ milestones: ".scratchpad/archive/milestones",
36
+ closedWithinDays: 7,
37
+ },
38
+ },
39
+ ],
40
+ };
41
+ ```
42
+
43
+ ## Keys
44
+
45
+ ### `repo`
46
+
47
+ Target repository as `owner/name`. Required by the schema; used by backlog sync.
48
+
49
+ ### `mounts`
50
+
51
+ Each mount has `provider: "github"`, `issues`, and `milestones` directories. The backlog mount
52
+ holds open work only. The optional `archive` block (`issues`, `milestones`, `closedWithinDays`)
53
+ projects objects closed within `closedWithinDays` to a separate read-only mount; the value must be
54
+ positive and is checked when the config loads. See [backlog-sync.md](backlog-sync.md#archive-mount)
55
+ and [ADR 0005](adr/0005-closed-object-archive.md).
56
+
57
+ ### `backlog`
58
+
59
+ `closedStatuses`: status tokens that sync as closed. See
60
+ [backlog-sync.md](backlog-sync.md#backlog-file-contract) for the defaults.
61
+
62
+ ### `layout`
63
+
64
+ `folders` and `files` list the allowed top-level entries of the notes root. An omitted list uses
65
+ the default: folders `backlog`, `research`, `reference`, `feedback`, `handoffs`, `decisions`,
66
+ `delivery`, `maintenance`, `artifacts`, `codemaps`; files `README.md`, `STATE.md`. A list given here replaces
67
+ the default list. `scratchpad doctor` reports drift; see [notes.md](notes.md#doctor).
68
+
69
+ ### `lifecycle`
70
+
71
+ - `artifacts.maxAgeDays`: artifact expiry window in days (greater than 0; default 14).
72
+ `artifacts.overrides` is a list of `{ path, maxAgeDays }` glob overrides; the last matching
73
+ override wins.
74
+ - `notes.autoTrashConfidence`: 0 to 1, default 0.9. Cached stale/superseded verdicts at or above
75
+ it are auto-trashed by `sweep --apply`.
76
+ - `notes.minFreshDays`: at least 0, default 7. Recently updated notes are protected.
77
+ - `notes.estimatedCostPerCall`: at least 0, USD, default 0.001. Fallback when OpenRouter reports
78
+ no cost; labeled an estimate.
79
+ - `protect`: globs of notes and artifacts that `sweep` never removes. Manual `archive` does not
80
+ check these globs.
81
+
82
+ Behavior: [lifecycle.md](lifecycle.md).
83
+
84
+ ### `search`
85
+
86
+ `embeddings: false` opts out of hybrid search even when an OpenRouter key is present. Config
87
+ discovery walks upward, so ancestor opt-outs apply too. See [search.md](search.md).
88
+
89
+ ### `classifier`
90
+
91
+ `model` names an OpenRouter Decisions model; `"none"` disables classification. See
92
+ [feedback.md](feedback.md#classifier).
93
+
94
+ ## Environment variables
95
+
96
+ | Variable | Purpose |
97
+ | ------------------------------- | ---------------------------------------------------------- |
98
+ | `GITHUB_TOKEN`, `GH_TOKEN` | GitHub auth, checked in that order before `gh auth token`. |
99
+ | `SCRATCHPAD_OPENROUTER_API_KEY` | OpenRouter key; overrides the secrets file. |
100
+ | `SCRATCHPAD_CLASSIFIER` | Classifier model override; `none` disables it. |
101
+ | `SCRATCHPAD_GLOBAL_HOME` | Host-wide notes home; default `~/.scratchpad`. |
102
+ | `XDG_DATA_HOME` | Fallback notes root `scratchpad/projects/<project-id>`. |
103
+ | `XDG_STATE_HOME` | State store and search index; default `~/.local/state`. |
104
+ | `XDG_CONFIG_HOME` | Secrets and deployment profiles; default `~/.config`. |
105
+
106
+ An empty `XDG_STATE_HOME` or `XDG_DATA_HOME` is treated as unset. `XDG_CONFIG_HOME` must be an
107
+ absolute path; a relative value is ignored.
108
+
109
+ ## Secrets
110
+
111
+ The OpenRouter key is shared by classification, note lifecycle review, and search embeddings.
112
+ Store it in `$XDG_CONFIG_HOME/scratchpad/secrets/openrouter-api-key` (default
113
+ `~/.config/scratchpad/secrets/openrouter-api-key`), or set `SCRATCHPAD_OPENROUTER_API_KEY` to
114
+ override it. Keep the secrets directory private (`0700`) and the key file readable only by its
115
+ owner (`0600`). An unreadable or empty key file is an error.
116
+
117
+ Deployment profiles for hosted artifacts live at `$XDG_CONFIG_HOME/scratchpad/deployments.json`;
118
+ see [artifacts.md](artifacts.md).
119
+
120
+ ## Where state lives
121
+
122
+ - Notes root: the checkout's `.scratchpad`, else the primary checkout's, else
123
+ `$XDG_DATA_HOME/scratchpad/projects/<project-id>`. See [notes.md](notes.md).
124
+ - Sync store: `$XDG_STATE_HOME/scratchpad/<project-hash>/store.db`, never in the repo. It holds
125
+ mappings, cursors, outbox, conflicts, and cached review verdicts.
126
+ - Search index: `$XDG_STATE_HOME/scratchpad/<project-hash>/search/`, derived and rebuildable.
127
+ - Global feedback: `~/.scratchpad` or `SCRATCHPAD_GLOBAL_HOME`.
package/docs/deploy.md ADDED
@@ -0,0 +1,75 @@
1
+ # Deploy
2
+
3
+ Scratchpad ships from a local machine. There is no CI/CD: checks, the worker
4
+ deploy, and the CLI release all run from `bun` scripts you invoke yourself.
5
+
6
+ ## Worker (`scratchpad.arya.sh`)
7
+
8
+ The `apps/worker` Cloudflare Worker hosts the artifact surfaces. Deploy it with
9
+ Wrangler from your own authenticated session:
10
+
11
+ ```sh
12
+ bun run check # gate locally — nothing else does
13
+ bun run deploy:dry-run # build + resolve bindings without uploading
14
+ bun run deploy # vite build + wrangler deploy
15
+ ```
16
+
17
+ `wrangler` authenticates through your `CLOUDFLARE_API_TOKEN` or an interactive
18
+ `wrangler login`; the deploy targets the account that owns the
19
+ `scratchpad` Worker, `scratchpad-artifacts` R2 bucket, and `ARTIFACT_AGENT`
20
+ Durable Object.
21
+
22
+ ### Secrets
23
+
24
+ Sequence fences read GitHub as the `scratchpad-app` GitHub App. Set its two
25
+ secrets once per environment; they are not in `wrangler.jsonc` and never leave
26
+ your machine:
27
+
28
+ ```sh
29
+ cd apps/worker
30
+ wrangler secret put GITHUB_APP_ID # 4298378
31
+ wrangler secret put GITHUB_APP_PRIVATE_KEY # the PKCS#8 PEM
32
+ ```
33
+
34
+ Dev reads the same values from `apps/worker/.env` (git-ignored). Do not create
35
+ `apps/worker/.dev.vars`: when it exists, Wrangler ignores every `.env` file and
36
+ GitHub-backed dev loses its credentials. Writing an env file while the Vite dev
37
+ server runs restarts workerd and can leave every route returning 500; change env
38
+ files together with a deliberate dev-server restart.
39
+
40
+ For local renderer work, `.env` also sets
41
+ `RENDERER_ORIGIN=http://html.renderer.localhost:5173` and
42
+ `RENDERER_HOST_SUFFIX=renderer.localhost`, so the same dev server serves the
43
+ isolated renderer. Without them, dev falls back to the production renderer from
44
+ `wrangler.jsonc`, and renderer changes are visible only after a renderer deploy.
45
+ `curl http://html.renderer.localhost:5173/` should return the bootstrap.
46
+
47
+ Grant the app
48
+ access to a repository's owner by installing github.com/apps/scratchpad-app on
49
+ that account — no secret changes when the set of charted repositories grows.
50
+
51
+ ### Cloudflare Access bypass for public routes
52
+
53
+ The Worker enforces its own auth in code, but the Cloudflare Access application
54
+ in front of `scratchpad.arya.sh` must let the public route families through or
55
+ anonymous fetches (including GitHub's camo image proxy) hit the Access login
56
+ wall. The Access app needs bypass rules covering:
57
+
58
+ - `/s/*` — shared artifact pages and their assets
59
+ - `/f/*` — unlisted public file uploads
60
+
61
+ This is dashboard (or API) state, not code: adding a new public route family
62
+ means adding a matching bypass rule before it works for anonymous callers.
63
+
64
+ ## CLI (`@aryasaatvik/scratchpad`)
65
+
66
+ Tegami owns the changelog, version PR, npm publish, `v<version>` tag, GitHub
67
+ Release, and the compiled release artifacts. Run it locally:
68
+
69
+ ```sh
70
+ bun run tegami pr preview # preview the version-package PR
71
+ bun run tegami pr # open/update it
72
+ bun run release # after the version PR merges: publish + tag + release
73
+ ```
74
+
75
+ See [release.md](release.md) for the npm auth and compiled-binary details.
@@ -0,0 +1,71 @@
1
+ # Instruction feedback and routing
2
+
3
+ Agents record corrections and friction as feedback notes. The CLI writes them deterministically and
4
+ may classify them with an optional decision model.
5
+
6
+ ## Commands
7
+
8
+ ```
9
+ scratchpad feedback new "<text>" [--global] [--harness <h>] [--model <m>] [--session <id>]
10
+ scratchpad feedback normalize [--global] [--dry-run] [--json]
11
+ scratchpad feedback review [--global] [--classify] [--json]
12
+ scratchpad feedback list [--global] [--status <s>] [--disposition <d>]... [--all]
13
+ scratchpad feedback resolve <id|file|path> --disposition <d> --review <name|path> [--evidence <e>]...
14
+ scratchpad route "<correction>" [--write] [--json]
15
+ ```
16
+
17
+ - `feedback new` writes a feedback file under the notes root's `feedback/`; `--slug` overrides the
18
+ file-name slug derived from the text.
19
+ - `feedback normalize` adopts legacy feedback without changing bodies; preview with
20
+ `feedback normalize --global --dry-run --json`.
21
+ - `feedback review` lists feedback with no disposition or an open disposition; `--classify`
22
+ classifies unclassified entries first and needs a classifier.
23
+ - `feedback list` filters by status (`new`, `review`, `classified`) and disposition (repeatable);
24
+ `--all` includes dismissed, installed, and verified occurrences.
25
+ - `feedback resolve` records a review disposition (`open`, `deferred`, `dismissed`, `source-fixed`,
26
+ `installed`, `verified`) on one occurrence. The occurrence is the id after the last `-` in the
27
+ file name, the file name with or without `.md`, or a path. `--review` names the review record in
28
+ `feedback/reviews/` (this scope's, then the global one) or a path; `--evidence` takes a commit,
29
+ PR URL, or path and is repeatable.
30
+ - `route` suggests which instruction layer a correction belongs to; `--write` also records it as a
31
+ feedback file.
32
+
33
+ ## Global feedback home
34
+
35
+ `--global` feedback lives in `~/.scratchpad` (override with `SCRATCHPAD_GLOBAL_HOME`). Use it for
36
+ corrections that apply across projects. `scratchpad search --global` includes its `feedback/`
37
+ folder; see [search.md](search.md).
38
+
39
+ ## Classifier
40
+
41
+ The classifier uses OpenRouter's Decisions API through `@effect/ai-openrouter`, with the pinned
42
+ default model `typesafe/jev-1.14`. Users may select the moving `~typesafe/jev-latest` alias through
43
+ `classifier.model`. Decision models are listed by
44
+ `GET https://openrouter.ai/api/v1/models?output_modalities=decisions`; chat-completion model IDs
45
+ are a separate catalog and are not valid here.
46
+
47
+ Model selection, in order: `SCRATCHPAD_CLASSIFIER`, then `classifier.model` in
48
+ `scratchpad.config.ts`, then the pinned default. `SCRATCHPAD_CLASSIFIER=none` or
49
+ `classifier.model: "none"` disables it. Model overrides name OpenRouter model IDs.
50
+
51
+ Classification and search embeddings share one OpenRouter key. Store it in
52
+ `$XDG_CONFIG_HOME/scratchpad/secrets/openrouter-api-key` (default
53
+ `~/.config/scratchpad/secrets/openrouter-api-key`), or set `SCRATCHPAD_OPENROUTER_API_KEY` to
54
+ override it. Keep the secrets directory private (`0700`) and the key file readable only by its
55
+ owner (`0600`). Relative `XDG_CONFIG_HOME` values are ignored. See
56
+ [configuration.md](configuration.md#secrets).
57
+
58
+ The same decision model also reviews note lifecycle; see [lifecycle.md](lifecycle.md) and
59
+ [ADR 0010](adr/0010-openrouter-decisions-and-note-lifecycle.md).
60
+
61
+ ## Redaction
62
+
63
+ Feedback is redacted before it is sent for classification: tokens, keys, private keys, and email
64
+ addresses never leave the process. Redaction is best-effort pattern matching biased toward
65
+ over-redacting, so feedback text should not contain customer data.
66
+
67
+ ## Writes first
68
+
69
+ Feedback files are written first, and classifier failures never block or undo those writes. A
70
+ timeout, provider error, or low confidence yields a warning or the review bucket, never a failed
71
+ command. Without a key, or with the classifier disabled, every command still works.
@@ -0,0 +1,126 @@
1
+ # Note lifecycle: review, sweep, archive
2
+
3
+ Notes accumulate. The lifecycle commands classify them against repository evidence and retire the
4
+ stale ones to the operating system's Trash, where they stay recoverable.
5
+
6
+ ```
7
+ scratchpad archive <paths...> --reason "<why>" # move notes or directories to the OS Trash
8
+ scratchpad review [paths...] [--apply] [--json] [--limit 100] # classify notes; --apply writes metadata
9
+ scratchpad sweep [--apply] [--json] # preview expired artifacts; --apply moves to Trash
10
+ ```
11
+
12
+ `archive` moves the given paths to Trash immediately; it has no preview. `sweep --apply` moves
13
+ files to Trash and `review --apply` writes lifecycle front matter; without `--apply` both only
14
+ report. Run `review` and `sweep` without `--apply` first.
15
+
16
+ ## Archive
17
+
18
+ `archive` retires local notes to the operating system's Trash and appends receipts to
19
+ `maintenance/trash-log.md`. It no longer creates dated directories under `archive/`. Paths are
20
+ relative to the notes root (omit the `.scratchpad/` prefix) and may be files or directories.
21
+ `--reason` is recorded in the receipt.
22
+
23
+ This local-note lifecycle is separate from the optional read-only GitHub archive mount described in
24
+ [backlog-sync.md](backlog-sync.md#archive-mount).
25
+
26
+ ## Trash and receipts
27
+
28
+ Trash uses `/usr/bin/trash` on macOS and `gio trash` on Linux; other platforms report an
29
+ unsupported-platform error. Each move first writes and flushes a `pending` receipt, then appends
30
+ `trashed`, `failed`, or `skipped-changed` with the same id. An unmatched pending receipt means the
31
+ operation needs reconciliation against the source and OS Trash; do not automatically retry it. A
32
+ later failure does not undo earlier moves.
33
+
34
+ ## Sweep
35
+
36
+ `sweep` previews expired artifacts with byte totals; `--apply` moves eligible entries to Trash and
37
+ records receipts. Markdown and HTML files are notes, so artifact expiry does not remove them.
38
+ Existing `archive/` contents may contain expired artifacts. Unwritable entries are reported as
39
+ refused, allowing other eligible entries to proceed.
40
+
41
+ Artifact windows use mtime (strictly older than the window); the last matching override wins.
42
+ Relative Markdown/HTML links (including linked directories) and `lifecycle.protect` globs protect
43
+ artifacts. Symlinks are not traversed or swept. Windows come from `lifecycle.artifacts`; see
44
+ [configuration.md](configuration.md#lifecycle).
45
+
46
+ `sweep` also consumes cached note verdicts, as described under [Review](#review). It never calls
47
+ the model.
48
+
49
+ ### Sweep JSON, version 1
50
+
51
+ `sweep --json` emits version 1 of the report: `version: 1`, `apply`, `groups`, `totalBytes`,
52
+ `refused`, `warningCount`, and `trashed`. Each group contains `source`, `entries`, and `bytes`;
53
+ entries contain `path`, `bytes`, `reason`, and `source`. Refused entries contain `path` and
54
+ `reason`; `trashed` contains the entries successfully moved by an apply run. Paths are relative to
55
+ the real notes root, bytes are file sizes, and `totalBytes` sums eligible entries (excluding
56
+ refusals). Groups are ordered by source and entries by path. Dry runs have an empty `trashed`
57
+ array. Refusals produce warnings and exit 0.
58
+
59
+ ## Review
60
+
61
+ Note lifecycle review uses the same OpenRouter decision model as routing; see
62
+ [feedback.md](feedback.md#classifier). Paths are relative to the resolved notes root. The dry run
63
+ reports kind, verdict (`fresh`, `stale`, `superseded`, `expired`), confidence, repository evidence,
64
+ cache hits, calls, and provider token usage. `review --apply` updates only lifecycle front matter,
65
+ preserving unknown YAML and body bytes. Backlog and feedback retain their own schemas.
66
+
67
+ ### Scope
68
+
69
+ Only regular Markdown/HTML files inside the notes root can be reviewed. HTML is dry-run only;
70
+ `--apply` accepts Markdown and uses a locked, checked atomic replacement. Configured issue,
71
+ milestone and archive-projection mounts are excluded by physical path, wherever they live.
72
+ Review-only metadata writes preserve mtime, so reviewing an old note does not make it newly fresh.
73
+
74
+ ### Confidence and probabilities
75
+
76
+ Confidence is exactly the Decisions API probability of the chosen lifecycle label, independent of
77
+ kind probability and the provider's separate confidence metric. Full per-label probabilities are
78
+ returned in `notes[].reviewed.probabilities` and cached with the review. Question revisions
79
+ invalidate old verdicts. See [ADR 0010](adr/0010-openrouter-decisions-and-note-lifecycle.md).
80
+
81
+ ### Cache
82
+
83
+ Verdicts are cached in the project state database by content, evidence and model. Age changes or
84
+ repository changes invalidate the cache. Declared kind corrections invalidate the cache; generated
85
+ review metadata does not. Cache hits incur no new model cost.
86
+
87
+ ### Legacy metadata and redaction
88
+
89
+ Existing front matter remains reviewable: unrecognized lifecycle values are preserved verbatim,
90
+ treated as absent in the normalized view, and supplied as field-local lifecycle evidence. Only
91
+ lifecycle keys enter that fallback; unrelated front matter is never copied into it. Recognized
92
+ lifecycle dates use ISO dates or timestamps.
93
+
94
+ Sensitive key values, including block scalars, are masked structurally before model serialization.
95
+ Local reference checks use the complete original bytes, including YAML comments and non-mapping
96
+ headers. The model receives a separate redacted lifecycle projection; local inbound links still
97
+ protect targets on cached reviews. Non-finite and cyclic legacy values use JSON-safe
98
+ representations; their original YAML is preserved. `metadataWarnings` identifies each field and
99
+ redacted value; only unparseable YAML is skipped.
100
+
101
+ ### Cost accounting
102
+
103
+ OpenRouter-reported cost is used when available, including zero-cost responses. Missing costs fall
104
+ back to calls x `estimatedCostPerCall` in USD and are labeled estimates; the default is a
105
+ configurable budget placeholder, not a provider quote. Mixed runs report the measured subtotal and
106
+ number of estimated calls separately.
107
+
108
+ ### What sweep auto-trashes
109
+
110
+ `sweep` consumes only current cached stale/superseded verdicts at or above `autoTrashConfidence`
111
+ (default 0.9). It protects README/STATE indexes, backlog/feedback, recently updated notes
112
+ (`minFreshDays`, default 7), notes linked from a non-stale note, and configured protect globs.
113
+ Expired model verdicts alone do not auto-trash notes. With the classifier disabled, review exits
114
+ successfully with a clear message and sweep handles artifacts only.
115
+
116
+ ## Lifecycle config
117
+
118
+ ```ts
119
+ lifecycle: {
120
+ notes: { autoTrashConfidence: 0.9, minFreshDays: 7, estimatedCostPerCall: 0.001 },
121
+ protect: ["decisions/**"],
122
+ }
123
+ ```
124
+
125
+ The full key reference is in [configuration.md](configuration.md#lifecycle). The decision record
126
+ is [ADR 0011](adr/0011-trash-instead-of-archive-folders.md).
package/docs/notes.md ADDED
@@ -0,0 +1,83 @@
1
+ # Notes root and layout
2
+
3
+ Scratchpad keeps a project's working memory as Markdown files in one directory, the notes root.
4
+ These commands need no `scratchpad.config.ts`.
5
+
6
+ ## Notes root resolution
7
+
8
+ The notes root of a project is, in order:
9
+
10
+ 1. the checkout's `.scratchpad`,
11
+ 2. else the primary checkout's `.scratchpad`,
12
+ 3. else `$XDG_DATA_HOME/scratchpad/projects/<project-id>`.
13
+
14
+ The project id is the origin remote, for example `github.com/owner/repo`. Outside a Git repository
15
+ the project id is local to the directory.
16
+
17
+ Every checkout of a project whose mounts resolve to the same files (for example `wt` worktrees
18
+ linking `.scratchpad` to the primary checkout) shares one notes root and one local store. Agents
19
+ running in different worktrees therefore read and write the same notes.
20
+
21
+ ## Commands
22
+
23
+ ```
24
+ scratchpad path [--global] [--real] # print the notes root; --real resolves symlinks
25
+ scratchpad doctor # project id, layout drift, store, token
26
+ scratchpad skills list | path # skills embedded in this CLI
27
+ scratchpad skills get <name> [--full | --ref <reference>]
28
+ scratchpad backlog new <issue|milestone> "<title>" [--milestone <slug>] [--depends-on <path>]
29
+ scratchpad backlog validate | graph # decode, check fields, links and cycles; show the tree
30
+ ```
31
+
32
+ ### `path`
33
+
34
+ `path` keeps the selected notes path by default, including a worktree's `.scratchpad` symlink.
35
+ Use `path --real` when an agent needs the physical storage path for writes. It preserves the same
36
+ plain-text or JSON output shape, works with `--global`, and fails if the selected root is missing
37
+ or inaccessible; it never creates the directory.
38
+
39
+ `--global` selects the host-wide notes home instead: `~/.scratchpad`, overridable with
40
+ `SCRATCHPAD_GLOBAL_HOME`. Global instruction feedback lives there; see [feedback.md](feedback.md).
41
+
42
+ ### `doctor`
43
+
44
+ `doctor` checks the notes root's top-level entries against `layout` in `scratchpad.config.ts`.
45
+ It reports unlisted folders and loose files, without moving them or inspecting nested layout.
46
+ The JSON report adds `layout` with `folders`, `files`, `rootExists`, `outOfLayoutFolders`, and
47
+ `looseFiles`. A missing notes root is reported without creating it. Omitted lists use the defaults:
48
+
49
+ - Folders: `backlog`, `research`, `reference`, `feedback`, `handoffs`, `decisions`, `delivery`,
50
+ `maintenance`, `artifacts`, `codemaps`.
51
+ - Files: `README.md`, `STATE.md`.
52
+
53
+ A list given in config replaces the corresponding default list; see
54
+ [configuration.md](configuration.md#layout).
55
+
56
+ `doctor` also reports the project id, notes root and its source, whether a config was found, the
57
+ state store, the selected classifier model and whether it is enabled, and GitHub auth availability.
58
+
59
+ ### Skills
60
+
61
+ `scratchpad skills get scratchpad` prints the agent skill that drives these commands. Its source is
62
+ [`packages/cli/skill-data/scratchpad/`](../packages/cli/skill-data/scratchpad/). Skills are embedded
63
+ in the CLI, so the instructions an agent reads match the CLI version it runs. The `codemap` skill
64
+ is printed with `scratchpad skills get codemap`; see [codemaps.md](codemaps.md).
65
+
66
+ ### Backlog notes
67
+
68
+ `backlog new` creates an issue or milestone file under the notes root's `backlog/`. `backlog
69
+ validate` decodes the files and checks fields, links, and cycles; `backlog graph` shows the tree.
70
+ Their file contract and the GitHub sync built on it are described in
71
+ [backlog-sync.md](backlog-sync.md).
72
+
73
+ ## Store sharing
74
+
75
+ The local SQLite store is derived state, kept under `$XDG_STATE_HOME/scratchpad/<project-hash>/`
76
+ and never in the repository; see [configuration.md](configuration.md#where-state-lives).
77
+ Checkouts that resolve to the same files share it.
78
+
79
+ ## Related
80
+
81
+ - Local note retirement: [lifecycle.md](lifecycle.md)
82
+ - Note search: [search.md](search.md)
83
+ - Instruction feedback: [feedback.md](feedback.md)
@@ -0,0 +1,75 @@
1
+ # Production Smoke
2
+
3
+ This is an operator-driven Chrome/Codex smoke for `https://scratchpad.arya.sh`. It is not an
4
+ automated deployment or rollback procedure. Do not start until all of these are confirmed:
5
+
6
+ - the intended Worker deployment is active at `scratchpad.arya.sh`;
7
+ - Cloudflare Access credentials work for both Chrome and the CLI profile;
8
+ - wildcard renderer DNS resolves to the isolated HTML renderer;
9
+ - the `ARTIFACT_AGENT` Durable Object migration and `ARTIFACTS` R2 binding exist.
10
+
11
+ Production checkpoint (2026-07-16): those prerequisites are live. Worker deployment
12
+ `e93ed81d-5530-4b0b-810c-97634616ec15`, built from `main` at `034f214`, passed focused Chrome and
13
+ CLI smoke for catalog/Trash, Markdown review, HTML element anchors, revision comparison, the mobile
14
+ review drawer, anonymous sharing and revocation, CSP boundaries, and exact-slug pruning. This is a
15
+ checkpoint for that deployment, not a substitute for rerunning the complete checklist below after
16
+ future changes.
17
+
18
+ ## Create unique fixtures
19
+
20
+ ```sh
21
+ bun run scripts/smoke-fixtures.ts
22
+ ```
23
+
24
+ The command prints the run directory and two unique slugs. Keep its `evidence.json` current. Store
25
+ screenshots, response bodies, CLI stderr, and other failure details under its `diagnostics/`
26
+ directory. Never reuse slugs from an earlier run.
27
+
28
+ Record before testing:
29
+
30
+ - Worker deployment ID and application/package version;
31
+ - exact CLI commit or standalone binary version;
32
+ - Chrome version and Access identity;
33
+ - every command, outcome, retained remote artifact, and cleanup attempt.
34
+
35
+ ## CLI and browser checklist
36
+
37
+ Use the configured production profile and the generated paths/slugs below. Append exact commands to
38
+ `evidence.json`; do not put Access secrets in evidence.
39
+
40
+ 1. Push `artifact.md` with `--review --wait` in one terminal. Open its authenticated review URL in
41
+ Chrome, add a general note and an anchored note over the unique anchor phrase, then disconnect
42
+ and restart the waiting CLI before completing the review. Confirm the reconnected wait returns
43
+ the same closed review exactly once.
44
+ 2. Push `artifact.html` with `--review`. Open it through the wildcard renderer host. Confirm the
45
+ iframe is isolated, the unique DOM text renders, and an element-anchored review survives reload
46
+ before completing the review.
47
+ 3. Run `artifact show` and `artifact list` for both fixtures. Confirm titles, formats, revisions,
48
+ source paths, visibility, and review history match the pushed fixtures.
49
+ 4. Share each artifact. Open the public URL in a signed-out/incognito Chrome window, verify the
50
+ content and security headers, then unshare it and confirm the same public request is denied.
51
+ 5. Pull the Markdown and HTML revisions to a new empty local directory and compare their SHA-256
52
+ hashes with the push results.
53
+ 6. Export the production workspace to a schema-1 ZIP. Keep the ZIP digest in evidence. Import it
54
+ into a newly started, disposable local Worker state and confirm catalog/review/visibility/hash
55
+ parity. An import against production itself must fail because the target is nonempty.
56
+ 7. Move both unique fixtures to Trash. Prune each by exact slug only after every earlier check has
57
+ passed. Confirm neither catalog, Trash, nor R2-backed asset URLs retain the fixtures.
58
+
59
+ ## Failure and cleanup contract
60
+
61
+ On any failure, stop the sequence. Do not automatically roll back the Worker, prune the fixture, or
62
+ rewrite evidence. Preserve:
63
+
64
+ - the failed command's stdout, stderr, exit code, and timestamp;
65
+ - Chrome screenshots and relevant Network/Console details;
66
+ - the archive or pulled files involved in the failure;
67
+ - every still-live slug/revision/share URL in `retainedArtifacts`.
68
+
69
+ Set `status` to `failed`, leave `cleanup.completed` false, and hand the run directory to the
70
+ operator investigating the failure. After an investigation, cleanup remains explicit and must be
71
+ recorded.
72
+
73
+ For a successful run, set every outcome to `passed`, record the two exact prune responses, set
74
+ `cleanup.attempted` and `cleanup.completed` true, set `status` to `passed`, and record
75
+ `operator.completedAt`. Keep the evidence directory; only the unique remote fixtures are pruned.
package/docs/release.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Release
2
2
 
3
- `@aryasaatvik/scratchpad` is a Bun-first npm package. The current version is
4
- `0.2.1`.
3
+ `@aryasaatvik/scratchpad` is a Bun-first npm package. The current version is the `version` in
4
+ [`package.json`](../package.json).
5
5
 
6
6
  ## Preflight and dry-run
7
7
 
@@ -39,7 +39,7 @@ binary. The compiled binaries and npm `dist/scratchpad.js` remain independent su
39
39
  Recommended repository description:
40
40
 
41
41
  ```text
42
- Local-first GitHub issue and milestone tracking through Markdown files.
42
+ 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.
43
43
  ```
44
44
 
45
45
  Recommended topics:
package/docs/search.md ADDED
@@ -0,0 +1,48 @@
1
+ # Search
2
+
3
+ `scratchpad search` finds project notes with hybrid text and vector retrieval over a derived,
4
+ rebuildable index.
5
+
6
+ ```sh
7
+ scratchpad index --rebuild --json
8
+ scratchpad search "deployment decision" --limit 10 --kind decision --json
9
+ scratchpad search "instruction feedback" --global
10
+ ```
11
+
12
+ ## Behavior
13
+
14
+ Search scans the resolved project's Markdown notes before every query, including edits and
15
+ removals. `--kind` matches front matter `kind` exactly; notes without a kind are excluded when
16
+ filtering. Results include the physical path, heading, snippet and reciprocal rank fusion score.
17
+ `--global` also includes `feedback/` under `SCRATCHPAD_GLOBAL_HOME` (default `~/.scratchpad`).
18
+
19
+ ## FTS-only fallback
20
+
21
+ Without credentials, commands use SQLite FTS5 and print a notice on stderr (also included in
22
+ JSON). Ordinary FTS-only search does not load native bindings.
23
+
24
+ ## Embeddings
25
+
26
+ Hybrid search shares the classifier's OpenRouter key: set `SCRATCHPAD_OPENROUTER_API_KEY` or put
27
+ it in `$XDG_CONFIG_HOME/scratchpad/secrets/openrouter-api-key` (default `~/.config/...`), with
28
+ mode `0600`. Hybrid indexing sends note title, heading and chunk text to OpenRouter's
29
+ `qwen/qwen3-embedding-8b` model at 1024 dimensions; queries are sent there too.
30
+
31
+ To opt out even when a key is present, set `search: { embeddings: false }` in
32
+ `scratchpad.config.ts`. Config discovery walks upward, so ancestor opt-outs apply too.
33
+
34
+ ## Index location
35
+
36
+ The rebuildable index lives in `$XDG_STATE_HOME/scratchpad/<project hash>/search/`, beside the
37
+ project sync database. Private (`0700`) caches are separated by the selected physical notes roots,
38
+ so toggling `--global` or switching worktrees retains each scope's index. `index --rebuild`
39
+ recreates that scope's text and vector stores, including corrupt stores.
40
+
41
+ ## Concurrency and platform
42
+
43
+ A concurrent refresh or native writer returns a busy error; retry after the other operation
44
+ exits. Rebuilding a scope with existing vector state briefly loads zvec to check that no native
45
+ reader or writer has it open, even without a key. Linux x64 vector search requires an AVX2-capable
46
+ CPU.
47
+
48
+ See [ADR 0012](adr/0012-local-hybrid-search.md) for the design.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aryasaatvik/scratchpad",
3
- "version": "0.6.1",
4
- "description": "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
3
+ "version": "0.6.2",
4
+ "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.",
5
5
  "keywords": [
6
6
  "bun",
7
7
  "cli",
@@ -40,8 +40,7 @@
40
40
  "LICENSE",
41
41
  "CHANGELOG.md",
42
42
  "SECURITY.md",
43
- "docs/adr",
44
- "docs/release.md"
43
+ "docs"
45
44
  ],
46
45
  "type": "module",
47
46
  "publishConfig": {