sigmap 3.3.1 → 3.3.3
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 +42 -0
- package/CHANGELOG.md +18 -0
- package/README.md +108 -46
- package/gen-context.config.json.example +1 -1
- package/gen-context.js +91 -18
- package/package.json +3 -1
- package/packages/adapters/codex.js +74 -0
- package/packages/adapters/copilot.js +36 -1
- package/packages/adapters/gemini.js +36 -1
- package/packages/adapters/index.js +2 -2
- package/packages/cli/package.json +1 -1
- package/packages/core/index.js +5 -0
- package/packages/core/package.json +1 -1
- package/src/config/loader.js +151 -2
- package/src/extractors/graphql.js +66 -0
- package/src/extractors/protobuf.js +63 -0
- package/src/extractors/sql.js +93 -0
- package/src/extractors/terraform.js +74 -0
- package/src/mcp/server.js +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract signatures from Terraform (.tf / .tfvars) configuration files.
|
|
5
|
+
* Captures resource, data, module, variable, output, locals, provider,
|
|
6
|
+
* terraform blocks, and moved/import blocks.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} src - Raw Terraform content
|
|
9
|
+
* @returns {string[]} Array of signature strings
|
|
10
|
+
*/
|
|
11
|
+
function extract(src) {
|
|
12
|
+
if (!src || typeof src !== 'string') return [];
|
|
13
|
+
const sigs = [];
|
|
14
|
+
|
|
15
|
+
// Strip single-line comments
|
|
16
|
+
const stripped = src
|
|
17
|
+
.replace(/\/\/[^\n]*/g, '')
|
|
18
|
+
.replace(/#[^\n]*/g, '')
|
|
19
|
+
.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
20
|
+
|
|
21
|
+
// resource "<type>" "<name>" { ... }
|
|
22
|
+
for (const m of stripped.matchAll(/\bresource\s+"([^"]+)"\s+"([^"]+)"\s*\{/g)) {
|
|
23
|
+
sigs.push(`resource "${m[1]}" "${m[2]}"`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// data "<type>" "<name>" { ... }
|
|
27
|
+
for (const m of stripped.matchAll(/\bdata\s+"([^"]+)"\s+"([^"]+)"\s*\{/g)) {
|
|
28
|
+
sigs.push(`data "${m[1]}" "${m[2]}"`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// module "<name>" { ... }
|
|
32
|
+
for (const m of stripped.matchAll(/\bmodule\s+"([^"]+)"\s*\{/g)) {
|
|
33
|
+
sigs.push(`module "${m[1]}"`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// variable "<name>" { ... }
|
|
37
|
+
for (const m of stripped.matchAll(/\bvariable\s+"([^"]+)"\s*\{/g)) {
|
|
38
|
+
sigs.push(`variable "${m[1]}"`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// output "<name>" { ... }
|
|
42
|
+
for (const m of stripped.matchAll(/\boutput\s+"([^"]+)"\s*\{/g)) {
|
|
43
|
+
sigs.push(`output "${m[1]}"`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// provider "<name>" { ... }
|
|
47
|
+
for (const m of stripped.matchAll(/\bprovider\s+"([^"]+)"\s*\{/g)) {
|
|
48
|
+
sigs.push(`provider "${m[1]}"`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// locals { ... } (just mark presence; key names too noisy to enumerate)
|
|
52
|
+
if (/\blocals\s*\{/.test(stripped)) {
|
|
53
|
+
sigs.push('locals { ... }');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// terraform { required_providers / backend }
|
|
57
|
+
if (/\bterraform\s*\{/.test(stripped)) {
|
|
58
|
+
sigs.push('terraform { ... }');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// moved block
|
|
62
|
+
for (const m of stripped.matchAll(/\bmoved\s*\{[\s\S]*?from\s*=\s*([^\n]+)/g)) {
|
|
63
|
+
sigs.push(`moved from ${m[1].trim()}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// import block (Terraform 1.5+)
|
|
67
|
+
for (const m of stripped.matchAll(/\bimport\s*\{[\s\S]*?to\s*=\s*([^\n]+)/g)) {
|
|
68
|
+
sigs.push(`import to ${m[1].trim()}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return sigs;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { extract };
|
package/src/mcp/server.js
CHANGED