sigmap 6.0.2 → 6.1.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/AGENTS.md +81 -70
- package/CHANGELOG.md +18 -0
- package/README.md +4 -4
- package/gen-context.js +126 -7
- package/package.json +1 -1
- package/packages/adapters/claude.js +6 -0
- package/packages/adapters/codex.js +13 -1
- package/packages/adapters/copilot.js +8 -0
- package/packages/adapters/cursor.js +4 -0
- package/packages/adapters/gemini.js +1 -0
- package/packages/adapters/openai.js +1 -0
- package/packages/adapters/windsurf.js +4 -0
- package/packages/cli/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/src/learning/weights.js +32 -0
- package/src/mcp/server.js +1 -1
package/AGENTS.md
CHANGED
|
@@ -13,10 +13,25 @@ Use this marker block for all appendable context files:
|
|
|
13
13
|
<!-- Updated by gen-context.js -->
|
|
14
14
|
# Code signatures
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## SigMap commands
|
|
17
|
+
|
|
18
|
+
| When | Command |
|
|
19
|
+
|------|---------|
|
|
20
|
+
| Before answering a question | `sigmap ask "<your question>"` |
|
|
21
|
+
| After code changes | `sigmap validate` |
|
|
22
|
+
| To query by topic | `sigmap --query "<topic>"` |
|
|
23
|
+
|
|
24
|
+
Always run `sigmap ask` or `sigmap --query` before searching for files relevant to a task.
|
|
25
|
+
## changes (last 5 commits — 31 minutes ago)
|
|
17
26
|
```
|
|
18
|
-
src/
|
|
27
|
+
src/learning/weights.js +exportWeights +importWeights ~resetWeights
|
|
19
28
|
packages/adapters/codex.js ~format
|
|
29
|
+
packages/adapters/gemini.js ~format
|
|
30
|
+
packages/adapters/copilot.js ~format
|
|
31
|
+
packages/adapters/openai.js ~format
|
|
32
|
+
packages/adapters/claude.js ~format
|
|
33
|
+
packages/adapters/cursor.js ~format
|
|
34
|
+
packages/adapters/windsurf.js ~format
|
|
20
35
|
```
|
|
21
36
|
|
|
22
37
|
## packages
|
|
@@ -44,39 +59,62 @@ function format(context, opts)
|
|
|
44
59
|
function write(context, cwd, opts)
|
|
45
60
|
```
|
|
46
61
|
|
|
47
|
-
### packages/
|
|
62
|
+
### packages/core/README.md
|
|
48
63
|
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
h1 sigmap-core
|
|
65
|
+
h2 Installation
|
|
66
|
+
h2 Quick start
|
|
67
|
+
h2 API reference
|
|
68
|
+
h3 `extract(src, language)` → `string[]`
|
|
69
|
+
h3 `rank(query, sigIndex, opts?)` → `Result[]`
|
|
70
|
+
h3 `buildSigIndex(cwd)` → `Map<string, string[]>`
|
|
71
|
+
h3 `scan(sigs, filePath)` → `{ safe: string[], redacted: boolean }`
|
|
72
|
+
h3 `score(cwd)` → `HealthResult`
|
|
73
|
+
h2 Migration from v2.3 and earlier
|
|
74
|
+
h2 v3.0 — Multi-Adapter Architecture (released)
|
|
75
|
+
h2 Zero dependencies
|
|
76
|
+
code-fence bash
|
|
77
|
+
code-fence plain
|
|
78
|
+
code-fence js
|
|
79
|
+
code-fence ---
|
|
54
80
|
```
|
|
55
81
|
|
|
56
|
-
### packages/
|
|
82
|
+
### packages/core/index.js
|
|
83
|
+
```
|
|
84
|
+
module.exports = { extract, rank, buildSigIndex, scan, score, adapt }
|
|
85
|
+
function _resolveExtractor(language)
|
|
86
|
+
function extract(src, language) → string[]
|
|
87
|
+
function rank(query, sigIndex, opts) → { file: string, score: nu
|
|
88
|
+
function buildSigIndex(cwd) → Map<string, string[]>
|
|
89
|
+
function scan(sigs, filePath) → { safe: string[], redacte
|
|
90
|
+
function score(cwd) → { * score: number, * grad
|
|
91
|
+
function adapt(context, adapterName, opts = {}) → string
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### packages/adapters/codex.js
|
|
57
95
|
```
|
|
58
96
|
module.exports = { name, format, outputPath, write }
|
|
59
97
|
function format(context, opts = {}) → string
|
|
60
|
-
function _confidenceMeta(opts)
|
|
61
98
|
function outputPath(cwd) → string
|
|
62
99
|
function write(context, cwd, opts = {})
|
|
63
100
|
```
|
|
64
101
|
|
|
65
|
-
### packages/adapters/
|
|
102
|
+
### packages/adapters/gemini.js
|
|
66
103
|
```
|
|
67
|
-
module.exports = { name, format, outputPath }
|
|
104
|
+
module.exports = { name, format, outputPath, write }
|
|
68
105
|
function format(context, opts = {}) → string
|
|
69
|
-
function _confidenceMeta(opts)
|
|
70
106
|
function outputPath(cwd) → string
|
|
107
|
+
function write(context, cwd, opts = {})
|
|
108
|
+
function _confidenceMeta(opts)
|
|
71
109
|
```
|
|
72
110
|
|
|
73
|
-
### packages/adapters/
|
|
111
|
+
### packages/adapters/copilot.js
|
|
74
112
|
```
|
|
75
113
|
module.exports = { name, format, outputPath, write }
|
|
76
114
|
function format(context, opts = {}) → string
|
|
115
|
+
function _confidenceMeta(opts)
|
|
77
116
|
function outputPath(cwd) → string
|
|
78
117
|
function write(context, cwd, opts = {})
|
|
79
|
-
function _confidenceMeta(opts)
|
|
80
118
|
```
|
|
81
119
|
|
|
82
120
|
### packages/adapters/openai.js
|
|
@@ -87,62 +125,33 @@ function outputPath(cwd) → string
|
|
|
87
125
|
function _confidenceMeta(opts)
|
|
88
126
|
```
|
|
89
127
|
|
|
90
|
-
### packages/adapters/
|
|
128
|
+
### packages/adapters/claude.js
|
|
91
129
|
```
|
|
92
|
-
module.exports = { name, format, outputPath }
|
|
130
|
+
module.exports = { name, format, outputPath, write }
|
|
93
131
|
function format(context, opts = {}) → string
|
|
94
132
|
function _confidenceMeta(opts)
|
|
95
133
|
function outputPath(cwd) → string
|
|
134
|
+
function write(context, cwd, opts = {})
|
|
96
135
|
```
|
|
97
136
|
|
|
98
|
-
### packages/
|
|
99
|
-
```
|
|
100
|
-
h1 sigmap-core
|
|
101
|
-
h2 Installation
|
|
102
|
-
h2 Quick start
|
|
103
|
-
h2 API reference
|
|
104
|
-
h3 `extract(src, language)` → `string[]`
|
|
105
|
-
h3 `rank(query, sigIndex, opts?)` → `Result[]`
|
|
106
|
-
h3 `buildSigIndex(cwd)` → `Map<string, string[]>`
|
|
107
|
-
h3 `scan(sigs, filePath)` → `{ safe: string[], redacted: boolean }`
|
|
108
|
-
h3 `score(cwd)` → `HealthResult`
|
|
109
|
-
h2 Migration from v2.3 and earlier
|
|
110
|
-
h2 v3.0 — Multi-Adapter Architecture (released)
|
|
111
|
-
h2 Zero dependencies
|
|
112
|
-
code-fence bash
|
|
113
|
-
code-fence plain
|
|
114
|
-
code-fence js
|
|
115
|
-
code-fence ---
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### packages/core/index.js
|
|
137
|
+
### packages/adapters/cursor.js
|
|
119
138
|
```
|
|
120
|
-
module.exports = {
|
|
121
|
-
function
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
function buildSigIndex(cwd) → Map<string, string[]>
|
|
125
|
-
function scan(sigs, filePath) → { safe: string[], redacte
|
|
126
|
-
function score(cwd) → { * score: number, * grad
|
|
127
|
-
function adapt(context, adapterName, opts = {}) → string
|
|
139
|
+
module.exports = { name, format, outputPath }
|
|
140
|
+
function format(context, opts = {}) → string
|
|
141
|
+
function _confidenceMeta(opts)
|
|
142
|
+
function outputPath(cwd) → string
|
|
128
143
|
```
|
|
129
144
|
|
|
130
|
-
### packages/adapters/
|
|
145
|
+
### packages/adapters/windsurf.js
|
|
131
146
|
```
|
|
132
|
-
module.exports = { name, format, outputPath
|
|
147
|
+
module.exports = { name, format, outputPath }
|
|
133
148
|
function format(context, opts = {}) → string
|
|
149
|
+
function _confidenceMeta(opts)
|
|
134
150
|
function outputPath(cwd) → string
|
|
135
|
-
function write(context, cwd, opts = {})
|
|
136
151
|
```
|
|
137
152
|
|
|
138
153
|
## src
|
|
139
154
|
|
|
140
|
-
### src/routing/hints.js
|
|
141
|
-
```
|
|
142
|
-
module.exports = { TIERS, formatRoutingSection }
|
|
143
|
-
function formatRoutingSection(groups) → string
|
|
144
|
-
```
|
|
145
|
-
|
|
146
155
|
### src/security/patterns.js
|
|
147
156
|
```
|
|
148
157
|
module.exports = { PATTERNS }
|
|
@@ -551,21 +560,6 @@ function extractContextFiles(context, cwd)
|
|
|
551
560
|
function judge(response, context, opts = {})
|
|
552
561
|
```
|
|
553
562
|
|
|
554
|
-
### src/learning/weights.js
|
|
555
|
-
```
|
|
556
|
-
module.exports = { BASELINE, DECAY, MAX_MULT, MIN_MULT, weightsPath, clampMultiplier, normalizeFile, loadWeights, saveWeights, updateWeights, boostFiles, penalizeFiles, resetWeights }
|
|
557
|
-
function weightsPath(cwd)
|
|
558
|
-
function clampMultiplier(value)
|
|
559
|
-
function normalizeFile(cwd, filePath)
|
|
560
|
-
function sanitizeWeights(cwd, weights)
|
|
561
|
-
function loadWeights(cwd)
|
|
562
|
-
function saveWeights(cwd, weights)
|
|
563
|
-
function updateWeights(cwd, opts = {})
|
|
564
|
-
function boostFiles(cwd, files, amount = 0.15)
|
|
565
|
-
function penalizeFiles(cwd, files, amount = 0.10)
|
|
566
|
-
function resetWeights(cwd)
|
|
567
|
-
```
|
|
568
|
-
|
|
569
563
|
### src/format/benchmark-report.js
|
|
570
564
|
```
|
|
571
565
|
module.exports = { loadBenchmarkReports, buildBenchmarkSummary, generateBenchmarkReportHtml, writeBenchmarkReport }
|
|
@@ -654,6 +648,23 @@ function extractClassMembers(block)
|
|
|
654
648
|
function normalizeParams(params)
|
|
655
649
|
```
|
|
656
650
|
|
|
651
|
+
### src/learning/weights.js
|
|
652
|
+
```
|
|
653
|
+
module.exports = { BASELINE, DECAY, MAX_MULT, MIN_MULT, weightsPath, clampMultiplier, normalizeFile, loadWeights, saveWeights, updateWeights, boostFiles, penalizeFiles, resetWeights, exportWeights, importWeights }
|
|
654
|
+
function weightsPath(cwd)
|
|
655
|
+
function clampMultiplier(value)
|
|
656
|
+
function normalizeFile(cwd, filePath)
|
|
657
|
+
function sanitizeWeights(cwd, weights)
|
|
658
|
+
function loadWeights(cwd)
|
|
659
|
+
function saveWeights(cwd, weights)
|
|
660
|
+
function updateWeights(cwd, opts = {})
|
|
661
|
+
function boostFiles(cwd, files, amount = 0.15)
|
|
662
|
+
function penalizeFiles(cwd, files, amount = 0.10)
|
|
663
|
+
function resetWeights(cwd)
|
|
664
|
+
function exportWeights(cwd, outputPath)
|
|
665
|
+
function importWeights(cwd, importPath, replace)
|
|
666
|
+
```
|
|
667
|
+
|
|
657
668
|
### src/mcp/server.js
|
|
658
669
|
```
|
|
659
670
|
module.exports = { start }
|
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,24 @@ Format: [Semantic Versioning](https://semver.org/)
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
+
## [6.1.0] — 2026-04-22
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **Tool instructions in every adapter (Level 1)** — each adapter's `format()` now embeds native-format SigMap command guidance: markdown table (copilot, codex), bullet list (claude), `#` comments (cursor, windsurf), instruction sentence (openai, gemini). Agents get `sigmap ask`, `sigmap validate`, and `sigmap judge` hints automatically in every generated context file.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## [6.0.3] — 2026-04-21
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`--coverage` CLI flag** — enables test coverage annotation (`✓`/`✗` per function) at runtime without editing config; sets `testCoverage: true` on the loaded config before any run path.
|
|
26
|
+
- **`sigmap weights --export [file]`** — writes learned weights JSON to a file path, or prints to stdout if no path given (pipe-friendly for CI and team sharing).
|
|
27
|
+
- **`sigmap weights --import <file> [--replace]`** — merges imported weights into the local `.context/weights.json`; `--replace` discards existing weights and takes the imported set entirely. Incoming values are sanitized and clamped.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
13
31
|
## [6.0.2] — 2026-04-21
|
|
14
32
|
|
|
15
33
|
### Fixed
|
package/README.md
CHANGED
|
@@ -76,14 +76,14 @@ Ask → Rank → Context → Validate → Judge → Learn
|
|
|
76
76
|
## Benchmark
|
|
77
77
|
|
|
78
78
|
```
|
|
79
|
-
Benchmark : sigmap-
|
|
79
|
+
Benchmark : sigmap-v6.0-main
|
|
80
80
|
Date : 2026-04-19
|
|
81
81
|
|
|
82
|
-
Hit@5 : 80.0% (baseline 13.6% — 5.
|
|
82
|
+
Hit@5 : 80.0% (baseline 13.6% — 5.8× lift)
|
|
83
83
|
Prompt reduction : 40.8%
|
|
84
84
|
Task success : 52.2% (baseline 10%)
|
|
85
85
|
Prompts / task : 1.68 (baseline 2.84)
|
|
86
|
-
Token reduction: 40–98% (avg
|
|
86
|
+
Token reduction: 40–98% (avg 96.9% across 18 real repos)
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Measured on 90 coding tasks across 18 real public repos. No LLM API — fully reproducible.
|
|
@@ -147,7 +147,7 @@ volta install sigmap
|
|
|
147
147
|
| `windsurf` | `.windsurfrules` | Windsurf |
|
|
148
148
|
| `openai` | `.github/openai-context.md` | OpenAI models |
|
|
149
149
|
| `gemini` | `.github/gemini-context.md` | Google Gemini |
|
|
150
|
-
| `codex` | `AGENTS.md` | OpenAI Codex |
|
|
150
|
+
| `codex` | `AGENTS.md` | OpenAI Codex · OpenCode |
|
|
151
151
|
|
|
152
152
|
```bash
|
|
153
153
|
sigmap --adapter copilot # default
|
package/gen-context.js
CHANGED
|
@@ -5327,11 +5327,42 @@ __factories["./src/learning/weights"] = function(module, exports) {
|
|
|
5327
5327
|
if (fs.existsSync(outPath)) fs.unlinkSync(outPath);
|
|
5328
5328
|
}
|
|
5329
5329
|
|
|
5330
|
+
function exportWeights(cwd, outputPath) {
|
|
5331
|
+
const weights = loadWeights(cwd);
|
|
5332
|
+
const json = JSON.stringify(weights, null, 2) + '\n';
|
|
5333
|
+
if (outputPath) {
|
|
5334
|
+
fs.mkdirSync(path.dirname(path.resolve(outputPath)), { recursive: true });
|
|
5335
|
+
fs.writeFileSync(outputPath, json, 'utf8');
|
|
5336
|
+
} else {
|
|
5337
|
+
process.stdout.write(json);
|
|
5338
|
+
}
|
|
5339
|
+
return weights;
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
function importWeights(cwd, importPath, replace) {
|
|
5343
|
+
let incoming;
|
|
5344
|
+
try {
|
|
5345
|
+
incoming = JSON.parse(fs.readFileSync(importPath, 'utf8'));
|
|
5346
|
+
} catch (err) {
|
|
5347
|
+
throw new Error('Cannot read weights file: ' + err.message);
|
|
5348
|
+
}
|
|
5349
|
+
const sanitized = sanitizeWeights(cwd, incoming);
|
|
5350
|
+
if (replace) {
|
|
5351
|
+
saveWeights(cwd, sanitized);
|
|
5352
|
+
return sanitized;
|
|
5353
|
+
}
|
|
5354
|
+
const existing = loadWeights(cwd);
|
|
5355
|
+
const merged = Object.assign({}, existing, sanitized);
|
|
5356
|
+
saveWeights(cwd, merged);
|
|
5357
|
+
return merged;
|
|
5358
|
+
}
|
|
5359
|
+
|
|
5330
5360
|
module.exports = {
|
|
5331
5361
|
BASELINE, DECAY, MAX_MULT, MIN_MULT,
|
|
5332
5362
|
weightsPath, clampMultiplier, normalizeFile,
|
|
5333
5363
|
loadWeights, saveWeights, updateWeights,
|
|
5334
5364
|
boostFiles, penalizeFiles, resetWeights,
|
|
5365
|
+
exportWeights, importWeights,
|
|
5335
5366
|
};
|
|
5336
5367
|
};
|
|
5337
5368
|
|
|
@@ -5356,7 +5387,7 @@ __factories["./src/mcp/server"] = function(module, exports) {
|
|
|
5356
5387
|
|
|
5357
5388
|
const SERVER_INFO = {
|
|
5358
5389
|
name: 'sigmap',
|
|
5359
|
-
version: '6.0
|
|
5390
|
+
version: '6.1.0',
|
|
5360
5391
|
description: 'SigMap MCP server — code signatures on demand',
|
|
5361
5392
|
};
|
|
5362
5393
|
|
|
@@ -6722,6 +6753,14 @@ __factories["./packages/adapters/copilot"] = function(module, exports) {
|
|
|
6722
6753
|
`<!-- Updated: ${timestamp} -->`,
|
|
6723
6754
|
`<!-- Do not edit below — regenerate with: node gen-context.js -->`,
|
|
6724
6755
|
'',
|
|
6756
|
+
'## SigMap commands',
|
|
6757
|
+
'',
|
|
6758
|
+
'| When | Command |',
|
|
6759
|
+
'|------|---------|',
|
|
6760
|
+
'| Before answering a question about code | `sigmap ask "<your question>"` |',
|
|
6761
|
+
'| After changing config or source dirs | `sigmap validate` |',
|
|
6762
|
+
'| To verify an AI answer is grounded | `sigmap judge --response <file>` |',
|
|
6763
|
+
'',
|
|
6725
6764
|
'# Code signatures',
|
|
6726
6765
|
'',
|
|
6727
6766
|
context,
|
|
@@ -6754,7 +6793,17 @@ __factories["./packages/adapters/claude"] = function(module, exports) {
|
|
|
6754
6793
|
if (!context || typeof context !== 'string') return '';
|
|
6755
6794
|
const version = (opts && opts.version) || 'unknown';
|
|
6756
6795
|
const timestamp = new Date().toISOString();
|
|
6757
|
-
return [
|
|
6796
|
+
return [
|
|
6797
|
+
'## SigMap',
|
|
6798
|
+
'- Before searching for files, run `sigmap ask "<query>"` — ranks by TF-IDF relevance',
|
|
6799
|
+
'- After config changes, run `sigmap validate` to confirm coverage',
|
|
6800
|
+
'- To verify answer groundedness, run `sigmap judge --response <file> --context CLAUDE.md`',
|
|
6801
|
+
'- For PR-scoped context, run `sigmap --diff`',
|
|
6802
|
+
'',
|
|
6803
|
+
`<!-- Generated by SigMap v${version} — ${timestamp} -->`,
|
|
6804
|
+
'',
|
|
6805
|
+
context,
|
|
6806
|
+
].join('\n');
|
|
6758
6807
|
}
|
|
6759
6808
|
function outputPath(cwd) { return path.join(cwd, 'CLAUDE.md'); }
|
|
6760
6809
|
function write(context, cwd, opts = {}) {
|
|
@@ -6779,7 +6828,17 @@ __factories["./packages/adapters/cursor"] = function(module, exports) {
|
|
|
6779
6828
|
if (!context || typeof context !== 'string') return '';
|
|
6780
6829
|
const version = (opts && opts.version) || 'unknown';
|
|
6781
6830
|
const timestamp = new Date().toISOString();
|
|
6782
|
-
return [
|
|
6831
|
+
return [
|
|
6832
|
+
`# Code signatures — generated by SigMap v${version}`,
|
|
6833
|
+
`# Updated: ${timestamp}`,
|
|
6834
|
+
`# Regenerate: node gen-context.js`,
|
|
6835
|
+
'#',
|
|
6836
|
+
'# SigMap: before answering, run: sigmap ask "<query>" — finds relevant files',
|
|
6837
|
+
'# SigMap: after config changes, run: sigmap validate',
|
|
6838
|
+
'# SigMap: to verify answers, run: sigmap judge --response <file>',
|
|
6839
|
+
'',
|
|
6840
|
+
context,
|
|
6841
|
+
].join('\n');
|
|
6783
6842
|
}
|
|
6784
6843
|
function outputPath(cwd) { return path.join(cwd, '.cursorrules'); }
|
|
6785
6844
|
module.exports = { name, format, outputPath };
|
|
@@ -6793,7 +6852,17 @@ __factories["./packages/adapters/windsurf"] = function(module, exports) {
|
|
|
6793
6852
|
if (!context || typeof context !== 'string') return '';
|
|
6794
6853
|
const version = (opts && opts.version) || 'unknown';
|
|
6795
6854
|
const timestamp = new Date().toISOString();
|
|
6796
|
-
return [
|
|
6855
|
+
return [
|
|
6856
|
+
`# Code signatures — generated by SigMap v${version}`,
|
|
6857
|
+
`# Updated: ${timestamp}`,
|
|
6858
|
+
`# Regenerate: node gen-context.js`,
|
|
6859
|
+
'#',
|
|
6860
|
+
'# SigMap: before answering, run: sigmap ask "<query>" — finds relevant files',
|
|
6861
|
+
'# SigMap: after config changes, run: sigmap validate',
|
|
6862
|
+
'# SigMap: to verify answers, run: sigmap judge --response <file>',
|
|
6863
|
+
'',
|
|
6864
|
+
context,
|
|
6865
|
+
].join('\n');
|
|
6797
6866
|
}
|
|
6798
6867
|
function outputPath(cwd) { return path.join(cwd, '.windsurfrules'); }
|
|
6799
6868
|
module.exports = { name, format, outputPath };
|
|
@@ -6813,6 +6882,8 @@ __factories["./packages/adapters/openai"] = function(module, exports) {
|
|
|
6813
6882
|
`Below are the code signatures extracted by SigMap v${version} on ${timestamp}.`,
|
|
6814
6883
|
projectLine,
|
|
6815
6884
|
`Use these signatures to answer questions about the code accurately.`,
|
|
6885
|
+
`When the user asks about a specific file or function, refer to the signatures below.`,
|
|
6886
|
+
`Before answering questions about specific code areas, prefer running \`sigmap ask "<query>"\` to get the most relevant files. After config changes, \`sigmap validate\` confirms coverage.`,
|
|
6816
6887
|
``,
|
|
6817
6888
|
`## Code Signatures`,
|
|
6818
6889
|
``,
|
|
@@ -6839,6 +6910,8 @@ __factories["./packages/adapters/gemini"] = function(module, exports) {
|
|
|
6839
6910
|
`The following code signatures were extracted by SigMap v${version} on ${timestamp}.`,
|
|
6840
6911
|
projectLine,
|
|
6841
6912
|
`These signatures represent every public function, class, and type in the project.`,
|
|
6913
|
+
`Refer to them when answering questions about code structure, APIs, and implementation.`,
|
|
6914
|
+
`Before answering questions about specific code areas, suggest running \`sigmap ask "<query>"\` to get the most relevant files. After config changes, \`sigmap validate\` confirms coverage.`,
|
|
6842
6915
|
``,
|
|
6843
6916
|
`## Code Signatures`,
|
|
6844
6917
|
``,
|
|
@@ -6870,7 +6943,19 @@ __factories["./packages/adapters/codex"] = function(module, exports) {
|
|
|
6870
6943
|
const CODEX_MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
6871
6944
|
function format(context, opts = {}) {
|
|
6872
6945
|
if (!context || typeof context !== 'string' || !context.trim()) return '';
|
|
6873
|
-
|
|
6946
|
+
const toolBlock = [
|
|
6947
|
+
'## SigMap commands',
|
|
6948
|
+
'',
|
|
6949
|
+
'| When | Command |',
|
|
6950
|
+
'|------|---------|',
|
|
6951
|
+
'| Before answering a question | `sigmap ask "<your question>"` |',
|
|
6952
|
+
'| After code changes | `sigmap validate` |',
|
|
6953
|
+
'| To query by topic | `sigmap --query "<topic>"` |',
|
|
6954
|
+
'',
|
|
6955
|
+
'Always run `sigmap ask` or `sigmap --query` before searching for files relevant to a task.',
|
|
6956
|
+
'',
|
|
6957
|
+
].join('\n');
|
|
6958
|
+
return '# Code signatures\n\n' + toolBlock + context;
|
|
6874
6959
|
}
|
|
6875
6960
|
function outputPath(cwd) { return path.join(cwd, 'AGENTS.md'); }
|
|
6876
6961
|
function write(context, cwd, opts = {}) {
|
|
@@ -7074,7 +7159,7 @@ const path = require('path');
|
|
|
7074
7159
|
const os = require('os');
|
|
7075
7160
|
const { execSync } = require('child_process');
|
|
7076
7161
|
|
|
7077
|
-
const VERSION = '6.0
|
|
7162
|
+
const VERSION = '6.1.0';
|
|
7078
7163
|
const MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
7079
7164
|
|
|
7080
7165
|
function requireSourceOrBundled(key) {
|
|
@@ -8982,6 +9067,11 @@ function main() {
|
|
|
8982
9067
|
config.srcDirs = ['.'];
|
|
8983
9068
|
}
|
|
8984
9069
|
|
|
9070
|
+
// --coverage: enable test coverage annotation without editing config
|
|
9071
|
+
if (args.includes('--coverage')) {
|
|
9072
|
+
config.testCoverage = true;
|
|
9073
|
+
}
|
|
9074
|
+
|
|
8985
9075
|
// ── --output <file> — parse early so every subsequent block can use it ─────
|
|
8986
9076
|
// Resolves the custom output path and merges it into config.customOutput.
|
|
8987
9077
|
// Also persists the resolved relative path to gen-context.config.json so
|
|
@@ -9304,7 +9394,36 @@ function main() {
|
|
|
9304
9394
|
|
|
9305
9395
|
// v5.2: `sigmap weights` — explain learned ranking multipliers
|
|
9306
9396
|
if (args[0] === 'weights') {
|
|
9307
|
-
const { loadWeights } = requireSourceOrBundled('./src/learning/weights');
|
|
9397
|
+
const { loadWeights, exportWeights, importWeights } = requireSourceOrBundled('./src/learning/weights');
|
|
9398
|
+
|
|
9399
|
+
if (args.includes('--export')) {
|
|
9400
|
+
const exportIdx = args.indexOf('--export');
|
|
9401
|
+
const maybeFile = args[exportIdx + 1];
|
|
9402
|
+
const exportFile = (maybeFile && !maybeFile.startsWith('--')) ? maybeFile : null;
|
|
9403
|
+
exportWeights(cwd, exportFile);
|
|
9404
|
+
if (exportFile) console.warn(`[sigmap] weights exported to ${exportFile}`);
|
|
9405
|
+
process.exit(0);
|
|
9406
|
+
}
|
|
9407
|
+
|
|
9408
|
+
if (args.includes('--import')) {
|
|
9409
|
+
const importIdx = args.indexOf('--import');
|
|
9410
|
+
const importFile = args[importIdx + 1];
|
|
9411
|
+
if (!importFile || importFile.startsWith('--')) {
|
|
9412
|
+
console.error('[sigmap] --import requires a file path');
|
|
9413
|
+
process.exit(1);
|
|
9414
|
+
}
|
|
9415
|
+
const replace = args.includes('--replace');
|
|
9416
|
+
try {
|
|
9417
|
+
const result = importWeights(cwd, importFile, replace);
|
|
9418
|
+
const count = Object.keys(result).length;
|
|
9419
|
+
console.warn(`[sigmap] weights ${replace ? 'replaced' : 'merged'} from ${importFile} — ${count} file(s) with non-baseline weights`);
|
|
9420
|
+
} catch (err) {
|
|
9421
|
+
console.error(`[sigmap] weights import failed: ${err.message}`);
|
|
9422
|
+
process.exit(1);
|
|
9423
|
+
}
|
|
9424
|
+
process.exit(0);
|
|
9425
|
+
}
|
|
9426
|
+
|
|
9308
9427
|
const weights = loadWeights(cwd);
|
|
9309
9428
|
const entries = Object.entries(weights).sort(([, a], [, b]) => b - a || 0);
|
|
9310
9429
|
|
package/package.json
CHANGED
|
@@ -30,6 +30,12 @@ function format(context, opts = {}) {
|
|
|
30
30
|
const timestamp = new Date().toISOString();
|
|
31
31
|
const meta = _confidenceMeta(opts);
|
|
32
32
|
return [
|
|
33
|
+
'## SigMap',
|
|
34
|
+
'- Before searching for files, run `sigmap ask "<query>"` — ranks by TF-IDF relevance',
|
|
35
|
+
'- After config changes, run `sigmap validate` to confirm coverage',
|
|
36
|
+
'- To verify answer groundedness, run `sigmap judge --response <file> --context CLAUDE.md`',
|
|
37
|
+
'- For PR-scoped context, run `sigmap --diff`',
|
|
38
|
+
'',
|
|
33
39
|
`<!-- Generated by SigMap v${version} — ${timestamp} -->`,
|
|
34
40
|
meta,
|
|
35
41
|
'',
|
|
@@ -26,7 +26,19 @@ const MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js
|
|
|
26
26
|
*/
|
|
27
27
|
function format(context, opts = {}) {
|
|
28
28
|
if (!context || typeof context !== 'string' || !context.trim()) return '';
|
|
29
|
-
|
|
29
|
+
const toolBlock = [
|
|
30
|
+
'## SigMap commands',
|
|
31
|
+
'',
|
|
32
|
+
'| When | Command |',
|
|
33
|
+
'|------|---------|',
|
|
34
|
+
'| Before answering a question | `sigmap ask "<your question>"` |',
|
|
35
|
+
'| After code changes | `sigmap validate` |',
|
|
36
|
+
'| To query by topic | `sigmap --query "<topic>"` |',
|
|
37
|
+
'',
|
|
38
|
+
'Always run `sigmap ask` or `sigmap --query` before searching for files relevant to a task.',
|
|
39
|
+
'',
|
|
40
|
+
].join('\n');
|
|
41
|
+
return `# Code signatures\n\n${toolBlock}${context}`;
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
/**
|
|
@@ -33,6 +33,14 @@ function format(context, opts = {}) {
|
|
|
33
33
|
meta,
|
|
34
34
|
`<!-- Do not edit below — regenerate with: node gen-context.js -->`,
|
|
35
35
|
'',
|
|
36
|
+
'## SigMap commands',
|
|
37
|
+
'',
|
|
38
|
+
'| When | Command |',
|
|
39
|
+
'|------|---------|',
|
|
40
|
+
'| Before answering a question about code | `sigmap ask "<your question>"` |',
|
|
41
|
+
'| After changing config or source dirs | `sigmap validate` |',
|
|
42
|
+
'| To verify an AI answer is grounded | `sigmap judge --response <file>` |',
|
|
43
|
+
'',
|
|
36
44
|
'# Code signatures',
|
|
37
45
|
'',
|
|
38
46
|
].join('\n');
|
|
@@ -30,6 +30,10 @@ function format(context, opts = {}) {
|
|
|
30
30
|
`# Updated: ${timestamp}`,
|
|
31
31
|
`# ${meta}`,
|
|
32
32
|
`# Regenerate: node gen-context.js`,
|
|
33
|
+
'#',
|
|
34
|
+
'# SigMap: before answering, run: sigmap ask "<query>" — finds relevant files',
|
|
35
|
+
'# SigMap: after config changes, run: sigmap validate',
|
|
36
|
+
'# SigMap: to verify answers, run: sigmap judge --response <file>',
|
|
33
37
|
'',
|
|
34
38
|
].join('\n');
|
|
35
39
|
return header + context;
|
|
@@ -44,6 +44,7 @@ function format(context, opts = {}) {
|
|
|
44
44
|
projectLine,
|
|
45
45
|
`These signatures represent every public function, class, and type in the project.`,
|
|
46
46
|
`Refer to them when answering questions about code structure, APIs, and implementation.`,
|
|
47
|
+
`Before answering questions about specific code areas, suggest running \`sigmap ask "<query>"\` to get the most relevant files. After config changes, \`sigmap validate\` confirms coverage.`,
|
|
47
48
|
``,
|
|
48
49
|
`## Code Signatures`,
|
|
49
50
|
``,
|
|
@@ -42,6 +42,7 @@ function format(context, opts = {}) {
|
|
|
42
42
|
projectLine,
|
|
43
43
|
`Use these signatures to answer questions about the code accurately.`,
|
|
44
44
|
`When the user asks about a specific file or function, refer to the signatures below.`,
|
|
45
|
+
`Before answering questions about specific code areas, prefer running \`sigmap ask "<query>"\` to get the most relevant files. After config changes, \`sigmap validate\` confirms coverage.`,
|
|
45
46
|
``,
|
|
46
47
|
`## Code Signatures`,
|
|
47
48
|
``,
|
|
@@ -30,6 +30,10 @@ function format(context, opts = {}) {
|
|
|
30
30
|
`# Updated: ${timestamp}`,
|
|
31
31
|
`# ${meta}`,
|
|
32
32
|
`# Regenerate: node gen-context.js`,
|
|
33
|
+
'#',
|
|
34
|
+
'# SigMap: before answering, run: sigmap ask "<query>" — finds relevant files',
|
|
35
|
+
'# SigMap: after config changes, run: sigmap validate',
|
|
36
|
+
'# SigMap: to verify answers, run: sigmap judge --response <file>',
|
|
33
37
|
'',
|
|
34
38
|
].join('\n');
|
|
35
39
|
return header + context;
|
package/src/learning/weights.js
CHANGED
|
@@ -121,6 +121,36 @@ function resetWeights(cwd) {
|
|
|
121
121
|
if (fs.existsSync(outPath)) fs.unlinkSync(outPath);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
function exportWeights(cwd, outputPath) {
|
|
125
|
+
const weights = loadWeights(cwd);
|
|
126
|
+
const json = JSON.stringify(weights, null, 2) + '\n';
|
|
127
|
+
if (outputPath) {
|
|
128
|
+
fs.mkdirSync(path.dirname(path.resolve(outputPath)), { recursive: true });
|
|
129
|
+
fs.writeFileSync(outputPath, json, 'utf8');
|
|
130
|
+
} else {
|
|
131
|
+
process.stdout.write(json);
|
|
132
|
+
}
|
|
133
|
+
return weights;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function importWeights(cwd, importPath, replace) {
|
|
137
|
+
let incoming;
|
|
138
|
+
try {
|
|
139
|
+
incoming = JSON.parse(fs.readFileSync(importPath, 'utf8'));
|
|
140
|
+
} catch (err) {
|
|
141
|
+
throw new Error(`Cannot read weights file: ${err.message}`);
|
|
142
|
+
}
|
|
143
|
+
const sanitized = sanitizeWeights(cwd, incoming);
|
|
144
|
+
if (replace) {
|
|
145
|
+
saveWeights(cwd, sanitized);
|
|
146
|
+
return sanitized;
|
|
147
|
+
}
|
|
148
|
+
const existing = loadWeights(cwd);
|
|
149
|
+
const merged = Object.assign({}, existing, sanitized);
|
|
150
|
+
saveWeights(cwd, merged);
|
|
151
|
+
return merged;
|
|
152
|
+
}
|
|
153
|
+
|
|
124
154
|
module.exports = {
|
|
125
155
|
BASELINE,
|
|
126
156
|
DECAY,
|
|
@@ -135,4 +165,6 @@ module.exports = {
|
|
|
135
165
|
boostFiles,
|
|
136
166
|
penalizeFiles,
|
|
137
167
|
resetWeights,
|
|
168
|
+
exportWeights,
|
|
169
|
+
importWeights,
|
|
138
170
|
};
|
package/src/mcp/server.js
CHANGED