hyntx 2.4.0 → 2.6.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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { detectShellConfigFile, findMarkerPositions, generateEnvExports, getManualInstructions, removeMalformedMarkers, saveConfigToShell, updateShellConfig } from './chunk-TLJ2AIHG.js';
package/package.json CHANGED
@@ -1,11 +1,37 @@
1
1
  {
2
2
  "name": "hyntx",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "CLI that analyzes Claude Code prompts and generates improvement suggestions",
5
5
  "type": "module",
6
+ "packageManager": "pnpm@9.15.4",
6
7
  "engines": {
7
8
  "node": ">=22.0.0"
8
9
  },
10
+ "scripts": {
11
+ "build": "tsup",
12
+ "build:debug": "SOURCE_MAP=true tsup",
13
+ "dev": "tsup --watch",
14
+ "start": "node dist/index.js",
15
+ "lint": "eslint src/",
16
+ "lint:fix": "eslint src/ --fix",
17
+ "format": "prettier --write .",
18
+ "format:check": "prettier --check .",
19
+ "typecheck": "tsc --noEmit",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
22
+ "test:coverage": "vitest run --coverage",
23
+ "test:unit": "vitest run tests/unit",
24
+ "test:integration": "vitest run tests/integration",
25
+ "test:e2e": "vitest run --config vitest.config.e2e.ts",
26
+ "test:e2e:watch": "vitest --config vitest.config.e2e.ts",
27
+ "test:all": "vitest run && vitest run --config vitest.config.e2e.ts",
28
+ "check": "pnpm typecheck && pnpm lint && pnpm format:check",
29
+ "validate:models": "node scripts/validate-model-sync.mjs",
30
+ "size": "npm pack --dry-run 2>&1 | tail -1",
31
+ "prepare": "husky",
32
+ "release": "semantic-release",
33
+ "release:dry": "semantic-release --dry-run"
34
+ },
9
35
  "keywords": [
10
36
  "cli",
11
37
  "claude",
@@ -15,16 +41,24 @@
15
41
  ],
16
42
  "author": "",
17
43
  "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/jmlweb/hyntx"
47
+ },
18
48
  "devDependencies": {
19
49
  "@commitlint/cli": "^20.2.0",
20
50
  "@commitlint/config-conventional": "^20.2.0",
21
51
  "@eslint/js": "^9.17.0",
52
+ "@jmlweb/commitlint-config": "^2.0.0",
53
+ "@jmlweb/eslint-config-base": "^2.0.1",
22
54
  "@jmlweb/prettier-config-base": "^1.0.0",
23
55
  "@jmlweb/tsconfig-base": "^1.0.0",
56
+ "@jmlweb/tsup-config-base": "^1.1.0",
24
57
  "@jmlweb/vitest-config": "^1.0.0",
25
58
  "@semantic-release/changelog": "^6.0.3",
26
59
  "@semantic-release/exec": "^6.0.3",
27
60
  "@semantic-release/git": "^10.0.1",
61
+ "@types/asciichart": "^1.5.8",
28
62
  "@types/figlet": "^1.7.0",
29
63
  "@types/node": "^25.0.3",
30
64
  "@types/prompts": "^2.4.9",
@@ -32,6 +66,7 @@
32
66
  "conventional-changelog-conventionalcommits": "^9.1.0",
33
67
  "eslint": "^9.17.0",
34
68
  "eslint-config-prettier": "^9.1.0",
69
+ "eslint-plugin-simple-import-sort": "^12.1.1",
35
70
  "husky": "^9.1.7",
36
71
  "lint-staged": "^16.2.7",
37
72
  "prettier": "^3.4.2",
@@ -78,37 +113,18 @@
78
113
  },
79
114
  "dependencies": {
80
115
  "@modelcontextprotocol/sdk": "^1.25.1",
116
+ "asciichart": "^1.5.25",
81
117
  "boxen": "^8.0.1",
82
118
  "chalk": "^5.6.2",
83
119
  "cli-table3": "^0.6.5",
84
120
  "date-fns": "^4.1.0",
85
121
  "figlet": "^1.9.4",
86
122
  "glob": "^13.0.0",
123
+ "ml-distance": "^4.0.1",
124
+ "ml-kmeans": "^7.0.0",
87
125
  "ora": "^9.0.0",
88
126
  "prompts": "^2.4.2",
127
+ "simple-statistics": "^7.8.8",
89
128
  "zod": "^4.2.1"
90
- },
91
- "scripts": {
92
- "build": "tsup",
93
- "build:debug": "SOURCE_MAP=true tsup",
94
- "dev": "tsup --watch",
95
- "start": "node dist/index.js",
96
- "lint": "eslint src/",
97
- "lint:fix": "eslint src/ --fix",
98
- "format": "prettier --write .",
99
- "format:check": "prettier --check .",
100
- "typecheck": "tsc --noEmit",
101
- "test": "vitest run",
102
- "test:watch": "vitest",
103
- "test:coverage": "vitest run --coverage",
104
- "test:unit": "vitest run tests/unit",
105
- "test:integration": "vitest run tests/integration",
106
- "test:e2e": "vitest run --config vitest.config.e2e.ts",
107
- "test:e2e:watch": "vitest --config vitest.config.e2e.ts",
108
- "test:all": "vitest run && vitest run --config vitest.config.e2e.ts",
109
- "check": "pnpm typecheck && pnpm lint && pnpm format:check",
110
- "size": "npm pack --dry-run 2>&1 | tail -1",
111
- "release": "semantic-release",
112
- "release:dry": "semantic-release --dry-run"
113
129
  }
114
- }
130
+ }
@@ -1,394 +0,0 @@
1
- /**
2
- * Hyntx - TypeScript Type Definitions
3
- *
4
- * This module contains all shared type definitions for the Hyntx system.
5
- * All types are designed to be composable and type-safe.
6
- */
7
-
8
- /**
9
- * Schema version for Claude Code JSONL logs.
10
- * Used for graceful degradation when log format changes.
11
- */
12
- type SchemaVersion = {
13
- readonly major: number;
14
- readonly minor: number;
15
- readonly detected: string;
16
- };
17
- /**
18
- * Message structure in Claude Code JSONL logs.
19
- * Represents a single entry in the conversation log.
20
- */
21
- type ClaudeMessage = {
22
- readonly type: 'user' | 'assistant' | 'system';
23
- readonly message: {
24
- readonly role: 'user' | 'assistant' | 'system';
25
- readonly content: string;
26
- };
27
- readonly timestamp: string;
28
- readonly sessionId: string;
29
- readonly cwd: string;
30
- };
31
- /**
32
- * Log entry type alias for JSONL files.
33
- * Used in test utilities and log parsing.
34
- */
35
- type LogEntry = ClaudeMessage;
36
- /**
37
- * Data extracted from Claude Code messages.
38
- * Contains the sanitized prompt and metadata.
39
- */
40
- type ExtractedPrompt = {
41
- readonly content: string;
42
- readonly timestamp: string;
43
- readonly sessionId: string;
44
- readonly project: string;
45
- readonly date: string;
46
- };
47
- /**
48
- * Result of reading logs from the filesystem.
49
- */
50
- type LogReadResult = {
51
- readonly prompts: readonly ExtractedPrompt[];
52
- readonly warnings: readonly string[];
53
- };
54
- /**
55
- * Grouping of prompts by day for analysis.
56
- */
57
- type DayGroup = {
58
- readonly date: string;
59
- readonly prompts: readonly ExtractedPrompt[];
60
- readonly projects: readonly string[];
61
- };
62
- /**
63
- * Before/after rewrite example for a pattern.
64
- * Shows concrete improvement for a detected issue.
65
- */
66
- type BeforeAfter = {
67
- readonly before: string;
68
- readonly after: string;
69
- };
70
- /**
71
- * Severity levels for detected patterns.
72
- */
73
- type PatternSeverity = 'low' | 'medium' | 'high';
74
- /**
75
- * Detected improvement pattern from analysis.
76
- * Each pattern includes concrete examples and actionable suggestions.
77
- */
78
- type AnalysisPattern = {
79
- readonly id: string;
80
- readonly name: string;
81
- readonly frequency: number;
82
- readonly severity: PatternSeverity;
83
- readonly examples: readonly string[];
84
- readonly suggestion: string;
85
- readonly beforeAfter: BeforeAfter;
86
- };
87
- /**
88
- * Statistics from the analysis.
89
- */
90
- type AnalysisStats = {
91
- readonly totalPrompts: number;
92
- readonly promptsWithIssues: number;
93
- readonly overallScore: number;
94
- };
95
- /**
96
- * Complete analysis result from a provider.
97
- * Contains patterns, statistics, and top suggestion.
98
- */
99
- type AnalysisResult = {
100
- readonly date: string;
101
- readonly patterns: readonly AnalysisPattern[];
102
- readonly stats: AnalysisStats;
103
- readonly topSuggestion: string;
104
- };
105
- /**
106
- * Prompt analysis without the date field.
107
- * Used for raw provider responses before date context is added.
108
- */
109
- type PromptAnalysis = Omit<AnalysisResult, 'date'>;
110
- /**
111
- * Supported AI provider types.
112
- */
113
- type ProviderType = 'ollama' | 'anthropic' | 'google';
114
- /**
115
- * Batch strategy type identifier.
116
- */
117
- type BatchStrategyType = 'micro' | 'small' | 'standard';
118
- /**
119
- * Batch strategy configuration for different model sizes.
120
- */
121
- type BatchStrategy = {
122
- readonly maxTokensPerBatch: number;
123
- readonly maxPromptsPerBatch: number;
124
- readonly description: string;
125
- };
126
- /**
127
- * Available batch strategies by model size.
128
- */
129
- declare const BATCH_STRATEGIES: Record<BatchStrategyType, BatchStrategy>;
130
- /**
131
- * Context limits for each provider.
132
- * Used for intelligent batching of prompts.
133
- */
134
- type ProviderLimits = {
135
- readonly maxTokensPerBatch: number;
136
- readonly maxPromptsPerBatch?: number;
137
- readonly prioritization: 'longest-first' | 'chronological';
138
- };
139
- /**
140
- * Provider limits by type.
141
- */
142
- declare const PROVIDER_LIMITS: Record<ProviderType, ProviderLimits>;
143
- /**
144
- * Configuration for a single analysis rule.
145
- * Allows enabling/disabling rules and overriding their severity.
146
- */
147
- type RuleConfig = {
148
- readonly enabled?: boolean;
149
- readonly severity?: PatternSeverity;
150
- };
151
- /**
152
- * Configuration for all analysis rules.
153
- * Maps rule IDs to their configuration.
154
- */
155
- type RulesConfig = Record<string, RuleConfig>;
156
- /**
157
- * Project-specific context information.
158
- * Loaded from .hyntxrc.json files to provide additional context during analysis.
159
- */
160
- type ProjectContext = {
161
- readonly role?: string;
162
- readonly techStack?: readonly string[];
163
- readonly domain?: string;
164
- readonly guidelines?: readonly string[];
165
- readonly projectType?: string;
166
- };
167
- /**
168
- * Interface for AI analysis providers.
169
- * All providers must implement this interface.
170
- */
171
- type AnalysisProvider = {
172
- readonly name: string;
173
- isAvailable(): Promise<boolean>;
174
- analyze(prompts: readonly string[], date: string, context?: ProjectContext): Promise<AnalysisResult>;
175
- getBatchLimits?(): ProviderLimits;
176
- };
177
- /**
178
- * Ollama provider configuration.
179
- */
180
- type OllamaConfig = {
181
- readonly model: string;
182
- readonly host: string;
183
- };
184
- /**
185
- * Anthropic provider configuration.
186
- */
187
- type AnthropicConfig = {
188
- readonly model: string;
189
- readonly apiKey: string;
190
- };
191
- /**
192
- * Google provider configuration.
193
- */
194
- type GoogleConfig = {
195
- readonly model: string;
196
- readonly apiKey: string;
197
- };
198
- /**
199
- * Complete configuration from environment variables.
200
- */
201
- type EnvConfig = {
202
- readonly services: readonly ProviderType[];
203
- readonly reminder: string;
204
- readonly ollama: OllamaConfig;
205
- readonly anthropic: AnthropicConfig;
206
- readonly google: GoogleConfig;
207
- };
208
- /**
209
- * Default values for environment configuration.
210
- */
211
- declare const ENV_DEFAULTS: {
212
- readonly reminder: "7d";
213
- readonly ollama: {
214
- readonly model: "llama3.2";
215
- readonly host: "http://localhost:11434";
216
- };
217
- readonly anthropic: {
218
- readonly model: "claude-3-5-haiku-latest";
219
- };
220
- readonly google: {
221
- readonly model: "gemini-2.0-flash-exp";
222
- };
223
- };
224
- /**
225
- * Result of shell config file update operation.
226
- */
227
- type ShellConfigResult = {
228
- readonly success: boolean;
229
- readonly shellFile: string;
230
- readonly message: string;
231
- readonly action: 'created' | 'updated' | 'skipped' | 'failed';
232
- };
233
- /**
234
- * Supported shell types for auto-configuration.
235
- */
236
- type ShellType = 'zsh' | 'bash' | 'fish' | 'unknown';
237
- /**
238
- * Exit codes for the CLI.
239
- */
240
- declare const EXIT_CODES: {
241
- readonly SUCCESS: 0;
242
- readonly ERROR: 1;
243
- readonly NO_DATA: 2;
244
- readonly PROVIDER_UNAVAILABLE: 3;
245
- };
246
- type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
247
- /**
248
- * Options parsed from CLI arguments.
249
- */
250
- type CliOptions = {
251
- readonly date: string;
252
- readonly from?: string;
253
- readonly to?: string;
254
- readonly project?: string;
255
- readonly output?: string;
256
- readonly verbose: boolean;
257
- readonly dryRun: boolean;
258
- readonly checkReminder: boolean;
259
- readonly help: boolean;
260
- readonly version: boolean;
261
- };
262
- /**
263
- * Output format for reports.
264
- */
265
- type OutputFormat = 'terminal' | 'markdown' | 'json';
266
- /**
267
- * JSON error response structure.
268
- */
269
- type JsonErrorResponse = {
270
- readonly error: string;
271
- readonly code: string;
272
- };
273
- /**
274
- * Metadata about the analysis execution.
275
- */
276
- type HistoryMetadata = {
277
- readonly provider: string;
278
- readonly promptCount: number;
279
- readonly projects: readonly string[];
280
- };
281
- /**
282
- * Complete history entry stored in history files.
283
- */
284
- type HistoryEntry = {
285
- readonly result: AnalysisResult;
286
- readonly metadata: HistoryMetadata;
287
- };
288
- /**
289
- * Options for listing history entries.
290
- */
291
- type ListHistoryOptions = {
292
- readonly provider?: string;
293
- readonly project?: string;
294
- readonly minScore?: number;
295
- readonly maxScore?: number;
296
- };
297
- /**
298
- * Change detected in a pattern between two analyses.
299
- */
300
- type PatternChange = {
301
- readonly id: string;
302
- readonly name: string;
303
- readonly status: 'new' | 'resolved' | 'changed';
304
- readonly frequencyBefore?: number;
305
- readonly frequencyAfter?: number;
306
- readonly severityBefore?: PatternSeverity;
307
- readonly severityAfter?: PatternSeverity;
308
- };
309
- /**
310
- * All detected changes between two analyses.
311
- */
312
- type ComparisonChanges = {
313
- readonly scoreDelta: number;
314
- readonly newPatterns: readonly AnalysisPattern[];
315
- readonly resolvedPatterns: readonly AnalysisPattern[];
316
- readonly changedPatterns: readonly PatternChange[];
317
- };
318
- /**
319
- * Result of comparing two analysis results.
320
- */
321
- type ComparisonResult = {
322
- readonly before: AnalysisResult;
323
- readonly after: AnalysisResult;
324
- readonly changes: ComparisonChanges;
325
- };
326
- /**
327
- * Event emitted when a new prompt is detected in the logs.
328
- * Contains the extracted prompt and the file path where it was found.
329
- */
330
- type PromptEvent = {
331
- readonly prompt: ExtractedPrompt;
332
- readonly filePath: string;
333
- };
334
- /**
335
- * Options for configuring the log watcher.
336
- */
337
- type WatcherOptions = {
338
- readonly debounceMs?: number;
339
- readonly projectFilter?: string;
340
- readonly signal?: AbortSignal;
341
- readonly baseDir?: string;
342
- };
343
- /**
344
- * Tracks the current position in a file for incremental reading.
345
- * Used to only read new content when files are modified.
346
- */
347
- type FilePosition = {
348
- readonly path: string;
349
- readonly size: number;
350
- readonly lastModified: number;
351
- };
352
- /**
353
- * Interface for the log watcher.
354
- * Watches Claude Code JSONL files for new prompts in real-time.
355
- */
356
- type LogWatcher = {
357
- start(): Promise<void>;
358
- stop(): Promise<void>;
359
- on(event: 'prompt', callback: (event: PromptEvent) => void): void;
360
- on(event: 'error', callback: (error: Error) => void): void;
361
- on(event: 'ready', callback: () => void): void;
362
- };
363
- /**
364
- * Metadata stored with cached analysis results.
365
- * Used for cache validation and invalidation.
366
- */
367
- type CacheMetadata = {
368
- readonly cachedAt: number;
369
- readonly promptCount: number;
370
- readonly model: string;
371
- readonly systemPromptHash: string;
372
- };
373
- /**
374
- * Complete cached batch result including metadata.
375
- * Stored as JSON files in the cache directory.
376
- */
377
- type CachedBatchResult = {
378
- readonly result: AnalysisResult;
379
- readonly metadata: CacheMetadata;
380
- };
381
- /**
382
- * Options for cache operations.
383
- */
384
- type CacheOptions = {
385
- readonly ttlMs: number;
386
- };
387
- /**
388
- * Default values for cache configuration.
389
- */
390
- declare const CACHE_DEFAULTS: {
391
- readonly ttlMs: number;
392
- };
393
-
394
- export { type AnalysisResult as A, type BeforeAfter as B, type ComparisonResult as C, type DayGroup as D, type ExtractedPrompt as E, type FilePosition as F, type GoogleConfig as G, type HistoryMetadata as H, type ShellConfigResult as I, type JsonErrorResponse as J, EXIT_CODES as K, type LogReadResult as L, ENV_DEFAULTS as M, PROVIDER_LIMITS as N, type OllamaConfig as O, type PatternSeverity as P, BATCH_STRATEGIES as Q, type RulesConfig as R, type SchemaVersion as S, CACHE_DEFAULTS as T, type WatcherOptions as W, type AnalysisProvider as a, type ProjectContext as b, type HistoryEntry as c, type ListHistoryOptions as d, type ProviderType as e, type EnvConfig as f, type CacheOptions as g, type AnalysisPattern as h, type AnalysisStats as i, type PromptAnalysis as j, type ProviderLimits as k, type BatchStrategy as l, type BatchStrategyType as m, type ClaudeMessage as n, type LogEntry as o, type AnthropicConfig as p, type ComparisonChanges as q, type PatternChange as r, type CacheMetadata as s, type CachedBatchResult as t, type LogWatcher as u, type PromptEvent as v, type CliOptions as w, type ExitCode as x, type OutputFormat as y, type ShellType as z };