@arsh342/athena 0.1.3 → 0.1.5

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,24 +1,26 @@
1
- # Athena
1
+ # Athena CLI
2
2
 
3
3
  AI code provenance tracker for JavaScript and TypeScript repositories.
4
4
 
5
- Athena scans JS/TS/JSX/TSX files, extracts function-level code units, scores AI-likelihood with heuristic signals, and runs targeted security checks on flagged sections.
5
+ Athena scans JS/TS/JSX/TSX files, extracts function-level code units, scores AI-origin likelihood with local heuristics, and runs targeted security checks.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @icemandev/athena
10
+ npm install -g @arsh342/athena
11
11
  ```
12
12
 
13
- ## Use
13
+ ## Quick Start
14
14
 
15
- Open the terminal selector:
15
+ Open interactive selector:
16
16
 
17
17
  ```bash
18
18
  athena
19
+ # or
20
+ athena menu
19
21
  ```
20
22
 
21
- Scan a repository:
23
+ Scan current directory:
22
24
 
23
25
  ```bash
24
26
  athena scan .
@@ -30,19 +32,28 @@ Check staged files:
30
32
  athena check
31
33
  ```
32
34
 
33
- Install the pre-commit hook:
35
+ Install pre-commit hook:
34
36
 
35
37
  ```bash
36
38
  athena init
37
39
  ```
38
40
 
39
- Remove the hook:
41
+ Remove pre-commit hook:
40
42
 
41
43
  ```bash
42
44
  athena uninstall
43
45
  ```
44
46
 
45
- ## Output formats
47
+ ## Common Options
48
+
49
+ Set threshold (default is `9`):
50
+
51
+ ```bash
52
+ athena scan . --threshold 9
53
+ athena check --threshold 9
54
+ ```
55
+
56
+ Choose output format:
46
57
 
47
58
  ```bash
48
59
  athena scan . --format terminal
@@ -50,9 +61,44 @@ athena scan . --format json
50
61
  athena scan . --format jsonl
51
62
  ```
52
63
 
64
+ ## Terminal UI Behavior
65
+
66
+ - Selector mode renders in-place and re-renders dynamically.
67
+ - Scan/check reports separate AI-origin confidence from security findings.
68
+ - Direct command runs clear the terminal before rendering report output.
69
+
70
+ ## Report Highlights
71
+
72
+ Terminal reports include:
73
+
74
+ - Top-level metrics (`files`, `units`, `ai-flagged units`, `duration`)
75
+ - AI-origin confidence section
76
+ - Top weighted signals
77
+ - Security findings section
78
+ - Gate status and gate reason
79
+
80
+ ## Development
81
+
82
+ Run from source:
83
+
84
+ ```bash
85
+ npm run dev -w @arsh342/athena -- menu
86
+ ```
87
+
88
+ Quiet npm wrapper output:
89
+
90
+ ```bash
91
+ npm run -s dev -w @arsh342/athena -- menu
92
+ ```
93
+
94
+ Build:
95
+
96
+ ```bash
97
+ npm run build -w @arsh342/athena
98
+ ```
99
+
53
100
  ## Notes
54
101
 
102
+ - Runs fully local (no external AI service required).
55
103
  - Supports JavaScript, TypeScript, JSX, and TSX.
56
- - Runs locally.
57
104
  - Requires Node.js 18 or newer.
58
- - Current release includes heuristic scoring, secret detection, hallucinated API checks, and ANSI terminal reports.
package/dist/index.cjs CHANGED
@@ -2271,10 +2271,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2271
2271
  }
2272
2272
  if (!proc.killed) {
2273
2273
  const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
2274
- signals.forEach((signal2) => {
2275
- process2.on(signal2, () => {
2274
+ signals.forEach((signal4) => {
2275
+ process2.on(signal4, () => {
2276
2276
  if (proc.killed === false && proc.exitCode === null) {
2277
- proc.kill(signal2);
2277
+ proc.kill(signal4);
2278
2278
  }
2279
2279
  });
2280
2280
  });
@@ -5726,7 +5726,7 @@ var require_typescript = __commonJS({
5726
5726
  walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
5727
5727
  whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
5728
5728
  writeCommentRange: () => writeCommentRange,
5729
- writeFile: () => writeFile2,
5729
+ writeFile: () => writeFile3,
5730
5730
  writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
5731
5731
  zipWith: () => zipWith
5732
5732
  });
@@ -12058,7 +12058,7 @@ ${lanes.join("\n")}
12058
12058
  writeOutputIsTTY() {
12059
12059
  return process.stdout.isTTY;
12060
12060
  },
12061
- readFile: readFile2,
12061
+ readFile: readFile3,
12062
12062
  writeFile: writeFile22,
12063
12063
  watchFile: watchFile2,
12064
12064
  watchDirectory,
@@ -12264,7 +12264,7 @@ ${lanes.join("\n")}
12264
12264
  callback
12265
12265
  );
12266
12266
  }
12267
- function readFile2(fileName, _encoding) {
12267
+ function readFile3(fileName, _encoding) {
12268
12268
  let buffer;
12269
12269
  try {
12270
12270
  buffer = _fs.readFileSync(fileName);
@@ -24369,7 +24369,7 @@ ${lanes.join("\n")}
24369
24369
  sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
24370
24370
  return combinePaths(newDirPath, sourceFilePath);
24371
24371
  }
24372
- function writeFile2(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
24372
+ function writeFile3(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
24373
24373
  host.writeFile(
24374
24374
  fileName,
24375
24375
  text,
@@ -48820,7 +48820,7 @@ ${lanes.join("\n")}
48820
48820
  const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
48821
48821
  return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
48822
48822
  }
48823
- function parseCommandLineWorker(diagnostics, commandLine, readFile2) {
48823
+ function parseCommandLineWorker(diagnostics, commandLine, readFile3) {
48824
48824
  const options = {};
48825
48825
  let watchOptions;
48826
48826
  const fileNames = [];
@@ -48868,7 +48868,7 @@ ${lanes.join("\n")}
48868
48868
  }
48869
48869
  }
48870
48870
  function parseResponseFile(fileName) {
48871
- const text = tryReadFile(fileName, readFile2 || ((fileName2) => sys.readFile(fileName2)));
48871
+ const text = tryReadFile(fileName, readFile3 || ((fileName2) => sys.readFile(fileName2)));
48872
48872
  if (!isString(text)) {
48873
48873
  errors.push(text);
48874
48874
  return;
@@ -48971,8 +48971,8 @@ ${lanes.join("\n")}
48971
48971
  unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
48972
48972
  optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
48973
48973
  };
48974
- function parseCommandLine(commandLine, readFile2) {
48975
- return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile2);
48974
+ function parseCommandLine(commandLine, readFile3) {
48975
+ return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile3);
48976
48976
  }
48977
48977
  function getOptionFromName(optionName, allowShort) {
48978
48978
  return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
@@ -49054,8 +49054,8 @@ ${lanes.join("\n")}
49054
49054
  watchOptionsToExtend
49055
49055
  );
49056
49056
  }
49057
- function readConfigFile(fileName, readFile2) {
49058
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
49057
+ function readConfigFile(fileName, readFile3) {
49058
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
49059
49059
  return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
49060
49060
  }
49061
49061
  function parseConfigFileTextToJson(fileName, jsonText) {
@@ -49070,14 +49070,14 @@ ${lanes.join("\n")}
49070
49070
  error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : void 0
49071
49071
  };
49072
49072
  }
49073
- function readJsonConfigFile(fileName, readFile2) {
49074
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
49073
+ function readJsonConfigFile(fileName, readFile3) {
49074
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
49075
49075
  return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
49076
49076
  }
49077
- function tryReadFile(fileName, readFile2) {
49077
+ function tryReadFile(fileName, readFile3) {
49078
49078
  let text;
49079
49079
  try {
49080
- text = readFile2(fileName);
49080
+ text = readFile3(fileName);
49081
49081
  } catch (e) {
49082
49082
  return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
49083
49083
  }
@@ -133120,7 +133120,7 @@ ${lanes.join("\n")}
133120
133120
  return;
133121
133121
  }
133122
133122
  const buildInfo = host.getBuildInfo() || { version };
133123
- writeFile2(
133123
+ writeFile3(
133124
133124
  host,
133125
133125
  emitterDiagnostics,
133126
133126
  buildInfoPath,
@@ -133332,7 +133332,7 @@ ${lanes.join("\n")}
133332
133332
  }
133333
133333
  if (sourceMapFilePath) {
133334
133334
  const sourceMap = sourceMapGenerator.toString();
133335
- writeFile2(
133335
+ writeFile3(
133336
133336
  host,
133337
133337
  emitterDiagnostics,
133338
133338
  sourceMapFilePath,
@@ -133347,7 +133347,7 @@ ${lanes.join("\n")}
133347
133347
  }
133348
133348
  const text = writer.getText();
133349
133349
  const data = { sourceMapUrlPos, diagnostics: transform2.diagnostics };
133350
- writeFile2(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
133350
+ writeFile3(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
133351
133351
  writer.clear();
133352
133352
  return !data.skippedDtsWrite;
133353
133353
  }
@@ -138735,12 +138735,12 @@ ${lanes.join("\n")}
138735
138735
  function createCompilerHost(options, setParentNodes) {
138736
138736
  return createCompilerHostWorker(options, setParentNodes);
138737
138737
  }
138738
- function createGetSourceFile(readFile2, setParentNodes) {
138738
+ function createGetSourceFile(readFile3, setParentNodes) {
138739
138739
  return (fileName, languageVersionOrOptions, onError) => {
138740
138740
  let text;
138741
138741
  try {
138742
138742
  mark("beforeIORead");
138743
- text = readFile2(fileName);
138743
+ text = readFile3(fileName);
138744
138744
  mark("afterIORead");
138745
138745
  measure("I/O Read", "beforeIORead", "afterIORead");
138746
138746
  } catch (e) {
@@ -139644,7 +139644,7 @@ ${lanes.join("\n")}
139644
139644
  getRedirectFromOutput,
139645
139645
  forEachResolvedProjectReference: forEachResolvedProjectReference2
139646
139646
  });
139647
- const readFile2 = host.readFile.bind(host);
139647
+ const readFile3 = host.readFile.bind(host);
139648
139648
  (_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
139649
139649
  const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
139650
139650
  (_f = tracing) == null ? void 0 : _f.pop();
@@ -139870,7 +139870,7 @@ ${lanes.join("\n")}
139870
139870
  shouldTransformImportCall,
139871
139871
  emitBuildInfo,
139872
139872
  fileExists,
139873
- readFile: readFile2,
139873
+ readFile: readFile3,
139874
139874
  directoryExists,
139875
139875
  getSymlinkCache,
139876
139876
  realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
@@ -201229,7 +201229,7 @@ ${options.prefix}` : "\n" : options.prefix
201229
201229
  walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
201230
201230
  whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
201231
201231
  writeCommentRange: () => writeCommentRange,
201232
- writeFile: () => writeFile2,
201232
+ writeFile: () => writeFile3,
201233
201233
  writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
201234
201234
  zipWith: () => zipWith
201235
201235
  });
@@ -214230,10 +214230,12 @@ var defaultWeights = {
214230
214230
  namingEntropy: 10,
214231
214231
  boilerplatePatterns: 10,
214232
214232
  helperOrdering: 10,
214233
- emojiComments: 10
214233
+ emojiComments: 10,
214234
+ perplexity: 12,
214235
+ burstiness: 12
214234
214236
  };
214235
214237
  var defaultConfig = {
214236
- threshold: 65,
214238
+ threshold: 9,
214237
214239
  blockOn: ["CRITICAL", "HIGH"],
214238
214240
  exclude: ["node_modules/", "dist/", "build/", ".git/", "coverage/"],
214239
214241
  secretDetection: true,
@@ -214485,7 +214487,7 @@ function estimateComplexity(node) {
214485
214487
 
214486
214488
  // ../core/dist/report/report-generator.js
214487
214489
  var severityOrder = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
214488
- function generateReport(startedAt, files, totalLoc, blockOn) {
214490
+ function generateReport(startedAt, files, totalLoc, config) {
214489
214491
  const units = files.flatMap((file) => file.units);
214490
214492
  const findings = files.flatMap((file) => file.findings);
214491
214493
  const severityCounts = severityOrder.reduce((acc, severity) => ({ ...acc, [severity]: findings.filter((finding) => finding.severity === severity).length }), { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 });
@@ -214496,6 +214498,20 @@ function generateReport(startedAt, files, totalLoc, blockOn) {
214496
214498
  };
214497
214499
  const flaggedUnits = units.filter((unit) => unit.flagged).length;
214498
214500
  const aiScore = Math.round(units.reduce((sum, unit) => sum + unit.score, 0) / Math.max(1, units.length));
214501
+ const blocked = findings.some((finding) => config.blockOn.includes(finding.severity));
214502
+ const riskDensity = {
214503
+ criticalPer1kLoc: roundPerK(severityCounts.CRITICAL, totalLoc),
214504
+ findingsPer1kLoc: roundPerK(findings.length, totalLoc),
214505
+ flaggedRatio: flaggedUnits / Math.max(1, units.length)
214506
+ };
214507
+ const aiOrigin = {
214508
+ score: aiScore,
214509
+ flaggedUnits,
214510
+ flagRatio: flaggedUnits / Math.max(1, units.length),
214511
+ percentage: Math.round(flaggedUnits / Math.max(1, units.length) * 100),
214512
+ confidenceBands
214513
+ };
214514
+ const weightedContributions = summarizeWeightedContributions(units);
214499
214515
  return {
214500
214516
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
214501
214517
  duration: Date.now() - startedAt,
@@ -214504,16 +214520,23 @@ function generateReport(startedAt, files, totalLoc, blockOn) {
214504
214520
  totalUnits: units.length,
214505
214521
  flaggedUnits,
214506
214522
  findings: severityCounts,
214507
- blocked: findings.some((finding) => blockOn.includes(finding.severity)),
214523
+ blocked,
214508
214524
  aiScore,
214509
- aiFlagRatio: flaggedUnits / Math.max(1, units.length),
214510
- aiPercentage: Math.round(flaggedUnits / Math.max(1, units.length) * 100),
214511
- riskDensity: {
214512
- criticalPer1kLoc: roundPerK(severityCounts.CRITICAL, totalLoc),
214513
- findingsPer1kLoc: roundPerK(findings.length, totalLoc),
214514
- flaggedRatio: flaggedUnits / Math.max(1, units.length)
214525
+ aiFlagRatio: aiOrigin.flagRatio,
214526
+ aiPercentage: aiOrigin.percentage,
214527
+ riskDensity,
214528
+ confidenceBands,
214529
+ aiOrigin,
214530
+ security: {
214531
+ findings: severityCounts,
214532
+ blocked,
214533
+ riskDensity
214515
214534
  },
214516
- confidenceBands
214535
+ weightedContributions,
214536
+ calibration: {
214537
+ thresholdUsed: config.threshold,
214538
+ source: "default"
214539
+ }
214517
214540
  },
214518
214541
  files
214519
214542
  };
@@ -214524,10 +214547,119 @@ function countBand(units, band) {
214524
214547
  function roundPerK(count, loc) {
214525
214548
  return Math.round(count / Math.max(1, loc) * 1e3 * 10) / 10;
214526
214549
  }
214550
+ function summarizeWeightedContributions(units) {
214551
+ const totals = /* @__PURE__ */ new Map();
214552
+ for (const unit of units) {
214553
+ for (const signal4 of unit.signals) {
214554
+ const existing = totals.get(signal4.signal) ?? { score: 0, maxWeight: 0 };
214555
+ existing.score += signal4.score;
214556
+ existing.maxWeight += signal4.maxWeight;
214557
+ totals.set(signal4.signal, existing);
214558
+ }
214559
+ }
214560
+ const totalScore = Array.from(totals.values()).reduce((sum, item) => sum + item.score, 0);
214561
+ return Array.from(totals.entries()).map(([signal4, values]) => ({
214562
+ signal: signal4,
214563
+ contribution: totalScore === 0 ? 0 : Math.round(values.score / totalScore * 100),
214564
+ score: values.score,
214565
+ maxWeight: values.maxWeight
214566
+ })).sort((a, b) => b.score - a.score).slice(0, 8);
214567
+ }
214527
214568
  function formatJsonl(report) {
214528
214569
  return report.files.flatMap((file) => file.findings).map((finding) => JSON.stringify(finding)).join("\n");
214529
214570
  }
214530
214571
 
214572
+ // ../core/dist/analyzers/burstiness-analyzer.js
214573
+ function scoreBurstiness(unit, maxWeight) {
214574
+ const sentences = splitSentences(unit.code);
214575
+ if (sentences.length < 3) {
214576
+ return signal("burstiness", 0, maxWeight, "insufficient sentence count for burstiness estimate");
214577
+ }
214578
+ const lengths = sentences.map((sentence) => tokenize(sentence).length).filter((count) => count > 0);
214579
+ if (lengths.length < 3) {
214580
+ return signal("burstiness", 0, maxWeight, "insufficient tokenized sentences for burstiness estimate");
214581
+ }
214582
+ const mean = average(lengths);
214583
+ const stdDev = standardDeviation(lengths, mean);
214584
+ const coeffVar = stdDev / Math.max(1, mean);
214585
+ const openerVariety = sentenceOpenerVariety(sentences);
214586
+ const lowLengthVariation = clamp01((0.55 - coeffVar) / 0.55);
214587
+ const lowOpenerVariation = clamp01((0.75 - openerVariety) / 0.75);
214588
+ const score = Math.round(maxWeight * (lowLengthVariation * 0.7 + lowOpenerVariation * 0.3));
214589
+ return signal("burstiness", score, maxWeight, `sentence cv ${coeffVar.toFixed(2)}, opener variety ${Math.round(openerVariety * 100)}%`);
214590
+ }
214591
+ function splitSentences(code) {
214592
+ return code.replace(/\s+/g, " ").split(/[.!?;]+/).map((line) => line.trim()).filter((line) => line.length > 0);
214593
+ }
214594
+ function tokenize(value) {
214595
+ return value.toLowerCase().split(/[^a-z0-9_]+/).map((part) => part.trim()).filter((part) => part.length > 0);
214596
+ }
214597
+ function sentenceOpenerVariety(sentences) {
214598
+ const starters = sentences.map((sentence) => tokenize(sentence)[0]).filter((token) => Boolean(token));
214599
+ if (starters.length === 0)
214600
+ return 0;
214601
+ return new Set(starters).size / starters.length;
214602
+ }
214603
+ function average(values) {
214604
+ return values.reduce((sum, value) => sum + value, 0) / Math.max(1, values.length);
214605
+ }
214606
+ function standardDeviation(values, mean) {
214607
+ const variance = values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(1, values.length);
214608
+ return Math.sqrt(variance);
214609
+ }
214610
+ function clamp01(value) {
214611
+ return Math.max(0, Math.min(1, value));
214612
+ }
214613
+ function signal(signalName, score, maxWeight, evidence) {
214614
+ return {
214615
+ signal: signalName,
214616
+ score: Math.max(0, Math.min(maxWeight, Math.round(score))),
214617
+ maxWeight,
214618
+ evidence
214619
+ };
214620
+ }
214621
+
214622
+ // ../core/dist/analyzers/perplexity-analyzer.js
214623
+ function scorePerplexity(unit, maxWeight) {
214624
+ const tokens = tokenize2(unit.code);
214625
+ if (tokens.length < 8) {
214626
+ return signal2("perplexity", 0, maxWeight, "insufficient tokens for perplexity estimate");
214627
+ }
214628
+ const entropy = shannonEntropy2(tokens);
214629
+ const normalizedEntropy = clamp012((entropy - 2.2) / 2.2);
214630
+ const repetitionPenalty = repetitionRate(tokens);
214631
+ const predictability = clamp012((1 - normalizedEntropy) * 0.75 + repetitionPenalty * 0.25);
214632
+ const score = Math.round(maxWeight * predictability);
214633
+ return signal2("perplexity", score, maxWeight, `token entropy ${entropy.toFixed(2)}, repetition ${Math.round(repetitionPenalty * 100)}%`);
214634
+ }
214635
+ function tokenize2(code) {
214636
+ return code.toLowerCase().split(/[^a-z0-9_]+/).map((part) => part.trim()).filter((part) => part.length > 0);
214637
+ }
214638
+ function shannonEntropy2(tokens) {
214639
+ const counts = /* @__PURE__ */ new Map();
214640
+ for (const token of tokens)
214641
+ counts.set(token, (counts.get(token) ?? 0) + 1);
214642
+ return Array.from(counts.values()).reduce((entropy, count) => {
214643
+ const p = count / tokens.length;
214644
+ return entropy - p * Math.log2(p);
214645
+ }, 0);
214646
+ }
214647
+ function repetitionRate(tokens) {
214648
+ const unique = new Set(tokens).size;
214649
+ return clamp012(1 - unique / Math.max(1, tokens.length));
214650
+ }
214651
+ function clamp012(value) {
214652
+ return Math.max(0, Math.min(1, value));
214653
+ }
214654
+ function signal2(signalName, score, maxWeight, evidence) {
214655
+ return {
214656
+ signal: signalName,
214657
+ score: Math.max(0, Math.min(maxWeight, Math.round(score))),
214658
+ maxWeight,
214659
+ evidence
214660
+ };
214661
+ }
214662
+
214531
214663
  // ../core/dist/scorer/heuristic-scorer.js
214532
214664
  var genericNames = /* @__PURE__ */ new Set([
214533
214665
  "data",
@@ -214557,10 +214689,12 @@ function scoreUnit(unit, config) {
214557
214689
  scoreNamingEntropy(unit, config.weights.namingEntropy),
214558
214690
  scoreBoilerplatePatterns(unit, config.weights.boilerplatePatterns),
214559
214691
  scoreHelperOrdering(unit, config.weights.helperOrdering),
214560
- scoreEmojiComments(unit, config.weights.emojiComments)
214692
+ scoreEmojiComments(unit, config.weights.emojiComments),
214693
+ scorePerplexity(unit, config.weights.perplexity),
214694
+ scoreBurstiness(unit, config.weights.burstiness)
214561
214695
  ];
214562
- const max = signals.reduce((sum, signal2) => sum + signal2.maxWeight, 0);
214563
- const raw = signals.reduce((sum, signal2) => sum + signal2.score, 0);
214696
+ const max = signals.reduce((sum, signal4) => sum + signal4.maxWeight, 0);
214697
+ const raw = signals.reduce((sum, signal4) => sum + signal4.score, 0);
214564
214698
  const score = Math.round(raw / max * 100);
214565
214699
  const explained = explain(score, signals);
214566
214700
  return {
@@ -214571,9 +214705,9 @@ function scoreUnit(unit, config) {
214571
214705
  explained
214572
214706
  };
214573
214707
  }
214574
- function signal(signal2, score, maxWeight, evidence) {
214708
+ function signal3(signal4, score, maxWeight, evidence) {
214575
214709
  return {
214576
- signal: signal2,
214710
+ signal: signal4,
214577
214711
  score: Math.max(0, Math.min(maxWeight, Math.round(score))),
214578
214712
  maxWeight,
214579
214713
  evidence
@@ -214583,36 +214717,36 @@ function scoreGenericNames(unit, max) {
214583
214717
  const identifiers = unit.metadata.identifiers;
214584
214718
  const hits = identifiers.filter((name) => genericNames.has(name.toLowerCase())).length;
214585
214719
  const ratio = hits / Math.max(1, identifiers.length);
214586
- return signal("genericNames", ratio * max * 3, max, `${hits}/${identifiers.length} identifiers are generic`);
214720
+ return signal3("genericNames", ratio * max * 3, max, `${hits}/${identifiers.length} identifiers are generic`);
214587
214721
  }
214588
214722
  function scoreCommentRatio(unit, max) {
214589
214723
  const ratio = unit.metadata.commentRatio;
214590
- return signal("commentRatio", ratio >= 0.4 ? max : ratio / 0.4 * max, max, `comment ratio ${ratio.toFixed(2)}`);
214724
+ return signal3("commentRatio", ratio >= 0.4 ? max : ratio / 0.4 * max, max, `comment ratio ${ratio.toFixed(2)}`);
214591
214725
  }
214592
214726
  function scoreObviousComments(unit, max) {
214593
214727
  const obvious = /\/\/\s*(set|get|return|create|update|delete|loop|check|initialize|calculate|fetch)\b/i.test(unit.code);
214594
- return signal("obviousComments", obvious ? max : 0, max, obvious ? "obvious explanatory comment found" : "no obvious comments");
214728
+ return signal3("obviousComments", obvious ? max : 0, max, obvious ? "obvious explanatory comment found" : "no obvious comments");
214595
214729
  }
214596
214730
  function scoreEmptyCatch(unit, max) {
214597
214731
  const emptyCatch = /catch\s*\([^)]*\)\s*\{\s*(console\.(error|log)\([^)]*\);\s*)?\}/s.test(unit.code);
214598
- return signal("emptyCatch", emptyCatch ? max : 0, max, emptyCatch ? "empty or log-only catch block" : "catch blocks include handling");
214732
+ return signal3("emptyCatch", emptyCatch ? max : 0, max, emptyCatch ? "empty or log-only catch block" : "catch blocks include handling");
214599
214733
  }
214600
214734
  function scoreNullChecks(unit, max) {
214601
214735
  const checks = (unit.code.match(/(\?\?|\?\.|typeof\s+\w+\s*===\s*['"]undefined['"]|!==\s*null|===\s*null)/g) ?? []).length;
214602
- return signal("nullChecks", Math.min(max, checks * 2), max, `${checks} defensive null/undefined checks`);
214736
+ return signal3("nullChecks", Math.min(max, checks * 2), max, `${checks} defensive null/undefined checks`);
214603
214737
  }
214604
214738
  function scoreFormattingUniformity(unit, max) {
214605
214739
  const indents = unit.code.split(/\r?\n/).filter((line) => line.trim().length > 0).map((line) => line.match(/^\s*/)?.[0].length ?? 0);
214606
214740
  const unique = new Set(indents);
214607
- return signal("formattingUniformity", unique.size <= 3 && indents.length > 8 ? max : max * 0.2, max, `${unique.size} indentation levels`);
214741
+ return signal3("formattingUniformity", unique.size <= 3 && indents.length > 8 ? max : max * 0.2, max, `${unique.size} indentation levels`);
214608
214742
  }
214609
214743
  function scoreUniversalJsdoc(unit, max) {
214610
- return signal("universalJsdoc", unit.metadata.hasJSDoc ? max : 0, max, unit.metadata.hasJSDoc ? "JSDoc present" : "no JSDoc");
214744
+ return signal3("universalJsdoc", unit.metadata.hasJSDoc ? max : 0, max, unit.metadata.hasJSDoc ? "JSDoc present" : "no JSDoc");
214611
214745
  }
214612
214746
  function scoreNamingEntropy(unit, max) {
214613
- const entropy = shannonEntropy2(unit.metadata.identifiers.join(""));
214747
+ const entropy = shannonEntropy3(unit.metadata.identifiers.join(""));
214614
214748
  const score = entropy < 3.2 ? max : entropy < 3.8 ? max * 0.5 : 0;
214615
- return signal("namingEntropy", score, max, `identifier entropy ${entropy.toFixed(2)}`);
214749
+ return signal3("namingEntropy", score, max, `identifier entropy ${entropy.toFixed(2)}`);
214616
214750
  }
214617
214751
  function scoreBoilerplatePatterns(unit, max) {
214618
214752
  const patterns = [
@@ -214622,18 +214756,18 @@ function scoreBoilerplatePatterns(unit, max) {
214622
214756
  /useState\([^)]*\)[\s\S]*useEffect/i
214623
214757
  ];
214624
214758
  const hits = patterns.filter((pattern) => pattern.test(unit.code)).length;
214625
- return signal("boilerplatePatterns", hits * (max / 2), max, `${hits} boilerplate patterns`);
214759
+ return signal3("boilerplatePatterns", hits * (max / 2), max, `${hits} boilerplate patterns`);
214626
214760
  }
214627
214761
  function scoreHelperOrdering(unit, max) {
214628
214762
  const helperDefinitions = (unit.code.match(/function\s+(validate|format|process|handle|create|update)\w*/gi) ?? []).length;
214629
214763
  const sequentialCalls = /(validate\w*\([^)]*\)[\s\S]*format\w*\([^)]*\)[\s\S]*process\w*\([^)]*\))/i.test(unit.code);
214630
- return signal("helperOrdering", helperDefinitions >= 2 || sequentialCalls ? max : 0, max, `${helperDefinitions} helper-like definitions`);
214764
+ return signal3("helperOrdering", helperDefinitions >= 2 || sequentialCalls ? max : 0, max, `${helperDefinitions} helper-like definitions`);
214631
214765
  }
214632
214766
  function scoreEmojiComments(unit, max) {
214633
214767
  const emojiLike = /[\u{1F300}-\u{1FAFF}\u{2600}-\u{27BF}]/u.test(unit.code);
214634
- return signal("emojiComments", emojiLike ? max : 0, max, emojiLike ? "emoji-like character found" : "no emoji comments");
214768
+ return signal3("emojiComments", emojiLike ? max : 0, max, emojiLike ? "emoji-like character found" : "no emoji comments");
214635
214769
  }
214636
- function shannonEntropy2(value) {
214770
+ function shannonEntropy3(value) {
214637
214771
  if (!value)
214638
214772
  return 0;
214639
214773
  const counts = /* @__PURE__ */ new Map();
@@ -214646,15 +214780,15 @@ function shannonEntropy2(value) {
214646
214780
  }
214647
214781
  function explain(score, signals) {
214648
214782
  const band = score < 40 ? "LOW" : score < 70 ? "UNCERTAIN" : "HIGH";
214649
- const total = signals.reduce((sum, signal2) => sum + signal2.score, 0);
214783
+ const total = signals.reduce((sum, signal4) => sum + signal4.score, 0);
214650
214784
  const mean = total / Math.max(1, signals.length);
214651
- const variance = signals.reduce((sum, signal2) => sum + (signal2.score - mean) ** 2, 0) / Math.max(1, signals.length);
214785
+ const variance = signals.reduce((sum, signal4) => sum + (signal4.score - mean) ** 2, 0) / Math.max(1, signals.length);
214652
214786
  return {
214653
214787
  score,
214654
214788
  band,
214655
- signalsTriggered: signals.filter((signal2) => signal2.score > 0).length,
214789
+ signalsTriggered: signals.filter((signal4) => signal4.score > 0).length,
214656
214790
  variance: Math.round(variance),
214657
- topSignals: signals.filter((signal2) => signal2.score > 0).sort((a, b) => b.score - a.score).slice(0, 3).map((signalResult) => ({
214791
+ topSignals: signals.filter((signal4) => signal4.score > 0).sort((a, b) => b.score - a.score).slice(0, 3).map((signalResult) => ({
214658
214792
  signal: signalResult.signal,
214659
214793
  contribution: total === 0 ? 0 : Math.round(signalResult.score / total * 100),
214660
214794
  score: signalResult.score
@@ -214682,7 +214816,7 @@ async function scanFiles(filePaths, configInput = {}) {
214682
214816
  findings
214683
214817
  });
214684
214818
  }
214685
- return generateReport(startedAt, files, totalLoc, config.blockOn);
214819
+ return generateReport(startedAt, files, totalLoc, config);
214686
214820
  }
214687
214821
 
214688
214822
  // ../core/dist/report/terminal-formatter.js
@@ -214690,7 +214824,6 @@ var c = {
214690
214824
  reset: "\x1B[0m",
214691
214825
  bold: "\x1B[1m",
214692
214826
  dim: "\x1B[2m",
214693
- cyan: "\x1B[36m",
214694
214827
  green: "\x1B[32m",
214695
214828
  yellow: "\x1B[33m",
214696
214829
  orange: "\x1B[38;5;208m",
@@ -214702,18 +214835,22 @@ var severityColor = {
214702
214835
  CRITICAL: c.red,
214703
214836
  HIGH: c.orange,
214704
214837
  MEDIUM: c.yellow,
214705
- LOW: c.cyan
214838
+ LOW: c.gray
214706
214839
  };
214707
214840
  function formatTerminalReport(report) {
214708
214841
  const lines = [];
214709
214842
  const summary = report.summary;
214843
+ const securityFindingsTotal = Object.values(summary.findings).reduce((sum, count) => sum + count, 0);
214844
+ const thresholdUsed = summary.calibration?.thresholdUsed;
214845
+ const aiScoreRelation = typeof thresholdUsed === "number" ? summary.aiScore === thresholdUsed ? "at threshold" : summary.aiScore < thresholdUsed ? "below threshold" : "above threshold" : "threshold unavailable";
214846
+ const gateReason = summary.blocked ? securityFindingsTotal > 0 ? "blocked (security findings matched block policy)" : `blocked (ai score ${aiScoreRelation})` : securityFindingsTotal === 0 ? `pass (no security findings, ai score ${aiScoreRelation})` : `pass (security findings present but below block policy, ai score ${aiScoreRelation})`;
214710
214847
  lines.push("");
214711
214848
  lines.push(sectionRule("Athena Report"));
214712
214849
  lines.push("");
214713
214850
  lines.push(metricLine([
214714
214851
  ["files", String(summary.filesScanned)],
214715
214852
  ["units", String(summary.totalUnits)],
214716
- ["flagged", String(summary.flaggedUnits)],
214853
+ ["ai-flagged units", String(summary.flaggedUnits)],
214717
214854
  ["duration", `${report.duration}ms`]
214718
214855
  ]));
214719
214856
  lines.push(metricLine([
@@ -214722,7 +214859,33 @@ function formatTerminalReport(report) {
214722
214859
  ["risk", `${summary.riskDensity.findingsPer1kLoc}/1k LOC`],
214723
214860
  ["gate", summary.blocked ? `${c.red}blocked${c.reset}` : `${c.green}pass${c.reset}`]
214724
214861
  ]));
214862
+ lines.push(` ${c.dim}gate reason${c.reset} ${c.white}${gateReason}${c.reset}`);
214725
214863
  lines.push("");
214864
+ if (summary.aiOrigin) {
214865
+ lines.push(` ${c.bold}AI-Origin Confidence${c.reset}`);
214866
+ lines.push(metricLine([
214867
+ ["score", `${summary.aiOrigin.score}/100`],
214868
+ ["flagged units", String(summary.aiOrigin.flaggedUnits)],
214869
+ ["ratio", `${Math.round(summary.aiOrigin.flagRatio * 100)}%`],
214870
+ ["threshold", String(summary.calibration?.thresholdUsed ?? "n/a")]
214871
+ ]));
214872
+ lines.push("");
214873
+ }
214874
+ if (summary.weightedContributions && summary.weightedContributions.length > 0) {
214875
+ lines.push(` ${c.bold}Top Weighted Signals${c.reset}`);
214876
+ lines.push(` ${summary.weightedContributions.slice(0, 4).map((item) => `${c.dim}${item.signal}${c.reset} ${c.orange}${item.contribution}%${c.reset}`).join(" ")}`);
214877
+ lines.push("");
214878
+ }
214879
+ if (summary.security) {
214880
+ lines.push(` ${c.bold}Security Findings${c.reset}`);
214881
+ lines.push(metricLine([
214882
+ ["critical", String(summary.security.findings.CRITICAL)],
214883
+ ["high", String(summary.security.findings.HIGH)],
214884
+ ["medium", String(summary.security.findings.MEDIUM)],
214885
+ ["low", String(summary.security.findings.LOW)]
214886
+ ]));
214887
+ lines.push("");
214888
+ }
214726
214889
  lines.push(` ${c.bold}Severity${c.reset}`);
214727
214890
  lines.push(` ${severityBar(report)}`);
214728
214891
  lines.push("");
@@ -214744,10 +214907,10 @@ function formatTerminalReport(report) {
214744
214907
  for (const finding of findings.slice(0, 20)) {
214745
214908
  const sevColor = severityColor[finding.severity];
214746
214909
  lines.push(` ${sevColor}${finding.severity.padEnd(9)}${c.reset}${c.bold}${finding.type}${c.reset} ${c.dim}${finding.id}${c.reset}`);
214747
- lines.push(` ${c.cyan}${finding.file}:${finding.line}${c.reset} ${c.dim}ai=${finding.aiScore} source=${finding.source}${c.reset}`);
214910
+ lines.push(` ${c.orange}${finding.file}:${finding.line}${c.reset} ${c.dim}ai=${finding.aiScore} source=${finding.source}${c.reset}`);
214748
214911
  lines.push(` ${c.dim}${finding.message}${c.reset}`);
214749
214912
  if (finding.explainedScore.topSignals.length > 0) {
214750
- const signals = finding.explainedScore.topSignals.map((s) => `${s.signal}:${c.cyan}${s.contribution}%${c.reset}`).join(" ");
214913
+ const signals = finding.explainedScore.topSignals.map((s) => `${s.signal}:${c.orange}${s.contribution}%${c.reset}`).join(" ");
214751
214914
  lines.push(` ${c.dim}signals:${c.reset} ${signals}`);
214752
214915
  }
214753
214916
  lines.push("");
@@ -214761,7 +214924,7 @@ function formatTerminalReport(report) {
214761
214924
  function sectionRule(title) {
214762
214925
  const ruleWidth = Math.max(48, title.length + 10);
214763
214926
  const dashCount = ruleWidth - title.length - 5;
214764
- return ` ${c.cyan}\u2500\u2500${c.reset} ${c.bold}${title}${c.reset} ${c.cyan}${"\u2500".repeat(dashCount)}${c.reset}`;
214927
+ return ` ${c.orange}\u2500\u2500${c.reset} ${c.bold}${title}${c.reset} ${c.orange}${"\u2500".repeat(dashCount)}${c.reset}`;
214765
214928
  }
214766
214929
  function metricLine(metrics) {
214767
214930
  return " " + metrics.map(([label, value]) => `${c.dim}${label}${c.reset} ${c.white}${value}${c.reset}`).join(" ");
@@ -214778,7 +214941,7 @@ function severityBar(report) {
214778
214941
  }
214779
214942
 
214780
214943
  // src/commands/check.ts
214781
- var import_node_path2 = require("path");
214944
+ var import_node_path3 = require("path");
214782
214945
 
214783
214946
  // src/utils/file-filter.ts
214784
214947
  var import_promises3 = require("fs/promises");
@@ -214829,6 +214992,61 @@ async function getStagedFiles() {
214829
214992
  }
214830
214993
  }
214831
214994
 
214995
+ // src/utils/history.ts
214996
+ var import_promises4 = require("fs/promises");
214997
+ var import_node_os = require("os");
214998
+ var import_node_path2 = require("path");
214999
+ var ATHENA_DIR = (0, import_node_path2.join)((0, import_node_os.homedir)(), ".athena");
215000
+ var HISTORY_PATH = (0, import_node_path2.join)(ATHENA_DIR, "scan-history.jsonl");
215001
+ var MAX_HISTORY_LINES = 300;
215002
+ async function appendScanHistory(entry) {
215003
+ try {
215004
+ await (0, import_promises4.mkdir)(ATHENA_DIR, { recursive: true });
215005
+ let lines = [];
215006
+ try {
215007
+ const existing = await (0, import_promises4.readFile)(HISTORY_PATH, "utf8");
215008
+ lines = existing.split("\n").map((line) => line.trim()).filter(Boolean);
215009
+ } catch {
215010
+ }
215011
+ lines.push(JSON.stringify(entry));
215012
+ const trimmed = lines.slice(-MAX_HISTORY_LINES);
215013
+ await (0, import_promises4.writeFile)(HISTORY_PATH, `${trimmed.join("\n")}
215014
+ `, "utf8");
215015
+ } catch {
215016
+ }
215017
+ }
215018
+ async function getRecentScanHistory(limit = 3) {
215019
+ try {
215020
+ const content = await (0, import_promises4.readFile)(HISTORY_PATH, "utf8");
215021
+ const lines = content.split("\n").map((line) => line.trim()).filter(Boolean).slice(-Math.max(1, limit));
215022
+ return lines.map((line) => {
215023
+ try {
215024
+ return JSON.parse(line);
215025
+ } catch {
215026
+ return null;
215027
+ }
215028
+ }).filter((entry) => entry !== null).reverse();
215029
+ } catch {
215030
+ return [];
215031
+ }
215032
+ }
215033
+ function formatRecentHistory(entries) {
215034
+ if (entries.length === 0) {
215035
+ return "history: none";
215036
+ }
215037
+ const parts = entries.map((entry) => {
215038
+ const stamp = new Date(entry.timestamp).toLocaleTimeString([], {
215039
+ hour: "2-digit",
215040
+ minute: "2-digit",
215041
+ hour12: false
215042
+ });
215043
+ const status = entry.blocked ? "blocked" : "pass";
215044
+ const score = Number.isFinite(entry.aiScore) ? Math.round(entry.aiScore) : 0;
215045
+ return `${entry.mode} ${stamp} ${status} ${score}`;
215046
+ });
215047
+ return `history: ${parts.join(" | ")}`;
215048
+ }
215049
+
214832
215050
  // src/utils/colors.ts
214833
215051
  var c2 = {
214834
215052
  reset: "\x1B[0m",
@@ -214836,7 +215054,7 @@ var c2 = {
214836
215054
  dim: "\x1B[2m",
214837
215055
  italic: "\x1B[3m",
214838
215056
  inverse: "\x1B[7m",
214839
- red: "\x1B[31m",
215057
+ red: "\x1B[38;2;232;122;65m",
214840
215058
  green: "\x1B[32m",
214841
215059
  yellow: "\x1B[33m",
214842
215060
  blue: "\x1B[34m",
@@ -214847,18 +215065,22 @@ var c2 = {
214847
215065
  brightBlue: "\x1B[94m",
214848
215066
  brightCyan: "\x1B[96m",
214849
215067
  brightWhite: "\x1B[97m",
214850
- orange: "\x1B[38;5;208m",
214851
- /** Primary accent — npm-like red profile. */
214852
- accent: "\x1B[38;5;160m"
215068
+ orange: "\x1B[38;2;232;122;65m",
215069
+ /** Primary accent — ATHENA orange profile. */
215070
+ accent: "\x1B[38;2;232;122;65m",
215071
+ /** ATHENA logo box background (#E87A41). */
215072
+ bannerBg: "\x1B[48;2;232;122;65m",
215073
+ /** ATHENA logo glyph color matches site dark bg (#0f0f0f). */
215074
+ bannerFg: "\x1B[38;2;15;15;15m"
214853
215075
  };
214854
215076
 
214855
215077
  // src/utils/banner.ts
214856
215078
  var BANNER_LARGE = [
214857
- " \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588 ",
214858
- "\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588",
214859
- "\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588",
214860
- "\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588",
214861
- "\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588 \u2588\u2588"
215079
+ " _ _____ _ _ _____ _ _ _ ",
215080
+ " / \\|_ _| | | | ____| \\ | | / \\ ",
215081
+ " / _ \\ | | | |_| | _| | \\| | / _ \\ ",
215082
+ " / ___ \\| | | _ | |___| |\\ |/ ___ \\",
215083
+ "/_/ \\_\\_| |_| |_|_____|_| \\_/_/ \\_\\"
214862
215084
  ];
214863
215085
  var BANNER_COMPACT = [
214864
215086
  "\u2584\u2580\u2588 \u2580\u2588\u2580 \u2588 \u2588 \u2588\u2580\u2580 \u2588\u2584 \u2588 \u2584\u2580\u2588",
@@ -214867,10 +215089,12 @@ var BANNER_COMPACT = [
214867
215089
  function printBanner() {
214868
215090
  if (!process.stdout.isTTY) return;
214869
215091
  const cols = process.stdout.columns ?? 80;
214870
- const banner = cols >= 56 ? BANNER_LARGE : BANNER_COMPACT;
215092
+ const useLarge = cols >= 56;
215093
+ const banner = useLarge ? BANNER_LARGE : BANNER_COMPACT;
214871
215094
  console.log("");
214872
215095
  for (const line of banner) {
214873
- console.log(` ${c2.accent}${line}${c2.reset}`);
215096
+ const style = useLarge ? `${c2.accent}${c2.bold}` : c2.accent;
215097
+ console.log(` ${style}${line}${c2.reset}`);
214874
215098
  }
214875
215099
  }
214876
215100
  function dashedLine(width) {
@@ -214883,6 +215107,9 @@ function truncate(value, max) {
214883
215107
  }
214884
215108
 
214885
215109
  // src/utils/terminal.ts
215110
+ function clearScreen() {
215111
+ process.stdout.write("\x1B[3J\x1B[2J\x1B[H");
215112
+ }
214886
215113
  function printRunHeader(mode, target) {
214887
215114
  const cols = Math.min(process.stdout.columns ?? 80, 72);
214888
215115
  printBanner();
@@ -214906,8 +215133,13 @@ function printRunResult(blocked) {
214906
215133
  // src/commands/check.ts
214907
215134
  async function checkCommand(files, options) {
214908
215135
  const selected = files.length > 0 ? files : await getStagedFiles();
214909
- const sourceFiles = selected.filter(isSourceFile).map((file) => (0, import_node_path2.resolve)(process.cwd(), file));
214910
- printRunHeader("check", `${sourceFiles.length} staged/source files`);
215136
+ const sourceFiles = selected.filter(isSourceFile).map((file) => (0, import_node_path3.resolve)(process.cwd(), file));
215137
+ if (!options.quietHeader) {
215138
+ if (process.stdout.isTTY) {
215139
+ clearScreen();
215140
+ }
215141
+ printRunHeader("check", `${sourceFiles.length} staged/source files`);
215142
+ }
214911
215143
  const expanded = sourceFiles.length === 1 ? await findSourceFiles(sourceFiles[0]) : sourceFiles;
214912
215144
  const report = await scanFiles(expanded, { threshold: Number(options.threshold) });
214913
215145
  if (options.format === "json") {
@@ -214917,13 +215149,21 @@ async function checkCommand(files, options) {
214917
215149
  } else {
214918
215150
  console.log(formatTerminalReport(report));
214919
215151
  }
215152
+ await appendScanHistory({
215153
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
215154
+ mode: "check",
215155
+ target: `${sourceFiles.length} staged/source files`,
215156
+ blocked: report.summary.blocked,
215157
+ filesScanned: report.summary.filesScanned,
215158
+ aiScore: report.summary.aiScore
215159
+ });
214920
215160
  printRunResult(report.summary.blocked);
214921
215161
  process.exitCode = report.summary.blocked ? 1 : 0;
214922
215162
  }
214923
215163
 
214924
215164
  // src/commands/init.ts
214925
- var import_promises4 = require("fs/promises");
214926
- var import_node_path3 = require("path");
215165
+ var import_promises5 = require("fs/promises");
215166
+ var import_node_path4 = require("path");
214927
215167
  async function initCommand() {
214928
215168
  const root = await getGitRoot();
214929
215169
  if (!root) {
@@ -214931,14 +215171,14 @@ async function initCommand() {
214931
215171
  process.exitCode = 1;
214932
215172
  return;
214933
215173
  }
214934
- const hookPath = (0, import_node_path3.join)(root, ".git", "hooks", "pre-commit");
215174
+ const hookPath = (0, import_node_path4.join)(root, ".git", "hooks", "pre-commit");
214935
215175
  const hook = [
214936
215176
  "#!/bin/sh",
214937
215177
  'echo "athena: checking staged JS/TS files"',
214938
215178
  "npx athena check"
214939
215179
  ].join("\n");
214940
- await (0, import_promises4.mkdir)((0, import_node_path3.dirname)(hookPath), { recursive: true });
214941
- await (0, import_promises4.writeFile)(hookPath, `${hook}
215180
+ await (0, import_promises5.mkdir)((0, import_node_path4.dirname)(hookPath), { recursive: true });
215181
+ await (0, import_promises5.writeFile)(hookPath, `${hook}
214942
215182
  `, { mode: 493 });
214943
215183
  console.log(`Athena pre-commit hook installed at ${hookPath}`);
214944
215184
  }
@@ -214947,10 +215187,15 @@ async function initCommand() {
214947
215187
  var import_node_readline = require("readline");
214948
215188
 
214949
215189
  // src/commands/scan.ts
214950
- var import_node_path4 = require("path");
215190
+ var import_node_path5 = require("path");
214951
215191
  async function scanCommand(dir, options) {
214952
- const root = (0, import_node_path4.resolve)(process.cwd(), dir);
214953
- printRunHeader("scan", root);
215192
+ const root = (0, import_node_path5.resolve)(process.cwd(), dir);
215193
+ if (!options.quietHeader) {
215194
+ if (process.stdout.isTTY) {
215195
+ clearScreen();
215196
+ }
215197
+ printRunHeader("scan", root);
215198
+ }
214954
215199
  const files = await findSourceFiles(root);
214955
215200
  const report = await scanFiles(files, { threshold: Number(options.threshold) });
214956
215201
  if (options.format === "json") {
@@ -214960,13 +215205,21 @@ async function scanCommand(dir, options) {
214960
215205
  } else {
214961
215206
  console.log(formatTerminalReport(report));
214962
215207
  }
215208
+ await appendScanHistory({
215209
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
215210
+ mode: "scan",
215211
+ target: root,
215212
+ blocked: report.summary.blocked,
215213
+ filesScanned: report.summary.filesScanned,
215214
+ aiScore: report.summary.aiScore
215215
+ });
214963
215216
  printRunResult(report.summary.blocked);
214964
215217
  process.exitCode = report.summary.blocked ? 1 : 0;
214965
215218
  }
214966
215219
 
214967
215220
  // src/commands/uninstall.ts
214968
- var import_promises5 = require("fs/promises");
214969
- var import_node_path5 = require("path");
215221
+ var import_promises6 = require("fs/promises");
215222
+ var import_node_path6 = require("path");
214970
215223
  async function uninstallCommand() {
214971
215224
  const root = await getGitRoot();
214972
215225
  if (!root) {
@@ -214974,15 +215227,15 @@ async function uninstallCommand() {
214974
215227
  process.exitCode = 1;
214975
215228
  return;
214976
215229
  }
214977
- const hookPath = (0, import_node_path5.join)(root, ".git", "hooks", "pre-commit");
214978
- await (0, import_promises5.rm)(hookPath, { force: true });
215230
+ const hookPath = (0, import_node_path6.join)(root, ".git", "hooks", "pre-commit");
215231
+ await (0, import_promises6.rm)(hookPath, { force: true });
214979
215232
  console.log(`Athena pre-commit hook removed from ${hookPath}`);
214980
215233
  }
214981
215234
 
214982
215235
  // package.json
214983
215236
  var package_default = {
214984
215237
  name: "@arsh342/athena",
214985
- version: "0.1.3",
215238
+ version: "0.1.5",
214986
215239
  description: "AI code provenance tracker and terminal scanner for JavaScript and TypeScript repositories.",
214987
215240
  type: "module",
214988
215241
  bin: {
@@ -214998,7 +215251,8 @@ var package_default = {
214998
215251
  files: [
214999
215252
  "dist",
215000
215253
  "README.md",
215001
- "LICENSE"
215254
+ "LICENSE",
215255
+ "null-pointer-font"
215002
215256
  ],
215003
215257
  keywords: [
215004
215258
  "ai",
@@ -215048,14 +215302,14 @@ async function menuCommand(program3) {
215048
215302
  desc: "Run full recursive JS/TS scan from cwd.",
215049
215303
  command: "athena scan .",
215050
215304
  detail: "Parse code units, score AI provenance, run targeted security checks, print report.",
215051
- run: () => scanCommand(".", { threshold: "65", format: "terminal" })
215305
+ run: () => scanCommand(".", { threshold: "9", format: "terminal", quietHeader: true })
215052
215306
  },
215053
215307
  {
215054
215308
  label: "Check staged files",
215055
215309
  desc: "Scan staged JS/TS files, same path used by pre-commit hook.",
215056
215310
  command: "athena check",
215057
215311
  detail: "Fast gate for commit flow. Reads git staged files and exits 1 on blocking risk.",
215058
- run: () => checkCommand([], { threshold: "65", format: "terminal" })
215312
+ run: () => checkCommand([], { threshold: "9", format: "terminal", quietHeader: true })
215059
215313
  },
215060
215314
  {
215061
215315
  label: "Install pre-commit hook",
@@ -215086,22 +215340,30 @@ async function menuCommand(program3) {
215086
215340
  run: () => void 0
215087
215341
  }
215088
215342
  ];
215089
- const choice = await select(items);
215090
- if (choice === null || items[choice]?.label === "Exit") {
215091
- console.log(`
215343
+ enterAltScreen();
215344
+ try {
215345
+ while (true) {
215346
+ const choice = await select(items);
215347
+ if (choice === null || items[choice]?.label === "Exit") {
215348
+ break;
215349
+ }
215350
+ clear();
215351
+ await items[choice].run();
215352
+ }
215353
+ } finally {
215354
+ exitAltScreen();
215355
+ }
215356
+ console.log(`
215092
215357
  ${c2.dim}athena selector closed${c2.reset}
215093
215358
  `);
215094
- return;
215095
- }
215096
- clear();
215097
- await items[choice].run();
215098
215359
  }
215099
215360
  async function select(items) {
215361
+ const historyText = formatRecentHistory(await getRecentScanHistory(3));
215100
215362
  (0, import_node_readline.emitKeypressEvents)(process.stdin);
215101
215363
  process.stdin.setRawMode(true);
215102
215364
  process.stdin.resume();
215103
215365
  let index = 0;
215104
- render(items, index);
215366
+ render(items, index, historyText);
215105
215367
  return new Promise((resolve3) => {
215106
215368
  const cleanup = () => {
215107
215369
  process.stdin.setRawMode(false);
@@ -215117,11 +215379,11 @@ async function select(items) {
215117
215379
  if (key.name === "q" || key.name === "escape") done(null);
215118
215380
  if (key.name === "up") {
215119
215381
  index = (index - 1 + items.length) % items.length;
215120
- render(items, index);
215382
+ render(items, index, historyText);
215121
215383
  }
215122
215384
  if (key.name === "down") {
215123
215385
  index = (index + 1) % items.length;
215124
- render(items, index);
215386
+ render(items, index, historyText);
215125
215387
  }
215126
215388
  if (key.name === "return") done(index);
215127
215389
  const number = Number(key.sequence);
@@ -215132,7 +215394,7 @@ async function select(items) {
215132
215394
  process.stdin.on("keypress", onKeypress);
215133
215395
  });
215134
215396
  }
215135
- function render(items, selected) {
215397
+ function render(items, selected, historyText) {
215136
215398
  clear();
215137
215399
  const cols = Math.min(process.stdout.columns ?? 80, 72);
215138
215400
  const selectedItem = items[selected];
@@ -215144,6 +215406,7 @@ function render(items, selected) {
215144
215406
  console.log(` ${dashedLine(cols - 4)}`);
215145
215407
  console.log("");
215146
215408
  console.log(` ${c2.dim}\u2191/\u2193${c2.reset} navigate ${c2.dim}enter${c2.reset} run ${c2.dim}1-${items.length}${c2.reset} jump ${c2.dim}q${c2.reset} quit`);
215409
+ console.log(` ${c2.dim}${truncate(historyText, cols - 4)}${c2.reset}`);
215147
215410
  console.log("");
215148
215411
  for (let i = 0; i < items.length; i++) {
215149
215412
  const item = items[i];
@@ -215164,7 +215427,13 @@ function render(items, selected) {
215164
215427
  console.log("");
215165
215428
  }
215166
215429
  function clear() {
215167
- process.stdout.write("\x1B[2J\x1B[H");
215430
+ clearScreen();
215431
+ }
215432
+ function enterAltScreen() {
215433
+ process.stdout.write("\x1B[?1049h");
215434
+ }
215435
+ function exitAltScreen() {
215436
+ process.stdout.write("\x1B[?1049l");
215168
215437
  }
215169
215438
  function pad(n) {
215170
215439
  return " ".repeat(Math.max(1, n));
@@ -215173,12 +215442,15 @@ function pad(n) {
215173
215442
  // src/index.ts
215174
215443
  var program2 = new Command();
215175
215444
  program2.name("athena").description("AI code provenance tracker for JavaScript and TypeScript repositories").version(CLI_VERSION);
215176
- program2.command("scan").argument("[dir]", "directory to scan", ".").option("-t, --threshold <number>", "AI score threshold", "65").option("-f, --format <format>", "terminal | json | jsonl", "terminal").description("scan a directory recursively").action(scanCommand);
215177
- program2.command("check").argument("[files...]", "files to check; defaults to staged JS/TS files").option("-t, --threshold <number>", "AI score threshold", "65").option("-f, --format <format>", "terminal | json | jsonl", "terminal").description("check changed files for blocking findings").action(checkCommand);
215445
+ program2.command("scan").argument("[dir]", "directory to scan", ".").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").description("scan a directory recursively").action(scanCommand);
215446
+ program2.command("check").argument("[files...]", "files to check; defaults to staged JS/TS files").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").description("check changed files for blocking findings").action(checkCommand);
215178
215447
  program2.command("init").description("install Athena pre-commit hook").action(initCommand);
215179
215448
  program2.command("uninstall").description("remove Athena pre-commit hook").action(uninstallCommand);
215180
215449
  program2.command("menu").description("open interactive terminal selector").action(() => menuCommand(program2));
215181
215450
  async function main() {
215451
+ if (process.stdout.isTTY) {
215452
+ clearScreen();
215453
+ }
215182
215454
  if (process.argv.length <= 2) {
215183
215455
  await menuCommand(program2);
215184
215456
  } else {
@@ -0,0 +1,2 @@
1
+ license: Freeware
2
+ link: https://www.fontspace.com/null-pointer-font-f2192
@@ -0,0 +1,68 @@
1
+ [ Divide By Zero ] Fonts
2
+ http://fonts.tom7.com/
3
+
4
+ I am employing a very generous license with these fonts (the way I
5
+ think most software should be) for a number of reasons. Mainly though,
6
+ it is because I would be making fonts regardless of whether I was
7
+ distributing them or not, and because I know that people benefit from
8
+ the fact that I give them away. I take enough stuff for free and it
9
+ makes me feel good to know that I am 'giving back'.
10
+
11
+ Here is the license. You are free to download and use these fonts
12
+ without my explicit permission for anything you want, except for the
13
+ following:
14
+
15
+ You may NOT* resell the actual font files (without my written
16
+ permission and without having to give me something in
17
+ return). This includes but is not limited to selling it on a Font
18
+ CD (even when the fee involved is a nominal "distribution" or
19
+ "handling" fee, or some similar thing), or distributing it on a
20
+ site which charges a fee per font download. (In contrast, a
21
+ pay-per-hour service such as America Online is free to distribute
22
+ the fonts.) You may not misrepresent the creator of the font
23
+ (pretend you made them) You may not adapt them to different fonts
24
+ without my permission. You may not modify the font files for
25
+ subsequent redistribution.
26
+
27
+ However, you have permission to do the following:
28
+ Use them to make graphics for your home page, non-profit web page,
29
+ or commerical web site.
30
+ Give them to your friends for free.
31
+ Make them available (for free) on your web page, as long as you make
32
+ clear where they came from.
33
+ Use them in design work that you get paid for.
34
+ Use them in any smalltime publications or fliers or other non
35
+ mass-produced literature.
36
+ Make commercial products like T-shirts or Mugs or Books using the
37
+ fonts and sell them. In this case, since you are indirectly
38
+ profiting off of my work, I ask that you send me one of the T-shirts
39
+ or Mugs or Books free, where reasonable. Obviously some discretion
40
+ on your part is due; but try to be fair. If it is inappropriate for
41
+ you to send me one of your product, at least make an attempt to
42
+ write me an e-mail at imightbetm@aol.com and let me know where the
43
+ font is being used.
44
+
45
+ * "Not", as in, "Not without my permission". I regularly give
46
+ permission for this sort of thing, so if you want to redistribute
47
+ the fonts for a fee, let me know and we can probably work something
48
+ out. Generally I simply request a copy of the CD or magazine or
49
+ whatever.
50
+
51
+ Exception to the above: The fonts (or converted versions of the fonts)
52
+ may be included on any recognized distribution of the Linux operating
53
+ system, even if the CD is sold. Please include this README file.
54
+ In addition, explicit permission is given for simtel.net, cdrom.com
55
+ and their partners to distribute this collection on physical medium.
56
+
57
+ For your information, here is my permanent address:
58
+
59
+ Tom Murphy 7
60
+ 339 Still Hill Rd
61
+ Hamden CT 06518.1830
62
+ USA
63
+
64
+ My e-mail address is: imightbetm(a)aol.com
65
+
66
+ The full [ Divide By Zero ] collection is always available at:
67
+
68
+ http://fonts.tom7.com/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arsh342/athena",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AI code provenance tracker and terminal scanner for JavaScript and TypeScript repositories.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,7 +16,8 @@
16
16
  "files": [
17
17
  "dist",
18
18
  "README.md",
19
- "LICENSE"
19
+ "LICENSE",
20
+ "null-pointer-font"
20
21
  ],
21
22
  "keywords": [
22
23
  "ai",