@forge-ts/core 0.7.2 → 0.13.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 +501 -1
- package/dist/index.js +535 -28
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,253 @@
|
|
|
1
|
+
import { TSDocConfiguration } from '@microsoft/tsdoc';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Append-only audit trail for forge-ts configuration and governance events.
|
|
5
|
+
*
|
|
6
|
+
* Events are stored as JSON Lines in `.forge-audit.jsonl` at the project root.
|
|
7
|
+
* Each line is a single JSON object — the file is never truncated or overwritten.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Discriminated event types recorded in the audit trail.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
type AuditEventType = "config.lock" | "config.unlock" | "config.drift" | "bypass.create" | "bypass.expire" | "rule.change";
|
|
18
|
+
/**
|
|
19
|
+
* A single audit event recorded in the forge-ts audit trail.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
interface AuditEvent {
|
|
24
|
+
/** ISO 8601 timestamp of when the event occurred. */
|
|
25
|
+
timestamp: string;
|
|
26
|
+
/** Discriminated event type. */
|
|
27
|
+
event: AuditEventType;
|
|
28
|
+
/** OS username of the actor (falls back to "unknown"). */
|
|
29
|
+
user: string;
|
|
30
|
+
/** Mandatory for lock/unlock/bypass events; optional otherwise. */
|
|
31
|
+
reason?: string;
|
|
32
|
+
/** Event-specific payload. */
|
|
33
|
+
details: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the current OS username, or "unknown" if unavailable.
|
|
37
|
+
*
|
|
38
|
+
* @returns The OS username string.
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { getCurrentUser } from "@forge-ts/core/audit";
|
|
42
|
+
* const user = getCurrentUser(); // e.g. "alice"
|
|
43
|
+
* ```
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
declare function getCurrentUser(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Appends a single audit event to the `.forge-audit.jsonl` file.
|
|
49
|
+
*
|
|
50
|
+
* Creates the file if it does not exist. The file is strictly append-only —
|
|
51
|
+
* existing content is never modified or truncated.
|
|
52
|
+
*
|
|
53
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
54
|
+
* @param event - The audit event to record.
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { appendAuditEvent } from "@forge-ts/core";
|
|
58
|
+
* appendAuditEvent("/path/to/project", {
|
|
59
|
+
* timestamp: new Date().toISOString(),
|
|
60
|
+
* event: "config.lock",
|
|
61
|
+
* user: "alice",
|
|
62
|
+
* reason: "Stabilize v2 config",
|
|
63
|
+
* details: { hash: "abc123" },
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
declare function appendAuditEvent(rootDir: string, event: AuditEvent): void;
|
|
69
|
+
/**
|
|
70
|
+
* Options for reading the audit log.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
interface ReadAuditOptions {
|
|
75
|
+
/** Maximum number of events to return. */
|
|
76
|
+
limit?: number;
|
|
77
|
+
/** Filter to a single event type. */
|
|
78
|
+
eventType?: AuditEventType;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reads the `.forge-audit.jsonl` file and returns parsed audit events.
|
|
82
|
+
*
|
|
83
|
+
* Returns newest events first. If the file does not exist, returns an empty
|
|
84
|
+
* array.
|
|
85
|
+
*
|
|
86
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
87
|
+
* @param options - Optional limit and event type filter.
|
|
88
|
+
* @returns Array of audit events, newest first.
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* import { readAuditLog } from "@forge-ts/core";
|
|
92
|
+
* const events = readAuditLog("/path/to/project", { limit: 10 });
|
|
93
|
+
* console.log(events.length); // up to 10
|
|
94
|
+
* ```
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
declare function readAuditLog(rootDir: string, options?: ReadAuditOptions): AuditEvent[];
|
|
98
|
+
/**
|
|
99
|
+
* Formats a single audit event as a human-readable string.
|
|
100
|
+
*
|
|
101
|
+
* @param event - The audit event to format.
|
|
102
|
+
* @returns A single-line human-readable representation.
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { formatAuditEvent } from "@forge-ts/core";
|
|
106
|
+
* const line = formatAuditEvent({
|
|
107
|
+
* timestamp: "2026-03-21T12:00:00.000Z",
|
|
108
|
+
* event: "config.lock",
|
|
109
|
+
* user: "alice",
|
|
110
|
+
* reason: "Stabilize v2 config",
|
|
111
|
+
* details: { hash: "abc123" },
|
|
112
|
+
* });
|
|
113
|
+
* console.log(line);
|
|
114
|
+
* // "[2026-03-21T12:00:00.000Z] config.lock by alice — Stabilize v2 config {hash: abc123}"
|
|
115
|
+
* ```
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
declare function formatAuditEvent(event: AuditEvent): string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Bypass budget system for forge-ts config governance.
|
|
122
|
+
*
|
|
123
|
+
* Allows agents to temporarily bypass locked rules with a limited daily budget.
|
|
124
|
+
* Each bypass requires a mandatory justification and expires after a configurable
|
|
125
|
+
* duration. All bypass events are recorded in the audit trail.
|
|
126
|
+
*
|
|
127
|
+
* Bypass records are stored in `.forge-bypass.json` at the project root as a
|
|
128
|
+
* JSON array of {@link BypassRecord} objects.
|
|
129
|
+
*
|
|
130
|
+
* @packageDocumentation
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* Configuration for the bypass budget system.
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
interface BypassConfig {
|
|
139
|
+
/** Maximum number of bypasses allowed per calendar day. Default: 3 */
|
|
140
|
+
dailyBudget: number;
|
|
141
|
+
/** Duration in hours before a bypass automatically expires. Default: 24 */
|
|
142
|
+
durationHours: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A single bypass record stored in `.forge-bypass.json`.
|
|
146
|
+
*
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
interface BypassRecord {
|
|
150
|
+
/** Unique identifier for this bypass. */
|
|
151
|
+
id: string;
|
|
152
|
+
/** ISO 8601 timestamp when the bypass was created. */
|
|
153
|
+
createdAt: string;
|
|
154
|
+
/** ISO 8601 timestamp when the bypass expires. */
|
|
155
|
+
expiresAt: string;
|
|
156
|
+
/** Mandatory justification for why the bypass was created. */
|
|
157
|
+
reason: string;
|
|
158
|
+
/** Specific rule code bypassed (e.g., "E009"), or "all" for a blanket bypass. */
|
|
159
|
+
rule: string;
|
|
160
|
+
/** OS username of the actor who created the bypass. */
|
|
161
|
+
user: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a new bypass record, writes it to `.forge-bypass.json`, and appends
|
|
165
|
+
* an audit event.
|
|
166
|
+
*
|
|
167
|
+
* Throws an error if the daily budget is exhausted.
|
|
168
|
+
*
|
|
169
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
170
|
+
* @param reason - Mandatory justification for the bypass.
|
|
171
|
+
* @param rule - Specific rule code to bypass (e.g., "E009"), or "all". Defaults to "all".
|
|
172
|
+
* @param config - Optional bypass budget configuration overrides.
|
|
173
|
+
* @returns The created bypass record.
|
|
174
|
+
* @throws Error when the daily bypass budget is exhausted.
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* import { createBypass } from "@forge-ts/core";
|
|
178
|
+
* const bypass = createBypass("/path/to/project", "hotfix for release", "E009");
|
|
179
|
+
* console.log(bypass.id); // unique bypass ID
|
|
180
|
+
* ```
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
declare function createBypass(rootDir: string, reason: string, rule?: string, config?: Partial<BypassConfig>): BypassRecord;
|
|
184
|
+
/**
|
|
185
|
+
* Returns all currently active (non-expired) bypass records.
|
|
186
|
+
*
|
|
187
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
188
|
+
* @returns Array of active bypass records.
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* import { getActiveBypasses } from "@forge-ts/core";
|
|
192
|
+
* const active = getActiveBypasses("/path/to/project");
|
|
193
|
+
* console.log(`${active.length} active bypass(es)`);
|
|
194
|
+
* ```
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
197
|
+
declare function getActiveBypasses(rootDir: string): BypassRecord[];
|
|
198
|
+
/**
|
|
199
|
+
* Checks whether a specific rule has an active bypass.
|
|
200
|
+
*
|
|
201
|
+
* A rule is considered bypassed if there is an active bypass with the exact
|
|
202
|
+
* rule code or an "all" bypass.
|
|
203
|
+
*
|
|
204
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
205
|
+
* @param ruleCode - The rule code to check (e.g., "E009", "E010").
|
|
206
|
+
* @returns `true` if the rule is currently bypassed.
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* import { isRuleBypassed } from "@forge-ts/core";
|
|
210
|
+
* if (isRuleBypassed("/path/to/project", "E009")) {
|
|
211
|
+
* console.log("E009 is currently bypassed");
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
declare function isRuleBypassed(rootDir: string, ruleCode: string): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Returns the number of bypass budget slots remaining for today.
|
|
219
|
+
*
|
|
220
|
+
* Counts bypasses created today (UTC) against the configured daily budget.
|
|
221
|
+
*
|
|
222
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
223
|
+
* @param config - Optional bypass budget configuration overrides.
|
|
224
|
+
* @returns Number of remaining bypass slots for today.
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* import { getRemainingBudget } from "@forge-ts/core";
|
|
228
|
+
* const remaining = getRemainingBudget("/path/to/project");
|
|
229
|
+
* console.log(`${remaining} bypass(es) remaining today`);
|
|
230
|
+
* ```
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
declare function getRemainingBudget(rootDir: string, config?: Partial<BypassConfig>): number;
|
|
234
|
+
/**
|
|
235
|
+
* Removes expired bypass records from `.forge-bypass.json`.
|
|
236
|
+
*
|
|
237
|
+
* Also appends a `bypass.expire` audit event for each expired record removed.
|
|
238
|
+
*
|
|
239
|
+
* @param rootDir - Absolute path to the project root directory.
|
|
240
|
+
* @returns The number of expired records removed.
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* import { expireOldBypasses } from "@forge-ts/core";
|
|
244
|
+
* const removed = expireOldBypasses("/path/to/project");
|
|
245
|
+
* console.log(`${removed} expired bypass(es) removed`);
|
|
246
|
+
* ```
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
declare function expireOldBypasses(rootDir: string): number;
|
|
250
|
+
|
|
1
251
|
/**
|
|
2
252
|
* Visibility levels for exported symbols.
|
|
3
253
|
* Derived from TSDoc release tags (@public, @beta, @internal).
|
|
@@ -54,6 +304,12 @@ interface ForgeSymbol {
|
|
|
54
304
|
target: string;
|
|
55
305
|
line: number;
|
|
56
306
|
}>;
|
|
307
|
+
/** TSDoc parser messages (syntax warnings/errors) from @microsoft/tsdoc. */
|
|
308
|
+
parseMessages?: Array<{
|
|
309
|
+
messageId: string;
|
|
310
|
+
text: string;
|
|
311
|
+
line: number;
|
|
312
|
+
}>;
|
|
57
313
|
};
|
|
58
314
|
/** Human-readable type signature of the symbol. */
|
|
59
315
|
signature?: string;
|
|
@@ -90,6 +346,22 @@ interface EnforceRules {
|
|
|
90
346
|
"require-class-member-doc": RuleSeverity;
|
|
91
347
|
/** E007: Interface/type member missing documentation. */
|
|
92
348
|
"require-interface-member-doc": RuleSeverity;
|
|
349
|
+
/** W006: TSDoc syntax parse error (invalid tag, malformed block, etc.). */
|
|
350
|
+
"require-tsdoc-syntax": RuleSeverity;
|
|
351
|
+
/** E013: Exported function/class is missing a @remarks block. */
|
|
352
|
+
"require-remarks": RuleSeverity;
|
|
353
|
+
/** E014: Optional property with default is missing @defaultValue. */
|
|
354
|
+
"require-default-value": RuleSeverity;
|
|
355
|
+
/** E015: Generic symbol is missing @typeParam for its type parameters. */
|
|
356
|
+
"require-type-param": RuleSeverity;
|
|
357
|
+
/** W005: Symbol references other symbols via {@link} but has no @see tags. */
|
|
358
|
+
"require-see": RuleSeverity;
|
|
359
|
+
/** E016: Exported symbol is missing a release tag (@public, @beta, @internal). */
|
|
360
|
+
"require-release-tag": RuleSeverity;
|
|
361
|
+
/** W007: Guide FORGE:AUTO section references a symbol that no longer exists or has changed. */
|
|
362
|
+
"require-fresh-guides": RuleSeverity;
|
|
363
|
+
/** W008: Exported public symbol is not mentioned in any guide page. */
|
|
364
|
+
"require-guide-coverage": RuleSeverity;
|
|
93
365
|
}
|
|
94
366
|
/**
|
|
95
367
|
* Full configuration for a forge-ts run.
|
|
@@ -171,6 +443,71 @@ interface ForgeConfig {
|
|
|
171
443
|
*/
|
|
172
444
|
extraGotchas?: string[];
|
|
173
445
|
};
|
|
446
|
+
/** TSDoc ecosystem configuration. */
|
|
447
|
+
tsdoc: {
|
|
448
|
+
/** Write tsdoc.json to project root during init. Default: true */
|
|
449
|
+
writeConfig: boolean;
|
|
450
|
+
/** Custom tag definitions beyond the forge-ts preset. */
|
|
451
|
+
customTags: Array<{
|
|
452
|
+
tagName: string;
|
|
453
|
+
syntaxKind: "block" | "inline" | "modifier";
|
|
454
|
+
}>;
|
|
455
|
+
/** Enforcement level per standardization group. */
|
|
456
|
+
enforce: {
|
|
457
|
+
/** Core tags (e.g. @param, @returns, @remarks). Default: "error" */
|
|
458
|
+
core: "error" | "warn" | "off";
|
|
459
|
+
/** Extended tags (e.g. @example, @throws, @see). Default: "warn" */
|
|
460
|
+
extended: "error" | "warn" | "off";
|
|
461
|
+
/** Discretionary tags (@alpha, @beta, @public, @internal). Default: "off" */
|
|
462
|
+
discretionary: "error" | "warn" | "off";
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
/** Bypass budget configuration for temporary rule overrides. */
|
|
466
|
+
bypass: {
|
|
467
|
+
/** Maximum number of bypasses allowed per calendar day. Default: 3 */
|
|
468
|
+
dailyBudget: number;
|
|
469
|
+
/** Duration in hours before a bypass automatically expires. Default: 24 */
|
|
470
|
+
durationHours: number;
|
|
471
|
+
};
|
|
472
|
+
/** Guide generation configuration. */
|
|
473
|
+
guides: {
|
|
474
|
+
/** Enable intelligent guide generation. Default: true */
|
|
475
|
+
enabled: boolean;
|
|
476
|
+
/** Auto-discover guide topics from code analysis. Default: true */
|
|
477
|
+
autoDiscover: boolean;
|
|
478
|
+
/** Explicit guide definitions (supplement auto-discovered guides). */
|
|
479
|
+
custom: Array<{
|
|
480
|
+
/** URL slug for the guide (e.g., "authentication") */
|
|
481
|
+
slug: string;
|
|
482
|
+
/** Human-readable title */
|
|
483
|
+
title: string;
|
|
484
|
+
/** Glob patterns for source files to analyze */
|
|
485
|
+
sources: string[];
|
|
486
|
+
}>;
|
|
487
|
+
};
|
|
488
|
+
/** Downstream config drift guards. */
|
|
489
|
+
guards: {
|
|
490
|
+
/** tsconfig.json strictness validation. */
|
|
491
|
+
tsconfig: {
|
|
492
|
+
enabled: boolean;
|
|
493
|
+
/** Required strict-mode flags. Default: ["strict", "strictNullChecks", "noImplicitAny"] */
|
|
494
|
+
requiredFlags: string[];
|
|
495
|
+
};
|
|
496
|
+
/** Biome config drift detection. */
|
|
497
|
+
biome: {
|
|
498
|
+
enabled: boolean;
|
|
499
|
+
/** Biome rules that must stay at error level. Auto-detected on lock. */
|
|
500
|
+
lockedRules: string[];
|
|
501
|
+
};
|
|
502
|
+
/** package.json guards. */
|
|
503
|
+
packageJson: {
|
|
504
|
+
enabled: boolean;
|
|
505
|
+
/** Minimum Node.js version in engines field. */
|
|
506
|
+
minNodeVersion: string;
|
|
507
|
+
/** Required fields in package.json. */
|
|
508
|
+
requiredFields: string[];
|
|
509
|
+
};
|
|
510
|
+
};
|
|
174
511
|
/**
|
|
175
512
|
* Warnings generated during config loading (e.g., unknown keys).
|
|
176
513
|
* Populated by loadConfig(). Agents should surface these in output.
|
|
@@ -289,6 +626,150 @@ declare function defaultConfig(rootDir: string): ForgeConfig;
|
|
|
289
626
|
*/
|
|
290
627
|
declare function loadConfig(rootDir?: string): Promise<ForgeConfig>;
|
|
291
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Config locking system for forge-ts.
|
|
631
|
+
*
|
|
632
|
+
* Prevents LLM agents from silently weakening project settings by snapshotting
|
|
633
|
+
* the current config state and validating it on every subsequent run.
|
|
634
|
+
*
|
|
635
|
+
* @packageDocumentation
|
|
636
|
+
* @public
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Manifest stored in `.forge-lock.json`.
|
|
641
|
+
* Captures a point-in-time snapshot of the project's forge-ts configuration
|
|
642
|
+
* so that future runs can detect when settings have been weakened.
|
|
643
|
+
*
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
646
|
+
interface ForgeLockManifest {
|
|
647
|
+
/** Schema version of the lock manifest. */
|
|
648
|
+
version: string;
|
|
649
|
+
/** ISO-8601 timestamp when the lock was created. */
|
|
650
|
+
lockedAt: string;
|
|
651
|
+
/** Identifier of the user or agent that created the lock. */
|
|
652
|
+
lockedBy: string;
|
|
653
|
+
/** Snapshot of locked configuration values. */
|
|
654
|
+
config: {
|
|
655
|
+
/** Rule name to severity mapping from enforce.rules. */
|
|
656
|
+
rules: Record<string, string>;
|
|
657
|
+
/** tsconfig guard settings, if readable at lock time. */
|
|
658
|
+
tsconfig?: Record<string, unknown>;
|
|
659
|
+
/** Biome guard settings, if readable at lock time. */
|
|
660
|
+
biome?: Record<string, unknown>;
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* A single violation found when comparing current config against the lock.
|
|
665
|
+
*
|
|
666
|
+
* @public
|
|
667
|
+
*/
|
|
668
|
+
interface LockViolation {
|
|
669
|
+
/** Dot-path of the config field that changed (e.g., "rules.require-summary"). */
|
|
670
|
+
field: string;
|
|
671
|
+
/** The value stored in the lock file. */
|
|
672
|
+
locked: string;
|
|
673
|
+
/** The current value in the live config. */
|
|
674
|
+
current: string;
|
|
675
|
+
/** Human-readable explanation of the violation. */
|
|
676
|
+
message: string;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Reads the `.forge-lock.json` file from the given project root.
|
|
680
|
+
*
|
|
681
|
+
* @param rootDir - Absolute path to the project root.
|
|
682
|
+
* @returns The parsed lock manifest, or `null` if no lock file exists or is invalid.
|
|
683
|
+
* @example
|
|
684
|
+
* ```typescript
|
|
685
|
+
* import { readLockFile } from "@forge-ts/core";
|
|
686
|
+
* const lock = readLockFile("/path/to/project");
|
|
687
|
+
* if (lock) {
|
|
688
|
+
* console.log(`Locked at ${lock.lockedAt} by ${lock.lockedBy}`);
|
|
689
|
+
* }
|
|
690
|
+
* ```
|
|
691
|
+
* @public
|
|
692
|
+
*/
|
|
693
|
+
declare function readLockFile(rootDir: string): ForgeLockManifest | null;
|
|
694
|
+
/**
|
|
695
|
+
* Writes a {@link ForgeLockManifest} to `.forge-lock.json` in the project root.
|
|
696
|
+
*
|
|
697
|
+
* @param rootDir - Absolute path to the project root.
|
|
698
|
+
* @param manifest - The lock manifest to write.
|
|
699
|
+
* @example
|
|
700
|
+
* ```typescript
|
|
701
|
+
* import { writeLockFile, createLockManifest, loadConfig } from "@forge-ts/core";
|
|
702
|
+
* const config = await loadConfig("/path/to/project");
|
|
703
|
+
* const manifest = createLockManifest(config);
|
|
704
|
+
* writeLockFile("/path/to/project", manifest);
|
|
705
|
+
* ```
|
|
706
|
+
* @public
|
|
707
|
+
*/
|
|
708
|
+
declare function writeLockFile(rootDir: string, manifest: ForgeLockManifest): void;
|
|
709
|
+
/**
|
|
710
|
+
* Removes the `.forge-lock.json` file from the project root.
|
|
711
|
+
*
|
|
712
|
+
* @param rootDir - Absolute path to the project root.
|
|
713
|
+
* @returns `true` if the file existed and was removed, `false` otherwise.
|
|
714
|
+
* @example
|
|
715
|
+
* ```typescript
|
|
716
|
+
* import { removeLockFile } from "@forge-ts/core";
|
|
717
|
+
* const removed = removeLockFile("/path/to/project");
|
|
718
|
+
* console.log(removed ? "Lock removed" : "No lock file found");
|
|
719
|
+
* ```
|
|
720
|
+
* @public
|
|
721
|
+
*/
|
|
722
|
+
declare function removeLockFile(rootDir: string): boolean;
|
|
723
|
+
/**
|
|
724
|
+
* Creates a {@link ForgeLockManifest} from the current project config.
|
|
725
|
+
*
|
|
726
|
+
* Snapshots the enforce rule severities and guard settings so they can
|
|
727
|
+
* be compared on future runs to detect weakening.
|
|
728
|
+
*
|
|
729
|
+
* @param config - The fully-resolved {@link ForgeConfig} to snapshot.
|
|
730
|
+
* @param lockedBy - Identifier of the user or agent creating the lock. Defaults to `"forge-ts lock"`.
|
|
731
|
+
* @returns A new lock manifest ready to be written with {@link writeLockFile}.
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* import { createLockManifest, loadConfig } from "@forge-ts/core";
|
|
735
|
+
* const config = await loadConfig();
|
|
736
|
+
* const manifest = createLockManifest(config);
|
|
737
|
+
* console.log(manifest.config.rules); // { "require-summary": "error", ... }
|
|
738
|
+
* ```
|
|
739
|
+
* @public
|
|
740
|
+
*/
|
|
741
|
+
declare function createLockManifest(config: ForgeConfig, lockedBy?: string): ForgeLockManifest;
|
|
742
|
+
/**
|
|
743
|
+
* Validates the current config against a locked manifest.
|
|
744
|
+
*
|
|
745
|
+
* Returns an array of violations where the current config has weakened
|
|
746
|
+
* settings relative to the locked state. Weakening means:
|
|
747
|
+
* - A rule severity changed from `"error"` to `"warn"` or `"off"`
|
|
748
|
+
* - A rule severity changed from `"warn"` to `"off"`
|
|
749
|
+
* - A tsconfig guard was disabled
|
|
750
|
+
* - A required tsconfig flag was removed
|
|
751
|
+
* - A biome guard was disabled
|
|
752
|
+
* - A locked biome rule was removed
|
|
753
|
+
*
|
|
754
|
+
* @param config - The current fully-resolved {@link ForgeConfig}.
|
|
755
|
+
* @param lock - The lock manifest to validate against.
|
|
756
|
+
* @returns An array of {@link LockViolation} entries. Empty means no weakening detected.
|
|
757
|
+
* @example
|
|
758
|
+
* ```typescript
|
|
759
|
+
* import { validateAgainstLock, readLockFile, loadConfig } from "@forge-ts/core";
|
|
760
|
+
* const config = await loadConfig();
|
|
761
|
+
* const lock = readLockFile(config.rootDir);
|
|
762
|
+
* if (lock) {
|
|
763
|
+
* const violations = validateAgainstLock(config, lock);
|
|
764
|
+
* for (const v of violations) {
|
|
765
|
+
* console.error(`LOCK VIOLATION: ${v.message}`);
|
|
766
|
+
* }
|
|
767
|
+
* }
|
|
768
|
+
* ```
|
|
769
|
+
* @public
|
|
770
|
+
*/
|
|
771
|
+
declare function validateAgainstLock(config: ForgeConfig, lock: ForgeLockManifest): LockViolation[];
|
|
772
|
+
|
|
292
773
|
/**
|
|
293
774
|
* OpenAPI 3.2 type contracts shared across the forge-ts toolchain.
|
|
294
775
|
*
|
|
@@ -544,6 +1025,25 @@ declare function meetsVisibility(candidate: Visibility, minVisibility: Visibilit
|
|
|
544
1025
|
*/
|
|
545
1026
|
declare function filterByVisibility(symbols: ForgeSymbol[], minVisibility: Visibility): ForgeSymbol[];
|
|
546
1027
|
|
|
1028
|
+
/** Clears the TSDoc configuration cache. Intended for use in tests only. @internal */
|
|
1029
|
+
declare function clearTSDocConfigCache(): void;
|
|
1030
|
+
/**
|
|
1031
|
+
* Resolve the {@link TSDocConfiguration} to use when parsing comments in
|
|
1032
|
+
* files under `folderPath`.
|
|
1033
|
+
*
|
|
1034
|
+
* If a `tsdoc.json` file exists in or above the folder and can be loaded
|
|
1035
|
+
* without errors, its settings are applied to a fresh configuration via
|
|
1036
|
+
* {@link TSDocConfigFile.configureParser}. Otherwise the default
|
|
1037
|
+
* `TSDocConfiguration` is returned (backward-compatible behaviour).
|
|
1038
|
+
*
|
|
1039
|
+
* Results are cached per folder path so the file system is only consulted
|
|
1040
|
+
* once per unique directory.
|
|
1041
|
+
*
|
|
1042
|
+
* @param folderPath - Absolute directory path of the source file being parsed.
|
|
1043
|
+
* @returns A configured {@link TSDocConfiguration} instance.
|
|
1044
|
+
* @internal
|
|
1045
|
+
*/
|
|
1046
|
+
declare function loadTSDocConfiguration(folderPath: string): TSDocConfiguration;
|
|
547
1047
|
/**
|
|
548
1048
|
* The return type of {@link createWalker}.
|
|
549
1049
|
* @public
|
|
@@ -577,4 +1077,4 @@ interface ASTWalker {
|
|
|
577
1077
|
*/
|
|
578
1078
|
declare function createWalker(config: ForgeConfig): ASTWalker;
|
|
579
1079
|
|
|
580
|
-
export { type ASTWalker, type EnforceRules, type ForgeConfig, type ForgeError, type ForgeResult, type ForgeSymbol, type ForgeWarning, type OpenAPIDocument, type OpenAPIEncodingObject, type OpenAPIInfoObject, type OpenAPIMediaTypeObject, type OpenAPIOperationObject, type OpenAPIParameterObject, type OpenAPIPathItemObject, type OpenAPIResponseObject, type OpenAPISchemaObject, type OpenAPITagObject, type RuleSeverity, Visibility, createWalker, defaultConfig, filterByVisibility, loadConfig, meetsVisibility, resolveVisibility };
|
|
1080
|
+
export { type ASTWalker, type AuditEvent, type AuditEventType, type BypassConfig, type BypassRecord, type EnforceRules, type ForgeConfig, type ForgeError, type ForgeLockManifest, type ForgeResult, type ForgeSymbol, type ForgeWarning, type LockViolation, type OpenAPIDocument, type OpenAPIEncodingObject, type OpenAPIInfoObject, type OpenAPIMediaTypeObject, type OpenAPIOperationObject, type OpenAPIParameterObject, type OpenAPIPathItemObject, type OpenAPIResponseObject, type OpenAPISchemaObject, type OpenAPITagObject, type ReadAuditOptions, type RuleSeverity, Visibility, appendAuditEvent, clearTSDocConfigCache, createBypass, createLockManifest, createWalker, defaultConfig, expireOldBypasses, filterByVisibility, formatAuditEvent, getActiveBypasses, getCurrentUser, getRemainingBudget, isRuleBypassed, loadConfig, loadTSDocConfiguration, meetsVisibility, readAuditLog, readLockFile, removeLockFile, resolveVisibility, validateAgainstLock, writeLockFile };
|