sigmap 6.1.0 → 6.3.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 +50 -25
- package/CHANGELOG.md +16 -0
- package/gen-context.js +130 -22
- package/package.json +1 -1
- package/packages/adapters/claude.js +42 -0
- package/packages/adapters/codex.js +48 -0
- package/packages/cli/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/src/mcp/server.js +1 -1
package/AGENTS.md
CHANGED
|
@@ -9,28 +9,53 @@ When writing generated signature content, never overwrite human-written notes ab
|
|
|
9
9
|
Use this marker block for all appendable context files:
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
+
## Tools
|
|
13
|
+
|
|
14
|
+
<!-- sigmap-tools -->
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
"name": "sigmap_ask",
|
|
20
|
+
"description": "Rank source files by relevance to a natural-language query. Run before exploring the codebase.",
|
|
21
|
+
"command": "sigmap ask \"$QUERY\""
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "sigmap_validate",
|
|
25
|
+
"description": "Validate SigMap config and measure context coverage. Run after changing config or source dirs.",
|
|
26
|
+
"command": "sigmap validate"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "sigmap_judge",
|
|
30
|
+
"description": "Score an LLM response for groundedness against source context. Use to verify answer quality.",
|
|
31
|
+
"command": "sigmap judge --response \"$RESPONSE\" --context \"$CONTEXT\""
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "sigmap_query",
|
|
35
|
+
"description": "Rank all files by relevance using TF-IDF and write a focused mini-context.",
|
|
36
|
+
"command": "sigmap --query \"$QUERY\" --context"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "sigmap_weights",
|
|
40
|
+
"description": "Show learned file-ranking multipliers accumulated from past sessions.",
|
|
41
|
+
"command": "sigmap weights"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
```
|
|
45
|
+
|
|
12
46
|
## Auto-generated signatures
|
|
13
47
|
<!-- Updated by gen-context.js -->
|
|
14
48
|
# Code signatures
|
|
15
49
|
|
|
16
|
-
##
|
|
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)
|
|
50
|
+
## changes (last 5 commits — 0 seconds ago)
|
|
26
51
|
```
|
|
27
52
|
src/learning/weights.js +exportWeights +importWeights ~resetWeights
|
|
28
|
-
packages/adapters/codex.js ~format
|
|
53
|
+
packages/adapters/codex.js ~write ~format
|
|
54
|
+
packages/adapters/claude.js ~format ~write
|
|
29
55
|
packages/adapters/gemini.js ~format
|
|
30
56
|
packages/adapters/copilot.js ~format
|
|
31
|
-
packages/adapters/openai.js ~format
|
|
32
|
-
packages/adapters/claude.js ~format
|
|
33
57
|
packages/adapters/cursor.js ~format
|
|
58
|
+
packages/adapters/openai.js ~format
|
|
34
59
|
packages/adapters/windsurf.js ~format
|
|
35
60
|
```
|
|
36
61
|
|
|
@@ -99,33 +124,25 @@ function outputPath(cwd) → string
|
|
|
99
124
|
function write(context, cwd, opts = {})
|
|
100
125
|
```
|
|
101
126
|
|
|
102
|
-
### packages/adapters/
|
|
127
|
+
### packages/adapters/claude.js
|
|
103
128
|
```
|
|
104
129
|
module.exports = { name, format, outputPath, write }
|
|
105
130
|
function format(context, opts = {}) → string
|
|
131
|
+
function _confidenceMeta(opts)
|
|
106
132
|
function outputPath(cwd) → string
|
|
107
133
|
function write(context, cwd, opts = {})
|
|
108
|
-
function _confidenceMeta(opts)
|
|
109
134
|
```
|
|
110
135
|
|
|
111
|
-
### packages/adapters/
|
|
136
|
+
### packages/adapters/gemini.js
|
|
112
137
|
```
|
|
113
138
|
module.exports = { name, format, outputPath, write }
|
|
114
139
|
function format(context, opts = {}) → string
|
|
115
|
-
function _confidenceMeta(opts)
|
|
116
140
|
function outputPath(cwd) → string
|
|
117
141
|
function write(context, cwd, opts = {})
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### packages/adapters/openai.js
|
|
121
|
-
```
|
|
122
|
-
module.exports = { name, format, outputPath }
|
|
123
|
-
function format(context, opts = {}) → string
|
|
124
|
-
function outputPath(cwd) → string
|
|
125
142
|
function _confidenceMeta(opts)
|
|
126
143
|
```
|
|
127
144
|
|
|
128
|
-
### packages/adapters/
|
|
145
|
+
### packages/adapters/copilot.js
|
|
129
146
|
```
|
|
130
147
|
module.exports = { name, format, outputPath, write }
|
|
131
148
|
function format(context, opts = {}) → string
|
|
@@ -142,6 +159,14 @@ function _confidenceMeta(opts)
|
|
|
142
159
|
function outputPath(cwd) → string
|
|
143
160
|
```
|
|
144
161
|
|
|
162
|
+
### packages/adapters/openai.js
|
|
163
|
+
```
|
|
164
|
+
module.exports = { name, format, outputPath }
|
|
165
|
+
function format(context, opts = {}) → string
|
|
166
|
+
function outputPath(cwd) → string
|
|
167
|
+
function _confidenceMeta(opts)
|
|
168
|
+
```
|
|
169
|
+
|
|
145
170
|
### packages/adapters/windsurf.js
|
|
146
171
|
```
|
|
147
172
|
module.exports = { name, format, outputPath }
|
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,22 @@ Format: [Semantic Versioning](https://semver.org/)
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
+
## [6.3.0] — 2026-04-22
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **Native tool registration (Level 3)** — `codex.write()` injects a `## Tools` JSON block into AGENTS.md with 5 named sigmap shell tools (`sigmap_ask`, `sigmap_validate`, `sigmap_judge`, `sigmap_query`, `sigmap_weights`); Codex CLI and OpenCode surface these in their tool picker. `claude.write()` injects a `## Bash allowlist` section into CLAUDE.md with `permissions.allow` patterns for all sigmap commands; adding these to `.claude/settings.json` bypasses the Claude Code confirmation prompt. Both sections are idempotent and preserve human content.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## [6.2.0] — 2026-04-22
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`--setup` MCP auto-wire for 4 new targets** — `sigmap --setup` now registers the MCP server in `.vscode/mcp.json` (GitHub Copilot in VS Code 1.99+), `opencode.json` and `~/.config/opencode/config.json` (OpenCode), `~/.gemini/settings.json` (Gemini CLI), and `~/.codex/config.yaml` (Codex CLI — YAML format). All 5 new targets are idempotent and only written if the file already exists. Total `--setup` targets: 5 → 10.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
13
29
|
## [6.1.0] — 2026-04-22
|
|
14
30
|
|
|
15
31
|
### Added
|
package/gen-context.js
CHANGED
|
@@ -5387,7 +5387,7 @@ __factories["./src/mcp/server"] = function(module, exports) {
|
|
|
5387
5387
|
|
|
5388
5388
|
const SERVER_INFO = {
|
|
5389
5389
|
name: 'sigmap',
|
|
5390
|
-
version: '6.
|
|
5390
|
+
version: '6.3.0',
|
|
5391
5391
|
description: 'SigMap MCP server — code signatures on demand',
|
|
5392
5392
|
};
|
|
5393
5393
|
|
|
@@ -6789,6 +6789,36 @@ __factories["./packages/adapters/claude"] = function(module, exports) {
|
|
|
6789
6789
|
const fs = require('fs');
|
|
6790
6790
|
const name = 'claude';
|
|
6791
6791
|
const CLAUDE_MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
6792
|
+
const CLAUDE_ALLOWLIST_MARKER = '<!-- sigmap-bash-allowlist -->';
|
|
6793
|
+
const CLAUDE_ALLOWLIST_BLOCK = [
|
|
6794
|
+
'## Bash allowlist',
|
|
6795
|
+
'',
|
|
6796
|
+
CLAUDE_ALLOWLIST_MARKER,
|
|
6797
|
+
'',
|
|
6798
|
+
'The following sigmap commands are pre-approved — Claude Code will not prompt for confirmation:',
|
|
6799
|
+
'',
|
|
6800
|
+
'```json',
|
|
6801
|
+
JSON.stringify({
|
|
6802
|
+
permissions: {
|
|
6803
|
+
allow: [
|
|
6804
|
+
'Bash(sigmap ask*)',
|
|
6805
|
+
'Bash(sigmap validate*)',
|
|
6806
|
+
'Bash(sigmap judge*)',
|
|
6807
|
+
'Bash(sigmap weights*)',
|
|
6808
|
+
'Bash(sigmap history*)',
|
|
6809
|
+
'Bash(sigmap --query*)',
|
|
6810
|
+
'Bash(sigmap --diff*)',
|
|
6811
|
+
'Bash(sigmap --health*)',
|
|
6812
|
+
'Bash(sigmap --coverage*)',
|
|
6813
|
+
'Bash(node gen-context.js*)',
|
|
6814
|
+
],
|
|
6815
|
+
},
|
|
6816
|
+
}, null, 2),
|
|
6817
|
+
'```',
|
|
6818
|
+
'',
|
|
6819
|
+
'Add the `permissions.allow` array above to `.claude/settings.json` to activate.',
|
|
6820
|
+
'',
|
|
6821
|
+
].join('\n');
|
|
6792
6822
|
function format(context, opts = {}) {
|
|
6793
6823
|
if (!context || typeof context !== 'string') return '';
|
|
6794
6824
|
const version = (opts && opts.version) || 'unknown';
|
|
@@ -6812,9 +6842,17 @@ __factories["./packages/adapters/claude"] = function(module, exports) {
|
|
|
6812
6842
|
if (fs.existsSync(filePath)) existing = fs.readFileSync(filePath, 'utf8');
|
|
6813
6843
|
const formatted = format(context, opts);
|
|
6814
6844
|
const markerIdx = existing.indexOf('## Auto-generated signatures');
|
|
6815
|
-
|
|
6845
|
+
let newContent = markerIdx !== -1
|
|
6816
6846
|
? existing.slice(0, markerIdx) + CLAUDE_MARKER.trimStart() + formatted
|
|
6817
6847
|
: existing + CLAUDE_MARKER + formatted;
|
|
6848
|
+
if (!newContent.includes(CLAUDE_ALLOWLIST_MARKER)) {
|
|
6849
|
+
const sigPos = newContent.indexOf('## Auto-generated signatures');
|
|
6850
|
+
if (sigPos !== -1) {
|
|
6851
|
+
newContent = newContent.slice(0, sigPos) + CLAUDE_ALLOWLIST_BLOCK + '\n' + newContent.slice(sigPos);
|
|
6852
|
+
} else {
|
|
6853
|
+
newContent = CLAUDE_ALLOWLIST_BLOCK + '\n' + newContent;
|
|
6854
|
+
}
|
|
6855
|
+
}
|
|
6818
6856
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
6819
6857
|
}
|
|
6820
6858
|
module.exports = { name, format, outputPath, write };
|
|
@@ -6941,6 +6979,23 @@ __factories["./packages/adapters/codex"] = function(module, exports) {
|
|
|
6941
6979
|
const fs = require('fs');
|
|
6942
6980
|
const name = 'codex';
|
|
6943
6981
|
const CODEX_MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
6982
|
+
const CODEX_TOOLS_MARKER = '<!-- sigmap-tools -->';
|
|
6983
|
+
const CODEX_TOOLS_BLOCK = [
|
|
6984
|
+
'## Tools',
|
|
6985
|
+
'',
|
|
6986
|
+
CODEX_TOOLS_MARKER,
|
|
6987
|
+
'',
|
|
6988
|
+
'```json',
|
|
6989
|
+
JSON.stringify([
|
|
6990
|
+
{ name: 'sigmap_ask', description: 'Rank source files by relevance to a natural-language query. Run before exploring the codebase.', command: 'sigmap ask "$QUERY"' },
|
|
6991
|
+
{ name: 'sigmap_validate', description: 'Validate SigMap config and measure context coverage. Run after changing config or source dirs.', command: 'sigmap validate' },
|
|
6992
|
+
{ name: 'sigmap_judge', description: 'Score an LLM response for groundedness against source context. Use to verify answer quality.', command: 'sigmap judge --response "$RESPONSE" --context "$CONTEXT"' },
|
|
6993
|
+
{ name: 'sigmap_query', description: 'Rank all files by relevance using TF-IDF and write a focused mini-context.', command: 'sigmap --query "$QUERY" --context' },
|
|
6994
|
+
{ name: 'sigmap_weights', description: 'Show learned file-ranking multipliers accumulated from past sessions.', command: 'sigmap weights' },
|
|
6995
|
+
], null, 2),
|
|
6996
|
+
'```',
|
|
6997
|
+
'',
|
|
6998
|
+
].join('\n');
|
|
6944
6999
|
function format(context, opts = {}) {
|
|
6945
7000
|
if (!context || typeof context !== 'string' || !context.trim()) return '';
|
|
6946
7001
|
const toolBlock = [
|
|
@@ -6965,9 +7020,17 @@ __factories["./packages/adapters/codex"] = function(module, exports) {
|
|
|
6965
7020
|
const formatted = format(context, opts);
|
|
6966
7021
|
const markerIdx = existing.indexOf('## Auto-generated signatures');
|
|
6967
7022
|
const isLegacyGenerated = existing.includes('<!-- Generated by SigMap gen-context.js') || existing.includes('## Code Signatures') || existing.includes('# Code signatures');
|
|
6968
|
-
|
|
7023
|
+
let newContent = markerIdx !== -1
|
|
6969
7024
|
? existing.slice(0, markerIdx) + CODEX_MARKER.trimStart() + formatted
|
|
6970
7025
|
: (isLegacyGenerated ? CODEX_MARKER.trimStart() + formatted : existing + CODEX_MARKER + formatted);
|
|
7026
|
+
if (!newContent.includes(CODEX_TOOLS_MARKER)) {
|
|
7027
|
+
const sigPos = newContent.indexOf('## Auto-generated signatures');
|
|
7028
|
+
if (sigPos !== -1) {
|
|
7029
|
+
newContent = newContent.slice(0, sigPos) + CODEX_TOOLS_BLOCK + '\n' + newContent.slice(sigPos);
|
|
7030
|
+
} else {
|
|
7031
|
+
newContent = CODEX_TOOLS_BLOCK + '\n' + newContent;
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
6971
7034
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
6972
7035
|
}
|
|
6973
7036
|
module.exports = { name, format, outputPath, write };
|
|
@@ -7159,7 +7222,7 @@ const path = require('path');
|
|
|
7159
7222
|
const os = require('os');
|
|
7160
7223
|
const { execSync } = require('child_process');
|
|
7161
7224
|
|
|
7162
|
-
const VERSION = '6.
|
|
7225
|
+
const VERSION = '6.3.0';
|
|
7163
7226
|
const MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
7164
7227
|
|
|
7165
7228
|
function requireSourceOrBundled(key) {
|
|
@@ -8862,34 +8925,67 @@ Output: .github/copilot-instructions.md (default)
|
|
|
8862
8925
|
// ---------------------------------------------------------------------------
|
|
8863
8926
|
// MCP auto-registration
|
|
8864
8927
|
// ---------------------------------------------------------------------------
|
|
8928
|
+
function _displayPath(p, cwd) {
|
|
8929
|
+
return p.startsWith(os.homedir()) ? '~' + p.slice(os.homedir().length) : path.relative(cwd, p);
|
|
8930
|
+
}
|
|
8931
|
+
|
|
8932
|
+
function _registerMcpJson(filePath, serverEntry, cwd) {
|
|
8933
|
+
if (!fs.existsSync(filePath)) return;
|
|
8934
|
+
try {
|
|
8935
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
8936
|
+
const settings = JSON.parse(raw);
|
|
8937
|
+
if (!settings.mcpServers) settings.mcpServers = {};
|
|
8938
|
+
if (settings.mcpServers['sigmap']) return;
|
|
8939
|
+
settings.mcpServers['sigmap'] = serverEntry;
|
|
8940
|
+
fs.writeFileSync(filePath, JSON.stringify(settings, null, 2) + '\n');
|
|
8941
|
+
console.warn(`[sigmap] registered MCP server in ${_displayPath(filePath, cwd)}`);
|
|
8942
|
+
} catch (err) {
|
|
8943
|
+
console.warn(`[sigmap] could not update ${_displayPath(filePath, cwd)}: ${err.message}`);
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8946
|
+
|
|
8947
|
+
function _registerCodexYaml(filePath, scriptPath) {
|
|
8948
|
+
if (!fs.existsSync(filePath)) return;
|
|
8949
|
+
try {
|
|
8950
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
8951
|
+
if (raw.includes('sigmap')) return; // already registered
|
|
8952
|
+
const yamlBlock = [
|
|
8953
|
+
'',
|
|
8954
|
+
'mcpServers:',
|
|
8955
|
+
' sigmap:',
|
|
8956
|
+
` command: node`,
|
|
8957
|
+
` args:`,
|
|
8958
|
+
` - ${path.resolve(scriptPath)}`,
|
|
8959
|
+
` - --mcp`,
|
|
8960
|
+
].join('\n');
|
|
8961
|
+
fs.writeFileSync(filePath, raw.trimEnd() + yamlBlock + '\n');
|
|
8962
|
+
console.warn('[sigmap] registered MCP server in ~/.codex/config.yaml');
|
|
8963
|
+
} catch (err) {
|
|
8964
|
+
console.warn(`[sigmap] could not update ~/.codex/config.yaml: ${err.message}`);
|
|
8965
|
+
}
|
|
8966
|
+
}
|
|
8967
|
+
|
|
8865
8968
|
function registerMcp(cwd, scriptPath) {
|
|
8866
8969
|
const serverEntry = {
|
|
8867
8970
|
command: 'node',
|
|
8868
8971
|
args: [path.resolve(scriptPath), '--mcp'],
|
|
8869
8972
|
};
|
|
8870
8973
|
|
|
8871
|
-
// mcpServers
|
|
8872
|
-
//
|
|
8873
|
-
const
|
|
8974
|
+
// JSON mcpServers targets: Claude, Cursor, Windsurf project, Windsurf global,
|
|
8975
|
+
// VS Code (GitHub Copilot 1.99+), OpenCode project, OpenCode global, Gemini CLI
|
|
8976
|
+
const jsonTargets = [
|
|
8874
8977
|
path.join(cwd, '.claude', 'settings.json'),
|
|
8875
8978
|
path.join(cwd, '.cursor', 'mcp.json'),
|
|
8876
8979
|
path.join(cwd, '.windsurf', 'mcp.json'),
|
|
8877
8980
|
path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json'),
|
|
8981
|
+
path.join(cwd, '.vscode', 'mcp.json'),
|
|
8982
|
+
path.join(cwd, 'opencode.json'),
|
|
8983
|
+
path.join(os.homedir(), '.config', 'opencode', 'config.json'),
|
|
8984
|
+
path.join(os.homedir(), '.gemini', 'settings.json'),
|
|
8878
8985
|
];
|
|
8879
8986
|
|
|
8880
|
-
for (const
|
|
8881
|
-
|
|
8882
|
-
try {
|
|
8883
|
-
const raw = fs.readFileSync(settingsPath, 'utf8');
|
|
8884
|
-
const settings = JSON.parse(raw);
|
|
8885
|
-
if (!settings.mcpServers) settings.mcpServers = {};
|
|
8886
|
-
if (settings.mcpServers['sigmap']) continue; // already registered
|
|
8887
|
-
settings.mcpServers['sigmap'] = serverEntry;
|
|
8888
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
8889
|
-
console.warn(`[sigmap] registered MCP server in ${settingsPath.startsWith(os.homedir()) ? '~' + settingsPath.slice(os.homedir().length) : path.relative(cwd, settingsPath)}`);
|
|
8890
|
-
} catch (err) {
|
|
8891
|
-
console.warn(`[sigmap] could not update ${path.relative(cwd, settingsPath)}: ${err.message}`);
|
|
8892
|
-
}
|
|
8987
|
+
for (const target of jsonTargets) {
|
|
8988
|
+
_registerMcpJson(target, serverEntry, cwd);
|
|
8893
8989
|
}
|
|
8894
8990
|
|
|
8895
8991
|
// Zed uses context_servers (different shape from mcpServers)
|
|
@@ -8911,12 +9007,24 @@ function registerMcp(cwd, scriptPath) {
|
|
|
8911
9007
|
}
|
|
8912
9008
|
}
|
|
8913
9009
|
|
|
8914
|
-
//
|
|
9010
|
+
// Codex CLI uses YAML (~/.codex/config.yaml)
|
|
9011
|
+
_registerCodexYaml(path.join(os.homedir(), '.codex', 'config.yaml'), scriptPath);
|
|
9012
|
+
|
|
9013
|
+
// Print manual snippets for all targets
|
|
8915
9014
|
console.warn('[sigmap] MCP / context server config snippets:');
|
|
8916
|
-
console.warn(' Claude / Cursor / Windsurf
|
|
9015
|
+
console.warn(' Claude / Cursor / Windsurf / VS Code / OpenCode / Gemini CLI:');
|
|
8917
9016
|
console.warn(JSON.stringify({ mcpServers: { sigmap: serverEntry } }, null, 2));
|
|
8918
9017
|
console.warn(' Zed (~/.config/zed/settings.json):');
|
|
8919
9018
|
console.warn(JSON.stringify({ context_servers: { sigmap: { command: { path: 'node', args: [path.resolve(scriptPath), '--mcp'] } } } }, null, 2));
|
|
9019
|
+
console.warn(' Codex CLI (~/.codex/config.yaml):');
|
|
9020
|
+
console.warn([
|
|
9021
|
+
'mcpServers:',
|
|
9022
|
+
' sigmap:',
|
|
9023
|
+
` command: node`,
|
|
9024
|
+
` args:`,
|
|
9025
|
+
` - ${path.resolve(scriptPath)}`,
|
|
9026
|
+
` - --mcp`,
|
|
9027
|
+
].join('\n'));
|
|
8920
9028
|
}
|
|
8921
9029
|
|
|
8922
9030
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -16,6 +16,37 @@ const fs = require('fs');
|
|
|
16
16
|
const name = 'claude';
|
|
17
17
|
|
|
18
18
|
const MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
19
|
+
const ALLOWLIST_MARKER = '<!-- sigmap-bash-allowlist -->';
|
|
20
|
+
|
|
21
|
+
const ALLOWLIST_BLOCK = [
|
|
22
|
+
'## Bash allowlist',
|
|
23
|
+
'',
|
|
24
|
+
ALLOWLIST_MARKER,
|
|
25
|
+
'',
|
|
26
|
+
'The following sigmap commands are pre-approved — Claude Code will not prompt for confirmation:',
|
|
27
|
+
'',
|
|
28
|
+
'```json',
|
|
29
|
+
JSON.stringify({
|
|
30
|
+
permissions: {
|
|
31
|
+
allow: [
|
|
32
|
+
'Bash(sigmap ask*)',
|
|
33
|
+
'Bash(sigmap validate*)',
|
|
34
|
+
'Bash(sigmap judge*)',
|
|
35
|
+
'Bash(sigmap weights*)',
|
|
36
|
+
'Bash(sigmap history*)',
|
|
37
|
+
'Bash(sigmap --query*)',
|
|
38
|
+
'Bash(sigmap --diff*)',
|
|
39
|
+
'Bash(sigmap --health*)',
|
|
40
|
+
'Bash(sigmap --coverage*)',
|
|
41
|
+
'Bash(node gen-context.js*)',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
}, null, 2),
|
|
45
|
+
'```',
|
|
46
|
+
'',
|
|
47
|
+
'Add the `permissions.allow` array above to `.claude/settings.json` to activate.',
|
|
48
|
+
'',
|
|
49
|
+
].join('\n');
|
|
19
50
|
|
|
20
51
|
/**
|
|
21
52
|
* Format context suited for CLAUDE.md.
|
|
@@ -82,6 +113,17 @@ function write(context, cwd, opts = {}) {
|
|
|
82
113
|
} else {
|
|
83
114
|
newContent = existing + MARKER + formatted;
|
|
84
115
|
}
|
|
116
|
+
|
|
117
|
+
// Inject ## Bash allowlist above the sig marker if not already present
|
|
118
|
+
if (!newContent.includes(ALLOWLIST_MARKER)) {
|
|
119
|
+
const sigMarkerPos = newContent.indexOf('## Auto-generated signatures');
|
|
120
|
+
if (sigMarkerPos !== -1) {
|
|
121
|
+
newContent = newContent.slice(0, sigMarkerPos) + ALLOWLIST_BLOCK + '\n' + newContent.slice(sigMarkerPos);
|
|
122
|
+
} else {
|
|
123
|
+
newContent = ALLOWLIST_BLOCK + '\n' + newContent;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
85
127
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
86
128
|
}
|
|
87
129
|
|
|
@@ -17,6 +17,44 @@ const fs = require('fs');
|
|
|
17
17
|
|
|
18
18
|
const name = 'codex';
|
|
19
19
|
const MARKER = '\n\n## Auto-generated signatures\n<!-- Updated by gen-context.js -->\n';
|
|
20
|
+
const TOOLS_MARKER = '<!-- sigmap-tools -->';
|
|
21
|
+
|
|
22
|
+
const TOOLS_BLOCK = [
|
|
23
|
+
'## Tools',
|
|
24
|
+
'',
|
|
25
|
+
TOOLS_MARKER,
|
|
26
|
+
'',
|
|
27
|
+
'```json',
|
|
28
|
+
JSON.stringify([
|
|
29
|
+
{
|
|
30
|
+
name: 'sigmap_ask',
|
|
31
|
+
description: 'Rank source files by relevance to a natural-language query. Run before exploring the codebase.',
|
|
32
|
+
command: 'sigmap ask "$QUERY"',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'sigmap_validate',
|
|
36
|
+
description: 'Validate SigMap config and measure context coverage. Run after changing config or source dirs.',
|
|
37
|
+
command: 'sigmap validate',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'sigmap_judge',
|
|
41
|
+
description: 'Score an LLM response for groundedness against source context. Use to verify answer quality.',
|
|
42
|
+
command: 'sigmap judge --response "$RESPONSE" --context "$CONTEXT"',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'sigmap_query',
|
|
46
|
+
description: 'Rank all files by relevance using TF-IDF and write a focused mini-context.',
|
|
47
|
+
command: 'sigmap --query "$QUERY" --context',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'sigmap_weights',
|
|
51
|
+
description: 'Show learned file-ranking multipliers accumulated from past sessions.',
|
|
52
|
+
command: 'sigmap weights',
|
|
53
|
+
},
|
|
54
|
+
], null, 2),
|
|
55
|
+
'```',
|
|
56
|
+
'',
|
|
57
|
+
].join('\n');
|
|
20
58
|
|
|
21
59
|
/**
|
|
22
60
|
* Format context for AGENTS.md — clean markdown, no LLM preamble.
|
|
@@ -80,6 +118,16 @@ function write(context, cwd, opts = {}) {
|
|
|
80
118
|
: existing + MARKER + formatted;
|
|
81
119
|
}
|
|
82
120
|
|
|
121
|
+
// Inject ## Tools block above the sig marker if not already present
|
|
122
|
+
if (!newContent.includes(TOOLS_MARKER)) {
|
|
123
|
+
const sigMarkerPos = newContent.indexOf('## Auto-generated signatures');
|
|
124
|
+
if (sigMarkerPos !== -1) {
|
|
125
|
+
newContent = newContent.slice(0, sigMarkerPos) + TOOLS_BLOCK + '\n' + newContent.slice(sigMarkerPos);
|
|
126
|
+
} else {
|
|
127
|
+
newContent = TOOLS_BLOCK + '\n' + newContent;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
83
131
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
84
132
|
}
|
|
85
133
|
|
package/src/mcp/server.js
CHANGED