prjct-cli 0.19.0 → 0.20.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 (230) hide show
  1. package/CHANGELOG.md +66 -6
  2. package/CLAUDE.md +56 -15
  3. package/README.md +5 -6
  4. package/bin/prjct +59 -42
  5. package/bin/prjct.ts +60 -0
  6. package/core/__tests__/agentic/memory-system.test.ts +18 -3
  7. package/core/__tests__/agentic/plan-mode.test.ts +55 -26
  8. package/core/__tests__/agentic/prompt-builder.test.ts +6 -6
  9. package/core/__tests__/utils/project-commands.test.ts +72 -0
  10. package/core/agentic/agent-router.ts +3 -12
  11. package/core/agentic/command-executor.ts +372 -3
  12. package/core/agentic/context-builder.ts +7 -27
  13. package/core/agentic/ground-truth.ts +604 -5
  14. package/core/agentic/index.ts +180 -0
  15. package/core/agentic/loop-detector.ts +418 -4
  16. package/core/agentic/memory-system.ts +857 -3
  17. package/core/agentic/plan-mode.ts +491 -4
  18. package/core/agentic/prompt-builder.ts +44 -65
  19. package/core/agentic/services.ts +13 -5
  20. package/core/agentic/skill-loader.ts +112 -0
  21. package/core/agentic/smart-context.ts +37 -122
  22. package/core/agentic/template-loader.ts +79 -122
  23. package/core/agentic/tool-registry.ts +5 -11
  24. package/core/agents/index.ts +1 -1
  25. package/core/agents/performance.ts +4 -2
  26. package/core/bus/bus.ts +262 -0
  27. package/core/bus/index.ts +3 -313
  28. package/core/commands/analysis.ts +5 -5
  29. package/core/commands/analytics.ts +11 -11
  30. package/core/commands/base.ts +33 -209
  31. package/core/commands/cleanup.ts +148 -0
  32. package/core/commands/command-data.ts +346 -0
  33. package/core/commands/commands.ts +216 -0
  34. package/core/commands/design.ts +83 -0
  35. package/core/commands/index.ts +13 -207
  36. package/core/commands/maintenance.ts +52 -473
  37. package/core/commands/planning.ts +3 -3
  38. package/core/commands/register.ts +104 -0
  39. package/core/commands/registry.ts +441 -0
  40. package/core/commands/setup.ts +25 -9
  41. package/core/commands/shipping.ts +48 -11
  42. package/core/commands/snapshots.ts +299 -0
  43. package/core/commands/workflow.ts +2 -2
  44. package/core/constants/index.ts +254 -4
  45. package/core/domain/agent-loader.ts +5 -6
  46. package/core/domain/task-stack.ts +555 -4
  47. package/core/errors.ts +127 -1
  48. package/core/events/events.ts +87 -0
  49. package/core/events/index.ts +4 -138
  50. package/core/index.ts +15 -23
  51. package/core/infrastructure/agent-detector.ts +126 -201
  52. package/core/infrastructure/author-detector.ts +99 -171
  53. package/core/infrastructure/command-installer.ts +476 -4
  54. package/core/infrastructure/config-manager.ts +41 -37
  55. package/core/infrastructure/path-manager.ts +59 -9
  56. package/core/infrastructure/permission-manager.ts +286 -0
  57. package/core/outcomes/analyzer.ts +7 -41
  58. package/core/outcomes/index.ts +1 -1
  59. package/core/outcomes/recorder.ts +1 -1
  60. package/core/{plugins → plugin/builtin}/webhook.ts +6 -22
  61. package/core/plugin/loader.ts +5 -5
  62. package/core/plugin/registry.ts +2 -2
  63. package/core/schemas/ideas.ts +85 -54
  64. package/core/schemas/index.ts +14 -33
  65. package/core/schemas/permissions.ts +177 -0
  66. package/core/schemas/project.ts +39 -12
  67. package/core/schemas/roadmap.ts +94 -59
  68. package/core/schemas/schemas.ts +39 -0
  69. package/core/schemas/shipped.ts +87 -60
  70. package/core/schemas/state.ts +110 -70
  71. package/core/server/index.ts +21 -0
  72. package/core/server/routes.ts +165 -0
  73. package/core/server/server.ts +136 -0
  74. package/core/server/sse.ts +135 -0
  75. package/core/services/agent-service.ts +170 -0
  76. package/core/services/breakdown-service.ts +126 -0
  77. package/core/services/index.ts +21 -0
  78. package/core/services/memory-service.ts +108 -0
  79. package/core/services/project-service.ts +146 -0
  80. package/core/services/skill-service.ts +253 -0
  81. package/core/session/compaction.ts +257 -0
  82. package/core/session/index.ts +20 -8
  83. package/core/{infrastructure/session-manager/migration.ts → session/log-migration.ts} +9 -9
  84. package/core/{infrastructure/session-manager/session-manager.ts → session/session-log-manager.ts} +27 -26
  85. package/core/session/{session-manager.ts → task-session-manager.ts} +7 -4
  86. package/core/session/utils.ts +1 -1
  87. package/core/storage/ideas-storage.ts +10 -26
  88. package/core/storage/index.ts +14 -162
  89. package/core/storage/queue-storage.ts +13 -11
  90. package/core/storage/shipped-storage.ts +4 -17
  91. package/core/storage/state-storage.ts +35 -43
  92. package/core/storage/storage-manager.ts +42 -52
  93. package/core/storage/storage.ts +160 -0
  94. package/core/sync/auth-config.ts +1 -8
  95. package/core/sync/index.ts +17 -10
  96. package/core/sync/oauth-handler.ts +1 -6
  97. package/core/sync/sync-client.ts +6 -34
  98. package/core/sync/sync-manager.ts +11 -40
  99. package/core/types/agentic.ts +577 -0
  100. package/core/types/agents.ts +145 -0
  101. package/core/types/bus.ts +82 -0
  102. package/core/types/commands.ts +366 -0
  103. package/core/types/config.ts +66 -0
  104. package/core/types/core.ts +96 -0
  105. package/core/types/domain.ts +71 -0
  106. package/core/types/events.ts +42 -0
  107. package/core/types/fs.ts +56 -0
  108. package/core/types/index.ts +387 -500
  109. package/core/types/infrastructure.ts +196 -0
  110. package/core/{agentic/memory-system/types.ts → types/memory.ts} +33 -8
  111. package/core/{outcomes/types.ts → types/outcomes.ts} +53 -8
  112. package/core/types/plugin.ts +25 -0
  113. package/core/types/server.ts +54 -0
  114. package/core/types/services.ts +65 -0
  115. package/core/types/session.ts +135 -0
  116. package/core/types/storage.ts +148 -0
  117. package/core/types/sync.ts +121 -0
  118. package/core/types/task.ts +72 -0
  119. package/core/types/template.ts +24 -0
  120. package/core/types/utils.ts +90 -0
  121. package/core/utils/cache.ts +195 -0
  122. package/core/utils/collection-filters.ts +245 -0
  123. package/core/utils/date-helper.ts +1 -5
  124. package/core/utils/file-helper.ts +20 -10
  125. package/core/utils/jsonl-helper.ts +5 -8
  126. package/core/utils/markdown-builder.ts +277 -0
  127. package/core/utils/project-commands.ts +132 -0
  128. package/core/utils/runtime.ts +119 -0
  129. package/dist/bin/prjct.mjs +12568 -0
  130. package/package.json +13 -8
  131. package/scripts/build.js +106 -0
  132. package/scripts/postinstall.js +50 -8
  133. package/templates/agentic/agents/uxui.md +210 -0
  134. package/templates/agentic/subagent-generation.md +1 -1
  135. package/templates/commands/bug.md +219 -41
  136. package/templates/commands/feature.md +368 -80
  137. package/templates/commands/serve.md +118 -0
  138. package/templates/commands/ship.md +152 -14
  139. package/templates/commands/skill.md +110 -0
  140. package/templates/commands/sync.md +63 -4
  141. package/templates/commands/test.md +40 -188
  142. package/templates/mcp-config.json +0 -36
  143. package/templates/permissions/default.jsonc +60 -0
  144. package/templates/permissions/permissive.jsonc +49 -0
  145. package/templates/permissions/strict.jsonc +62 -0
  146. package/templates/skills/code-review.md +47 -0
  147. package/templates/skills/debug.md +61 -0
  148. package/templates/skills/refactor.md +47 -0
  149. package/templates/subagents/domain/devops.md +1 -1
  150. package/templates/subagents/domain/testing.md +6 -10
  151. package/templates/subagents/workflow/prjct-shipper.md +16 -7
  152. package/templates/tools/bash.txt +22 -0
  153. package/templates/tools/edit.txt +18 -0
  154. package/templates/tools/glob.txt +19 -0
  155. package/templates/tools/grep.txt +21 -0
  156. package/templates/tools/read.txt +14 -0
  157. package/templates/tools/task.txt +20 -0
  158. package/templates/tools/webfetch.txt +16 -0
  159. package/templates/tools/websearch.txt +18 -0
  160. package/templates/tools/write.txt +17 -0
  161. package/core/agentic/command-executor/command-executor.ts +0 -312
  162. package/core/agentic/command-executor/index.ts +0 -16
  163. package/core/agentic/command-executor/status-signal.ts +0 -38
  164. package/core/agentic/command-executor/types.ts +0 -79
  165. package/core/agentic/ground-truth/index.ts +0 -76
  166. package/core/agentic/ground-truth/types.ts +0 -33
  167. package/core/agentic/ground-truth/utils.ts +0 -48
  168. package/core/agentic/ground-truth/verifiers/analyze.ts +0 -54
  169. package/core/agentic/ground-truth/verifiers/done.ts +0 -75
  170. package/core/agentic/ground-truth/verifiers/feature.ts +0 -70
  171. package/core/agentic/ground-truth/verifiers/index.ts +0 -37
  172. package/core/agentic/ground-truth/verifiers/init.ts +0 -52
  173. package/core/agentic/ground-truth/verifiers/now.ts +0 -57
  174. package/core/agentic/ground-truth/verifiers/ship.ts +0 -85
  175. package/core/agentic/ground-truth/verifiers/spec.ts +0 -45
  176. package/core/agentic/ground-truth/verifiers/sync.ts +0 -47
  177. package/core/agentic/ground-truth/verifiers.ts +0 -6
  178. package/core/agentic/loop-detector/error-analysis.ts +0 -97
  179. package/core/agentic/loop-detector/hallucination.ts +0 -71
  180. package/core/agentic/loop-detector/index.ts +0 -41
  181. package/core/agentic/loop-detector/loop-detector.ts +0 -222
  182. package/core/agentic/loop-detector/types.ts +0 -66
  183. package/core/agentic/memory-system/history.ts +0 -53
  184. package/core/agentic/memory-system/index.ts +0 -192
  185. package/core/agentic/memory-system/patterns.ts +0 -156
  186. package/core/agentic/memory-system/semantic-memories.ts +0 -278
  187. package/core/agentic/memory-system/session.ts +0 -21
  188. package/core/agentic/plan-mode/approval.ts +0 -57
  189. package/core/agentic/plan-mode/constants.ts +0 -44
  190. package/core/agentic/plan-mode/index.ts +0 -28
  191. package/core/agentic/plan-mode/plan-mode.ts +0 -407
  192. package/core/agentic/plan-mode/types.ts +0 -193
  193. package/core/agents/types.ts +0 -126
  194. package/core/command-registry/categories.ts +0 -23
  195. package/core/command-registry/commands.ts +0 -15
  196. package/core/command-registry/core-commands.ts +0 -344
  197. package/core/command-registry/index.ts +0 -158
  198. package/core/command-registry/optional-commands.ts +0 -163
  199. package/core/command-registry/setup-commands.ts +0 -83
  200. package/core/command-registry/types.ts +0 -59
  201. package/core/command-registry.ts +0 -9
  202. package/core/commands/types.ts +0 -185
  203. package/core/commands.ts +0 -11
  204. package/core/constants/formats.ts +0 -187
  205. package/core/context-sync.ts +0 -18
  206. package/core/data/index.ts +0 -27
  207. package/core/data/md-base-manager.ts +0 -203
  208. package/core/data/md-ideas-manager.ts +0 -155
  209. package/core/data/md-queue-manager.ts +0 -180
  210. package/core/data/md-shipped-manager.ts +0 -90
  211. package/core/data/md-state-manager.ts +0 -137
  212. package/core/domain/task-stack/index.ts +0 -19
  213. package/core/domain/task-stack/parser.ts +0 -86
  214. package/core/domain/task-stack/storage.ts +0 -123
  215. package/core/domain/task-stack/task-stack.ts +0 -340
  216. package/core/domain/task-stack/types.ts +0 -51
  217. package/core/infrastructure/command-installer/command-installer.ts +0 -327
  218. package/core/infrastructure/command-installer/global-config.ts +0 -136
  219. package/core/infrastructure/command-installer/index.ts +0 -25
  220. package/core/infrastructure/command-installer/types.ts +0 -41
  221. package/core/infrastructure/session-manager/index.ts +0 -23
  222. package/core/infrastructure/session-manager/types.ts +0 -45
  223. package/core/infrastructure/session-manager.ts +0 -8
  224. package/core/serializers/ideas-serializer.ts +0 -187
  225. package/core/serializers/index.ts +0 -36
  226. package/core/serializers/queue-serializer.ts +0 -210
  227. package/core/serializers/shipped-serializer.ts +0 -108
  228. package/core/serializers/state-serializer.ts +0 -136
  229. package/core/session/types.ts +0 -29
  230. /package/core/infrastructure/{agents/claude-agent.ts → claude-agent.ts} +0 -0
@@ -0,0 +1,577 @@
1
+ /**
2
+ * Agentic Types
3
+ * Types for the agentic system.
4
+ */
5
+
6
+ import type { CommandParams } from './core'
7
+
8
+ // =============================================================================
9
+ // Tool Registry Types
10
+ // =============================================================================
11
+
12
+ export type ToolFunction = (...args: unknown[]) => Promise<unknown>
13
+
14
+ export interface ToolRegistryInterface {
15
+ tools: Map<string, ToolFunction>
16
+ register(name: string, fn: ToolFunction): void
17
+ get(name: string): ToolFunction | undefined
18
+ isAllowed(name: string, allowedTools: string[]): boolean
19
+ list(): string[]
20
+ }
21
+
22
+ export interface ToolDefinition {
23
+ name: string
24
+ description: string
25
+ handler: ToolFunction
26
+ parallelizable: boolean
27
+ }
28
+
29
+ export interface ToolRegistry {
30
+ get(name: string): ToolFunction | undefined
31
+ list(): string[]
32
+ has(name: string): boolean
33
+ }
34
+
35
+ export interface BashResult {
36
+ stdout: string
37
+ stderr: string
38
+ code: number
39
+ }
40
+
41
+ // =============================================================================
42
+ // Context Types
43
+ // =============================================================================
44
+
45
+ export type ContextDomain = 'frontend' | 'backend' | 'devops' | 'docs' | 'testing' | 'general'
46
+
47
+ export interface ContextState {
48
+ [key: string]: string | null
49
+ }
50
+
51
+ export interface SmartContextProjectState {
52
+ projectId: string
53
+ currentTask: { description: string; startedAt: string } | null
54
+ queue: { description: string; priority: string }[]
55
+ }
56
+
57
+ export interface FullContext {
58
+ state: SmartContextProjectState | null
59
+ agents: AgentInfo[]
60
+ roadmap: FeatureInfo[]
61
+ patterns: PatternInfo[]
62
+ stack: StackInfo
63
+ files: string[]
64
+ projectPath: string
65
+ }
66
+
67
+ export interface FilteredContext {
68
+ agents: AgentInfo[]
69
+ roadmap: FeatureInfo[]
70
+ patterns: PatternInfo[]
71
+ stack: Partial<StackInfo>
72
+ files: string[]
73
+ metrics: FilterMetrics
74
+ }
75
+
76
+ export interface AgentInfo {
77
+ name: string
78
+ domain: ContextDomain
79
+ skills: string[]
80
+ successRate?: number
81
+ }
82
+
83
+ export interface FeatureInfo {
84
+ id: string
85
+ name: string
86
+ relatedTo: ContextDomain[]
87
+ status: string
88
+ }
89
+
90
+ export interface PatternInfo {
91
+ description: string
92
+ domain: ContextDomain
93
+ confidence: number
94
+ }
95
+
96
+ export interface StackInfo {
97
+ frontend: string[]
98
+ backend: string[]
99
+ devops: string[]
100
+ database: string[]
101
+ testing: string[]
102
+ }
103
+
104
+ export interface FilterMetrics {
105
+ originalSize: number
106
+ filteredSize: number
107
+ reductionPercent: number
108
+ domain: ContextDomain
109
+ }
110
+
111
+ export interface DomainAnalysis {
112
+ primary: ContextDomain
113
+ secondary: ContextDomain[]
114
+ confidence: number
115
+ }
116
+
117
+ // =============================================================================
118
+ // Prompt Builder Types
119
+ // =============================================================================
120
+
121
+ export interface PromptProjectState {
122
+ projectId: string
123
+ currentTask: { description: string; startedAt: string; estimate?: string } | null
124
+ queue: { description: string; priority: string }[]
125
+ }
126
+
127
+ export interface Frontmatter {
128
+ name?: string
129
+ description?: string
130
+ 'allowed-tools'?: string[]
131
+ [key: string]: unknown
132
+ }
133
+
134
+ export interface Template {
135
+ frontmatter: Frontmatter
136
+ content: string
137
+ }
138
+
139
+ export interface PromptAgent {
140
+ name: string
141
+ role?: string
142
+ skills?: string[]
143
+ [key: string]: unknown
144
+ }
145
+
146
+ export interface PromptContext {
147
+ files?: string[]
148
+ filteredSize?: number
149
+ projectPath?: string
150
+ projectId?: string
151
+ params?: { task?: string; description?: string }
152
+ [key: string]: unknown
153
+ }
154
+
155
+ export interface PromptState {
156
+ codePatterns?: string
157
+ analysis?: string
158
+ [key: string]: unknown
159
+ }
160
+
161
+ /**
162
+ * Learned patterns from memory (Record version)
163
+ */
164
+ export type LearnedPatternsRecord = Record<string, string | null>
165
+
166
+ export interface ThinkBlock {
167
+ plan?: string[]
168
+ conclusions?: string[]
169
+ confidence?: number
170
+ }
171
+
172
+ export interface PlanInfo {
173
+ isPlanning?: boolean
174
+ requiresApproval?: boolean
175
+ allowedTools?: string[]
176
+ active?: Plan | null
177
+ }
178
+
179
+ // =============================================================================
180
+ // Ground Truth Types
181
+ // =============================================================================
182
+
183
+ export interface GroundTruthContext {
184
+ projectPath: string
185
+ projectId?: string | null
186
+ paths: {
187
+ now: string
188
+ next: string
189
+ metrics: string
190
+ shipped: string
191
+ roadmap: string
192
+ specs: string
193
+ [key: string]: string
194
+ }
195
+ params: {
196
+ feature?: string
197
+ description?: string
198
+ task?: string
199
+ name?: string
200
+ [key: string]: unknown
201
+ }
202
+ }
203
+
204
+ export interface VerificationResult {
205
+ verified: boolean
206
+ actual: Record<string, unknown>
207
+ warnings: string[]
208
+ recommendations: string[]
209
+ }
210
+
211
+ export type Verifier = (context: GroundTruthContext, state: unknown) => Promise<VerificationResult>
212
+
213
+ // =============================================================================
214
+ // Plan Mode Types
215
+ // =============================================================================
216
+
217
+ export interface PlanParams extends CommandParams {
218
+ /** Skip approval prompt */
219
+ autoApprove?: boolean
220
+ /** Verbose output during planning */
221
+ verbose?: boolean
222
+ }
223
+
224
+ export interface GatheredInfo {
225
+ type: GatheredInfoType
226
+ source: string
227
+ data: string | GatheredFileData | GatheredAnalysisData
228
+ gatheredAt: string
229
+ }
230
+
231
+ export type GatheredInfoType =
232
+ | 'file_content'
233
+ | 'git_status'
234
+ | 'git_diff'
235
+ | 'analysis'
236
+ | 'dependencies'
237
+ | 'structure'
238
+
239
+ export interface GatheredFileData {
240
+ path: string
241
+ content: string
242
+ lines: number
243
+ }
244
+
245
+ export interface GatheredAnalysisData {
246
+ summary: string
247
+ findings: string[]
248
+ }
249
+
250
+ export interface ProposedPlan {
251
+ summary: string
252
+ approach: string
253
+ steps: PlanStepDefinition[]
254
+ risks?: string[]
255
+ alternatives?: string[]
256
+ estimatedTime?: string
257
+ affectedFiles: string[]
258
+ }
259
+
260
+ export interface PlanStepDefinition {
261
+ description: string
262
+ tool?: string
263
+ args?: string[]
264
+ }
265
+
266
+ export interface PlanStep {
267
+ index: number
268
+ description: string
269
+ status: 'pending' | 'completed' | 'failed'
270
+ tool?: string
271
+ args?: string[]
272
+ result?: PlanStepResult
273
+ completedAt?: string
274
+ error?: string
275
+ }
276
+
277
+ export interface PlanStepResult {
278
+ success: boolean
279
+ output?: string
280
+ filesModified?: string[]
281
+ }
282
+
283
+ export type PlanStatus =
284
+ | 'gathering'
285
+ | 'analyzing'
286
+ | 'proposing'
287
+ | 'awaiting_approval'
288
+ | 'approved'
289
+ | 'rejected'
290
+ | 'executing'
291
+ | 'completed'
292
+ | 'aborted'
293
+
294
+ export interface Plan {
295
+ id: string
296
+ projectId: string
297
+ command: string
298
+ params: PlanParams
299
+ status: PlanStatus
300
+ startedAt: string
301
+ gatheredInfo: GatheredInfo[]
302
+ analysis: PlanAnalysis | null
303
+ proposedPlan: ProposedPlan | null
304
+ userFeedback: string | null
305
+ approvedAt: string | null
306
+ executionStartedAt: string | null
307
+ completedAt: string | null
308
+ steps: PlanStep[]
309
+ currentStep: number
310
+ abortReason?: string
311
+ }
312
+
313
+ export interface PlanAnalysis {
314
+ complexity: 'low' | 'medium' | 'high'
315
+ riskLevel: 'low' | 'medium' | 'high'
316
+ estimatedDuration: string
317
+ dependencies: string[]
318
+ }
319
+
320
+ export interface ApprovalPrompt {
321
+ title: string
322
+ message: string
323
+ details?: string[]
324
+ options: ApprovalOption[]
325
+ }
326
+
327
+ export interface ApprovalOption {
328
+ key: string
329
+ label: string
330
+ action: 'approve' | 'reject' | 'modify' | 'abort' | 'edit' | 'list'
331
+ }
332
+
333
+ export interface ApprovalContext {
334
+ branch?: string
335
+ changedFiles: ChangedFile[]
336
+ commitMessage?: string
337
+ filesToDelete: string[]
338
+ linesOfCode?: number
339
+ operation: ApprovalOperation
340
+ warnings: string[]
341
+ }
342
+
343
+ export interface ChangedFile {
344
+ path: string
345
+ action: 'create' | 'modify' | 'delete'
346
+ linesAdded?: number
347
+ linesRemoved?: number
348
+ }
349
+
350
+ export type ApprovalOperation =
351
+ | 'create_files'
352
+ | 'modify_files'
353
+ | 'delete_files'
354
+ | 'git_commit'
355
+ | 'git_push'
356
+ | 'run_command'
357
+
358
+ // =============================================================================
359
+ // Loop Detector Types
360
+ // =============================================================================
361
+
362
+ export interface ErrorEntry {
363
+ message: string
364
+ timestamp: number
365
+ }
366
+
367
+ export interface AttemptRecord {
368
+ command: string
369
+ context: string
370
+ attempts: number
371
+ errors: ErrorEntry[]
372
+ firstAttempt: number
373
+ lastAttempt: number
374
+ success: boolean
375
+ }
376
+
377
+ export interface ErrorPattern {
378
+ type: string
379
+ description: string
380
+ }
381
+
382
+ export interface EscalationInfo {
383
+ status: string
384
+ command: string
385
+ context: string
386
+ attempts: number
387
+ duration: number
388
+ errorPattern: ErrorPattern
389
+ message: string
390
+ suggestion: string
391
+ lastError: string | null
392
+ }
393
+
394
+ export interface AttemptResult {
395
+ success?: boolean
396
+ error?: string
397
+ }
398
+
399
+ export interface AttemptInfo {
400
+ attemptNumber: number
401
+ isLooping: boolean
402
+ shouldEscalate: boolean
403
+ }
404
+
405
+ export interface HallucinationPattern {
406
+ pattern: RegExp
407
+ type: string
408
+ description: string
409
+ }
410
+
411
+ export interface HallucinationResult {
412
+ detected: boolean
413
+ type?: string
414
+ pattern?: string
415
+ description?: string
416
+ message?: string
417
+ suggestion?: string
418
+ }
419
+
420
+ export interface OutputAnalysis extends HallucinationResult {
421
+ shouldBlock: boolean
422
+ action?: string
423
+ }
424
+
425
+ // =============================================================================
426
+ // Command Executor Types
427
+ // =============================================================================
428
+
429
+ export interface ExecutionResult {
430
+ success: boolean
431
+ error?: string
432
+ escalation?: EscalationInfo | null
433
+ isLoopDetected?: boolean
434
+ suggestion?: string
435
+ validation?: unknown
436
+ isValidationError?: boolean
437
+ template?: unknown
438
+ context?: unknown
439
+ state?: unknown
440
+ prompt?: string
441
+ agenticDelegation?: boolean
442
+ agentsPath?: string
443
+ agentRoutingPath?: string
444
+ reasoning?: unknown
445
+ thinkBlock?: unknown
446
+ groundTruth?: unknown
447
+ compressionMetrics?: unknown
448
+ learnedPatterns?: unknown
449
+ relevantMemories?: unknown
450
+ formatResponse?: (data: unknown) => string
451
+ formatThinkBlock?: (verbose: boolean) => string
452
+ parallel?: {
453
+ execute: (toolCalls: unknown[]) => Promise<unknown>
454
+ readAll: (paths: string[]) => Promise<Map<string, string | null>>
455
+ canParallelize: (tools: string[]) => boolean
456
+ getMetrics: () => unknown
457
+ }
458
+ memory?: {
459
+ create: (memory: unknown) => Promise<string>
460
+ autoRemember: (type: string, value: string, ctx?: string) => Promise<void>
461
+ search: (query: string) => Promise<unknown[]>
462
+ findByTags: (tags: string[]) => Promise<unknown[]>
463
+ getStats: () => Promise<unknown>
464
+ }
465
+ plan?: {
466
+ active: unknown
467
+ isPlanning: boolean
468
+ isDestructive: boolean
469
+ requiresApproval: boolean
470
+ recordInfo: (info: unknown) => void
471
+ setAnalysis: (analysis: unknown) => void
472
+ propose: (plan: unknown) => unknown
473
+ approve: (feedback?: string | null) => unknown
474
+ reject: (reason?: string | null) => unknown
475
+ getApprovalPrompt: () => unknown
476
+ startExecution: () => unknown
477
+ getNextStep: () => unknown
478
+ completeStep: (result?: unknown) => unknown
479
+ failStep: (error: string) => unknown
480
+ abort: (reason?: string) => unknown
481
+ getStatus: () => string
482
+ getAllowedTools: () => string[]
483
+ }
484
+ attemptNumber?: number
485
+ isLooping?: boolean
486
+ }
487
+
488
+ export interface SimpleExecutionResult {
489
+ success: boolean
490
+ result?: unknown
491
+ error?: string
492
+ }
493
+
494
+ export type ExecutionToolsFn = (
495
+ tools: {
496
+ read: (path: string) => Promise<unknown>
497
+ write: (path: string, content: string) => Promise<unknown>
498
+ bash: (cmd: string) => Promise<unknown>
499
+ },
500
+ context: unknown
501
+ ) => Promise<unknown>
502
+
503
+ // =============================================================================
504
+ // Template Loader Types
505
+ // =============================================================================
506
+
507
+ export interface ParsedTemplate {
508
+ frontmatter: Frontmatter
509
+ content: string
510
+ raw?: string
511
+ }
512
+
513
+ // =============================================================================
514
+ // Skill Loader Types
515
+ // =============================================================================
516
+
517
+ export interface FormattedSkill {
518
+ id?: string
519
+ name: string
520
+ description?: string
521
+ prompt?: string
522
+ content?: string
523
+ }
524
+
525
+ export interface SkillContext {
526
+ skills?: FormattedSkill[]
527
+ availableSkills: FormattedSkill[]
528
+ skillsMarkdown: string
529
+ projectPath?: string
530
+ timestamp?: string
531
+ }
532
+
533
+ // =============================================================================
534
+ // Chain of Thought Types
535
+ // =============================================================================
536
+
537
+ export interface ChainOfThoughtContext {
538
+ projectPath?: string
539
+ projectId?: string | null
540
+ paths?: Record<string, string>
541
+ params?: Record<string, unknown>
542
+ }
543
+
544
+ export interface ChainOfThoughtState {
545
+ currentTask?: { description: string; startedAt: string } | null
546
+ queue?: { description: string; priority: string }[]
547
+ [key: string]: unknown
548
+ }
549
+
550
+ export interface ReasoningStep {
551
+ step: string
552
+ result: string
553
+ passed: boolean
554
+ }
555
+
556
+ export interface ReasoningResult {
557
+ steps: ReasoningStep[]
558
+ allPassed: boolean
559
+ plan: string[]
560
+ }
561
+
562
+ export interface ChainOfThoughtResult {
563
+ reasoning: ReasoningResult | null
564
+ thinkBlock: string | null
565
+ }
566
+
567
+ // =============================================================================
568
+ // Learned Patterns Type
569
+ // =============================================================================
570
+
571
+ export interface LearnedPatterns {
572
+ commit_footer?: string | null
573
+ branch_naming?: string | null
574
+ test_before_ship?: string | null
575
+ preferred_agent?: string | null
576
+ [key: string]: string | null | undefined
577
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Agent Types
3
+ * Types for agent routing and assignment.
4
+ */
5
+
6
+ import type { ContextDomain } from './agentic'
7
+
8
+ // ============================================
9
+ // Task Types
10
+ // ============================================
11
+
12
+ /**
13
+ * Task type categories for agent routing.
14
+ */
15
+ export type TaskType =
16
+ | 'frontend'
17
+ | 'backend'
18
+ | 'devops'
19
+ | 'database'
20
+ | 'testing'
21
+ | 'documentation'
22
+ | 'refactoring'
23
+ | 'bugfix'
24
+ | 'feature'
25
+ | 'design'
26
+ | 'other'
27
+
28
+ /**
29
+ * Agent performance record.
30
+ */
31
+ export interface AgentPerformance {
32
+ agentName: string
33
+ taskType: TaskType
34
+ tasksCompleted: number
35
+ successRate: number
36
+ avgDuration: string
37
+ estimateAccuracy: number
38
+ improving: boolean
39
+ lastUpdated: string
40
+ bestFor: TaskType[]
41
+ avoidFor: TaskType[]
42
+ }
43
+
44
+ /**
45
+ * Task completion record for agent performance tracking.
46
+ */
47
+ export interface AgentTaskRecord {
48
+ agentName: string
49
+ taskType: TaskType
50
+ success: boolean
51
+ estimatedDuration: string
52
+ actualDuration: string
53
+ qualityScore: 1 | 2 | 3 | 4 | 5
54
+ completedAt: string
55
+ notes?: string
56
+ }
57
+
58
+ /**
59
+ * Agent routing suggestion.
60
+ */
61
+ export interface AgentSuggestion {
62
+ agentName: string
63
+ confidence: number
64
+ reason: string
65
+ alternatives?: string[]
66
+ }
67
+
68
+ /**
69
+ * Agent performance summary for a project.
70
+ */
71
+ export interface AgentPerformanceSummary {
72
+ totalAgents: number
73
+ topPerformer: string | null
74
+ mostUsed: string | null
75
+ avgSuccessRate: number
76
+ byTaskType: Record<TaskType, string | null>
77
+ }
78
+
79
+ // ============================================
80
+ // Agent Types
81
+ // ============================================
82
+
83
+ /**
84
+ * Agent representation - from simple file to full metadata.
85
+ * Only name and content are required for basic loading.
86
+ */
87
+ export interface Agent {
88
+ name: string
89
+ content: string
90
+ path?: string
91
+ role?: string | null
92
+ domain?: string | null
93
+ skills?: string[]
94
+ modified?: Date
95
+ }
96
+
97
+ /**
98
+ * Consolidated agent info for routing and detection.
99
+ * Combines fields from all previous AgentInfo definitions.
100
+ */
101
+ export interface AgentInfo {
102
+ name: string
103
+ type?: string
104
+ domain?: string | ContextDomain
105
+ skills?: string[]
106
+ successRate?: number
107
+ isSupported?: boolean
108
+ }
109
+
110
+ /**
111
+ * Agent routing decision result.
112
+ * Contains the selected agent, confidence, and reasoning.
113
+ */
114
+ export interface AgentRouting {
115
+ agent: AgentInfo
116
+ confidence: number
117
+ reason: string
118
+ availableAgents: string[]
119
+ }
120
+
121
+ /**
122
+ * Context for agent assignment decisions.
123
+ * Provides task and environment info for routing.
124
+ */
125
+ export interface AssignmentContext {
126
+ task: string
127
+ availableAgents: string[]
128
+ projectPath: string
129
+ projectId: string | null
130
+ _template: string
131
+ }
132
+
133
+ /**
134
+ * Result of agent assignment operation.
135
+ * Contains assigned agent and routing metadata.
136
+ */
137
+ export interface AgentAssignmentResult {
138
+ agent: { name: string; domain?: string } | null
139
+ routing: {
140
+ confidence: number
141
+ reason: string
142
+ availableAgents?: string[]
143
+ }
144
+ _agenticNote?: string
145
+ }