@h-rig/docs-drift-plugin 0.0.6-alpha.157 → 0.0.6-alpha.158

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.
@@ -395,9 +395,6 @@ function requireNoExtraArgs(args, usage) {
395
395
  throw new Error(`Unexpected argument: ${args[0]}
396
396
  Usage: ${usage}`);
397
397
  }
398
- function parseCsv(value) {
399
- return value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
400
- }
401
398
  function driftSummary(report) {
402
399
  const highConfidence = highConfidenceDriftFindings(report).length;
403
400
  return { total: report.findings.length, highConfidence, degraded: report.degraded };
@@ -408,8 +405,8 @@ async function executeDrift(context, args, options = {}) {
408
405
  const ignore = takeOption(docs.rest, "--ignore");
409
406
  const failOnDrift = takeFlag(ignore.rest, "--fail-on-drift");
410
407
  requireNoExtraArgs(failOnDrift.rest, "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]");
411
- const docsGlobs = parseCsv(docs.value);
412
- const ignoreGlobs = parseCsv(ignore.value);
408
+ const docsGlobs = docs.value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
409
+ const ignoreGlobs = ignore.value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
413
410
  const effectiveDocsGlobs = docsGlobs.length > 0 ? docsGlobs : options.docsGlobs;
414
411
  const effectiveIgnoreGlobs = ignoreGlobs.length > 0 ? ignoreGlobs : options.ignoreGlobs;
415
412
  const effectiveFailOnDrift = failOnDrift.value || options.failOnDrift === true;
@@ -444,9 +444,6 @@ function requireNoExtraArgs(args, usage) {
444
444
  throw new Error(`Unexpected argument: ${args[0]}
445
445
  Usage: ${usage}`);
446
446
  }
447
- function parseCsv(value) {
448
- return value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
449
- }
450
447
  function driftSummary(report) {
451
448
  const highConfidence = highConfidenceDriftFindings(report).length;
452
449
  return { total: report.findings.length, highConfidence, degraded: report.degraded };
@@ -457,8 +454,8 @@ async function executeDrift(context, args, options = {}) {
457
454
  const ignore = takeOption(docs.rest, "--ignore");
458
455
  const failOnDrift = takeFlag(ignore.rest, "--fail-on-drift");
459
456
  requireNoExtraArgs(failOnDrift.rest, "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]");
460
- const docsGlobs = parseCsv(docs.value);
461
- const ignoreGlobs = parseCsv(ignore.value);
457
+ const docsGlobs = docs.value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
458
+ const ignoreGlobs = ignore.value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? [];
462
459
  const effectiveDocsGlobs = docsGlobs.length > 0 ? docsGlobs : options.docsGlobs;
463
460
  const effectiveIgnoreGlobs = ignoreGlobs.length > 0 ? ignoreGlobs : options.ignoreGlobs;
464
461
  const effectiveFailOnDrift = failOnDrift.value || options.failOnDrift === true;
@@ -622,34 +619,19 @@ function createStandardDocsDriftPlugin(opts = {}) {
622
619
  name: "@rig/standard-plugin:docs-drift",
623
620
  version: "0.1.0",
624
621
  contributes: {
625
- validators: [DOCS_DRIFT_VALIDATOR],
622
+ validators: [createLazyDocsDriftValidator(opts)],
626
623
  capabilities: [
627
624
  { id: DOCS_DRIFT_CAPABILITY_ID, title: "Documentation drift detection", commandId: DOCS_DRIFT_CLI_ID, panelId: DOCS_HEALTH_PANEL_ID }
628
625
  ],
629
626
  panels: [
630
- { id: DOCS_HEALTH_PANEL_ID, slot: "capability", title: "Documentation drift", capabilityId: DOCS_DRIFT_CAPABILITY_ID }
627
+ { id: DOCS_HEALTH_PANEL_ID, slot: "capability", title: "Documentation drift", capabilityId: DOCS_DRIFT_CAPABILITY_ID, produce: createDocsHealthPanelProducer(opts) }
631
628
  ],
632
- cliCommands: [
633
- {
634
- id: DOCS_DRIFT_CLI_ID,
635
- family: "drift",
636
- command: DOCS_DRIFT_CLI_COMMAND,
637
- description: "Scan documentation for stale code references.",
638
- projectRequired: true
639
- }
629
+ cliCommands: [createLazyDocsDriftRuntimeCliCommand(opts)],
630
+ stages: [
631
+ { id: DOCS_DRIFT_STAGE_ID, kind: "gate", priority: 0, protected: false, run: createLazyDocsDriftGateStage(opts) }
640
632
  ],
641
633
  stageMutations: [DOCS_DRIFT_STAGE_MUTATION]
642
634
  }
643
- }, {
644
- validators: [createLazyDocsDriftValidator(opts)],
645
- stages: { [DOCS_DRIFT_STAGE_ID]: createLazyDocsDriftGateStage(opts) },
646
- featureCapabilities: [
647
- { id: DOCS_DRIFT_CAPABILITY_ID, title: "Documentation drift detection", commandId: DOCS_DRIFT_CLI_ID, panelId: DOCS_HEALTH_PANEL_ID }
648
- ],
649
- panels: [
650
- { id: DOCS_HEALTH_PANEL_ID, slot: "capability", title: "Documentation drift", capabilityId: DOCS_DRIFT_CAPABILITY_ID, produce: createDocsHealthPanelProducer(opts) }
651
- ],
652
- cliCommands: [createLazyDocsDriftRuntimeCliCommand(opts)]
653
635
  });
654
636
  }
655
637
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/docs-drift-plugin",
3
- "version": "0.0.6-alpha.157",
3
+ "version": "0.0.6-alpha.158",
4
4
  "type": "module",
5
5
  "description": "First-party documentation drift detection capability plugin for Rig.",
6
6
  "license": "UNLICENSED",
@@ -26,8 +26,8 @@
26
26
  "bun": ">=1.3.11"
27
27
  },
28
28
  "dependencies": {
29
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.157",
30
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.157",
29
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.158",
30
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.158",
31
31
  "effect": "4.0.0-beta.90"
32
32
  }
33
33
  }
@@ -1,24 +0,0 @@
1
- import type { DriftConfidence, DriftFinding, DriftKind, DriftReport } from "@rig/contracts";
2
- export interface DriftScanInput {
3
- readonly projectRoot: string;
4
- readonly docsGlobs?: readonly string[];
5
- readonly ignoreGlobs?: readonly string[];
6
- readonly judge?: boolean;
7
- }
8
- export type DriftDetector = (input: DriftScanInput) => Promise<DriftReport> | DriftReport;
9
- export interface DriftSummary {
10
- readonly total: number;
11
- readonly highConfidence: number;
12
- readonly byKind: Readonly<Record<DriftKind, number>>;
13
- readonly byConfidence: Readonly<Record<DriftConfidence, number>>;
14
- readonly degraded: boolean;
15
- }
16
- export declare function runDriftScan(projectRoot: string, deps: {
17
- readonly detectDrift: DriftDetector;
18
- }, options?: Omit<DriftScanInput, "projectRoot">): Promise<DriftReport>;
19
- export declare function summarizeDriftReport(report: DriftReport): DriftSummary;
20
- export declare function driftFindingsByDocument(report: DriftReport): ReadonlyMap<string, readonly DriftFinding[]>;
21
- export declare function shouldFailOnDrift(report: DriftReport, options?: {
22
- readonly failOnDrift?: boolean;
23
- readonly minimumConfidence?: DriftConfidence;
24
- }): boolean;
@@ -1,42 +0,0 @@
1
- // @bun
2
- // packages/docs-drift-plugin/src/drift/summary.ts
3
- var DRIFT_KINDS = ["deleted-reference", "stale-anchor", "semantic-mismatch", "issue-mismatch"];
4
- var DRIFT_CONFIDENCES = ["high", "medium", "low"];
5
- async function runDriftScan(projectRoot, deps, options = {}) {
6
- return deps.detectDrift({ projectRoot, ...options });
7
- }
8
- function summarizeDriftReport(report) {
9
- const byKind = Object.fromEntries(DRIFT_KINDS.map((kind) => [kind, 0]));
10
- const byConfidence = Object.fromEntries(DRIFT_CONFIDENCES.map((confidence) => [confidence, 0]));
11
- for (const finding of report.findings) {
12
- byKind[finding.kind] += 1;
13
- byConfidence[finding.confidence] += 1;
14
- }
15
- return {
16
- total: report.findings.length,
17
- highConfidence: byConfidence.high,
18
- byKind,
19
- byConfidence,
20
- degraded: report.degraded
21
- };
22
- }
23
- function driftFindingsByDocument(report) {
24
- const grouped = new Map;
25
- for (const finding of report.findings) {
26
- grouped.set(finding.docPath, [...grouped.get(finding.docPath) ?? [], finding]);
27
- }
28
- return new Map([...grouped.entries()].map(([path, findings]) => [path, findings.toSorted((left, right) => (left.line ?? 0) - (right.line ?? 0))]));
29
- }
30
- function shouldFailOnDrift(report, options = {}) {
31
- if (!options.failOnDrift)
32
- return false;
33
- const threshold = options.minimumConfidence ?? "high";
34
- const rank = { high: 3, medium: 2, low: 1 };
35
- return report.findings.some((finding) => rank[finding.confidence] >= rank[threshold]);
36
- }
37
- export {
38
- summarizeDriftReport,
39
- shouldFailOnDrift,
40
- runDriftScan,
41
- driftFindingsByDocument
42
- };