@pi-unipi/compactor 2.6.1 → 2.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.
Files changed (44) hide show
  1. package/README.md +5 -4
  2. package/package.json +1 -1
  3. package/skills/compactor/SKILL.md +1 -1
  4. package/skills/compactor-detail/SKILL.md +3 -5
  5. package/skills/compactor-doctor/SKILL.md +1 -1
  6. package/skills/compactor-stats/SKILL.md +1 -1
  7. package/src/commands/index.ts +47 -78
  8. package/src/compaction/brief.ts +161 -90
  9. package/src/compaction/build-sections.ts +3 -4
  10. package/src/compaction/compact-args.ts +86 -0
  11. package/src/compaction/cut.ts +270 -28
  12. package/src/compaction/drill-down.ts +261 -0
  13. package/src/compaction/format-recall.ts +96 -0
  14. package/src/compaction/format.ts +8 -3
  15. package/src/compaction/hooks.ts +248 -72
  16. package/src/compaction/merge.ts +34 -4
  17. package/src/compaction/rank.ts +270 -0
  18. package/src/compaction/recall-scope.ts +28 -0
  19. package/src/compaction/search-entries.ts +333 -96
  20. package/src/compaction/skill-collapse.ts +35 -0
  21. package/src/compaction/summarize.ts +37 -6
  22. package/src/compaction/token-estimate.ts +104 -0
  23. package/src/compaction/touched-files.ts +35 -0
  24. package/src/config/manager.ts +2 -27
  25. package/src/config/presets.ts +0 -2
  26. package/src/config/schema.ts +2 -16
  27. package/src/executor/executor.ts +6 -15
  28. package/src/executor/runtime.ts +2 -12
  29. package/src/index.ts +12 -122
  30. package/src/info-screen.ts +3 -10
  31. package/src/security/evaluator.ts +0 -53
  32. package/src/security/policy.ts +7 -8
  33. package/src/session/db.ts +0 -6
  34. package/src/tools/ctx-execute-file.ts +0 -5
  35. package/src/tools/register.ts +27 -50
  36. package/src/tools/vcc-recall.ts +86 -48
  37. package/src/tui/settings-overlay.ts +20 -40
  38. package/src/types.ts +43 -100
  39. package/src/display/diff-renderer.ts +0 -281
  40. package/src/display/line-width-safety.ts +0 -28
  41. package/src/display/render-utils.ts +0 -52
  42. package/src/display/thinking-label.ts +0 -18
  43. package/src/display/tool-overrides.ts +0 -136
  44. package/src/tools/compact.ts +0 -20
@@ -1,136 +0,0 @@
1
- /**
2
- * Tool override renderers — mode-aware output for built-in tools
3
- */
4
-
5
- import type { OutputMode } from "../types.js";
6
- import { previewLines, countNonEmptyLines, shortenPath } from "./render-utils.js";
7
-
8
- export interface ToolOverrideConfig {
9
- readOutputMode?: OutputMode;
10
- searchOutputMode?: OutputMode;
11
- bashOutputMode?: OutputMode;
12
- previewLines?: number;
13
- bashCollapsedLines?: number;
14
- showTruncationHints?: boolean;
15
- }
16
-
17
- export function renderReadResult(
18
- content: string,
19
- filePath: string,
20
- config: ToolOverrideConfig,
21
- ): string {
22
- switch (config.readOutputMode) {
23
- case "hidden":
24
- return `[Read: ${shortenPath(filePath)}]`;
25
- case "summary":
26
- return `[Read: ${shortenPath(filePath)} — ${countNonEmptyLines(content)} lines]`;
27
- case "preview":
28
- return previewLines(content, config.previewLines ?? 20);
29
- default:
30
- return content;
31
- }
32
- }
33
-
34
- export function renderSearchResult(
35
- results: string,
36
- config: ToolOverrideConfig,
37
- ): string {
38
- switch (config.searchOutputMode) {
39
- case "hidden":
40
- return `[Search results hidden]`;
41
- case "count":
42
- return `[Search: ${countNonEmptyLines(results)} matches]`;
43
- case "preview":
44
- return previewLines(results, config.previewLines ?? 20);
45
- default:
46
- return results;
47
- }
48
- }
49
-
50
- export function renderBashResult(
51
- output: string,
52
- command: string,
53
- config: ToolOverrideConfig,
54
- ): string {
55
- switch (config.bashOutputMode) {
56
- case "hidden":
57
- return `[Bash: ${command.slice(0, 60)}]`;
58
- case "summary":
59
- return `[Bash: ${command.slice(0, 60)} — ${countNonEmptyLines(output)} lines]`;
60
- case "preview":
61
- return previewLines(output, config.bashCollapsedLines ?? 5);
62
- default:
63
- return output;
64
- }
65
- }
66
-
67
- /**
68
- * Apply display overrides for built-in tool results.
69
- * Returns modified event result if override applies, undefined otherwise.
70
- *
71
- * Call this from the `tool_result` event handler to intercept and transform
72
- * tool output before it enters the LLM context.
73
- */
74
- export function applyToolDisplayOverride(
75
- toolName: string,
76
- event: Record<string, unknown>,
77
- config: ToolOverrideConfig,
78
- ): { content?: Array<{ type: string; text: string }> } | undefined {
79
- const content = (event as any).content as Array<{ type: string; text: string }> | undefined;
80
- if (!content || !Array.isArray(content) || content.length === 0) return undefined;
81
-
82
- const textContent = content[0]?.text ?? "";
83
- const previewLinesCount = config.previewLines ?? 20;
84
- const collapsedLines = config.bashCollapsedLines ?? 5;
85
-
86
- let overridden: string | undefined;
87
-
88
- switch (toolName) {
89
- case "read": {
90
- const filePath = String((event as any).args?.path ?? "");
91
- const mode = config.readOutputMode ?? "full";
92
- if (mode === "hidden") {
93
- overridden = `[Read: ${shortenPath(filePath)}]`;
94
- } else if (mode === "summary") {
95
- overridden = `[Read: ${shortenPath(filePath)} — ${countNonEmptyLines(textContent)} lines]`;
96
- } else if (mode === "preview") {
97
- overridden = previewLines(textContent, previewLinesCount);
98
- }
99
- break;
100
- }
101
- case "grep":
102
- case "find":
103
- case "ls": {
104
- const mode = config.searchOutputMode ?? "full";
105
- if (mode === "hidden") {
106
- overridden = `[${toolName} results hidden]`;
107
- } else if (mode === "count") {
108
- overridden = `[${toolName}: ${countNonEmptyLines(textContent)} matches]`;
109
- } else if (mode === "preview") {
110
- overridden = previewLines(textContent, previewLinesCount);
111
- }
112
- break;
113
- }
114
- case "bash": {
115
- const command = String((event as any).args?.command ?? "");
116
- const mode = config.bashOutputMode ?? "full";
117
- if (mode === "hidden") {
118
- overridden = `[Bash: ${command.slice(0, 60)}]`;
119
- } else if (mode === "summary") {
120
- overridden = `[Bash: ${command.slice(0, 60)} — ${countNonEmptyLines(textContent)} lines]`;
121
- } else if (mode === "preview") {
122
- overridden = previewLines(textContent, collapsedLines);
123
- }
124
- break;
125
- }
126
- default:
127
- return undefined;
128
- }
129
-
130
- if (overridden !== undefined) {
131
- return {
132
- content: [{ type: "text", text: overridden }],
133
- };
134
- }
135
- return undefined;
136
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * compact tool — trigger manual compaction with stats
3
- */
4
-
5
- import type { CompactionStats } from "../types.js";
6
-
7
- export interface CompactResult {
8
- success: boolean;
9
- stats?: CompactionStats;
10
- message: string;
11
- }
12
-
13
- export function compactTool(): CompactResult {
14
- // The actual compaction is handled by the session_before_compact hook.
15
- // This tool just signals the intent and returns current stats.
16
- return {
17
- success: true,
18
- message: "Compaction triggered. Stats will be available after next compact event.",
19
- };
20
- }