@runhalo/cli 0.3.0 → 0.4.1

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.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Halo CLI - Child Safety Compliance Scanner
4
4
  * Usage: runhalo scan <path> [options]
5
5
  */
6
- import { HaloEngine, Violation, ScanResult, EngineConfig } from '@runhalo/engine';
6
+ import { HaloEngine, Violation, ScanResult, EngineConfig, JSONRule } from '@runhalo/engine';
7
7
  type OutputFormat = 'json' | 'sarif' | 'text';
8
8
  interface CLIOptions {
9
9
  format: OutputFormat;
@@ -15,6 +15,13 @@ interface CLIOptions {
15
15
  verbose: boolean;
16
16
  ethicalPreview: boolean;
17
17
  report: string | boolean;
18
+ aiAudit: boolean;
19
+ sectorAuSbd: boolean;
20
+ sectorAuOsa: boolean;
21
+ pack: string[];
22
+ offline: boolean;
23
+ framework?: string;
24
+ astAnalysis?: boolean;
18
25
  }
19
26
  /**
20
27
  * Format violations as SARIF output
@@ -42,6 +49,11 @@ declare function generateHtmlReport(results: ScanResult[], scoreResult: any, fil
42
49
  * Escape HTML special characters
43
50
  */
44
51
  declare function escapeHtml(text: string): string;
52
+ /**
53
+ * Generate a government-procurement-grade PDF compliance report.
54
+ * Uses PDFKit — pure JS, no browser dependencies, CI-safe.
55
+ */
56
+ declare function generatePdfReport(results: ScanResult[], scoreResult: any, fileCount: number, projectPath: string, history?: ScanHistoryEntry[]): Promise<Buffer>;
45
57
  /**
46
58
  * Create a Halo engine instance
47
59
  */
@@ -58,17 +70,59 @@ declare const HALO_CONFIG_DIR: string;
58
70
  declare const HALO_CONFIG_PATH: string;
59
71
  declare const HALO_HISTORY_PATH: string;
60
72
  declare const MAX_HISTORY_ENTRIES = 100;
73
+ declare const RULES_CACHE_PATH: string;
74
+ interface RulesCache {
75
+ etag: string | null;
76
+ packs: string[];
77
+ rules: JSONRule[];
78
+ fetchedAt: string;
79
+ }
80
+ /**
81
+ * Fetch rules from the Supabase rules-fetch edge function.
82
+ * Returns raw JSON rules (not compiled) or null on failure.
83
+ */
84
+ declare function fetchRulesFromAPI(packs: string[], verbose: boolean): Promise<{
85
+ rules: JSONRule[];
86
+ etag: string | null;
87
+ } | null>;
88
+ /**
89
+ * Read the local rules cache.
90
+ */
91
+ declare function readRulesCache(): RulesCache | null;
92
+ /**
93
+ * Write rules to the local cache.
94
+ */
95
+ declare function writeRulesCache(etag: string | null, packs: string[], rules: JSONRule[]): void;
96
+ /**
97
+ * Load bundled baseline rules from @runhalo/engine's rules.json.
98
+ */
99
+ declare function loadBaselineRules(packs: string[]): JSONRule[] | null;
100
+ /**
101
+ * Map CLI options to pack IDs.
102
+ * --pack takes precedence. Legacy flags (--ethical-preview, --ai-audit, --sector-au-sbd, --sector-au-osa) are mapped.
103
+ */
104
+ declare function resolvePacks(options: CLIOptions): string[];
105
+ /**
106
+ * Resolve rules with fallback chain:
107
+ * API (fresh) → 304 cache hit → local cache (stale OK) → bundled baseline → null
108
+ */
109
+ declare function resolveRules(packs: string[], offline: boolean, verbose: boolean): Promise<JSONRule[] | null>;
61
110
  interface HaloConfig {
62
111
  email?: string;
63
112
  prompted: boolean;
64
113
  promptedAt: string;
65
114
  consent: boolean;
115
+ license_key?: string;
116
+ tier?: 'free' | 'pro' | 'enterprise';
117
+ scans_today?: number;
118
+ scan_date?: string;
66
119
  }
67
120
  interface ScanHistoryEntry {
68
121
  scannedAt: string;
69
122
  score: number;
70
123
  grade: string;
71
124
  totalViolations: number;
125
+ suppressedCount: number;
72
126
  bySeverity: {
73
127
  critical: number;
74
128
  high: number;
@@ -83,6 +137,34 @@ declare function loadConfig(): HaloConfig | null;
83
137
  declare function saveConfig(config: HaloConfig): void;
84
138
  declare function loadHistory(): ScanHistoryEntry[];
85
139
  declare function saveHistory(entry: ScanHistoryEntry): void;
140
+ declare const FREE_SCAN_LIMIT = 5;
141
+ /**
142
+ * Validate a license key against Supabase validate-license edge function.
143
+ * Returns license info or null on failure.
144
+ */
145
+ declare function validateLicenseKey(licenseKey: string): Promise<{
146
+ valid: boolean;
147
+ tier?: string;
148
+ email?: string;
149
+ status?: string;
150
+ expires_at?: string;
151
+ error?: string;
152
+ } | null>;
153
+ /**
154
+ * Activate a license key — validates via Supabase, stores in ~/.halo/config.json.
155
+ */
156
+ declare function activateLicense(licenseKey: string): Promise<number>;
157
+ /**
158
+ * Check scan limit for free-tier users.
159
+ * Returns true if scan is allowed, false if blocked.
160
+ * CI environments always bypass limits.
161
+ */
162
+ declare function checkScanLimit(): boolean;
163
+ /**
164
+ * Check if a Pro feature is available for the current user.
165
+ * Returns true if allowed, false with upsell message if blocked.
166
+ */
167
+ declare function checkProFeature(featureName: string, flagName: string): boolean;
86
168
  /**
87
169
  * First-run email prompt — one-time, optional, non-blocking.
88
170
  * Auto-skips when: config exists, --no-prompt, !isTTY, CI env.
@@ -107,4 +189,12 @@ interface FixCLIOptions {
107
189
  * Flow: discover files → scan → filter auto-fixable → apply fixes → re-scan → write (or dry-run)
108
190
  */
109
191
  declare function fix(paths: string[], options: FixCLIOptions): Promise<number>;
110
- export { scan, fix, scanFile, scanDirectory, createEngine, formatSARIF, formatJSON, formatText, loadConfig, saveConfig, firstRunPrompt, loadHistory, saveHistory, formatTrend, generateHtmlReport, escapeHtml, HALO_CONFIG_DIR, HALO_CONFIG_PATH, HALO_HISTORY_PATH, MAX_HISTORY_ENTRIES };
192
+ interface InitOptions {
193
+ ide: boolean;
194
+ force: boolean;
195
+ }
196
+ /**
197
+ * Init command — generate IDE rules files and project configuration.
198
+ */
199
+ declare function init(projectPath: string, options: InitOptions): Promise<number>;
200
+ export { scan, fix, init, scanFile, scanDirectory, createEngine, formatSARIF, formatJSON, formatText, loadConfig, saveConfig, firstRunPrompt, loadHistory, saveHistory, formatTrend, generateHtmlReport, generatePdfReport, escapeHtml, validateLicenseKey, activateLicense, checkScanLimit, checkProFeature, resolvePacks, resolveRules, fetchRulesFromAPI, readRulesCache, writeRulesCache, loadBaselineRules, FREE_SCAN_LIMIT, HALO_CONFIG_DIR, HALO_CONFIG_PATH, HALO_HISTORY_PATH, MAX_HISTORY_ENTRIES, RULES_CACHE_PATH };