slopbrick 0.41.0 → 0.42.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/index.d.cts CHANGED
@@ -776,6 +776,101 @@ interface Rule<Context = unknown> {
776
776
  create(context: RuleContext): Context;
777
777
  analyze(context: Context, facts: ScanFacts): Issue[];
778
778
  }
779
+ /**
780
+ * v0.42.0 (Sprint 3, task 3b.1): composite rule type. A composite
781
+ * fires when *at least `minMatch`* of its member `ruleIds` fire on the
782
+ * same file. Members are referenced by their existing `Rule.id`.
783
+ *
784
+ * Structurally parallel to `Rule<Context>` so the `RuleRegistry`
785
+ * treats it uniformly: same `create` + `analyze` lifecycle, same
786
+ * `defaultOff` opt-in semantics, same `severity` for reporter
787
+ * weighting. The engine wires composites after per-file `RuleRegistry`
788
+ * (see `engine/worker.ts` + task 3b.5).
789
+ *
790
+ * Design choice: `CompositeRule<Context>` is its own interface rather
791
+ * than a `Rule<Context>` variant because (a) it carries member-rule
792
+ * metadata (`ruleIds`, `minMatch`) that vanilla rules do not, and
793
+ * (b) the union of the two types would force every consumer to
794
+ * narrow, defeating the structural-parallelism goal.
795
+ */
796
+ interface CompositeRule<Context = unknown> {
797
+ id: string;
798
+ category: Category;
799
+ severity: Severity;
800
+ aiSpecific: boolean;
801
+ /** Short description shown by `slopbrick rules`. */
802
+ description?: string;
803
+ /** v0.42.0: composite rules are opt-in by default. */
804
+ defaultOff?: boolean;
805
+ /** Member rule IDs (sorted, unique). The composite fires when
806
+ * at least `minMatch` of these fire on the same file. */
807
+ ruleIds: string[];
808
+ /** Minimum number of `ruleIds` that must fire together. */
809
+ minMatch: number;
810
+ create(context: RuleContext): Context;
811
+ analyze(context: Context, facts: ScanFacts): Issue[];
812
+ }
813
+ /**
814
+ * v0.42.0 (Sprint 3, task 3b.3): clusterer-emitted composite rule
815
+ * entry. The shape that `engine/cluster.ts` produces and that the
816
+ * `RuleRegistry` loader materializes into `CompositeRule<Context>`
817
+ * instances. Lives next to `CompositeRule<Context>` so the public
818
+ * type surface for empirical composites is in one place.
819
+ *
820
+ * Fields mirror the spec in `docs/superpowers/sprint-0.41-0.42.md`
821
+ * §3b STEP 5: id, ruleIds, minMatch, severity, defaultOff,
822
+ * description, calibration, provenance.
823
+ */
824
+ interface CompositeRuleEntry {
825
+ id: string;
826
+ ruleIds: string[];
827
+ minMatch: number;
828
+ severity: Severity;
829
+ defaultOff: true;
830
+ description: string;
831
+ calibration: {
832
+ recall: number;
833
+ /** False-positive rate, FP / neg_count. */
834
+ FP: number;
835
+ precision: number;
836
+ F1: number;
837
+ nFiles: number;
838
+ };
839
+ provenance: {
840
+ seed: 'auto-cluster' | 'hand-curated-by-brief';
841
+ discoveredAt: string;
842
+ nFiles: number;
843
+ members: number;
844
+ /** Strongest NPMI edge among cluster members (0 if singleton). */
845
+ npmi: number;
846
+ /** Strongest-edge Fisher's p (1 if singleton). */
847
+ fisherP: number;
848
+ };
849
+ }
850
+ /**
851
+ * v0.42.0 (Sprint 3, task 3b.2): input to the empirical composite
852
+ * clusterer. `fireMatrix` is the per-file fired-rule-set map; the
853
+ * other fields are optional inputs to STEP 4 calibration.
854
+ */
855
+ interface ClusterInput {
856
+ /** Per-file fired-rule-set map (file id → set of rule IDs that fired). */
857
+ fireMatrix: ReadonlyMap<string, ReadonlySet<string>>;
858
+ /** Positive (gold-standard) file IDs for recall/precision. */
859
+ positiveFiles?: ReadonlySet<string>;
860
+ /** Severity of each member rule; used to pick `severity = worst`. */
861
+ memberSeverities?: ReadonlyMap<string, Severity>;
862
+ /** Algorithm parameter overrides (all optional). */
863
+ params?: ClusterParamOverrides;
864
+ /** ISO timestamp embedded in `provenance.discoveredAt` for tests. */
865
+ now?: string;
866
+ }
867
+ type ClusterParams = {
868
+ minSupport: number;
869
+ minNPMI: number;
870
+ fisherAlpha: number;
871
+ minClusterSize: number;
872
+ };
873
+ type ClusterParamOverrides = Partial<ClusterParams>;
779
874
  interface ResolvedConfig {
780
875
  framework?: string;
781
876
  hasTailwind?: boolean;
@@ -1612,6 +1707,13 @@ interface ScanProjectOptions {
1612
1707
  noIncrease?: boolean;
1613
1708
  cache?: boolean;
1614
1709
  telemetry?: boolean;
1710
+ /** v0.42.0 (§3a.4): opt-in flag for the AGENTS.md auto-refresh hook.
1711
+ * When true, `slopbrick scan` writes the freshly-built snippet body
1712
+ * inside the `<!-- slopbrick:begin:v3 --> ... -->` block in
1713
+ * AGENTS.md / CLAUDE.md, replacing only that block (user-edited
1714
+ * content outside the markers is preserved). Default false so
1715
+ * first-time users aren't surprised. */
1716
+ autoRefreshSnippets?: boolean;
1615
1717
  }
1616
1718
 
1617
1719
  declare function scanProject(options: ScanProjectOptions): Promise<ProjectReport>;
@@ -1674,4 +1776,4 @@ declare function formatBadge(report: ProjectReport): string;
1674
1776
  /** Render an array of values as a Unicode sparkline (▁▂▃▄▅▆▇█). */
1675
1777
  declare function formatSparkline(values: number[]): string;
1676
1778
 
1677
- export { AI_SECURITY_NUMERIC, type AiDebt, type AiMaintenanceCost, type AiMaintenanceCostResult, type AstroComponentFact, type AutoRelaxedRule, type AutoTunedRule, type BaselineCache, type BaselineMeta, type CachedFile, type Category, type ClassNameFact, type CommentFact, type ComponentFacts, type ComponentScore, type ComponentSizeFact, type ConsoleCallFact, type Constitution, DEFAULT_CONFIG, type DangerouslySetInnerHtmlFact, type DbDriftLevel, type DbFinding, type DialogCallFact, type DisabledLintRuleFact, type DocDriftLevel, type DocFinding, type DomQueryFact, type ElementFact, type EvalCallFact, type ExplicitAnyFact, type FetchCallFact, type FileScanResult, type FixSuggestion, type FlywheelOutput, type FlywheelState, type Framework$1 as Framework, type HealthFile, type HookCallFact, type HookDependencyArrayFact, type HookFact, type ImportFact, type InlineEventHandlerFact, type Issue, type JsxAttributeStringLiteralFact, type JsxTextLiteralFact, type KeyPropFact, type LogicalExpressionFact, type MagicNumberSpacingConfig, type MaintenanceAxes, type MaintenanceAxisHealth, type NonNullAssertionFact, type OptimisticUpdateFact, type ProjectReport, type PropMutationFact, type PropPassThroughFact, REPOSITORY_HEALTH_WEIGHTS, type ReportReadResult, type RepositoryHealth, type RepositoryHealthInputs, type ResearchMetrics, type ResolvedConfig, type Rule, type RuleContext, type RuleSeverity, type RuleSuggestion, type ScanCache, type ScanFacts, type ScanProjectOptions, type ScanSelfScanConfig, type Severity, type SlopAuditRun, type StateBinding, type StateBindingFact, type StringLiteralFact, type StylePropFact, type TamaguiStylePropFact, type TopOffender, type UseEffectBodyFact, VERSION, baselineStatusMessage, colorForSlop, failedThresholdCount, filterByDisabledDirectives, filterIssues, formatBadge, formatReportFromFile, formatSparkline, loadConfig, readReportFile, runCli, runInitWizard, scanProject, serializeConfig, stagedGating, thresholdExceeded };
1779
+ export { AI_SECURITY_NUMERIC, type AiDebt, type AiMaintenanceCost, type AiMaintenanceCostResult, type AstroComponentFact, type AutoRelaxedRule, type AutoTunedRule, type BaselineCache, type BaselineMeta, type CachedFile, type Category, type ClassNameFact, type ClusterInput, type ClusterParamOverrides, type ClusterParams, type CommentFact, type ComponentFacts, type ComponentScore, type ComponentSizeFact, type CompositeRule, type CompositeRuleEntry, type ConsoleCallFact, type Constitution, DEFAULT_CONFIG, type DangerouslySetInnerHtmlFact, type DbDriftLevel, type DbFinding, type DialogCallFact, type DisabledLintRuleFact, type DocDriftLevel, type DocFinding, type DomQueryFact, type ElementFact, type EvalCallFact, type ExplicitAnyFact, type FetchCallFact, type FileScanResult, type FixSuggestion, type FlywheelOutput, type FlywheelState, type Framework$1 as Framework, type HealthFile, type HookCallFact, type HookDependencyArrayFact, type HookFact, type ImportFact, type InlineEventHandlerFact, type Issue, type JsxAttributeStringLiteralFact, type JsxTextLiteralFact, type KeyPropFact, type LogicalExpressionFact, type MagicNumberSpacingConfig, type MaintenanceAxes, type MaintenanceAxisHealth, type NonNullAssertionFact, type OptimisticUpdateFact, type ProjectReport, type PropMutationFact, type PropPassThroughFact, REPOSITORY_HEALTH_WEIGHTS, type ReportReadResult, type RepositoryHealth, type RepositoryHealthInputs, type ResearchMetrics, type ResolvedConfig, type Rule, type RuleContext, type RuleSeverity, type RuleSuggestion, type ScanCache, type ScanFacts, type ScanProjectOptions, type ScanSelfScanConfig, type Severity, type SlopAuditRun, type StateBinding, type StateBindingFact, type StringLiteralFact, type StylePropFact, type TamaguiStylePropFact, type TopOffender, type UseEffectBodyFact, VERSION, baselineStatusMessage, colorForSlop, failedThresholdCount, filterByDisabledDirectives, filterIssues, formatBadge, formatReportFromFile, formatSparkline, loadConfig, readReportFile, runCli, runInitWizard, scanProject, serializeConfig, stagedGating, thresholdExceeded };
package/dist/index.d.ts CHANGED
@@ -776,6 +776,101 @@ interface Rule<Context = unknown> {
776
776
  create(context: RuleContext): Context;
777
777
  analyze(context: Context, facts: ScanFacts): Issue[];
778
778
  }
779
+ /**
780
+ * v0.42.0 (Sprint 3, task 3b.1): composite rule type. A composite
781
+ * fires when *at least `minMatch`* of its member `ruleIds` fire on the
782
+ * same file. Members are referenced by their existing `Rule.id`.
783
+ *
784
+ * Structurally parallel to `Rule<Context>` so the `RuleRegistry`
785
+ * treats it uniformly: same `create` + `analyze` lifecycle, same
786
+ * `defaultOff` opt-in semantics, same `severity` for reporter
787
+ * weighting. The engine wires composites after per-file `RuleRegistry`
788
+ * (see `engine/worker.ts` + task 3b.5).
789
+ *
790
+ * Design choice: `CompositeRule<Context>` is its own interface rather
791
+ * than a `Rule<Context>` variant because (a) it carries member-rule
792
+ * metadata (`ruleIds`, `minMatch`) that vanilla rules do not, and
793
+ * (b) the union of the two types would force every consumer to
794
+ * narrow, defeating the structural-parallelism goal.
795
+ */
796
+ interface CompositeRule<Context = unknown> {
797
+ id: string;
798
+ category: Category;
799
+ severity: Severity;
800
+ aiSpecific: boolean;
801
+ /** Short description shown by `slopbrick rules`. */
802
+ description?: string;
803
+ /** v0.42.0: composite rules are opt-in by default. */
804
+ defaultOff?: boolean;
805
+ /** Member rule IDs (sorted, unique). The composite fires when
806
+ * at least `minMatch` of these fire on the same file. */
807
+ ruleIds: string[];
808
+ /** Minimum number of `ruleIds` that must fire together. */
809
+ minMatch: number;
810
+ create(context: RuleContext): Context;
811
+ analyze(context: Context, facts: ScanFacts): Issue[];
812
+ }
813
+ /**
814
+ * v0.42.0 (Sprint 3, task 3b.3): clusterer-emitted composite rule
815
+ * entry. The shape that `engine/cluster.ts` produces and that the
816
+ * `RuleRegistry` loader materializes into `CompositeRule<Context>`
817
+ * instances. Lives next to `CompositeRule<Context>` so the public
818
+ * type surface for empirical composites is in one place.
819
+ *
820
+ * Fields mirror the spec in `docs/superpowers/sprint-0.41-0.42.md`
821
+ * §3b STEP 5: id, ruleIds, minMatch, severity, defaultOff,
822
+ * description, calibration, provenance.
823
+ */
824
+ interface CompositeRuleEntry {
825
+ id: string;
826
+ ruleIds: string[];
827
+ minMatch: number;
828
+ severity: Severity;
829
+ defaultOff: true;
830
+ description: string;
831
+ calibration: {
832
+ recall: number;
833
+ /** False-positive rate, FP / neg_count. */
834
+ FP: number;
835
+ precision: number;
836
+ F1: number;
837
+ nFiles: number;
838
+ };
839
+ provenance: {
840
+ seed: 'auto-cluster' | 'hand-curated-by-brief';
841
+ discoveredAt: string;
842
+ nFiles: number;
843
+ members: number;
844
+ /** Strongest NPMI edge among cluster members (0 if singleton). */
845
+ npmi: number;
846
+ /** Strongest-edge Fisher's p (1 if singleton). */
847
+ fisherP: number;
848
+ };
849
+ }
850
+ /**
851
+ * v0.42.0 (Sprint 3, task 3b.2): input to the empirical composite
852
+ * clusterer. `fireMatrix` is the per-file fired-rule-set map; the
853
+ * other fields are optional inputs to STEP 4 calibration.
854
+ */
855
+ interface ClusterInput {
856
+ /** Per-file fired-rule-set map (file id → set of rule IDs that fired). */
857
+ fireMatrix: ReadonlyMap<string, ReadonlySet<string>>;
858
+ /** Positive (gold-standard) file IDs for recall/precision. */
859
+ positiveFiles?: ReadonlySet<string>;
860
+ /** Severity of each member rule; used to pick `severity = worst`. */
861
+ memberSeverities?: ReadonlyMap<string, Severity>;
862
+ /** Algorithm parameter overrides (all optional). */
863
+ params?: ClusterParamOverrides;
864
+ /** ISO timestamp embedded in `provenance.discoveredAt` for tests. */
865
+ now?: string;
866
+ }
867
+ type ClusterParams = {
868
+ minSupport: number;
869
+ minNPMI: number;
870
+ fisherAlpha: number;
871
+ minClusterSize: number;
872
+ };
873
+ type ClusterParamOverrides = Partial<ClusterParams>;
779
874
  interface ResolvedConfig {
780
875
  framework?: string;
781
876
  hasTailwind?: boolean;
@@ -1612,6 +1707,13 @@ interface ScanProjectOptions {
1612
1707
  noIncrease?: boolean;
1613
1708
  cache?: boolean;
1614
1709
  telemetry?: boolean;
1710
+ /** v0.42.0 (§3a.4): opt-in flag for the AGENTS.md auto-refresh hook.
1711
+ * When true, `slopbrick scan` writes the freshly-built snippet body
1712
+ * inside the `<!-- slopbrick:begin:v3 --> ... -->` block in
1713
+ * AGENTS.md / CLAUDE.md, replacing only that block (user-edited
1714
+ * content outside the markers is preserved). Default false so
1715
+ * first-time users aren't surprised. */
1716
+ autoRefreshSnippets?: boolean;
1615
1717
  }
1616
1718
 
1617
1719
  declare function scanProject(options: ScanProjectOptions): Promise<ProjectReport>;
@@ -1674,4 +1776,4 @@ declare function formatBadge(report: ProjectReport): string;
1674
1776
  /** Render an array of values as a Unicode sparkline (▁▂▃▄▅▆▇█). */
1675
1777
  declare function formatSparkline(values: number[]): string;
1676
1778
 
1677
- export { AI_SECURITY_NUMERIC, type AiDebt, type AiMaintenanceCost, type AiMaintenanceCostResult, type AstroComponentFact, type AutoRelaxedRule, type AutoTunedRule, type BaselineCache, type BaselineMeta, type CachedFile, type Category, type ClassNameFact, type CommentFact, type ComponentFacts, type ComponentScore, type ComponentSizeFact, type ConsoleCallFact, type Constitution, DEFAULT_CONFIG, type DangerouslySetInnerHtmlFact, type DbDriftLevel, type DbFinding, type DialogCallFact, type DisabledLintRuleFact, type DocDriftLevel, type DocFinding, type DomQueryFact, type ElementFact, type EvalCallFact, type ExplicitAnyFact, type FetchCallFact, type FileScanResult, type FixSuggestion, type FlywheelOutput, type FlywheelState, type Framework$1 as Framework, type HealthFile, type HookCallFact, type HookDependencyArrayFact, type HookFact, type ImportFact, type InlineEventHandlerFact, type Issue, type JsxAttributeStringLiteralFact, type JsxTextLiteralFact, type KeyPropFact, type LogicalExpressionFact, type MagicNumberSpacingConfig, type MaintenanceAxes, type MaintenanceAxisHealth, type NonNullAssertionFact, type OptimisticUpdateFact, type ProjectReport, type PropMutationFact, type PropPassThroughFact, REPOSITORY_HEALTH_WEIGHTS, type ReportReadResult, type RepositoryHealth, type RepositoryHealthInputs, type ResearchMetrics, type ResolvedConfig, type Rule, type RuleContext, type RuleSeverity, type RuleSuggestion, type ScanCache, type ScanFacts, type ScanProjectOptions, type ScanSelfScanConfig, type Severity, type SlopAuditRun, type StateBinding, type StateBindingFact, type StringLiteralFact, type StylePropFact, type TamaguiStylePropFact, type TopOffender, type UseEffectBodyFact, VERSION, baselineStatusMessage, colorForSlop, failedThresholdCount, filterByDisabledDirectives, filterIssues, formatBadge, formatReportFromFile, formatSparkline, loadConfig, readReportFile, runCli, runInitWizard, scanProject, serializeConfig, stagedGating, thresholdExceeded };
1779
+ export { AI_SECURITY_NUMERIC, type AiDebt, type AiMaintenanceCost, type AiMaintenanceCostResult, type AstroComponentFact, type AutoRelaxedRule, type AutoTunedRule, type BaselineCache, type BaselineMeta, type CachedFile, type Category, type ClassNameFact, type ClusterInput, type ClusterParamOverrides, type ClusterParams, type CommentFact, type ComponentFacts, type ComponentScore, type ComponentSizeFact, type CompositeRule, type CompositeRuleEntry, type ConsoleCallFact, type Constitution, DEFAULT_CONFIG, type DangerouslySetInnerHtmlFact, type DbDriftLevel, type DbFinding, type DialogCallFact, type DisabledLintRuleFact, type DocDriftLevel, type DocFinding, type DomQueryFact, type ElementFact, type EvalCallFact, type ExplicitAnyFact, type FetchCallFact, type FileScanResult, type FixSuggestion, type FlywheelOutput, type FlywheelState, type Framework$1 as Framework, type HealthFile, type HookCallFact, type HookDependencyArrayFact, type HookFact, type ImportFact, type InlineEventHandlerFact, type Issue, type JsxAttributeStringLiteralFact, type JsxTextLiteralFact, type KeyPropFact, type LogicalExpressionFact, type MagicNumberSpacingConfig, type MaintenanceAxes, type MaintenanceAxisHealth, type NonNullAssertionFact, type OptimisticUpdateFact, type ProjectReport, type PropMutationFact, type PropPassThroughFact, REPOSITORY_HEALTH_WEIGHTS, type ReportReadResult, type RepositoryHealth, type RepositoryHealthInputs, type ResearchMetrics, type ResolvedConfig, type Rule, type RuleContext, type RuleSeverity, type RuleSuggestion, type ScanCache, type ScanFacts, type ScanProjectOptions, type ScanSelfScanConfig, type Severity, type SlopAuditRun, type StateBinding, type StateBindingFact, type StringLiteralFact, type StylePropFact, type TamaguiStylePropFact, type TopOffender, type UseEffectBodyFact, VERSION, baselineStatusMessage, colorForSlop, failedThresholdCount, filterByDisabledDirectives, filterIssues, formatBadge, formatReportFromFile, formatSparkline, loadConfig, readReportFile, runCli, runInitWizard, scanProject, serializeConfig, stagedGating, thresholdExceeded };