composto-ai 0.8.2 → 0.8.4

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/index.js CHANGED
@@ -1194,6 +1194,13 @@ async function astWalkIR(code, filePath) {
1194
1194
  return merged.join("\n");
1195
1195
  }
1196
1196
 
1197
+ // src/benchmark/tokenizer.ts
1198
+ function estimateTokens(text) {
1199
+ if (!text) return 0;
1200
+ const tokens = text.split(/[\s]+|(?<=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])|(?=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])/).filter(Boolean);
1201
+ return tokens.length;
1202
+ }
1203
+
1197
1204
  // src/ir/layers.ts
1198
1205
  function generateL0(code, filePath) {
1199
1206
  const structure = extractStructure(code);
@@ -1211,7 +1218,8 @@ ${declarations.join("\n")}`;
1211
1218
  }
1212
1219
  async function generateL1(code, filePath, health) {
1213
1220
  const ir = await astWalkIR(code, filePath) ?? fingerprintFile(code, 0.75);
1214
- const result = ir.length < code.length ? ir : code;
1221
+ const irIsWin = ir.trim().length > 0 && estimateTokens(ir) < estimateTokens(code);
1222
+ const result = irIsWin ? ir : code;
1215
1223
  if (health) {
1216
1224
  return annotateIR(result, health);
1217
1225
  }
@@ -1497,13 +1505,6 @@ var CLIAdapter = class {
1497
1505
  }
1498
1506
  };
1499
1507
 
1500
- // src/benchmark/tokenizer.ts
1501
- function estimateTokens(text) {
1502
- if (!text) return 0;
1503
- const tokens = text.split(/[\s]+|(?<=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])|(?=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])/).filter(Boolean);
1504
- return tokens.length;
1505
- }
1506
-
1507
1508
  // src/benchmark/runner.ts
1508
1509
  async function benchmarkFile(code, filePath) {
1509
1510
  const rawTokens = estimateTokens(code);
@@ -1526,6 +1527,17 @@ function summarize(results) {
1526
1527
  return { fileCount: results.length, totalRaw, totalIRL0, totalIRL1, totalSavedPercent, astCount, fpCount };
1527
1528
  }
1528
1529
 
1530
+ // src/version.ts
1531
+ import { createRequire } from "module";
1532
+ var VERSION = (() => {
1533
+ try {
1534
+ const req = createRequire(import.meta.url);
1535
+ return req("../package.json").version;
1536
+ } catch {
1537
+ return "0.0.0";
1538
+ }
1539
+ })();
1540
+
1529
1541
  // src/benchmark/quality.ts
1530
1542
  var BENCHMARK_PROMPTS = [
1531
1543
  {
@@ -2692,7 +2704,8 @@ function statFileSize(path) {
2692
2704
  function runScan(projectPath) {
2693
2705
  const adapter = new CLIAdapter();
2694
2706
  const config = loadConfig(projectPath);
2695
- console.log("composto v0.4.2 \u2014 scanning...\n");
2707
+ console.log(`composto v${VERSION} \u2014 scanning...
2708
+ `);
2696
2709
  const files = collectFiles(projectPath, [".ts", ".tsx", ".js", ".jsx"]);
2697
2710
  console.log(` Found ${files.length} files
2698
2711
  `);
@@ -2719,7 +2732,8 @@ function runScan(projectPath) {
2719
2732
  function runTrends(projectPath) {
2720
2733
  const adapter = new CLIAdapter();
2721
2734
  const config = loadConfig(projectPath);
2722
- console.log("composto v0.4.2 \u2014 trend analysis...\n");
2735
+ console.log(`composto v${VERSION} \u2014 trend analysis...
2736
+ `);
2723
2737
  const entries = getGitLog(projectPath, 100);
2724
2738
  if (entries.length === 0) {
2725
2739
  console.log(" No git history found.\n");
@@ -2761,7 +2775,8 @@ async function runIR(projectPath, filePath, layer) {
2761
2775
  }
2762
2776
  var ALL_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".py", ".go", ".rs"];
2763
2777
  async function runBenchmark(projectPath) {
2764
- console.log("composto v0.4.2 \u2014 benchmark\n");
2778
+ console.log(`composto v${VERSION} \u2014 benchmark
2779
+ `);
2765
2780
  const files = collectFiles(projectPath, ALL_EXTENSIONS);
2766
2781
  console.log(` ${files.length} files
2767
2782
  `);
@@ -2827,7 +2842,8 @@ async function runBenchmarkQuality(projectPath, filePath) {
2827
2842
  }
2828
2843
  const code = readFileSync4(filePath, "utf-8");
2829
2844
  const relPath = relative2(projectPath, filePath);
2830
- console.log("composto v0.4.2 \u2014 quality benchmark\n");
2845
+ console.log(`composto v${VERSION} \u2014 quality benchmark
2846
+ `);
2831
2847
  console.log(` File: ${relPath}
2832
2848
  `);
2833
2849
  console.log(" Sending to Claude Haiku...\n");
@@ -2857,8 +2873,8 @@ ${result.ir.response}
2857
2873
  }
2858
2874
  }
2859
2875
  async function runContext(projectPath, budget, target) {
2860
- const header = target ? `composto v0.4.2 \u2014 context (target: ${target}, budget: ${budget} tokens)
2861
- ` : `composto v0.4.2 \u2014 context (budget: ${budget} tokens)
2876
+ const header = target ? `composto v${VERSION} \u2014 context (target: ${target}, budget: ${budget} tokens)
2877
+ ` : `composto v${VERSION} \u2014 context (budget: ${budget} tokens)
2862
2878
  `;
2863
2879
  console.log(header);
2864
2880
  const files = collectFiles(projectPath, ALL_EXTENSIONS);
@@ -3679,11 +3695,11 @@ function renderSummary(s) {
3679
3695
  }
3680
3696
 
3681
3697
  // src/index.ts
3682
- import { createRequire } from "module";
3698
+ import { createRequire as createRequire2 } from "module";
3683
3699
  import { join as join13, resolve as resolve2 } from "path";
3684
3700
  var PKG_VERSION = (() => {
3685
3701
  try {
3686
- const req = createRequire(import.meta.url);
3702
+ const req = createRequire2(import.meta.url);
3687
3703
  return req("../package.json").version;
3688
3704
  } catch {
3689
3705
  return "0.0.0";
@@ -1002,6 +1002,13 @@ async function astWalkIR(code, filePath) {
1002
1002
  return merged.join("\n");
1003
1003
  }
1004
1004
 
1005
+ // src/benchmark/tokenizer.ts
1006
+ function estimateTokens(text) {
1007
+ if (!text) return 0;
1008
+ const tokens = text.split(/[\s]+|(?<=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])|(?=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])/).filter(Boolean);
1009
+ return tokens.length;
1010
+ }
1011
+
1005
1012
  // src/ir/layers.ts
1006
1013
  function generateL0(code, filePath) {
1007
1014
  const structure = extractStructure(code);
@@ -1019,7 +1026,8 @@ ${declarations.join("\n")}`;
1019
1026
  }
1020
1027
  async function generateL1(code, filePath, health) {
1021
1028
  const ir = await astWalkIR(code, filePath) ?? fingerprintFile(code, 0.75);
1022
- const result = ir.length < code.length ? ir : code;
1029
+ const irIsWin = ir.trim().length > 0 && estimateTokens(ir) < estimateTokens(code);
1030
+ const result = irIsWin ? ir : code;
1023
1031
  if (health) {
1024
1032
  return annotateIR(result, health);
1025
1033
  }
@@ -1262,13 +1270,6 @@ function loadConfig(projectPath) {
1262
1270
  return parseConfig(content);
1263
1271
  }
1264
1272
 
1265
- // src/benchmark/tokenizer.ts
1266
- function estimateTokens(text) {
1267
- if (!text) return 0;
1268
- const tokens = text.split(/[\s]+|(?<=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])|(?=[{}()[\];,.:=<>!&|?+\-*/^~@#$%\\])/).filter(Boolean);
1269
- return tokens.length;
1270
- }
1271
-
1272
1273
  // src/benchmark/runner.ts
1273
1274
  async function benchmarkFile(code, filePath) {
1274
1275
  const rawTokens = estimateTokens(code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "composto-ai",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Proactive AI team companion — less tokens, more insight",
5
5
  "type": "module",
6
6
  "bin": {