kodu 1.1.12 → 1.1.13
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/AGENTS.md +7 -3
- package/dist/src/commands/clean/clean.command.js +6 -1
- package/dist/src/commands/clean/clean.command.js.map +1 -1
- package/dist/src/commands/init/init.command.js +16 -7
- package/dist/src/commands/init/init.command.js.map +1 -1
- package/dist/src/commands/pack/pack.command.js +6 -1
- package/dist/src/commands/pack/pack.command.js.map +1 -1
- package/dist/src/commands/review/review.command.js +2 -2
- package/dist/src/commands/review/review.command.js.map +1 -1
- package/dist/src/core/config/config.schema.d.ts +2 -0
- package/dist/src/core/config/config.schema.js +8 -3
- package/dist/src/core/config/config.schema.js.map +1 -1
- package/dist/src/core/file-system/fs.service.d.ts +16 -9
- package/dist/src/core/file-system/fs.service.js +68 -114
- package/dist/src/core/file-system/fs.service.js.map +1 -1
- package/dist/src/shared/ai/ai.service.js +2 -5
- package/dist/src/shared/ai/ai.service.js.map +1 -1
- package/dist/src/shared/constants.d.ts +7 -0
- package/dist/src/shared/constants.js +116 -0
- package/dist/src/shared/constants.js.map +1 -0
- package/dist/src/shared/tokenizer/tokenizer.service.d.ts +1 -0
- package/dist/src/shared/tokenizer/tokenizer.service.js +13 -6
- package/dist/src/shared/tokenizer/tokenizer.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/kodu.json +5 -3
- package/kodu.schema.json +18 -5
- package/package.json +2 -1
- package/src/commands/clean/clean.command.ts +6 -1
- package/src/commands/init/init.command.ts +21 -7
- package/src/commands/pack/pack.command.ts +6 -1
- package/src/commands/review/review.command.ts +2 -2
- package/src/core/config/config.schema.ts +12 -3
- package/src/core/file-system/fs.service.ts +93 -131
- package/src/shared/ai/ai.service.ts +2 -6
- package/src/shared/constants.ts +121 -0
- package/src/shared/tokenizer/tokenizer.service.ts +15 -8
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export const MAX_FILE_SIZE_BYTES = 1024 * 1024; // 1 MB
|
|
2
|
+
export const WARNING_TOKEN_THRESHOLD = 12_000;
|
|
3
|
+
export const DEFAULT_COMMIT_TOKENS = 1_500;
|
|
4
|
+
export const DEFAULT_REVIEW_TOKENS = 5_000;
|
|
5
|
+
export const DEFAULT_LLM_MODEL = 'gpt-4o';
|
|
6
|
+
|
|
7
|
+
const BINARY_EXTENSION_LIST = [
|
|
8
|
+
'.png',
|
|
9
|
+
'.jpg',
|
|
10
|
+
'.jpeg',
|
|
11
|
+
'.webp',
|
|
12
|
+
'.gif',
|
|
13
|
+
'.bmp',
|
|
14
|
+
'.ico',
|
|
15
|
+
'.tif',
|
|
16
|
+
'.tiff',
|
|
17
|
+
'.psd',
|
|
18
|
+
'.ai',
|
|
19
|
+
'.sketch',
|
|
20
|
+
'.heic',
|
|
21
|
+
'.heif',
|
|
22
|
+
'.mp3',
|
|
23
|
+
'.wav',
|
|
24
|
+
'.flac',
|
|
25
|
+
'.ogg',
|
|
26
|
+
'.m4a',
|
|
27
|
+
'.mp4',
|
|
28
|
+
'.mkv',
|
|
29
|
+
'.mov',
|
|
30
|
+
'.avi',
|
|
31
|
+
'.webm',
|
|
32
|
+
'.wmv',
|
|
33
|
+
'.flv',
|
|
34
|
+
'.mpg',
|
|
35
|
+
'.mpeg',
|
|
36
|
+
'.ogv',
|
|
37
|
+
'.zip',
|
|
38
|
+
'.gz',
|
|
39
|
+
'.tgz',
|
|
40
|
+
'.bz2',
|
|
41
|
+
'.xz',
|
|
42
|
+
'.rar',
|
|
43
|
+
'.7z',
|
|
44
|
+
'.tar',
|
|
45
|
+
'.pdf',
|
|
46
|
+
'.exe',
|
|
47
|
+
'.dll',
|
|
48
|
+
'.so',
|
|
49
|
+
'.dylib',
|
|
50
|
+
'.class',
|
|
51
|
+
'.jar',
|
|
52
|
+
'.war',
|
|
53
|
+
'.ear',
|
|
54
|
+
'.ttf',
|
|
55
|
+
'.otf',
|
|
56
|
+
'.woff',
|
|
57
|
+
'.woff2',
|
|
58
|
+
'.eot',
|
|
59
|
+
'.bin',
|
|
60
|
+
'.pak',
|
|
61
|
+
'.dat',
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const KNOWN_TEXT_LIST = [
|
|
65
|
+
// Web / JS
|
|
66
|
+
'.js',
|
|
67
|
+
'.jsx',
|
|
68
|
+
'.ts',
|
|
69
|
+
'.tsx',
|
|
70
|
+
'.mjs',
|
|
71
|
+
'.cjs',
|
|
72
|
+
'.json',
|
|
73
|
+
'.html',
|
|
74
|
+
'.css',
|
|
75
|
+
'.scss',
|
|
76
|
+
'.less',
|
|
77
|
+
'.vue',
|
|
78
|
+
'.svelte',
|
|
79
|
+
// Backend / System
|
|
80
|
+
'.java',
|
|
81
|
+
'.py',
|
|
82
|
+
'.c',
|
|
83
|
+
'.cpp',
|
|
84
|
+
'.h',
|
|
85
|
+
'.hpp',
|
|
86
|
+
'.cs',
|
|
87
|
+
'.go',
|
|
88
|
+
'.rs',
|
|
89
|
+
'.php',
|
|
90
|
+
'.rb',
|
|
91
|
+
'.swift',
|
|
92
|
+
'.kt',
|
|
93
|
+
'.dart',
|
|
94
|
+
'.scala',
|
|
95
|
+
'.pl',
|
|
96
|
+
'.lua',
|
|
97
|
+
'.sh',
|
|
98
|
+
'.bat',
|
|
99
|
+
// Data / Docs
|
|
100
|
+
'.md',
|
|
101
|
+
'.txt',
|
|
102
|
+
'.xml',
|
|
103
|
+
'.yaml',
|
|
104
|
+
'.yml',
|
|
105
|
+
'.sql',
|
|
106
|
+
'.graphql',
|
|
107
|
+
'.toml',
|
|
108
|
+
'.ini',
|
|
109
|
+
'.env',
|
|
110
|
+
// Config
|
|
111
|
+
'.gitignore',
|
|
112
|
+
'.dockerignore',
|
|
113
|
+
'dockerfile',
|
|
114
|
+
'.editorconfig',
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
const createLowercaseSet = (values: string[]): ReadonlySet<string> =>
|
|
118
|
+
new Set(values.map((value) => value.toLowerCase()));
|
|
119
|
+
|
|
120
|
+
export const BINARY_EXTENSIONS = createLowercaseSet(BINARY_EXTENSION_LIST);
|
|
121
|
+
export const KNOWN_TEXT_EXTENSIONS = createLowercaseSet(KNOWN_TEXT_LIST);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { encodingForModel, type TiktokenModel } from 'js-tiktoken';
|
|
2
|
+
import { encodingForModel, getEncoding, type TiktokenModel } from 'js-tiktoken';
|
|
3
3
|
import { ConfigService } from '../../core/config/config.service';
|
|
4
|
+
import { DEFAULT_LLM_MODEL } from '../constants';
|
|
4
5
|
|
|
5
6
|
type TokenEstimate = {
|
|
6
7
|
tokens: number;
|
|
@@ -8,6 +9,7 @@ type TokenEstimate = {
|
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
const PRICE_PER_MILLION: Record<string, number> = {
|
|
12
|
+
'gpt-4o': 10,
|
|
11
13
|
'gpt-5-mini': 2.5,
|
|
12
14
|
};
|
|
13
15
|
|
|
@@ -27,19 +29,16 @@ export class TokenizerService {
|
|
|
27
29
|
|
|
28
30
|
private getPricePerMillion(): number {
|
|
29
31
|
const config = this.configService.getConfig();
|
|
30
|
-
const model = config.llm?.model ??
|
|
31
|
-
const key =
|
|
32
|
+
const model = config.llm?.model ?? `openai/${DEFAULT_LLM_MODEL}`;
|
|
33
|
+
const key = this.normalizeModelKey(model);
|
|
32
34
|
return PRICE_PER_MILLION[key] ?? 0;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
private createEncoder() {
|
|
36
|
-
const config = this.configService.getConfig();
|
|
37
|
-
const model = config.llm?.model ?? 'gpt-5-mini';
|
|
38
|
-
|
|
39
38
|
try {
|
|
40
|
-
return encodingForModel(
|
|
39
|
+
return encodingForModel(DEFAULT_LLM_MODEL as TiktokenModel);
|
|
41
40
|
} catch {
|
|
42
|
-
return
|
|
41
|
+
return getEncoding('o200k_base');
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -50,4 +49,12 @@ export class TokenizerService {
|
|
|
50
49
|
|
|
51
50
|
return this.encoder;
|
|
52
51
|
}
|
|
52
|
+
|
|
53
|
+
private normalizeModelKey(model: string): string {
|
|
54
|
+
const lower = model.toLowerCase();
|
|
55
|
+
if (lower.includes('/')) {
|
|
56
|
+
return lower.split('/').pop() ?? lower;
|
|
57
|
+
}
|
|
58
|
+
return lower;
|
|
59
|
+
}
|
|
53
60
|
}
|