@monotykamary/pi-vcc 0.3.16

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 (76) hide show
  1. package/README.md +688 -0
  2. package/__tests__/helpers.ts +135 -0
  3. package/__tests__/root-causes.test.ts +858 -0
  4. package/demo.gif +0 -0
  5. package/index.ts +21 -0
  6. package/knip.json +4 -0
  7. package/npm-shrinkwrap.json +3001 -0
  8. package/package.json +36 -0
  9. package/scripts/audit-sessions.ts +88 -0
  10. package/scripts/benchmark-real-sessions.ts +25 -0
  11. package/scripts/compare-before-after.ts +36 -0
  12. package/scripts/dump-branch-output.ts +20 -0
  13. package/src/commands/pi-vcc.ts +36 -0
  14. package/src/commands/vcc-recall.ts +65 -0
  15. package/src/core/brief.ts +497 -0
  16. package/src/core/build-sections.ts +431 -0
  17. package/src/core/content.ts +71 -0
  18. package/src/core/filter-noise.ts +42 -0
  19. package/src/core/format-recall.ts +177 -0
  20. package/src/core/format.ts +98 -0
  21. package/src/core/invisible-continue.ts +172 -0
  22. package/src/core/lineage.ts +26 -0
  23. package/src/core/load-messages.ts +40 -0
  24. package/src/core/normalize.ts +73 -0
  25. package/src/core/recall-scope.ts +49 -0
  26. package/src/core/render-entries.ts +58 -0
  27. package/src/core/report.ts +237 -0
  28. package/src/core/sanitize.ts +5 -0
  29. package/src/core/search-entries.ts +375 -0
  30. package/src/core/settings.ts +190 -0
  31. package/src/core/skill-collapse.ts +35 -0
  32. package/src/core/summarize.ts +179 -0
  33. package/src/core/tool-args.ts +14 -0
  34. package/src/details.ts +19 -0
  35. package/src/extract/commits.ts +69 -0
  36. package/src/extract/goals.ts +79 -0
  37. package/src/extract/preferences.ts +55 -0
  38. package/src/extract/shared-symbols.ts +357 -0
  39. package/src/hooks/before-compact.ts +564 -0
  40. package/src/hooks/proactive-threshold.ts +131 -0
  41. package/src/sections.ts +23 -0
  42. package/src/tools/recall.ts +204 -0
  43. package/src/types.ts +20 -0
  44. package/tests/australian-government.test.ts +479 -0
  45. package/tests/before-compact-hook.test.ts +185 -0
  46. package/tests/before-compact.test.ts +227 -0
  47. package/tests/brief.test.ts +215 -0
  48. package/tests/build-sections.test.ts +59 -0
  49. package/tests/compile.test.ts +89 -0
  50. package/tests/content.test.ts +66 -0
  51. package/tests/deep-extraction.test.ts +313 -0
  52. package/tests/extract-goals.test.ts +86 -0
  53. package/tests/extract-preferences.test.ts +30 -0
  54. package/tests/filter-noise.test.ts +61 -0
  55. package/tests/fixtures.ts +61 -0
  56. package/tests/format-recall.test.ts +87 -0
  57. package/tests/format.test.ts +73 -0
  58. package/tests/government-domain.test.ts +542 -0
  59. package/tests/lineage.test.ts +33 -0
  60. package/tests/load-messages.test.ts +49 -0
  61. package/tests/model-threshold-hook.test.ts +377 -0
  62. package/tests/model-threshold.test.ts +223 -0
  63. package/tests/normalize.test.ts +104 -0
  64. package/tests/proactive-threshold.test.ts +490 -0
  65. package/tests/real-sessions.test.ts +38 -0
  66. package/tests/recall-expand.test.ts +15 -0
  67. package/tests/recall-scope.test.ts +32 -0
  68. package/tests/recall-tool-scope.test.ts +67 -0
  69. package/tests/render-entries.test.ts +92 -0
  70. package/tests/report.test.ts +58 -0
  71. package/tests/sanitize.test.ts +24 -0
  72. package/tests/search-entries.test.ts +233 -0
  73. package/tests/support/load-session.ts +23 -0
  74. package/tests/support/real-sessions.ts +51 -0
  75. package/tests/threshold-integration.test.ts +359 -0
  76. package/tsconfig.json +20 -0
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Helpers for constructing mock session entries and messages.
3
+ *
4
+ * These mirror pi-agent-core types but use loose object shapes
5
+ * so we don't need the actual runtime dependency in tests.
6
+ */
7
+
8
+ export interface MockEntry {
9
+ type: string;
10
+ id?: string;
11
+ message?: {
12
+ role?: string;
13
+ content?: unknown;
14
+ stopReason?: string;
15
+ };
16
+ firstKeptEntryId?: string;
17
+ summary?: string;
18
+ timestamp?: string;
19
+ }
20
+
21
+ let nextId = 1;
22
+
23
+ function makeId(): string {
24
+ return `entry_${nextId++}`;
25
+ }
26
+
27
+ export function resetIds(): void {
28
+ nextId = 1;
29
+ }
30
+
31
+ export function makeUserEntry(
32
+ text: string,
33
+ overrides?: Partial<MockEntry>,
34
+ ): MockEntry {
35
+ const id = makeId();
36
+ return {
37
+ type: "message",
38
+ id,
39
+ message: {
40
+ role: "user",
41
+ content: [{ type: "text", text }],
42
+ },
43
+ ...overrides,
44
+ };
45
+ }
46
+
47
+ export function makeAssistantEntry(
48
+ text: string,
49
+ stopReason = "stop",
50
+ overrides?: Partial<MockEntry>,
51
+ ): MockEntry {
52
+ const id = makeId();
53
+ return {
54
+ type: "message",
55
+ id,
56
+ message: {
57
+ role: "assistant",
58
+ content: [{ type: "text", text }],
59
+ stopReason,
60
+ },
61
+ ...overrides,
62
+ };
63
+ }
64
+
65
+ export function makeToolResultEntry(
66
+ toolCallId: string,
67
+ content: string,
68
+ overrides?: Partial<MockEntry>,
69
+ ): MockEntry {
70
+ const id = makeId();
71
+ return {
72
+ type: "message",
73
+ id,
74
+ message: {
75
+ role: "toolResult",
76
+ content: [{ type: "toolResult", toolCallId, content }],
77
+ },
78
+ ...overrides,
79
+ };
80
+ }
81
+
82
+ export function makeCompactionEntry(
83
+ firstKeptEntryId: string,
84
+ overrides?: Partial<MockEntry>,
85
+ ): MockEntry {
86
+ const id = makeId();
87
+ return {
88
+ type: "compaction",
89
+ id,
90
+ firstKeptEntryId,
91
+ summary: "Compaction summary",
92
+ ...overrides,
93
+ };
94
+ }
95
+
96
+ /**
97
+ * Build a context snapshot dict matching Agent.state.messages shape.
98
+ * Used for testing the "continue from assistant message" scenarios.
99
+ */
100
+ export interface ContextMessage {
101
+ role: string;
102
+ content: unknown;
103
+ stopReason?: string;
104
+ }
105
+
106
+ export function makeContextMessages(
107
+ ...msgs: ContextMessage[]
108
+ ): ContextMessage[] {
109
+ return msgs;
110
+ }
111
+
112
+ export function userMsg(text: string): ContextMessage {
113
+ return { role: "user", content: [{ type: "text", text }] };
114
+ }
115
+
116
+ export function assistantMsg(
117
+ text: string,
118
+ stopReason = "stop",
119
+ ): ContextMessage {
120
+ return { role: "assistant", content: [{ type: "text", text }], stopReason };
121
+ }
122
+
123
+ export function toolResultMsg(
124
+ toolCallId: string,
125
+ content: string,
126
+ ): ContextMessage {
127
+ return {
128
+ role: "toolResult",
129
+ content: [{ type: "toolResult", toolCallId, content }],
130
+ };
131
+ }
132
+
133
+ export function compactionSummaryMsg(summary: string): ContextMessage {
134
+ return { role: "user", content: [{ type: "compactionSummary", text: summary }] };
135
+ }