kuzushi 0.2.0 → 0.9.2
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/README.md +2 -0
- package/dist/agent-runtime/claude.js +15 -3
- package/dist/agent-runtime/claude.js.map +1 -1
- package/dist/agents/tasks/code-config-detect.js +3 -0
- package/dist/agents/tasks/code-config-detect.js.map +1 -1
- package/dist/agents/tasks/command-injection.js +10 -8
- package/dist/agents/tasks/command-injection.js.map +1 -1
- package/dist/agents/tasks/context-enricher.js +2 -0
- package/dist/agents/tasks/context-enricher.js.map +1 -1
- package/dist/agents/tasks/deserialization-detection.js +4 -1
- package/dist/agents/tasks/deserialization-detection.js.map +1 -1
- package/dist/agents/tasks/graphql-security.js +4 -1
- package/dist/agents/tasks/graphql-security.js.map +1 -1
- package/dist/agents/tasks/nosql-injection.js +6 -3
- package/dist/agents/tasks/nosql-injection.js.map +1 -1
- package/dist/agents/tasks/prototype-pollution.js +4 -1
- package/dist/agents/tasks/prototype-pollution.js.map +1 -1
- package/dist/agents/tasks/race-condition.js +4 -1
- package/dist/agents/tasks/race-condition.js.map +1 -1
- package/dist/agents/tasks/secrets-crypto-detect.js +3 -0
- package/dist/agents/tasks/secrets-crypto-detect.js.map +1 -1
- package/dist/agents/tasks/sharp-edges-detect.js +5 -0
- package/dist/agents/tasks/sharp-edges-detect.js.map +1 -1
- package/dist/agents/tasks/ssrf-detection.js +6 -1
- package/dist/agents/tasks/ssrf-detection.js.map +1 -1
- package/dist/agents/tasks/supply-chain.js +4 -1
- package/dist/agents/tasks/supply-chain.js.map +1 -1
- package/dist/agents/tasks/template-injection.js +6 -3
- package/dist/agents/tasks/template-injection.js.map +1 -1
- package/dist/agents/tasks/threat-modeling/randori-adapter.js +19 -2
- package/dist/agents/tasks/threat-modeling/randori-adapter.js.map +1 -1
- package/dist/agents/tasks/threat-modeling/randori-artifacts.js +69 -13
- package/dist/agents/tasks/threat-modeling/randori-artifacts.js.map +1 -1
- package/dist/agents/tasks/threat-modeling/randori.js +70 -30
- package/dist/agents/tasks/threat-modeling/randori.js.map +1 -1
- package/dist/agents/tasks/xxe-detection.js +4 -1
- package/dist/agents/tasks/xxe-detection.js.map +1 -1
- package/dist/cli/commands/scan.js +35 -5
- package/dist/cli/commands/scan.js.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/migrations/024_rename_scanner_to_task_id.d.ts +13 -0
- package/dist/migrations/024_rename_scanner_to_task_id.js +25 -0
- package/dist/migrations/024_rename_scanner_to_task_id.js.map +1 -0
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/runner.js +7 -0
- package/dist/migrations/runner.js.map +1 -1
- package/dist/prompts/language-tuning.d.ts +38 -0
- package/dist/prompts/language-tuning.js +225 -0
- package/dist/prompts/language-tuning.js.map +1 -0
- package/dist/prompts/languages/c-cpp.d.ts +2 -0
- package/dist/prompts/languages/c-cpp.js +276 -0
- package/dist/prompts/languages/c-cpp.js.map +1 -0
- package/dist/prompts/languages/go.d.ts +2 -0
- package/dist/prompts/languages/go.js +252 -0
- package/dist/prompts/languages/go.js.map +1 -0
- package/dist/prompts/languages/index.d.ts +6 -0
- package/dist/prompts/languages/index.js +44 -0
- package/dist/prompts/languages/index.js.map +1 -0
- package/dist/prompts/languages/java-kotlin.d.ts +2 -0
- package/dist/prompts/languages/java-kotlin.js +495 -0
- package/dist/prompts/languages/java-kotlin.js.map +1 -0
- package/dist/prompts/languages/javascript-typescript.d.ts +2 -0
- package/dist/prompts/languages/javascript-typescript.js +421 -0
- package/dist/prompts/languages/javascript-typescript.js.map +1 -0
- package/dist/prompts/languages/php.d.ts +2 -0
- package/dist/prompts/languages/php.js +277 -0
- package/dist/prompts/languages/php.js.map +1 -0
- package/dist/prompts/languages/python.d.ts +2 -0
- package/dist/prompts/languages/python.js +283 -0
- package/dist/prompts/languages/python.js.map +1 -0
- package/dist/prompts/languages/ruby.d.ts +2 -0
- package/dist/prompts/languages/ruby.js +219 -0
- package/dist/prompts/languages/ruby.js.map +1 -0
- package/dist/prompts/languages/rust.d.ts +2 -0
- package/dist/prompts/languages/rust.js +149 -0
- package/dist/prompts/languages/rust.js.map +1 -0
- package/dist/prompts/languages/types.d.ts +79 -0
- package/dist/prompts/languages/types.js +9 -0
- package/dist/prompts/languages/types.js.map +1 -0
- package/dist/scanners/run-agentic.d.ts +2 -2
- package/dist/scanners/run-agentic.js +11 -3
- package/dist/scanners/run-agentic.js.map +1 -1
- package/dist/store.js +4 -0
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// NOTE: This file contains DETECTION PATTERNS for a security scanner.
|
|
2
|
+
// The API references are DETECTION TARGETS describing what the scanner
|
|
3
|
+
// looks for in scanned codebases, not code this file executes.
|
|
4
|
+
export const goProfile = {
|
|
5
|
+
languageId: "Go",
|
|
6
|
+
aliases: ["go", "golang"],
|
|
7
|
+
generalHints: {
|
|
8
|
+
grepPatterns: [
|
|
9
|
+
"func\\s+\\w+Handler",
|
|
10
|
+
"http\\.HandleFunc",
|
|
11
|
+
"gin\\.Context",
|
|
12
|
+
"echo\\.Context",
|
|
13
|
+
"r\\.FormValue",
|
|
14
|
+
"c\\.Param\\(",
|
|
15
|
+
"go\\s+func",
|
|
16
|
+
],
|
|
17
|
+
fileHints: [
|
|
18
|
+
"go.mod for dependencies and Go version",
|
|
19
|
+
"main.go / cmd/server/ for entry points and route registration",
|
|
20
|
+
"middleware/ for auth and validation middleware",
|
|
21
|
+
"internal/handler/ or handlers/ for HTTP handler functions",
|
|
22
|
+
],
|
|
23
|
+
instructions: [
|
|
24
|
+
"Check go.mod for known vulnerable dependency versions",
|
|
25
|
+
"Look at router setup (mux, gin, echo) for missing middleware on routes",
|
|
26
|
+
"Check for goroutine usage in request handlers — shared state access patterns",
|
|
27
|
+
"Inspect error handling — Go returns errors, check if they are silently discarded",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
generalAntiHallucination: [
|
|
31
|
+
"Go database/sql with ? placeholders uses parameterized queries — SAFE against SQL injection",
|
|
32
|
+
"GORM .Where(\"field = ?\", val) is parameterized — only flag raw SQL string concatenation",
|
|
33
|
+
"Go html/template auto-escapes by default — only flag text/template with HTML output",
|
|
34
|
+
],
|
|
35
|
+
vulnClasses: {
|
|
36
|
+
"race-condition": {
|
|
37
|
+
sinks: [
|
|
38
|
+
{ api: "Shared map/slice accessed from multiple goroutines", risk: "Go maps are NOT concurrent-safe — concurrent read+write causes panic or corruption", cwes: ["CWE-362"] },
|
|
39
|
+
{ api: "Global variable modified in goroutine", risk: "Package-level var accessed without sync", cwes: ["CWE-362"] },
|
|
40
|
+
{ api: "Read-modify-write without mutex", risk: "counter++ across goroutines is not atomic", cwes: ["CWE-362"] },
|
|
41
|
+
],
|
|
42
|
+
safePatterns: [
|
|
43
|
+
{ api: "sync.Mutex / sync.RWMutex around shared state", why: "Proper locking" },
|
|
44
|
+
{ api: "sync.Map for concurrent map access", why: "Concurrent-safe map implementation" },
|
|
45
|
+
{ api: "atomic.AddInt64 / atomic.Load*", why: "Lock-free atomic operations" },
|
|
46
|
+
{ api: "Channel-based communication", why: "Share memory by communicating, don't communicate by sharing memory" },
|
|
47
|
+
],
|
|
48
|
+
investigationHints: {
|
|
49
|
+
grepPatterns: [
|
|
50
|
+
"go\\s+func",
|
|
51
|
+
"sync\\.Mutex",
|
|
52
|
+
"sync\\.RWMutex",
|
|
53
|
+
"sync\\.Map",
|
|
54
|
+
"atomic\\.",
|
|
55
|
+
"chan\\s+",
|
|
56
|
+
],
|
|
57
|
+
fileHints: [
|
|
58
|
+
"HTTP handler functions that spawn goroutines",
|
|
59
|
+
"Background worker/job processing code",
|
|
60
|
+
"Cache implementations with concurrent access",
|
|
61
|
+
],
|
|
62
|
+
instructions: [
|
|
63
|
+
"Look for 'go func()' inside HTTP handlers — does the goroutine access request-scoped or shared state?",
|
|
64
|
+
"Check if package-level maps are accessed from request handlers (concurrent HTTP requests = concurrent goroutines)",
|
|
65
|
+
"Run 'go vet -race' mentally: any variable written by one goroutine and read by another without sync?",
|
|
66
|
+
"Check for TOC-TOU patterns: checking map key existence, then acting on it without holding lock",
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
fewShots: [
|
|
70
|
+
{
|
|
71
|
+
scenario: "Concurrent map write in HTTP handler",
|
|
72
|
+
vulnerableCode: 'var cache = make(map[string]string)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n key := r.FormValue("key")\n cache[key] = r.FormValue("value") // concurrent write\n}',
|
|
73
|
+
explanation: "HTTP handlers run in separate goroutines. Concurrent writes to the unsynchronized map cause a runtime panic (fatal error: concurrent map writes) or silent data corruption.",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
antiHallucinationExtra: [
|
|
77
|
+
"Go maps are NOT concurrent-safe even for reads during concurrent writes — this is a real bug, not theoretical",
|
|
78
|
+
"A single-goroutine function that is never called concurrently is NOT a race condition",
|
|
79
|
+
"sync.Once is safe — do NOT flag it as a race condition",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
"command-injection": {
|
|
83
|
+
sinks: [
|
|
84
|
+
{ api: 'exec.Command("sh", "-c", userStr)', risk: "Shell interpretation of user-controlled string", shellInvoking: true, cwes: ["CWE-78"] },
|
|
85
|
+
{ api: 'exec.Command("bash", "-c", userStr)', risk: "Shell interpretation via bash", shellInvoking: true, cwes: ["CWE-78"] },
|
|
86
|
+
{ api: "exec.Command(userBinary, args...)", risk: "User controls which binary is executed", shellInvoking: false, cwes: ["CWE-78"] },
|
|
87
|
+
],
|
|
88
|
+
safePatterns: [
|
|
89
|
+
{ api: 'exec.Command("fixed-binary", userArg)', why: "Binary is fixed, user controls only arguments — no shell interpretation" },
|
|
90
|
+
{ api: "exec.CommandContext with fixed binary", why: "Context adds timeout but same safety as Command" },
|
|
91
|
+
],
|
|
92
|
+
investigationHints: {
|
|
93
|
+
grepPatterns: [
|
|
94
|
+
'exec\\.Command\\(',
|
|
95
|
+
"exec\\.CommandContext\\(",
|
|
96
|
+
'"sh".*"-c"',
|
|
97
|
+
'"bash".*"-c"',
|
|
98
|
+
],
|
|
99
|
+
fileHints: [
|
|
100
|
+
"Utility functions that invoke system commands",
|
|
101
|
+
"CI/CD pipeline handlers",
|
|
102
|
+
"Git operation wrappers",
|
|
103
|
+
],
|
|
104
|
+
instructions: [
|
|
105
|
+
'Check if exec.Command uses "sh" or "bash" with "-c" flag — this enables shell interpretation',
|
|
106
|
+
"If the binary name itself comes from user input, it is command injection regardless of shell",
|
|
107
|
+
"exec.Command with a fixed binary and user args is safe against shell metachar injection (no shell involved)",
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
fewShots: [
|
|
111
|
+
{
|
|
112
|
+
scenario: "Git clone with user-controlled URL via shell",
|
|
113
|
+
vulnerableCode: 'func cloneRepo(url string) error {\n cmd := exec.Command("sh", "-c", "git clone "+url)\n return cmd.Run()\n}',
|
|
114
|
+
explanation: 'url is user-controlled and concatenated into a shell command via "sh -c". Attacker sends "; rm -rf /" as URL. Fix: use exec.Command("git", "clone", url) without shell.',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
antiHallucinationExtra: [
|
|
118
|
+
'exec.Command("fixed-binary", userArgs...) without "sh"/"-c" is NOT vulnerable to shell metachar injection',
|
|
119
|
+
"Do NOT flag exec.Command with all hardcoded arguments",
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
ssrf: {
|
|
123
|
+
sinks: [
|
|
124
|
+
{ api: "http.Get(url) / http.Post(url, ...)", risk: "User-controlled URL can target internal services", cwes: ["CWE-918"] },
|
|
125
|
+
{ api: "http.NewRequest + client.Do", risk: "URL from user input in request construction", cwes: ["CWE-918"] },
|
|
126
|
+
{ api: "resty.New().R().Get(url)", risk: "Resty client with user-controlled URL", cwes: ["CWE-918"] },
|
|
127
|
+
],
|
|
128
|
+
safePatterns: [
|
|
129
|
+
{ api: "URL validated against allowlist before request", why: "Only permitted hosts reachable" },
|
|
130
|
+
{ api: "Hardcoded base URL with user-controlled path/params", why: "User cannot change the target host" },
|
|
131
|
+
],
|
|
132
|
+
investigationHints: {
|
|
133
|
+
grepPatterns: [
|
|
134
|
+
"http\\.Get\\(",
|
|
135
|
+
"http\\.Post\\(",
|
|
136
|
+
"http\\.NewRequest\\(",
|
|
137
|
+
"client\\.Do\\(",
|
|
138
|
+
"url\\.Parse\\(",
|
|
139
|
+
],
|
|
140
|
+
fileHints: [
|
|
141
|
+
"Webhook/callback handlers",
|
|
142
|
+
"URL fetching or proxy endpoints",
|
|
143
|
+
"File download features",
|
|
144
|
+
],
|
|
145
|
+
instructions: [
|
|
146
|
+
"Check if URL comes from r.FormValue, r.URL.Query(), or request body",
|
|
147
|
+
"Go http.Client follows redirects by default (up to 10) — this can bypass URL validation",
|
|
148
|
+
"Check for cloud metadata access: can user URL reach 169.254.169.254?",
|
|
149
|
+
"Look for url.Parse followed by checking scheme/host — can be bypassed with URL parser tricks",
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
fewShots: [
|
|
153
|
+
{
|
|
154
|
+
scenario: "Proxy endpoint with open redirect",
|
|
155
|
+
vulnerableCode: 'func proxyHandler(w http.ResponseWriter, r *http.Request) {\n target := r.URL.Query().Get("url")\n resp, _ := http.Get(target)\n io.Copy(w, resp.Body)\n}',
|
|
156
|
+
explanation: "User-controlled URL is fetched server-side. Attacker sends url=http://169.254.169.254/latest/meta-data/ to access cloud metadata.",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
antiHallucinationExtra: [
|
|
160
|
+
"http.Get with hardcoded URL and no user-controlled components is NOT SSRF",
|
|
161
|
+
"Internal microservice calls with URLs from config (not user input) are NOT SSRF",
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
"template-injection": {
|
|
165
|
+
sinks: [
|
|
166
|
+
{ api: "text/template with user-controlled template string", risk: "Go templates can call methods — user controls which methods via {{.Method}}", cwes: ["CWE-1336"] },
|
|
167
|
+
{ api: "html/template with user-controlled template string", risk: "Same as text/template but with HTML escaping — methods still callable", cwes: ["CWE-1336"] },
|
|
168
|
+
],
|
|
169
|
+
safePatterns: [
|
|
170
|
+
{ api: "Template files with user data as variables", why: "User controls data, not template structure" },
|
|
171
|
+
{ api: "html/template with hardcoded template string", why: "Template is constant, only data varies" },
|
|
172
|
+
],
|
|
173
|
+
investigationHints: {
|
|
174
|
+
grepPatterns: [
|
|
175
|
+
'template\\.New\\(',
|
|
176
|
+
'template\\.Must\\(',
|
|
177
|
+
'\\.Parse\\(',
|
|
178
|
+
'template\\.ParseFiles\\(',
|
|
179
|
+
],
|
|
180
|
+
fileHints: [
|
|
181
|
+
"Template rendering in HTTP handlers",
|
|
182
|
+
"Email or notification template generation",
|
|
183
|
+
],
|
|
184
|
+
instructions: [
|
|
185
|
+
"Check if the template string (not the data) comes from user input",
|
|
186
|
+
"template.New().Parse(userInput) is dangerous — template.New().Parse(constant).Execute(w, userData) is safe",
|
|
187
|
+
"Go templates can call exported methods on the data object — check what methods are accessible",
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
fewShots: [
|
|
191
|
+
{
|
|
192
|
+
scenario: "User-controlled Go template string",
|
|
193
|
+
vulnerableCode: 'func render(w http.ResponseWriter, r *http.Request) {\n tpl := r.FormValue("template")\n t, _ := template.New("").Parse(tpl)\n t.Execute(w, data)\n}',
|
|
194
|
+
explanation: "User controls the template string. Attacker sends {{.SensitiveField}} to extract data or chains method calls for further access.",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
antiHallucinationExtra: [
|
|
198
|
+
"Go html/template auto-escapes HTML by default — this prevents XSS but NOT template injection",
|
|
199
|
+
"Template files loaded from disk with user data as variables are SAFE",
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
"crypto-misuse": {
|
|
203
|
+
sinks: [
|
|
204
|
+
{ api: "crypto/md5 or crypto/sha1 for passwords", risk: "Weak hash — fast to brute force", cwes: ["CWE-328"] },
|
|
205
|
+
{ api: "crypto/des", risk: "DES is broken — 56-bit key length", cwes: ["CWE-327"] },
|
|
206
|
+
{ api: "math/rand for security-sensitive values", risk: "Predictable PRNG — not cryptographically secure", cwes: ["CWE-338"] },
|
|
207
|
+
{ api: "Hardcoded keys/secrets in source", risk: "Secrets in code are extractable", cwes: ["CWE-798"] },
|
|
208
|
+
{ api: "crypto/aes in ECB mode", risk: "ECB reveals patterns in plaintext", cwes: ["CWE-327"] },
|
|
209
|
+
],
|
|
210
|
+
safePatterns: [
|
|
211
|
+
{ api: "crypto/rand for random bytes", why: "Cryptographically secure RNG" },
|
|
212
|
+
{ api: "golang.org/x/crypto/bcrypt or argon2", why: "Proper password hashing" },
|
|
213
|
+
{ api: "crypto/aes with GCM mode", why: "Authenticated encryption" },
|
|
214
|
+
],
|
|
215
|
+
investigationHints: {
|
|
216
|
+
grepPatterns: [
|
|
217
|
+
"crypto/md5",
|
|
218
|
+
"crypto/sha1",
|
|
219
|
+
"crypto/des",
|
|
220
|
+
"math/rand",
|
|
221
|
+
"crypto/rand",
|
|
222
|
+
"bcrypt",
|
|
223
|
+
"argon2",
|
|
224
|
+
"aes\\.NewCipher",
|
|
225
|
+
"cipher\\.NewGCM",
|
|
226
|
+
],
|
|
227
|
+
fileHints: [
|
|
228
|
+
"Authentication and password handling code",
|
|
229
|
+
"Token/session generation code",
|
|
230
|
+
"Encryption/decryption utilities",
|
|
231
|
+
],
|
|
232
|
+
instructions: [
|
|
233
|
+
"Check if md5/sha1 is used for password hashing vs. checksums (checksums are fine)",
|
|
234
|
+
"Check if math/rand is seeded with crypto/rand or used for security tokens (use crypto/rand instead)",
|
|
235
|
+
"Look for AES usage — is it using GCM/CTR mode or insecure ECB mode?",
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
fewShots: [
|
|
239
|
+
{
|
|
240
|
+
scenario: "Math/rand for session token generation",
|
|
241
|
+
vulnerableCode: 'import "math/rand"\n\nfunc generateToken() string {\n b := make([]byte, 32)\n for i := range b {\n b[i] = byte(rand.Intn(256))\n }\n return hex.EncodeToString(b)\n}',
|
|
242
|
+
explanation: "math/rand is a predictable PRNG. If an attacker knows or guesses the seed (often time-based), they can predict all future tokens. Use crypto/rand.Read instead.",
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
antiHallucinationExtra: [
|
|
246
|
+
"md5/sha1 for content checksums or cache keys is NOT a vulnerability — only flag for password hashing or authentication",
|
|
247
|
+
"math/rand for non-security purposes (shuffling, jitter, load balancing) is NOT a vulnerability",
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go.js","sourceRoot":"","sources":["../../../src/prompts/languages/go.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uEAAuE;AACvE,+DAA+D;AAI/D,MAAM,CAAC,MAAM,SAAS,GAAoB;IACxC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;IACzB,YAAY,EAAE;QACZ,YAAY,EAAE;YACZ,qBAAqB;YACrB,mBAAmB;YACnB,eAAe;YACf,gBAAgB;YAChB,eAAe;YACf,cAAc;YACd,YAAY;SACb;QACD,SAAS,EAAE;YACT,wCAAwC;YACxC,+DAA+D;YAC/D,gDAAgD;YAChD,2DAA2D;SAC5D;QACD,YAAY,EAAE;YACZ,uDAAuD;YACvD,wEAAwE;YACxE,8EAA8E;YAC9E,kFAAkF;SACnF;KACF;IACD,wBAAwB,EAAE;QACxB,6FAA6F;QAC7F,2FAA2F;QAC3F,qFAAqF;KACtF;IACD,WAAW,EAAE;QACX,gBAAgB,EAAE;YAChB,KAAK,EAAE;gBACL,EAAE,GAAG,EAAE,oDAAoD,EAAE,IAAI,EAAE,oFAAoF,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;gBAC5K,EAAE,GAAG,EAAE,u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;oBAClD,cAAc,EAAE,yLAAyL;oBACzM,WAAW,EAAE,iKAAiK;iBAC/K;aACF;YACD,sBAAsB,EAAE;gBACtB,wHAAwH;gBACxH,gGAAgG;aACjG;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language profile registry — maps language names to profiles.
|
|
3
|
+
*/
|
|
4
|
+
import type { LanguageProfile } from "./types.js";
|
|
5
|
+
export declare function getLanguageProfile(language: string): LanguageProfile | undefined;
|
|
6
|
+
export declare function getLanguageProfiles(languages: string[]): LanguageProfile[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language profile registry — maps language names to profiles.
|
|
3
|
+
*/
|
|
4
|
+
import { cCppProfile } from "./c-cpp.js";
|
|
5
|
+
import { javaKotlinProfile } from "./java-kotlin.js";
|
|
6
|
+
import { pythonProfile } from "./python.js";
|
|
7
|
+
import { goProfile } from "./go.js";
|
|
8
|
+
import { jstsProfile } from "./javascript-typescript.js";
|
|
9
|
+
import { rustProfile } from "./rust.js";
|
|
10
|
+
import { phpProfile } from "./php.js";
|
|
11
|
+
import { rubyProfile } from "./ruby.js";
|
|
12
|
+
const PROFILES = [
|
|
13
|
+
cCppProfile,
|
|
14
|
+
javaKotlinProfile,
|
|
15
|
+
pythonProfile,
|
|
16
|
+
goProfile,
|
|
17
|
+
jstsProfile,
|
|
18
|
+
rustProfile,
|
|
19
|
+
phpProfile,
|
|
20
|
+
rubyProfile,
|
|
21
|
+
];
|
|
22
|
+
const BY_ID = new Map();
|
|
23
|
+
for (const profile of PROFILES) {
|
|
24
|
+
BY_ID.set(profile.languageId.toLowerCase(), profile);
|
|
25
|
+
for (const alias of profile.aliases) {
|
|
26
|
+
BY_ID.set(alias.toLowerCase(), profile);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function getLanguageProfile(language) {
|
|
30
|
+
return BY_ID.get(language.toLowerCase());
|
|
31
|
+
}
|
|
32
|
+
export function getLanguageProfiles(languages) {
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const lang of languages) {
|
|
36
|
+
const profile = BY_ID.get(lang.toLowerCase());
|
|
37
|
+
if (profile && !seen.has(profile.languageId)) {
|
|
38
|
+
seen.add(profile.languageId);
|
|
39
|
+
result.push(profile);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/languages/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,QAAQ,GAAsB;IAClC,WAAW;IACX,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;CACZ,CAAC;AAEF,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;AACjD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;IAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;IACrD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpC,KAAK,CAAC,GAAG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