@syv-ai/rulecast 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ADAPTERS,
4
+ adapterByName,
5
+ builtinDetectors,
6
+ createRegistry
7
+ } from "./chunk-C6C5EER7.js";
8
+ import {
4
9
  CONFIG_FILE,
5
10
  LockTimeoutError,
6
11
  MANIFEST_FILE,
7
12
  NO_PROMPT,
8
13
  RepoFetchError,
9
- VERSION,
10
- adapterByName,
11
14
  allFiles,
12
- builtinDetectors,
13
15
  cacheHome,
14
16
  cachedRepo,
15
17
  cachedRepos,
@@ -18,37 +20,41 @@ import {
18
20
  checkDetectors,
19
21
  compile,
20
22
  compileManifest,
21
- createRegistry,
22
23
  debugLogger,
23
24
  defaultConfig,
24
- detectorCacheDir,
25
25
  diagnosticText,
26
- diskCache,
27
26
  ensureProjectState,
28
27
  ensureRepo,
29
- errorMessage,
30
28
  fetchCheckout,
31
29
  fetchingRepos,
32
30
  fixedRepo,
33
31
  git,
34
- isNotFound,
35
- memoryCache,
36
32
  mergeBase,
37
33
  parseConfig,
38
- parseVersion,
39
34
  projectStateDir,
40
35
  readConfigData,
41
36
  readManifest,
42
- readSourceFile,
43
- renderAgentText,
44
37
  repoLabel,
38
+ rulesOfKind,
45
39
  runDetection,
46
40
  runPipeline,
47
- scanHeadings,
48
41
  stagedFiles,
49
- tagsOf,
50
42
  withLock
51
- } from "./chunk-3HRTZULM.js";
43
+ } from "./chunk-RODZRI7B.js";
44
+ import {
45
+ VERSION,
46
+ detectorCacheDir,
47
+ diskCache,
48
+ errorMessage,
49
+ isDetectorRule,
50
+ isNotFound,
51
+ memoryCache,
52
+ parseVersion,
53
+ readSourceFile,
54
+ renderAgentText,
55
+ scanHeadings,
56
+ tagsOf
57
+ } from "./chunk-ZEFEQKG5.js";
52
58
  import {
53
59
  Cancelled
54
60
  } from "./chunk-K37BHCEK.js";
@@ -477,7 +483,7 @@ async function dryRun(project, registry) {
477
483
  }
478
484
  const lines = [];
479
485
  for (const rule of project.rules) {
480
- if (rule.detector === null) {
486
+ if (!isDetectorRule(rule)) {
481
487
  lines.push({ rule: rule.id, level: "ok", detail: "context only, nothing to run" });
482
488
  continue;
483
489
  }
@@ -542,7 +548,7 @@ async function warmDetectors(options) {
542
548
  await Promise.all(
543
549
  kinds.map(async (kind) => {
544
550
  const detector = registry.get(kind);
545
- const rules = project.rules.filter((rule) => rule.detector?.kind === kind).map((rule) => ({ id: rule.id, config: rule.detector.config }));
551
+ const rules = rulesOfKind(project.rules, kind);
546
552
  try {
547
553
  await withLock(
548
554
  path4.join(stateDir, "warm", kind),
@@ -1245,7 +1251,9 @@ function terminal(delivery, options) {
1245
1251
  for (const finding of delivery.findings) {
1246
1252
  const count = shown.get(finding.rule) ?? 0;
1247
1253
  if (count >= options.maxMatchesPerRule) {
1248
- hidden.set(finding.rule, [...hidden.get(finding.rule) ?? [], finding]);
1254
+ const rest = hidden.get(finding.rule);
1255
+ if (rest === void 0) hidden.set(finding.rule, [finding]);
1256
+ else rest.push(finding);
1249
1257
  continue;
1250
1258
  }
1251
1259
  shown.set(finding.rule, count + 1);
@@ -1273,6 +1281,20 @@ function terminal(delivery, options) {
1273
1281
  );
1274
1282
  return out.join("\n");
1275
1283
  }
1284
+ function json(delivery) {
1285
+ return JSON.stringify(
1286
+ {
1287
+ findings: delivery.findings,
1288
+ preexistingSummary: delivery.preexistingSummary,
1289
+ references: delivery.references,
1290
+ touches: delivery.touches,
1291
+ warnings: delivery.warnings,
1292
+ stop: delivery.stop
1293
+ },
1294
+ null,
1295
+ 2
1296
+ );
1297
+ }
1276
1298
  function sarif(delivery) {
1277
1299
  const rules = [...new Set(delivery.findings.map((finding) => finding.rule))].map((id) => ({ id }));
1278
1300
  return JSON.stringify(
@@ -1309,7 +1331,7 @@ function formatDelivery(delivery, format, options) {
1309
1331
  case "agent":
1310
1332
  return renderAgentText(delivery, options);
1311
1333
  case "json":
1312
- return JSON.stringify(delivery, null, 2);
1334
+ return json(delivery);
1313
1335
  case "sarif":
1314
1336
  return sarif(delivery);
1315
1337
  }