tokenbuild 0.1.0 → 0.1.1
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/bin/tokenbuild.mjs +1 -1
- package/package.json +1 -1
- package/src/mcp.mjs +2 -2
- package/src/util.mjs +2 -0
package/bin/tokenbuild.mjs
CHANGED
package/package.json
CHANGED
package/src/mcp.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Minimal MCP stdio server (JSON-RPC 2.0, newline-delimited). Tools answer from the local index: zero model tokens to compute.
|
|
2
2
|
import readline from 'node:readline';
|
|
3
3
|
import { loadIndex, buildIndex, repoMap, find, pack } from './repo.mjs';
|
|
4
|
-
import { appendLedger } from './util.mjs';
|
|
4
|
+
import { appendLedger, VERSION } from './util.mjs';
|
|
5
5
|
import { config, detect, digest } from './local.mjs';
|
|
6
6
|
import { licensed, explain, refreshIfDue } from './license.mjs';
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ const DIGEST = { name: 'tb_digest', description: 'Ask a local model (on this mac
|
|
|
20
20
|
export async function handle(msg, root, state) {
|
|
21
21
|
const { id, method, params = {} } = msg;
|
|
22
22
|
const ok = (result) => ({ jsonrpc: '2.0', id, result });
|
|
23
|
-
if (method === 'initialize') return ok({ protocolVersion: params.protocolVersion || '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'tokenbuild', version:
|
|
23
|
+
if (method === 'initialize') return ok({ protocolVersion: params.protocolVersion || '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'tokenbuild', version: VERSION } });
|
|
24
24
|
if (method === 'tools/list') return ok({ tools: state.boost ? [...TOOLS, DIGEST] : TOOLS });
|
|
25
25
|
if (method === 'tools/call') {
|
|
26
26
|
if (!state.idx || Date.now() - state.at > 30_000) { state.idx = state.idx ? buildIndex(root).idx : loadIndex(root); state.at = Date.now(); }
|
package/src/util.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import crypto from 'node:crypto';
|
|
4
4
|
|
|
5
|
+
export const VERSION = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
6
|
+
|
|
5
7
|
// ~4 chars per token for code and English; good enough for budgets.
|
|
6
8
|
export const tokens = (s) => Math.ceil((s ? String(s).length : 0) / 4);
|
|
7
9
|
|