@sanity/ailf 0.1.29 → 0.1.30

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/cli.d.ts CHANGED
@@ -5,6 +5,11 @@
5
5
  * Unified command-line interface for the AI Literacy Framework.
6
6
  * All evaluation commands are exposed as subcommands under `ailf`.
7
7
  *
8
+ * Commands are organized into semantic groups (Core Workflow, Analysis &
9
+ * Reports, etc.) using Commander v14's native `helpGroup()` API. The
10
+ * custom help formatter in `./commands/shared/help.ts` adds styling and
11
+ * appends Quick Start examples.
12
+ *
8
13
  * Usage:
9
14
  * ailf pipeline [flags] # full evaluation pipeline
10
15
  * ailf compare [flags] # compare evaluation runs
package/dist/cli.js CHANGED
@@ -7,6 +7,11 @@
7
7
  * Unified command-line interface for the AI Literacy Framework.
8
8
  * All evaluation commands are exposed as subcommands under `ailf`.
9
9
  *
10
+ * Commands are organized into semantic groups (Core Workflow, Analysis &
11
+ * Reports, etc.) using Commander v14's native `helpGroup()` API. The
12
+ * custom help formatter in `./commands/shared/help.ts` adds styling and
13
+ * appends Quick Start examples.
14
+ *
10
15
  * Usage:
11
16
  * ailf pipeline [flags] # full evaluation pipeline
12
17
  * ailf compare [flags] # compare evaluation runs
@@ -74,12 +79,13 @@ else if (process.argv.includes("--quiet") || process.argv.includes("-q")) {
74
79
  // Build CLI program
75
80
  // ---------------------------------------------------------------------------
76
81
  import { Command } from "commander";
82
+ import { CommandGroup, configureProgram } from "./commands/shared/help.js";
77
83
  // Read version from package.json
78
84
  const pkgPath = resolve(ROOT, "package.json");
79
85
  const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
80
86
  const program = new Command()
81
87
  .name("ailf")
82
- .description("AI Literacy Framework — evaluate how well docs enable AI coding tools")
88
+ .description("AI Literacy Framework — evaluate how well docs enable AI coding tools\n\nMeasure whether AI coding agents can find the right documentation\nand produce correct implementations of your product features.")
83
89
  .version(pkg.version)
84
90
  .option("-v, --verbose", "Increase log output")
85
91
  .option("-q, --quiet", "Suppress non-error output")
@@ -87,6 +93,7 @@ const program = new Command()
87
93
  .option("--explain", "Show execution plan without running")
88
94
  .option("--format <fmt>", "Output format for --explain (console, json)", "console")
89
95
  .option("-y, --yes", "With --explain: show plan then prompt to confirm execution");
96
+ configureProgram(program);
90
97
  // ---------------------------------------------------------------------------
91
98
  // Global --explain hook — intercepts any command before execution
92
99
  // ---------------------------------------------------------------------------
@@ -114,85 +121,72 @@ program.hook("preAction", async (thisCommand, actionCommand) => {
114
121
  });
115
122
  // ---------------------------------------------------------------------------
116
123
  // Register commands
124
+ //
125
+ // Registration order determines group display order in --help.
126
+ // Within each group, commands appear in the order they are added.
117
127
  // ---------------------------------------------------------------------------
118
- // Pipeline the main orchestrator
128
+ // ── Core Workflow ──────────────────────────────────────────────────────
119
129
  import { createPipelineCommand } from "./commands/pipeline.js";
120
- program.addCommand(createPipelineCommand());
121
- // Compare — structured score comparison
130
+ program.addCommand(createPipelineCommand().helpGroup(CommandGroup.CoreWorkflow));
122
131
  import { createCompareCommand } from "./commands/compare.js";
123
- program.addCommand(createCompareCommand());
124
- // Baseline — save/compare/history
132
+ program.addCommand(createCompareCommand().helpGroup(CommandGroup.CoreWorkflow));
125
133
  import { createBaselineCommand } from "./commands/baseline.js";
126
- program.addCommand(createBaselineCommand());
127
- // Validate config validation
128
- import { createValidateCommand } from "./commands/validate.js";
129
- program.addCommand(createValidateCommand());
130
- // Coverage audit — feature coverage analysis
131
- import { createCoverageAuditCommand } from "./commands/coverage-audit.js";
132
- program.addCommand(createCoverageAuditCommand());
133
- // Weekly digest — trend digest delivery
134
- import { createWeeklyDigestCommand } from "./commands/weekly-digest.js";
135
- program.addCommand(createWeeklyDigestCommand());
136
- // Readiness report — launch readiness checklist
134
+ program.addCommand(createBaselineCommand().helpGroup(CommandGroup.CoreWorkflow));
135
+ import { createPublishCommand } from "./commands/publish.js";
136
+ program.addCommand(createPublishCommand().helpGroup(CommandGroup.CoreWorkflow));
137
+ // ── Analysis & Reports ────────────────────────────────────────────────
137
138
  import { createReadinessReportCommand } from "./commands/readiness-report.js";
138
- program.addCommand(createReadinessReportCommand());
139
- // Discovery report agent discoverability analysis
139
+ program.addCommand(createReadinessReportCommand().helpGroup(CommandGroup.AnalysisReports));
140
+ import { createCoverageAuditCommand } from "./commands/coverage-audit.js";
141
+ program.addCommand(createCoverageAuditCommand().helpGroup(CommandGroup.AnalysisReports));
140
142
  import { createDiscoveryReportCommand } from "./commands/discovery-report.js";
141
- program.addCommand(createDiscoveryReportCommand());
142
- // Grader reliability tools (consistency, compare, sensitivity, validate)
143
+ program.addCommand(createDiscoveryReportCommand().helpGroup(CommandGroup.AnalysisReports));
144
+ import { createAgentReportCommand } from "./commands/agent-report.js";
145
+ program.addCommand(createAgentReportCommand().helpGroup(CommandGroup.AnalysisReports));
146
+ import { createWeeklyDigestCommand } from "./commands/weekly-digest.js";
147
+ program.addCommand(createWeeklyDigestCommand().helpGroup(CommandGroup.AnalysisReports));
148
+ // ── Grader Reliability ────────────────────────────────────────────────
143
149
  import { createGraderCommand } from "./commands/grader/index.js";
144
- program.addCommand(createGraderCommand());
145
- // Fetch docs pull documentation from Sanity CMS
150
+ program.addCommand(createGraderCommand().helpGroup(CommandGroup.GraderReliability));
151
+ // ── Setup & Configuration ─────────────────────────────────────────────
152
+ import { createInitCommand } from "./commands/init.js";
153
+ program.addCommand(createInitCommand().helpGroup(CommandGroup.SetupConfig));
154
+ import { createValidateCommand } from "./commands/validate.js";
155
+ program.addCommand(createValidateCommand().helpGroup(CommandGroup.SetupConfig));
156
+ import { createValidateTasksCommand } from "./commands/validate-tasks.js";
157
+ program.addCommand(createValidateTasksCommand().helpGroup(CommandGroup.SetupConfig));
146
158
  import { createFetchDocsCommand } from "./commands/fetch-docs.js";
147
- program.addCommand(createFetchDocsCommand());
148
- // Generate configs — generate promptfoo config files
159
+ program.addCommand(createFetchDocsCommand().helpGroup(CommandGroup.SetupConfig));
149
160
  import { createGenerateConfigsCommand } from "./commands/generate-configs.js";
150
- program.addCommand(createGenerateConfigsCommand());
151
- // Calculate scores compute AI Literacy Scores from eval results
152
- import { createCalculateScoresCommand } from "./commands/calculate-scores.js";
153
- program.addCommand(createCalculateScoresCommand());
154
- // Eval — direct promptfoo eval passthrough
161
+ program.addCommand(createGenerateConfigsCommand().helpGroup(CommandGroup.SetupConfig));
162
+ import { createCacheCommand } from "./commands/cache.js";
163
+ program.addCommand(createCacheCommand().helpGroup(CommandGroup.SetupConfig));
164
+ // ── Pipeline Internals ────────────────────────────────────────────────
155
165
  import { createEvalCommand } from "./commands/eval.js";
156
- program.addCommand(createEvalCommand());
157
- // PR comment generate markdown PR comment
166
+ program.addCommand(createEvalCommand().helpGroup(CommandGroup.PipelineInternals));
167
+ import { createCalculateScoresCommand } from "./commands/calculate-scores.js";
168
+ program.addCommand(createCalculateScoresCommand().helpGroup(CommandGroup.PipelineInternals));
158
169
  import { createPrCommentCommand } from "./commands/pr-comment.js";
159
- program.addCommand(createPrCommentCommand());
160
- // Publish — standalone report publishing to Sanity Content Lake
161
- import { createPublishCommand } from "./commands/publish.js";
162
- program.addCommand(createPublishCommand());
163
- // Agent report — agent behavior observation report
164
- import { createAgentReportCommand } from "./commands/agent-report.js";
165
- program.addCommand(createAgentReportCommand());
166
- // Cache — local pipeline cache management
167
- import { createCacheCommand } from "./commands/cache.js";
168
- program.addCommand(createCacheCommand());
169
- // Webhook server — local development server
170
- import { createWebhookServerCommand } from "./commands/webhook-server.js";
171
- program.addCommand(createWebhookServerCommand());
172
- // Lookup doc — search Sanity for documentation articles
173
- import { createLookupDocCommand } from "./commands/lookup-doc.js";
174
- program.addCommand(createLookupDocCommand());
175
- // Measure retrieval — retrieval quality measurement
170
+ program.addCommand(createPrCommentCommand().helpGroup(CommandGroup.PipelineInternals));
176
171
  import { createMeasureRetrievalCommand } from "./commands/measure-retrieval.js";
177
- program.addCommand(createMeasureRetrievalCommand());
178
- // Init initialize a directory for AILF
179
- import { createInitCommand } from "./commands/init.js";
180
- program.addCommand(createInitCommand());
181
- // Validate tasks — standalone repo task validation
182
- import { createValidateTasksCommand } from "./commands/validate-tasks.js";
183
- program.addCommand(createValidateTasksCommand());
184
- // Interactive — guided wizard
172
+ program.addCommand(createMeasureRetrievalCommand().helpGroup(CommandGroup.PipelineInternals));
173
+ import { createLookupDocCommand } from "./commands/lookup-doc.js";
174
+ program.addCommand(createLookupDocCommand().helpGroup(CommandGroup.PipelineInternals));
175
+ import { createWebhookServerCommand } from "./commands/webhook-server.js";
176
+ program.addCommand(createWebhookServerCommand().helpGroup(CommandGroup.PipelineInternals));
177
+ // ── Developer Tools ───────────────────────────────────────────────────
185
178
  import { createInteractiveCommand } from "./commands/interactive.js";
186
- program.addCommand(createInteractiveCommand());
179
+ program.addCommand(createInteractiveCommand().helpGroup(CommandGroup.DeveloperTools));
187
180
  // Shell completion — must be registered last (needs full program tree)
188
181
  import { createCompletionCommand } from "./commands/completion.js";
189
- program.addCommand(createCompletionCommand(program));
182
+ program.addCommand(createCompletionCommand(program).helpGroup(CommandGroup.DeveloperTools));
190
183
  // ---------------------------------------------------------------------------
191
- // Parse and run — default to interactive mode when no arguments given
184
+ // Parse and run — default to showing help when no arguments given
192
185
  // ---------------------------------------------------------------------------
193
- // If no command is specified (just `ailf`), launch interactive mode
186
+ // If no command is specified (just `ailf`), show help.
187
+ // The interactive wizard is still available via `ailf interactive`.
194
188
  if (process.argv.length <= 2) {
195
- await program.parseAsync([...process.argv, "interactive"]);
189
+ program.outputHelp();
196
190
  }
197
191
  else {
198
192
  await program.parseAsync();
@@ -5,7 +5,7 @@
5
5
  * options object, bridges to process.env for downstream modules, and
6
6
  * delegates to runPipeline().
7
7
  *
8
- * @see docs/API.md for the full flag reference.
8
+ * @see docs/CLI.md for the full flag reference.
9
9
  */
10
10
  import { Command } from "commander";
11
11
  /**
@@ -5,7 +5,7 @@
5
5
  * options object, bridges to process.env for downstream modules, and
6
6
  * delegates to runPipeline().
7
7
  *
8
- * @see docs/API.md for the full flag reference.
8
+ * @see docs/CLI.md for the full flag reference.
9
9
  */
10
10
  import { Command } from "commander";
11
11
  import { addAgenticOptions, addDebugOptions, addSanitySourceOptions, } from "./shared/options.js";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Custom help configuration for the AILF CLI.
3
+ *
4
+ * Uses Commander v14's native help customization APIs:
5
+ * - `helpGroup()` on Command for grouped subcommand listings
6
+ * - `configureHelp()` with a custom Help subclass for styling
7
+ * - `addHelpText('after', ...)` for contextual examples
8
+ *
9
+ * This avoids ad-hoc console.log formatting and keeps help output
10
+ * consistent, testable, and automatically aligned with the command tree.
11
+ */
12
+ import { type Command } from "commander";
13
+ /**
14
+ * Semantic group headings displayed in `ailf --help`.
15
+ *
16
+ * Groups appear in the order their first member is registered with the
17
+ * program. Keep the registration order in cli.ts intentional.
18
+ */
19
+ export declare const CommandGroup: {
20
+ readonly CoreWorkflow: "Core Workflow:";
21
+ readonly AnalysisReports: "Analysis & Reports:";
22
+ readonly GraderReliability: "Grader Reliability:";
23
+ readonly SetupConfig: "Setup & Configuration:";
24
+ readonly PipelineInternals: "Pipeline Internals:";
25
+ readonly DeveloperTools: "Developer Tools:";
26
+ };
27
+ export type CommandGroupHeading = (typeof CommandGroup)[keyof typeof CommandGroup];
28
+ /**
29
+ * Apply help configuration to the root program.
30
+ *
31
+ * Call this once in cli.ts after creating the program but before
32
+ * registering commands. It:
33
+ * 1. Sets the custom Help formatter via `configureHelp()`
34
+ * 2. Appends Quick Start examples via `addHelpText('after', ...)`
35
+ * 3. Customizes the built-in help command description
36
+ */
37
+ export declare function configureProgram(program: Command): void;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Custom help configuration for the AILF CLI.
3
+ *
4
+ * Uses Commander v14's native help customization APIs:
5
+ * - `helpGroup()` on Command for grouped subcommand listings
6
+ * - `configureHelp()` with a custom Help subclass for styling
7
+ * - `addHelpText('after', ...)` for contextual examples
8
+ *
9
+ * This avoids ad-hoc console.log formatting and keeps help output
10
+ * consistent, testable, and automatically aligned with the command tree.
11
+ */
12
+ import { Help } from "commander";
13
+ // ---------------------------------------------------------------------------
14
+ // Command group headings
15
+ // ---------------------------------------------------------------------------
16
+ /**
17
+ * Semantic group headings displayed in `ailf --help`.
18
+ *
19
+ * Groups appear in the order their first member is registered with the
20
+ * program. Keep the registration order in cli.ts intentional.
21
+ */
22
+ export const CommandGroup = {
23
+ CoreWorkflow: "Core Workflow:",
24
+ AnalysisReports: "Analysis & Reports:",
25
+ GraderReliability: "Grader Reliability:",
26
+ SetupConfig: "Setup & Configuration:",
27
+ PipelineInternals: "Pipeline Internals:",
28
+ DeveloperTools: "Developer Tools:",
29
+ };
30
+ // ---------------------------------------------------------------------------
31
+ // Custom Help formatter
32
+ // ---------------------------------------------------------------------------
33
+ /**
34
+ * Extended Help class that adds subtle ANSI styling to section headings.
35
+ *
36
+ * Commander v14 calls these style methods during `formatHelp()`.
37
+ * Terminal emulators that don't support ANSI codes degrade gracefully
38
+ * (the escape sequences are invisible in raw-mode pipes like `| cat`).
39
+ */
40
+ class AilfHelp extends Help {
41
+ /** Bold section titles (Options:, Commands:, group headings). */
42
+ styleTitle(str) {
43
+ if (!hasColorSupport())
44
+ return str;
45
+ return `\x1b[1m${str}\x1b[0m`;
46
+ }
47
+ /** Dim the description text slightly for visual hierarchy. */
48
+ styleDescriptionText(str) {
49
+ if (!hasColorSupport())
50
+ return str;
51
+ return `\x1b[2m${str}\x1b[0m`;
52
+ }
53
+ }
54
+ // ---------------------------------------------------------------------------
55
+ // Color support detection
56
+ // ---------------------------------------------------------------------------
57
+ /** Conservative check — disable color when piped or when NO_COLOR is set. */
58
+ function hasColorSupport() {
59
+ if (process.env.NO_COLOR !== undefined)
60
+ return false;
61
+ if (process.env.FORCE_COLOR !== undefined)
62
+ return true;
63
+ return Boolean(process.stdout.isTTY);
64
+ }
65
+ // ---------------------------------------------------------------------------
66
+ // After-help text (Quick Start + links)
67
+ // ---------------------------------------------------------------------------
68
+ const afterHelpText = `
69
+ Quick Start:
70
+ $ ailf pipeline --debug Run a quick evaluation (first 2 tests)
71
+ $ ailf pipeline --area groq Evaluate a specific feature area
72
+ $ ailf pipeline --explain Preview the execution plan
73
+ $ ailf init Set up AILF in a new project
74
+
75
+ Documentation:
76
+ Repository https://github.com/sanity-io/ai-literacy-framework
77
+ CLI Guide https://github.com/sanity-io/ai-literacy-framework/blob/main/docs/CLI.md
78
+ Getting Started https://github.com/sanity-io/ai-literacy-framework/blob/main/docs/GETTING_STARTED.md
79
+
80
+ Run ailf <command> --help for detailed usage of any command.`;
81
+ // ---------------------------------------------------------------------------
82
+ // Program configuration
83
+ // ---------------------------------------------------------------------------
84
+ /**
85
+ * Apply help configuration to the root program.
86
+ *
87
+ * Call this once in cli.ts after creating the program but before
88
+ * registering commands. It:
89
+ * 1. Sets the custom Help formatter via `configureHelp()`
90
+ * 2. Appends Quick Start examples via `addHelpText('after', ...)`
91
+ * 3. Customizes the built-in help command description
92
+ */
93
+ export function configureProgram(program) {
94
+ program
95
+ .configureHelp(new AilfHelp())
96
+ .addHelpText("after", afterHelpText)
97
+ .addHelpCommand("help [command]", "Show help for a command");
98
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "restricted"