@spences10/pi-context 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # @spences10/pi-context
2
2
 
3
- Local SQLite context sidecar for Pi. Oversized tool output is stored
4
- in an FTS5-backed database and replaced with a compact receipt that
5
- the agent can search or retrieve later.
3
+ Local SQLite context sidecar for Pi. Oversized text tool output is
4
+ redacted, stored in an FTS5-backed database, and replaced with a
5
+ compact receipt that shows the source id, project/session scope, and
6
+ retrieval actions.
7
+
8
+ This is an ephemeral overflow cache for large artifacts, not durable
9
+ session memory. Use `pirecall` for durable session history.
6
10
 
7
11
  ## Runtime
8
12
 
@@ -22,14 +26,81 @@ pi -e ./packages/pi-context
22
26
 
23
27
  ## Commands/tools
24
28
 
25
- - `context_search` — search indexed tool output
26
- - `context_get` retrieve exact stored chunks
27
- - `context_stats` / `/context-stats` — byte accounting and DB stats
28
- - `context_purge` — delete old indexed output
29
+ - `context_search` — search indexed tool output in the current
30
+ project/session scope by default. Pass `global: true` to search all
31
+ scopes.
32
+ - `context_get` — retrieve exact stored chunks by source id.
33
+ - `context_list` / `/context list [limit]` — list recent indexed
34
+ sources in the current scope with source ids, tool names, sizes, and
35
+ previews.
36
+ - `context_stats` / `/context stats` / `/context-stats` — scoped
37
+ totals, global totals, DB size, oldest/newest sources, and active
38
+ retention policy.
39
+ - `context_purge` / `/context purge [days]` — delete old indexed
40
+ output. Also supports source/project/session filters and
41
+ `/context purge expired`.
42
+
43
+ Use `/context` in interactive mode for a small modal with list, stats,
44
+ and purge actions.
45
+
46
+ Receipts suggest the main retrieval path:
47
+
48
+ ```text
49
+ context_search query:"..." source_id:"ctx_..."
50
+ context_get source_id:"ctx_..."
51
+ context_list
52
+ ```
53
+
54
+ ## Coverage policy
55
+
56
+ Intentional sidecar-backed output:
57
+
58
+ - `read` and `bash` text output: handled by the generic `tool_result`
59
+ hook when output exceeds byte/line thresholds.
60
+ - MCP tool output: handled directly in `@spences10/pi-mcp` before
61
+ temp-file fallback, then ignored by the generic hook because
62
+ receipts already contain `[context-sidecar]`.
63
+ - LSP tool output: handled by the generic hook for large text
64
+ diagnostics or symbol/reference dumps; small structured summaries
65
+ stay inline.
66
+ - Hook output and telemetry summaries: not directly indexed unless
67
+ they appear as large text tool results.
68
+
69
+ Intentionally skipped output:
70
+
71
+ - `context_*` tools: avoids recursive indexing of
72
+ retrieval/maintenance output.
73
+ - `team`: coordination/mailbox/task state belongs in team-mode and
74
+ session history surfaces, not this overflow cache.
75
+ - Non-text/image results: ignored by `pi-context`; image/file handling
76
+ should use dedicated tool-specific surfaces.
77
+
78
+ Any newly sidecar-backed text follows the same redaction,
79
+ project/session scope, retention, and dedupe rules.
80
+
81
+ ## Storage, scoping, and retention
29
82
 
30
83
  The default DB path is
31
84
  `${PI_CODING_AGENT_DIR:-~/.pi/agent}/context.db`. Set
32
85
  `MY_PI_CONTEXT_DB` to override it.
33
86
 
34
- This is context retrieval/isolation, not a security sandbox. Stored
35
- text is redacted with `@spences10/pi-redact` before persistence.
87
+ New sources are scoped by Pi session file/id when available, falling
88
+ back to the current project path. Retrieval tools use that scope by
89
+ default to avoid leaking other projects or sessions into results; pass
90
+ `global: true` when you intend to search or list everything.
91
+
92
+ Retention is env-backed:
93
+
94
+ - `MY_PI_CONTEXT_RETENTION_DAYS` — default `7`; set `0`, `off`, or
95
+ `disabled` to disable age cleanup.
96
+ - `MY_PI_CONTEXT_PURGE_ON_SHUTDOWN` — set `true`/`1`/`yes`/`on` to run
97
+ cleanup on shutdown.
98
+ - `MY_PI_CONTEXT_MAX_MB` — optional max stored raw bytes; oldest
99
+ sources are removed first when exceeded.
100
+
101
+ ## Safety model
102
+
103
+ This is redacted local persistence and retrieval, not a security
104
+ sandbox. Stored text is redacted with `@spences10/pi-redact` before
105
+ persistence, but anything persisted in the local SQLite DB should
106
+ still be treated as local tool output.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { ExtensionAPI } from '@mariozechner/pi-coding-agent';
2
2
  export default function context_sidecar(pi: ExtensionAPI): void;
3
- export { get_context_store, is_context_sidecar_enabled, maybe_store_context_output, set_context_sidecar_enabled, should_index_text, } from './store.js';
4
- export type { ContextSearchResult, ContextStats, StoreContextInput, StoredContextOutput, } from './store.js';
3
+ export { get_context_store, is_context_sidecar_enabled, maybe_store_context_output, parse_context_retention_policy, set_context_sidecar_enabled, should_index_text, } from './store.js';
4
+ export type { ContextCleanupResult, ContextListResult, ContextPurgeDetails, ContextRetentionPolicy, ContextScopeOptions, ContextSearchResult, ContextStats, StoreContextInput, StoredContextOutput, } from './store.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { show_confirm_modal, show_picker_modal, show_text_modal, } from '@spences10/pi-tui-modal';
1
2
  import { Type } from 'typebox';
2
3
  import { get_context_store, is_context_sidecar_enabled, maybe_store_context_output, set_context_sidecar_enabled, should_index_text, } from './store.js';
3
4
  function is_text_content(item) {
@@ -18,12 +19,31 @@ function summarize_tool_input(input) {
18
19
  }
19
20
  }
20
21
  function should_skip_tool(tool_name) {
22
+ // Coverage policy:
23
+ // - context_* tools are retrieval/maintenance output; indexing them would
24
+ // recurse and make the sidecar harder to reason about.
25
+ // - team output is coordination state, not bulky artifact content; keep it in
26
+ // team/pirecall surfaces rather than duplicating mailbox/task state here.
27
+ // - MCP receipts are produced before generic tool_result hooks; the hook also
28
+ // ignores existing [context-sidecar] receipts so direct MCP storage is not
29
+ // indexed a second time.
21
30
  return (tool_name === 'context_search' ||
22
31
  tool_name === 'context_get' ||
32
+ tool_name === 'context_list' ||
23
33
  tool_name === 'context_stats' ||
24
34
  tool_name === 'context_purge' ||
25
35
  tool_name === 'team');
26
36
  }
37
+ function session_id_from_context(ctx) {
38
+ const manager = ctx?.sessionManager;
39
+ return (manager?.getSessionFile?.() ?? manager?.getSessionId?.() ?? null);
40
+ }
41
+ function scope_from_context(ctx) {
42
+ return {
43
+ project_path: ctx?.cwd ?? process.cwd(),
44
+ session_id: session_id_from_context(ctx),
45
+ };
46
+ }
27
47
  function format_search_results(results) {
28
48
  if (results.length === 0)
29
49
  return 'No indexed context matched.';
@@ -36,32 +56,148 @@ function format_search_results(results) {
36
56
  ].join('\n'))
37
57
  .join('\n\n---\n\n');
38
58
  }
59
+ function format_list_results(results) {
60
+ if (results.length === 0)
61
+ return 'No indexed context sources found.';
62
+ return results
63
+ .map((result) => [
64
+ `## ${result.source_id}`,
65
+ `Created: ${new Date(result.created_at).toISOString()} • Tool: ${result.tool_name}`,
66
+ `Size: ${result.bytes} bytes, ${result.lines} lines, ${result.chunk_count} chunks`,
67
+ `Project: ${result.project_path ?? '(none)'}`,
68
+ `Session: ${result.session_id ?? '(none)'}`,
69
+ result.input_summary
70
+ ? `Input: ${result.input_summary}`
71
+ : undefined,
72
+ result.first_chunk_title
73
+ ? `First chunk: ${result.first_chunk_title}`
74
+ : undefined,
75
+ result.preview ? `Preview: ${result.preview}` : undefined,
76
+ ]
77
+ .filter(Boolean)
78
+ .join('\n'))
79
+ .join('\n\n');
80
+ }
81
+ function format_purge_details(details) {
82
+ const filters = [
83
+ details.source_id ? `source_id=${details.source_id}` : undefined,
84
+ details.project_path !== undefined
85
+ ? `project_path=${details.project_path ?? '(none)'}`
86
+ : undefined,
87
+ details.session_id !== undefined
88
+ ? `session_id=${details.session_id ?? '(none)'}`
89
+ : undefined,
90
+ details.older_than_days !== undefined
91
+ ? `older_than_days=${details.older_than_days}`
92
+ : undefined,
93
+ ]
94
+ .filter(Boolean)
95
+ .join(', ');
96
+ return `Deleted ${details.deleted} context source(s).${filters ? ` Filters: ${filters}.` : ''}`;
97
+ }
39
98
  function format_stats(stats) {
99
+ const scoped = stats.scope_project_path || stats.scope_session_id;
40
100
  return [
41
101
  '## context-sidecar stats',
42
102
  '',
43
103
  `- Enabled: ${is_context_sidecar_enabled()}`,
44
- `- Sources: ${stats.sources}`,
45
- `- Chunks: ${stats.chunks}`,
46
- `- Raw bytes stored: ${stats.bytes_stored}`,
104
+ scoped
105
+ ? `- Scope: project=${stats.scope_project_path ?? '(none)'}, session=${stats.scope_session_id ?? '(none)'}`
106
+ : '- Scope: global',
107
+ `- Scoped sources: ${stats.sources}`,
108
+ `- Scoped chunks: ${stats.chunks}`,
109
+ `- Scoped raw bytes stored: ${stats.bytes_stored}`,
110
+ `- Global sources: ${stats.global_sources}`,
111
+ `- Global chunks: ${stats.global_chunks}`,
112
+ `- Global raw bytes stored: ${stats.global_bytes_stored}`,
47
113
  `- Bytes returned: ${stats.bytes_returned}`,
48
114
  `- Bytes saved: ${stats.bytes_saved}`,
49
115
  `- Reduction: ${stats.reduction_pct}%`,
50
116
  `- DB bytes: ${stats.total_bytes}`,
117
+ `- Scoped oldest source: ${format_timestamp(stats.oldest_created_at)}`,
118
+ `- Scoped newest source: ${format_timestamp(stats.newest_created_at)}`,
119
+ `- Global oldest source: ${format_timestamp(stats.global_oldest_created_at)}`,
120
+ `- Global newest source: ${format_timestamp(stats.global_newest_created_at)}`,
121
+ `- Retention days: ${stats.retention_days ?? 'disabled'}`,
122
+ `- Purge on shutdown: ${stats.purge_on_shutdown}`,
123
+ `- Max DB size: ${stats.max_mb === null ? 'disabled' : `${stats.max_mb} MiB`}`,
51
124
  ].join('\n');
52
125
  }
126
+ function format_timestamp(timestamp) {
127
+ return timestamp === null
128
+ ? '(none)'
129
+ : new Date(timestamp).toISOString();
130
+ }
131
+ async function show_context_text_modal(ctx, title, text) {
132
+ await show_text_modal(ctx, {
133
+ title,
134
+ text,
135
+ max_visible_lines: 18,
136
+ overlay_options: { width: '80%', minWidth: 64 },
137
+ });
138
+ }
139
+ async function show_context_stats(ctx) {
140
+ const scope = scope_from_context(ctx);
141
+ const text = format_stats(get_context_store(scope).stats(scope));
142
+ if (ctx.hasUI) {
143
+ await show_context_text_modal(ctx, 'Context sidecar stats', text);
144
+ }
145
+ else {
146
+ ctx.ui.notify(text, 'info');
147
+ }
148
+ }
149
+ async function show_context_list(ctx, limit) {
150
+ const scope = scope_from_context(ctx);
151
+ const text = format_list_results(get_context_store(scope).list({ ...scope, limit }));
152
+ if (ctx.hasUI) {
153
+ await show_context_text_modal(ctx, 'Context sidecar sources', text);
154
+ }
155
+ else {
156
+ ctx.ui.notify(text, 'info');
157
+ }
158
+ }
159
+ async function purge_context(ctx, options = {}) {
160
+ const policy = get_context_store().stats();
161
+ const days = options.older_than_days ?? policy.retention_days ?? 14;
162
+ const description = options.expired
163
+ ? 'Delete expired context sources now?'
164
+ : options.source_id
165
+ ? `Delete context source ${options.source_id}?`
166
+ : `Delete context sources older than ${days} day(s)?`;
167
+ const confirmed = ctx.hasUI
168
+ ? await show_confirm_modal(ctx, {
169
+ title: 'Purge context sidecar?',
170
+ message: description,
171
+ confirm_label: 'Purge',
172
+ })
173
+ : await ctx.ui.confirm('Purge context sidecar?', description);
174
+ if (!confirmed)
175
+ return;
176
+ const scope = scope_from_context(ctx);
177
+ const details = options.expired
178
+ ? { deleted: get_context_store(scope).cleanup().deleted }
179
+ : get_context_store(scope).purge_with_details({
180
+ ...scope,
181
+ older_than_days: options.source_id ? undefined : days,
182
+ source_id: options.source_id,
183
+ });
184
+ ctx.ui.notify(format_purge_details(details), 'info');
185
+ }
53
186
  export default function context_sidecar(pi) {
54
187
  set_context_sidecar_enabled(true, { project_path: process.cwd() });
55
188
  pi.on('session_start', async (_event, ctx) => {
56
- set_context_sidecar_enabled(true, {
57
- project_path: ctx.cwd,
58
- session_id: undefined,
59
- });
189
+ const scope = scope_from_context(ctx);
190
+ set_context_sidecar_enabled(true, scope);
191
+ get_context_store(scope).cleanup();
60
192
  });
61
193
  pi.on('session_shutdown', async () => {
194
+ const store = get_context_store();
195
+ const stats = store.stats();
196
+ if (stats.purge_on_shutdown)
197
+ store.cleanup();
62
198
  set_context_sidecar_enabled(false);
63
199
  });
64
- pi.on('tool_result', async (event) => {
200
+ pi.on('tool_result', async (event, ctx) => {
65
201
  const tool_name = String(event.toolName ?? 'tool');
66
202
  if (should_skip_tool(tool_name))
67
203
  return;
@@ -80,6 +216,7 @@ export default function context_sidecar(pi) {
80
216
  text,
81
217
  tool_name,
82
218
  input_summary: summarize_tool_input(event.input),
219
+ ...scope_from_context(ctx),
83
220
  });
84
221
  if (!stored)
85
222
  return;
@@ -105,9 +242,15 @@ export default function context_sidecar(pi) {
105
242
  limit: Type.Optional(Type.Number({
106
243
  description: 'Maximum chunks to return, default 5',
107
244
  })),
245
+ global: Type.Optional(Type.Boolean({
246
+ description: 'Search all indexed sources instead of current project/session scope',
247
+ })),
108
248
  }),
109
- async execute(_toolCallId, params) {
110
- const results = get_context_store().search(params.query, {
249
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
250
+ const scope = scope_from_context(ctx);
251
+ const results = get_context_store(scope).search(params.query, {
252
+ ...(params.global ? {} : scope),
253
+ global: params.global,
111
254
  source_id: params.source_id,
112
255
  tool_name: params.tool_name,
113
256
  limit: params.limit,
@@ -131,9 +274,13 @@ export default function context_sidecar(pi) {
131
274
  parameters: Type.Object({
132
275
  source_id: Type.String({ description: 'Indexed source id' }),
133
276
  chunk_id: Type.Optional(Type.String({ description: 'Optional exact chunk id' })),
277
+ global: Type.Optional(Type.Boolean({
278
+ description: 'Retrieve across all scopes instead of current project/session scope',
279
+ })),
134
280
  }),
135
- async execute(_toolCallId, params) {
136
- const chunks = get_context_store().get(params.source_id, params.chunk_id);
281
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
282
+ const scope = scope_from_context(ctx);
283
+ const chunks = get_context_store(scope).get(params.source_id, params.chunk_id, { ...(params.global ? {} : scope), global: params.global });
137
284
  const text = chunks.length
138
285
  ? chunks
139
286
  .map((chunk) => [
@@ -150,13 +297,68 @@ export default function context_sidecar(pi) {
150
297
  };
151
298
  },
152
299
  });
300
+ pi.registerTool({
301
+ name: 'context_list',
302
+ label: 'Context List',
303
+ description: 'List indexed sources in the local SQLite context sidecar.',
304
+ promptSnippet: 'List recent indexed context-sidecar sources without knowing a source id',
305
+ parameters: Type.Object({
306
+ source_id: Type.Optional(Type.String({ description: 'Limit to one source id' })),
307
+ tool_name: Type.Optional(Type.String({ description: 'Limit to one tool name' })),
308
+ project_path: Type.Optional(Type.String({ description: 'Limit to one project path' })),
309
+ session_id: Type.Optional(Type.String({ description: 'Limit to one session id' })),
310
+ newer_than_days: Type.Optional(Type.Number({
311
+ description: 'Only sources newer than N days',
312
+ })),
313
+ older_than_days: Type.Optional(Type.Number({
314
+ description: 'Only sources older than N days',
315
+ })),
316
+ limit: Type.Optional(Type.Number({ description: 'Maximum sources, default 10' })),
317
+ offset: Type.Optional(Type.Number({ description: 'Pagination offset, default 0' })),
318
+ global: Type.Optional(Type.Boolean({
319
+ description: 'List all scopes instead of current project/session scope',
320
+ })),
321
+ }),
322
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
323
+ const scope = scope_from_context(ctx);
324
+ const has_explicit_scope = params.project_path !== undefined ||
325
+ params.session_id !== undefined;
326
+ const project_path = has_explicit_scope
327
+ ? params.project_path
328
+ : scope.project_path;
329
+ const session_id = has_explicit_scope
330
+ ? params.session_id
331
+ : scope.session_id;
332
+ const results = get_context_store(scope).list({
333
+ project_path,
334
+ session_id,
335
+ global: params.global || has_explicit_scope,
336
+ source_id: params.source_id,
337
+ tool_name: params.tool_name,
338
+ newer_than_days: params.newer_than_days,
339
+ older_than_days: params.older_than_days,
340
+ limit: params.limit,
341
+ offset: params.offset,
342
+ });
343
+ return {
344
+ content: [
345
+ {
346
+ type: 'text',
347
+ text: format_list_results(results),
348
+ },
349
+ ],
350
+ details: { count: results.length },
351
+ };
352
+ },
353
+ });
153
354
  pi.registerTool({
154
355
  name: 'context_stats',
155
356
  label: 'Context Stats',
156
357
  description: 'Show byte accounting for the local SQLite context sidecar.',
157
358
  parameters: Type.Object({}),
158
- async execute() {
159
- const stats = get_context_store().stats();
359
+ async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
360
+ const scope = scope_from_context(ctx);
361
+ const stats = get_context_store(scope).stats(scope);
160
362
  return {
161
363
  content: [
162
364
  { type: 'text', text: format_stats(stats) },
@@ -168,35 +370,147 @@ export default function context_sidecar(pi) {
168
370
  pi.registerTool({
169
371
  name: 'context_purge',
170
372
  label: 'Context Purge',
171
- description: 'Delete indexed context-sidecar output by age or source id.',
373
+ description: 'Delete indexed context-sidecar output by age, source, project, session, or active retention policy.',
172
374
  parameters: Type.Object({
375
+ expired: Type.Optional(Type.Boolean({
376
+ description: 'Run active retention cleanup now instead of manual age purge',
377
+ })),
173
378
  older_than_days: Type.Optional(Type.Number({
174
- description: 'Delete sources older than this many days; default 14',
379
+ description: 'Delete sources older than this many days; defaults to active retention days or 14',
175
380
  })),
176
381
  source_id: Type.Optional(Type.String({ description: 'Delete one source id' })),
382
+ project_path: Type.Optional(Type.String({
383
+ description: 'Limit purge to one project path',
384
+ })),
385
+ session_id: Type.Optional(Type.String({ description: 'Limit purge to one session id' })),
386
+ global: Type.Optional(Type.Boolean({
387
+ description: 'Purge all scopes instead of current project/session scope',
388
+ })),
177
389
  }),
178
- async execute(_toolCallId, params) {
179
- const deleted = get_context_store().purge({
180
- older_than_days: params.older_than_days,
181
- source_id: params.source_id,
182
- });
390
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
391
+ const scope = scope_from_context(ctx);
392
+ const store = get_context_store(scope);
393
+ const stats = store.stats();
394
+ const has_explicit_scope = params.project_path !== undefined ||
395
+ params.session_id !== undefined;
396
+ const project_path = params.global
397
+ ? params.project_path
398
+ : has_explicit_scope
399
+ ? params.project_path
400
+ : scope.project_path;
401
+ const session_id = params.global
402
+ ? params.session_id
403
+ : has_explicit_scope
404
+ ? params.session_id
405
+ : scope.session_id;
406
+ const details = params.expired
407
+ ? { deleted: store.cleanup().deleted }
408
+ : store.purge_with_details({
409
+ project_path,
410
+ session_id,
411
+ older_than_days: params.source_id
412
+ ? undefined
413
+ : (params.older_than_days ??
414
+ stats.retention_days ??
415
+ 14),
416
+ source_id: params.source_id,
417
+ });
183
418
  return {
184
419
  content: [
185
420
  {
186
421
  type: 'text',
187
- text: `Deleted ${deleted} context source(s).`,
422
+ text: format_purge_details(details),
188
423
  },
189
424
  ],
190
- details: { deleted },
425
+ details,
191
426
  };
192
427
  },
193
428
  });
429
+ pi.registerCommand('context', {
430
+ description: 'Inspect and manage the context sidecar',
431
+ getArgumentCompletions: (prefix) => ['list', 'stats', 'purge']
432
+ .filter((item) => item.startsWith(prefix.trim()))
433
+ .map((item) => ({ value: item, label: item })),
434
+ handler: async (args, ctx) => {
435
+ const [sub = '', ...rest] = args
436
+ .trim()
437
+ .split(/\s+/)
438
+ .filter(Boolean);
439
+ if (!sub && ctx.hasUI) {
440
+ const selected = await show_picker_modal(ctx, {
441
+ title: 'Context sidecar',
442
+ subtitle: 'Local SQLite storage for oversized tool output',
443
+ items: [
444
+ {
445
+ value: 'list',
446
+ label: 'List recent sources',
447
+ description: 'Browse indexed output in this scope',
448
+ },
449
+ {
450
+ value: 'stats',
451
+ label: 'Show stats',
452
+ description: 'Byte accounting and storage reduction',
453
+ },
454
+ {
455
+ value: 'purge',
456
+ label: 'Purge old context',
457
+ description: 'Delete sources older than 14 days',
458
+ },
459
+ ],
460
+ });
461
+ if (!selected)
462
+ return;
463
+ if (selected === 'list')
464
+ await show_context_list(ctx);
465
+ else if (selected === 'stats')
466
+ await show_context_stats(ctx);
467
+ else
468
+ await purge_context(ctx);
469
+ return;
470
+ }
471
+ switch (sub || 'list') {
472
+ case 'list': {
473
+ const [limit_text] = rest;
474
+ const limit = limit_text ? Number(limit_text) : undefined;
475
+ if (limit !== undefined && !Number.isFinite(limit)) {
476
+ ctx.ui.notify('Usage: /context list [limit]', 'warning');
477
+ return;
478
+ }
479
+ await show_context_list(ctx, limit);
480
+ return;
481
+ }
482
+ case 'stats':
483
+ await show_context_stats(ctx);
484
+ return;
485
+ case 'purge': {
486
+ const [kind, value] = rest;
487
+ if (kind === 'expired') {
488
+ await purge_context(ctx, { expired: true });
489
+ return;
490
+ }
491
+ if (kind === 'source' && value) {
492
+ await purge_context(ctx, { source_id: value });
493
+ return;
494
+ }
495
+ const days = kind ? Number(kind) : undefined;
496
+ if (days !== undefined && !Number.isFinite(days)) {
497
+ ctx.ui.notify('Usage: /context purge [older-than-days] | expired | source <source-id>', 'warning');
498
+ return;
499
+ }
500
+ await purge_context(ctx, { older_than_days: days });
501
+ return;
502
+ }
503
+ default:
504
+ ctx.ui.notify(`Unknown context command: ${sub}. Use list, stats, or purge.`, 'warning');
505
+ }
506
+ },
507
+ });
194
508
  pi.registerCommand('context-stats', {
195
509
  description: 'Show context sidecar byte accounting',
196
510
  handler: async (_args, ctx) => {
197
- ctx.ui.notify(format_stats(get_context_store().stats()), 'info');
511
+ await show_context_stats(ctx);
198
512
  },
199
513
  });
200
514
  }
201
- export { get_context_store, is_context_sidecar_enabled, maybe_store_context_output, set_context_sidecar_enabled, should_index_text, } from './store.js';
515
+ export { get_context_store, is_context_sidecar_enabled, maybe_store_context_output, parse_context_retention_policy, set_context_sidecar_enabled, should_index_text, } from './store.js';
202
516
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACN,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,GAGjB,MAAM,YAAY,CAAC;AAEpB,SAAS,eAAe,CACvB,IAAa;IAEb,OAAO,CACN,CAAC,CAAC,IAAI;QACN,OAAO,IAAI,KAAK,QAAQ;QACvB,IAA2B,CAAC,IAAI,KAAK,MAAM;QAC5C,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,CACrD,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;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,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ContextRetentionPolicy } from './types.js';
2
+ export declare const DEFAULT_CONTEXT_RETENTION_DAYS = 7;
3
+ export declare function parse_context_retention_policy(env?: NodeJS.ProcessEnv): ContextRetentionPolicy;
package/dist/policy.js ADDED
@@ -0,0 +1,30 @@
1
+ export const DEFAULT_CONTEXT_RETENTION_DAYS = 7;
2
+ export function parse_context_retention_policy(env = process.env) {
3
+ const retention_days = parse_optional_positive_number(env.MY_PI_CONTEXT_RETENTION_DAYS, DEFAULT_CONTEXT_RETENTION_DAYS);
4
+ const max_mb = parse_optional_positive_number(env.MY_PI_CONTEXT_MAX_MB, null);
5
+ return {
6
+ retention_days,
7
+ purge_on_shutdown: parse_boolean_env(env.MY_PI_CONTEXT_PURGE_ON_SHUTDOWN),
8
+ max_mb,
9
+ max_bytes: max_mb === null ? null : max_mb * 1024 * 1024,
10
+ };
11
+ }
12
+ function parse_optional_positive_number(value, fallback) {
13
+ if (value === undefined || value.trim() === '')
14
+ return fallback;
15
+ const normalized = value.trim().toLowerCase();
16
+ if (normalized === '0' ||
17
+ normalized === 'off' ||
18
+ normalized === 'false' ||
19
+ normalized === 'none' ||
20
+ normalized === 'disabled')
21
+ return null;
22
+ const parsed = Number(normalized);
23
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
24
+ }
25
+ function parse_boolean_env(value) {
26
+ if (!value)
27
+ return false;
28
+ return ['1', 'true', 'yes', 'on'].includes(value.trim().toLowerCase());
29
+ }
30
+ //# sourceMappingURL=policy.js.map