make-laten 1.0.3 → 1.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/README.md CHANGED
@@ -1,49 +1,161 @@
1
1
  # make-laten
2
2
 
3
- Universal efficiency toolkit for AI coding agents — compress, cache, route, and optimize token usage.
3
+ [![npm version](https://img.shields.io/npm/v/make-laten.svg)](https://www.npmjs.com/package/make-laten)
4
+ [![license](https://img.shields.io/npm/l/make-laten.svg)](https://github.com/sukirman1901/make-laten/blob/main/LICENSE)
5
+ [![tests](https://img.shields.io/badge/tests-201%20passing-brightgreen)]()
6
+
7
+ Universal efficiency toolkit for AI coding agents — compress, cache, and optimize token usage across all platforms.
4
8
 
5
9
  ## What it does
6
10
 
7
11
  make-laten reduces token consumption when working with AI coding agents by compressing outputs, caching results, and routing operations intelligently.
8
12
 
9
- **Token savings:** 60-90% reduction across file reads, grep, git diff, and web fetches.
13
+ ```
14
+ User → AI Agent → make-laten intercept → compress (60-90% savings) → return
15
+ ```
16
+
17
+ **Token savings per command:**
18
+
19
+ | Command | Savings | Description |
20
+ |---------|---------|-------------|
21
+ | `read` | **89%** | Compressed file read — exports, classes, functions only |
22
+ | `grep` | **70%** | Grouped by file with line numbers |
23
+ | `git diff` | **60%** | Condensed hunks, only changes shown |
24
+ | `git status` | **65%** | Status summary |
25
+ | `fetch` | **75%** | Web content with semantic extraction |
26
+
27
+ ## Quick Start
28
+
29
+ **One command to set up everything:**
30
+
31
+ ```bash
32
+ npx make-laten init --all
33
+ ```
10
34
 
11
- ## Install
35
+ This auto-detects your installed AI agents and configures MCP for each one.
36
+
37
+ **Or install globally first:**
12
38
 
13
39
  ```bash
14
40
  npm install -g make-laten
41
+ make-laten init --all
15
42
  ```
16
43
 
17
- ## CLI Commands
44
+ ## Setup Options
45
+
46
+ ### Option 1: Init Wizard (Recommended)
18
47
 
19
48
  ```bash
20
- # Compressed file read (89% savings)
21
- make-laten read src/index.ts
49
+ # Auto-configure all detected agents
50
+ npx make-laten init --all
51
+
52
+ # Per-project only (creates .mcp.json)
53
+ npx make-laten init --project
54
+
55
+ # Interactive (choose agents one by one)
56
+ npx make-laten init
57
+ ```
58
+
59
+ ### Option 2: Global Install
60
+
61
+ ```bash
62
+ npm install -g make-laten
63
+
64
+ # Install shell aliases
65
+ make-laten install
66
+
67
+ # Or configure MCP for agents
68
+ make-laten init --all
69
+ ```
70
+
71
+ ### Option 3: Shell Aliases Only
72
+
73
+ ```bash
74
+ # Add to ~/.zshrc or ~/.bashrc
75
+ source $(npm root -g)/make-laten/shell/init.sh
76
+ ```
77
+
78
+ This gives you short aliases:
79
+
80
+ | Alias | Command | Description |
81
+ |-------|---------|-------------|
82
+ | `mread` | `make-laten read` | Compressed file read |
83
+ | `mgrep` | `make-laten grep` | Grouped grep |
84
+ | `mdiff` | `make-laten git diff` | Compressed git diff |
85
+ | `mstatus` | `make-laten git status` | Git status summary |
86
+ | `msearch` | `make-laten search` | Web search |
87
+ | `mfetch` | `make-laten fetch` | Web fetch + compress |
88
+
89
+ ## CLI Commands
22
90
 
23
- # Compressed grep with file grouping
24
- make-laten grep "TODO" src/
91
+ ```bash
92
+ # File operations
93
+ make-laten read src/index.ts # 89% savings
94
+ make-laten grep "TODO" src/ # grouped by file
95
+ make-laten grep "export" . --ignore ts
25
96
 
26
- # Compressed git diff
27
- make-laten git diff
97
+ # Git operations
98
+ make-laten git diff # 60% savings
28
99
  make-laten git diff --staged
29
100
  make-laten git status
30
101
 
31
- # Web search (via DuckDuckGo)
102
+ # Web operations
32
103
  make-laten search "typescript generics"
33
-
34
- # Web fetch + semantic extraction + compression
35
104
  make-laten fetch https://docs.example.com
36
105
 
37
- # Cache management
106
+ # Cache
38
107
  make-laten cache stats
39
108
  make-laten cache clear
40
109
 
41
- # Install adapters for detected agents
42
- make-laten install
43
- make-laten install --status
44
- make-laten install --uninstall
110
+ # Setup
111
+ make-laten init --all # detect + configure MCP
112
+ make-laten install # install shell aliases
113
+ make-laten install --status # show what's installed
114
+ ```
115
+
116
+ ## MCP Server
117
+
118
+ make-laten includes an MCP server that auto-compresses tool outputs for any MCP-compatible agent.
119
+
120
+ **Tools provided:**
121
+
122
+ | Tool | Description |
123
+ |------|-------------|
124
+ | `make-laten-read` | Compressed file read |
125
+ | `make-laten-grep` | Grouped grep results |
126
+ | `make-laten-git-diff` | Compressed git diff |
127
+ | `make-laten-git-status` | Git status summary |
128
+ | `make-laten-cache-stats` | Cache performance |
129
+
130
+ **Manual MCP config (if needed):**
131
+
132
+ ```json
133
+ {
134
+ "mcpServers": {
135
+ "make-laten": {
136
+ "command": "npx",
137
+ "args": ["-y", "make-laten-mcp", "server"]
138
+ }
139
+ }
140
+ }
45
141
  ```
46
142
 
143
+ ## Supported Agents
144
+
145
+ make-laten works with **9+ AI coding agents**:
146
+
147
+ | Agent | Integration | Setup |
148
+ |-------|-------------|-------|
149
+ | **Claude Code** | MCP + Hooks | `npx make-laten init --all` |
150
+ | **Cursor** | MCP + Rules | `npx make-laten init --all` |
151
+ | **Codex** | MCP + AGENTS.md | `npx make-laten init --all` |
152
+ | **OpenCode** | MCP + Skill | `npx make-laten init --all` |
153
+ | **Gemini CLI** | MCP | `npx make-laten init --all` |
154
+ | **Windsurf** | MCP | `npx make-laten init --all` |
155
+ | **Cline** | MCP | `npx make-laten init --all` |
156
+ | **GitHub Copilot** | MCP | `npx make-laten init --all` |
157
+ | **Any MCP client** | MCP | Add server config manually |
158
+
47
159
  ## Programmatic Usage
48
160
 
49
161
  ```typescript
@@ -51,10 +163,10 @@ import {
51
163
  FileReadCompressor,
52
164
  GrepCompressor,
53
165
  GitDiffCompressor,
54
- SemanticCache,
55
166
  WebRouter,
56
- getAdapter,
57
- createInstaller
167
+ RateLimiter,
168
+ Logger,
169
+ Pipeline
58
170
  } from 'make-laten'
59
171
 
60
172
  // Compress file reads
@@ -64,20 +176,59 @@ const result = await compressor.compress({
64
176
  filePath: 'src/main.ts',
65
177
  language: 'typescript'
66
178
  })
179
+ // result.content → compressed output (89% smaller)
180
+ // result.metadata.savings → 0.89
67
181
 
68
- // Semantic web search
182
+ // Semantic web search + fetch
69
183
  const web = new WebRouter()
70
184
  const results = await web.search('how to use async await')
71
185
  const page = await web.fetch('https://example.com/docs')
186
+ // page.content → compressed (75% smaller)
187
+ // page.semantic → sections, code examples, key points
72
188
 
73
- // Cache with cosine similarity
74
- const cache = new SemanticCache()
75
- cache.set('key1', { content: 'docs', embedding: [0.1, 0.2], metadata: {} })
76
- const similar = cache.search([0.1, 0.2], 0.8)
189
+ // Middleware pipeline
190
+ const pipeline = new Pipeline()
191
+ pipeline.use(async (ctx, next) => {
192
+ ctx.metadata.enhanced = true
193
+ return next(ctx)
194
+ })
195
+
196
+ // Rate limiting
197
+ const limiter = new RateLimiter({ maxRequests: 100, windowMs: 60000 })
198
+ if (limiter.allow('user1')) { /* proceed */ }
199
+
200
+ // Structured logging
201
+ const logger = new Logger({ level: 'info', handler: (entry) => console.log(entry) })
202
+ logger.info('Processing', { file: 'src/main.ts' })
203
+ ```
204
+
205
+ ## Architecture
77
206
 
78
- // Agent adapters
79
- const installer = createInstaller()
80
- await installer.install()
207
+ ```
208
+ ┌──────────────────────────────────────────────────────────┐
209
+ │ User / AI Agent │
210
+ │ │
211
+ │ "read src/index.ts" "grep TODO" "git diff" │
212
+ └─────────────────┬────────────────────┬──────────────────┘
213
+ │ │
214
+ ┌─────────────────▼────────────────────▼──────────────────┐
215
+ │ make-laten MCP Server │
216
+ │ │
217
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
218
+ │ │ Compress │ │ Cache │ │ Web │ │
219
+ │ │ Layer │ │ L1/L2/L3│ │ Router │ │
220
+ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
221
+ │ │ │ │ │
222
+ │ ┌────▼──────────────▼──────────────▼─────┐ │
223
+ │ │ Knowledge Graph │ │
224
+ │ │ (patterns, failures, learning) │ │
225
+ │ └────────────────────────────────────────┘ │
226
+ └─────────────────────────────────────────────────────────┘
227
+
228
+ ┌─────────────────▼───────────────────────────────────────┐
229
+ │ Shell Aliases (terminal) │
230
+ │ mread | mgrep | mdiff | mstatus | msearch | mfetch │
231
+ └─────────────────────────────────────────────────────────┘
81
232
  ```
82
233
 
83
234
  ## Modules
@@ -89,44 +240,40 @@ await installer.install()
89
240
  | `graph` | Knowledge graph for operation patterns |
90
241
  | `route` | Smart routing between compression strategies |
91
242
  | `tool` | Tool router with pattern matching |
92
- | `adapter` | Agent adapters (Claude Code, Codex, Gemini, Cursor, etc.) |
243
+ | `adapter` | Agent adapters (9+ agents) |
93
244
  | `learn` | Pattern mining and failure learning |
94
245
  | `correct` | Auto-correction engine |
95
246
  | `web` | Web search, fetch, semantic extraction |
96
- | `middleware` | Middleware pipeline |
247
+ | `middleware` | Middleware pipeline with chain execution |
97
248
  | `plugin` | Plugin system with lifecycle |
98
249
  | `security` | Rate limiter |
99
250
  | `logging` | Structured logger |
100
251
  | `error` | Error handler with suggestions |
101
252
  | `metrics` | Counters, gauges, histograms |
102
253
  | `session` | Session manager with timeout |
103
-
104
- ## Supported Agents
105
-
106
- make-laten works with 7+ AI coding agents:
107
-
108
- - **Claude Code** — hook-based interception
109
- - **Codex** — hook-based interception
110
- - **Gemini CLI** — hook-based interception
111
- - **Cursor** — rules injection
112
- - **Windsurf** — rules injection
113
- - **Cline** — rules injection
114
- - **GitHub Copilot** — rules injection
115
-
116
- ```bash
117
- # Auto-detect and configure
118
- make-laten install
119
- ```
254
+ | `mcp` | MCP server for AI agent integration |
120
255
 
121
256
  ## Development
122
257
 
123
258
  ```bash
259
+ git clone https://github.com/sukirman1901/make-laten.git
260
+ cd make-laten
124
261
  npm install
125
- npm test # Run 201 tests
126
- npm run build # Build CJS + ESM
262
+ npm test # 201 tests passing
263
+ npm run build # Build CJS + ESM + MCP
127
264
  npm run typecheck # Type check
128
265
  ```
129
266
 
267
+ ## Contributing
268
+
269
+ 1. Fork the repo
270
+ 2. Create a feature branch (`git checkout -b feat/amazing`)
271
+ 3. Write tests first (`tests/`)
272
+ 4. Implement feature (`src/`)
273
+ 5. Run `npm test` — all 201 tests must pass
274
+ 6. Run `npm run typecheck` — must be clean
275
+ 7. Submit PR
276
+
130
277
  ## License
131
278
 
132
- MIT
279
+ MIT © [Sukirman](https://github.com/sukirman1901)
package/dist/cli/index.js CHANGED
@@ -1323,9 +1323,199 @@ Done! Configured for ${installed.length} platform(s).`);
1323
1323
  console.log(" mfetch <url> web fetch + compress");
1324
1324
  }
1325
1325
 
1326
+ // src/cli/commands/init.ts
1327
+ var import_child_process4 = require("child_process");
1328
+ var import_util4 = require("util");
1329
+ var import_promises3 = __toESM(require("fs/promises"));
1330
+ var import_path2 = __toESM(require("path"));
1331
+ var import_readline = __toESM(require("readline"));
1332
+ var execAsync4 = (0, import_util4.promisify)(import_child_process4.exec);
1333
+ function getHome2() {
1334
+ return process.env.HOME || process.env.USERPROFILE || "";
1335
+ }
1336
+ async function commandExists2(cmd) {
1337
+ try {
1338
+ await execAsync4(`which ${cmd}`, { timeout: 3e3 });
1339
+ return true;
1340
+ } catch {
1341
+ return false;
1342
+ }
1343
+ }
1344
+ async function directoryExists(dirPath) {
1345
+ try {
1346
+ await import_promises3.default.access(dirPath);
1347
+ return true;
1348
+ } catch {
1349
+ return false;
1350
+ }
1351
+ }
1352
+ async function readJSON(filePath) {
1353
+ try {
1354
+ const raw = await import_promises3.default.readFile(filePath, "utf-8");
1355
+ return JSON.parse(raw);
1356
+ } catch {
1357
+ return {};
1358
+ }
1359
+ }
1360
+ async function writeJSON(filePath, data) {
1361
+ try {
1362
+ const dir = import_path2.default.dirname(filePath);
1363
+ await import_promises3.default.mkdir(dir, { recursive: true });
1364
+ await import_promises3.default.writeFile(filePath, JSON.stringify(data, null, 2));
1365
+ return true;
1366
+ } catch {
1367
+ return false;
1368
+ }
1369
+ }
1370
+ var MCP_CMD = ["npx", "-y", "make-laten-mcp", "server"];
1371
+ async function detectAllAgents() {
1372
+ const home = getHome2();
1373
+ const agents2 = [];
1374
+ agents2.push({
1375
+ name: "Claude Code",
1376
+ detected: await commandExists2("claude") || await directoryExists(import_path2.default.join(home, ".claude")),
1377
+ configPath: import_path2.default.join(home, ".claude", "mcp.json"),
1378
+ version: await commandExists2("claude") ? await execAsync4("claude --version", { timeout: 3e3 }).then((r) => r.stdout.trim().split("\n")[0]).catch(() => "unknown") : void 0,
1379
+ writeConfig: async (p) => {
1380
+ const data = await readJSON(p);
1381
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1382
+ return writeJSON(p, data);
1383
+ }
1384
+ });
1385
+ agents2.push({
1386
+ name: "Cursor",
1387
+ detected: await directoryExists(import_path2.default.join(home, ".cursor")),
1388
+ configPath: import_path2.default.join(home, ".cursor", "mcp.json"),
1389
+ writeConfig: async (p) => {
1390
+ const data = await readJSON(p);
1391
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1392
+ return writeJSON(p, data);
1393
+ }
1394
+ });
1395
+ agents2.push({
1396
+ name: "Codex",
1397
+ detected: await commandExists2("codex") || await directoryExists(import_path2.default.join(home, ".codex")),
1398
+ configPath: import_path2.default.join(home, ".codex", "config.json"),
1399
+ writeConfig: async (p) => {
1400
+ const data = await readJSON(p);
1401
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1402
+ return writeJSON(p, data);
1403
+ }
1404
+ });
1405
+ agents2.push({
1406
+ name: "OpenCode",
1407
+ detected: await directoryExists(import_path2.default.join(home, ".config", "opencode")),
1408
+ configPath: import_path2.default.join(home, ".config", "opencode", "opencode.json"),
1409
+ writeConfig: async (p) => {
1410
+ const data = await readJSON(p);
1411
+ data.mcp = { ...data.mcp || {}, "make-laten": { type: "local", command: MCP_CMD, enabled: true } };
1412
+ delete data.mcpServers;
1413
+ return writeJSON(p, data);
1414
+ }
1415
+ });
1416
+ agents2.push({
1417
+ name: "Windsurf",
1418
+ detected: await directoryExists(import_path2.default.join(home, ".codeium", "windsurf")),
1419
+ configPath: import_path2.default.join(home, ".codeium", "windsurf", "mcp_config.json"),
1420
+ writeConfig: async (p) => {
1421
+ const data = await readJSON(p);
1422
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1423
+ return writeJSON(p, data);
1424
+ }
1425
+ });
1426
+ agents2.push({
1427
+ name: "Cline",
1428
+ detected: await directoryExists(import_path2.default.join(home, ".cline")),
1429
+ configPath: import_path2.default.join(home, ".cline", "mcp_settings.json"),
1430
+ writeConfig: async (p) => {
1431
+ const data = await readJSON(p);
1432
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1433
+ return writeJSON(p, data);
1434
+ }
1435
+ });
1436
+ agents2.push({
1437
+ name: "Gemini CLI",
1438
+ detected: await commandExists2("gemini") || await directoryExists(import_path2.default.join(home, ".gemini")),
1439
+ configPath: import_path2.default.join(home, ".gemini", "settings.json"),
1440
+ writeConfig: async (p) => {
1441
+ const data = await readJSON(p);
1442
+ data.mcpServers = { ...data.mcpServers || {}, "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } };
1443
+ return writeJSON(p, data);
1444
+ }
1445
+ });
1446
+ return agents2;
1447
+ }
1448
+ function askQuestion(rl, question) {
1449
+ return new Promise((resolve) => rl.question(question, resolve));
1450
+ }
1451
+ async function initCommand(options) {
1452
+ console.log("");
1453
+ console.log(" make-laten setup wizard");
1454
+ console.log(" ======================");
1455
+ console.log("");
1456
+ const agents2 = await detectAllAgents();
1457
+ const detected = agents2.filter((a) => a.detected);
1458
+ const notDetected = agents2.filter((a) => !a.detected);
1459
+ console.log(" Detected agents:");
1460
+ for (const agent of detected) {
1461
+ const ver = agent.version ? ` v${agent.version}` : "";
1462
+ console.log(` \u2713 ${agent.name}${ver}`);
1463
+ }
1464
+ if (notDetected.length > 0) {
1465
+ console.log("");
1466
+ console.log(" Not detected (skipped):");
1467
+ for (const agent of notDetected) {
1468
+ console.log(` \u25CB ${agent.name}`);
1469
+ }
1470
+ }
1471
+ console.log("");
1472
+ if (options.all) {
1473
+ for (const agent of detected) {
1474
+ const success = await agent.writeConfig(agent.configPath);
1475
+ if (success) {
1476
+ console.log(` \u2713 ${agent.name} \u2192 MCP configured`);
1477
+ } else {
1478
+ console.log(` \u2717 ${agent.name} \u2192 failed to write config`);
1479
+ }
1480
+ }
1481
+ } else if (options.project) {
1482
+ const cwd = process.cwd();
1483
+ const configPath = import_path2.default.join(cwd, ".mcp.json");
1484
+ const data = { mcpServers: { "make-laten": { command: "npx", args: ["-y", "make-laten-mcp", "server"] } } };
1485
+ await writeJSON(configPath, data);
1486
+ console.log(` \u2713 .mcp.json created in ${cwd}`);
1487
+ } else {
1488
+ const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
1489
+ for (const agent of detected) {
1490
+ const answer = await askQuestion(rl, ` Configure ${agent.name}? (Y/n) `);
1491
+ if (answer.toLowerCase() !== "n") {
1492
+ const success = await agent.writeConfig(agent.configPath);
1493
+ if (success) {
1494
+ console.log(` \u2713 ${agent.name} \u2192 MCP configured`);
1495
+ } else {
1496
+ console.log(` \u2717 ${agent.name} \u2192 failed`);
1497
+ }
1498
+ } else {
1499
+ console.log(` \u25CB ${agent.name} \u2192 skipped`);
1500
+ }
1501
+ }
1502
+ rl.close();
1503
+ }
1504
+ console.log("");
1505
+ console.log(" Setup complete!");
1506
+ console.log("");
1507
+ console.log(" make-laten provides:");
1508
+ console.log(" \u2022 MCP server \u2192 auto-compress for all AI agents");
1509
+ console.log(" \u2022 CLI commands \u2192 mread, mgrep, mdiff, msearch, mfetch");
1510
+ console.log(" \u2022 Shell aliases \u2192 auto-load in new terminals");
1511
+ console.log("");
1512
+ console.log(" Restart your agent to activate MCP tools.");
1513
+ console.log("");
1514
+ }
1515
+
1326
1516
  // src/cli/index.ts
1327
1517
  var program = new import_commander.Command();
1328
- program.name("make-laten").description("Universal efficiency skill for AI coding agents").version("0.1.0");
1518
+ program.name("make-laten").description("Universal efficiency toolkit for AI coding agents").version("1.0.3");
1329
1519
  program.command("read").description("Compressed file read").argument("<file>", "File path").action(readCommand);
1330
1520
  program.command("grep").description("Compressed grep with file grouping").argument("<pattern>", "Search pattern").argument("[directory]", "Directory to search", ".").option("-i, --ignore <ext>", "File extension to ignore").action(grepCommand);
1331
1521
  var gitCmd = program.command("git").description("Git operations");
@@ -1336,6 +1526,7 @@ cacheCmd.command("stats").description("Show cache statistics").action(cacheStats
1336
1526
  cacheCmd.command("clear").description("Clear cache").action(cacheClearCommand);
1337
1527
  program.command("search").description("Search the web").argument("<query>", "Search query").option("-b, --backend <backend>", "Search backend").option("-m, --max <n>", "Max results", "5").action(searchCommand);
1338
1528
  program.command("fetch").description("Fetch and compress web content").argument("<url>", "URL to fetch").option("--no-compress", "Disable compression").option("--no-extract", "Disable semantic extraction").action(fetchCommand);
1339
- program.command("install").description("Install make-laten adapters for detected agents").option("-u, --uninstall", "Remove adapters").option("-s, --status", "Show installation status").action(installCommand);
1529
+ program.command("install").description("Install make-laten across all detected platforms").option("-u, --uninstall", "Remove adapters").option("-s, --status", "Show installation status").action(installCommand);
1530
+ program.command("init").description("Interactive setup wizard \u2014 detect agents & configure MCP").option("-a, --all", "Configure all detected agents (no prompts)").option("-p, --project", "Create .mcp.json in current directory only").action(initCommand);
1340
1531
  program.parse();
1341
1532
  //# sourceMappingURL=index.js.map