cast-code 1.0.0

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 (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -0
  3. package/dist/app.module.js +45 -0
  4. package/dist/app.module.js.map +1 -0
  5. package/dist/common/common.module.js +49 -0
  6. package/dist/common/common.module.js.map +1 -0
  7. package/dist/common/constants/index.js +105 -0
  8. package/dist/common/constants/index.js.map +1 -0
  9. package/dist/common/index.js +24 -0
  10. package/dist/common/index.js.map +1 -0
  11. package/dist/common/services/config.service.js +119 -0
  12. package/dist/common/services/config.service.js.map +1 -0
  13. package/dist/common/services/llm.service.js +56 -0
  14. package/dist/common/services/llm.service.js.map +1 -0
  15. package/dist/common/services/markdown-parser.service.js +101 -0
  16. package/dist/common/services/markdown-parser.service.js.map +1 -0
  17. package/dist/common/services/markdown-renderer.service.js +220 -0
  18. package/dist/common/services/markdown-renderer.service.js.map +1 -0
  19. package/dist/common/services/multi-llm.service.js +115 -0
  20. package/dist/common/services/multi-llm.service.js.map +1 -0
  21. package/dist/common/types/index.js +20 -0
  22. package/dist/common/types/index.js.map +1 -0
  23. package/dist/common/types/markdown.types.js +6 -0
  24. package/dist/common/types/markdown.types.js.map +1 -0
  25. package/dist/main.js +84 -0
  26. package/dist/main.js.map +1 -0
  27. package/dist/modules/agents/agents.module.js +43 -0
  28. package/dist/modules/agents/agents.module.js.map +1 -0
  29. package/dist/modules/agents/definitions/architect.md +35 -0
  30. package/dist/modules/agents/definitions/backend.md +43 -0
  31. package/dist/modules/agents/definitions/coder.md +34 -0
  32. package/dist/modules/agents/definitions/devops.md +42 -0
  33. package/dist/modules/agents/definitions/frontend.md +46 -0
  34. package/dist/modules/agents/definitions/reviewer.md +35 -0
  35. package/dist/modules/agents/definitions/tester.md +41 -0
  36. package/dist/modules/agents/index.js +23 -0
  37. package/dist/modules/agents/index.js.map +1 -0
  38. package/dist/modules/agents/services/agent-loader.service.js +150 -0
  39. package/dist/modules/agents/services/agent-loader.service.js.map +1 -0
  40. package/dist/modules/agents/services/agent-registry.service.js +108 -0
  41. package/dist/modules/agents/services/agent-registry.service.js.map +1 -0
  42. package/dist/modules/agents/types/agent.types.js +6 -0
  43. package/dist/modules/agents/types/agent.types.js.map +1 -0
  44. package/dist/modules/agents/types/index.js +20 -0
  45. package/dist/modules/agents/types/index.js.map +1 -0
  46. package/dist/modules/config/config.module.js +38 -0
  47. package/dist/modules/config/config.module.js.map +1 -0
  48. package/dist/modules/config/index.js +24 -0
  49. package/dist/modules/config/index.js.map +1 -0
  50. package/dist/modules/config/services/config-commands.service.js +405 -0
  51. package/dist/modules/config/services/config-commands.service.js.map +1 -0
  52. package/dist/modules/config/services/config-manager.service.js +175 -0
  53. package/dist/modules/config/services/config-manager.service.js.map +1 -0
  54. package/dist/modules/config/services/init-config.service.js +238 -0
  55. package/dist/modules/config/services/init-config.service.js.map +1 -0
  56. package/dist/modules/config/types/config.types.js +163 -0
  57. package/dist/modules/config/types/config.types.js.map +1 -0
  58. package/dist/modules/config/types/index.js +20 -0
  59. package/dist/modules/config/types/index.js.map +1 -0
  60. package/dist/modules/core/core.module.js +60 -0
  61. package/dist/modules/core/core.module.js.map +1 -0
  62. package/dist/modules/core/index.js +22 -0
  63. package/dist/modules/core/index.js.map +1 -0
  64. package/dist/modules/core/services/deep-agent.service.js +575 -0
  65. package/dist/modules/core/services/deep-agent.service.js.map +1 -0
  66. package/dist/modules/core/services/plan-mode.service.js +225 -0
  67. package/dist/modules/core/services/plan-mode.service.js.map +1 -0
  68. package/dist/modules/git/git.module.js +48 -0
  69. package/dist/modules/git/git.module.js.map +1 -0
  70. package/dist/modules/git/index.js +23 -0
  71. package/dist/modules/git/index.js.map +1 -0
  72. package/dist/modules/git/services/code-review.service.js +330 -0
  73. package/dist/modules/git/services/code-review.service.js.map +1 -0
  74. package/dist/modules/git/services/commit-generator.service.js +403 -0
  75. package/dist/modules/git/services/commit-generator.service.js.map +1 -0
  76. package/dist/modules/git/services/index.js +21 -0
  77. package/dist/modules/git/services/index.js.map +1 -0
  78. package/dist/modules/git/services/monorepo-detector.service.js +338 -0
  79. package/dist/modules/git/services/monorepo-detector.service.js.map +1 -0
  80. package/dist/modules/git/services/pr-generator.service.js +429 -0
  81. package/dist/modules/git/services/pr-generator.service.js.map +1 -0
  82. package/dist/modules/git/services/release-notes.service.js +426 -0
  83. package/dist/modules/git/services/release-notes.service.js.map +1 -0
  84. package/dist/modules/git/types/git.types.js +6 -0
  85. package/dist/modules/git/types/git.types.js.map +1 -0
  86. package/dist/modules/git/types/index.js +20 -0
  87. package/dist/modules/git/types/index.js.map +1 -0
  88. package/dist/modules/mcp/catalog/mcp-templates.js +606 -0
  89. package/dist/modules/mcp/catalog/mcp-templates.js.map +1 -0
  90. package/dist/modules/mcp/index.js +23 -0
  91. package/dist/modules/mcp/index.js.map +1 -0
  92. package/dist/modules/mcp/mcp.module.js +35 -0
  93. package/dist/modules/mcp/mcp.module.js.map +1 -0
  94. package/dist/modules/mcp/services/mcp-client.service.js +289 -0
  95. package/dist/modules/mcp/services/mcp-client.service.js.map +1 -0
  96. package/dist/modules/mcp/services/mcp-registry.service.js +197 -0
  97. package/dist/modules/mcp/services/mcp-registry.service.js.map +1 -0
  98. package/dist/modules/mcp/types/index.js +20 -0
  99. package/dist/modules/mcp/types/index.js.map +1 -0
  100. package/dist/modules/mcp/types/mcp.types.js +6 -0
  101. package/dist/modules/mcp/types/mcp.types.js.map +1 -0
  102. package/dist/modules/memory/index.js +23 -0
  103. package/dist/modules/memory/index.js.map +1 -0
  104. package/dist/modules/memory/memory.module.js +35 -0
  105. package/dist/modules/memory/memory.module.js.map +1 -0
  106. package/dist/modules/memory/services/memory-tools.service.js +78 -0
  107. package/dist/modules/memory/services/memory-tools.service.js.map +1 -0
  108. package/dist/modules/memory/services/memory.service.js +169 -0
  109. package/dist/modules/memory/services/memory.service.js.map +1 -0
  110. package/dist/modules/memory/types/index.js +20 -0
  111. package/dist/modules/memory/types/index.js.map +1 -0
  112. package/dist/modules/memory/types/memory.types.js +6 -0
  113. package/dist/modules/memory/types/memory.types.js.map +1 -0
  114. package/dist/modules/mentions/index.js +22 -0
  115. package/dist/modules/mentions/index.js.map +1 -0
  116. package/dist/modules/mentions/mentions.module.js +32 -0
  117. package/dist/modules/mentions/mentions.module.js.map +1 -0
  118. package/dist/modules/mentions/services/mentions.service.js +336 -0
  119. package/dist/modules/mentions/services/mentions.service.js.map +1 -0
  120. package/dist/modules/mentions/types/index.js +20 -0
  121. package/dist/modules/mentions/types/index.js.map +1 -0
  122. package/dist/modules/mentions/types/mention.types.js +19 -0
  123. package/dist/modules/mentions/types/mention.types.js.map +1 -0
  124. package/dist/modules/permissions/index.js +23 -0
  125. package/dist/modules/permissions/index.js.map +1 -0
  126. package/dist/modules/permissions/permissions.module.js +35 -0
  127. package/dist/modules/permissions/permissions.module.js.map +1 -0
  128. package/dist/modules/permissions/services/permission.service.js +269 -0
  129. package/dist/modules/permissions/services/permission.service.js.map +1 -0
  130. package/dist/modules/permissions/services/prompt.service.js +116 -0
  131. package/dist/modules/permissions/services/prompt.service.js.map +1 -0
  132. package/dist/modules/permissions/types/permission.types.js +32 -0
  133. package/dist/modules/permissions/types/permission.types.js.map +1 -0
  134. package/dist/modules/project/index.js +24 -0
  135. package/dist/modules/project/index.js.map +1 -0
  136. package/dist/modules/project/project.module.js +38 -0
  137. package/dist/modules/project/project.module.js.map +1 -0
  138. package/dist/modules/project/services/project-analyzer.service.js +1063 -0
  139. package/dist/modules/project/services/project-analyzer.service.js.map +1 -0
  140. package/dist/modules/project/services/project-context.service.js +62 -0
  141. package/dist/modules/project/services/project-context.service.js.map +1 -0
  142. package/dist/modules/project/services/project-loader.service.js +147 -0
  143. package/dist/modules/project/services/project-loader.service.js.map +1 -0
  144. package/dist/modules/project/types/index.js +20 -0
  145. package/dist/modules/project/types/index.js.map +1 -0
  146. package/dist/modules/project/types/project.types.js +6 -0
  147. package/dist/modules/project/types/project.types.js.map +1 -0
  148. package/dist/modules/repl/index.js +21 -0
  149. package/dist/modules/repl/index.js.map +1 -0
  150. package/dist/modules/repl/repl.module.js +66 -0
  151. package/dist/modules/repl/repl.module.js.map +1 -0
  152. package/dist/modules/repl/services/commands/agent-commands.service.js +196 -0
  153. package/dist/modules/repl/services/commands/agent-commands.service.js.map +1 -0
  154. package/dist/modules/repl/services/commands/git-commands.service.js +500 -0
  155. package/dist/modules/repl/services/commands/git-commands.service.js.map +1 -0
  156. package/dist/modules/repl/services/commands/mcp-commands.service.js +579 -0
  157. package/dist/modules/repl/services/commands/mcp-commands.service.js.map +1 -0
  158. package/dist/modules/repl/services/commands/project-commands.service.js +226 -0
  159. package/dist/modules/repl/services/commands/project-commands.service.js.map +1 -0
  160. package/dist/modules/repl/services/commands/repl-commands.service.js +254 -0
  161. package/dist/modules/repl/services/commands/repl-commands.service.js.map +1 -0
  162. package/dist/modules/repl/services/repl.service.js +647 -0
  163. package/dist/modules/repl/services/repl.service.js.map +1 -0
  164. package/dist/modules/repl/services/smart-input.js +544 -0
  165. package/dist/modules/repl/services/smart-input.js.map +1 -0
  166. package/dist/modules/repl/services/welcome-screen.service.js +117 -0
  167. package/dist/modules/repl/services/welcome-screen.service.js.map +1 -0
  168. package/dist/modules/repl/utils/prompts-with-esc.js +187 -0
  169. package/dist/modules/repl/utils/prompts-with-esc.js.map +1 -0
  170. package/dist/modules/repl/utils/theme.js +185 -0
  171. package/dist/modules/repl/utils/theme.js.map +1 -0
  172. package/dist/modules/skills/definitions/general/file-operations.md +60 -0
  173. package/dist/modules/skills/definitions/general/git-operations.md +59 -0
  174. package/dist/modules/skills/definitions/general/planning.md +86 -0
  175. package/dist/modules/skills/definitions/general/search.md +59 -0
  176. package/dist/modules/skills/definitions/specialized/api-design.md +85 -0
  177. package/dist/modules/skills/definitions/specialized/database-operations.md +78 -0
  178. package/dist/modules/skills/definitions/specialized/frontend-bootstrap.md +71 -0
  179. package/dist/modules/skills/definitions/specialized/react-patterns.md +77 -0
  180. package/dist/modules/skills/definitions/specialized/testing-strategies.md +79 -0
  181. package/dist/modules/skills/index.js +23 -0
  182. package/dist/modules/skills/index.js.map +1 -0
  183. package/dist/modules/skills/services/skill-loader.service.js +130 -0
  184. package/dist/modules/skills/services/skill-loader.service.js.map +1 -0
  185. package/dist/modules/skills/services/skill-registry.service.js +96 -0
  186. package/dist/modules/skills/services/skill-registry.service.js.map +1 -0
  187. package/dist/modules/skills/skills.module.js +38 -0
  188. package/dist/modules/skills/skills.module.js.map +1 -0
  189. package/dist/modules/skills/types/index.js +20 -0
  190. package/dist/modules/skills/types/index.js.map +1 -0
  191. package/dist/modules/skills/types/skill.types.js +6 -0
  192. package/dist/modules/skills/types/skill.types.js.map +1 -0
  193. package/dist/modules/tasks/index.js +24 -0
  194. package/dist/modules/tasks/index.js.map +1 -0
  195. package/dist/modules/tasks/services/plan-executor.service.js +199 -0
  196. package/dist/modules/tasks/services/plan-executor.service.js.map +1 -0
  197. package/dist/modules/tasks/services/plan-mode.service.js +118 -0
  198. package/dist/modules/tasks/services/plan-mode.service.js.map +1 -0
  199. package/dist/modules/tasks/services/plan-persistence.service.js +148 -0
  200. package/dist/modules/tasks/services/plan-persistence.service.js.map +1 -0
  201. package/dist/modules/tasks/services/task-management.service.js +255 -0
  202. package/dist/modules/tasks/services/task-management.service.js.map +1 -0
  203. package/dist/modules/tasks/services/task-tools.service.js +270 -0
  204. package/dist/modules/tasks/services/task-tools.service.js.map +1 -0
  205. package/dist/modules/tasks/tasks.module.js +49 -0
  206. package/dist/modules/tasks/tasks.module.js.map +1 -0
  207. package/dist/modules/tasks/types/task.types.js +21 -0
  208. package/dist/modules/tasks/types/task.types.js.map +1 -0
  209. package/dist/modules/tools/index.js +24 -0
  210. package/dist/modules/tools/index.js.map +1 -0
  211. package/dist/modules/tools/services/filesystem-tools.service.js +450 -0
  212. package/dist/modules/tools/services/filesystem-tools.service.js.map +1 -0
  213. package/dist/modules/tools/services/search-tools.service.js +63 -0
  214. package/dist/modules/tools/services/search-tools.service.js.map +1 -0
  215. package/dist/modules/tools/services/shell-tools.service.js +194 -0
  216. package/dist/modules/tools/services/shell-tools.service.js.map +1 -0
  217. package/dist/modules/tools/services/tools-registry.service.js +83 -0
  218. package/dist/modules/tools/services/tools-registry.service.js.map +1 -0
  219. package/dist/modules/tools/tools.module.js +46 -0
  220. package/dist/modules/tools/tools.module.js.map +1 -0
  221. package/package.json +74 -0
@@ -0,0 +1,647 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ReplService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ReplService;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _deepagentservice = require("../../core/services/deep-agent.service");
13
+ const _configservice = require("../../../common/services/config.service");
14
+ const _configmanagerservice = require("../../config/services/config-manager.service");
15
+ const _mentionsservice = require("../../mentions/services/mentions.service");
16
+ const _mcpregistryservice = require("../../mcp/services/mcp-registry.service");
17
+ const _agentregistryservice = require("../../agents/services/agent-registry.service");
18
+ const _skillregistryservice = require("../../skills/services/skill-registry.service");
19
+ const _planmodeservice = require("../../core/services/plan-mode.service");
20
+ const _smartinput = require("./smart-input");
21
+ const _welcomescreenservice = require("./welcome-screen.service");
22
+ const _replcommandsservice = require("./commands/repl-commands.service");
23
+ const _gitcommandsservice = require("./commands/git-commands.service");
24
+ const _agentcommandsservice = require("./commands/agent-commands.service");
25
+ const _mcpcommandsservice = require("./commands/mcp-commands.service");
26
+ const _configcommandsservice = require("../../config/services/config-commands.service");
27
+ const _projectcommandsservice = require("./commands/project-commands.service");
28
+ const _toolsregistryservice = require("../../tools/services/tools-registry.service");
29
+ const _theme = require("../utils/theme");
30
+ function _ts_decorate(decorators, target, key, desc) {
31
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
32
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
33
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
34
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
35
+ }
36
+ function _ts_metadata(k, v) {
37
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
38
+ }
39
+ let ReplService = class ReplService {
40
+ async start() {
41
+ const initResult = await this.deepAgent.initialize();
42
+ const agentCount = this.agentRegistry.resolveAllAgents().length;
43
+ this.welcomeScreen.printWelcomeScreen({
44
+ projectPath: initResult.projectPath || undefined,
45
+ model: this.getModelDisplayName(),
46
+ toolCount: initResult.toolCount,
47
+ agentCount
48
+ });
49
+ this.smartInput = new _smartinput.SmartInput({
50
+ prompt: `${_theme.Colors.cyan}${_theme.Colors.bold}>${_theme.Colors.reset} `,
51
+ promptVisibleLen: 2,
52
+ getCommandSuggestions: (input)=>this.getCommandSuggestions(input),
53
+ getMentionSuggestions: (partial)=>this.getMentionSuggestions(partial),
54
+ onSubmit: (line)=>this.handleLine(line),
55
+ onCancel: ()=>this.handleCancel(),
56
+ onExit: ()=>this.handleExit()
57
+ });
58
+ this.smartInput.start();
59
+ }
60
+ getCommandSuggestions(input) {
61
+ const commands = [
62
+ {
63
+ text: '/help',
64
+ display: '/help',
65
+ description: 'Show help'
66
+ },
67
+ {
68
+ text: '/clear',
69
+ display: '/clear',
70
+ description: 'Clear conversation'
71
+ },
72
+ {
73
+ text: '/compact',
74
+ display: '/compact',
75
+ description: 'Compact history'
76
+ },
77
+ {
78
+ text: '/exit',
79
+ display: '/exit',
80
+ description: 'Exit'
81
+ },
82
+ {
83
+ text: '/status',
84
+ display: '/status',
85
+ description: 'Git status'
86
+ },
87
+ {
88
+ text: '/diff',
89
+ display: '/diff',
90
+ description: 'Git diff'
91
+ },
92
+ {
93
+ text: '/log',
94
+ display: '/log',
95
+ description: 'Git log'
96
+ },
97
+ {
98
+ text: '/commit',
99
+ display: '/commit',
100
+ description: 'Commit changes'
101
+ },
102
+ {
103
+ text: '/up',
104
+ display: '/up',
105
+ description: 'Smart commit & push'
106
+ },
107
+ {
108
+ text: '/split-up',
109
+ display: '/split-up',
110
+ description: 'Split commits'
111
+ },
112
+ {
113
+ text: '/pr',
114
+ display: '/pr',
115
+ description: 'Create Pull Request'
116
+ },
117
+ {
118
+ text: '/review',
119
+ display: '/review',
120
+ description: 'Code review'
121
+ },
122
+ {
123
+ text: '/fix',
124
+ display: '/fix',
125
+ description: 'Auto-fix code'
126
+ },
127
+ {
128
+ text: '/ident',
129
+ display: '/ident',
130
+ description: 'Format code'
131
+ },
132
+ {
133
+ text: '/release',
134
+ display: '/release',
135
+ description: 'Release notes'
136
+ },
137
+ {
138
+ text: '/tools',
139
+ display: '/tools',
140
+ description: 'List tools'
141
+ },
142
+ {
143
+ text: '/agents',
144
+ display: '/agents',
145
+ description: 'List agents'
146
+ },
147
+ {
148
+ text: '/skills',
149
+ display: '/skills',
150
+ description: 'List skills'
151
+ },
152
+ {
153
+ text: '/context',
154
+ display: '/context',
155
+ description: 'Session info'
156
+ },
157
+ {
158
+ text: '/mentions',
159
+ display: '/mentions',
160
+ description: 'Mentions help'
161
+ },
162
+ {
163
+ text: '/model',
164
+ display: '/model',
165
+ description: 'Show model'
166
+ },
167
+ {
168
+ text: '/config',
169
+ display: '/config',
170
+ description: 'Configuration'
171
+ },
172
+ {
173
+ text: '/project',
174
+ display: '/project',
175
+ description: 'Project context'
176
+ },
177
+ {
178
+ text: '/project-deep',
179
+ display: '/project-deep',
180
+ description: 'Deep project analysis'
181
+ },
182
+ {
183
+ text: '/init',
184
+ display: '/init',
185
+ description: 'Analyze project and generate context'
186
+ },
187
+ {
188
+ text: '/mcp',
189
+ display: '/mcp',
190
+ description: 'MCP servers'
191
+ }
192
+ ];
193
+ return commands.filter((c)=>c.text.startsWith(input));
194
+ }
195
+ getMentionSuggestions(partial) {
196
+ const fs = require('fs');
197
+ const path = require('path');
198
+ const gitOpts = [
199
+ {
200
+ text: '@git:status',
201
+ display: '@git:status',
202
+ description: 'Git status'
203
+ },
204
+ {
205
+ text: '@git:diff',
206
+ display: '@git:diff',
207
+ description: 'Git diff'
208
+ },
209
+ {
210
+ text: '@git:log',
211
+ display: '@git:log',
212
+ description: 'Git log'
213
+ },
214
+ {
215
+ text: '@git:branch',
216
+ display: '@git:branch',
217
+ description: 'Branches'
218
+ }
219
+ ];
220
+ if (partial === '') return [
221
+ ...gitOpts,
222
+ ...this.getFileEntries('')
223
+ ];
224
+ if (partial.startsWith('git:')) return gitOpts.filter((o)=>o.text.startsWith('@' + partial));
225
+ return [
226
+ ...gitOpts.filter((o)=>o.text.startsWith('@' + partial)),
227
+ ...this.getFileEntries(partial)
228
+ ].slice(0, 30);
229
+ }
230
+ getFileEntries(partial) {
231
+ const fs = require('fs');
232
+ const path = require('path');
233
+ try {
234
+ let dir;
235
+ let prefix;
236
+ if (partial.endsWith('/')) {
237
+ dir = partial.slice(0, -1) || '.';
238
+ prefix = '';
239
+ } else if (partial.includes('/')) {
240
+ dir = path.dirname(partial);
241
+ prefix = path.basename(partial);
242
+ } else {
243
+ dir = '.';
244
+ prefix = partial;
245
+ }
246
+ const resolved = path.resolve(process.cwd(), dir);
247
+ if (!fs.existsSync(resolved) || !fs.statSync(resolved).isDirectory()) return [];
248
+ const entries = fs.readdirSync(resolved, {
249
+ withFileTypes: true
250
+ });
251
+ const ignore = [
252
+ 'node_modules',
253
+ '.git',
254
+ 'dist',
255
+ 'coverage',
256
+ '.next',
257
+ '__pycache__'
258
+ ];
259
+ return entries.filter((e)=>!ignore.includes(e.name)).filter((e)=>!e.name.startsWith('.') || prefix.startsWith('.')).filter((e)=>prefix === '' || e.name.toLowerCase().startsWith(prefix.toLowerCase())).map((e)=>{
260
+ const relDir = dir === '.' ? '' : dir + '/';
261
+ const isDir = e.isDirectory();
262
+ return {
263
+ text: '@' + relDir + e.name + (isDir ? '/' : ''),
264
+ display: '@' + relDir + e.name + (isDir ? '/' : ''),
265
+ description: isDir ? 'dir' : ''
266
+ };
267
+ }).slice(0, 20);
268
+ } catch {
269
+ return [];
270
+ }
271
+ }
272
+ handleCancel() {
273
+ if (this.isProcessing && this.abortController) {
274
+ this.abortController.abort();
275
+ this.stopSpinner();
276
+ process.stdout.write(`\r\n${_theme.Colors.yellow} Cancelled${_theme.Colors.reset}\r\n\r\n`);
277
+ this.isProcessing = false;
278
+ } else {
279
+ process.stdout.write(`${_theme.Colors.dim} (Use /exit to quit)${_theme.Colors.reset}\r\n`);
280
+ this.smartInput?.showPrompt();
281
+ }
282
+ }
283
+ handleExit() {
284
+ process.stdout.write(`${_theme.Colors.dim} Goodbye!${_theme.Colors.reset}\r\n`);
285
+ this.stop();
286
+ process.exit(0);
287
+ }
288
+ async handleLine(input) {
289
+ const trimmed = input.trim();
290
+ if (!trimmed) {
291
+ this.smartInput?.showPrompt();
292
+ return;
293
+ }
294
+ if (trimmed.startsWith('/')) {
295
+ await this.handleCommand(trimmed);
296
+ } else {
297
+ await this.handleMessage(trimmed);
298
+ }
299
+ this.smartInput?.showPrompt();
300
+ }
301
+ async handleCommand(command) {
302
+ const parts = command.slice(1).split(/\s+/);
303
+ const cmd = parts[0].toLowerCase();
304
+ const args = parts.slice(1);
305
+ switch(cmd){
306
+ case 'help':
307
+ this.replCommands.printHelp();
308
+ break;
309
+ case 'clear':
310
+ this.replCommands.cmdClear(this.welcomeScreen);
311
+ break;
312
+ case 'exit':
313
+ case 'quit':
314
+ this.handleExit();
315
+ return;
316
+ case 'compact':
317
+ await this.handleCompact();
318
+ break;
319
+ case 'context':
320
+ this.replCommands.cmdContext();
321
+ break;
322
+ case 'config':
323
+ await this.configCommands.handleConfigCommand(args, this.smartInput);
324
+ break;
325
+ case 'model':
326
+ this.replCommands.cmdModel(args);
327
+ break;
328
+ case 'init':
329
+ await this.projectCommands.cmdProject([
330
+ 'analyze'
331
+ ], this.smartInput);
332
+ break;
333
+ case 'mentions':
334
+ this.replCommands.cmdMentionsHelp();
335
+ break;
336
+ case 'tools':
337
+ this.cmdTools();
338
+ break;
339
+ case 'status':
340
+ this.gitCommands.runGit('git status');
341
+ break;
342
+ case 'diff':
343
+ this.gitCommands.runGit(args.length ? `git diff ${args.join(' ')}` : 'git diff');
344
+ break;
345
+ case 'log':
346
+ this.gitCommands.runGit('git log --oneline -15');
347
+ break;
348
+ case 'commit':
349
+ await this.gitCommands.cmdCommit(args, this.smartInput);
350
+ break;
351
+ case 'up':
352
+ await this.gitCommands.cmdUp(this.smartInput);
353
+ break;
354
+ case 'split-up':
355
+ await this.gitCommands.cmdSplitUp(this.smartInput);
356
+ break;
357
+ case 'pr':
358
+ await this.gitCommands.cmdPr(this.smartInput);
359
+ break;
360
+ case 'review':
361
+ await this.gitCommands.cmdReview(args);
362
+ break;
363
+ case 'fix':
364
+ await this.gitCommands.cmdFix(args);
365
+ break;
366
+ case 'ident':
367
+ await this.gitCommands.cmdIdent();
368
+ break;
369
+ case 'release':
370
+ await this.gitCommands.cmdRelease(args);
371
+ break;
372
+ case 'agents':
373
+ await this.agentCommands.cmdAgents(args, this.smartInput);
374
+ break;
375
+ case 'skills':
376
+ await this.agentCommands.cmdSkills(args, this.smartInput);
377
+ break;
378
+ case 'mcp':
379
+ await this.mcpCommands.cmdMcp(args, this.smartInput);
380
+ break;
381
+ case 'project':
382
+ await this.projectCommands.cmdProject(args, this.smartInput);
383
+ break;
384
+ case 'project-deep':
385
+ await this.projectCommands.cmdProject([
386
+ 'deep'
387
+ ], this.smartInput);
388
+ break;
389
+ default:
390
+ process.stdout.write(`${_theme.Colors.red} Unknown: /${cmd}${_theme.Colors.reset} ${_theme.Colors.dim}Try /help${_theme.Colors.reset}\r\n`);
391
+ }
392
+ }
393
+ async handleCompact() {
394
+ const msgCount = this.deepAgent.getMessageCount();
395
+ if (msgCount < 4) {
396
+ process.stdout.write(`${_theme.Colors.dim} Nothing to compact (${msgCount} messages)${_theme.Colors.reset}\r\n`);
397
+ return;
398
+ }
399
+ process.stdout.write(`${_theme.Colors.dim} Summarizing ${msgCount} messages...${_theme.Colors.reset}\r\n`);
400
+ const result = await this.deepAgent.compactHistory();
401
+ if (result.compacted) {
402
+ process.stdout.write(`${_theme.Colors.green} Compacted: ${result.messagesBefore} → ${result.messagesAfter} messages${_theme.Colors.reset}\r\n`);
403
+ } else {
404
+ process.stdout.write(`${_theme.Colors.yellow} Could not compact (summarization failed)${_theme.Colors.reset}\r\n`);
405
+ }
406
+ }
407
+ async handleMessage(message) {
408
+ this.isProcessing = true;
409
+ this.abortController = new AbortController();
410
+ this.smartInput?.enterPassiveMode();
411
+ try {
412
+ let messageToProcess = message;
413
+ const planCheck = await this.planMode.shouldEnterPlanMode(message);
414
+ if (planCheck.shouldPlan) {
415
+ const usePlan = await this.smartInput.askChoice('📝 Complex task. Create a plan?', [
416
+ {
417
+ key: 'y',
418
+ label: 'yes',
419
+ description: 'Create structured plan'
420
+ },
421
+ {
422
+ key: 'n',
423
+ label: 'no',
424
+ description: 'Proceed without plan'
425
+ }
426
+ ]);
427
+ if (usePlan === 'y') {
428
+ const plannedMessage = await this.runInteractivePlanMode(message);
429
+ if (!plannedMessage) {
430
+ this.isProcessing = false;
431
+ this.smartInput?.exitPassiveMode();
432
+ return;
433
+ }
434
+ messageToProcess = plannedMessage;
435
+ }
436
+ }
437
+ const mentionResult = await this.mentionsService.processMessage(messageToProcess);
438
+ if (mentionResult.mentions.length > 0) {
439
+ const summary = this.mentionsService.getMentionsSummary(mentionResult.mentions);
440
+ for (const line of summary){
441
+ process.stdout.write(`${_theme.Colors.dim}${line}${_theme.Colors.reset}\r\n`);
442
+ }
443
+ process.stdout.write('\r\n');
444
+ }
445
+ this.startSpinner('Thinking');
446
+ let firstChunk = true;
447
+ let fullResponse = '';
448
+ for await (const chunk of this.deepAgent.chat(mentionResult.expandedMessage)){
449
+ if (this.abortController?.signal.aborted) break;
450
+ const isToolOutput = chunk.includes('\x1b[') && (chunk.includes('⏿') || chunk.includes('tokens:') || chunk.includes('conversation compacted'));
451
+ if (firstChunk && !isToolOutput) {
452
+ this.stopSpinner();
453
+ process.stdout.write(`\r\n${_theme.Colors.magenta}${_theme.Colors.bold}${_theme.Icons.chestnut} Cast${_theme.Colors.reset}\r\n`);
454
+ firstChunk = false;
455
+ }
456
+ if (!isToolOutput) {
457
+ fullResponse += chunk;
458
+ }
459
+ process.stdout.write(chunk);
460
+ }
461
+ if (!firstChunk) {
462
+ process.stdout.write('\r\n');
463
+ } else {
464
+ this.stopSpinner();
465
+ }
466
+ } catch (error) {
467
+ this.stopSpinner();
468
+ const msg = error.message;
469
+ if (!msg.includes('abort')) {
470
+ process.stdout.write(`\r\n${_theme.Colors.red} Error: ${msg}${_theme.Colors.reset}\r\n\r\n`);
471
+ }
472
+ } finally{
473
+ this.isProcessing = false;
474
+ this.abortController = null;
475
+ this.smartInput?.exitPassiveMode();
476
+ }
477
+ }
478
+ async runInteractivePlanMode(userMessage) {
479
+ process.stdout.write(`\r\n${_theme.Colors.cyan}${_theme.Colors.bold}📋 PLAN MODE${_theme.Colors.reset}\r\n`);
480
+ process.stdout.write(`${_theme.Colors.dim}Build plan first, execute after approval${_theme.Colors.reset}\r\n\r\n`);
481
+ const clarifyingQuestions = await this.planMode.generateClarifyingQuestions(userMessage);
482
+ const answers = [];
483
+ if (clarifyingQuestions.length > 0) {
484
+ process.stdout.write(`${_theme.Colors.dim}I need a few quick clarifications:${_theme.Colors.reset}\r\n`);
485
+ for(let i = 0; i < clarifyingQuestions.length; i++){
486
+ const q = clarifyingQuestions[i];
487
+ const answer = await this.smartInput.question(`${_theme.Colors.yellow}Q${i + 1}:${_theme.Colors.reset} ${q} `);
488
+ if (answer.trim()) {
489
+ answers.push(`- ${q} => ${answer.trim()}`);
490
+ }
491
+ }
492
+ process.stdout.write('\r\n');
493
+ }
494
+ const context = answers.length > 0 ? `User clarifications:\n${answers.join('\n')}` : undefined;
495
+ let plan = await this.planMode.generatePlan(userMessage, context);
496
+ while(true){
497
+ process.stdout.write(this.planMode.formatPlanForDisplay(plan));
498
+ const action = await this.smartInput.askChoice('Plan options', [
499
+ {
500
+ key: 'a',
501
+ label: 'accept',
502
+ description: 'Use this plan and continue'
503
+ },
504
+ {
505
+ key: 'r',
506
+ label: 'refine',
507
+ description: 'Refine plan with extra feedback'
508
+ },
509
+ {
510
+ key: 'c',
511
+ label: 'cancel',
512
+ description: 'Cancel and return to prompt'
513
+ }
514
+ ]);
515
+ if (action === 'c') {
516
+ process.stdout.write(`${_theme.Colors.dim} Plan cancelled${_theme.Colors.reset}\r\n\r\n`);
517
+ return null;
518
+ }
519
+ if (action === 'r') {
520
+ const feedback = await this.smartInput.question(`${_theme.Colors.cyan}Refinement feedback:${_theme.Colors.reset} `);
521
+ if (!feedback.trim()) {
522
+ process.stdout.write(`${_theme.Colors.dim} No feedback provided. Keeping current plan.${_theme.Colors.reset}\r\n\r\n`);
523
+ continue;
524
+ }
525
+ plan = await this.planMode.refinePlan(plan, feedback.trim());
526
+ continue;
527
+ }
528
+ return this.buildPlanExecutionPrompt(userMessage, plan, answers);
529
+ }
530
+ }
531
+ buildPlanExecutionPrompt(userMessage, plan, clarifications) {
532
+ const lines = [];
533
+ lines.push(userMessage);
534
+ lines.push('');
535
+ lines.push('Approved execution plan:');
536
+ lines.push(`Title: ${plan.title}`);
537
+ lines.push(`Overview: ${plan.overview}`);
538
+ lines.push('Steps:');
539
+ for (const step of plan.steps){
540
+ const files = step.files.length > 0 ? ` | files: ${step.files.join(', ')}` : '';
541
+ lines.push(`${step.id}. ${step.description}${files}`);
542
+ }
543
+ if (clarifications.length > 0) {
544
+ lines.push('');
545
+ lines.push('User clarifications:');
546
+ lines.push(...clarifications);
547
+ }
548
+ lines.push('');
549
+ lines.push('Execute the task following this approved plan and report progress by step.');
550
+ return lines.join('\n');
551
+ }
552
+ startSpinner(label) {
553
+ let i = 0;
554
+ this.spinnerTimer = setInterval(()=>{
555
+ process.stdout.write(`\r${_theme.Colors.cyan}${_theme.Icons.thinkingChestnut[i++ % _theme.Icons.thinkingChestnut.length]}${_theme.Colors.reset} ${_theme.Colors.dim}${label}...${_theme.Colors.reset}`);
556
+ }, 80);
557
+ }
558
+ stopSpinner() {
559
+ if (this.spinnerTimer) {
560
+ clearInterval(this.spinnerTimer);
561
+ this.spinnerTimer = null;
562
+ process.stdout.write('\r\x1b[K');
563
+ }
564
+ }
565
+ cmdTools() {
566
+ const allTools = this.toolsRegistry.getAllTools();
567
+ const tools = allTools.map((t)=>[
568
+ t.name,
569
+ t.description.slice(0, 60)
570
+ ]);
571
+ if (tools.length > 0) {
572
+ const maxLen = Math.max(...tools.map(([n])=>n.length));
573
+ process.stdout.write('\r\n');
574
+ process.stdout.write(`${_theme.Colors.bold}Built-in Tools (${tools.length}):${_theme.Colors.reset}\r\n`);
575
+ for (const [name, desc] of tools){
576
+ process.stdout.write(` ${_theme.Colors.cyan}${name.padEnd(maxLen)}${_theme.Colors.reset} ${_theme.Colors.dim}${desc}${_theme.Colors.reset}\r\n`);
577
+ }
578
+ }
579
+ const mcpTools = this.mcpRegistry.getAllMcpTools();
580
+ if (mcpTools.length > 0) {
581
+ process.stdout.write(`\r\n${_theme.Colors.bold}MCP Tools (${mcpTools.length}):${_theme.Colors.reset}\r\n`);
582
+ for (const t of mcpTools.slice(0, 10)){
583
+ process.stdout.write(` ${_theme.Colors.cyan}${t.name}${_theme.Colors.reset} ${_theme.Colors.dim}${t.description.slice(0, 50)}${_theme.Colors.reset}\r\n`);
584
+ }
585
+ }
586
+ process.stdout.write('\r\n');
587
+ }
588
+ getModelDisplayName() {
589
+ try {
590
+ const modelConfig = this.configManager.getModelConfig('default');
591
+ if (modelConfig) {
592
+ return `${modelConfig.provider}/${modelConfig.model}`;
593
+ }
594
+ } catch {}
595
+ return `${this.configService.getProvider()}/${this.configService.getModel()}`;
596
+ }
597
+ stop() {
598
+ this.stopSpinner();
599
+ this.smartInput?.destroy();
600
+ }
601
+ constructor(deepAgent, configService, configManager, mentionsService, mcpRegistry, agentRegistry, skillRegistry, welcomeScreen, planMode, replCommands, gitCommands, agentCommands, mcpCommands, configCommands, projectCommands, toolsRegistry){
602
+ this.deepAgent = deepAgent;
603
+ this.configService = configService;
604
+ this.configManager = configManager;
605
+ this.mentionsService = mentionsService;
606
+ this.mcpRegistry = mcpRegistry;
607
+ this.agentRegistry = agentRegistry;
608
+ this.skillRegistry = skillRegistry;
609
+ this.welcomeScreen = welcomeScreen;
610
+ this.planMode = planMode;
611
+ this.replCommands = replCommands;
612
+ this.gitCommands = gitCommands;
613
+ this.agentCommands = agentCommands;
614
+ this.mcpCommands = mcpCommands;
615
+ this.configCommands = configCommands;
616
+ this.projectCommands = projectCommands;
617
+ this.toolsRegistry = toolsRegistry;
618
+ this.smartInput = null;
619
+ this.abortController = null;
620
+ this.isProcessing = false;
621
+ this.spinnerTimer = null;
622
+ }
623
+ };
624
+ ReplService = _ts_decorate([
625
+ (0, _common.Injectable)(),
626
+ _ts_metadata("design:type", Function),
627
+ _ts_metadata("design:paramtypes", [
628
+ typeof _deepagentservice.DeepAgentService === "undefined" ? Object : _deepagentservice.DeepAgentService,
629
+ typeof _configservice.ConfigService === "undefined" ? Object : _configservice.ConfigService,
630
+ typeof _configmanagerservice.ConfigManagerService === "undefined" ? Object : _configmanagerservice.ConfigManagerService,
631
+ typeof _mentionsservice.MentionsService === "undefined" ? Object : _mentionsservice.MentionsService,
632
+ typeof _mcpregistryservice.McpRegistryService === "undefined" ? Object : _mcpregistryservice.McpRegistryService,
633
+ typeof _agentregistryservice.AgentRegistryService === "undefined" ? Object : _agentregistryservice.AgentRegistryService,
634
+ typeof _skillregistryservice.SkillRegistryService === "undefined" ? Object : _skillregistryservice.SkillRegistryService,
635
+ typeof _welcomescreenservice.WelcomeScreenService === "undefined" ? Object : _welcomescreenservice.WelcomeScreenService,
636
+ typeof _planmodeservice.PlanModeService === "undefined" ? Object : _planmodeservice.PlanModeService,
637
+ typeof _replcommandsservice.ReplCommandsService === "undefined" ? Object : _replcommandsservice.ReplCommandsService,
638
+ typeof _gitcommandsservice.GitCommandsService === "undefined" ? Object : _gitcommandsservice.GitCommandsService,
639
+ typeof _agentcommandsservice.AgentCommandsService === "undefined" ? Object : _agentcommandsservice.AgentCommandsService,
640
+ typeof _mcpcommandsservice.McpCommandsService === "undefined" ? Object : _mcpcommandsservice.McpCommandsService,
641
+ typeof _configcommandsservice.ConfigCommandsService === "undefined" ? Object : _configcommandsservice.ConfigCommandsService,
642
+ typeof _projectcommandsservice.ProjectCommandsService === "undefined" ? Object : _projectcommandsservice.ProjectCommandsService,
643
+ typeof _toolsregistryservice.ToolsRegistryService === "undefined" ? Object : _toolsregistryservice.ToolsRegistryService
644
+ ])
645
+ ], ReplService);
646
+
647
+ //# sourceMappingURL=repl.service.js.map