@dudong2/pi-context 0.0.0-stage → 0.3.2-rev.1
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/LICENSE +21 -0
- package/README.md +274 -2
- package/dist/commands/context-command.d.ts +2 -0
- package/dist/commands/context-command.js +65 -0
- package/dist/commands/context-command.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.js +184 -0
- package/dist/config.js.map +1 -0
- package/dist/context-format.d.ts +20 -0
- package/dist/context-format.js +200 -0
- package/dist/context-format.js.map +1 -0
- package/dist/context-scope.d.ts +7 -0
- package/dist/context-scope.js +44 -0
- package/dist/context-scope.js.map +1 -0
- package/dist/eval/checks.d.ts +9 -0
- package/dist/eval/checks.js +241 -0
- package/dist/eval/checks.js.map +1 -0
- package/dist/eval/codemode-benchmark.d.ts +25 -0
- package/dist/eval/codemode-benchmark.js +308 -0
- package/dist/eval/codemode-benchmark.js.map +1 -0
- package/dist/eval/fixtures.d.ts +31 -0
- package/dist/eval/fixtures.js +79 -0
- package/dist/eval/fixtures.js.map +1 -0
- package/dist/eval/index.d.ts +4 -0
- package/dist/eval/index.js +56 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/report.d.ts +3 -0
- package/dist/eval/report.js +45 -0
- package/dist/eval/report.js.map +1 -0
- package/dist/eval/scenarios.d.ts +3 -0
- package/dist/eval/scenarios.js +52 -0
- package/dist/eval/scenarios.js.map +1 -0
- package/dist/eval/types.d.ts +48 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/export-files.d.ts +9 -0
- package/dist/export-files.js +45 -0
- package/dist/export-files.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +2 -0
- package/dist/lifecycle.js +59 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/policy.d.ts +3 -0
- package/dist/policy.js +39 -0
- package/dist/policy.js.map +1 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +39 -0
- package/dist/schema.js.map +1 -0
- package/dist/schema.sql +49 -0
- package/dist/store/maintenance.d.ts +19 -0
- package/dist/store/maintenance.js +155 -0
- package/dist/store/maintenance.js.map +1 -0
- package/dist/store/registry.d.ts +7 -0
- package/dist/store/registry.js +44 -0
- package/dist/store/registry.js.map +1 -0
- package/dist/store/retrieval.d.ts +8 -0
- package/dist/store/retrieval.js +127 -0
- package/dist/store/retrieval.js.map +1 -0
- package/dist/store/row-schemas.d.ts +73 -0
- package/dist/store/row-schemas.js +74 -0
- package/dist/store/row-schemas.js.map +1 -0
- package/dist/store.d.ts +53 -0
- package/dist/store.js +408 -0
- package/dist/store.js.map +1 -0
- package/dist/text.d.ts +11 -0
- package/dist/text.js +226 -0
- package/dist/text.js.map +1 -0
- package/dist/tool-output.d.ts +6 -0
- package/dist/tool-output.js +48 -0
- package/dist/tool-output.js.map +1 -0
- package/dist/tools/export.d.ts +2 -0
- package/dist/tools/export.js +99 -0
- package/dist/tools/export.js.map +1 -0
- package/dist/tools/get.d.ts +2 -0
- package/dist/tools/get.js +61 -0
- package/dist/tools/get.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list.d.ts +2 -0
- package/dist/tools/list.js +72 -0
- package/dist/tools/list.js.map +1 -0
- package/dist/tools/output-schemas.d.ts +93 -0
- package/dist/tools/output-schemas.js +89 -0
- package/dist/tools/output-schemas.js.map +1 -0
- package/dist/tools/purge.d.ts +2 -0
- package/dist/tools/purge.js +73 -0
- package/dist/tools/purge.js.map +1 -0
- package/dist/tools/search.d.ts +2 -0
- package/dist/tools/search.js +63 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/stats.d.ts +2 -0
- package/dist/tools/stats.js +37 -0
- package/dist/tools/stats.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/menu.d.ts +8 -0
- package/dist/ui/menu.js +88 -0
- package/dist/ui/menu.js.map +1 -0
- package/dist/ui/settings.d.ts +7 -0
- package/dist/ui/settings.js +353 -0
- package/dist/ui/settings.js.map +1 -0
- package/package.json +64 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.js","sourceRoot":"","sources":["../../src/tools/purge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACN,iBAAiB,GAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,2BAA2B,CAAC,EAAgB;IAC3D,EAAE,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,sBAAsB;QACjC,YAAY,EAAE,2BAA2B;QACzC,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE;YACZ,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;YACrB,aAAa,EAAE,KAAK;SACpB;QACD,KAAK,EAAE,eAAe;QACtB,WAAW,EACV,qGAAqG;QACtG,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI,CAAC,OAAO,CAAC;gBACZ,WAAW,EACV,8DAA8D;aAC/D,CAAC,CACF;YACD,eAAe,EAAE,IAAI,CAAC,QAAQ,CAC7B,IAAI,CAAC,MAAM,CAAC;gBACX,WAAW,EACV,mFAAmF;aACpF,CAAC,CACF;YACD,SAAS,EAAE,IAAI,CAAC,QAAQ,CACvB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC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E,MAAM,CAAC,SAAS;wBAChC,CAAC,CAAC,SAAS;wBACX,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,IAAI,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC;oBACzD,SAAS,EAAE,MAAM,CAAC,SAAS;iBAC3B,CAAC,CAAC;YAEJ,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC;qBACnC;iBACD;gBACD,OAAO;gBACP,iBAAiB,EAAE,EAAE,GAAG,OAAO,EAAE;aACjC,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Type } from 'typebox';
|
|
2
|
+
import { format_search_results } from '../context-format.js';
|
|
3
|
+
import { scope_from_context } from '../context-scope.js';
|
|
4
|
+
import { get_context_store } from '../store.js';
|
|
5
|
+
import { context_search_output_schema, context_tool_namespace, } from './output-schemas.js';
|
|
6
|
+
export function register_context_search_tool(pi) {
|
|
7
|
+
pi.registerTool({
|
|
8
|
+
name: 'context_search',
|
|
9
|
+
namespace: context_tool_namespace,
|
|
10
|
+
outputSchema: context_search_output_schema,
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
openWorldHint: false,
|
|
15
|
+
},
|
|
16
|
+
label: 'Context Search',
|
|
17
|
+
description: 'Search large tool output stored in the local SQLite context sidecar. Use this snippet-first before retrieving chunks; reserve full_content:true for small matched chunks, not broad retrieval.',
|
|
18
|
+
promptSnippet: 'Search oversized tool output with concise snippets before retrieving chunks; export broad results for offline rg/jq/Python work',
|
|
19
|
+
parameters: Type.Object({
|
|
20
|
+
query: Type.String({ description: 'FTS search query' }),
|
|
21
|
+
source_id: Type.Optional(Type.String({
|
|
22
|
+
description: 'Limit to one indexed source id',
|
|
23
|
+
})),
|
|
24
|
+
tool_name: Type.Optional(Type.String({ description: 'Limit to one tool name' })),
|
|
25
|
+
limit: Type.Optional(Type.Number({
|
|
26
|
+
description: 'Maximum chunks to return, default 5',
|
|
27
|
+
})),
|
|
28
|
+
full_content: Type.Optional(Type.Boolean({
|
|
29
|
+
description: 'Return full matched chunks instead of concise snippets. Last resort for small matches only; prefer context_get before/after or context_export for large outputs.',
|
|
30
|
+
})),
|
|
31
|
+
global: Type.Optional(Type.Boolean({
|
|
32
|
+
description: 'Search all indexed sources instead of current project/session scope',
|
|
33
|
+
})),
|
|
34
|
+
}),
|
|
35
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
36
|
+
const scope = scope_from_context(ctx);
|
|
37
|
+
const search_options = {
|
|
38
|
+
global: params.global,
|
|
39
|
+
source_id: params.source_id,
|
|
40
|
+
tool_name: params.tool_name,
|
|
41
|
+
limit: params.limit,
|
|
42
|
+
full_content: params.full_content,
|
|
43
|
+
};
|
|
44
|
+
const scope_options = params.global
|
|
45
|
+
? search_options
|
|
46
|
+
: { ...scope, ...search_options };
|
|
47
|
+
const results = get_context_store(scope).search(params.query, scope_options);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: format_search_results(results),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
details: { count: results.length },
|
|
56
|
+
structuredContent: {
|
|
57
|
+
results: results.map((result) => ({ ...result })),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAA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,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAEtC,MAAM,cAAc,GAAG;gBACtB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,YAAY,EAAE,MAAM,CAAC,YAAY;aACjC,CAAC;YAEF,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM;gBAClC,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,cAAc,EAAE,CAAC;YAEnC,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,MAAM,CAC9C,MAAM,CAAC,KAAK,EACZ,aAAa,CACb,CAAC;YAEF,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC;qBACpC;iBACD;gBACD,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;gBAClC,iBAAiB,EAAE;oBAClB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;iBACjD;aACD,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Type } from 'typebox';
|
|
2
|
+
import { format_stats } from '../context-format.js';
|
|
3
|
+
import { scope_from_context } from '../context-scope.js';
|
|
4
|
+
import { get_context_store } from '../store.js';
|
|
5
|
+
import { context_stats_output_schema, context_tool_namespace, } from './output-schemas.js';
|
|
6
|
+
export function register_context_stats_tool(pi) {
|
|
7
|
+
pi.registerTool({
|
|
8
|
+
name: 'context_stats',
|
|
9
|
+
namespace: context_tool_namespace,
|
|
10
|
+
outputSchema: context_stats_output_schema,
|
|
11
|
+
exposure: 'deferred',
|
|
12
|
+
annotations: {
|
|
13
|
+
readOnlyHint: true,
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
openWorldHint: false,
|
|
16
|
+
},
|
|
17
|
+
label: 'Context Stats',
|
|
18
|
+
description: 'Show byte accounting for the local SQLite context sidecar.',
|
|
19
|
+
parameters: Type.Object({
|
|
20
|
+
global: Type.Optional(Type.Boolean({
|
|
21
|
+
description: 'Show stats across all indexed sources instead of current project/session scope.',
|
|
22
|
+
})),
|
|
23
|
+
}),
|
|
24
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
25
|
+
const scope = scope_from_context(ctx);
|
|
26
|
+
const stats = get_context_store(scope).stats(params.global === true ? { global: true } : scope);
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{ type: 'text', text: format_stats(stats) },
|
|
30
|
+
],
|
|
31
|
+
details: stats,
|
|
32
|
+
structuredContent: { ...stats },
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/tools/stats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,2BAA2B,CAAC,EAAgB;IAC3D,EAAE,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,sBAAsB;QACjC,YAAY,EAAE,2BAA2B;QACzC,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE;YACZ,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,KAAK;SACpB;QACD,KAAK,EAAE,eAAe;QACtB,WAAW,EACV,4DAA4D;QAC7D,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACvB,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,OAAO,CAAC;gBACZ,WAAW,EACV,iFAAiF;aAClF,CAAC,CACF;SACD,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG;YACzD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAEtC,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,KAAK,CAC3C,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CACjD,CAAC;YAEF,OAAO;gBACN,OAAO,EAAE;oBACR,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE;iBACpD;gBACD,OAAO,EAAE,KAAK;gBACd,iBAAiB,EAAE,EAAE,GAAG,KAAK,EAAE;aAC/B,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export interface ContextStoreOptions {
|
|
2
|
+
db_path?: string;
|
|
3
|
+
project_path?: string | null;
|
|
4
|
+
session_id?: string | null;
|
|
5
|
+
max_bytes?: number;
|
|
6
|
+
max_lines?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ContextRetentionPolicy {
|
|
9
|
+
retention_days: number | null;
|
|
10
|
+
purge_on_shutdown: boolean;
|
|
11
|
+
max_mb: number | null;
|
|
12
|
+
max_bytes: number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ContextCleanupResult {
|
|
15
|
+
deleted: number;
|
|
16
|
+
age_deleted: number;
|
|
17
|
+
size_deleted: number;
|
|
18
|
+
policy: ContextRetentionPolicy;
|
|
19
|
+
}
|
|
20
|
+
export interface ContextPurgeDetails {
|
|
21
|
+
deleted: number;
|
|
22
|
+
source_id?: string;
|
|
23
|
+
project_path?: string | null;
|
|
24
|
+
session_id?: string | null;
|
|
25
|
+
older_than_days?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface StoreContextInput {
|
|
28
|
+
text: string;
|
|
29
|
+
tool_name: string;
|
|
30
|
+
input_summary?: string | null;
|
|
31
|
+
session_id?: string | null;
|
|
32
|
+
project_path?: string | null;
|
|
33
|
+
force?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface StoredContextOutput {
|
|
36
|
+
source_id: string;
|
|
37
|
+
bytes: number;
|
|
38
|
+
lines: number;
|
|
39
|
+
preview: string;
|
|
40
|
+
receipt: string;
|
|
41
|
+
chunk_count: number;
|
|
42
|
+
first_chunk_id: string | null;
|
|
43
|
+
returned_bytes: number;
|
|
44
|
+
project_path: string | null;
|
|
45
|
+
session_id: string | null;
|
|
46
|
+
deduped?: boolean;
|
|
47
|
+
capture_max_bytes?: number;
|
|
48
|
+
capture_max_lines?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ContextSearchResult {
|
|
51
|
+
source_id: string;
|
|
52
|
+
chunk_id: string;
|
|
53
|
+
ordinal: number;
|
|
54
|
+
title: string | null;
|
|
55
|
+
content: string;
|
|
56
|
+
tool_name: string;
|
|
57
|
+
created_at: number;
|
|
58
|
+
bytes: number;
|
|
59
|
+
lines: number;
|
|
60
|
+
rank: number;
|
|
61
|
+
snippet: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface ContextListResult {
|
|
64
|
+
source_id: string;
|
|
65
|
+
created_at: number;
|
|
66
|
+
project_path: string | null;
|
|
67
|
+
session_id: string | null;
|
|
68
|
+
tool_name: string;
|
|
69
|
+
input_summary: string | null;
|
|
70
|
+
bytes: number;
|
|
71
|
+
lines: number;
|
|
72
|
+
chunk_count: number;
|
|
73
|
+
first_chunk_title: string | null;
|
|
74
|
+
preview: string | null;
|
|
75
|
+
}
|
|
76
|
+
export interface ContextChunkSummary {
|
|
77
|
+
source_id: string;
|
|
78
|
+
chunk_count: number;
|
|
79
|
+
first_chunk_id: string | null;
|
|
80
|
+
last_chunk_id: string | null;
|
|
81
|
+
first_ordinal: number | null;
|
|
82
|
+
last_ordinal: number | null;
|
|
83
|
+
}
|
|
84
|
+
export interface ContextScopeOptions {
|
|
85
|
+
project_path?: string | null;
|
|
86
|
+
session_id?: string | null;
|
|
87
|
+
global?: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface ContextChunkSelectionOptions extends ContextScopeOptions {
|
|
90
|
+
before?: number;
|
|
91
|
+
after?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface ContextStats {
|
|
94
|
+
sources: number;
|
|
95
|
+
chunks: number;
|
|
96
|
+
bytes_stored: number;
|
|
97
|
+
bytes_returned: number;
|
|
98
|
+
bytes_saved: number;
|
|
99
|
+
reduction_pct: number;
|
|
100
|
+
db_bytes: number;
|
|
101
|
+
wal_bytes: number;
|
|
102
|
+
total_bytes: number;
|
|
103
|
+
oldest_created_at: number | null;
|
|
104
|
+
newest_created_at: number | null;
|
|
105
|
+
retention_days: number | null;
|
|
106
|
+
purge_on_shutdown: boolean;
|
|
107
|
+
max_mb: number | null;
|
|
108
|
+
scope_project_path: string | null;
|
|
109
|
+
scope_session_id: string | null;
|
|
110
|
+
global_sources: number;
|
|
111
|
+
global_chunks: number;
|
|
112
|
+
global_bytes_stored: number;
|
|
113
|
+
global_oldest_created_at: number | null;
|
|
114
|
+
global_newest_created_at: number | null;
|
|
115
|
+
}
|
|
116
|
+
export interface SourceRow {
|
|
117
|
+
id: string;
|
|
118
|
+
tool_name: string;
|
|
119
|
+
created_at: number;
|
|
120
|
+
byte_count: number;
|
|
121
|
+
line_count: number;
|
|
122
|
+
}
|
|
123
|
+
export interface SearchRow extends SourceRow {
|
|
124
|
+
chunk_id: string;
|
|
125
|
+
ordinal: number;
|
|
126
|
+
title: string | null;
|
|
127
|
+
content: string;
|
|
128
|
+
rank: number;
|
|
129
|
+
}
|
|
130
|
+
export interface ScopedFilter {
|
|
131
|
+
where: string[];
|
|
132
|
+
params: Array<string | number>;
|
|
133
|
+
}
|
|
134
|
+
export interface ListRow {
|
|
135
|
+
source_id: string;
|
|
136
|
+
created_at: number;
|
|
137
|
+
project_path: string | null;
|
|
138
|
+
session_id: string | null;
|
|
139
|
+
tool_name: string;
|
|
140
|
+
input_summary: string | null;
|
|
141
|
+
byte_count: number;
|
|
142
|
+
line_count: number;
|
|
143
|
+
chunk_count: number;
|
|
144
|
+
first_chunk_title: string | null;
|
|
145
|
+
preview: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface ChunkSummaryRow {
|
|
148
|
+
source_id: string;
|
|
149
|
+
chunk_count: number;
|
|
150
|
+
first_chunk_id: string | null;
|
|
151
|
+
last_chunk_id: string | null;
|
|
152
|
+
first_ordinal: number | null;
|
|
153
|
+
last_ordinal: number | null;
|
|
154
|
+
}
|
|
155
|
+
export interface ContextChunk {
|
|
156
|
+
id: string;
|
|
157
|
+
source_id: string;
|
|
158
|
+
ordinal: number;
|
|
159
|
+
title: string | null;
|
|
160
|
+
content: string;
|
|
161
|
+
byte_count: number;
|
|
162
|
+
}
|
|
163
|
+
export interface ContextExportContent {
|
|
164
|
+
chunks: ContextChunk[];
|
|
165
|
+
content: string;
|
|
166
|
+
verified: boolean | null;
|
|
167
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export declare function show_context_list(ctx: ExtensionCommandContext, limit?: number): Promise<void>;
|
|
3
|
+
export declare function purge_context(ctx: ExtensionCommandContext, options?: {
|
|
4
|
+
older_than_days?: number;
|
|
5
|
+
source_id?: string;
|
|
6
|
+
expired?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function show_context_menu(ctx: ExtensionCommandContext): Promise<void>;
|
package/dist/ui/menu.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { show_confirm_modal, show_picker_modal, } from '@spences10/pi-tui-modal';
|
|
2
|
+
import { format_list_results, format_purge_details, } from '../context-format.js';
|
|
3
|
+
import { scope_from_context } from '../context-scope.js';
|
|
4
|
+
import { get_context_store, } from '../store.js';
|
|
5
|
+
import { show_context_settings, show_context_stats, show_context_text_modal, } from './settings.js';
|
|
6
|
+
export async function show_context_list(ctx, limit) {
|
|
7
|
+
const scope = scope_from_context(ctx);
|
|
8
|
+
const text = format_list_results(get_context_store(scope).list({ ...scope, limit }), { audience: 'tui' });
|
|
9
|
+
if (ctx.hasUI) {
|
|
10
|
+
await show_context_text_modal(ctx, 'Context sidecar sources', text);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
ctx.ui.notify(text, 'info');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function purge_context(ctx, options = {}) {
|
|
17
|
+
const policy = get_context_store().stats();
|
|
18
|
+
const days = options.older_than_days ?? policy.retention_days ?? 14;
|
|
19
|
+
let description;
|
|
20
|
+
if (options.expired)
|
|
21
|
+
description = 'Delete expired context sources now?';
|
|
22
|
+
else
|
|
23
|
+
description = options.source_id
|
|
24
|
+
? `Delete context source ${options.source_id}?`
|
|
25
|
+
: `Delete context sources older than ${days} day(s)?`;
|
|
26
|
+
const confirmed = ctx.hasUI
|
|
27
|
+
? await show_confirm_modal(ctx, {
|
|
28
|
+
title: 'Purge context sidecar?',
|
|
29
|
+
message: description,
|
|
30
|
+
confirm_label: 'Purge',
|
|
31
|
+
})
|
|
32
|
+
: await ctx.ui.confirm('Purge context sidecar?', description);
|
|
33
|
+
if (!confirmed)
|
|
34
|
+
return;
|
|
35
|
+
const scope = scope_from_context(ctx);
|
|
36
|
+
let details;
|
|
37
|
+
if (options.expired)
|
|
38
|
+
details = { deleted: get_context_store(scope).cleanup().deleted };
|
|
39
|
+
else
|
|
40
|
+
details = get_context_store(scope).purge_with_details({
|
|
41
|
+
...scope,
|
|
42
|
+
older_than_days: options.source_id ? undefined : days,
|
|
43
|
+
source_id: options.source_id,
|
|
44
|
+
});
|
|
45
|
+
ctx.ui.notify(format_purge_details(details), 'info');
|
|
46
|
+
}
|
|
47
|
+
export async function show_context_menu(ctx) {
|
|
48
|
+
while (true) {
|
|
49
|
+
const selected = await show_picker_modal(ctx, {
|
|
50
|
+
title: 'Context sidecar',
|
|
51
|
+
subtitle: 'Local SQLite storage for oversized tool output',
|
|
52
|
+
items: [
|
|
53
|
+
{
|
|
54
|
+
value: 'list',
|
|
55
|
+
label: 'List recent sources',
|
|
56
|
+
description: 'Browse indexed output in this scope',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: 'stats',
|
|
60
|
+
label: 'Show stats',
|
|
61
|
+
description: 'Byte accounting and storage reduction',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: 'settings',
|
|
65
|
+
label: 'Configure settings',
|
|
66
|
+
description: 'Configure capture size, retention, and storage cap',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: 'purge',
|
|
70
|
+
label: 'Purge old context',
|
|
71
|
+
description: 'Delete sources older than 14 days',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
footer: 'enter opens • esc close',
|
|
75
|
+
});
|
|
76
|
+
if (!selected)
|
|
77
|
+
return;
|
|
78
|
+
if (selected === 'list')
|
|
79
|
+
await show_context_list(ctx);
|
|
80
|
+
else if (selected === 'stats')
|
|
81
|
+
await show_context_stats(ctx);
|
|
82
|
+
else if (selected === 'settings')
|
|
83
|
+
await show_context_settings(ctx, { nested: true });
|
|
84
|
+
else
|
|
85
|
+
await purge_context(ctx);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/ui/menu.ts"],"names":[],"mappings":"AACA,OAAO,EACN,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,mBAAmB,EACnB,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACN,iBAAiB,GAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,GAA4B,EAC5B,KAAc;IAEd,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAEtC,MAAM,IAAI,GAAG,mBAAmB,CAC/B,iBAAiB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,EAClD,EAAE,QAAQ,EAAE,KAAK,EAAE,CACnB,CAAC;IAEF,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,uBAAuB,CAC5B,GAAG,EACH,yBAAyB,EACzB,IAAI,CACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACP,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,GAA4B,EAC5B,UAII,EAAE;IAEN,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC,KAAK,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,IAA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BAAiB,CAAC,GAAG,EAAE;YAC7C,KAAK,EAAE,iBAAiB;YACxB,QAAQ,EAAE,gDAAgD;YAC1D,KAAK,EAAE;gBACN;oBACC,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE,qBAAqB;oBAC5B,WAAW,EAAE,qCAAqC;iBAClD;gBACD;oBACC,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,YAAY;oBACnB,WAAW,EAAE,uCAAuC;iBACpD;gBACD;oBACC,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE,oBAAoB;oBAC3B,WAAW,EACV,oDAAoD;iBACrD;gBACD;oBACC,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,mBAAmB;oBAC1B,WAAW,EAAE,mCAAmC;iBAChD;aACD;YACD,MAAM,EAAE,yBAAyB;SACjC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,IAAI,QAAQ,KAAK,MAAM;YAAE,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;aACjD,IAAI,QAAQ,KAAK,OAAO;YAAE,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC;aACxD,IAAI,QAAQ,KAAK,UAAU;YAC/B,MAAM,qBAAqB,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;;YAC/C,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export declare function show_context_text_modal(ctx: ExtensionCommandContext, title: string, text: string): Promise<void>;
|
|
3
|
+
export declare function show_context_stats(ctx: ExtensionCommandContext): Promise<void>;
|
|
4
|
+
export declare function show_context_settings(ctx: ExtensionCommandContext, options?: {
|
|
5
|
+
nested?: boolean;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
export declare function handle_context_settings(ctx: ExtensionCommandContext, args: string[]): Promise<void>;
|