Skip to content

Commit b7ad020

Browse files
committed
release: v2.4.0 — packages/core + packages/cli refactor
- Add packages/core/index.js: programmatic API (extract, rank, buildSigIndex, scan, score) - Add packages/cli/index.js: thin CLI wrapper / v3 forward-compat shim - Add exports field to package.json so require('sigmap') → packages/core - Bump version to 2.4.0 in package.json, gen-context.js, src/mcp/server.js - Add test/integration/core-api.test.js: 15 new integration tests - Update docs/roadmap.html: v2.4 timeline entry, meta tags, stats (340 tests), footer - Update README.md: programmatic API section + packages/ in project structure - Update CHANGELOG.md: [2.4.0] entry Closes #12
1 parent b15d88f commit b7ad020

15 files changed

Lines changed: 942 additions & 100 deletions

File tree

.github/copilot-instructions.md

Lines changed: 114 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,104 @@
1-
<!-- Generated by SigMap gen-context.js v2.0.0 -->
1+
<!-- Generated by SigMap gen-context.js v2.3.0 -->
22
<!-- DO NOT EDIT below the marker line — run gen-context.js to regenerate -->
33

44
# Code signatures
55

6-
## changes (last 5 commits — 13 minutes ago)
7-
```
8-
src/config/defaults.js +fields +signatures
9-
src/extractors/coverage.js +walkFiles +buildTestIndex +isTested
10-
src/extractors/cpp.js +normalizeType ~extract ~extractBlock ~normalizeParams
11-
src/extractors/csharp.js +normalizeParams +normalizeType ~extractBlock ~extractMembers
12-
src/extractors/dart.js ~extract ~extractBlock ~extractMembers
13-
src/extractors/deps.js +extractPythonDeps +extractTSDeps +buildReverseDepMap
14-
src/extractors/go.js ~extract ~extractBlock ~extractInterfaceMethods
15-
src/extractors/java.js +normalizeParams +normalizeType ~extractBlock ~extractMembers
16-
src/extractors/javascript.js +extractClassMembers +buildReturnHints +normalizeType +formatReturnHint
17-
src/extractors/kotlin.js ~extract ~extractBlock ~extractMembers
18-
src/extractors/php.js +normalizeType ~extract ~extractBlock ~normalizeParams
19-
src/extractors/prdiff.js +diffSignatures +extractName
20-
src/extractors/python.js +collapse +name +extractClassMethods +tryExtractDataclassFields
21-
src/extractors/ruby.js +extractReturnHint ~extract ~normalizeParams
22-
src/extractors/rust.js +extractReturnType ~extract ~extractBlock ~normalizeParams
23-
src/extractors/scala.js +normalizeType ~extract ~extractBlock ~normalizeParams
24-
src/extractors/svelte.js +normalizeType ~extract ~normalizeParams
25-
src/extractors/swift.js +extractArrowType ~extract ~extractBlock ~normalizeParams
26-
src/extractors/todos.js +extractTodos
27-
src/extractors/typescript.js ~extract ~extractBlock ~extractClassMembers ~extractInterfaceMembers
28-
src/extractors/vue.js +normalizeType ~extract ~normalizeParams
29-
```
30-
316
## src
327

338
### src/config/defaults.js
349
```
3510
module.exports = { DEFAULTS }
3611
```
3712

13+
### src/eval/analyzer.js
14+
```
15+
module.exports = { analyzeFiles, formatAnalysisTable, formatAnalysisJSON }
16+
function isDockerfile(name)
17+
function getExtractorName(filePath)
18+
function tokenCount(sigs)
19+
function hasCoverage(filePath, cwd)
20+
function loadExtractor(name, cwd)
21+
function analyzeFiles(files, cwd, opts) → object[]
22+
function formatAnalysisTable(stats, showSlow) → string
23+
function formatAnalysisJSON(stats) → object
24+
```
25+
26+
### src/eval/runner.js
27+
```
28+
module.exports = { run, rank, loadTasks, buildSigIndex, formatTable, formatMetrics, tokenize }
29+
function buildSigIndex(cwd) → Map<string, string[]>
30+
function tokenize(text) → string[]
31+
function scoreFile(sigs, queryTokens) → number
32+
function rank(query, index, topK = 10) → { file: string, score: nu
33+
function estimateTokens(sigs) → number
34+
function loadTasks(tasksFile) → Array<{id:string, query:s
35+
function run(tasksFile, cwd, opts = {}) → { * tasks: Array<{id, que
36+
function formatTable(taskResults) → string
37+
function formatMetrics(metrics) → string
38+
```
39+
40+
### src/eval/scorer.js
41+
```
42+
module.exports = { hitAtK, reciprocalRank, precisionAtK, aggregate, firstRank }
43+
function firstRank(ranked, expected) → number
44+
function normalizePath(p) → string
45+
function hitAtK(ranked, expected, k = 5) → 0|1
46+
function reciprocalRank(ranked, expected) → number
47+
function precisionAtK(ranked, expected, k = 5) → number
48+
function aggregate(results, k = 5) → { * hitAt5: number, // fr
49+
function round(x)
50+
```
51+
52+
### src/mcp/handlers.js
53+
```
54+
module.exports = { readContext, searchSignatures, getMap, createCheckpoint, getRouting, explainFile, listModules, queryContext }
55+
function readContext(args, cwd)
56+
function searchSignatures(args, cwd)
57+
function getMap(args, cwd)
58+
function createCheckpoint(args, cwd)
59+
function getRouting(args, cwd)
60+
function explainFile(args, cwd)
61+
function listModules(args, cwd)
62+
function queryContext(args, cwd)
63+
```
64+
65+
### src/mcp/server.js
66+
```
67+
module.exports = { start }
68+
function respond(id, result)
69+
function respondError(id, code, message)
70+
function dispatch(msg, cwd)
71+
function start(cwd)
72+
```
73+
74+
### src/mcp/tools.js
75+
```
76+
module.exports = { TOOLS }
77+
```
78+
79+
### src/retrieval/ranker.js
80+
```
81+
module.exports = { rank, buildSigIndex, scoreFile, formatRankTable, formatRankJSON, DEFAULT_WEIGHTS }
82+
function scoreFile(filePath, sigs, queryTokens, weights) → number
83+
function rank(query, sigIndex, opts) → { file: string, score: nu
84+
function buildSigIndex(cwd) → Map<string, string[]>
85+
function formatRankTable(results, query) → string
86+
function formatRankJSON(results, query) → object
87+
```
88+
89+
### src/retrieval/tokenizer.js
90+
```
91+
module.exports = { tokenize, STOP_WORDS }
92+
function tokenize(text, opts) → string[]
93+
```
94+
95+
### src/config/loader.js
96+
```
97+
module.exports = { loadConfig }
98+
function loadConfig(cwd) → object
99+
function deepClone(obj)
100+
```
101+
38102
### src/extractors/coverage.js
39103
```
40104
module.exports = { buildTestIndex, isTested }
@@ -63,6 +127,12 @@ function normalizeParams(params)
63127
function normalizeType(type)
64128
```
65129

130+
### src/extractors/css.js
131+
```
132+
module.exports = { extract }
133+
function extract(src) → string[]
134+
```
135+
66136
### src/extractors/dart.js
67137
```
68138
module.exports = { extract }
@@ -80,6 +150,12 @@ function extractTSDeps(src) → string[]
80150
function buildReverseDepMap(forwardMap) → Map<string, string[]>
81151
```
82152

153+
### src/extractors/dockerfile.js
154+
```
155+
module.exports = { extract }
156+
function extract(src) → string[]
157+
```
158+
83159
### src/extractors/go.js
84160
```
85161
module.exports = { extract }
@@ -89,6 +165,12 @@ function extractInterfaceMethods(block)
89165
function normalizeParams(params)
90166
```
91167

168+
### src/extractors/html.js
169+
```
170+
module.exports = { extract }
171+
function extract(src) → string[]
172+
```
173+
92174
### src/extractors/java.js
93175
```
94176
module.exports = { extract }
@@ -178,6 +260,12 @@ function normalizeParams(params)
178260
function normalizeType(type)
179261
```
180262

263+
### src/extractors/shell.js
264+
```
265+
module.exports = { extract }
266+
function extract(src) → string[]
267+
```
268+
181269
### src/extractors/svelte.js
182270
```
183271
module.exports = { extract }
@@ -220,46 +308,6 @@ function normalizeParams(params)
220308
function normalizeType(type)
221309
```
222310

223-
### src/mcp/server.js
224-
```
225-
module.exports = { start }
226-
function respond(id, result)
227-
function respondError(id, code, message)
228-
function dispatch(msg, cwd)
229-
function start(cwd)
230-
```
231-
232-
### src/config/loader.js
233-
```
234-
module.exports = { loadConfig }
235-
function loadConfig(cwd) → object
236-
function deepClone(obj)
237-
```
238-
239-
### src/extractors/css.js
240-
```
241-
module.exports = { extract }
242-
function extract(src) → string[]
243-
```
244-
245-
### src/extractors/dockerfile.js
246-
```
247-
module.exports = { extract }
248-
function extract(src) → string[]
249-
```
250-
251-
### src/extractors/html.js
252-
```
253-
module.exports = { extract }
254-
function extract(src) → string[]
255-
```
256-
257-
### src/extractors/shell.js
258-
```
259-
module.exports = { extract }
260-
function extract(src) → string[]
261-
```
262-
263311
### src/extractors/yaml.js
264312
```
265313
module.exports = { extract }
@@ -301,23 +349,6 @@ function shouldSkipFile(rel)
301349
function analyze(files, cwd)
302350
```
303351

304-
### src/mcp/handlers.js
305-
```
306-
module.exports = { readContext, searchSignatures, getMap, createCheckpoint, getRouting, explainFile, listModules }
307-
function readContext(args, cwd)
308-
function searchSignatures(args, cwd)
309-
function getMap(args, cwd)
310-
function createCheckpoint(args, cwd)
311-
function getRouting(args, cwd)
312-
function explainFile(args, cwd)
313-
function listModules(args, cwd)
314-
```
315-
316-
### src/mcp/tools.js
317-
```
318-
module.exports = { TOOLS }
319-
```
320-
321352
### src/routing/classifier.js
322353
```
323354
module.exports = { classify, classifyAll }

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ Format: [Semantic Versioning](https://semver.org/)
66

77
---
88

9+
## [2.4.0] — 2026-04-05
10+
11+
### Added
12+
- **`packages/core/`** — new `sigmap-core` package exposing a stable programmatic API: `{ extract, rank, buildSigIndex, scan, score }`. Third-party tools can now `require('sigmap')` and use all extraction/retrieval/security/health APIs without spawning a CLI process.
13+
- **`packages/cli/`** — new `sigmap-cli` thin wrapper that exposes `{ CLI_ENTRY, run }` for programmatic CLI invocation and forward-compat with the v3.0 adapter architecture.
14+
- **`packages/core/README.md`** — full programmatic API reference with usage examples for all five exported functions.
15+
- **`exports` field in `package.json`**`require('sigmap')` resolves to `packages/core/index.js`; `require('sigmap/cli')` resolves to `packages/cli/index.js`.
16+
- **`test/integration/core-api.test.js`** — 15 integration tests covering: all exports present, `extract` for JS/TS/Python, file-path extension detection, unknown language returns `[]`, never throws on bad input, `rank` with empty map, `rank` sorted shape, `scan` clean/redact, `score` shape, `buildSigIndex` returns Map, CLI `--version` backward compat, CLI `--help` no crash.
17+
18+
### Changed
19+
- `package.json` `"version"` bumped to `2.4.0`.
20+
- `package.json` `"files"` — added `"packages/"` so `sigmap-core` and `sigmap-cli` are published with the root package.
21+
- `gen-context.js` `VERSION` constant bumped to `2.4.0`.
22+
- `src/mcp/server.js` `SERVER_INFO.version` bumped to `2.4.0`.
23+
24+
### Validation gate
25+
- 21/21 extractor unit tests passed
26+
- 21/21 integration suites passed (0 failures, including new `core-api.test.js`)
27+
- `node gen-context.js --version``2.4.0`
28+
- `node -e "const { extract } = require('.'); console.log(extract('function hello(){}', 'javascript').length > 0 ? 'OK' : 'FAIL')"``OK`
29+
- `require('sigmap')` works from any directory
30+
31+
---
32+
933
## [2.3.0] — 2026-04-07
1034

1135
### Added

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,31 @@ node gen-context.js --format cache
447447

448448
---
449449

450+
## 📦 Programmatic API (v2.4+)
451+
452+
Use SigMap as a library — no CLI subprocess needed:
453+
454+
```js
455+
const { extract, rank, buildSigIndex, scan, score } = require('sigmap');
456+
457+
// Extract signatures from source code
458+
const sigs = extract('function hello() {}', 'javascript');
459+
460+
// Build an index and rank files by query
461+
const index = buildSigIndex('/path/to/project');
462+
const results = rank('authentication middleware', index);
463+
464+
// Scan signatures for secrets before storing
465+
const { safe, redacted } = scan(sigs, 'src/config.ts');
466+
467+
// Get a composite health score for a project
468+
const health = score('/path/to/project');
469+
```
470+
471+
📖 Full API reference: [packages/core/README.md](packages/core/README.md)
472+
473+
---
474+
450475
## 🧪 Testing
451476

452477
```bash
@@ -493,6 +518,11 @@ sigmap/
493518
├── gen-context.js ← PRIMARY ENTRY POINT — single file, zero deps
494519
├── gen-project-map.js ← import graph, class hierarchy, route table
495520
521+
├── packages/
522+
│ ├── core/ ← programmatic API — require('sigmap') (v2.4)
523+
│ │ └── index.js ← extract, rank, buildSigIndex, scan, score
524+
│ └── cli/ ← thin CLI wrapper / v3 compat shim (v2.4)
525+
496526
├── src/
497527
│ ├── extractors/ ← 21 language extractors (one file per language)
498528
│ ├── retrieval/ ← query-aware ranker + tokenizer (v2.3)

0 commit comments

Comments
 (0)