@forge-ts/gen 0.5.0 → 0.6.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
@@ -11,6 +11,13 @@ interface DocPage {
11
11
  content: string;
12
12
  /** Frontmatter fields */
13
13
  frontmatter: Record<string, string | number | boolean>;
14
+ /**
15
+ * When true, this page is scaffolding intended for human/agent editing.
16
+ * Stub pages are created only on the first build and never overwritten,
17
+ * preserving manual edits across subsequent `forge-ts build` runs.
18
+ * Auto-generated pages (stub=false) are always regenerated from source.
19
+ */
20
+ stub?: boolean;
14
21
  }
15
22
  /**
16
23
  * Options controlling the doc site generator.
@@ -25,6 +32,10 @@ interface SiteGeneratorOptions {
25
32
  projectName: string;
26
33
  /** Project description */
27
34
  projectDescription?: string;
35
+ /** Repository URL (auto-detected from package.json). */
36
+ repositoryUrl?: string;
37
+ /** npm package name for install commands. */
38
+ packageName?: string;
28
39
  }
29
40
  /**
30
41
  * Groups symbols by their package based on file path.
@@ -48,8 +59,12 @@ declare function groupSymbolsByPackage(symbols: ForgeSymbol[], rootDir: string):
48
59
  /**
49
60
  * Generates a full multi-page documentation site from symbols grouped by package.
50
61
  *
51
- * Produces an index page, a getting-started page, and per-package pages for
52
- * the API reference, types, functions, and examples.
62
+ * Follows a 5-stage information architecture:
63
+ * 1. ORIENT Landing page, Getting Started
64
+ * 2. LEARN — Concepts (stub)
65
+ * 3. BUILD — Guides (stub)
66
+ * 4. REFERENCE — API Reference, Types, Configuration, Changelog
67
+ * 5. COMMUNITY — FAQ, Contributing (stubs)
53
68
  *
54
69
  * @param symbolsByPackage - Symbols grouped by package name.
55
70
  * @param config - The resolved {@link ForgeConfig}.
@@ -80,6 +95,13 @@ interface GeneratedFile {
80
95
  path: string;
81
96
  /** File content (string for text). */
82
97
  content: string;
98
+ /**
99
+ * When true, this file is scaffolding intended for human/agent editing.
100
+ * Stub files are created only on the first build and never overwritten,
101
+ * preserving manual edits across subsequent `forge-ts build` runs.
102
+ * Callers should check this flag and skip writing if the file exists.
103
+ */
104
+ stub?: boolean;
83
105
  }
84
106
  /**
85
107
  * Style guide configuration for the SSG target.
@@ -135,6 +157,22 @@ interface AdapterContext {
135
157
  /** Output directory for generated docs. */
136
158
  outDir: string;
137
159
  }
160
+ /**
161
+ * Command to start a local dev server for doc preview.
162
+ * @public
163
+ */
164
+ interface DevServerCommand {
165
+ /** The binary to execute (e.g., "npx", "node"). */
166
+ bin: string;
167
+ /** Arguments to pass to the binary. */
168
+ args: string[];
169
+ /** Working directory to run from. */
170
+ cwd: string;
171
+ /** Human-readable label for the command. */
172
+ label: string;
173
+ /** The URL the dev server will be available at. */
174
+ url: string;
175
+ }
138
176
  /**
139
177
  * The central SSG adapter interface.
140
178
  * Every doc platform provider implements this contract.
@@ -204,6 +242,21 @@ interface SSGAdapter {
204
242
  * ```
205
243
  */
206
244
  generateConfig(context: AdapterContext): GeneratedFile[];
245
+ /**
246
+ * Get the command to start the local dev server for this platform.
247
+ * Called by `forge-ts docs dev`.
248
+ *
249
+ * @param outDir - The docs output directory.
250
+ * @returns The shell command and args to spawn, plus a display label.
251
+ * @example
252
+ * ```typescript
253
+ * import { getAdapter } from "@forge-ts/gen";
254
+ * const adapter = getAdapter("mintlify");
255
+ * const cmd = adapter.getDevCommand("./docs");
256
+ * // { bin: "npx", args: ["@mintlify/cli", "dev"], cwd: "./docs" }
257
+ * ```
258
+ */
259
+ getDevCommand(outDir: string): DevServerCommand;
207
260
  /**
208
261
  * Check if a scaffold already exists in the output directory.
209
262
  * Used for safety checks before init or target change.
@@ -357,6 +410,57 @@ interface ReadmeSyncOptions {
357
410
  */
358
411
  declare function syncReadme(readmePath: string, symbols: ForgeSymbol[], options?: ReadmeSyncOptions): Promise<boolean>;
359
412
 
413
+ /**
414
+ * A generated skill package following the agentskills.io directory structure.
415
+ * Contains SKILL.md plus optional references and scripts files.
416
+ *
417
+ * @public
418
+ */
419
+ interface SkillPackage {
420
+ /** The skill directory name (lowercase, hyphens only, max 64 chars). */
421
+ directoryName: string;
422
+ /** Files to write inside the skill directory. */
423
+ files: Array<{
424
+ path: string;
425
+ content: string;
426
+ }>;
427
+ }
428
+ /**
429
+ * Generates an agentskills.io-compliant skill package for ANY TypeScript project.
430
+ *
431
+ * All content is derived from the project's exported symbols and metadata.
432
+ * No hardcoded project-specific content. Works for any project that forge-ts analyzes.
433
+ *
434
+ * @param symbols - All symbols from the project.
435
+ * @param config - The resolved forge-ts config.
436
+ * @returns A {@link SkillPackage} describing the directory and its files.
437
+ * @example
438
+ * ```typescript
439
+ * import { generateSkillPackage } from "@forge-ts/gen";
440
+ * const pkg = generateSkillPackage(symbols, config);
441
+ * console.log(pkg.directoryName); // "my-lib"
442
+ * console.log(pkg.files.map(f => f.path));
443
+ * // ["SKILL.md", "references/API-REFERENCE.md", ...]
444
+ * ```
445
+ * @public
446
+ */
447
+ declare function generateSkillPackage(symbols: ForgeSymbol[], config: ForgeConfig): SkillPackage;
448
+ /**
449
+ * Generates a SKILL.md string following the Agent Skills specification.
450
+ * Generic for any TypeScript project — content derived from symbols.
451
+ *
452
+ * @param symbols - All symbols from the project.
453
+ * @param config - The resolved forge-ts config.
454
+ * @returns The SKILL.md content as a string.
455
+ * @example
456
+ * ```typescript
457
+ * import { generateSkillMd } from "@forge-ts/gen";
458
+ * const skill = generateSkillMd(symbols, config);
459
+ * ```
460
+ * @public
461
+ */
462
+ declare function generateSkillMd(symbols: ForgeSymbol[], config: ForgeConfig): string;
463
+
360
464
  /**
361
465
  * A single generated SSG configuration file.
362
466
  * @public
@@ -397,10 +501,35 @@ declare function generateSSGConfigs(pages: DocPage[], target: "docusaurus" | "mi
397
501
  * @public
398
502
  */
399
503
 
504
+ /**
505
+ * Options for the generation pipeline.
506
+ *
507
+ * @public
508
+ */
509
+ interface GenerateOptions {
510
+ /**
511
+ * When true, overwrite stub pages even if they already exist on disk.
512
+ * Normally stub pages (concepts, guides, faq, contributing, changelog)
513
+ * are only created on the first build to preserve manual edits.
514
+ * Use this to reset stubs to their scaffolding state.
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * await generate(config, { forceStubs: true });
519
+ * ```
520
+ */
521
+ forceStubs?: boolean;
522
+ }
400
523
  /**
401
524
  * Runs the full generation pipeline: walk → render → write.
402
525
  *
526
+ * Auto-generated pages are always regenerated from source code.
527
+ * Stub pages (scaffolding for human/agent editing) are only created
528
+ * if they don't already exist, preserving manual edits across builds.
529
+ * Pass `{ forceStubs: true }` to overwrite stubs.
530
+ *
403
531
  * @param config - The resolved {@link ForgeConfig} for the project.
532
+ * @param options - Optional generation flags (e.g., forceStubs).
404
533
  * @returns A {@link ForgeResult} describing the outcome.
405
534
  * @example
406
535
  * ```typescript
@@ -411,6 +540,6 @@ declare function generateSSGConfigs(pages: DocPage[], target: "docusaurus" | "mi
411
540
  * @public
412
541
  * @packageDocumentation
413
542
  */
414
- declare function generate(config: ForgeConfig): Promise<ForgeResult>;
543
+ declare function generate(config: ForgeConfig, options?: GenerateOptions): Promise<ForgeResult>;
415
544
 
416
- export { type AdapterContext, DEFAULT_TARGET, type DocPage, type GeneratedFile, type MarkdownOptions, type ReadmeSyncOptions, type SSGAdapter, type SSGConfigFile, type SSGStyleGuide, type SSGTarget, type ScaffoldManifest, type SiteGeneratorOptions, generate, generateDocSite, generateLlmsFullTxt, generateLlmsTxt, generateMarkdown, generateSSGConfigs, getAdapter, getAvailableTargets, groupSymbolsByPackage, registerAdapter, syncReadme };
545
+ export { type AdapterContext, DEFAULT_TARGET, type DevServerCommand, type DocPage, type GenerateOptions, type GeneratedFile, type MarkdownOptions, type ReadmeSyncOptions, type SSGAdapter, type SSGConfigFile, type SSGStyleGuide, type SSGTarget, type ScaffoldManifest, type SiteGeneratorOptions, type SkillPackage, generate, generateDocSite, generateLlmsFullTxt, generateLlmsTxt, generateMarkdown, generateSSGConfigs, generateSkillMd, generateSkillPackage, getAdapter, getAvailableTargets, groupSymbolsByPackage, registerAdapter, syncReadme };