@aiready/context-analyzer 0.22.21 → 0.22.23

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.
@@ -0,0 +1,95 @@
1
+ import {
2
+ analyzeContext
3
+ } from "./chunk-4N6ZDLJF.mjs";
4
+ import "./chunk-RQ5BQLT6.mjs";
5
+ import {
6
+ generateSummary
7
+ } from "./chunk-HD4Y3GYL.mjs";
8
+ import "./chunk-JSM7Q5CY.mjs";
9
+
10
+ // src/cli-action.ts
11
+ import {
12
+ loadMergedConfig,
13
+ handleJSONOutput,
14
+ handleCLIError,
15
+ getElapsedTime,
16
+ resolveOutputPath
17
+ } from "@aiready/core";
18
+ import chalk from "chalk";
19
+ import { writeFileSync } from "fs";
20
+ async function contextActionHandler(directory, options) {
21
+ console.log(chalk.blue("\u{1F50D} Analyzing context window costs...\n"));
22
+ const startTime = Date.now();
23
+ try {
24
+ const defaults = {
25
+ maxDepth: 10,
26
+ maxContextBudget: 1e4,
27
+ minCohesion: 0.6,
28
+ maxFragmentation: 0.5,
29
+ focus: "all",
30
+ includeNodeModules: false,
31
+ include: void 0,
32
+ exclude: void 0,
33
+ maxResults: 10
34
+ };
35
+ let finalOptions = await loadMergedConfig(directory, defaults, {
36
+ maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
37
+ maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
38
+ minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : void 0,
39
+ maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : void 0,
40
+ focus: options.focus || void 0,
41
+ includeNodeModules: options.includeNodeModules,
42
+ include: options.include?.split(","),
43
+ exclude: options.exclude?.split(","),
44
+ maxResults: options.maxResults ? parseInt(options.maxResults) : void 0
45
+ });
46
+ if (options.interactive) {
47
+ const { runInteractiveSetup } = await import("./interactive-setup-JGFBFI3M.mjs");
48
+ finalOptions = await runInteractiveSetup(directory, finalOptions);
49
+ }
50
+ const results = await analyzeContext(
51
+ finalOptions
52
+ );
53
+ const summary = generateSummary(results, finalOptions);
54
+ const duration = getElapsedTime(startTime);
55
+ if (options.output === "json") {
56
+ handleJSONOutput(
57
+ {
58
+ summary: {
59
+ ...summary,
60
+ executionTime: duration,
61
+ config: {
62
+ scan: { tools: ["context"] },
63
+ tools: { context: finalOptions }
64
+ },
65
+ toolConfigs: { context: finalOptions }
66
+ },
67
+ context: { results }
68
+ },
69
+ options.outputFile
70
+ );
71
+ } else if (options.output === "html") {
72
+ const { generateHTMLReport } = await import("./html-report-BYGKWC3K.mjs");
73
+ const html = generateHTMLReport(summary, results);
74
+ const outputPath = resolveOutputPath(
75
+ directory,
76
+ options.outputFile,
77
+ "context-report.html"
78
+ );
79
+ writeFileSync(outputPath, html, "utf-8");
80
+ console.log(chalk.green(`
81
+ \u2705 HTML report saved to: ${outputPath}`));
82
+ } else {
83
+ const { displayConsoleReport } = await import("./console-report-CVGRMWEU.mjs");
84
+ displayConsoleReport(summary, results, finalOptions.maxResults);
85
+ console.log(chalk.dim(`
86
+ \u2728 Analysis completed in ${duration}ms
87
+ `));
88
+ }
89
+ } catch (error) {
90
+ handleCLIError(error, "context-analyzer");
91
+ }
92
+ }
93
+ export {
94
+ contextActionHandler
95
+ };
package/dist/cli.js CHANGED
@@ -1357,6 +1357,59 @@ var init_remediation = __esm({
1357
1357
  }
1358
1358
  });
1359
1359
 
1360
+ // src/defaults.ts
1361
+ async function getSmartDefaults(directory, userOptions) {
1362
+ const files = await (0, import_core5.scanFiles)({
1363
+ rootDir: directory,
1364
+ include: userOptions.include,
1365
+ exclude: userOptions.exclude
1366
+ });
1367
+ const estimatedBlocks = files.length;
1368
+ let maxDepth;
1369
+ let maxContextBudget;
1370
+ let minCohesion;
1371
+ let maxFragmentation;
1372
+ if (estimatedBlocks < 100) {
1373
+ maxDepth = 5;
1374
+ maxContextBudget = 8e3;
1375
+ minCohesion = 0.5;
1376
+ maxFragmentation = 0.5;
1377
+ } else if (estimatedBlocks < 500) {
1378
+ maxDepth = 6;
1379
+ maxContextBudget = 15e3;
1380
+ minCohesion = 0.45;
1381
+ maxFragmentation = 0.6;
1382
+ } else if (estimatedBlocks < 2e3) {
1383
+ maxDepth = 8;
1384
+ maxContextBudget = 25e3;
1385
+ minCohesion = 0.4;
1386
+ maxFragmentation = 0.7;
1387
+ } else {
1388
+ maxDepth = 12;
1389
+ maxContextBudget = 4e4;
1390
+ minCohesion = 0.35;
1391
+ maxFragmentation = 0.8;
1392
+ }
1393
+ return {
1394
+ maxDepth,
1395
+ maxContextBudget,
1396
+ minCohesion,
1397
+ maxFragmentation,
1398
+ focus: "all",
1399
+ includeNodeModules: false,
1400
+ rootDir: userOptions.rootDir || directory,
1401
+ include: userOptions.include,
1402
+ exclude: userOptions.exclude
1403
+ };
1404
+ }
1405
+ var import_core5;
1406
+ var init_defaults = __esm({
1407
+ "src/defaults.ts"() {
1408
+ "use strict";
1409
+ import_core5 = require("@aiready/core");
1410
+ }
1411
+ });
1412
+
1360
1413
  // src/analyzers/python-context.ts
1361
1414
  var python_context_exports = {};
1362
1415
  __export(python_context_exports, {
@@ -1364,7 +1417,7 @@ __export(python_context_exports, {
1364
1417
  });
1365
1418
  async function analyzePythonContext(files, rootDir) {
1366
1419
  const results = [];
1367
- const parser = await (0, import_core5.getParser)("dummy.py");
1420
+ const parser = await (0, import_core6.getParser)("dummy.py");
1368
1421
  if (!parser) {
1369
1422
  console.warn("Python parser not available");
1370
1423
  return results;
@@ -1428,7 +1481,7 @@ async function analyzePythonContext(files, rootDir) {
1428
1481
  }
1429
1482
  async function buildPythonDependencyGraph(files, rootDir) {
1430
1483
  const graph = /* @__PURE__ */ new Map();
1431
- const parser = await (0, import_core5.getParser)("dummy.py");
1484
+ const parser = await (0, import_core6.getParser)("dummy.py");
1432
1485
  if (!parser) return graph;
1433
1486
  for (const file of files) {
1434
1487
  try {
@@ -1487,7 +1540,7 @@ function resolvePythonImport(fromFile, importPath, rootDir) {
1487
1540
  }
1488
1541
  function estimateContextBudget(code, imports, dependencyGraph) {
1489
1542
  void dependencyGraph;
1490
- let budget = (0, import_core5.estimateTokens)(code);
1543
+ let budget = (0, import_core6.estimateTokens)(code);
1491
1544
  const avgTokensPerDep = 500;
1492
1545
  budget += imports.length * avgTokensPerDep;
1493
1546
  return budget;
@@ -1512,11 +1565,11 @@ function calculatePythonCohesion(exports2, imports) {
1512
1565
  }
1513
1566
  return Math.min(1, Math.max(0, cohesion));
1514
1567
  }
1515
- var import_core5, import_path2, import_fs;
1568
+ var import_core6, import_path2, import_fs;
1516
1569
  var init_python_context = __esm({
1517
1570
  "src/analyzers/python-context.ts"() {
1518
1571
  "use strict";
1519
- import_core5 = require("@aiready/core");
1572
+ import_core6 = require("@aiready/core");
1520
1573
  import_path2 = require("path");
1521
1574
  import_fs = __toESM(require("fs"));
1522
1575
  init_dependency_graph_utils();
@@ -1597,7 +1650,28 @@ function mapNodeToResult(node, graph, clusters, allCircularDeps, options) {
1597
1650
  potentialSavings
1598
1651
  };
1599
1652
  }
1653
+ async function resolveOptions(options) {
1654
+ const budget = options.maxContextBudget;
1655
+ if (budget === "auto") {
1656
+ const smartDefaults = await getSmartDefaults(
1657
+ options.rootDir || ".",
1658
+ options
1659
+ );
1660
+ return {
1661
+ ...options,
1662
+ maxContextBudget: smartDefaults.maxContextBudget,
1663
+ maxDepth: smartDefaults.maxDepth,
1664
+ minCohesion: smartDefaults.minCohesion,
1665
+ maxFragmentation: smartDefaults.maxFragmentation
1666
+ };
1667
+ }
1668
+ return {
1669
+ ...options,
1670
+ maxContextBudget: typeof budget === "number" ? budget : 25e3
1671
+ };
1672
+ }
1600
1673
  async function analyzeContext(options) {
1674
+ const resolvedOptions = await resolveOptions(options);
1601
1675
  const {
1602
1676
  maxDepth = 5,
1603
1677
  maxContextBudget = 25e3,
@@ -1605,8 +1679,8 @@ async function analyzeContext(options) {
1605
1679
  maxFragmentation = 0.5,
1606
1680
  includeNodeModules = false,
1607
1681
  ...scanOptions
1608
- } = options;
1609
- const files = await (0, import_core6.scanFiles)({
1682
+ } = resolvedOptions;
1683
+ const files = await (0, import_core7.scanFiles)({
1610
1684
  ...scanOptions,
1611
1685
  exclude: includeNodeModules && scanOptions.exclude ? scanOptions.exclude.filter(
1612
1686
  (pattern) => pattern !== "**/node_modules/**"
@@ -1616,7 +1690,7 @@ async function analyzeContext(options) {
1616
1690
  const fileContents = await Promise.all(
1617
1691
  files.map(async (file) => ({
1618
1692
  file,
1619
- content: await (0, import_core6.readFileContent)(file)
1693
+ content: await (0, import_core7.readFileContent)(file)
1620
1694
  }))
1621
1695
  );
1622
1696
  const graph = await buildDependencyGraph(
@@ -1678,17 +1752,18 @@ async function analyzeContext(options) {
1678
1752
  );
1679
1753
  return [...results, ...pythonResults];
1680
1754
  }
1681
- var import_core6;
1755
+ var import_core7;
1682
1756
  var init_orchestrator = __esm({
1683
1757
  "src/orchestrator.ts"() {
1684
1758
  "use strict";
1685
- import_core6 = require("@aiready/core");
1759
+ import_core7 = require("@aiready/core");
1686
1760
  init_metrics();
1687
1761
  init_issue_analyzer();
1688
1762
  init_graph_builder();
1689
1763
  init_cluster_detector();
1690
1764
  init_classifier();
1691
1765
  init_remediation();
1766
+ init_defaults();
1692
1767
  }
1693
1768
  });
1694
1769
 
@@ -1696,7 +1771,7 @@ var init_orchestrator = __esm({
1696
1771
  function generateSummary(results, options = {}) {
1697
1772
  const config = options ? Object.fromEntries(
1698
1773
  Object.entries(options).filter(
1699
- ([key]) => !import_core7.GLOBAL_SCAN_OPTIONS.includes(key) || key === "rootDir"
1774
+ ([key]) => !import_core8.GLOBAL_SCAN_OPTIONS.includes(key) || key === "rootDir"
1700
1775
  )
1701
1776
  ) : {};
1702
1777
  const totalFiles = results.length;
@@ -1807,11 +1882,11 @@ function generateSummary(results, options = {}) {
1807
1882
  config
1808
1883
  };
1809
1884
  }
1810
- var import_core7;
1885
+ var import_core8;
1811
1886
  var init_summary = __esm({
1812
1887
  "src/summary.ts"() {
1813
1888
  "use strict";
1814
- import_core7 = require("@aiready/core");
1889
+ import_core8 = require("@aiready/core");
1815
1890
  init_metrics();
1816
1891
  }
1817
1892
  });
@@ -1921,7 +1996,7 @@ function generateHTMLReport(summary, results) {
1921
1996
  if (totalIssues > 0) {
1922
1997
  sections.push({
1923
1998
  title: "\u26A0\uFE0F Issues Summary",
1924
- content: (0, import_core8.generateIssueSummary)(
1999
+ content: (0, import_core9.generateIssueSummary)(
1925
2000
  summary.criticalIssues,
1926
2001
  summary.majorIssues,
1927
2002
  summary.minorIssues,
@@ -1932,7 +2007,7 @@ function generateHTMLReport(summary, results) {
1932
2007
  if (summary.fragmentedModules.length > 0) {
1933
2008
  sections.push({
1934
2009
  title: "\u{1F9E9} Fragmented Modules",
1935
- content: (0, import_core8.generateTable)({
2010
+ content: (0, import_core9.generateTable)({
1936
2011
  headers: ["Domain", "Files", "Fragmentation", "Token Cost"],
1937
2012
  rows: summary.fragmentedModules.map((m) => [
1938
2013
  m.domain,
@@ -1946,7 +2021,7 @@ function generateHTMLReport(summary, results) {
1946
2021
  if (summary.topExpensiveFiles.length > 0) {
1947
2022
  sections.push({
1948
2023
  title: "\u{1F4B8} Most Expensive Files",
1949
- content: (0, import_core8.generateTable)({
2024
+ content: (0, import_core9.generateTable)({
1950
2025
  headers: ["File", "Context Budget", "Severity"],
1951
2026
  rows: summary.topExpensiveFiles.map((f) => [
1952
2027
  f.file,
@@ -1956,7 +2031,7 @@ function generateHTMLReport(summary, results) {
1956
2031
  })
1957
2032
  });
1958
2033
  }
1959
- return (0, import_core8.generateStandardHtmlReport)(
2034
+ return (0, import_core9.generateStandardHtmlReport)(
1960
2035
  {
1961
2036
  title: "Context Analysis Report",
1962
2037
  packageName: "context-analyzer",
@@ -1968,11 +2043,11 @@ function generateHTMLReport(summary, results) {
1968
2043
  sections
1969
2044
  );
1970
2045
  }
1971
- var import_core8;
2046
+ var import_core9;
1972
2047
  var init_html_report = __esm({
1973
2048
  "src/report/html-report.ts"() {
1974
2049
  "use strict";
1975
- import_core8 = require("@aiready/core");
2050
+ import_core9 = require("@aiready/core");
1976
2051
  }
1977
2052
  });
1978
2053
 
@@ -2078,7 +2153,7 @@ async function contextActionHandler(directory, options) {
2078
2153
  exclude: void 0,
2079
2154
  maxResults: 10
2080
2155
  };
2081
- let finalOptions = await (0, import_core9.loadMergedConfig)(directory, defaults, {
2156
+ let finalOptions = await (0, import_core10.loadMergedConfig)(directory, defaults, {
2082
2157
  maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
2083
2158
  maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
2084
2159
  minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : void 0,
@@ -2097,9 +2172,9 @@ async function contextActionHandler(directory, options) {
2097
2172
  finalOptions
2098
2173
  );
2099
2174
  const summary = generateSummary(results, finalOptions);
2100
- const duration = (0, import_core9.getElapsedTime)(startTime);
2175
+ const duration = (0, import_core10.getElapsedTime)(startTime);
2101
2176
  if (options.output === "json") {
2102
- (0, import_core9.handleJSONOutput)(
2177
+ (0, import_core10.handleJSONOutput)(
2103
2178
  {
2104
2179
  summary: {
2105
2180
  ...summary,
@@ -2117,7 +2192,7 @@ async function contextActionHandler(directory, options) {
2117
2192
  } else if (options.output === "html") {
2118
2193
  const { generateHTMLReport: generateHTMLReport2 } = await Promise.resolve().then(() => (init_html_report(), html_report_exports));
2119
2194
  const html = generateHTMLReport2(summary, results);
2120
- const outputPath = (0, import_core9.resolveOutputPath)(
2195
+ const outputPath = (0, import_core10.resolveOutputPath)(
2121
2196
  directory,
2122
2197
  options.outputFile,
2123
2198
  "context-report.html"
@@ -2133,14 +2208,14 @@ async function contextActionHandler(directory, options) {
2133
2208
  `));
2134
2209
  }
2135
2210
  } catch (error) {
2136
- (0, import_core9.handleCLIError)(error, "context-analyzer");
2211
+ (0, import_core10.handleCLIError)(error, "context-analyzer");
2137
2212
  }
2138
2213
  }
2139
- var import_core9, import_chalk3, import_fs3;
2214
+ var import_core10, import_chalk3, import_fs3;
2140
2215
  var init_cli_action = __esm({
2141
2216
  "src/cli-action.ts"() {
2142
2217
  "use strict";
2143
- import_core9 = require("@aiready/core");
2218
+ import_core10 = require("@aiready/core");
2144
2219
  init_orchestrator();
2145
2220
  init_summary();
2146
2221
  import_chalk3 = __toESM(require("chalk"));
package/dist/cli.mjs CHANGED
@@ -37,7 +37,7 @@ function defineContextCommand(program2) {
37
37
  "--interactive",
38
38
  "Run interactive setup to suggest excludes and focus areas"
39
39
  ).action(async (directory, options) => {
40
- const { contextActionHandler } = await import("./cli-action-7QXG7LHS.mjs");
40
+ const { contextActionHandler } = await import("./cli-action-37GCH3M6.mjs");
41
41
  await contextActionHandler(directory, options);
42
42
  });
43
43
  }
package/dist/index.d.mts CHANGED
@@ -13,8 +13,8 @@ declare const CONTEXT_ANALYZER_PROVIDER: ToolProvider;
13
13
  interface ContextAnalyzerOptions extends ScanOptions {
14
14
  /** Maximum acceptable import depth (default: 5) */
15
15
  maxDepth?: number;
16
- /** Maximum acceptable token budget for a single context (default: 25000) */
17
- maxContextBudget?: number;
16
+ /** Maximum acceptable token budget for a single context, or "auto" for smart scaling */
17
+ maxContextBudget?: number | 'auto';
18
18
  /** Minimum acceptable cohesion score between 0 and 1 (default: 0.6) */
19
19
  minCohesion?: number;
20
20
  /** Maximum acceptable fragmentation score between 0 and 1 (default: 0.5) */
package/dist/index.d.ts CHANGED
@@ -13,8 +13,8 @@ declare const CONTEXT_ANALYZER_PROVIDER: ToolProvider;
13
13
  interface ContextAnalyzerOptions extends ScanOptions {
14
14
  /** Maximum acceptable import depth (default: 5) */
15
15
  maxDepth?: number;
16
- /** Maximum acceptable token budget for a single context (default: 25000) */
17
- maxContextBudget?: number;
16
+ /** Maximum acceptable token budget for a single context, or "auto" for smart scaling */
17
+ maxContextBudget?: number | 'auto';
18
18
  /** Minimum acceptable cohesion score between 0 and 1 (default: 0.6) */
19
19
  minCohesion?: number;
20
20
  /** Maximum acceptable fragmentation score between 0 and 1 (default: 0.5) */
package/dist/index.js CHANGED
@@ -1448,6 +1448,59 @@ var init_remediation = __esm({
1448
1448
  }
1449
1449
  });
1450
1450
 
1451
+ // src/defaults.ts
1452
+ async function getSmartDefaults(directory, userOptions) {
1453
+ const files = await (0, import_core6.scanFiles)({
1454
+ rootDir: directory,
1455
+ include: userOptions.include,
1456
+ exclude: userOptions.exclude
1457
+ });
1458
+ const estimatedBlocks = files.length;
1459
+ let maxDepth;
1460
+ let maxContextBudget;
1461
+ let minCohesion;
1462
+ let maxFragmentation;
1463
+ if (estimatedBlocks < 100) {
1464
+ maxDepth = 5;
1465
+ maxContextBudget = 8e3;
1466
+ minCohesion = 0.5;
1467
+ maxFragmentation = 0.5;
1468
+ } else if (estimatedBlocks < 500) {
1469
+ maxDepth = 6;
1470
+ maxContextBudget = 15e3;
1471
+ minCohesion = 0.45;
1472
+ maxFragmentation = 0.6;
1473
+ } else if (estimatedBlocks < 2e3) {
1474
+ maxDepth = 8;
1475
+ maxContextBudget = 25e3;
1476
+ minCohesion = 0.4;
1477
+ maxFragmentation = 0.7;
1478
+ } else {
1479
+ maxDepth = 12;
1480
+ maxContextBudget = 4e4;
1481
+ minCohesion = 0.35;
1482
+ maxFragmentation = 0.8;
1483
+ }
1484
+ return {
1485
+ maxDepth,
1486
+ maxContextBudget,
1487
+ minCohesion,
1488
+ maxFragmentation,
1489
+ focus: "all",
1490
+ includeNodeModules: false,
1491
+ rootDir: userOptions.rootDir || directory,
1492
+ include: userOptions.include,
1493
+ exclude: userOptions.exclude
1494
+ };
1495
+ }
1496
+ var import_core6;
1497
+ var init_defaults = __esm({
1498
+ "src/defaults.ts"() {
1499
+ "use strict";
1500
+ import_core6 = require("@aiready/core");
1501
+ }
1502
+ });
1503
+
1451
1504
  // src/analyzers/python-context.ts
1452
1505
  var python_context_exports = {};
1453
1506
  __export(python_context_exports, {
@@ -1455,7 +1508,7 @@ __export(python_context_exports, {
1455
1508
  });
1456
1509
  async function analyzePythonContext(files, rootDir) {
1457
1510
  const results = [];
1458
- const parser = await (0, import_core6.getParser)("dummy.py");
1511
+ const parser = await (0, import_core7.getParser)("dummy.py");
1459
1512
  if (!parser) {
1460
1513
  console.warn("Python parser not available");
1461
1514
  return results;
@@ -1519,7 +1572,7 @@ async function analyzePythonContext(files, rootDir) {
1519
1572
  }
1520
1573
  async function buildPythonDependencyGraph(files, rootDir) {
1521
1574
  const graph = /* @__PURE__ */ new Map();
1522
- const parser = await (0, import_core6.getParser)("dummy.py");
1575
+ const parser = await (0, import_core7.getParser)("dummy.py");
1523
1576
  if (!parser) return graph;
1524
1577
  for (const file of files) {
1525
1578
  try {
@@ -1578,7 +1631,7 @@ function resolvePythonImport(fromFile, importPath, rootDir) {
1578
1631
  }
1579
1632
  function estimateContextBudget(code, imports, dependencyGraph) {
1580
1633
  void dependencyGraph;
1581
- let budget = (0, import_core6.estimateTokens)(code);
1634
+ let budget = (0, import_core7.estimateTokens)(code);
1582
1635
  const avgTokensPerDep = 500;
1583
1636
  budget += imports.length * avgTokensPerDep;
1584
1637
  return budget;
@@ -1603,11 +1656,11 @@ function calculatePythonCohesion(exports2, imports) {
1603
1656
  }
1604
1657
  return Math.min(1, Math.max(0, cohesion));
1605
1658
  }
1606
- var import_core6, import_path2, import_fs;
1659
+ var import_core7, import_path2, import_fs;
1607
1660
  var init_python_context = __esm({
1608
1661
  "src/analyzers/python-context.ts"() {
1609
1662
  "use strict";
1610
- import_core6 = require("@aiready/core");
1663
+ import_core7 = require("@aiready/core");
1611
1664
  import_path2 = require("path");
1612
1665
  import_fs = __toESM(require("fs"));
1613
1666
  init_dependency_graph_utils();
@@ -1696,7 +1749,28 @@ function mapNodeToResult(node, graph, clusters, allCircularDeps, options) {
1696
1749
  function calculateCohesion(exports2, filePath, options) {
1697
1750
  return calculateEnhancedCohesion(exports2, filePath, options);
1698
1751
  }
1752
+ async function resolveOptions(options) {
1753
+ const budget = options.maxContextBudget;
1754
+ if (budget === "auto") {
1755
+ const smartDefaults = await getSmartDefaults(
1756
+ options.rootDir || ".",
1757
+ options
1758
+ );
1759
+ return {
1760
+ ...options,
1761
+ maxContextBudget: smartDefaults.maxContextBudget,
1762
+ maxDepth: smartDefaults.maxDepth,
1763
+ minCohesion: smartDefaults.minCohesion,
1764
+ maxFragmentation: smartDefaults.maxFragmentation
1765
+ };
1766
+ }
1767
+ return {
1768
+ ...options,
1769
+ maxContextBudget: typeof budget === "number" ? budget : 25e3
1770
+ };
1771
+ }
1699
1772
  async function analyzeContext(options) {
1773
+ const resolvedOptions = await resolveOptions(options);
1700
1774
  const {
1701
1775
  maxDepth = 5,
1702
1776
  maxContextBudget = 25e3,
@@ -1704,8 +1778,8 @@ async function analyzeContext(options) {
1704
1778
  maxFragmentation = 0.5,
1705
1779
  includeNodeModules = false,
1706
1780
  ...scanOptions
1707
- } = options;
1708
- const files = await (0, import_core7.scanFiles)({
1781
+ } = resolvedOptions;
1782
+ const files = await (0, import_core8.scanFiles)({
1709
1783
  ...scanOptions,
1710
1784
  exclude: includeNodeModules && scanOptions.exclude ? scanOptions.exclude.filter(
1711
1785
  (pattern) => pattern !== "**/node_modules/**"
@@ -1715,7 +1789,7 @@ async function analyzeContext(options) {
1715
1789
  const fileContents = await Promise.all(
1716
1790
  files.map(async (file) => ({
1717
1791
  file,
1718
- content: await (0, import_core7.readFileContent)(file)
1792
+ content: await (0, import_core8.readFileContent)(file)
1719
1793
  }))
1720
1794
  );
1721
1795
  const graph = await buildDependencyGraph(
@@ -1777,17 +1851,18 @@ async function analyzeContext(options) {
1777
1851
  );
1778
1852
  return [...results, ...pythonResults];
1779
1853
  }
1780
- var import_core7;
1854
+ var import_core8;
1781
1855
  var init_orchestrator = __esm({
1782
1856
  "src/orchestrator.ts"() {
1783
1857
  "use strict";
1784
- import_core7 = require("@aiready/core");
1858
+ import_core8 = require("@aiready/core");
1785
1859
  init_metrics();
1786
1860
  init_issue_analyzer();
1787
1861
  init_graph_builder();
1788
1862
  init_cluster_detector();
1789
1863
  init_classifier();
1790
1864
  init_remediation();
1865
+ init_defaults();
1791
1866
  }
1792
1867
  });
1793
1868
 
@@ -1799,7 +1874,7 @@ __export(summary_exports, {
1799
1874
  function generateSummary(results, options = {}) {
1800
1875
  const config = options ? Object.fromEntries(
1801
1876
  Object.entries(options).filter(
1802
- ([key]) => !import_core8.GLOBAL_SCAN_OPTIONS.includes(key) || key === "rootDir"
1877
+ ([key]) => !import_core9.GLOBAL_SCAN_OPTIONS.includes(key) || key === "rootDir"
1803
1878
  )
1804
1879
  ) : {};
1805
1880
  const totalFiles = results.length;
@@ -1910,11 +1985,11 @@ function generateSummary(results, options = {}) {
1910
1985
  config
1911
1986
  };
1912
1987
  }
1913
- var import_core8;
1988
+ var import_core9;
1914
1989
  var init_summary = __esm({
1915
1990
  "src/summary.ts"() {
1916
1991
  "use strict";
1917
- import_core8 = require("@aiready/core");
1992
+ import_core9 = require("@aiready/core");
1918
1993
  init_metrics();
1919
1994
  }
1920
1995
  });
@@ -1946,10 +2021,10 @@ __export(index_exports, {
1946
2021
  mapScoreToRating: () => mapScoreToRating
1947
2022
  });
1948
2023
  module.exports = __toCommonJS(index_exports);
1949
- var import_core10 = require("@aiready/core");
2024
+ var import_core11 = require("@aiready/core");
1950
2025
 
1951
2026
  // src/provider.ts
1952
- var import_core9 = require("@aiready/core");
2027
+ var import_core10 = require("@aiready/core");
1953
2028
 
1954
2029
  // src/scoring.ts
1955
2030
  var import_core = require("@aiready/core");
@@ -2137,7 +2212,7 @@ function mapScoreToRating(score) {
2137
2212
 
2138
2213
  // src/provider.ts
2139
2214
  var CONTEXT_ANALYZER_PROVIDER = {
2140
- id: import_core9.ToolName.ContextAnalyzer,
2215
+ id: import_core10.ToolName.ContextAnalyzer,
2141
2216
  alias: ["context", "fragmentation", "budget"],
2142
2217
  async analyze(options) {
2143
2218
  const { analyzeContext: analyzeContext2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
@@ -2148,7 +2223,7 @@ var CONTEXT_ANALYZER_PROVIDER = {
2148
2223
  (r) => ({
2149
2224
  fileName: r.file,
2150
2225
  issues: r.issues.map((msg) => ({
2151
- type: import_core9.IssueType.ContextFragmentation,
2226
+ type: import_core10.IssueType.ContextFragmentation,
2152
2227
  severity: r.severity,
2153
2228
  message: msg,
2154
2229
  location: { file: r.file, line: 1 },
@@ -2160,13 +2235,13 @@ var CONTEXT_ANALYZER_PROVIDER = {
2160
2235
  }
2161
2236
  })
2162
2237
  );
2163
- return import_core9.SpokeOutputSchema.parse({
2238
+ return import_core10.SpokeOutputSchema.parse({
2164
2239
  results: normalizedResults,
2165
2240
  summary: {
2166
2241
  ...summary
2167
2242
  },
2168
2243
  metadata: {
2169
- toolName: import_core9.ToolName.ContextAnalyzer,
2244
+ toolName: import_core10.ToolName.ContextAnalyzer,
2170
2245
  version: "0.17.5",
2171
2246
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2172
2247
  }
@@ -2187,7 +2262,7 @@ init_graph_builder();
2187
2262
  init_classifier();
2188
2263
  init_remediation();
2189
2264
  init_summary();
2190
- import_core10.ToolRegistry.register(CONTEXT_ANALYZER_PROVIDER);
2265
+ import_core11.ToolRegistry.register(CONTEXT_ANALYZER_PROVIDER);
2191
2266
  // Annotate the CommonJS export names for ESM import in node:
2192
2267
  0 && (module.exports = {
2193
2268
  CONTEXT_ANALYZER_PROVIDER,
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  getClassificationRecommendations,
13
13
  getGeneralRecommendations,
14
14
  getTransitiveDependencies
15
- } from "./chunk-2LEHY2GV.mjs";
15
+ } from "./chunk-4N6ZDLJF.mjs";
16
16
  import "./chunk-RQ5BQLT6.mjs";
17
17
  import {
18
18
  generateSummary
@@ -230,7 +230,7 @@ var CONTEXT_ANALYZER_PROVIDER = {
230
230
  id: ToolName2.ContextAnalyzer,
231
231
  alias: ["context", "fragmentation", "budget"],
232
232
  async analyze(options) {
233
- const { analyzeContext: analyzeContext2 } = await import("./orchestrator-66ZVNOLR.mjs");
233
+ const { analyzeContext: analyzeContext2 } = await import("./orchestrator-EVJP3WUV.mjs");
234
234
  const { generateSummary: generateSummary2 } = await import("./summary-TZFB6ZFM.mjs");
235
235
  const results = await analyzeContext2(options);
236
236
  const summary = generateSummary2(results, options);
@@ -0,0 +1,10 @@
1
+ import {
2
+ analyzeContext,
3
+ calculateCohesion
4
+ } from "./chunk-4N6ZDLJF.mjs";
5
+ import "./chunk-RQ5BQLT6.mjs";
6
+ import "./chunk-JSM7Q5CY.mjs";
7
+ export {
8
+ analyzeContext,
9
+ calculateCohesion
10
+ };