cto-ai-cli 1.3.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.
- package/LICENSE +21 -0
- package/README.md +326 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +6331 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.d.ts +717 -0
- package/dist/core/index.js +4446 -0
- package/dist/core/index.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +15336 -0
- package/dist/mcp/index.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
import { Project } from 'ts-morph';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
|
|
4
|
+
type Tier = 'hot' | 'warm' | 'cold';
|
|
5
|
+
type ModelPreference = 'opus' | 'sonnet' | 'haiku';
|
|
6
|
+
interface FileInfo {
|
|
7
|
+
path: string;
|
|
8
|
+
relativePath: string;
|
|
9
|
+
size: number;
|
|
10
|
+
tokens: number;
|
|
11
|
+
extension: string;
|
|
12
|
+
lastModified: Date;
|
|
13
|
+
lastAccessed: Date;
|
|
14
|
+
tier: Tier;
|
|
15
|
+
lines: number;
|
|
16
|
+
imports?: string[];
|
|
17
|
+
importedBy?: string[];
|
|
18
|
+
importCount?: number;
|
|
19
|
+
importedByCount?: number;
|
|
20
|
+
isHub?: boolean;
|
|
21
|
+
complexity?: number;
|
|
22
|
+
modelSuggestion?: ModelPreference;
|
|
23
|
+
}
|
|
24
|
+
interface TierThresholds {
|
|
25
|
+
hotDays: number;
|
|
26
|
+
warmDays: number;
|
|
27
|
+
hotTokenLimit: number;
|
|
28
|
+
warmTokenLimit: number;
|
|
29
|
+
}
|
|
30
|
+
interface ProjectAnalysis {
|
|
31
|
+
projectPath: string;
|
|
32
|
+
projectName: string;
|
|
33
|
+
totalFiles: number;
|
|
34
|
+
totalTokens: number;
|
|
35
|
+
totalSize: number;
|
|
36
|
+
files: FileInfo[];
|
|
37
|
+
tiers: TierSummary;
|
|
38
|
+
analyzedAt: Date;
|
|
39
|
+
dependencyGraph?: DependencyGraph;
|
|
40
|
+
tokenEstimationMethod?: 'chars4' | 'tiktoken';
|
|
41
|
+
}
|
|
42
|
+
interface TierSummary {
|
|
43
|
+
hot: TierDetail;
|
|
44
|
+
warm: TierDetail;
|
|
45
|
+
cold: TierDetail;
|
|
46
|
+
}
|
|
47
|
+
interface TierDetail {
|
|
48
|
+
files: FileInfo[];
|
|
49
|
+
totalTokens: number;
|
|
50
|
+
totalSize: number;
|
|
51
|
+
count: number;
|
|
52
|
+
percentage: number;
|
|
53
|
+
}
|
|
54
|
+
interface CTOConfig {
|
|
55
|
+
version: string;
|
|
56
|
+
extensions: ExtensionConfig;
|
|
57
|
+
tiering: TierThresholds;
|
|
58
|
+
ignoreDirs: string[];
|
|
59
|
+
ignorePatterns: string[];
|
|
60
|
+
model: ModelPreference;
|
|
61
|
+
tokenEstimation: 'chars4' | 'tiktoken';
|
|
62
|
+
}
|
|
63
|
+
interface ExtensionConfig {
|
|
64
|
+
code: string[];
|
|
65
|
+
config: string[];
|
|
66
|
+
docs: string[];
|
|
67
|
+
ignore: string[];
|
|
68
|
+
}
|
|
69
|
+
interface ProjectConfig extends Partial<CTOConfig> {
|
|
70
|
+
projectPath: string;
|
|
71
|
+
customRules?: string[];
|
|
72
|
+
}
|
|
73
|
+
interface GeneratedArtifact {
|
|
74
|
+
type: 'claude-md' | 'claudeignore';
|
|
75
|
+
content: string;
|
|
76
|
+
targetPath: string;
|
|
77
|
+
projectPath: string;
|
|
78
|
+
}
|
|
79
|
+
interface BackupEntry {
|
|
80
|
+
id: string;
|
|
81
|
+
artifactType: 'claude-md' | 'claudeignore';
|
|
82
|
+
originalPath: string;
|
|
83
|
+
backupPath: string;
|
|
84
|
+
timestamp: Date;
|
|
85
|
+
projectPath: string;
|
|
86
|
+
hadOriginal: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface ApplyResult {
|
|
89
|
+
success: boolean;
|
|
90
|
+
artifact: GeneratedArtifact;
|
|
91
|
+
backup?: BackupEntry;
|
|
92
|
+
error?: string;
|
|
93
|
+
}
|
|
94
|
+
interface RevertResult {
|
|
95
|
+
success: boolean;
|
|
96
|
+
backup: BackupEntry;
|
|
97
|
+
error?: string;
|
|
98
|
+
}
|
|
99
|
+
interface SessionInfo {
|
|
100
|
+
id: string;
|
|
101
|
+
projectPath: string;
|
|
102
|
+
startedAt: Date;
|
|
103
|
+
endedAt?: Date;
|
|
104
|
+
tokensEstimated: number;
|
|
105
|
+
filesRead: string[];
|
|
106
|
+
description?: string;
|
|
107
|
+
coldFilesRead: number;
|
|
108
|
+
warmFilesRead: number;
|
|
109
|
+
hotFilesRead: number;
|
|
110
|
+
suggestions: string[];
|
|
111
|
+
}
|
|
112
|
+
interface PromptTemplate {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
template: string;
|
|
117
|
+
category: 'task' | 'review' | 'debug' | 'refactor' | 'test';
|
|
118
|
+
}
|
|
119
|
+
interface DiffResult {
|
|
120
|
+
artifact: GeneratedArtifact;
|
|
121
|
+
currentContent: string | null;
|
|
122
|
+
diff: string;
|
|
123
|
+
hasChanges: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface DependencyEdge {
|
|
126
|
+
from: string;
|
|
127
|
+
to: string;
|
|
128
|
+
type: 'import' | 'export' | 're-export';
|
|
129
|
+
}
|
|
130
|
+
interface DependencyGraph {
|
|
131
|
+
nodes: string[];
|
|
132
|
+
edges: DependencyEdge[];
|
|
133
|
+
hubs: HubFile[];
|
|
134
|
+
leaves: string[];
|
|
135
|
+
}
|
|
136
|
+
interface HubFile {
|
|
137
|
+
relativePath: string;
|
|
138
|
+
importedByCount: number;
|
|
139
|
+
importCount: number;
|
|
140
|
+
score: number;
|
|
141
|
+
}
|
|
142
|
+
interface FileComplexity {
|
|
143
|
+
relativePath: string;
|
|
144
|
+
cyclomaticComplexity: number;
|
|
145
|
+
functions: FunctionComplexity[];
|
|
146
|
+
modelSuggestion: ModelPreference;
|
|
147
|
+
}
|
|
148
|
+
interface FunctionComplexity {
|
|
149
|
+
name: string;
|
|
150
|
+
complexity: number;
|
|
151
|
+
startLine: number;
|
|
152
|
+
endLine: number;
|
|
153
|
+
}
|
|
154
|
+
interface WatchEvent {
|
|
155
|
+
type: 'add' | 'change' | 'unlink';
|
|
156
|
+
filePath: string;
|
|
157
|
+
relativePath: string;
|
|
158
|
+
timestamp: Date;
|
|
159
|
+
}
|
|
160
|
+
interface TierChangeEvent {
|
|
161
|
+
relativePath: string;
|
|
162
|
+
previousTier: Tier;
|
|
163
|
+
newTier: Tier;
|
|
164
|
+
reason: string;
|
|
165
|
+
}
|
|
166
|
+
interface SessionFileRead {
|
|
167
|
+
relativePath: string;
|
|
168
|
+
tier: Tier;
|
|
169
|
+
tokens: number;
|
|
170
|
+
timestamp: Date;
|
|
171
|
+
}
|
|
172
|
+
interface SessionMetrics {
|
|
173
|
+
totalSessions: number;
|
|
174
|
+
totalTokensConsumed: number;
|
|
175
|
+
totalTokensSaved: number;
|
|
176
|
+
savingsPercent: number;
|
|
177
|
+
averageSessionDuration: number;
|
|
178
|
+
mostReadFiles: Array<{
|
|
179
|
+
relativePath: string;
|
|
180
|
+
readCount: number;
|
|
181
|
+
tier: Tier;
|
|
182
|
+
}>;
|
|
183
|
+
wastePatterns: WastePattern[];
|
|
184
|
+
}
|
|
185
|
+
interface WastePattern {
|
|
186
|
+
type: 'cold-reads' | 'repeated-reads' | 'large-context';
|
|
187
|
+
description: string;
|
|
188
|
+
impact: number;
|
|
189
|
+
suggestion: string;
|
|
190
|
+
}
|
|
191
|
+
interface DashboardData {
|
|
192
|
+
projectName: string;
|
|
193
|
+
sessionsToday: number;
|
|
194
|
+
tokensConsumed: number;
|
|
195
|
+
tokensSaved: number;
|
|
196
|
+
savingsRatio: number;
|
|
197
|
+
mostReadFiles: Array<{
|
|
198
|
+
relativePath: string;
|
|
199
|
+
readCount: number;
|
|
200
|
+
}>;
|
|
201
|
+
suggestions: string[];
|
|
202
|
+
tiers: TierSummary;
|
|
203
|
+
recentSessions: SessionInfo[];
|
|
204
|
+
}
|
|
205
|
+
interface WeeklyReport {
|
|
206
|
+
projectPath: string;
|
|
207
|
+
projectName: string;
|
|
208
|
+
weekStart: Date;
|
|
209
|
+
weekEnd: Date;
|
|
210
|
+
sessions: SessionInfo[];
|
|
211
|
+
totalTokensConsumed: number;
|
|
212
|
+
totalTokensSaved: number;
|
|
213
|
+
trend: number;
|
|
214
|
+
topFiles: Array<{
|
|
215
|
+
relativePath: string;
|
|
216
|
+
readCount: number;
|
|
217
|
+
}>;
|
|
218
|
+
suggestions: string[];
|
|
219
|
+
}
|
|
220
|
+
interface MCPToolResult {
|
|
221
|
+
content: Array<{
|
|
222
|
+
type: 'text';
|
|
223
|
+
text: string;
|
|
224
|
+
}>;
|
|
225
|
+
isError?: boolean;
|
|
226
|
+
}
|
|
227
|
+
interface SecurityConfig {
|
|
228
|
+
encryptionEnabled: boolean;
|
|
229
|
+
secretDetection: boolean;
|
|
230
|
+
auditLogging: boolean;
|
|
231
|
+
retentionDays: number;
|
|
232
|
+
securePermissions: boolean;
|
|
233
|
+
customSecretPatterns?: string[];
|
|
234
|
+
}
|
|
235
|
+
interface SecretFinding {
|
|
236
|
+
type: SecretType;
|
|
237
|
+
file: string;
|
|
238
|
+
line: number;
|
|
239
|
+
match: string;
|
|
240
|
+
redacted: string;
|
|
241
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
242
|
+
}
|
|
243
|
+
type SecretType = 'api-key' | 'aws-key' | 'private-key' | 'password' | 'token' | 'connection-string' | 'env-variable' | 'custom';
|
|
244
|
+
interface AuditEntry {
|
|
245
|
+
id: string;
|
|
246
|
+
timestamp: Date;
|
|
247
|
+
action: AuditAction;
|
|
248
|
+
user: string;
|
|
249
|
+
projectPath: string;
|
|
250
|
+
details: Record<string, unknown>;
|
|
251
|
+
integrityHash: string;
|
|
252
|
+
}
|
|
253
|
+
type AuditAction = 'analyze' | 'generate' | 'apply' | 'revert' | 'clean' | 'session-start' | 'session-end' | 'config-change' | 'secret-detected' | 'integrity-check' | 'data-purge';
|
|
254
|
+
interface IntegrityManifest {
|
|
255
|
+
version: string;
|
|
256
|
+
createdAt: Date;
|
|
257
|
+
entries: IntegrityEntry[];
|
|
258
|
+
}
|
|
259
|
+
interface IntegrityEntry {
|
|
260
|
+
filePath: string;
|
|
261
|
+
hash: string;
|
|
262
|
+
size: number;
|
|
263
|
+
createdAt: Date;
|
|
264
|
+
type: 'artifact' | 'backup' | 'config' | 'session';
|
|
265
|
+
}
|
|
266
|
+
interface ValidationResult {
|
|
267
|
+
valid: boolean;
|
|
268
|
+
errors: string[];
|
|
269
|
+
warnings: string[];
|
|
270
|
+
artifactsUpToDate: boolean;
|
|
271
|
+
integrityOk: boolean;
|
|
272
|
+
secretsClean: boolean;
|
|
273
|
+
}
|
|
274
|
+
interface DoctorCheck {
|
|
275
|
+
name: string;
|
|
276
|
+
status: 'pass' | 'warn' | 'fail';
|
|
277
|
+
message: string;
|
|
278
|
+
}
|
|
279
|
+
type PruneLevel = 'full' | 'signatures' | 'skeleton' | 'none';
|
|
280
|
+
interface PrunedFile {
|
|
281
|
+
relativePath: string;
|
|
282
|
+
originalTokens: number;
|
|
283
|
+
prunedTokens: number;
|
|
284
|
+
pruneLevel: PruneLevel;
|
|
285
|
+
content: string;
|
|
286
|
+
savings: number;
|
|
287
|
+
}
|
|
288
|
+
interface PruneResult {
|
|
289
|
+
files: PrunedFile[];
|
|
290
|
+
totalOriginalTokens: number;
|
|
291
|
+
totalPrunedTokens: number;
|
|
292
|
+
totalSavings: number;
|
|
293
|
+
savingsPercent: number;
|
|
294
|
+
}
|
|
295
|
+
interface GitFileInfo {
|
|
296
|
+
relativePath: string;
|
|
297
|
+
lastCommitDate: Date;
|
|
298
|
+
lastAuthor: string;
|
|
299
|
+
commitCount: number;
|
|
300
|
+
isInDiff: boolean;
|
|
301
|
+
isNewFile: boolean;
|
|
302
|
+
linesChanged: number;
|
|
303
|
+
}
|
|
304
|
+
interface GitContext {
|
|
305
|
+
branch: string;
|
|
306
|
+
isGitRepo: boolean;
|
|
307
|
+
changedFiles: GitFileInfo[];
|
|
308
|
+
recentCommits: number;
|
|
309
|
+
activeDevelopers: string[];
|
|
310
|
+
}
|
|
311
|
+
interface ModelPricing {
|
|
312
|
+
model: ModelPreference;
|
|
313
|
+
inputPerMillion: number;
|
|
314
|
+
outputPerMillion: number;
|
|
315
|
+
cacheReadPerMillion: number;
|
|
316
|
+
}
|
|
317
|
+
interface CostEstimate {
|
|
318
|
+
model: ModelPreference;
|
|
319
|
+
withoutCTO: CostBreakdown;
|
|
320
|
+
withCTO: CostBreakdown;
|
|
321
|
+
saved: CostBreakdown;
|
|
322
|
+
savingsPercent: number;
|
|
323
|
+
}
|
|
324
|
+
interface CostBreakdown {
|
|
325
|
+
tokens: number;
|
|
326
|
+
cost: number;
|
|
327
|
+
formatted: string;
|
|
328
|
+
}
|
|
329
|
+
interface BudgetResult {
|
|
330
|
+
budget: number;
|
|
331
|
+
usedTokens: number;
|
|
332
|
+
remainingTokens: number;
|
|
333
|
+
includedFiles: BudgetFile[];
|
|
334
|
+
excludedFiles: BudgetFile[];
|
|
335
|
+
fillPercent: number;
|
|
336
|
+
}
|
|
337
|
+
interface BudgetFile {
|
|
338
|
+
relativePath: string;
|
|
339
|
+
tokens: number;
|
|
340
|
+
tier: Tier;
|
|
341
|
+
pruneLevel: PruneLevel;
|
|
342
|
+
included: boolean;
|
|
343
|
+
reason: string;
|
|
344
|
+
}
|
|
345
|
+
type AITarget = 'claude' | 'cursor' | 'copilot' | 'gemini' | 'windsurf';
|
|
346
|
+
interface AIAdapter {
|
|
347
|
+
target: AITarget;
|
|
348
|
+
fileName: string;
|
|
349
|
+
generate: (analysis: ProjectAnalysis, config: CTOConfig) => string;
|
|
350
|
+
}
|
|
351
|
+
interface PRContext {
|
|
352
|
+
baseBranch: string;
|
|
353
|
+
changedFiles: string[];
|
|
354
|
+
dependencies: string[];
|
|
355
|
+
contextFiles: FileInfo[];
|
|
356
|
+
totalTokens: number;
|
|
357
|
+
generatedContent: string;
|
|
358
|
+
}
|
|
359
|
+
interface TierExplanation {
|
|
360
|
+
file: string;
|
|
361
|
+
tier: Tier;
|
|
362
|
+
factors: ExplainFactor[];
|
|
363
|
+
summary: string;
|
|
364
|
+
}
|
|
365
|
+
interface ExplainFactor {
|
|
366
|
+
name: string;
|
|
367
|
+
value: string;
|
|
368
|
+
impact: 'promotes' | 'neutral' | 'demotes';
|
|
369
|
+
weight: number;
|
|
370
|
+
}
|
|
371
|
+
type TaskType = 'debug' | 'review' | 'refactor' | 'test' | 'docs' | 'simple-edit' | 'feature' | 'architecture';
|
|
372
|
+
interface ModelRecommendation {
|
|
373
|
+
task: TaskType;
|
|
374
|
+
recommended: ModelPreference;
|
|
375
|
+
reason: string;
|
|
376
|
+
estimatedTokens: number;
|
|
377
|
+
estimatedCost: string;
|
|
378
|
+
alternatives: Array<{
|
|
379
|
+
model: ModelPreference;
|
|
380
|
+
reason: string;
|
|
381
|
+
}>;
|
|
382
|
+
}
|
|
383
|
+
interface RoutingRule {
|
|
384
|
+
task: TaskType;
|
|
385
|
+
maxComplexity: number;
|
|
386
|
+
maxFiles: number;
|
|
387
|
+
defaultModel: ModelPreference;
|
|
388
|
+
}
|
|
389
|
+
interface LocalProjectConfig {
|
|
390
|
+
version: string;
|
|
391
|
+
model?: ModelPreference;
|
|
392
|
+
autoRouting?: boolean;
|
|
393
|
+
tiering?: Partial<TierThresholds>;
|
|
394
|
+
ignoreDirs?: string[];
|
|
395
|
+
extensions?: Partial<ExtensionConfig>;
|
|
396
|
+
security?: Partial<SecurityConfig>;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare function estimateTokens(sizeInBytes: number): number;
|
|
400
|
+
declare function analyzeProject(projectPath: string): Promise<ProjectAnalysis>;
|
|
401
|
+
declare function loadAnalysis(projectPath: string): Promise<ProjectAnalysis | null>;
|
|
402
|
+
declare function detectStack(files: FileInfo[]): string[];
|
|
403
|
+
declare function detectTestFramework(files: FileInfo[]): string;
|
|
404
|
+
|
|
405
|
+
interface WalkEntry {
|
|
406
|
+
path: string;
|
|
407
|
+
relativePath: string;
|
|
408
|
+
extension: string;
|
|
409
|
+
size: number;
|
|
410
|
+
lastModified: Date;
|
|
411
|
+
lastAccessed: Date;
|
|
412
|
+
lines: number;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
declare function classifyFile(entry: WalkEntry, thresholds: TierThresholds): Tier;
|
|
416
|
+
declare function classifyFileWithAST(file: FileInfo, thresholds: TierThresholds): Tier;
|
|
417
|
+
declare function buildTierSummary(files: FileInfo[], totalTokens: number): TierSummary;
|
|
418
|
+
declare function getTierFiles(files: FileInfo[], tier: Tier): FileInfo[];
|
|
419
|
+
declare function getTokenSavings(files: FileInfo[]): {
|
|
420
|
+
withOptimization: number;
|
|
421
|
+
withoutOptimization: number;
|
|
422
|
+
saved: number;
|
|
423
|
+
savingsPercent: number;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
declare function generateClaudeMd(analysis: ProjectAnalysis): Promise<GeneratedArtifact>;
|
|
427
|
+
declare function generateClaudeignore(analysis: ProjectAnalysis): Promise<GeneratedArtifact>;
|
|
428
|
+
declare function loadGeneratedArtifact(projectPath: string, type: 'claude-md' | 'claudeignore'): Promise<string | null>;
|
|
429
|
+
|
|
430
|
+
declare function initCTODir(): Promise<void>;
|
|
431
|
+
declare function loadGlobalConfig(): Promise<CTOConfig>;
|
|
432
|
+
declare function saveGlobalConfig(config: CTOConfig): Promise<void>;
|
|
433
|
+
declare function loadProjectConfig(projectPath: string): Promise<CTOConfig>;
|
|
434
|
+
declare function saveProjectConfig(projectPath: string, config: Partial<ProjectConfig>): Promise<void>;
|
|
435
|
+
declare function hasGlobalConfig(): Promise<boolean>;
|
|
436
|
+
|
|
437
|
+
declare function applyArtifact(artifact: GeneratedArtifact): Promise<ApplyResult>;
|
|
438
|
+
declare function revertArtifact(projectPath: string, artifactType?: 'claude-md' | 'claudeignore'): Promise<RevertResult>;
|
|
439
|
+
declare function diffArtifact(artifact: GeneratedArtifact): Promise<DiffResult>;
|
|
440
|
+
declare function listBackups(projectPath: string): Promise<BackupEntry[]>;
|
|
441
|
+
|
|
442
|
+
interface CleanResult {
|
|
443
|
+
success: boolean;
|
|
444
|
+
projectPath: string;
|
|
445
|
+
removedDir: string;
|
|
446
|
+
error?: string;
|
|
447
|
+
}
|
|
448
|
+
declare function cleanProject(projectPath: string): Promise<CleanResult>;
|
|
449
|
+
|
|
450
|
+
declare function getPromptTemplates(): PromptTemplate[];
|
|
451
|
+
declare function getPromptById(id: string): PromptTemplate | undefined;
|
|
452
|
+
declare function renderPrompt(template: PromptTemplate, analysis: ProjectAnalysis, taskDescription?: string): string;
|
|
453
|
+
declare function listPromptCategories(): string[];
|
|
454
|
+
|
|
455
|
+
declare function countTokensTiktoken(text: string): number;
|
|
456
|
+
declare function countTokensChars4(sizeInBytes: number): number;
|
|
457
|
+
declare function estimateFileTokens(filePath: string, method?: 'chars4' | 'tiktoken'): Promise<number>;
|
|
458
|
+
declare function freeEncoder(): void;
|
|
459
|
+
|
|
460
|
+
declare function createProject(projectPath: string, filePaths: string[]): Project;
|
|
461
|
+
declare function buildDependencyGraph(project: Project, projectPath: string): DependencyGraph;
|
|
462
|
+
declare function analyzeFileComplexity(project: Project, projectPath: string, filePath: string): FileComplexity | null;
|
|
463
|
+
declare function analyzeAllComplexity(project: Project, projectPath: string): FileComplexity[];
|
|
464
|
+
declare function enrichFilesWithAST(files: FileInfo[], graph: DependencyGraph, complexities: FileComplexity[]): FileInfo[];
|
|
465
|
+
|
|
466
|
+
interface WatcherOptions {
|
|
467
|
+
debounceMs?: number;
|
|
468
|
+
autoRegenerate?: boolean;
|
|
469
|
+
verbose?: boolean;
|
|
470
|
+
}
|
|
471
|
+
declare class ProjectWatcher extends EventEmitter {
|
|
472
|
+
private watcher;
|
|
473
|
+
private projectPath;
|
|
474
|
+
private options;
|
|
475
|
+
private currentAnalysis;
|
|
476
|
+
private tierCache;
|
|
477
|
+
private debounceTimer;
|
|
478
|
+
private pendingChanges;
|
|
479
|
+
private extensions;
|
|
480
|
+
private running;
|
|
481
|
+
constructor(projectPath: string, options?: WatcherOptions);
|
|
482
|
+
start(): Promise<void>;
|
|
483
|
+
stop(): Promise<void>;
|
|
484
|
+
isRunning(): boolean;
|
|
485
|
+
getLastAnalysis(): ProjectAnalysis | null;
|
|
486
|
+
private handleEvent;
|
|
487
|
+
private processPendingChanges;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
declare function startSession(projectPath: string, description?: string): Promise<SessionInfo>;
|
|
491
|
+
declare function endSession(projectPath: string, analysis?: ProjectAnalysis): Promise<SessionInfo | null>;
|
|
492
|
+
declare function getCurrentSession(projectPath: string): Promise<SessionInfo | null>;
|
|
493
|
+
declare function logFileRead(projectPath: string, fileRead: SessionFileRead): Promise<void>;
|
|
494
|
+
declare function listSessions(projectPath: string, limit?: number): Promise<SessionInfo[]>;
|
|
495
|
+
declare function getSessionMetrics(projectPath: string, analysis?: ProjectAnalysis): Promise<SessionMetrics>;
|
|
496
|
+
declare function getTodaySessions(projectPath: string): Promise<SessionInfo[]>;
|
|
497
|
+
|
|
498
|
+
declare function getDashboardData(projectPath: string): Promise<DashboardData>;
|
|
499
|
+
declare function renderDashboard(data: DashboardData): string;
|
|
500
|
+
|
|
501
|
+
declare function generateWeeklyReport(projectPath: string): Promise<WeeklyReport>;
|
|
502
|
+
declare function renderWeeklyReport(report: WeeklyReport): string;
|
|
503
|
+
declare function generateProjectReport(projectPaths: string[]): Promise<string>;
|
|
504
|
+
declare function exportMetrics(projectPath: string, format?: 'json' | 'csv'): Promise<string>;
|
|
505
|
+
|
|
506
|
+
declare const DEFAULT_SECURITY_CONFIG: SecurityConfig;
|
|
507
|
+
declare function scanContentForSecrets(content: string, filePath: string, customPatterns?: string[]): SecretFinding[];
|
|
508
|
+
declare function scanFileForSecrets(filePath: string, projectPath: string, customPatterns?: string[]): Promise<SecretFinding[]>;
|
|
509
|
+
declare function scanProjectForSecrets(projectPath: string, filePaths: string[], customPatterns?: string[]): Promise<SecretFinding[]>;
|
|
510
|
+
declare function sanitizeContent(content: string, customPatterns?: string[]): string;
|
|
511
|
+
|
|
512
|
+
declare function logAudit(action: AuditAction, projectPath: string, details?: Record<string, unknown>): Promise<AuditEntry>;
|
|
513
|
+
declare function getAuditEntries(options?: {
|
|
514
|
+
projectPath?: string;
|
|
515
|
+
action?: AuditAction;
|
|
516
|
+
since?: Date;
|
|
517
|
+
limit?: number;
|
|
518
|
+
}): Promise<AuditEntry[]>;
|
|
519
|
+
declare function verifyAuditEntry(entry: AuditEntry): boolean;
|
|
520
|
+
declare function verifyAuditIntegrity(): Promise<{
|
|
521
|
+
totalEntries: number;
|
|
522
|
+
validEntries: number;
|
|
523
|
+
invalidEntries: AuditEntry[];
|
|
524
|
+
}>;
|
|
525
|
+
declare function purgeOldAuditEntries(retentionDays: number): Promise<number>;
|
|
526
|
+
|
|
527
|
+
declare function hashContent(content: string | Buffer): string;
|
|
528
|
+
declare function hashFile(filePath: string): Promise<string | null>;
|
|
529
|
+
declare function buildIntegrityManifest(projectPath: string): Promise<IntegrityManifest>;
|
|
530
|
+
declare function verifyIntegrity(projectPath: string): Promise<{
|
|
531
|
+
valid: boolean;
|
|
532
|
+
total: number;
|
|
533
|
+
verified: number;
|
|
534
|
+
corrupted: string[];
|
|
535
|
+
missing: string[];
|
|
536
|
+
}>;
|
|
537
|
+
declare function secureFilePermissions(projectPath: string): Promise<number>;
|
|
538
|
+
declare function purgeOldData(projectPath: string, retentionDays: number): Promise<{
|
|
539
|
+
purgedSessions: number;
|
|
540
|
+
purgedBackups: number;
|
|
541
|
+
}>;
|
|
542
|
+
|
|
543
|
+
declare function getPruneLevelForTier(tier: Tier): PruneLevel;
|
|
544
|
+
declare function pruneFile(file: FileInfo, level?: PruneLevel): Promise<PrunedFile>;
|
|
545
|
+
declare function pruneProject(files: FileInfo[]): Promise<PruneResult>;
|
|
546
|
+
|
|
547
|
+
declare function isGitRepo(projectPath: string): Promise<boolean>;
|
|
548
|
+
declare function getCurrentBranch(projectPath: string): Promise<string>;
|
|
549
|
+
declare function getGitContext(projectPath: string, diffBase?: string): Promise<GitContext>;
|
|
550
|
+
declare function getChangedFiles(projectPath: string, diffBase?: string): Promise<GitFileInfo[]>;
|
|
551
|
+
declare function getFileGitInfo(projectPath: string, relativePath: string): Promise<GitFileInfo | null>;
|
|
552
|
+
declare function getActiveDevelopers(projectPath: string, days: number): Promise<string[]>;
|
|
553
|
+
declare function classifyFileWithGit(file: FileInfo, gitInfo: GitFileInfo | undefined, thresholds: TierThresholds): Tier;
|
|
554
|
+
declare function enrichFilesWithGit(files: FileInfo[], projectPath: string, thresholds: TierThresholds): Promise<FileInfo[]>;
|
|
555
|
+
|
|
556
|
+
declare const MODEL_PRICING: Record<ModelPreference, ModelPricing>;
|
|
557
|
+
declare function estimateCost(tokens: number, model?: ModelPreference): CostBreakdown;
|
|
558
|
+
declare function estimateSessionCost(files: FileInfo[], model?: ModelPreference): CostEstimate;
|
|
559
|
+
declare function estimateWeeklyCost(sessions: SessionInfo[], totalProjectTokens: number, model?: ModelPreference): {
|
|
560
|
+
totalCost: CostBreakdown;
|
|
561
|
+
savedCost: CostBreakdown;
|
|
562
|
+
costWithoutCTO: CostBreakdown;
|
|
563
|
+
sessionsCount: number;
|
|
564
|
+
avgCostPerSession: string;
|
|
565
|
+
};
|
|
566
|
+
declare function estimateMonthlySavings(avgSessionsPerDay: number, avgTokensSaved: number, model?: ModelPreference): {
|
|
567
|
+
daily: string;
|
|
568
|
+
weekly: string;
|
|
569
|
+
monthly: string;
|
|
570
|
+
yearly: string;
|
|
571
|
+
};
|
|
572
|
+
declare function getModelPricingTable(): string;
|
|
573
|
+
|
|
574
|
+
declare function optimizeBudget(files: FileInfo[], budget: number): Promise<BudgetResult>;
|
|
575
|
+
|
|
576
|
+
declare const AI_ADAPTERS: Record<AITarget, AIAdapter>;
|
|
577
|
+
declare const ALL_AI_TARGETS: AITarget[];
|
|
578
|
+
declare function generateForTarget(target: AITarget, analysis: ProjectAnalysis, config: CTOConfig, options?: {
|
|
579
|
+
enhanced?: boolean;
|
|
580
|
+
task?: TaskType;
|
|
581
|
+
}): {
|
|
582
|
+
fileName: string;
|
|
583
|
+
content: string;
|
|
584
|
+
};
|
|
585
|
+
declare function generateForAllTargets(analysis: ProjectAnalysis, config: CTOConfig, options?: {
|
|
586
|
+
enhanced?: boolean;
|
|
587
|
+
task?: TaskType;
|
|
588
|
+
}): Array<{
|
|
589
|
+
target: AITarget;
|
|
590
|
+
fileName: string;
|
|
591
|
+
content: string;
|
|
592
|
+
}>;
|
|
593
|
+
|
|
594
|
+
declare function generatePRContext(analysis: ProjectAnalysis, baseBranch?: string): Promise<PRContext>;
|
|
595
|
+
|
|
596
|
+
declare function explainTier(file: FileInfo, projectPath: string, thresholds: TierThresholds): Promise<TierExplanation>;
|
|
597
|
+
declare function formatExplanation(explanation: TierExplanation): string;
|
|
598
|
+
|
|
599
|
+
declare const ROUTING_RULES: RoutingRule[];
|
|
600
|
+
declare const ALL_TASK_TYPES: TaskType[];
|
|
601
|
+
declare function recommendModel(task: TaskType, analysis: ProjectAnalysis, targetFiles?: string[]): ModelRecommendation;
|
|
602
|
+
declare function recommendModelForFiles(files: FileInfo[]): ModelPreference;
|
|
603
|
+
declare function getTaskDescription(task: TaskType): string;
|
|
604
|
+
|
|
605
|
+
declare function getLocalCTOPath(projectPath: string): string;
|
|
606
|
+
declare function hasLocalConfig(projectPath: string): Promise<boolean>;
|
|
607
|
+
declare function initLocalProject(projectPath: string, config?: Partial<LocalProjectConfig>): Promise<string>;
|
|
608
|
+
declare function loadLocalConfig(projectPath: string): Promise<LocalProjectConfig | null>;
|
|
609
|
+
declare function saveLocalConfig(projectPath: string, config: LocalProjectConfig): Promise<void>;
|
|
610
|
+
declare function mergeLocalWithGlobal(globalConfig: CTOConfig, localConfig: LocalProjectConfig): CTOConfig;
|
|
611
|
+
declare function detectProjectRoot(startPath: string): Promise<string>;
|
|
612
|
+
|
|
613
|
+
interface EnhancedPromptOptions {
|
|
614
|
+
task?: TaskType;
|
|
615
|
+
stack?: string[];
|
|
616
|
+
testFramework?: string | null;
|
|
617
|
+
hotFiles?: FileInfo[];
|
|
618
|
+
totalTokens?: number;
|
|
619
|
+
enableCoT?: boolean;
|
|
620
|
+
enableConstraints?: boolean;
|
|
621
|
+
enableAntiHallucination?: boolean;
|
|
622
|
+
locale?: 'en' | 'es';
|
|
623
|
+
}
|
|
624
|
+
declare function buildRolePriming(stack: string[]): string;
|
|
625
|
+
declare function buildChainOfThought(task?: TaskType): string;
|
|
626
|
+
declare function buildConstraints(stack: string[], testFramework: string | null): string;
|
|
627
|
+
declare function buildAntiHallucination(): string;
|
|
628
|
+
declare function buildOutputFormat(task?: TaskType): string;
|
|
629
|
+
declare function buildFilePriority(hotFiles: FileInfo[]): string;
|
|
630
|
+
declare function buildEnhancedPrompt(analysis: ProjectAnalysis, opts?: EnhancedPromptOptions): string;
|
|
631
|
+
declare function getTaskPromptBlock(task: TaskType): string;
|
|
632
|
+
|
|
633
|
+
interface SpecEntry {
|
|
634
|
+
kind: 'interface' | 'type' | 'enum' | 'function' | 'class';
|
|
635
|
+
name: string;
|
|
636
|
+
file: string;
|
|
637
|
+
line: number;
|
|
638
|
+
exported: boolean;
|
|
639
|
+
signature: string;
|
|
640
|
+
properties?: SpecProperty[];
|
|
641
|
+
extends?: string[];
|
|
642
|
+
jsdoc?: string;
|
|
643
|
+
}
|
|
644
|
+
interface SpecProperty {
|
|
645
|
+
name: string;
|
|
646
|
+
type: string;
|
|
647
|
+
optional: boolean;
|
|
648
|
+
}
|
|
649
|
+
interface SpecMap {
|
|
650
|
+
projectName: string;
|
|
651
|
+
extractedAt: Date;
|
|
652
|
+
totalSpecs: number;
|
|
653
|
+
entries: SpecEntry[];
|
|
654
|
+
byFile: Record<string, SpecEntry[]>;
|
|
655
|
+
byKind: Record<string, SpecEntry[]>;
|
|
656
|
+
}
|
|
657
|
+
interface SpecValidation {
|
|
658
|
+
valid: boolean;
|
|
659
|
+
errors: SpecIssue[];
|
|
660
|
+
warnings: SpecIssue[];
|
|
661
|
+
stats: {
|
|
662
|
+
totalFunctions: number;
|
|
663
|
+
withReturnType: number;
|
|
664
|
+
totalInterfaces: number;
|
|
665
|
+
fullyDocumented: number;
|
|
666
|
+
exportedWithoutJSDoc: number;
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
interface SpecIssue {
|
|
670
|
+
file: string;
|
|
671
|
+
name: string;
|
|
672
|
+
line: number;
|
|
673
|
+
message: string;
|
|
674
|
+
}
|
|
675
|
+
declare function extractSpecs(projectPath: string, files: FileInfo[]): SpecMap;
|
|
676
|
+
declare function generateSpecDocument(map: SpecMap): string;
|
|
677
|
+
declare function validateSpecs(projectPath: string, files: FileInfo[]): SpecValidation;
|
|
678
|
+
|
|
679
|
+
interface FocusResult {
|
|
680
|
+
targetFiles: FileInfo[];
|
|
681
|
+
dependencies: FileInfo[];
|
|
682
|
+
allFiles: FileInfo[];
|
|
683
|
+
totalTokens: number;
|
|
684
|
+
savedTokens: number;
|
|
685
|
+
savingsPercent: number;
|
|
686
|
+
}
|
|
687
|
+
declare function buildFocusContext(analysis: ProjectAnalysis, targetPaths: string[], depth?: number): FocusResult;
|
|
688
|
+
declare function formatFocusDocument(analysis: ProjectAnalysis, focus: FocusResult): string;
|
|
689
|
+
|
|
690
|
+
interface TodoItem {
|
|
691
|
+
file: string;
|
|
692
|
+
line: number;
|
|
693
|
+
type: 'TODO' | 'FIXME' | 'HACK' | 'XXX' | 'NOTE';
|
|
694
|
+
text: string;
|
|
695
|
+
tier: 'hot' | 'warm' | 'cold';
|
|
696
|
+
priority: 'high' | 'medium' | 'low';
|
|
697
|
+
}
|
|
698
|
+
interface TodoScanResult {
|
|
699
|
+
items: TodoItem[];
|
|
700
|
+
byType: Record<string, TodoItem[]>;
|
|
701
|
+
byPriority: Record<string, TodoItem[]>;
|
|
702
|
+
totalCount: number;
|
|
703
|
+
}
|
|
704
|
+
declare function scanTodos(files: FileInfo[]): Promise<TodoScanResult>;
|
|
705
|
+
|
|
706
|
+
interface GitignoreResult {
|
|
707
|
+
ignoreDirs: string[];
|
|
708
|
+
ignorePatterns: string[];
|
|
709
|
+
raw: string[];
|
|
710
|
+
}
|
|
711
|
+
declare function parseGitignore(projectPath: string): Promise<GitignoreResult | null>;
|
|
712
|
+
declare function mergeWithDefaults(gitignoreResult: GitignoreResult, defaultDirs: string[], defaultPatterns: string[]): {
|
|
713
|
+
ignoreDirs: string[];
|
|
714
|
+
ignorePatterns: string[];
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
export { type AIAdapter, type AITarget, AI_ADAPTERS, ALL_AI_TARGETS, ALL_TASK_TYPES, type ApplyResult, type AuditAction, type AuditEntry, type BackupEntry, type BudgetFile, type BudgetResult, type CTOConfig, type CostBreakdown, type CostEstimate, DEFAULT_SECURITY_CONFIG, type DashboardData, type DependencyEdge, type DependencyGraph, type DiffResult, type DoctorCheck, type ExplainFactor, type ExtensionConfig, type FileComplexity, type FileInfo, type FunctionComplexity, type GeneratedArtifact, type GitContext, type GitFileInfo, type HubFile, type IntegrityEntry, type IntegrityManifest, type LocalProjectConfig, type MCPToolResult, MODEL_PRICING, type ModelPreference, type ModelPricing, type ModelRecommendation, type PRContext, type ProjectAnalysis, type ProjectConfig, ProjectWatcher, type PromptTemplate, type PruneLevel, type PruneResult, type PrunedFile, ROUTING_RULES, type RevertResult, type RoutingRule, type SecretFinding, type SecretType, type SecurityConfig, type SessionFileRead, type SessionInfo, type SessionMetrics, type TaskType, type Tier, type TierChangeEvent, type TierDetail, type TierExplanation, type TierSummary, type TierThresholds, type ValidationResult, type WastePattern, type WatchEvent, type WeeklyReport, analyzeAllComplexity, analyzeFileComplexity, analyzeProject, applyArtifact, buildAntiHallucination, buildChainOfThought, buildConstraints, buildDependencyGraph, buildEnhancedPrompt, buildFilePriority, buildFocusContext, buildIntegrityManifest, buildOutputFormat, buildRolePriming, buildTierSummary, classifyFile, classifyFileWithAST, classifyFileWithGit, cleanProject, countTokensChars4, countTokensTiktoken, createProject, detectProjectRoot, detectStack, detectTestFramework, diffArtifact, endSession, enrichFilesWithAST, enrichFilesWithGit, estimateCost, estimateFileTokens, estimateMonthlySavings, estimateSessionCost, estimateTokens, estimateWeeklyCost, explainTier, exportMetrics, extractSpecs, formatExplanation, formatFocusDocument, freeEncoder, generateClaudeMd, generateClaudeignore, generateForAllTargets, generateForTarget, generatePRContext, generateProjectReport, generateSpecDocument, generateWeeklyReport, getActiveDevelopers, getAuditEntries, getChangedFiles, getCurrentBranch, getCurrentSession, getDashboardData, getFileGitInfo, getGitContext, getLocalCTOPath, getModelPricingTable, getPromptById, getPromptTemplates, getPruneLevelForTier, getSessionMetrics, getTaskDescription, getTaskPromptBlock, getTierFiles, getTodaySessions, getTokenSavings, hasGlobalConfig, hasLocalConfig, hashContent, hashFile, initCTODir, initLocalProject, isGitRepo, listBackups, listPromptCategories, listSessions, loadAnalysis, loadGeneratedArtifact, loadGlobalConfig, loadLocalConfig, loadProjectConfig, logAudit, logFileRead, mergeLocalWithGlobal, mergeWithDefaults, optimizeBudget, parseGitignore, pruneFile, pruneProject, purgeOldAuditEntries, purgeOldData, recommendModel, recommendModelForFiles, renderDashboard, renderPrompt, renderWeeklyReport, revertArtifact, sanitizeContent, saveGlobalConfig, saveLocalConfig, saveProjectConfig, scanContentForSecrets, scanFileForSecrets, scanProjectForSecrets, scanTodos, secureFilePermissions, startSession, validateSpecs, verifyAuditEntry, verifyAuditIntegrity, verifyIntegrity };
|