@tuanhung303/opencode-acp 0.0.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.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +79 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/commands/budget.d.ts +15 -0
  8. package/dist/lib/commands/budget.d.ts.map +1 -0
  9. package/dist/lib/commands/budget.js +120 -0
  10. package/dist/lib/commands/budget.js.map +1 -0
  11. package/dist/lib/commands/context.d.ts +49 -0
  12. package/dist/lib/commands/context.d.ts.map +1 -0
  13. package/dist/lib/commands/context.js +191 -0
  14. package/dist/lib/commands/context.js.map +1 -0
  15. package/dist/lib/commands/help.d.ts +15 -0
  16. package/dist/lib/commands/help.d.ts.map +1 -0
  17. package/dist/lib/commands/help.js +28 -0
  18. package/dist/lib/commands/help.js.map +1 -0
  19. package/dist/lib/commands/protected.d.ts +17 -0
  20. package/dist/lib/commands/protected.d.ts.map +1 -0
  21. package/dist/lib/commands/protected.js +50 -0
  22. package/dist/lib/commands/protected.js.map +1 -0
  23. package/dist/lib/commands/stats.d.ts +15 -0
  24. package/dist/lib/commands/stats.d.ts.map +1 -0
  25. package/dist/lib/commands/stats.js +64 -0
  26. package/dist/lib/commands/stats.js.map +1 -0
  27. package/dist/lib/commands/sweep.d.ts +23 -0
  28. package/dist/lib/commands/sweep.d.ts.map +1 -0
  29. package/dist/lib/commands/sweep.js +194 -0
  30. package/dist/lib/commands/sweep.js.map +1 -0
  31. package/dist/lib/config-schema.d.ts +119 -0
  32. package/dist/lib/config-schema.d.ts.map +1 -0
  33. package/dist/lib/config-schema.js +97 -0
  34. package/dist/lib/config-schema.js.map +1 -0
  35. package/dist/lib/config.d.ts +59 -0
  36. package/dist/lib/config.d.ts.map +1 -0
  37. package/dist/lib/config.js +426 -0
  38. package/dist/lib/config.js.map +1 -0
  39. package/dist/lib/hooks.d.ts +31 -0
  40. package/dist/lib/hooks.d.ts.map +1 -0
  41. package/dist/lib/hooks.js +230 -0
  42. package/dist/lib/hooks.js.map +1 -0
  43. package/dist/lib/logger.d.ts +55 -0
  44. package/dist/lib/logger.d.ts.map +1 -0
  45. package/dist/lib/logger.js +230 -0
  46. package/dist/lib/logger.js.map +1 -0
  47. package/dist/lib/messages/index.d.ts +3 -0
  48. package/dist/lib/messages/index.d.ts.map +1 -0
  49. package/dist/lib/messages/index.js +3 -0
  50. package/dist/lib/messages/index.js.map +1 -0
  51. package/dist/lib/messages/inject.d.ts +10 -0
  52. package/dist/lib/messages/inject.d.ts.map +1 -0
  53. package/dist/lib/messages/inject.js +10 -0
  54. package/dist/lib/messages/inject.js.map +1 -0
  55. package/dist/lib/messages/prune.d.ts +13 -0
  56. package/dist/lib/messages/prune.d.ts.map +1 -0
  57. package/dist/lib/messages/prune.js +173 -0
  58. package/dist/lib/messages/prune.js.map +1 -0
  59. package/dist/lib/messages/utils.d.ts +43 -0
  60. package/dist/lib/messages/utils.d.ts.map +1 -0
  61. package/dist/lib/messages/utils.js +262 -0
  62. package/dist/lib/messages/utils.js.map +1 -0
  63. package/dist/lib/prompts/discard-tool-spec.d.ts +2 -0
  64. package/dist/lib/prompts/discard-tool-spec.d.ts.map +1 -0
  65. package/dist/lib/prompts/discard-tool-spec.js +54 -0
  66. package/dist/lib/prompts/discard-tool-spec.js.map +1 -0
  67. package/dist/lib/prompts/extract-tool-spec.d.ts +2 -0
  68. package/dist/lib/prompts/extract-tool-spec.d.ts.map +1 -0
  69. package/dist/lib/prompts/extract-tool-spec.js +56 -0
  70. package/dist/lib/prompts/extract-tool-spec.js.map +1 -0
  71. package/dist/lib/prompts/index.d.ts +2 -0
  72. package/dist/lib/prompts/index.d.ts.map +1 -0
  73. package/dist/lib/prompts/index.js +29 -0
  74. package/dist/lib/prompts/index.js.map +1 -0
  75. package/dist/lib/prompts/restore-tool-spec.d.ts +2 -0
  76. package/dist/lib/prompts/restore-tool-spec.d.ts.map +1 -0
  77. package/dist/lib/prompts/restore-tool-spec.js +37 -0
  78. package/dist/lib/prompts/restore-tool-spec.js.map +1 -0
  79. package/dist/lib/prompts/system/both.d.ts +2 -0
  80. package/dist/lib/prompts/system/both.d.ts.map +1 -0
  81. package/dist/lib/prompts/system/both.js +65 -0
  82. package/dist/lib/prompts/system/both.js.map +1 -0
  83. package/dist/lib/prompts/system/discard.d.ts +2 -0
  84. package/dist/lib/prompts/system/discard.d.ts.map +1 -0
  85. package/dist/lib/prompts/system/discard.js +55 -0
  86. package/dist/lib/prompts/system/discard.js.map +1 -0
  87. package/dist/lib/prompts/system/extract.d.ts +2 -0
  88. package/dist/lib/prompts/system/extract.d.ts.map +1 -0
  89. package/dist/lib/prompts/system/extract.js +55 -0
  90. package/dist/lib/prompts/system/extract.js.map +1 -0
  91. package/dist/lib/protected-file-patterns.d.ts +12 -0
  92. package/dist/lib/protected-file-patterns.d.ts.map +1 -0
  93. package/dist/lib/protected-file-patterns.js +69 -0
  94. package/dist/lib/protected-file-patterns.js.map +1 -0
  95. package/dist/lib/safe-execute.d.ts +20 -0
  96. package/dist/lib/safe-execute.d.ts.map +1 -0
  97. package/dist/lib/safe-execute.js +38 -0
  98. package/dist/lib/safe-execute.js.map +1 -0
  99. package/dist/lib/shared-utils.d.ts +4 -0
  100. package/dist/lib/shared-utils.d.ts.map +1 -0
  101. package/dist/lib/shared-utils.js +14 -0
  102. package/dist/lib/shared-utils.js.map +1 -0
  103. package/dist/lib/state/index.d.ts +4 -0
  104. package/dist/lib/state/index.d.ts.map +1 -0
  105. package/dist/lib/state/index.js +4 -0
  106. package/dist/lib/state/index.js.map +1 -0
  107. package/dist/lib/state/persistence.d.ts +27 -0
  108. package/dist/lib/state/persistence.d.ts.map +1 -0
  109. package/dist/lib/state/persistence.js +165 -0
  110. package/dist/lib/state/persistence.js.map +1 -0
  111. package/dist/lib/state/state.d.ts +8 -0
  112. package/dist/lib/state/state.d.ts.map +1 -0
  113. package/dist/lib/state/state.js +166 -0
  114. package/dist/lib/state/state.js.map +1 -0
  115. package/dist/lib/state/tool-cache.d.ts +15 -0
  116. package/dist/lib/state/tool-cache.d.ts.map +1 -0
  117. package/dist/lib/state/tool-cache.js +99 -0
  118. package/dist/lib/state/tool-cache.js.map +1 -0
  119. package/dist/lib/state/types.d.ts +83 -0
  120. package/dist/lib/state/types.d.ts.map +1 -0
  121. package/dist/lib/state/types.js +2 -0
  122. package/dist/lib/state/types.js.map +1 -0
  123. package/dist/lib/state/utils.d.ts +2 -0
  124. package/dist/lib/state/utils.d.ts.map +1 -0
  125. package/dist/lib/state/utils.js +10 -0
  126. package/dist/lib/state/utils.js.map +1 -0
  127. package/dist/lib/strategies/deduplication.d.ts +11 -0
  128. package/dist/lib/strategies/deduplication.d.ts.map +1 -0
  129. package/dist/lib/strategies/deduplication.js +178 -0
  130. package/dist/lib/strategies/deduplication.js.map +1 -0
  131. package/dist/lib/strategies/index.d.ts +5 -0
  132. package/dist/lib/strategies/index.d.ts.map +1 -0
  133. package/dist/lib/strategies/index.js +5 -0
  134. package/dist/lib/strategies/index.js.map +1 -0
  135. package/dist/lib/strategies/purge-errors.d.ts +13 -0
  136. package/dist/lib/strategies/purge-errors.d.ts.map +1 -0
  137. package/dist/lib/strategies/purge-errors.js +62 -0
  138. package/dist/lib/strategies/purge-errors.js.map +1 -0
  139. package/dist/lib/strategies/supersede-writes.d.ts +13 -0
  140. package/dist/lib/strategies/supersede-writes.d.ts.map +1 -0
  141. package/dist/lib/strategies/supersede-writes.js +90 -0
  142. package/dist/lib/strategies/supersede-writes.js.map +1 -0
  143. package/dist/lib/strategies/tools.d.ts +15 -0
  144. package/dist/lib/strategies/tools.d.ts.map +1 -0
  145. package/dist/lib/strategies/tools.js +288 -0
  146. package/dist/lib/strategies/tools.js.map +1 -0
  147. package/dist/lib/strategies/utils.d.ts +11 -0
  148. package/dist/lib/strategies/utils.d.ts.map +1 -0
  149. package/dist/lib/strategies/utils.js +75 -0
  150. package/dist/lib/strategies/utils.js.map +1 -0
  151. package/dist/lib/ui/notification.d.ts +12 -0
  152. package/dist/lib/ui/notification.d.ts.map +1 -0
  153. package/dist/lib/ui/notification.js +81 -0
  154. package/dist/lib/ui/notification.js.map +1 -0
  155. package/dist/lib/ui/utils.d.ts +10 -0
  156. package/dist/lib/ui/utils.d.ts.map +1 -0
  157. package/dist/lib/ui/utils.js +113 -0
  158. package/dist/lib/ui/utils.js.map +1 -0
  159. package/package.json +62 -0
@@ -0,0 +1,173 @@
1
+ import { isMessageCompacted } from "../shared-utils";
2
+ const PRUNED_TOOL_ERROR_INPUT_REPLACEMENT = "[input removed due to failed tool call]";
3
+ const PRUNED_QUESTION_INPUT_REPLACEMENT = "[questions removed - see output for user's answers]";
4
+ /**
5
+ * Injects hash identifiers into tool outputs for hash-based discarding.
6
+ * Format: #x_xxxxx#\n<original output>
7
+ *
8
+ * This allows agents to reference tools by their stable hash when discarding,
9
+ * eliminating the need for a separate prunable-tools list.
10
+ */
11
+ export const injectHashesIntoToolOutputs = (state, config, messages, logger) => {
12
+ const protectedTools = config.tools.settings.protectedTools;
13
+ for (const msg of messages) {
14
+ if (isMessageCompacted(state, msg)) {
15
+ continue;
16
+ }
17
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
18
+ for (const part of parts) {
19
+ if (part.type !== "tool" || !part.callID) {
20
+ continue;
21
+ }
22
+ // Skip protected tools - they don't get hashes
23
+ if (protectedTools.includes(part.tool)) {
24
+ continue;
25
+ }
26
+ // Skip if already pruned
27
+ if (state.prune.toolIds.includes(part.callID)) {
28
+ continue;
29
+ }
30
+ // Only inject into completed tools that have output
31
+ if (part.state.status !== "completed") {
32
+ continue;
33
+ }
34
+ const hash = state.callIdToHash.get(part.callID);
35
+ if (!hash) {
36
+ continue;
37
+ }
38
+ // Skip if already has hash prefix
39
+ if (part.state.output?.startsWith("#")) {
40
+ continue;
41
+ }
42
+ // Prepend hash to output
43
+ if (part.state.output) {
44
+ part.state.output = `${hash}\n${part.state.output}`;
45
+ logger.debug(`Injected hash ${hash} into ${part.tool} output`);
46
+ }
47
+ }
48
+ }
49
+ };
50
+ /**
51
+ * Creates a compact breadcrumb string for pruned tool outputs.
52
+ * Format: [Output removed...] tool({param: "value"}) → status
53
+ *
54
+ * This preserves key metadata so the agent can understand what was pruned
55
+ * without needing to re-read the content.
56
+ */
57
+ const createPrunedOutputBreadcrumb = (tool, input, status) => {
58
+ let paramsStr = "";
59
+ if (input && typeof input === "object") {
60
+ // Extract key parameters for common tools
61
+ const keyParams = {
62
+ read: ["filePath"],
63
+ write: ["filePath"],
64
+ edit: ["filePath"],
65
+ glob: ["pattern", "path"],
66
+ grep: ["pattern", "include", "path"],
67
+ bash: ["command", "description"],
68
+ webfetch: ["url"],
69
+ task: ["description"],
70
+ };
71
+ const relevantKeys = keyParams[tool] || Object.keys(input).slice(0, 2);
72
+ const params = [];
73
+ for (const key of relevantKeys) {
74
+ if (input[key] !== undefined) {
75
+ const value = input[key];
76
+ if (typeof value === "string") {
77
+ // Truncate long strings
78
+ const truncated = value.length > 50 ? value.slice(0, 47) + "..." : value;
79
+ params.push(`${key}: "${truncated}"`);
80
+ }
81
+ else if (typeof value === "number" || typeof value === "boolean") {
82
+ params.push(`${key}: ${value}`);
83
+ }
84
+ }
85
+ }
86
+ if (params.length > 0) {
87
+ paramsStr = `{${params.join(", ")}}`;
88
+ }
89
+ }
90
+ return `[Output removed to save context - information superseded or no longer needed]\n${tool}(${paramsStr}) → ${status}`;
91
+ };
92
+ export const prune = (state, logger, config, messages) => {
93
+ pruneToolOutputs(state, logger, messages);
94
+ pruneToolInputs(state, logger, messages);
95
+ pruneToolErrors(state, logger, messages);
96
+ };
97
+ const pruneToolOutputs = (state, logger, messages) => {
98
+ for (const msg of messages) {
99
+ if (isMessageCompacted(state, msg)) {
100
+ continue;
101
+ }
102
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
103
+ for (const part of parts) {
104
+ if (part.type !== "tool") {
105
+ continue;
106
+ }
107
+ if (!state.prune.toolIds.includes(part.callID)) {
108
+ continue;
109
+ }
110
+ if (part.state.status !== "completed") {
111
+ continue;
112
+ }
113
+ if (part.tool === "question") {
114
+ continue;
115
+ }
116
+ part.state.output = createPrunedOutputBreadcrumb(part.tool, part.state.input, part.state.status);
117
+ }
118
+ }
119
+ };
120
+ const pruneToolInputs = (state, logger, messages) => {
121
+ for (const msg of messages) {
122
+ if (isMessageCompacted(state, msg)) {
123
+ continue;
124
+ }
125
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
126
+ for (const part of parts) {
127
+ if (part.type !== "tool") {
128
+ continue;
129
+ }
130
+ if (!state.prune.toolIds.includes(part.callID)) {
131
+ continue;
132
+ }
133
+ if (part.state.status !== "completed") {
134
+ continue;
135
+ }
136
+ if (part.tool !== "question") {
137
+ continue;
138
+ }
139
+ if (part.state.input?.questions !== undefined) {
140
+ part.state.input.questions = PRUNED_QUESTION_INPUT_REPLACEMENT;
141
+ }
142
+ }
143
+ }
144
+ };
145
+ const pruneToolErrors = (state, logger, messages) => {
146
+ for (const msg of messages) {
147
+ if (isMessageCompacted(state, msg)) {
148
+ continue;
149
+ }
150
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
151
+ for (const part of parts) {
152
+ if (part.type !== "tool") {
153
+ continue;
154
+ }
155
+ if (!state.prune.toolIds.includes(part.callID)) {
156
+ continue;
157
+ }
158
+ if (part.state.status !== "error") {
159
+ continue;
160
+ }
161
+ // Prune all string inputs for errored tools
162
+ const input = part.state.input;
163
+ if (input && typeof input === "object") {
164
+ for (const key of Object.keys(input)) {
165
+ if (typeof input[key] === "string") {
166
+ input[key] = PRUNED_TOOL_ERROR_INPUT_REPLACEMENT;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ };
173
+ //# sourceMappingURL=prune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings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AC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC7C,SAAQ;YACZ,CAAC;YACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAChC,SAAQ;YACZ,CAAC;YAED,4CAA4C;YAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;YAC9B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnC,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;wBACjC,KAAK,CAAC,GAAG,CAAC,GAAG,mCAAmC,CAAA;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { Logger } from "../logger";
2
+ import type { SessionState, WithParts } from "../state";
3
+ /**
4
+ * Stable JSON stringify with sorted keys for deterministic hashing.
5
+ * Ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
6
+ */
7
+ export declare function stableStringify(obj: unknown): string;
8
+ /**
9
+ * Generate a short, stable hash for a tool call.
10
+ * Format: #x_xxxxx# (e.g., #r_a1b2c#)
11
+ * - First char is tool prefix (first letter of tool name)
12
+ * - 5 hex chars from SHA256 hash of stable-stringified params
13
+ */
14
+ export declare function generateToolHash(tool: string, params: unknown): string;
15
+ export declare const isDeepSeekOrKimi: (providerID: string, modelID: string) => boolean;
16
+ export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
17
+ export declare const createSyntheticAssistantMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
18
+ export declare const createSyntheticToolPart: (baseMessage: WithParts, content: string) => {
19
+ id: string;
20
+ sessionID: string;
21
+ messageID: string;
22
+ type: "tool";
23
+ callID: string;
24
+ tool: string;
25
+ state: {
26
+ status: "completed";
27
+ input: {};
28
+ output: string;
29
+ title: string;
30
+ metadata: {};
31
+ time: {
32
+ start: number;
33
+ end: number;
34
+ };
35
+ };
36
+ };
37
+ /**
38
+ * Extracts a human-readable key from tool metadata for display purposes.
39
+ */
40
+ export declare const extractParameterKey: (tool: string, parameters: any) => string;
41
+ export declare function buildToolIdList(state: SessionState, messages: WithParts[], logger: Logger): string[];
42
+ export declare const isIgnoredUserMessage: (message: WithParts) => boolean;
43
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKvD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAqBpD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAKtE;AAID,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,EAAE,SAAS,MAAM,KAAG,OAStE,CAAA;AAED,eAAO,MAAM,0BAA0B,GACnC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,UAAU,MAAM,KACjB,SAwBF,CAAA;AAED,eAAO,MAAM,+BAA+B,GACxC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,UAAU,MAAM,KACjB,SAiCF,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,aAAa,SAAS,EAAE,SAAS,MAAM;;;;;;;;;;;;;;;;;;CAoB9E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,EAAE,YAAY,GAAG,KAAG,MAkHnE,CAAA;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,MAAM,GACf,MAAM,EAAE,CAgBV;AAED,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,KAAG,OAazD,CAAA"}
@@ -0,0 +1,262 @@
1
+ import { createHash } from "crypto";
2
+ import { isMessageCompacted } from "../shared-utils";
3
+ const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
4
+ /**
5
+ * Stable JSON stringify with sorted keys for deterministic hashing.
6
+ * Ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
7
+ */
8
+ export function stableStringify(obj) {
9
+ if (obj === null || obj === undefined) {
10
+ return JSON.stringify(obj);
11
+ }
12
+ if (typeof obj !== "object") {
13
+ return JSON.stringify(obj);
14
+ }
15
+ if (Array.isArray(obj)) {
16
+ return "[" + obj.map(stableStringify).join(",") + "]";
17
+ }
18
+ const keys = Object.keys(obj).sort();
19
+ return ("{" +
20
+ keys
21
+ .map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`)
22
+ .join(",") +
23
+ "}");
24
+ }
25
+ /**
26
+ * Generate a short, stable hash for a tool call.
27
+ * Format: #x_xxxxx# (e.g., #r_a1b2c#)
28
+ * - First char is tool prefix (first letter of tool name)
29
+ * - 5 hex chars from SHA256 hash of stable-stringified params
30
+ */
31
+ export function generateToolHash(tool, params) {
32
+ const prefix = (tool[0] ?? "x").toLowerCase();
33
+ const paramsStr = stableStringify(params);
34
+ const hash = createHash("sha256").update(paramsStr).digest("hex").substring(0, 5);
35
+ return `#${prefix}_${hash}#`;
36
+ }
37
+ const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
38
+ const SYNTHETIC_CALL_ID = "call_01234567890123456789012345";
39
+ export const isDeepSeekOrKimi = (providerID, modelID) => {
40
+ const lowerProviderID = providerID.toLowerCase();
41
+ const lowerModelID = modelID.toLowerCase();
42
+ return (lowerProviderID.includes("deepseek") ||
43
+ lowerProviderID.includes("kimi") ||
44
+ lowerModelID.includes("deepseek") ||
45
+ lowerModelID.includes("kimi"));
46
+ };
47
+ export const createSyntheticUserMessage = (baseMessage, content, variant) => {
48
+ const userInfo = baseMessage.info;
49
+ const now = Date.now();
50
+ return {
51
+ info: {
52
+ id: SYNTHETIC_MESSAGE_ID,
53
+ sessionID: userInfo.sessionID,
54
+ role: "user",
55
+ agent: userInfo.agent || "code",
56
+ model: userInfo.model,
57
+ time: { created: now },
58
+ ...(variant !== undefined && { variant }),
59
+ },
60
+ parts: [
61
+ {
62
+ id: SYNTHETIC_PART_ID,
63
+ sessionID: userInfo.sessionID,
64
+ messageID: SYNTHETIC_MESSAGE_ID,
65
+ type: "text",
66
+ text: content,
67
+ },
68
+ ],
69
+ };
70
+ };
71
+ export const createSyntheticAssistantMessage = (baseMessage, content, variant) => {
72
+ const userInfo = baseMessage.info;
73
+ const now = Date.now();
74
+ return {
75
+ info: {
76
+ id: SYNTHETIC_MESSAGE_ID,
77
+ sessionID: userInfo.sessionID,
78
+ role: "assistant",
79
+ agent: userInfo.agent || "code",
80
+ parentID: userInfo.id,
81
+ modelID: userInfo.model.modelID,
82
+ providerID: userInfo.model.providerID,
83
+ mode: "default",
84
+ path: {
85
+ cwd: "/",
86
+ root: "/",
87
+ },
88
+ time: { created: now, completed: now },
89
+ cost: 0,
90
+ tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
91
+ ...(variant !== undefined && { variant }),
92
+ },
93
+ parts: [
94
+ {
95
+ id: SYNTHETIC_PART_ID,
96
+ sessionID: userInfo.sessionID,
97
+ messageID: SYNTHETIC_MESSAGE_ID,
98
+ type: "text",
99
+ text: content,
100
+ },
101
+ ],
102
+ };
103
+ };
104
+ export const createSyntheticToolPart = (baseMessage, content) => {
105
+ const userInfo = baseMessage.info;
106
+ const now = Date.now();
107
+ return {
108
+ id: SYNTHETIC_PART_ID,
109
+ sessionID: userInfo.sessionID,
110
+ messageID: baseMessage.info.id,
111
+ type: "tool",
112
+ callID: SYNTHETIC_CALL_ID,
113
+ tool: "context_info",
114
+ state: {
115
+ status: "completed",
116
+ input: {},
117
+ output: content,
118
+ title: "Context Info",
119
+ metadata: {},
120
+ time: { start: now, end: now },
121
+ },
122
+ };
123
+ };
124
+ /**
125
+ * Extracts a human-readable key from tool metadata for display purposes.
126
+ */
127
+ export const extractParameterKey = (tool, parameters) => {
128
+ if (!parameters)
129
+ return "";
130
+ if (tool === "read" && parameters.filePath) {
131
+ const offset = parameters.offset;
132
+ const limit = parameters.limit;
133
+ if (offset !== undefined && limit !== undefined) {
134
+ return `${parameters.filePath} (lines ${offset}-${offset + limit})`;
135
+ }
136
+ if (offset !== undefined) {
137
+ return `${parameters.filePath} (lines ${offset}+)`;
138
+ }
139
+ if (limit !== undefined) {
140
+ return `${parameters.filePath} (lines 0-${limit})`;
141
+ }
142
+ return parameters.filePath;
143
+ }
144
+ if (tool === "write" && parameters.filePath) {
145
+ return parameters.filePath;
146
+ }
147
+ if (tool === "edit" && parameters.filePath) {
148
+ return parameters.filePath;
149
+ }
150
+ if (tool === "list") {
151
+ return parameters.path || "(current directory)";
152
+ }
153
+ if (tool === "glob") {
154
+ if (parameters.pattern) {
155
+ const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
156
+ return `"${parameters.pattern}"${pathInfo}`;
157
+ }
158
+ return "(unknown pattern)";
159
+ }
160
+ if (tool === "grep") {
161
+ if (parameters.pattern) {
162
+ const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
163
+ return `"${parameters.pattern}"${pathInfo}`;
164
+ }
165
+ return "(unknown pattern)";
166
+ }
167
+ if (tool === "bash") {
168
+ if (parameters.description)
169
+ return parameters.description;
170
+ if (parameters.command) {
171
+ return parameters.command.length > 50
172
+ ? parameters.command.substring(0, 50) + "..."
173
+ : parameters.command;
174
+ }
175
+ }
176
+ if (tool === "webfetch" && parameters.url) {
177
+ return parameters.url;
178
+ }
179
+ if (tool === "websearch" && parameters.query) {
180
+ return `"${parameters.query}"`;
181
+ }
182
+ if (tool === "codesearch" && parameters.query) {
183
+ return `"${parameters.query}"`;
184
+ }
185
+ if (tool === "todowrite") {
186
+ return `${parameters.todos?.length || 0} todos`;
187
+ }
188
+ if (tool === "todoread") {
189
+ return "read todo list";
190
+ }
191
+ if (tool === "task" && parameters.description) {
192
+ return parameters.description;
193
+ }
194
+ if (tool === "skill" && parameters.name) {
195
+ return parameters.name;
196
+ }
197
+ if (tool === "lsp") {
198
+ const op = parameters.operation || "lsp";
199
+ const path = parameters.filePath || "";
200
+ const line = parameters.line;
201
+ const char = parameters.character;
202
+ if (path && line !== undefined && char !== undefined) {
203
+ return `${op} ${path}:${line}:${char}`;
204
+ }
205
+ if (path) {
206
+ return `${op} ${path}`;
207
+ }
208
+ return op;
209
+ }
210
+ if (tool === "question") {
211
+ const questions = parameters.questions;
212
+ if (Array.isArray(questions) && questions.length > 0) {
213
+ const headers = questions
214
+ .map((q) => q.header || "")
215
+ .filter(Boolean)
216
+ .slice(0, 3);
217
+ const count = questions.length;
218
+ const plural = count > 1 ? "s" : "";
219
+ if (headers.length > 0) {
220
+ const suffix = count > 3 ? ` (+${count - 3} more)` : "";
221
+ return `${count} question${plural}: ${headers.join(", ")}${suffix}`;
222
+ }
223
+ return `${count} question${plural}`;
224
+ }
225
+ return "question";
226
+ }
227
+ const paramStr = JSON.stringify(parameters);
228
+ if (paramStr === "{}" || paramStr === "[]" || paramStr === "null") {
229
+ return "";
230
+ }
231
+ return paramStr.substring(0, 50);
232
+ };
233
+ export function buildToolIdList(state, messages, logger) {
234
+ const toolIds = [];
235
+ for (const msg of messages) {
236
+ if (isMessageCompacted(state, msg)) {
237
+ continue;
238
+ }
239
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
240
+ if (parts.length > 0) {
241
+ for (const part of parts) {
242
+ if (part.type === "tool" && part.callID && part.tool) {
243
+ toolIds.push(part.callID);
244
+ }
245
+ }
246
+ }
247
+ }
248
+ return toolIds;
249
+ }
250
+ export const isIgnoredUserMessage = (message) => {
251
+ const parts = Array.isArray(message.parts) ? message.parts : [];
252
+ if (parts.length === 0) {
253
+ return true;
254
+ }
255
+ for (const part of parts) {
256
+ if (!part.ignored) {
257
+ return false;
258
+ }
259
+ }
260
+ return true;
261
+ };
262
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,oBAAoB,GAAG,gCAAgC,CAAA;AAE7D;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IACxC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACzD,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,OAAO,CACH,GAAG;QACH,IAAI;aACC,GAAG,CACA,CAAC,CAAC,EAAE,EAAE,CACF,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAE,GAA+B,CAAC,CAAC,CAAC,CAAC,EAAE,CACrF;aACA,IAAI,CAAC,GAAG,CAAC;QACd,GAAG,CACN,CAAA;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UA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,MAAM,CAAC,CAAA;gBAC7B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAkB,EAAW,EAAE;IAChE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,CAAE,IAAY,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const DISCARD_TOOL_SPEC = "Discards tool outputs from context to manage conversation size and reduce noise.\n\n## How It Works\n\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to discard specific tool outputs when they are no longer needed.\n\n## When to Use This Tool\n\nUse `discard` for removing tool content that is no longer needed:\n\n- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.\n- **Task Completion:** Work is complete and there's no valuable information worth preserving.\n\n## When NOT to Use This Tool\n\n- **If the output contains useful information:** Keep it in context rather than discarding.\n- **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.\n\n## Best Practices\n- **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.\n- **Think ahead:** Before discarding, ask: \"Will I need this output for an upcoming task?\" If yes, keep it.\n\n## Parameters\n\n- `reason` (required): Why you're discarding. One of:\n - `noise` - Irrelevant or unhelpful output\n - `completion` - Task done, no longer needed\n - `superseded` - Newer output replaces this\n - `exploration` - Dead-end investigation\n - `duplicate` - Same content read multiple times\n\n- `hashes` (required): Array of hash strings from tool outputs (e.g., [\"#r_a1b2c#\", \"#g_d4e5f#\"])\n\n## Examples\n\n<example_single>\nTool output shows:\n#r_a1b2c#\n<file content...>\n\nTo discard: discard({hashes: [\"#r_a1b2c#\"], reason: \"noise\"})\n</example_single>\n\n<example_multiple>\nMultiple tools to discard after task completion:\ndiscard({hashes: [\"#r_a1b2c#\", \"#g_d4e5f#\", \"#b_12345#\"], reason: \"completion\"})\n</example_multiple>\n\n<example_exploration>\nAfter exploring files that weren't useful:\ndiscard({hashes: [\"#r_abc12#\", \"#r_def34#\"], reason: \"exploration\"})\n</example_exploration>";
2
+ //# sourceMappingURL=discard-tool-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discard-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,0hEAoDP,CAAA"}
@@ -0,0 +1,54 @@
1
+ export const DISCARD_TOOL_SPEC = `Discards tool outputs from context to manage conversation size and reduce noise.
2
+
3
+ ## How It Works
4
+
5
+ Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
6
+ Use these hashes to discard specific tool outputs when they are no longer needed.
7
+
8
+ ## When to Use This Tool
9
+
10
+ Use \`discard\` for removing tool content that is no longer needed:
11
+
12
+ - **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
13
+ - **Task Completion:** Work is complete and there's no valuable information worth preserving.
14
+
15
+ ## When NOT to Use This Tool
16
+
17
+ - **If the output contains useful information:** Keep it in context rather than discarding.
18
+ - **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.
19
+
20
+ ## Best Practices
21
+ - **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.
22
+ - **Think ahead:** Before discarding, ask: "Will I need this output for an upcoming task?" If yes, keep it.
23
+
24
+ ## Parameters
25
+
26
+ - \`reason\` (required): Why you're discarding. One of:
27
+ - \`noise\` - Irrelevant or unhelpful output
28
+ - \`completion\` - Task done, no longer needed
29
+ - \`superseded\` - Newer output replaces this
30
+ - \`exploration\` - Dead-end investigation
31
+ - \`duplicate\` - Same content read multiple times
32
+
33
+ - \`hashes\` (required): Array of hash strings from tool outputs (e.g., ["#r_a1b2c#", "#g_d4e5f#"])
34
+
35
+ ## Examples
36
+
37
+ <example_single>
38
+ Tool output shows:
39
+ #r_a1b2c#
40
+ <file content...>
41
+
42
+ To discard: discard({hashes: ["#r_a1b2c#"], reason: "noise"})
43
+ </example_single>
44
+
45
+ <example_multiple>
46
+ Multiple tools to discard after task completion:
47
+ discard({hashes: ["#r_a1b2c#", "#g_d4e5f#", "#b_12345#"], reason: "completion"})
48
+ </example_multiple>
49
+
50
+ <example_exploration>
51
+ After exploring files that weren't useful:
52
+ discard({hashes: ["#r_abc12#", "#r_def34#"], reason: "exploration"})
53
+ </example_exploration>`;
54
+ //# sourceMappingURL=discard-tool-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discard-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAoDV,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const EXTRACT_TOOL_SPEC = "Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.\n\n## How It Works\n\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to extract and distill specific tool outputs.\n\n## When to Use This Tool\n\nUse `extract` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:\n\n- **Task Completion:** You completed a unit of work and want to preserve key findings.\n- **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.\n\n## When NOT to Use This Tool\n\n- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.\n- **If uncertain:** Prefer keeping over re-fetching.\n\n## Best Practices\n- **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.\n- **Think ahead:** Before extracting, ask: \"Will I need the raw output for an upcoming task?\" If you researched a file you'll later edit, do NOT extract it.\n\n## Format\n\n- `hashes`: Array of hash strings from tool outputs (e.g., [\"#r_a1b2c#\", \"#r_d4e5f#\"])\n- `distillation`: Array of strings, one per hash (positional: distillation[0] is for hashes[0], etc.)\n- `preserve` (optional): Set to `true` to keep the original tool output after extraction. Default is `false` (prunes after extraction).\n\nEach distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed for your task.\n\n## Example\n\n<example_extraction>\nTool outputs show:\n#r_a1b2c#\n<auth.ts content...>\n\n#r_d4e5f#\n<user.ts content...>\n\nTo extract:\nextract({\n hashes: [\"#r_a1b2c#\", \"#r_d4e5f#\"],\n distillation: [\n \"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds.\",\n \"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }\"\n ]\n})\n</example_extraction>\n\n<example_keep>\nAssistant: [Reads 'auth.ts' to understand the login flow]\nI've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than extracting.\n</example_keep>";
2
+ //# sourceMappingURL=extract-tool-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,2iFAsDd,CAAA"}
@@ -0,0 +1,56 @@
1
+ export const EXTRACT_TOOL_SPEC = `Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.
2
+
3
+ ## How It Works
4
+
5
+ Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
6
+ Use these hashes to extract and distill specific tool outputs.
7
+
8
+ ## When to Use This Tool
9
+
10
+ Use \`extract\` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:
11
+
12
+ - **Task Completion:** You completed a unit of work and want to preserve key findings.
13
+ - **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.
14
+
15
+ ## When NOT to Use This Tool
16
+
17
+ - **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.
18
+ - **If uncertain:** Prefer keeping over re-fetching.
19
+
20
+ ## Best Practices
21
+ - **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.
22
+ - **Think ahead:** Before extracting, ask: "Will I need the raw output for an upcoming task?" If you researched a file you'll later edit, do NOT extract it.
23
+
24
+ ## Format
25
+
26
+ - \`hashes\`: Array of hash strings from tool outputs (e.g., ["#r_a1b2c#", "#r_d4e5f#"])
27
+ - \`distillation\`: Array of strings, one per hash (positional: distillation[0] is for hashes[0], etc.)
28
+ - \`preserve\` (optional): Set to \`true\` to keep the original tool output after extraction. Default is \`false\` (prunes after extraction).
29
+
30
+ Each distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed for your task.
31
+
32
+ ## Example
33
+
34
+ <example_extraction>
35
+ Tool outputs show:
36
+ #r_a1b2c#
37
+ <auth.ts content...>
38
+
39
+ #r_d4e5f#
40
+ <user.ts content...>
41
+
42
+ To extract:
43
+ extract({
44
+ hashes: ["#r_a1b2c#", "#r_d4e5f#"],
45
+ distillation: [
46
+ "auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds.",
47
+ "user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }"
48
+ ]
49
+ })
50
+ </example_extraction>
51
+
52
+ <example_keep>
53
+ Assistant: [Reads 'auth.ts' to understand the login flow]
54
+ I've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than extracting.
55
+ </example_keep>`;
56
+ //# sourceMappingURL=extract-tool-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAsDjB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function loadPrompt(name: string, vars?: Record<string, string>): string;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAW9E"}