make-laten 1.2.1 → 1.2.3
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/dist/cli/index.js +499 -26
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +499 -26
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +143 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -3
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/server.js +148 -8
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/server.mjs +150 -10
- package/dist/mcp/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -498,14 +498,55 @@ var StrategyRouter = class {
|
|
|
498
498
|
};
|
|
499
499
|
|
|
500
500
|
// src/learn/pattern-miner.ts
|
|
501
|
+
var import_fs = __toESM(require("fs"));
|
|
502
|
+
var import_path = __toESM(require("path"));
|
|
503
|
+
var DATA_FILE = import_path.default.join(process.env.HOME || "~", ".make-laten", "patterns.json");
|
|
501
504
|
var PatternMiner = class {
|
|
502
505
|
operations = [];
|
|
503
506
|
patterns = /* @__PURE__ */ new Map();
|
|
507
|
+
persistencePath;
|
|
508
|
+
lastPersist = 0;
|
|
509
|
+
constructor(options) {
|
|
510
|
+
this.persistencePath = options?.persistencePath || DATA_FILE;
|
|
511
|
+
this.loadFromDisk();
|
|
512
|
+
}
|
|
513
|
+
loadFromDisk() {
|
|
514
|
+
try {
|
|
515
|
+
if (import_fs.default.existsSync(this.persistencePath)) {
|
|
516
|
+
const data = JSON.parse(import_fs.default.readFileSync(this.persistencePath, "utf-8"));
|
|
517
|
+
if (Array.isArray(data.patterns)) {
|
|
518
|
+
for (const p of data.patterns) {
|
|
519
|
+
this.patterns.set(p.type, p);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (Array.isArray(data.operations)) {
|
|
523
|
+
this.operations = data.operations.slice(-100);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
} catch {
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
persistToDisk() {
|
|
530
|
+
const now = Date.now();
|
|
531
|
+
if (now - this.lastPersist < 5e3) return;
|
|
532
|
+
this.lastPersist = now;
|
|
533
|
+
try {
|
|
534
|
+
const dir = import_path.default.dirname(this.persistencePath);
|
|
535
|
+
if (!import_fs.default.existsSync(dir)) import_fs.default.mkdirSync(dir, { recursive: true });
|
|
536
|
+
import_fs.default.writeFileSync(this.persistencePath, JSON.stringify({
|
|
537
|
+
patterns: Array.from(this.patterns.values()),
|
|
538
|
+
operations: this.operations.slice(-100)
|
|
539
|
+
}, null, 2));
|
|
540
|
+
} catch {
|
|
541
|
+
}
|
|
542
|
+
}
|
|
504
543
|
record(operation) {
|
|
505
544
|
this.operations.push(operation);
|
|
545
|
+
if (this.operations.length > 100) this.operations.shift();
|
|
506
546
|
if (operation.success) {
|
|
507
547
|
this.updatePatterns(operation);
|
|
508
548
|
}
|
|
549
|
+
this.persistToDisk();
|
|
509
550
|
}
|
|
510
551
|
getPatterns() {
|
|
511
552
|
return Array.from(this.patterns.values());
|
|
@@ -532,8 +573,43 @@ var PatternMiner = class {
|
|
|
532
573
|
};
|
|
533
574
|
|
|
534
575
|
// src/learn/failure-learner.ts
|
|
576
|
+
var import_fs2 = __toESM(require("fs"));
|
|
577
|
+
var import_path2 = __toESM(require("path"));
|
|
578
|
+
var DATA_FILE2 = import_path2.default.join(process.env.HOME || "~", ".make-laten", "failures.json");
|
|
535
579
|
var FailureLearner = class {
|
|
536
580
|
failures = /* @__PURE__ */ new Map();
|
|
581
|
+
persistencePath;
|
|
582
|
+
lastPersist = 0;
|
|
583
|
+
constructor(options) {
|
|
584
|
+
this.persistencePath = options?.persistencePath || DATA_FILE2;
|
|
585
|
+
this.loadFromDisk();
|
|
586
|
+
}
|
|
587
|
+
loadFromDisk() {
|
|
588
|
+
try {
|
|
589
|
+
if (import_fs2.default.existsSync(this.persistencePath)) {
|
|
590
|
+
const data = JSON.parse(import_fs2.default.readFileSync(this.persistencePath, "utf-8"));
|
|
591
|
+
if (Array.isArray(data.failures)) {
|
|
592
|
+
for (const f of data.failures) {
|
|
593
|
+
this.failures.set(`${f.type}:${f.error}`, f);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
} catch {
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
persistToDisk() {
|
|
601
|
+
const now = Date.now();
|
|
602
|
+
if (now - this.lastPersist < 5e3) return;
|
|
603
|
+
this.lastPersist = now;
|
|
604
|
+
try {
|
|
605
|
+
const dir = import_path2.default.dirname(this.persistencePath);
|
|
606
|
+
if (!import_fs2.default.existsSync(dir)) import_fs2.default.mkdirSync(dir, { recursive: true });
|
|
607
|
+
import_fs2.default.writeFileSync(this.persistencePath, JSON.stringify({
|
|
608
|
+
failures: Array.from(this.failures.values())
|
|
609
|
+
}, null, 2));
|
|
610
|
+
} catch {
|
|
611
|
+
}
|
|
612
|
+
}
|
|
537
613
|
record(failure) {
|
|
538
614
|
const key = `${failure.type}:${failure.error}`;
|
|
539
615
|
const existing = this.failures.get(key);
|
|
@@ -547,6 +623,7 @@ var FailureLearner = class {
|
|
|
547
623
|
count: 1
|
|
548
624
|
});
|
|
549
625
|
}
|
|
626
|
+
this.persistToDisk();
|
|
550
627
|
}
|
|
551
628
|
getFailures() {
|
|
552
629
|
return Array.from(this.failures.values());
|
|
@@ -573,32 +650,95 @@ var FailureLearner = class {
|
|
|
573
650
|
};
|
|
574
651
|
|
|
575
652
|
// src/correct/auto-correct.ts
|
|
653
|
+
var import_fs3 = __toESM(require("fs"));
|
|
654
|
+
var import_path3 = __toESM(require("path"));
|
|
655
|
+
var DEFAULT_RULES = [
|
|
656
|
+
// Common typos
|
|
657
|
+
{ name: "typo-teh", description: "Common typo", pattern: "teh", replacement: "the" },
|
|
658
|
+
{ name: "typo-adn", description: "Common typo", pattern: "adn", replacement: "and" },
|
|
659
|
+
{ name: "typo-fo", description: "Common typo", pattern: " fo ", replacement: " of " },
|
|
660
|
+
{ name: "typo-ot", description: "Common typo", pattern: " ot ", replacement: " to " },
|
|
661
|
+
{ name: "typo-isnt", description: "Common typo", pattern: "isnt", replacement: "isn't" },
|
|
662
|
+
{ name: "typo-dont", description: "Common typo", pattern: "dont", replacement: "don't" },
|
|
663
|
+
{ name: "typo-cant", description: "Common typo", pattern: "cant", replacement: "can't" },
|
|
664
|
+
{ name: "typo-wont", description: "Common typo", pattern: "wont", replacement: "won't" },
|
|
665
|
+
{ name: "typo-youre", description: "Common typo", pattern: "youre", replacement: "you're" },
|
|
666
|
+
{ name: "typo-its", description: "Common typo", pattern: "its a", replacement: "it's a" },
|
|
667
|
+
// Code patterns
|
|
668
|
+
{ name: "code-console-log", description: "Remove console.log", pattern: /console\.log\([^)]*\);?\n?/g, replacement: "" },
|
|
669
|
+
{ name: "code-debugger", description: "Remove debugger", pattern: /debugger;?\n?/g, replacement: "" },
|
|
670
|
+
{ name: "code-var-let", description: "var to let", pattern: /\bvar\b/g, replacement: "let" },
|
|
671
|
+
// Markdown
|
|
672
|
+
{ name: "md-double-space", description: "Double space to single", pattern: " ", replacement: " " }
|
|
673
|
+
];
|
|
674
|
+
var DATA_FILE3 = import_path3.default.join(process.env.HOME || "~", ".make-laten", "corrections.json");
|
|
576
675
|
var AutoCorrect = class {
|
|
577
|
-
rules
|
|
676
|
+
rules;
|
|
578
677
|
corrections = [];
|
|
579
678
|
appliedCount = 0;
|
|
679
|
+
persistencePath;
|
|
680
|
+
constructor(options) {
|
|
681
|
+
this.persistencePath = options?.persistencePath || DATA_FILE3;
|
|
682
|
+
this.rules = [...DEFAULT_RULES];
|
|
683
|
+
this.loadPersistedRules();
|
|
684
|
+
}
|
|
685
|
+
loadPersistedRules() {
|
|
686
|
+
try {
|
|
687
|
+
if (import_fs3.default.existsSync(this.persistencePath)) {
|
|
688
|
+
const data = JSON.parse(import_fs3.default.readFileSync(this.persistencePath, "utf-8"));
|
|
689
|
+
if (Array.isArray(data.customRules)) {
|
|
690
|
+
this.rules.push(...data.customRules);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
} catch {
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
persistRules() {
|
|
697
|
+
try {
|
|
698
|
+
const dir = import_path3.default.dirname(this.persistencePath);
|
|
699
|
+
if (!import_fs3.default.existsSync(dir)) import_fs3.default.mkdirSync(dir, { recursive: true });
|
|
700
|
+
const existing = this.loadExistingData();
|
|
701
|
+
existing.customRules = this.rules.filter((r) => !DEFAULT_RULES.includes(r));
|
|
702
|
+
import_fs3.default.writeFileSync(this.persistencePath, JSON.stringify(existing, null, 2));
|
|
703
|
+
} catch {
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
loadExistingData() {
|
|
707
|
+
try {
|
|
708
|
+
if (import_fs3.default.existsSync(this.persistencePath)) {
|
|
709
|
+
return JSON.parse(import_fs3.default.readFileSync(this.persistencePath, "utf-8"));
|
|
710
|
+
}
|
|
711
|
+
} catch {
|
|
712
|
+
}
|
|
713
|
+
return { customRules: [] };
|
|
714
|
+
}
|
|
580
715
|
addRule(rule) {
|
|
581
716
|
this.rules.push(rule);
|
|
717
|
+
this.persistRules();
|
|
582
718
|
}
|
|
583
719
|
getRules() {
|
|
584
720
|
return this.rules;
|
|
585
721
|
}
|
|
586
722
|
correct(input) {
|
|
587
723
|
let output = input;
|
|
724
|
+
let changed = false;
|
|
588
725
|
for (const rule of this.rules) {
|
|
589
726
|
if (typeof rule.pattern === "string") {
|
|
590
727
|
if (output.includes(rule.pattern)) {
|
|
591
728
|
output = output.split(rule.pattern).join(rule.replacement);
|
|
592
|
-
|
|
729
|
+
changed = true;
|
|
593
730
|
}
|
|
594
731
|
} else {
|
|
595
732
|
const matches = output.match(rule.pattern);
|
|
596
733
|
if (matches) {
|
|
597
734
|
output = output.replace(rule.pattern, rule.replacement);
|
|
598
|
-
|
|
735
|
+
changed = true;
|
|
599
736
|
}
|
|
600
737
|
}
|
|
601
738
|
}
|
|
739
|
+
if (changed) {
|
|
740
|
+
this.recordCorrection(input, output, "auto");
|
|
741
|
+
}
|
|
602
742
|
return output;
|
|
603
743
|
}
|
|
604
744
|
getStats() {
|
|
@@ -1092,17 +1232,17 @@ var TOOLS = [
|
|
|
1092
1232
|
// Learn Layer
|
|
1093
1233
|
{
|
|
1094
1234
|
name: "make-laten-patterns",
|
|
1095
|
-
description: "Get learned patterns from usage",
|
|
1235
|
+
description: "Get learned patterns from usage (persisted across sessions)",
|
|
1096
1236
|
inputSchema: { type: "object", properties: {} }
|
|
1097
1237
|
},
|
|
1098
1238
|
{
|
|
1099
1239
|
name: "make-laten-failures",
|
|
1100
|
-
description: "Get failure records and suggestions",
|
|
1240
|
+
description: "Get failure records and suggestions (persisted across sessions)",
|
|
1101
1241
|
inputSchema: { type: "object", properties: {} }
|
|
1102
1242
|
},
|
|
1103
1243
|
{
|
|
1104
1244
|
name: "make-laten-suggestions",
|
|
1105
|
-
description: "Get suggestions based on learned patterns",
|
|
1245
|
+
description: "Get suggestions based on learned patterns and failures",
|
|
1106
1246
|
inputSchema: {
|
|
1107
1247
|
type: "object",
|
|
1108
1248
|
properties: {
|
|
@@ -1113,7 +1253,7 @@ var TOOLS = [
|
|
|
1113
1253
|
// Correct Layer
|
|
1114
1254
|
{
|
|
1115
1255
|
name: "make-laten-correct",
|
|
1116
|
-
description: "Apply auto-corrections to text",
|
|
1256
|
+
description: "Apply auto-corrections to text (11 built-in rules + custom rules)",
|
|
1117
1257
|
inputSchema: {
|
|
1118
1258
|
type: "object",
|
|
1119
1259
|
properties: {
|
|
@@ -1316,7 +1456,7 @@ async function handleLine(line) {
|
|
|
1316
1456
|
sendResponse(request.id, {
|
|
1317
1457
|
protocolVersion: "2024-11-05",
|
|
1318
1458
|
capabilities: { tools: {} },
|
|
1319
|
-
serverInfo: { name: "make-laten", version: "1.
|
|
1459
|
+
serverInfo: { name: "make-laten", version: "1.3.0" }
|
|
1320
1460
|
});
|
|
1321
1461
|
} else if (request.method === "notifications/initialized") {
|
|
1322
1462
|
} else if (request.method === "tools/list") {
|