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