dsh-snip 0.0.1 → 0.1.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,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0
4
+
5
+ - Implement `SnipService` with `add`, `list`, `search`, `get`, `forget` and
6
+ `clear`, plus stable `clipboard://<id>` handles.
7
+ - Exclude secrets by default: `sk-...`, `ghp_...` / `github_pat_...`,
8
+ `AKIA...` / `ASIA...`, PEM/PGP private keys, `password=...`, API keys,
9
+ bearer tokens, JWTs and common provider tokens. Matching input is never
10
+ stored; only `[redacted:<reason>]` is kept and `redacted` is `true`.
11
+ - Add a 24-hour default TTL, a 200-entry cap and a 64 KiB per-entry cap with
12
+ automatic expiry and oldest-first eviction.
13
+ - Add optional atomic JSON snapshots through `stateFile` (temporary file plus
14
+ `rename`, mode `0600`, re-screened on load).
15
+ - Provide `ctx.snip` and six plain-object agent tools: `snip_add`,
16
+ `snip_search`, `snip_get`, `snip_list`, `snip_forget`, `snip_clear`.
17
+ - 0.1.0 is a ledger only: no OS clipboard polling, no background capture, no
18
+ network access and no encryption yet.
19
+ - Add `node --test` coverage for CRUD, handles, redaction, TTL/eviction,
20
+ persistence and tool registration.
21
+
3
22
  ## 0.0.1
4
23
 
5
24
  - Reserve the `dsh-snip` package name.
package/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # Snip · `dsh-snip`
2
2
 
3
- > Encrypted, searchable clipboard ledger for DeepSeek Harness with secret exclusion and agent handles.
3
+ > A local-first clipboard ledger for DeepSeek Harness with secret exclusion and
4
+ > `clipboard://` agent handles.
4
5
 
5
- **Status: 0.0.1 name reservation.** The working design lives in the
6
- [dsh-os design notes](https://github.com/PerryLink/dsh-os#readme). A functional MVP is planned for 0.1.0.
6
+ **Status: 0.1.0 (MVP). A ledger, not a background listener.** Snip records a
7
+ clipping only when a caller explicitly invokes `snip.add(...)` or the `snip_add`
8
+ agent tool. 0.1.0 has no OS clipboard polling, no `snip_capture`, no network
9
+ access and no encryption yet. Secret-looking text is excluded by default.
10
+ Everything stays on this machine: entries live in process memory, plus an
11
+ optional local JSON snapshot when `stateFile` is configured.
12
+
13
+ In one sentence: **0.1.0 is a ledger, not a background listener; it excludes
14
+ secrets by default and stores clippings locally.**
7
15
 
8
16
  **Not affiliated with DeepSeek.** DeepSeek and DeepSeek Harness are trademarks
9
17
  of their respective owners.
@@ -14,8 +22,88 @@ of their respective owners.
14
22
  dsh plugin --profile web add dsh-snip
15
23
  ```
16
24
 
17
- ## Design
25
+ The bundle patch mounts the plugin and provides `ctx.snip`.
26
+
27
+ ## Host service
28
+
29
+ ```js
30
+ const snip = ctx.get('snip')
31
+
32
+ const clip = snip.add({ text: 'SELECT * FROM users', sourceApp: 'psql' })
33
+ // { id, handle: 'clipboard://<id>', kind: 'text', preview, createdAt, expiresAt, redacted }
34
+
35
+ snip.get(clip.handle).text // original text, or '[redacted:<reason>]'
36
+ snip.search('select') // newest-first summaries
37
+ snip.list({ kind: 'text', limit: 20 })
38
+ snip.forget(clip.id) // true when it existed
39
+ snip.clear() // number removed
40
+ ```
41
+
42
+ `add()` accepts `{ text, kind = 'text', sourceApp = 'unknown', sensitivity = 'normal' }`.
43
+ Supported kinds are `text`, `html`, `link` and `color`; sensitivities are
44
+ `normal`, `sensitive` and `secret` (`secret` always redacts). Handles are
45
+ `clipboard://<id>` and are accepted anywhere an id is accepted. `get()` returns
46
+ `null` for an unknown, expired or forgotten id.
47
+
48
+ ## Agent tools
49
+
50
+ The plugin registers six plain-object tools (no `@deepseek-ai/dsh-tools`
51
+ dependency):
52
+
53
+ | Tool | Arguments | Result |
54
+ | --- | --- | --- |
55
+ | `snip_add` | `text` (required), `kind`, `sourceApp`, `sensitivity` | `{ id, handle, kind, preview, createdAt, expiresAt, redacted }` |
56
+ | `snip_search` | `query` (required), `limit` | `{ query, entries }` |
57
+ | `snip_get` | `id` (id or `clipboard://` handle) | full entry including `text` |
58
+ | `snip_list` | `kind`, `limit` | `{ entries }` |
59
+ | `snip_forget` | `id` | `{ ok, removed }` |
60
+ | `snip_clear` | none | `{ removed }` |
61
+
62
+ `entries` are newest-first summaries (`id`, `handle`, `kind`, `preview`,
63
+ `createdAt`, `expiresAt`, `redacted`). `snip_get` returns the full text, which
64
+ then becomes part of the append-only conversation session log — read only what
65
+ you need.
66
+
67
+ ## Configuration
68
+
69
+ | Option | Default | Meaning |
70
+ | --- | --- | --- |
71
+ | `excludeSecrets` | `true` | Detect secrets and store only the redaction marker. |
72
+ | `ttlMs` | `86400000` (24 h) | Entry lifetime; expired entries are swept on access. |
73
+ | `maxEntries` | `200` | Oldest entries are evicted when the cap is exceeded. |
74
+ | `maxBytes` | `65536` (64 KiB) | Larger `add()` calls fail with `SNIP_TOO_LARGE`. |
75
+ | `stateFile` | unset | Optional JSON snapshot path, written atomically. |
76
+
77
+ Expiry and the entry cap are applied automatically on `add`, `list`, `search`,
78
+ `get`, `forget` and on mount.
79
+
80
+ ## Secret exclusion and local storage
81
+
82
+ - With `excludeSecrets` on (the default), a hit is **not stored at all**: the
83
+ ledger keeps only `[redacted:<reason>]` as the text/preview and marks
84
+ `redacted: true`. Supported patterns include `sk-...`, `ghp_...` /
85
+ `github_pat_...`, `AKIA...` / `ASIA...`, PEM/PGP private keys,
86
+ `password=...`, `api_key=...`, bearer tokens, JWTs, Slack, Stripe and Google
87
+ API keys.
88
+ - Detection is best-effort, not a guarantee. Set `excludeSecrets: false` to
89
+ opt out (not recommended). `sensitivity: 'secret'` is a caller-side override
90
+ that always redacts.
91
+ - When `stateFile` is set, each mutation writes the snapshot through a
92
+ temporary file and `rename` (atomic replace, mode `0600`). The snapshot is
93
+ plain JSON and is **not encrypted in 0.1.0** — protect it like any local
94
+ secret. A snapshot written with detection disabled is re-screened on load.
95
+ - 0.1.0 performs no network I/O and does not read the OS clipboard. There is no
96
+ background capture, watcher or timer.
97
+
98
+ ## Development
99
+
100
+ ```sh
101
+ cd packages/snip
102
+ node --test
103
+ ```
104
+
105
+ Pure ESM JavaScript, Node 22+, no runtime dependencies and no build step.
106
+
107
+ ## License
18
108
 
19
- - Host seam: `ctx.snip` (planned)
20
- - Agent tools and CLI are declared in the package's design doc.
21
- - License: MIT.
109
+ MIT. See [LICENSE](./LICENSE).
package/index.js CHANGED
@@ -1,13 +1,395 @@
1
1
  /**
2
- * dsh-snip — Encrypted, searchable clipboard ledger for DeepSeek Harness with secret exclusion and agent handles.
2
+ * dsh-snip — local-first clipboard ledger for DeepSeek Harness.
3
3
  *
4
- * 0.0.1 placeholder: the bundle loads and provides a stable package name.
5
- * The functional implementation lands in 0.1.0.
4
+ * 0.1.0 records explicit `add` calls only: no clipboard polling, no network,
5
+ * no encryption yet. Secret-looking text is not stored unless the caller
6
+ * explicitly disables `excludeSecrets`.
6
7
  * @module dsh-snip
7
8
  */
9
+ import { randomUUID } from 'node:crypto'
10
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
11
+ import { dirname } from 'node:path'
8
12
 
9
- /** Cordis plugin name. */
10
13
  export const name = 'dsh-snip'
14
+ export const inject = ['tools']
11
15
 
12
- /** Mount the plugin. The 0.0.1 placeholder intentionally has no side effects. */
13
- export function apply() {}
16
+ const DAY_MS = 86_400_000
17
+ const PREVIEW_CHARS = 140
18
+ const HANDLE_PREFIX = 'clipboard://'
19
+ const KINDS = new Set(['text', 'html', 'link', 'color'])
20
+ const SENSITIVITIES = new Set(['normal', 'sensitive', 'secret'])
21
+
22
+ /** Ordered: first match wins. Reasons are stable for `[redacted:<reason>]`. */
23
+ const SECRET_PATTERNS = [
24
+ ['private-key', /-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----/],
25
+ ['openai-key', /\bsk-[A-Za-z0-9_-]{6,}\b/],
26
+ ['github-token', /\b(?:gh[pousr]_[A-Za-z0-9]{6,}|github_pat_[A-Za-z0-9_]{6,})\b/],
27
+ ['aws-access-key', /\b(?:AKIA|ASIA)[0-9A-Z]{8,}\b/],
28
+ ['slack-token', /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/],
29
+ ['google-api-key', /\bAIza[0-9A-Za-z_-]{10,}\b/],
30
+ ['stripe-key', /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/],
31
+ ['jwt', /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],
32
+ ['bearer-token', /\bBearer\s+[A-Za-z0-9._~+/-]{10,}=*/],
33
+ ['password', /\b(?:password|passwd|pwd)"?\s*[:=]\s*(?:"[^"]{3,}"|'[^']{3,}'|[^\s'"]{3,})/i],
34
+ ['api-key', /\b(?:api[_-]?key|apikey)"?\s*[:=]\s*(?:"[^"]{8,}"|'[^']{8,}'|[^\s'"]{8,})/i],
35
+ ['credential', /\b(?:secret|token|access[_-]?key)"?\s*[:=]\s*(?:"[^"]{6,}"|'[^']{6,}'|[^\s'"]{6,})/i],
36
+ ]
37
+
38
+ function fail(code, message) {
39
+ const error = new Error(message)
40
+ error.code = code
41
+ return error
42
+ }
43
+
44
+ function positiveInt(value, fallback) {
45
+ const number = Number(value)
46
+ return Number.isFinite(number) && number >= 1 ? Math.floor(number) : fallback
47
+ }
48
+
49
+ function requestedLimit(value, fallback) {
50
+ if (value == null) return fallback
51
+ const number = Number(value)
52
+ return Number.isFinite(number) && number >= 1 ? Math.min(Math.floor(number), fallback) : fallback
53
+ }
54
+
55
+ function previewOf(text) {
56
+ const flat = text.replace(/\s+/g, ' ').trim()
57
+ return flat.length > PREVIEW_CHARS ? `${flat.slice(0, PREVIEW_CHARS - 1)}…` : flat
58
+ }
59
+
60
+ function handleOf(id) {
61
+ return `${HANDLE_PREFIX}${id}`
62
+ }
63
+
64
+ function resolveId(value) {
65
+ if (typeof value !== 'string') throw fail('SNIP_BAD_ID', 'snip: id must be a string')
66
+ const id = value.startsWith(HANDLE_PREFIX) ? value.slice(HANDLE_PREFIX.length) : value
67
+ if (!id) throw fail('SNIP_BAD_ID', 'snip: id must not be empty')
68
+ return id
69
+ }
70
+
71
+ function summaryOf(entry) {
72
+ return {
73
+ id: entry.id,
74
+ handle: handleOf(entry.id),
75
+ kind: entry.kind,
76
+ preview: entry.preview,
77
+ createdAt: entry.createdAt,
78
+ expiresAt: entry.expiresAt,
79
+ redacted: entry.redacted,
80
+ }
81
+ }
82
+
83
+ function isContext(value) {
84
+ return Boolean(value && typeof value === 'object' && ('provide' in value || 'get' in value || 'tools' in value))
85
+ }
86
+
87
+ /** Return the first secret pattern reason found in `text`, or null. */
88
+ export function detectSecret(text) {
89
+ if (typeof text !== 'string') return null
90
+ for (const [reason, pattern] of SECRET_PATTERNS) {
91
+ if (pattern.test(text)) return reason
92
+ }
93
+ return null
94
+ }
95
+
96
+ /** In-memory ledger with optional atomic JSON snapshot. */
97
+ export class SnipService {
98
+ #entries = new Map()
99
+ #stateFile
100
+ #ttlMs
101
+ #maxEntries
102
+ #maxBytes
103
+ #excludeSecrets
104
+ #now
105
+
106
+ constructor(ctxOrConfig = {}, maybeConfig) {
107
+ const config = isContext(ctxOrConfig) ? (maybeConfig ?? {}) : (ctxOrConfig ?? {})
108
+ this.#ttlMs = positiveInt(config.ttlMs ?? config.ttl, DAY_MS)
109
+ this.#maxEntries = positiveInt(config.maxEntries, 200)
110
+ this.#maxBytes = positiveInt(config.maxBytes, 64 * 1024)
111
+ this.#excludeSecrets = config.excludeSecrets !== false
112
+ this.#now = typeof config.now === 'function' ? config.now : Date.now
113
+ this.#stateFile = typeof config.stateFile === 'string' && config.stateFile.length > 0 ? config.stateFile : null
114
+ if (this.#stateFile) this.#load()
115
+ if (this.#sweep() || this.#stateFile) this.#persist()
116
+ }
117
+
118
+ /** Store one clipping; return its stable handle and metadata. */
119
+ add(input = {}) {
120
+ const args = input ?? {}
121
+ const text = args.text
122
+ if (typeof text !== 'string') throw fail('SNIP_BAD_TEXT', 'snip: text must be a string')
123
+ if (text.trim().length === 0) throw fail('SNIP_EMPTY_TEXT', 'snip: text must not be empty')
124
+ if (Buffer.byteLength(text, 'utf8') > this.#maxBytes) {
125
+ throw fail('SNIP_TOO_LARGE', `snip: text exceeds maxBytes (${this.#maxBytes})`)
126
+ }
127
+
128
+ const kind = args.kind ?? 'text'
129
+ if (typeof kind !== 'string' || !KINDS.has(kind)) {
130
+ throw fail('SNIP_BAD_KIND', 'snip: unsupported kind')
131
+ }
132
+ const sensitivity = args.sensitivity ?? 'normal'
133
+ if (typeof sensitivity !== 'string' || !SENSITIVITIES.has(sensitivity)) {
134
+ throw fail('SNIP_BAD_SENSITIVITY', 'snip: unsupported sensitivity')
135
+ }
136
+ const rawSource = typeof args.sourceApp === 'string' ? args.sourceApp.trim() : ''
137
+ const sourceApp = (rawSource || 'unknown').slice(0, 80)
138
+
139
+ const reason = sensitivity === 'secret'
140
+ ? 'sensitivity'
141
+ : this.#excludeSecrets ? detectSecret(text) : null
142
+ const storedText = reason ? `[redacted:${reason}]` : text
143
+ const timestamp = this.#now()
144
+ const entry = {
145
+ id: randomUUID(),
146
+ kind,
147
+ text: storedText,
148
+ preview: previewOf(storedText),
149
+ sourceApp,
150
+ sensitivity,
151
+ createdAt: new Date(timestamp).toISOString(),
152
+ expiresAt: new Date(timestamp + this.#ttlMs).toISOString(),
153
+ redacted: reason !== null,
154
+ }
155
+
156
+ this.#sweep()
157
+ this.#entries.set(entry.id, entry)
158
+ this.#enforceMax()
159
+ this.#persist()
160
+ return summaryOf(entry)
161
+ }
162
+
163
+ /** Newest-first summaries, optionally filtered by kind. */
164
+ list(options = {}) {
165
+ const args = options ?? {}
166
+ if (this.#sweep()) this.#persist()
167
+ const kind = typeof args.kind === 'string' && args.kind.length > 0 ? args.kind : null
168
+ return [...this.#entries.values()]
169
+ .reverse()
170
+ .filter(entry => kind === null || entry.kind === kind)
171
+ .slice(0, requestedLimit(args.limit, this.#maxEntries))
172
+ .map(summaryOf)
173
+ }
174
+
175
+ /** Case-insensitive substring search over stored text (redacted text included). */
176
+ search(query, options = {}) {
177
+ const needle = typeof query === 'string' ? query.trim().toLowerCase() : ''
178
+ if (!needle) throw fail('SNIP_BAD_QUERY', 'snip: query must be a non-empty string')
179
+ if (this.#sweep()) this.#persist()
180
+ return [...this.#entries.values()]
181
+ .reverse()
182
+ .filter(entry => entry.text.toLowerCase().includes(needle))
183
+ .slice(0, requestedLimit(options?.limit, this.#maxEntries))
184
+ .map(summaryOf)
185
+ }
186
+
187
+ /** Full entry (including text) by id or `clipboard://` handle; null if absent. */
188
+ get(idOrHandle) {
189
+ const id = resolveId(idOrHandle)
190
+ if (this.#sweep()) this.#persist()
191
+ const entry = this.#entries.get(id)
192
+ if (!entry) return null
193
+ return {
194
+ ...summaryOf(entry),
195
+ text: entry.text,
196
+ sourceApp: entry.sourceApp,
197
+ sensitivity: entry.sensitivity,
198
+ }
199
+ }
200
+
201
+ /** Delete one entry by id or handle; true when it existed. */
202
+ forget(idOrHandle) {
203
+ const id = resolveId(idOrHandle)
204
+ const swept = this.#sweep()
205
+ const removed = this.#entries.delete(id)
206
+ if (removed || swept) this.#persist()
207
+ return removed
208
+ }
209
+
210
+ /** Delete every entry; return the number removed. */
211
+ clear() {
212
+ const removed = this.#entries.size
213
+ this.#entries.clear()
214
+ if (removed) this.#persist()
215
+ return removed
216
+ }
217
+
218
+ #sweep() {
219
+ const now = this.#now()
220
+ let removed = 0
221
+ for (const [id, entry] of this.#entries) {
222
+ if (Date.parse(entry.expiresAt) <= now) {
223
+ this.#entries.delete(id)
224
+ removed += 1
225
+ }
226
+ }
227
+ return removed + this.#enforceMax()
228
+ }
229
+
230
+ #enforceMax() {
231
+ let removed = 0
232
+ while (this.#entries.size > this.#maxEntries) {
233
+ this.#entries.delete(this.#entries.keys().next().value)
234
+ removed += 1
235
+ }
236
+ return removed
237
+ }
238
+
239
+ #load() {
240
+ if (!existsSync(this.#stateFile)) return
241
+ let parsed
242
+ try {
243
+ const raw = readFileSync(this.#stateFile, 'utf8').trim()
244
+ if (!raw) return
245
+ parsed = JSON.parse(raw)
246
+ } catch (error) {
247
+ throw fail('SNIP_STATE_INVALID', `snip: cannot read state file: ${error.message}`)
248
+ }
249
+ const entries = Array.isArray(parsed?.entries) ? parsed.entries : []
250
+ for (const raw of entries) {
251
+ if (!raw || typeof raw.id !== 'string' || typeof raw.text !== 'string') continue
252
+ const sensitivity = SENSITIVITIES.has(raw.sensitivity) ? raw.sensitivity : 'normal'
253
+ // Re-scan on load so a snapshot written with detection disabled is safe.
254
+ const reason = sensitivity === 'secret'
255
+ ? 'sensitivity'
256
+ : this.#excludeSecrets ? detectSecret(raw.text) : null
257
+ const text = reason ? `[redacted:${reason}]` : raw.text
258
+ this.#entries.set(raw.id, {
259
+ id: raw.id,
260
+ kind: KINDS.has(raw.kind) ? raw.kind : 'text',
261
+ text,
262
+ preview: previewOf(text),
263
+ sourceApp: typeof raw.sourceApp === 'string' ? raw.sourceApp : 'unknown',
264
+ sensitivity,
265
+ createdAt: typeof raw.createdAt === 'string' ? raw.createdAt : new Date(this.#now()).toISOString(),
266
+ expiresAt: typeof raw.expiresAt === 'string' ? raw.expiresAt : new Date(this.#now() + this.#ttlMs).toISOString(),
267
+ redacted: raw.redacted === true || reason !== null,
268
+ })
269
+ }
270
+ }
271
+
272
+ #persist() {
273
+ if (!this.#stateFile) return
274
+ const payload = `${JSON.stringify({ version: 1, entries: [...this.#entries.values()] }, null, 2)}\n`
275
+ const temp = `${this.#stateFile}.${process.pid}.${randomUUID()}.tmp`
276
+ try {
277
+ mkdirSync(dirname(this.#stateFile), { recursive: true, mode: 0o700 })
278
+ writeFileSync(temp, payload, { mode: 0o600 })
279
+ renameSync(temp, this.#stateFile)
280
+ } catch (error) {
281
+ throw fail('SNIP_STATE_WRITE_FAILED', `snip: cannot write state file: ${error.message}`)
282
+ }
283
+ }
284
+ }
285
+
286
+ const TOOL_OUTPUT = {
287
+ schema: { type: 'object', additionalProperties: true },
288
+ render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
289
+ }
290
+
291
+ function tool(name, description, parameters, run) {
292
+ return {
293
+ name,
294
+ description,
295
+ parameters,
296
+ output: TOOL_OUTPUT,
297
+ async execute(args) {
298
+ return run(args ?? {})
299
+ },
300
+ }
301
+ }
302
+
303
+ /** Plain-object ToolDefinition list; deliberately no @deepseek-ai/dsh-tools import. */
304
+ export function makeTools(service) {
305
+ return [
306
+ tool(
307
+ 'snip_add',
308
+ 'Add a text clipping to the local Snip ledger and return a clipboard:// handle. Secret-looking text is redacted and not stored by default.',
309
+ {
310
+ type: 'object',
311
+ additionalProperties: false,
312
+ required: ['text'],
313
+ properties: {
314
+ text: { type: 'string', description: 'Text to record.' },
315
+ kind: { type: 'string', enum: [...KINDS] },
316
+ sourceApp: { type: 'string', description: 'Optional source application label.' },
317
+ sensitivity: { type: 'string', enum: [...SENSITIVITIES] },
318
+ },
319
+ },
320
+ args => service.add(args),
321
+ ),
322
+ tool(
323
+ 'snip_search',
324
+ 'Search the local Snip ledger (case-insensitive substring) and return matching handles and previews.',
325
+ {
326
+ type: 'object',
327
+ additionalProperties: false,
328
+ required: ['query'],
329
+ properties: {
330
+ query: { type: 'string', description: 'Text to look for.' },
331
+ limit: { type: 'integer', minimum: 1 },
332
+ },
333
+ },
334
+ args => ({ query: args.query, entries: service.search(args.query, { limit: args.limit }) }),
335
+ ),
336
+ tool(
337
+ 'snip_get',
338
+ 'Read one clipping by id or clipboard:// handle. Returned text becomes part of this conversation session log.',
339
+ {
340
+ type: 'object',
341
+ additionalProperties: false,
342
+ required: ['id'],
343
+ properties: { id: { type: 'string', description: 'Clipping id or clipboard:// handle.' } },
344
+ },
345
+ args => {
346
+ const entry = service.get(args.id)
347
+ if (!entry) throw fail('SNIP_NOT_FOUND', 'snip: clipping not found')
348
+ return entry
349
+ },
350
+ ),
351
+ tool(
352
+ 'snip_list',
353
+ 'List recent clippings newest first, optionally filtered by kind.',
354
+ {
355
+ type: 'object',
356
+ additionalProperties: false,
357
+ properties: {
358
+ kind: { type: 'string', enum: [...KINDS] },
359
+ limit: { type: 'integer', minimum: 1 },
360
+ },
361
+ },
362
+ args => ({ entries: service.list(args) }),
363
+ ),
364
+ tool(
365
+ 'snip_forget',
366
+ 'Delete one clipping by id or clipboard:// handle.',
367
+ {
368
+ type: 'object',
369
+ additionalProperties: false,
370
+ required: ['id'],
371
+ properties: { id: { type: 'string', description: 'Clipping id or clipboard:// handle.' } },
372
+ },
373
+ args => {
374
+ const removed = service.forget(args.id)
375
+ return { ok: removed, removed }
376
+ },
377
+ ),
378
+ tool(
379
+ 'snip_clear',
380
+ 'Delete every clipping in the local Snip ledger.',
381
+ { type: 'object', additionalProperties: false, properties: {} },
382
+ () => ({ removed: service.clear() }),
383
+ ),
384
+ ]
385
+ }
386
+
387
+ /** Mount `ctx.snip` and the snip_* agent tools. */
388
+ export function apply(ctx, config = {}) {
389
+ const service = new SnipService(config)
390
+ ctx.provide('snip', service)
391
+ if (ctx.tools && typeof ctx.tools.register === 'function') {
392
+ for (const definition of makeTools(service)) ctx.tools.register(definition)
393
+ }
394
+ return service
395
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-snip",
3
- "version": "0.0.1",
4
- "description": "Encrypted, searchable clipboard ledger for DeepSeek Harness with secret exclusion and agent handles.",
3
+ "version": "0.1.0",
4
+ "description": "Local-first, searchable clipboard ledger for DeepSeek Harness with secret exclusion and clipboard:// agent handles.",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "exports": {
@@ -14,11 +14,16 @@
14
14
  "README.md",
15
15
  "CHANGELOG.md"
16
16
  ],
17
+ "scripts": {
18
+ "test": "node --test"
19
+ },
17
20
  "keywords": [
18
21
  "dsh",
19
22
  "dsh-plugin",
20
23
  "deepseek-harness",
21
24
  "agent-os",
25
+ "clipboard",
26
+ "clipboard-history",
22
27
  "snip"
23
28
  ],
24
29
  "license": "MIT",