yowtf 0.1.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.
@@ -0,0 +1,1337 @@
1
+ import { Command } from 'commander';
2
+ import os from 'node:os';
3
+
4
+ declare const APP_NAME = "yowtf";
5
+ declare const APP_FULL_NAME = "Your Operating Workstation Trouble Finder";
6
+ declare const APP_TAGLINE = "Yo, WTF is happening?";
7
+ declare const APP_VERSION = "0.1.0";
8
+ /**
9
+ * Creates and configures the complete Commander program for YOWTF.
10
+ * Registers global options and all 20 public V1 commands.
11
+ * Adheres to docs/CLI-SPEC.md and docs/COMMANDS.md.
12
+ */
13
+ declare function createProgram(): Command;
14
+ /**
15
+ * Executes the Commander program with the provided arguments.
16
+ * Returns process exit code:
17
+ * - 0: Success (or help/version output)
18
+ * - 1: Application/diagnostic failure
19
+ * - 2: CLI usage error (unknown command, unknown option, invalid path, etc.)
20
+ */
21
+ declare function runCli(argv?: string[]): Promise<number>;
22
+
23
+ /**
24
+ * CLI Error types and exit codes.
25
+ * Adheres to docs/CLI-SPEC.md Section 48 & Section 55.
26
+ */
27
+ declare const EXIT_SUCCESS = 0;
28
+ declare const EXIT_APPLICATION_ERROR = 1;
29
+ declare const EXIT_USAGE_ERROR = 2;
30
+ declare class CliError extends Error {
31
+ readonly exitCode: number;
32
+ constructor(message: string, exitCode?: number);
33
+ }
34
+ declare class CliUsageError extends CliError {
35
+ constructor(message: string);
36
+ }
37
+ /**
38
+ * Formats an error into a clean, human-readable message without exposing raw stack traces or secrets.
39
+ */
40
+ declare function formatCliError(error: unknown): string;
41
+
42
+ /**
43
+ * Global CLI options interface.
44
+ * Adheres to docs/CLI-SPEC.md Section 7.
45
+ */
46
+ interface GlobalOptions {
47
+ readonly verbose?: boolean;
48
+ readonly color?: boolean;
49
+ readonly json?: boolean;
50
+ readonly quiet?: boolean;
51
+ readonly path?: string;
52
+ }
53
+ /**
54
+ * Registers all authoritative global options on a Commander command.
55
+ */
56
+ declare function registerGlobalOptions(command: Command): void;
57
+
58
+ /**
59
+ * Resolves and validates the target directory path.
60
+ * If targetPath is not provided, defaults to normalized current working directory.
61
+ * If targetPath is provided, validates that it exists, is a directory, and is accessible.
62
+ * Throws CliUsageError (exit code 2) on failure.
63
+ * Adheres to docs/CLI-SPEC.md Section 15, 16, & 56.
64
+ */
65
+ declare function resolveAndValidatePath(rawPath?: string, cwd?: string): string;
66
+
67
+ interface DispatchOptions extends GlobalOptions {
68
+ readonly preview?: boolean;
69
+ }
70
+ /**
71
+ * Dispatches a parsed CLI command to the application layer.
72
+ * Normalizes global options and path, delegates to the application use case,
73
+ * and formats the resulting response according to presentation options.
74
+ */
75
+ declare function dispatchCommand(commandName: string, options: DispatchOptions, commandSpecificOptions?: Record<string, unknown>): Promise<number>;
76
+
77
+ /**
78
+ * Platform abstraction types and interfaces.
79
+ * Adheres to docs/ARCHITECTURE.md Section 5.5 and docs/TECH-STACK.md Section 40.
80
+ */
81
+ type SupportedPlatform = 'windows' | 'macos' | 'linux';
82
+ type PlatformType = SupportedPlatform | 'unsupported';
83
+ interface PlatformInfo {
84
+ readonly platform: PlatformType;
85
+ readonly isSupported: boolean;
86
+ readonly os: NodeJS.Platform;
87
+ readonly arch: string;
88
+ readonly release: string;
89
+ readonly hostname: string;
90
+ }
91
+ interface MemoryInfo {
92
+ readonly totalBytes: number;
93
+ readonly freeBytes: number;
94
+ readonly usedBytes: number;
95
+ readonly utilizationPercent: number;
96
+ }
97
+ interface CpuCoreInfo {
98
+ readonly model: string;
99
+ readonly speedMHz: number;
100
+ }
101
+ interface CpuInfo {
102
+ readonly model: string;
103
+ readonly cores: number;
104
+ readonly speedMHz?: number;
105
+ readonly utilizationPercent?: number;
106
+ }
107
+ interface UptimeInfo {
108
+ readonly uptimeSeconds: number;
109
+ }
110
+ interface SafeCommandOptions {
111
+ readonly timeoutMs?: number;
112
+ readonly cwd?: string;
113
+ readonly env?: NodeJS.ProcessEnv;
114
+ }
115
+ interface SafeCommandResult {
116
+ readonly stdout: string;
117
+ readonly stderr: string;
118
+ readonly exitCode: number;
119
+ readonly killed: boolean;
120
+ readonly durationMs: number;
121
+ }
122
+ /**
123
+ * Standard contract for operating-system-specific fact adapters.
124
+ * Implementations gather facts without calculating scores, creating findings,
125
+ * or mutating user state.
126
+ */
127
+ interface PlatformAdapter {
128
+ readonly platformType: PlatformType;
129
+ readonly isSupported: boolean;
130
+ getPlatformInfo(): PlatformInfo;
131
+ getMemoryInfo(): Promise<MemoryInfo> | MemoryInfo;
132
+ getCpuInfo(): Promise<CpuInfo> | CpuInfo;
133
+ getUptimeInfo(): UptimeInfo;
134
+ isCommandAvailable(command: string): Promise<boolean>;
135
+ }
136
+
137
+ /**
138
+ * Authoritative diagnostic categories.
139
+ * Adheres to docs/RULE-CATALOGUE.md Section 12 and docs/DETECTION-ENGINE.md Section 12.
140
+ */
141
+ declare const DIAGNOSTIC_CATEGORIES: readonly ["system", "disk", "process", "port", "network", "environment", "runtime", "tool", "path", "version", "project", "dependency", "git", "config", "cache"];
142
+ type DiagnosticCategory = (typeof DIAGNOSTIC_CATEGORIES)[number];
143
+ declare const CANONICAL_DIAGNOSTIC_CATEGORIES: readonly ["system", "disk", "process", "port", "network", "environment", "runtime", "tool", "path", "version", "project", "dependency", "git", "config", "cache"];
144
+ type CanonicalDiagnosticCategory = DiagnosticCategory;
145
+ /**
146
+ * Type guard for DiagnosticCategory.
147
+ * Strictly verifies against the 15 authoritative diagnostic categories.
148
+ */
149
+ declare function isDiagnosticCategory(value: unknown): value is DiagnosticCategory;
150
+
151
+ /**
152
+ * Authoritative diagnostic confidence levels.
153
+ * Adheres to docs/DETECTION-ENGINE.md Section 31-32.
154
+ *
155
+ * Confidence communicates certainty; it does NOT directly modify scoring penalties.
156
+ */
157
+ declare const FINDING_CONFIDENCES: readonly ["HIGH", "MEDIUM", "LOW"];
158
+ type FindingConfidence = (typeof FINDING_CONFIDENCES)[number];
159
+ /**
160
+ * Type guard for FindingConfidence.
161
+ */
162
+ declare function isFindingConfidence(value: unknown): value is FindingConfidence;
163
+
164
+ /**
165
+ * Authoritative evidence availability states.
166
+ * Adheres to docs/DETECTION-ENGINE.md Section 7.
167
+ */
168
+ declare const EVIDENCE_AVAILABILITIES: readonly ["AVAILABLE", "UNAVAILABLE", "FAILED", "NOT_APPLICABLE"];
169
+ type EvidenceAvailability = (typeof EVIDENCE_AVAILABILITIES)[number];
170
+ declare function isEvidenceAvailability(value: unknown): value is EvidenceAvailability;
171
+ /**
172
+ * Primitive metadata value types safe for evidence representation without secret exposure.
173
+ */
174
+ type EvidenceMetadataValue = string | number | boolean;
175
+ /**
176
+ * Represents a single normalized piece of collected diagnostic evidence.
177
+ * Adheres to docs/DETECTION-ENGINE.md Section 8-9.
178
+ */
179
+ interface EvidenceItem<T = unknown> {
180
+ readonly key: string;
181
+ readonly source: string;
182
+ readonly type?: string;
183
+ readonly availability: EvidenceAvailability;
184
+ readonly value?: T;
185
+ readonly unit?: string;
186
+ readonly metadata?: Readonly<Record<string, EvidenceMetadataValue>>;
187
+ }
188
+ /**
189
+ * Structured evidence attached to a diagnostic finding explaining why the rule produced its result.
190
+ * Adheres to docs/DETECTION-ENGINE.md Section 28.
191
+ */
192
+ interface FindingEvidence {
193
+ readonly items: readonly EvidenceItem[];
194
+ readonly details?: Readonly<Record<string, EvidenceMetadataValue | readonly string[]>>;
195
+ }
196
+ /**
197
+ * Collection of evidence items grouped by category or collector scope.
198
+ * Adheres to docs/DETECTION-ENGINE.md Section 5.
199
+ */
200
+ interface EvidenceSet {
201
+ readonly category?: DiagnosticCategory;
202
+ readonly items: readonly EvidenceItem[];
203
+ }
204
+
205
+ /**
206
+ * Authoritative diagnostic severity levels.
207
+ * Adheres to docs/DETECTION-ENGINE.md Section 32 and docs/SCORING.md Section 7.
208
+ *
209
+ * Severity describes diagnostic impact; scoring calculations belong in the scoring layer.
210
+ */
211
+ declare const FINDING_SEVERITIES: readonly ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"];
212
+ type FindingSeverity = (typeof FINDING_SEVERITIES)[number];
213
+ /**
214
+ * Type guard for FindingSeverity.
215
+ */
216
+ declare function isFindingSeverity(value: unknown): value is FindingSeverity;
217
+
218
+ /**
219
+ * Authoritative diagnostic finding statuses.
220
+ * Adheres to docs/DETECTION-ENGINE.md Section 17-23 and docs/SCORING.md Section 9.
221
+ */
222
+ declare const FINDING_STATUSES: readonly ["PASS", "FAIL", "WARN", "SKIPPED", "UNAVAILABLE", "ERROR"];
223
+ type FindingStatus = (typeof FINDING_STATUSES)[number];
224
+ /**
225
+ * Type guard for FindingStatus.
226
+ */
227
+ declare function isFindingStatus(value: unknown): value is FindingStatus;
228
+
229
+ /**
230
+ * Authoritative diagnostic finding model.
231
+ * Adheres to docs/DETECTION-ENGINE.md Section 24.
232
+ */
233
+ interface Finding {
234
+ readonly ruleId: string;
235
+ readonly category: DiagnosticCategory;
236
+ readonly status: FindingStatus;
237
+ readonly severity: FindingSeverity;
238
+ readonly confidence: FindingConfidence;
239
+ readonly title: string;
240
+ readonly summary: string;
241
+ readonly explanation?: string;
242
+ readonly impact?: string;
243
+ readonly remediationHint?: string;
244
+ readonly evidence?: FindingEvidence;
245
+ }
246
+ interface CreateFindingParams {
247
+ readonly ruleId: string;
248
+ readonly category: DiagnosticCategory;
249
+ readonly status: FindingStatus;
250
+ readonly severity: FindingSeverity;
251
+ readonly confidence: FindingConfidence;
252
+ readonly title: string;
253
+ readonly summary: string;
254
+ readonly explanation?: string;
255
+ readonly impact?: string;
256
+ readonly remediationHint?: string;
257
+ readonly evidence?: FindingEvidence;
258
+ }
259
+ /**
260
+ * Creates and validates an immutable Finding object.
261
+ * Rejects structurally invalid parameters and enforces deep immutability.
262
+ */
263
+ declare function createFinding(params: CreateFindingParams): Finding;
264
+
265
+ /**
266
+ * Rule Identifier contract and validation.
267
+ * Adheres to docs/RULE-CATALOGUE.md Section 4 and docs/DETECTION-ENGINE.md Section 11.
268
+ *
269
+ * Rule IDs are lowercase, dot-separated identifiers in the canonical format:
270
+ * <category>.<subject>.<condition>
271
+ */
272
+ interface ParsedRuleId {
273
+ readonly category: string;
274
+ readonly segments: readonly string[];
275
+ readonly subject?: string;
276
+ readonly condition?: string;
277
+ }
278
+ /**
279
+ * Validates whether a string matches the canonical Rule ID format.
280
+ * Lowercase, dot-separated identifier with at least two segments.
281
+ */
282
+ declare function isValidRuleId(id: string): boolean;
283
+ /**
284
+ * Parses a Rule ID into its component parts.
285
+ * Returns null if the Rule ID is invalid.
286
+ */
287
+ declare function parseRuleId(id: string): ParsedRuleId | null;
288
+
289
+ /**
290
+ * Declarative rule metadata describing a diagnostic rule specification.
291
+ * Adheres to docs/RULE-CATALOGUE.md Section 5.
292
+ */
293
+ interface RuleMetadata {
294
+ readonly id: string;
295
+ readonly name: string;
296
+ readonly category: DiagnosticCategory;
297
+ readonly description: string;
298
+ readonly severity: FindingSeverity;
299
+ readonly confidence: FindingConfidence;
300
+ readonly applicability?: readonly string[];
301
+ readonly requiredEvidence?: readonly string[];
302
+ readonly explanation?: string;
303
+ readonly remediationHint?: string;
304
+ }
305
+ /**
306
+ * Represents the raw evaluated outcome of a diagnostic rule before finding construction.
307
+ * Adheres to docs/DETECTION-ENGINE.md Section 16-17.
308
+ */
309
+ interface RuleEvaluation {
310
+ readonly ruleId: string;
311
+ readonly status: FindingStatus;
312
+ readonly finding?: Finding;
313
+ }
314
+
315
+ /**
316
+ * Diagnostic detection result providing coverage transparency.
317
+ * Adheres to docs/DETECTION-ENGINE.md Section 86.
318
+ *
319
+ * Preserves findings, executed rules, skipped rules, unavailable rules, and errors.
320
+ */
321
+ interface DetectionResult {
322
+ readonly findings: readonly Finding[];
323
+ readonly executedRules: readonly string[];
324
+ readonly skippedRules: readonly string[];
325
+ readonly unavailableRules: readonly string[];
326
+ readonly errors: readonly string[];
327
+ }
328
+
329
+ /**
330
+ * Core Domain Layer exports for YOWTF.
331
+ * Adheres to docs/ARCHITECTURE.md Section 5.3, docs/DETECTION-ENGINE.md, and docs/RULE-CATALOGUE.md.
332
+ */
333
+
334
+ /**
335
+ * Diagnostic scan result representing aggregated detection output for reporting.
336
+ * Adheres to docs/DETECTION-ENGINE.md Section 86 and docs/ARCHITECTURE.md Section 5.3.
337
+ */
338
+ interface DiagnosticResult extends DetectionResult {
339
+ readonly status: FindingStatus;
340
+ readonly summary?: string;
341
+ }
342
+
343
+ /**
344
+ * Authoritative score bands.
345
+ * Adheres to docs/SCORING.md Section 28.
346
+ */
347
+ declare const SCORE_BANDS: readonly ["EXCELLENT", "GOOD", "FAIR", "POOR", "CRITICAL"];
348
+ type ScoreBand = (typeof SCORE_BANDS)[number];
349
+ /**
350
+ * Base severity penalties.
351
+ * Adheres to docs/SCORING.md Section 8 & 57.
352
+ */
353
+ declare const BASE_SEVERITY_PENALTIES: Readonly<Record<FindingSeverity, number>>;
354
+ declare const SEVERITY_PENALTIES: Readonly<Record<"HIGH" | "MEDIUM" | "LOW" | "CRITICAL" | "INFO", number>>;
355
+ declare const WARN_PENALTY_MULTIPLIER = 0.5;
356
+ /**
357
+ * Detailed penalty assigned to an individual deduplicated finding.
358
+ */
359
+ interface FindingPenalty {
360
+ readonly ruleId: string;
361
+ readonly severity: FindingSeverity;
362
+ readonly status: Finding['status'];
363
+ readonly penalty: number;
364
+ }
365
+ /**
366
+ * Complete health score result model.
367
+ * Adheres to docs/SCORING.md Section 3, 28, 38, & 55.
368
+ */
369
+ interface ScoreResult {
370
+ readonly score: number;
371
+ readonly rawScore: number;
372
+ readonly band: ScoreBand;
373
+ readonly totalPenalty: number;
374
+ readonly penalties: readonly FindingPenalty[];
375
+ readonly totalFindings: number;
376
+ readonly criticalCount: number;
377
+ readonly highCount: number;
378
+ readonly mediumCount: number;
379
+ readonly lowCount: number;
380
+ readonly infoCount: number;
381
+ readonly failCount: number;
382
+ readonly warnCount: number;
383
+ readonly passCount: number;
384
+ }
385
+ type HealthScore = ScoreResult;
386
+ interface ScoreCalculator {
387
+ calculate(findings: readonly Finding[]): ScoreResult;
388
+ }
389
+ /**
390
+ * Determines the score band from the final clamped and rounded score.
391
+ * Adheres to docs/SCORING.md Section 28 & 29.
392
+ *
393
+ * 90-100: EXCELLENT
394
+ * 75-89: GOOD
395
+ * 60-74: FAIR
396
+ * 40-59: POOR
397
+ * 0-39: CRITICAL
398
+ */
399
+ declare function getScoreBand(score: number): ScoreBand;
400
+ /**
401
+ * Calculates deterministic health score from diagnostic findings.
402
+ * Adheres strictly to docs/SCORING.md:
403
+ * - Starting score = 100
404
+ * - Deduplication by stable ruleId (retains highest penalty among duplicates)
405
+ * - FAIL: base penalty (CRITICAL: 25, HIGH: 15, MEDIUM: 8, LOW: 3, INFO: 0)
406
+ * - WARN: 50% of base penalty (CRITICAL: 12.5, HIGH: 7.5, MEDIUM: 4, LOW: 1.5, INFO: 0)
407
+ * - PASS, SKIPPED, UNAVAILABLE, ERROR: 0 penalty
408
+ * - No confidence multiplier
409
+ * - Final score clamped to 0-100 and rounded to nearest integer
410
+ */
411
+ declare function calculateScore(findings: readonly Finding[]): ScoreResult;
412
+ /**
413
+ * Default score calculator implementation.
414
+ */
415
+ declare class DefaultScoreCalculator implements ScoreCalculator {
416
+ calculate(findings: readonly Finding[]): ScoreResult;
417
+ }
418
+
419
+ /**
420
+ * Diagnostic coverage details.
421
+ * Adheres to docs/SCORING.md Section 38 and docs/CLI-SPEC.md Section 46.
422
+ */
423
+ interface DiagnosticCoverage {
424
+ readonly totalRules: number;
425
+ readonly executed: number;
426
+ readonly passed: number;
427
+ readonly failed: number;
428
+ readonly warned: number;
429
+ readonly skipped: number;
430
+ readonly unavailable: number;
431
+ readonly errored: number;
432
+ }
433
+ /**
434
+ * Report metadata identifying tool, version, command, target path, and scope.
435
+ */
436
+ interface ReportMetadata {
437
+ readonly tool: string;
438
+ readonly version: string;
439
+ readonly command: string;
440
+ readonly targetPath: string;
441
+ readonly scope: string;
442
+ readonly category?: DiagnosticCategory;
443
+ }
444
+ /**
445
+ * Structured diagnostic report model.
446
+ * Canonical representation serving both Human and JSON reporters.
447
+ * Adheres to docs/CLI-SPEC.md Section 46.
448
+ */
449
+ interface ReportModel {
450
+ readonly metadata: ReportMetadata;
451
+ readonly status: FindingStatus;
452
+ readonly score?: ScoreResult;
453
+ readonly findings: readonly Finding[];
454
+ readonly coverage: DiagnosticCoverage;
455
+ }
456
+ /**
457
+ * Presentation options passed to reporters.
458
+ */
459
+ interface ReportOptions {
460
+ readonly json?: boolean;
461
+ readonly quiet?: boolean;
462
+ readonly verbose?: boolean;
463
+ readonly color?: boolean;
464
+ readonly command?: string;
465
+ }
466
+ /**
467
+ * Reporter interface for formatting ReportModel into terminal or JSON output.
468
+ */
469
+ interface Reporter {
470
+ readonly format: 'terminal' | 'json';
471
+ render(model: ReportModel, options?: ReportOptions): string;
472
+ }
473
+
474
+ /**
475
+ * Scan and execution context provided to detection rules and the detection engine.
476
+ * Adheres to docs/DETECTION-ENGINE.md Section 36 and 78.
477
+ */
478
+ interface DetectionContext {
479
+ readonly platform?: PlatformType | NodeJS.Platform;
480
+ readonly projectRoot?: string;
481
+ readonly commandScope?: string;
482
+ readonly env?: Readonly<Record<string, string | undefined>>;
483
+ readonly targetArchitecture?: string;
484
+ readonly targetNodeVersion?: string;
485
+ readonly targetPythonVersion?: string;
486
+ }
487
+ /**
488
+ * Standard contract for a diagnostic rule.
489
+ * Rules evaluate already-collected evidence to produce deterministic findings.
490
+ * Rules are strictly read-only and never perform collection, scoring, or remediation.
491
+ * Reference: docs/DETECTION-ENGINE.md Section 6, 10, 16.
492
+ */
493
+ interface DiagnosticRule {
494
+ readonly metadata: RuleMetadata;
495
+ isApplicable(context: DetectionContext, evidence: readonly EvidenceItem[]): boolean;
496
+ evaluate(context: DetectionContext, evidence: readonly EvidenceItem[]): Promise<RuleEvaluation> | RuleEvaluation;
497
+ }
498
+ interface SyncDiagnosticRule extends DiagnosticRule {
499
+ evaluate(context: DetectionContext, evidence: readonly EvidenceItem[]): RuleEvaluation;
500
+ }
501
+ /**
502
+ * Registry interface for managing and selecting diagnostic rules deterministically.
503
+ * Reference: docs/DETECTION-ENGINE.md Section 39-40.
504
+ */
505
+ interface RuleRegistryInterface {
506
+ register(rule: DiagnosticRule): void;
507
+ get(ruleId: string): DiagnosticRule | undefined;
508
+ list(): readonly DiagnosticRule[];
509
+ select(context?: DetectionContext): readonly DiagnosticRule[];
510
+ }
511
+
512
+ interface DetectionServiceOptions {
513
+ readonly registry?: RuleRegistryInterface;
514
+ }
515
+ /**
516
+ * Application service coordinating diagnostic rule evaluation.
517
+ * Boundary between application orchestration and the detection engine.
518
+ * Reference: docs/ARCHITECTURE.md Section 5.2 and 5.6.
519
+ */
520
+ declare class DetectionService {
521
+ private readonly engine;
522
+ constructor(options?: DetectionServiceOptions);
523
+ /**
524
+ * Executes detection rules against normalized evidence and returns deterministic findings.
525
+ */
526
+ runDetection(evidence: readonly EvidenceItem[] | readonly EvidenceSet[], context?: DetectionContext): Promise<DetectionResult>;
527
+ }
528
+
529
+ /**
530
+ * Project discovery and collection types.
531
+ * Adheres to docs/ARCHITECTURE.md Section 18 and docs/RULE-CATALOGUE.md Section 23, 24, 25, 26.
532
+ */
533
+ type SupportedProjectType = 'node' | 'python' | 'rust' | 'go' | 'java' | 'php' | 'ruby' | 'unknown';
534
+ interface ProjectManifestMetadata {
535
+ readonly packageName?: string;
536
+ readonly packageManager?: string;
537
+ readonly engines?: Readonly<Record<string, string>>;
538
+ readonly scripts?: readonly string[];
539
+ readonly declaredDependencyCount?: number;
540
+ }
541
+ interface ProjectManifestInfo {
542
+ readonly name: string;
543
+ readonly path: string;
544
+ readonly ecosystem: SupportedProjectType;
545
+ readonly metadata?: ProjectManifestMetadata;
546
+ }
547
+ interface ProjectLockfileInfo {
548
+ readonly name: string;
549
+ readonly path: string;
550
+ readonly packageManager: string;
551
+ }
552
+ type ConfigCategory = 'runtime-policy' | 'environment' | 'tooling' | 'general';
553
+ interface ProjectConfigInfo {
554
+ readonly name: string;
555
+ readonly path: string;
556
+ readonly category: ConfigCategory;
557
+ }
558
+ interface ProjectGitInfo {
559
+ readonly isRepository: boolean;
560
+ readonly gitDir?: string;
561
+ readonly branch?: string;
562
+ }
563
+ /**
564
+ * Structured project context established by project discovery.
565
+ */
566
+ interface DiscoveredProject {
567
+ readonly isProject: boolean;
568
+ readonly rootPath: string;
569
+ readonly types: readonly SupportedProjectType[];
570
+ readonly primaryType: SupportedProjectType;
571
+ readonly manifests: readonly ProjectManifestInfo[];
572
+ readonly lockfiles: readonly ProjectLockfileInfo[];
573
+ readonly configFiles: readonly ProjectConfigInfo[];
574
+ readonly packageManager?: string;
575
+ readonly git: ProjectGitInfo;
576
+ }
577
+
578
+ declare class ProjectDiscovery {
579
+ /**
580
+ * Discovers project root and inspects structured project facts.
581
+ * Strictly read-only and safe.
582
+ */
583
+ discover(startDir: string): Promise<DiscoveredProject>;
584
+ /**
585
+ * Walks upward from startDir to locate the first ancestor directory containing project markers.
586
+ * Prevents escaping into unrelated directories such as user home or system temp root.
587
+ */
588
+ private findProjectRoot;
589
+ private safeReadDir;
590
+ private discoverManifests;
591
+ private safelyParsePackageJson;
592
+ private discoverLockfiles;
593
+ private discoverConfigs;
594
+ private discoverGit;
595
+ private determineTypes;
596
+ private resolvePackageManager;
597
+ }
598
+
599
+ /**
600
+ * Execution context provided to all collectors during a diagnostic scan.
601
+ * Reference: docs/ARCHITECTURE.md Section 5.4.
602
+ */
603
+ interface CollectorContext {
604
+ readonly cwd: string;
605
+ readonly platformAdapter: PlatformAdapter;
606
+ readonly env?: NodeJS.ProcessEnv;
607
+ }
608
+ /**
609
+ * Standard contract for diagnostic collectors.
610
+ * Collectors gather raw machine and environment facts without making evaluative decisions.
611
+ */
612
+ interface Collector<T = EvidenceSet> {
613
+ readonly name: string;
614
+ readonly category: DiagnosticCategory;
615
+ collect(context: CollectorContext): Promise<T>;
616
+ }
617
+
618
+ /**
619
+ * ProjectCollector gathers structured facts about the target project,
620
+ * fulfilling evidence requirements for PROJ-001 through PROJ-004,
621
+ * DEP-001 through DEP-003, GIT-001, and CFG-001.
622
+ *
623
+ * It is strictly read-only and does not calculate scores or create findings.
624
+ */
625
+ declare class ProjectCollector implements Collector<EvidenceSet> {
626
+ private readonly discovery;
627
+ readonly name = "project";
628
+ readonly category: "project";
629
+ constructor(discovery?: ProjectDiscovery);
630
+ collect(context: CollectorContext): Promise<EvidenceSet>;
631
+ buildEvidenceSet(project: DiscoveredProject): EvidenceSet;
632
+ }
633
+
634
+ interface ProjectCollectionOptions {
635
+ readonly targetPath?: string;
636
+ readonly cwd?: string;
637
+ readonly platformAdapter?: PlatformAdapter;
638
+ }
639
+ interface ProjectCollectionResult {
640
+ readonly project: DiscoveredProject;
641
+ readonly evidence: EvidenceSet;
642
+ }
643
+ /**
644
+ * Application service coordinating project path resolution, project discovery,
645
+ * and structured project evidence collection.
646
+ * Reference: docs/ARCHITECTURE.md Section 5.2 and Section 18.
647
+ */
648
+ declare class ProjectCollectionService {
649
+ private readonly discovery;
650
+ private readonly collector;
651
+ constructor(discovery?: ProjectDiscovery, collector?: ProjectCollector);
652
+ /**
653
+ * Discovers and collects structured project facts for the target directory.
654
+ */
655
+ discoverAndCollect(options?: ProjectCollectionOptions): Promise<ProjectCollectionResult>;
656
+ }
657
+
658
+ /**
659
+ * SystemCollector collects normalized system facts matching authoritative V1
660
+ * diagnostic rules (SYS-001 through SYS-005 in docs/RULE-CATALOGUE.md).
661
+ *
662
+ * It is strictly read-only and produces structured evidence without making evaluative decisions.
663
+ */
664
+ declare class SystemCollector implements Collector<EvidenceSet> {
665
+ readonly name = "system";
666
+ readonly category: "system";
667
+ collect(context: CollectorContext): Promise<EvidenceSet>;
668
+ }
669
+
670
+ interface SystemCollectionOptions {
671
+ readonly cwd?: string;
672
+ readonly platformAdapter?: PlatformAdapter;
673
+ }
674
+ /**
675
+ * Application service coordinating platform resolution and system facts collection.
676
+ * Serves as the boundary between application use cases/scans and the collection layer.
677
+ * Reference: docs/ARCHITECTURE.md Section 5.2.
678
+ */
679
+ declare class SystemCollectionService {
680
+ private readonly collector;
681
+ constructor(collector?: SystemCollector);
682
+ /**
683
+ * Executes system facts collection and returns normalized structured evidence.
684
+ */
685
+ collectSystemEvidence(options?: SystemCollectionOptions): Promise<EvidenceSet>;
686
+ }
687
+
688
+ interface ScanOrchestratorOptions {
689
+ readonly systemCollectionService?: SystemCollectionService;
690
+ readonly projectCollectionService?: ProjectCollectionService;
691
+ readonly detectionService?: DetectionService;
692
+ }
693
+ interface RunScanOptions {
694
+ readonly command: string;
695
+ readonly targetPath: string;
696
+ readonly verbose?: boolean;
697
+ readonly json?: boolean;
698
+ readonly quiet?: boolean;
699
+ readonly color?: boolean;
700
+ readonly preview?: boolean;
701
+ readonly platformAdapter?: PlatformAdapter;
702
+ }
703
+ /**
704
+ * Application service orchestrating the full diagnostic pipeline:
705
+ * Discovery -> Evidence Collection -> Rule Detection -> Health Scoring -> Report Assembly.
706
+ * Adheres to docs/ARCHITECTURE.md Section 5.2 and docs/CLI-SPEC.md Section 46.
707
+ */
708
+ declare class ScanOrchestratorService {
709
+ private readonly systemCollectionService;
710
+ private readonly projectCollectionService;
711
+ private readonly detectionService;
712
+ constructor(options?: ScanOrchestratorOptions);
713
+ /**
714
+ * Executes an end-to-end diagnostic scan for the specified command and options.
715
+ */
716
+ executeScan(options: RunScanOptions): Promise<ReportModel>;
717
+ private resolveScope;
718
+ }
719
+
720
+ /**
721
+ * Application Layer foundational interfaces and use cases.
722
+ * Orchestrates the scan lifecycle: discovery -> collection -> detection -> scoring -> reporting.
723
+ * Reference: docs/ARCHITECTURE.md Section 5.2.
724
+ */
725
+ interface ScanOptions {
726
+ readonly cwd?: string;
727
+ readonly verbose?: boolean;
728
+ readonly json?: boolean;
729
+ readonly quiet?: boolean;
730
+ readonly color?: boolean;
731
+ }
732
+ interface ApplicationContext {
733
+ readonly cwd: string;
734
+ }
735
+ interface CommandContext {
736
+ readonly command: string;
737
+ readonly targetPath: string;
738
+ readonly options: {
739
+ readonly verbose?: boolean;
740
+ readonly json?: boolean;
741
+ readonly quiet?: boolean;
742
+ readonly color?: boolean;
743
+ readonly preview?: boolean;
744
+ readonly platformAdapter?: PlatformAdapter;
745
+ };
746
+ }
747
+ interface CommandResult {
748
+ readonly command: string;
749
+ readonly targetPath: string;
750
+ readonly status: 'ready' | 'executed' | 'error';
751
+ readonly message?: string;
752
+ readonly exitCode: number;
753
+ readonly reportModel?: ReportModel;
754
+ }
755
+ /**
756
+ * Application entry point for command execution.
757
+ * Orchestrates the full diagnostic pipeline:
758
+ * Discovery -> Evidence Collection -> Detection -> Scoring -> Reporting.
759
+ */
760
+ declare function executeCommand(context: CommandContext, orchestrator?: ScanOrchestratorService): Promise<CommandResult>;
761
+
762
+ /**
763
+ * Deterministic Rule Registry for YOWTF.
764
+ * Rejects duplicate rule IDs and preserves stable catalog order.
765
+ * Reference: docs/DETECTION-ENGINE.md Section 39-40.
766
+ */
767
+ declare class DefaultRuleRegistry implements RuleRegistryInterface {
768
+ private readonly rulesById;
769
+ private readonly rulesOrder;
770
+ constructor(initialRules?: readonly DiagnosticRule[]);
771
+ register(rule: DiagnosticRule): void;
772
+ get(ruleId: string): DiagnosticRule | undefined;
773
+ list(): readonly DiagnosticRule[];
774
+ select(context?: DetectionContext): readonly DiagnosticRule[];
775
+ }
776
+ /**
777
+ * Creates a pre-populated rule registry containing all 60 authoritative V1 diagnostic rules.
778
+ */
779
+ declare function createDefaultRuleRegistry(): DefaultRuleRegistry;
780
+
781
+ /**
782
+ * Authoritative Detection Engine for YOWTF.
783
+ * Executes registered diagnostic rules deterministically against normalized evidence.
784
+ * Provides fault isolation and structured coverage transparency.
785
+ * Reference: docs/DETECTION-ENGINE.md Section 85-87.
786
+ */
787
+ declare class DetectionEngine {
788
+ private readonly registry;
789
+ constructor(registry: RuleRegistryInterface);
790
+ execute(evidenceInput: readonly EvidenceItem[] | readonly EvidenceSet[], context?: DetectionContext): Promise<DetectionResult>;
791
+ }
792
+
793
+ /**
794
+ * The authoritative, closed V1 diagnostic rule set for YOWTF.
795
+ * Order matches docs/RULE-CATALOGUE.md Section 76.
796
+ * Contains exactly 60 rules across 15 categories.
797
+ */
798
+ declare const allV1Rules: readonly DiagnosticRule[];
799
+
800
+ /**
801
+ * SYS-001: High Memory Pressure
802
+ * Reference: docs/RULE-CATALOGUE.md Section 13
803
+ */
804
+ declare const sys001MemoryPressure: SyncDiagnosticRule;
805
+ /**
806
+ * SYS-002: High CPU Pressure
807
+ * Reference: docs/RULE-CATALOGUE.md Section 13
808
+ */
809
+ declare const sys002CpuPressure: SyncDiagnosticRule;
810
+ /**
811
+ * SYS-003: Recently Restarted System
812
+ * Reference: docs/RULE-CATALOGUE.md Section 13
813
+ */
814
+ declare const sys003UptimeShort: SyncDiagnosticRule;
815
+ /**
816
+ * SYS-004: Architecture Mismatch
817
+ * Reference: docs/RULE-CATALOGUE.md Section 13
818
+ */
819
+ declare const sys004ArchitectureMismatch: SyncDiagnosticRule;
820
+ /**
821
+ * SYS-005: Supported Operating System
822
+ * Reference: docs/RULE-CATALOGUE.md Section 13
823
+ */
824
+ declare const sys005PlatformSupported: SyncDiagnosticRule;
825
+ declare const systemRules: readonly DiagnosticRule[];
826
+
827
+ /**
828
+ * DISK-001: Low Disk Space
829
+ * Reference: docs/RULE-CATALOGUE.md Section 14
830
+ */
831
+ declare const disk001SpaceLow: SyncDiagnosticRule;
832
+ /**
833
+ * DISK-002: Developer Storage Pressure
834
+ * Reference: docs/RULE-CATALOGUE.md Section 14
835
+ */
836
+ declare const disk002DeveloperStoragePressure: SyncDiagnosticRule;
837
+ /**
838
+ * DISK-003: Project Storage Location Unavailable
839
+ * Reference: docs/RULE-CATALOGUE.md Section 14
840
+ */
841
+ declare const disk003ProjectLocationUnavailable: SyncDiagnosticRule;
842
+ /**
843
+ * DISK-004: Read-Only Project Filesystem
844
+ * Reference: docs/RULE-CATALOGUE.md Section 14
845
+ */
846
+ declare const disk004FilesystemReadonly: SyncDiagnosticRule;
847
+ declare const diskRules: readonly DiagnosticRule[];
848
+
849
+ interface ProcessItem {
850
+ readonly pid: number;
851
+ readonly name: string;
852
+ readonly cpuPercent?: number;
853
+ readonly memoryPercent?: number;
854
+ readonly state?: string;
855
+ }
856
+ /**
857
+ * PROC-001: Resource-Heavy Process
858
+ * Reference: docs/RULE-CATALOGUE.md Section 15
859
+ */
860
+ declare const proc001ResourceHog: SyncDiagnosticRule;
861
+ /**
862
+ * PROC-002: Memory-Heavy Process
863
+ * Reference: docs/RULE-CATALOGUE.md Section 15
864
+ */
865
+ declare const proc002MemoryHog: SyncDiagnosticRule;
866
+ /**
867
+ * PROC-003: Zombie/Defunct Development Process
868
+ * Reference: docs/RULE-CATALOGUE.md Section 15
869
+ */
870
+ declare const proc003Zombie: SyncDiagnosticRule;
871
+ /**
872
+ * PROC-004: Duplicate Development Process
873
+ * Reference: docs/RULE-CATALOGUE.md Section 15
874
+ */
875
+ declare const proc004Duplicate: SyncDiagnosticRule;
876
+ declare const processRules: readonly DiagnosticRule[];
877
+
878
+ interface PortListener {
879
+ readonly port: number;
880
+ readonly address: string;
881
+ readonly pid?: number;
882
+ readonly processName?: string;
883
+ readonly hasConflict?: boolean;
884
+ readonly isDuplicate?: boolean;
885
+ readonly ownerKnown?: boolean;
886
+ }
887
+ /**
888
+ * PORT-001: Development Port Conflict
889
+ * Reference: docs/RULE-CATALOGUE.md Section 16
890
+ */
891
+ declare const port001DevConflict: SyncDiagnosticRule;
892
+ /**
893
+ * PORT-002: Duplicate Listener Detection
894
+ * Reference: docs/RULE-CATALOGUE.md Section 16
895
+ */
896
+ declare const port002DuplicateListener: SyncDiagnosticRule;
897
+ /**
898
+ * PORT-003: Unexpected Local Port Exposure
899
+ * Reference: docs/RULE-CATALOGUE.md Section 16
900
+ */
901
+ declare const port003UnexpectedExposure: SyncDiagnosticRule;
902
+ /**
903
+ * PORT-004: Port Owner Unavailable
904
+ * Reference: docs/RULE-CATALOGUE.md Section 16
905
+ */
906
+ declare const port004ProcessUnavailable: SyncDiagnosticRule;
907
+ declare const portRules: readonly DiagnosticRule[];
908
+
909
+ /**
910
+ * NET-001: Network Interface Information Unavailable
911
+ * Reference: docs/RULE-CATALOGUE.md Section 17
912
+ */
913
+ declare const net001InterfaceUnavailable: SyncDiagnosticRule;
914
+ /**
915
+ * NET-002: DNS Configuration Missing
916
+ * Reference: docs/RULE-CATALOGUE.md Section 17
917
+ */
918
+ declare const net002DnsMissing: SyncDiagnosticRule;
919
+ /**
920
+ * NET-003: Suspicious Proxy Configuration
921
+ * Reference: docs/RULE-CATALOGUE.md Section 17
922
+ */
923
+ declare const net003ProxySuspicious: SyncDiagnosticRule;
924
+ /**
925
+ * NET-004: Local Route Information Unavailable
926
+ * Reference: docs/RULE-CATALOGUE.md Section 17
927
+ */
928
+ declare const net004RouteUnavailable: SyncDiagnosticRule;
929
+ declare const networkRules: readonly DiagnosticRule[];
930
+
931
+ /**
932
+ * ENV-001: Empty PATH Entry
933
+ * Reference: docs/RULE-CATALOGUE.md Section 18
934
+ */
935
+ declare const env001EmptyPathEntry: SyncDiagnosticRule;
936
+ /**
937
+ * ENV-002: Potential Secret in Environment Metadata
938
+ * Reference: docs/RULE-CATALOGUE.md Section 18
939
+ */
940
+ declare const env002SecretExposure: SyncDiagnosticRule;
941
+ /**
942
+ * ENV-003: Duplicate PATH Entry
943
+ * Reference: docs/RULE-CATALOGUE.md Section 18
944
+ */
945
+ declare const env003DuplicatePath: SyncDiagnosticRule;
946
+ /**
947
+ * ENV-004: Shell Environment PATH Mismatch
948
+ * Reference: docs/RULE-CATALOGUE.md Section 18
949
+ */
950
+ declare const env004ShellPathMismatch: SyncDiagnosticRule;
951
+ declare const environmentRules: readonly DiagnosticRule[];
952
+
953
+ /**
954
+ * RUN-001: Node.js Runtime Unavailable
955
+ * Reference: docs/RULE-CATALOGUE.md Section 19
956
+ */
957
+ declare const run001NodeUnavailable: SyncDiagnosticRule;
958
+ /**
959
+ * RUN-002: Node.js Runtime Unpinned
960
+ * Reference: docs/RULE-CATALOGUE.md Section 19
961
+ */
962
+ declare const run002NodeUnpinned: SyncDiagnosticRule;
963
+ /**
964
+ * RUN-003: Python Runtime Unavailable
965
+ * Reference: docs/RULE-CATALOGUE.md Section 19
966
+ */
967
+ declare const run003PythonUnavailable: SyncDiagnosticRule;
968
+ /**
969
+ * RUN-004: Python Version Not Pinned
970
+ * Reference: docs/RULE-CATALOGUE.md Section 19
971
+ */
972
+ declare const run004PythonUnpinned: SyncDiagnosticRule;
973
+ /**
974
+ * RUN-005: Java Runtime Unavailable
975
+ * Reference: docs/RULE-CATALOGUE.md Section 19
976
+ */
977
+ declare const run005JavaUnavailable: SyncDiagnosticRule;
978
+ /**
979
+ * RUN-006: Runtime Version Mismatch
980
+ * Reference: docs/RULE-CATALOGUE.md Section 19
981
+ */
982
+ declare const run006VersionMismatch: SyncDiagnosticRule;
983
+ declare const runtimeRules: readonly DiagnosticRule[];
984
+
985
+ /**
986
+ * TOOL-001: Git Unavailable
987
+ * Reference: docs/RULE-CATALOGUE.md Section 20
988
+ */
989
+ declare const tool001GitUnavailable: SyncDiagnosticRule;
990
+ /**
991
+ * TOOL-002: Package Manager Mismatch
992
+ * Reference: docs/RULE-CATALOGUE.md Section 20
993
+ */
994
+ declare const tool002PackageManagerMismatch: SyncDiagnosticRule;
995
+ /**
996
+ * TOOL-003: Required Package Manager Missing
997
+ * Reference: docs/RULE-CATALOGUE.md Section 20
998
+ */
999
+ declare const tool003PackageManagerMissing: SyncDiagnosticRule;
1000
+ /**
1001
+ * TOOL-004: Docker Unavailable
1002
+ * Reference: docs/RULE-CATALOGUE.md Section 20
1003
+ */
1004
+ declare const tool004DockerUnavailable: SyncDiagnosticRule;
1005
+ /**
1006
+ * TOOL-005: Executable Shadowing
1007
+ * Reference: docs/RULE-CATALOGUE.md Section 20
1008
+ */
1009
+ declare const tool005ExecutableShadowing: SyncDiagnosticRule;
1010
+ declare const toolRules: readonly DiagnosticRule[];
1011
+
1012
+ /**
1013
+ * PATH-001: Expected Executable Missing
1014
+ * Reference: docs/RULE-CATALOGUE.md Section 21
1015
+ */
1016
+ declare const path001ExecutableMissing: SyncDiagnosticRule;
1017
+ /**
1018
+ * PATH-002: Multiple Executable Resolutions
1019
+ * Reference: docs/RULE-CATALOGUE.md Section 21
1020
+ */
1021
+ declare const path002ExecutableMultiple: SyncDiagnosticRule;
1022
+ /**
1023
+ * PATH-003: Invalid PATH Entry
1024
+ * Reference: docs/RULE-CATALOGUE.md Section 21
1025
+ */
1026
+ declare const path003EntryInvalid: SyncDiagnosticRule;
1027
+ /**
1028
+ * PATH-004: PATH Order Shadowing
1029
+ * Reference: docs/RULE-CATALOGUE.md Section 21
1030
+ */
1031
+ declare const path004OrderShadowing: SyncDiagnosticRule;
1032
+ declare const pathRules: readonly DiagnosticRule[];
1033
+
1034
+ /**
1035
+ * VER-001: Runtime Version Conflict
1036
+ * Reference: docs/RULE-CATALOGUE.md Section 22
1037
+ */
1038
+ declare const ver001RuntimeConflict: SyncDiagnosticRule;
1039
+ /**
1040
+ * VER-002: Developer Tool Version Conflict
1041
+ * Reference: docs/RULE-CATALOGUE.md Section 22
1042
+ */
1043
+ declare const ver002ToolConflict: SyncDiagnosticRule;
1044
+ /**
1045
+ * VER-003: Project Runtime Requirement Unsatisfied
1046
+ * Reference: docs/RULE-CATALOGUE.md Section 22
1047
+ */
1048
+ declare const ver003ProjectRuntimeUnsatisfied: SyncDiagnosticRule;
1049
+ /**
1050
+ * VER-004: Developer Tool Version Below Project Requirement
1051
+ * Reference: docs/RULE-CATALOGUE.md Section 22
1052
+ */
1053
+ declare const ver004ToolOutdated: SyncDiagnosticRule;
1054
+ declare const versionRules: readonly DiagnosticRule[];
1055
+
1056
+ /**
1057
+ * PROJ-001: Project Manifest Missing
1058
+ * Reference: docs/RULE-CATALOGUE.md Section 23
1059
+ */
1060
+ declare const proj001ManifestMissing: SyncDiagnosticRule;
1061
+ /**
1062
+ * PROJ-002: Project Lockfile Missing
1063
+ * Reference: docs/RULE-CATALOGUE.md Section 23
1064
+ */
1065
+ declare const proj002LockfileMissing: SyncDiagnosticRule;
1066
+ /**
1067
+ * PROJ-003: Project Runtime Policy Missing
1068
+ * Reference: docs/RULE-CATALOGUE.md Section 23
1069
+ */
1070
+ declare const proj003RuntimePolicyMissing: SyncDiagnosticRule;
1071
+ /**
1072
+ * PROJ-004: Ambiguous Project Root
1073
+ * Reference: docs/RULE-CATALOGUE.md Section 23
1074
+ */
1075
+ declare const proj004RootAmbiguous: SyncDiagnosticRule;
1076
+ declare const projectRules: readonly DiagnosticRule[];
1077
+
1078
+ /**
1079
+ * DEP-001: Dependency Lockfile Missing
1080
+ * Reference: docs/RULE-CATALOGUE.md Section 24
1081
+ */
1082
+ declare const dep001LockfileMissing: SyncDiagnosticRule;
1083
+ /**
1084
+ * DEP-002: Dependency Lockfile Mismatch
1085
+ * Reference: docs/RULE-CATALOGUE.md Section 24
1086
+ */
1087
+ declare const dep002LockfileMismatch: SyncDiagnosticRule;
1088
+ /**
1089
+ * DEP-003: Dependency Package Manager Mismatch
1090
+ * Reference: docs/RULE-CATALOGUE.md Section 24
1091
+ */
1092
+ declare const dep003PackageManagerMismatch: SyncDiagnosticRule;
1093
+ /**
1094
+ * DEP-004: Dependency Directory Inconsistency
1095
+ * Reference: docs/RULE-CATALOGUE.md Section 24
1096
+ */
1097
+ declare const dep004DirectoryInconsistent: SyncDiagnosticRule;
1098
+ declare const dependencyRules: readonly DiagnosticRule[];
1099
+
1100
+ /**
1101
+ * GIT-001: Git Repository Missing
1102
+ * Reference: docs/RULE-CATALOGUE.md Section 25
1103
+ */
1104
+ declare const git001RepositoryMissing: SyncDiagnosticRule;
1105
+ /**
1106
+ * GIT-002: Dirty Working Tree
1107
+ * Reference: docs/RULE-CATALOGUE.md Section 25
1108
+ */
1109
+ declare const git002WorkingTreeDirty: SyncDiagnosticRule;
1110
+ /**
1111
+ * GIT-003: Untracked Files Present
1112
+ * Reference: docs/RULE-CATALOGUE.md Section 25
1113
+ */
1114
+ declare const git003UntrackedFiles: SyncDiagnosticRule;
1115
+ /**
1116
+ * GIT-004: Branch Divergence
1117
+ * Reference: docs/RULE-CATALOGUE.md Section 25
1118
+ */
1119
+ declare const git004BranchDivergence: SyncDiagnosticRule;
1120
+ declare const gitRules: readonly DiagnosticRule[];
1121
+
1122
+ /**
1123
+ * CFG-001: Expected Environment Configuration Missing
1124
+ * Reference: docs/RULE-CATALOGUE.md Section 26
1125
+ */
1126
+ declare const cfg001EnvFileMissing: SyncDiagnosticRule;
1127
+ /**
1128
+ * CFG-002: Required Configuration Metadata Missing
1129
+ * Reference: docs/RULE-CATALOGUE.md Section 26
1130
+ */
1131
+ declare const cfg002RequiredValueMissing: SyncDiagnosticRule;
1132
+ declare const configRules: readonly DiagnosticRule[];
1133
+
1134
+ /**
1135
+ * CACHE-001: Large Developer Cache
1136
+ * Reference: docs/RULE-CATALOGUE.md Section 27
1137
+ */
1138
+ declare const cache001StorageLarge: SyncDiagnosticRule;
1139
+ /**
1140
+ * CACHE-002: Large Build Artifact
1141
+ * Reference: docs/RULE-CATALOGUE.md Section 27
1142
+ */
1143
+ declare const cache002BuildArtifactLarge: SyncDiagnosticRule;
1144
+ declare const cacheRules: readonly DiagnosticRule[];
1145
+
1146
+ /**
1147
+ * Pure machine-readable JSON reporter.
1148
+ * Adheres strictly to docs/CLI-SPEC.md Section 12, 15, 46, & 47:
1149
+ * - Emits valid, formatted JSON
1150
+ * - Zero ANSI color codes
1151
+ * - Zero spinner noise
1152
+ * - Zero decorative boxes or tables
1153
+ * - Deterministic, stable field ordering
1154
+ * - Quiet mode does not alter or suppress required JSON fields
1155
+ */
1156
+ declare class JsonReporter implements Reporter {
1157
+ readonly format: "json";
1158
+ render(model: ReportModel, _options?: ReportOptions): string;
1159
+ }
1160
+
1161
+ /**
1162
+ * Terminal presentation reporter.
1163
+ * Adheres to docs/CLI-SPEC.md Section 14, 18, 30, 32, 33, 64-68 and docs/COMMANDS.md.
1164
+ * - Supports color/no-color via Chalk level toggle
1165
+ * - Clean, professional layout with Boxen for health scores
1166
+ * - Structured tables via cli-table3 for findings where helpful
1167
+ * - Supports --quiet mode (minimal summary & key failures)
1168
+ * - Supports --verbose mode (exposing rule IDs, coverage, evidence keys)
1169
+ * - Command-specific presentation:
1170
+ * - score: focused score view
1171
+ * - explain: deep explanation view (problem -> evidence -> impact -> next action)
1172
+ * - doctor: prioritized problem view
1173
+ * - default / category commands: full / scoped diagnostics
1174
+ */
1175
+ declare class TerminalReporter implements Reporter {
1176
+ readonly format: "terminal";
1177
+ render(model: ReportModel, options?: ReportOptions): string;
1178
+ private renderScoreOnly;
1179
+ private renderExplainView;
1180
+ private renderStandardView;
1181
+ private formatStatusBadge;
1182
+ private formatSeverity;
1183
+ private colorScore;
1184
+ private colorScoreBand;
1185
+ private getBorderColorForBand;
1186
+ }
1187
+
1188
+ interface CreateReportModelOptions {
1189
+ readonly command: string;
1190
+ readonly targetPath: string;
1191
+ readonly scope: string;
1192
+ readonly category?: DiagnosticCategory;
1193
+ readonly score?: ScoreResult;
1194
+ readonly tool?: string;
1195
+ readonly version?: string;
1196
+ }
1197
+ /**
1198
+ * Assembles a canonical ReportModel from detection results, coverage, and metadata.
1199
+ * Adheres to docs/CLI-SPEC.md Section 46 and docs/SCORING.md Section 38.
1200
+ */
1201
+ declare function createReportModel(detectionResult: DetectionResult, options: CreateReportModelOptions): ReportModel;
1202
+
1203
+ /**
1204
+ * Reporting Layer foundational interfaces and implementations.
1205
+ * Formats and renders diagnostic results to terminal or JSON output.
1206
+ * Adheres to docs/ARCHITECTURE.md Section 5.8, docs/CLI-SPEC.md, and docs/SCORING.md.
1207
+ */
1208
+
1209
+ /**
1210
+ * Legacy ReportPayload interface preserved for compatibility.
1211
+ */
1212
+ interface ReportPayload {
1213
+ readonly result: DiagnosticResult;
1214
+ readonly score?: HealthScore;
1215
+ }
1216
+
1217
+ declare class CommandExecutionError extends Error {
1218
+ readonly exitCode: number | null;
1219
+ readonly stdout: string;
1220
+ readonly stderr: string;
1221
+ readonly killed: boolean;
1222
+ constructor(message: string, options: {
1223
+ exitCode: number | null;
1224
+ stdout: string;
1225
+ stderr: string;
1226
+ killed: boolean;
1227
+ cause?: unknown;
1228
+ });
1229
+ }
1230
+ /**
1231
+ * Executes a command safely without shell expansion.
1232
+ * Strictly non-interactive and read-only.
1233
+ */
1234
+ declare function executeSafeCommand(file: string, args?: readonly string[], options?: SafeCommandOptions): Promise<SafeCommandResult>;
1235
+
1236
+ interface WindowsSystemProvider {
1237
+ arch(): string;
1238
+ release(): string;
1239
+ hostname(): string;
1240
+ totalmem(): number;
1241
+ freemem(): number;
1242
+ cpus(): os.CpuInfo[];
1243
+ uptime(): number;
1244
+ }
1245
+ declare class WindowsPlatformAdapter implements PlatformAdapter {
1246
+ private readonly provider;
1247
+ readonly platformType: "windows";
1248
+ readonly isSupported = true;
1249
+ constructor(provider?: WindowsSystemProvider);
1250
+ getPlatformInfo(): PlatformInfo;
1251
+ getMemoryInfo(): MemoryInfo;
1252
+ getCpuInfo(): CpuInfo;
1253
+ getUptimeInfo(): UptimeInfo;
1254
+ isCommandAvailable(command: string): Promise<boolean>;
1255
+ }
1256
+
1257
+ interface DarwinSystemProvider {
1258
+ arch(): string;
1259
+ release(): string;
1260
+ hostname(): string;
1261
+ totalmem(): number;
1262
+ freemem(): number;
1263
+ cpus(): os.CpuInfo[];
1264
+ uptime(): number;
1265
+ }
1266
+ declare class MacOSPlatformAdapter implements PlatformAdapter {
1267
+ private readonly provider;
1268
+ readonly platformType: "macos";
1269
+ readonly isSupported = true;
1270
+ constructor(provider?: DarwinSystemProvider);
1271
+ getPlatformInfo(): PlatformInfo;
1272
+ getMemoryInfo(): MemoryInfo;
1273
+ getCpuInfo(): CpuInfo;
1274
+ getUptimeInfo(): UptimeInfo;
1275
+ isCommandAvailable(command: string): Promise<boolean>;
1276
+ }
1277
+
1278
+ interface LinuxSystemProvider {
1279
+ arch(): string;
1280
+ release(): string;
1281
+ hostname(): string;
1282
+ totalmem(): number;
1283
+ freemem(): number;
1284
+ cpus(): os.CpuInfo[];
1285
+ uptime(): number;
1286
+ }
1287
+ declare class LinuxPlatformAdapter implements PlatformAdapter {
1288
+ private readonly provider;
1289
+ readonly platformType: "linux";
1290
+ readonly isSupported = true;
1291
+ constructor(provider?: LinuxSystemProvider);
1292
+ getPlatformInfo(): PlatformInfo;
1293
+ getMemoryInfo(): MemoryInfo;
1294
+ getCpuInfo(): CpuInfo;
1295
+ getUptimeInfo(): UptimeInfo;
1296
+ isCommandAvailable(command: string): Promise<boolean>;
1297
+ }
1298
+
1299
+ interface UnsupportedSystemProvider {
1300
+ platform(): NodeJS.Platform;
1301
+ arch(): string;
1302
+ release(): string;
1303
+ hostname(): string;
1304
+ totalmem(): number;
1305
+ freemem(): number;
1306
+ cpus(): os.CpuInfo[];
1307
+ uptime(): number;
1308
+ }
1309
+ declare class UnsupportedPlatformAdapter implements PlatformAdapter {
1310
+ private readonly provider;
1311
+ readonly platformType: "unsupported";
1312
+ readonly isSupported = false;
1313
+ constructor(provider?: UnsupportedSystemProvider);
1314
+ getPlatformInfo(): PlatformInfo;
1315
+ getMemoryInfo(): MemoryInfo;
1316
+ getCpuInfo(): CpuInfo;
1317
+ getUptimeInfo(): UptimeInfo;
1318
+ isCommandAvailable(_command: string): Promise<boolean>;
1319
+ }
1320
+
1321
+ declare const SUPPORTED_PLATFORMS: readonly SupportedPlatform[];
1322
+ /**
1323
+ * Normalizes an operating system platform identifier into a PlatformType.
1324
+ * Defaults to current process.platform if none is supplied.
1325
+ */
1326
+ declare function detectPlatform(osPlatform?: string): PlatformType;
1327
+ /**
1328
+ * Checks whether an operating system platform identifier is supported.
1329
+ */
1330
+ declare function isSupportedPlatform(osPlatform?: string): boolean;
1331
+ /**
1332
+ * Factory that returns the appropriate PlatformAdapter for the given platform.
1333
+ * Defaults to process.platform.
1334
+ */
1335
+ declare function resolvePlatformAdapter(osPlatform?: string): PlatformAdapter;
1336
+
1337
+ export { APP_FULL_NAME, APP_NAME, APP_TAGLINE, APP_VERSION, type ApplicationContext, BASE_SEVERITY_PENALTIES, CANONICAL_DIAGNOSTIC_CATEGORIES, type CanonicalDiagnosticCategory, CliError, CliUsageError, type Collector, type CollectorContext, type CommandContext, CommandExecutionError, type CommandResult, type ConfigCategory, type CpuCoreInfo, type CpuInfo, type CreateFindingParams, type CreateReportModelOptions, DIAGNOSTIC_CATEGORIES, type DarwinSystemProvider, DefaultRuleRegistry, DefaultScoreCalculator, type DetectionContext, DetectionEngine, type DetectionResult, DetectionService, type DetectionServiceOptions, type DiagnosticCategory, type DiagnosticCoverage, type DiagnosticResult, type DiagnosticRule, type DiscoveredProject, type DispatchOptions, EVIDENCE_AVAILABILITIES, EXIT_APPLICATION_ERROR, EXIT_SUCCESS, EXIT_USAGE_ERROR, type EvidenceAvailability, type EvidenceItem, type EvidenceMetadataValue, type EvidenceSet, FINDING_CONFIDENCES, FINDING_SEVERITIES, FINDING_STATUSES, type Finding, type FindingConfidence, type FindingEvidence, type FindingPenalty, type FindingSeverity, type FindingStatus, type GlobalOptions, type HealthScore, JsonReporter, LinuxPlatformAdapter, type LinuxSystemProvider, MacOSPlatformAdapter, type MemoryInfo, type ParsedRuleId, type PlatformAdapter, type PlatformInfo, type PlatformType, type PortListener, type ProcessItem, type ProjectCollectionOptions, type ProjectCollectionResult, ProjectCollectionService, ProjectCollector, type ProjectConfigInfo, ProjectDiscovery, type ProjectGitInfo, type ProjectLockfileInfo, type ProjectManifestInfo, type ProjectManifestMetadata, type ReportMetadata, type ReportModel, type ReportOptions, type ReportPayload, type Reporter, type RuleEvaluation, type RuleMetadata, type RuleRegistryInterface, type RunScanOptions, SCORE_BANDS, SEVERITY_PENALTIES, SUPPORTED_PLATFORMS, type SafeCommandOptions, type SafeCommandResult, type ScanOptions, type ScanOrchestratorOptions, ScanOrchestratorService, type ScoreBand, type ScoreCalculator, type ScoreResult, type SupportedPlatform, type SupportedProjectType, type SyncDiagnosticRule, type SystemCollectionOptions, SystemCollectionService, SystemCollector, TerminalReporter, UnsupportedPlatformAdapter, type UnsupportedSystemProvider, type UptimeInfo, WARN_PENALTY_MULTIPLIER, WindowsPlatformAdapter, type WindowsSystemProvider, allV1Rules, cache001StorageLarge, cache002BuildArtifactLarge, cacheRules, calculateScore, cfg001EnvFileMissing, cfg002RequiredValueMissing, configRules, createDefaultRuleRegistry, createFinding, createProgram, createReportModel, dep001LockfileMissing, dep002LockfileMismatch, dep003PackageManagerMismatch, dep004DirectoryInconsistent, dependencyRules, detectPlatform, disk001SpaceLow, disk002DeveloperStoragePressure, disk003ProjectLocationUnavailable, disk004FilesystemReadonly, diskRules, dispatchCommand, env001EmptyPathEntry, env002SecretExposure, env003DuplicatePath, env004ShellPathMismatch, environmentRules, executeCommand, executeSafeCommand, formatCliError, getScoreBand, git001RepositoryMissing, git002WorkingTreeDirty, git003UntrackedFiles, git004BranchDivergence, gitRules, isDiagnosticCategory, isEvidenceAvailability, isFindingConfidence, isFindingSeverity, isFindingStatus, isSupportedPlatform, isValidRuleId, net001InterfaceUnavailable, net002DnsMissing, net003ProxySuspicious, net004RouteUnavailable, networkRules, parseRuleId, path001ExecutableMissing, path002ExecutableMultiple, path003EntryInvalid, path004OrderShadowing, pathRules, port001DevConflict, port002DuplicateListener, port003UnexpectedExposure, port004ProcessUnavailable, portRules, proc001ResourceHog, proc002MemoryHog, proc003Zombie, proc004Duplicate, processRules, proj001ManifestMissing, proj002LockfileMissing, proj003RuntimePolicyMissing, proj004RootAmbiguous, projectRules, registerGlobalOptions, resolveAndValidatePath, resolvePlatformAdapter, run001NodeUnavailable, run002NodeUnpinned, run003PythonUnavailable, run004PythonUnpinned, run005JavaUnavailable, run006VersionMismatch, runCli, runtimeRules, sys001MemoryPressure, sys002CpuPressure, sys003UptimeShort, sys004ArchitectureMismatch, sys005PlatformSupported, systemRules, tool001GitUnavailable, tool002PackageManagerMismatch, tool003PackageManagerMissing, tool004DockerUnavailable, tool005ExecutableShadowing, toolRules, ver001RuntimeConflict, ver002ToolConflict, ver003ProjectRuntimeUnsatisfied, ver004ToolOutdated, versionRules };