@nathapp/nax 0.38.0 → 0.38.2

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.
Files changed (75) hide show
  1. package/dist/nax.js +3294 -2907
  2. package/package.json +2 -2
  3. package/src/agents/claude-complete.ts +72 -0
  4. package/src/agents/claude-execution.ts +189 -0
  5. package/src/agents/claude-interactive.ts +77 -0
  6. package/src/agents/claude-plan.ts +23 -8
  7. package/src/agents/claude.ts +64 -349
  8. package/src/analyze/classifier.ts +2 -1
  9. package/src/cli/config-descriptions.ts +206 -0
  10. package/src/cli/config-diff.ts +103 -0
  11. package/src/cli/config-display.ts +285 -0
  12. package/src/cli/config-get.ts +55 -0
  13. package/src/cli/config.ts +7 -618
  14. package/src/cli/plugins.ts +15 -4
  15. package/src/cli/prompts-export.ts +58 -0
  16. package/src/cli/prompts-init.ts +200 -0
  17. package/src/cli/prompts-main.ts +237 -0
  18. package/src/cli/prompts-tdd.ts +78 -0
  19. package/src/cli/prompts.ts +10 -541
  20. package/src/commands/logs-formatter.ts +201 -0
  21. package/src/commands/logs-reader.ts +171 -0
  22. package/src/commands/logs.ts +11 -362
  23. package/src/config/loader.ts +4 -15
  24. package/src/config/runtime-types.ts +451 -0
  25. package/src/config/schema-types.ts +53 -0
  26. package/src/config/schemas.ts +2 -0
  27. package/src/config/types.ts +49 -486
  28. package/src/context/auto-detect.ts +2 -1
  29. package/src/context/builder.ts +3 -2
  30. package/src/execution/crash-heartbeat.ts +77 -0
  31. package/src/execution/crash-recovery.ts +23 -365
  32. package/src/execution/crash-signals.ts +149 -0
  33. package/src/execution/crash-writer.ts +154 -0
  34. package/src/execution/lifecycle/run-setup.ts +7 -1
  35. package/src/execution/parallel-coordinator.ts +278 -0
  36. package/src/execution/parallel-executor-rectification-pass.ts +117 -0
  37. package/src/execution/parallel-executor-rectify.ts +135 -0
  38. package/src/execution/parallel-executor.ts +19 -211
  39. package/src/execution/parallel-worker.ts +148 -0
  40. package/src/execution/parallel.ts +5 -404
  41. package/src/execution/pid-registry.ts +3 -8
  42. package/src/execution/runner-completion.ts +160 -0
  43. package/src/execution/runner-execution.ts +221 -0
  44. package/src/execution/runner-setup.ts +82 -0
  45. package/src/execution/runner.ts +53 -202
  46. package/src/execution/timeout-handler.ts +100 -0
  47. package/src/hooks/runner.ts +11 -21
  48. package/src/metrics/tracker.ts +7 -30
  49. package/src/pipeline/runner.ts +2 -1
  50. package/src/pipeline/stages/completion.ts +0 -1
  51. package/src/pipeline/stages/context.ts +2 -1
  52. package/src/plugins/extensions.ts +225 -0
  53. package/src/plugins/loader.ts +40 -4
  54. package/src/plugins/types.ts +18 -221
  55. package/src/prd/index.ts +2 -1
  56. package/src/prd/validate.ts +41 -0
  57. package/src/precheck/checks-blockers.ts +15 -419
  58. package/src/precheck/checks-cli.ts +68 -0
  59. package/src/precheck/checks-config.ts +102 -0
  60. package/src/precheck/checks-git.ts +87 -0
  61. package/src/precheck/checks-system.ts +163 -0
  62. package/src/review/orchestrator.ts +19 -6
  63. package/src/review/runner.ts +17 -5
  64. package/src/routing/chain.ts +2 -1
  65. package/src/routing/loader.ts +2 -5
  66. package/src/tdd/orchestrator.ts +2 -1
  67. package/src/tdd/verdict-reader.ts +266 -0
  68. package/src/tdd/verdict.ts +6 -271
  69. package/src/utils/errors.ts +12 -0
  70. package/src/utils/git.ts +12 -5
  71. package/src/utils/json-file.ts +72 -0
  72. package/src/verification/executor.ts +2 -1
  73. package/src/verification/smart-runner.ts +23 -3
  74. package/src/worktree/manager.ts +9 -3
  75. package/src/worktree/merge.ts +3 -2
@@ -0,0 +1,451 @@
1
+ /**
2
+ * Runtime Configuration Type Definitions
3
+ *
4
+ * All configuration interfaces for nax runtime behavior,
5
+ * including execution limits, quality gates, and feature settings.
6
+ */
7
+
8
+ import type { Complexity, LlmRoutingMode, ModelMap, ModelTier, RoutingStrategyName, TddStrategy } from "./schema-types";
9
+
10
+ export interface EscalationEntry {
11
+ from: string;
12
+ to: string;
13
+ }
14
+
15
+ /** Auto mode configuration */
16
+ export interface AutoModeConfig {
17
+ enabled: boolean;
18
+ /** Default agent to use */
19
+ defaultAgent: string;
20
+ /** Fallback order when agent is rate-limited */
21
+ fallbackOrder: string[];
22
+ /** Model tier per complexity */
23
+ complexityRouting: Record<Complexity, ModelTier>;
24
+ /** Escalation config */
25
+ escalation: {
26
+ enabled: boolean;
27
+ /** Ordered tier escalation with per-tier attempt budgets */
28
+ tierOrder: Array<{ tier: string; attempts: number }>;
29
+ /** When a batch fails, escalate all stories in the batch (default: true) */
30
+ escalateEntireBatch?: boolean;
31
+ };
32
+ }
33
+
34
+ /** Rectification config (v0.11) */
35
+ export interface RectificationConfig {
36
+ /** Enable rectification loop (retry failed tests with failure context) */
37
+ enabled: boolean;
38
+ /** Max retry attempts per story (default: 2) */
39
+ maxRetries: number;
40
+ /** Timeout for full test suite run in seconds (default: 120) */
41
+ fullSuiteTimeoutSeconds: number;
42
+ /** Max characters in failure summary sent to agent (default: 2000) */
43
+ maxFailureSummaryChars: number;
44
+ /** Abort rectification if failure count increases (default: true) */
45
+ abortOnIncreasingFailures: boolean;
46
+ }
47
+
48
+ /** Regression gate config (BUG-009, BUG-026) */
49
+ export interface RegressionGateConfig {
50
+ /** Enable full-suite regression gate after scoped verification (default: true) */
51
+ enabled: boolean;
52
+ /** Timeout for full-suite regression run in seconds (default: 120) */
53
+ timeoutSeconds: number;
54
+ /** Accept timeout as pass instead of failing (BUG-026, default: true) */
55
+ acceptOnTimeout?: boolean;
56
+ /** Mode of regression gate: 'deferred' (run once after all stories), 'per-story' (run after each story), 'disabled' (default: 'deferred') */
57
+ mode?: "deferred" | "per-story" | "disabled";
58
+ /** Max rectification attempts for deferred regression gate (default: 2) */
59
+ maxRectificationAttempts?: number;
60
+ }
61
+
62
+ /** Smart test runner configuration (STR-007) */
63
+ export interface SmartTestRunnerConfig {
64
+ /** Enable smart test runner (default: true) */
65
+ enabled: boolean;
66
+ /** Glob patterns to scan for test files during import-grep fallback */
67
+ testFilePatterns: string[];
68
+ /** Fallback strategy when path-convention mapping yields no results */
69
+ fallback: "import-grep" | "full-suite";
70
+ }
71
+
72
+ /** Execution limits */
73
+ export interface ExecutionConfig {
74
+ /** Max iterations per feature run (auto-calculated from tierOrder sum if not set) */
75
+ maxIterations: number;
76
+ /** Delay between iterations (ms) */
77
+ iterationDelayMs: number;
78
+ /** Max cost (USD) before pausing */
79
+ costLimit: number;
80
+ /** Timeout per agent coding session (seconds) */
81
+ sessionTimeoutSeconds: number;
82
+ /** Verification subprocess timeout in seconds (ADR-003 Decision 4) */
83
+ verificationTimeoutSeconds: number;
84
+ /** Max stories per feature (prevents memory exhaustion) */
85
+ maxStoriesPerFeature: number;
86
+ /** Rectification loop settings (v0.11) */
87
+ rectification: RectificationConfig;
88
+ /** Regression gate settings (BUG-009) */
89
+ regressionGate: RegressionGateConfig;
90
+ /** Token budget for plugin context providers (default: 2000) */
91
+ contextProviderTokenBudget: number;
92
+ /** Test command override (null = disabled, undefined = auto-detect from package.json) */
93
+ testCommand?: string | null;
94
+ /** Lint command override (null = disabled, undefined = auto-detect from package.json) */
95
+ lintCommand?: string | null;
96
+ /** Typecheck command override (null = disabled, undefined = auto-detect from package.json) */
97
+ typecheckCommand?: string | null;
98
+ /** Use --dangerously-skip-permissions flag for agent (default: true for backward compat, SEC-1 fix) */
99
+ dangerouslySkipPermissions?: boolean;
100
+ /** Enable smart test runner to scope test runs to changed files (default: true).
101
+ * Accepts boolean for backward compat or a SmartTestRunnerConfig object. */
102
+ smartTestRunner?: boolean | SmartTestRunnerConfig;
103
+ /** Configured agent binary: claude, codex, opencode, gemini, aider (default: claude) */
104
+ agent?: string;
105
+ /** Git HEAD ref captured before agent ran — passed through pipeline for plugin reviewers (FEAT-010) */
106
+ storyGitRef?: string;
107
+ }
108
+
109
+ /** Quality gate config */
110
+ export interface QualityConfig {
111
+ /** Require typecheck to pass */
112
+ requireTypecheck: boolean;
113
+ /** Require lint to pass */
114
+ requireLint: boolean;
115
+ /** Require tests to pass */
116
+ requireTests: boolean;
117
+ /** Custom quality commands */
118
+ commands: {
119
+ typecheck?: string;
120
+ lint?: string;
121
+ test?: string;
122
+ /** Scoped test command template with {{files}} placeholder (e.g., "bun test --timeout=60000 {{files}}") */
123
+ testScoped?: string;
124
+ /** Auto-fix lint errors (e.g., "biome check --fix") */
125
+ lintFix?: string;
126
+ /** Auto-fix formatting (e.g., "biome format --write") */
127
+ formatFix?: string;
128
+ };
129
+ /** Auto-fix configuration (Phase 2) */
130
+ autofix?: {
131
+ /** Whether to auto-fix lint/format errors before escalating (default: true) */
132
+ enabled?: boolean;
133
+ /** Max auto-fix attempts (default: 2) */
134
+ maxAttempts?: number;
135
+ };
136
+ /** Append --forceExit to test command to prevent open handle hangs (default: false) */
137
+ forceExit: boolean;
138
+ /** Append --detectOpenHandles on timeout retry to diagnose hangs (default: true) */
139
+ detectOpenHandles: boolean;
140
+ /** Max retries with --detectOpenHandles before falling back to --forceExit (default: 1) */
141
+ detectOpenHandlesRetries: number;
142
+ /** Grace period in ms after SIGTERM before sending SIGKILL (default: 5000) */
143
+ gracePeriodMs: number;
144
+ /** Use --dangerously-skip-permissions for agent sessions (default: false) */
145
+ dangerouslySkipPermissions: boolean;
146
+ /** Deadline in ms to drain stdout/stderr after killing process (Bun stream workaround, default: 2000) */
147
+ drainTimeoutMs: number;
148
+ /** Shell to use for running verification commands (default: /bin/sh) */
149
+ shell: string;
150
+ /** Environment variables to strip during verification (prevents AI-optimized output) */
151
+ stripEnvVars: string[];
152
+ /** Divisor for environmental failure early escalation (default: 2 = half the tier budget) */
153
+ environmentalEscalationDivisor: number;
154
+ }
155
+
156
+ /** TDD config */
157
+ export interface TddConfig {
158
+ /** Max retries for each session before escalating */
159
+ maxRetries: number;
160
+ /** Auto-verify isolation between sessions */
161
+ autoVerifyIsolation: boolean;
162
+ /** TDD strategy override (default: 'auto') */
163
+ strategy: TddStrategy;
164
+ /** Session 3 verifier: auto-approve legitimate fixes */
165
+ autoApproveVerifier: boolean;
166
+ /** Per-session model tier overrides. Defaults: test-writer=balanced, implementer=story tier, verifier=fast */
167
+ sessionTiers?: {
168
+ /** Model tier for test-writer session (default: "balanced") */
169
+ testWriter?: ModelTier;
170
+ /** Model tier for implementer session (default: uses story's routed tier) */
171
+ implementer?: ModelTier;
172
+ /** Model tier for verifier session (default: "fast") */
173
+ verifier?: ModelTier;
174
+ };
175
+ /** Glob patterns for files test-writer can modify (soft violations, logged as warnings) */
176
+ testWriterAllowedPaths?: string[];
177
+ /** Rollback git changes when TDD fails (default: true). Prevents partial commits when TDD fails. */
178
+ rollbackOnFailure?: boolean;
179
+ /** Enable greenfield detection to force test-after on projects with no test files (default: true, BUG-010) */
180
+ greenfieldDetection?: boolean;
181
+ }
182
+
183
+ /** Constitution config */
184
+ export interface ConstitutionConfig {
185
+ /** Enable constitution loading and injection */
186
+ enabled: boolean;
187
+ /** Path to constitution file relative to nax/ directory */
188
+ path: string;
189
+ /** Maximum tokens allowed for constitution content */
190
+ maxTokens: number;
191
+ /** Skip loading global constitution (default: false) */
192
+ skipGlobal?: boolean;
193
+ }
194
+
195
+ /** Analyze config */
196
+ export interface AnalyzeConfig {
197
+ /** Enable LLM-enhanced analysis */
198
+ llmEnhanced: boolean;
199
+ /** Model tier for decompose+classify (default: balanced) */
200
+ model: ModelTier;
201
+ /** Fall back to keyword matching on LLM failure */
202
+ fallbackToKeywords: boolean;
203
+ /** Max tokens for codebase summary */
204
+ maxCodebaseSummaryTokens: number;
205
+ }
206
+
207
+ /** Review config */
208
+ export interface ReviewConfig {
209
+ /** Enable review phase */
210
+ enabled: boolean;
211
+ /** List of checks to run */
212
+ checks: Array<"typecheck" | "lint" | "test">;
213
+ /** Custom commands per check */
214
+ commands: {
215
+ typecheck?: string;
216
+ lint?: string;
217
+ test?: string;
218
+ };
219
+ }
220
+
221
+ /** Plan config */
222
+ export interface PlanConfig {
223
+ /** Model tier for planning (default: balanced) */
224
+ model: ModelTier;
225
+ /** Output path for generated spec (relative to nax/ directory) */
226
+ outputPath: string;
227
+ }
228
+
229
+ /** Acceptance validation config */
230
+ export interface AcceptanceConfig {
231
+ /** Enable acceptance test generation and validation */
232
+ enabled: boolean;
233
+ /** Maximum retry loops for fix stories (default: 2) */
234
+ maxRetries: number;
235
+ /** Generate acceptance tests during analyze (default: true) */
236
+ generateTests: boolean;
237
+ /** Path to acceptance test file (relative to feature directory) */
238
+ testPath: string;
239
+ }
240
+
241
+ /** Optimizer config (v0.10) */
242
+ export interface OptimizerConfig {
243
+ /** Enable prompt optimizer */
244
+ enabled: boolean;
245
+ /** Optimization strategy: "rule-based" | "llm" | "noop" */
246
+ strategy?: "rule-based" | "llm" | "noop";
247
+ /** Strategy-specific configurations */
248
+ strategies?: {
249
+ "rule-based"?: {
250
+ stripWhitespace?: boolean;
251
+ compactCriteria?: boolean;
252
+ deduplicateContext?: boolean;
253
+ maxPromptTokens?: number;
254
+ };
255
+ llm?: {
256
+ model?: ModelTier;
257
+ targetReduction?: number;
258
+ minPromptTokens?: number;
259
+ };
260
+ custom?: {
261
+ module?: string;
262
+ options?: Record<string, unknown>;
263
+ };
264
+ };
265
+ }
266
+
267
+ export interface PluginConfigEntry {
268
+ module: string;
269
+ config?: Record<string, unknown>;
270
+ enabled?: boolean;
271
+ }
272
+
273
+ export interface HooksConfig {
274
+ skipGlobal?: boolean;
275
+ hooks: Record<string, unknown>;
276
+ }
277
+
278
+ /** Interaction config (v0.15.0) */
279
+ export interface InteractionConfig {
280
+ /** Plugin to use for interactions (default: "cli") */
281
+ plugin: string;
282
+ /** Plugin-specific configuration */
283
+ config?: Record<string, unknown>;
284
+ /** Default settings */
285
+ defaults: {
286
+ /** Default timeout in milliseconds (default: 600000 = 10 minutes) */
287
+ timeout: number;
288
+ /** Default fallback behavior (default: "escalate") */
289
+ fallback: "continue" | "skip" | "escalate" | "abort";
290
+ };
291
+ /** Enable/disable built-in triggers */
292
+ triggers: Partial<
293
+ Record<string, boolean | { enabled: boolean; fallback?: string; timeout?: number; threshold?: number }>
294
+ >;
295
+ }
296
+
297
+ /** Test coverage context config */
298
+ export interface TestCoverageConfig {
299
+ /** Enable test coverage context injection (default: true) */
300
+ enabled: boolean;
301
+ /** Detail level for test summary */
302
+ detail: "names-only" | "names-and-counts" | "describe-blocks";
303
+ /** Max tokens for the summary (default: 500) */
304
+ maxTokens: number;
305
+ /** Test directory relative to workdir (default: auto-detect) */
306
+ testDir?: string;
307
+ /** Glob pattern for test files */
308
+ testPattern: string;
309
+ /** Scope test coverage to story-relevant files only (default: true) */
310
+ scopeToStory: boolean;
311
+ }
312
+
313
+ export interface ContextAutoDetectConfig {
314
+ enabled: boolean;
315
+ maxFiles: number;
316
+ traceImports: boolean;
317
+ }
318
+
319
+ export interface ContextConfig {
320
+ testCoverage: TestCoverageConfig;
321
+ autoDetect: ContextAutoDetectConfig;
322
+ fileInjection?: "keyword" | "disabled";
323
+ }
324
+
325
+ /** Story size gate thresholds (v0.16.0) */
326
+ export interface StorySizeGateConfig {
327
+ /** Enable story size gate (default: true) */
328
+ enabled: boolean;
329
+ /** Max acceptance criteria count before flagging (default: 6) */
330
+ maxAcCount: number;
331
+ /** Max description character length before flagging (default: 2000) */
332
+ maxDescriptionLength: number;
333
+ /** Max bullet point count before flagging (default: 8) */
334
+ maxBulletPoints: number;
335
+ }
336
+
337
+ /** Precheck configuration (v0.16.0) */
338
+ export interface PrecheckConfig {
339
+ /** Story size gate settings */
340
+ storySizeGate: StorySizeGateConfig;
341
+ }
342
+
343
+ export interface AdaptiveRoutingConfig {
344
+ minSamples: number;
345
+ costThreshold: number;
346
+ fallbackStrategy: "keyword" | "llm" | "manual";
347
+ }
348
+
349
+ /** LLM routing config */
350
+ export interface LlmRoutingConfig {
351
+ /** Model tier for routing call (default: "fast") */
352
+ model?: string;
353
+ /** Fall back to keyword strategy on LLM failure (default: true) */
354
+ fallbackToKeywords?: boolean;
355
+ /** Max input tokens for story context (default: 2000) */
356
+ /** Cache routing decisions per story ID (default: true) */
357
+ cacheDecisions?: boolean;
358
+ /** Routing mode (default: "hybrid")
359
+ * - "one-shot": batch-route ALL pending stories once at run start, use keyword fallback on cache miss
360
+ * - "per-story": route each story individually just before execution (max LLM calls = N stories)
361
+ * - "hybrid": batch-route upfront, re-route individually on retry/failure (best quality + cost balance)
362
+ */
363
+ mode?: LlmRoutingMode;
364
+ /** @deprecated Use mode instead. Will be removed in v1.0 */
365
+ batchMode?: boolean;
366
+ /** Timeout for LLM call in milliseconds (default: 30000) */
367
+ timeoutMs?: number;
368
+ /** Number of retries on LLM timeout or transient failure (default: 1) */
369
+ retries?: number;
370
+ /** Delay between retries in milliseconds (default: 1000) */
371
+ retryDelayMs?: number;
372
+ }
373
+
374
+ /** Routing config */
375
+ export interface RoutingConfig {
376
+ /** Strategy to use (default: "keyword") */
377
+ strategy: RoutingStrategyName;
378
+ /** Path to custom strategy file (required if strategy = "custom") */
379
+ customStrategyPath?: string;
380
+ /** Adaptive routing settings (used when strategy = "adaptive") */
381
+ adaptive?: AdaptiveRoutingConfig;
382
+ /** LLM routing settings (used when strategy = "llm") */
383
+ llm?: LlmRoutingConfig;
384
+ }
385
+
386
+ /** Prompt overrides config (PB-003) */
387
+ export interface PromptsConfig {
388
+ overrides?: Partial<Record<"test-writer" | "implementer" | "verifier" | "single-session" | "tdd-simple", string>>;
389
+ }
390
+
391
+ /** Decompose config (SD-003) */
392
+ export interface DecomposeConfig {
393
+ /** Trigger mode: 'auto' = decompose automatically, 'confirm' = ask user, 'disabled' = skip */
394
+ trigger: "auto" | "confirm" | "disabled";
395
+ /** Max acceptance criteria before flagging a story as oversized (default: 6) */
396
+ maxAcceptanceCriteria: number;
397
+ /** Max number of substories to generate (default: 5) */
398
+ maxSubstories: number;
399
+ /** Max complexity for any generated substory (default: 'medium') */
400
+ maxSubstoryComplexity: Complexity;
401
+ /** Max retries on decomposition validation failure (default: 2) */
402
+ maxRetries: number;
403
+ /** Model tier for decomposition LLM calls (default: 'balanced') */
404
+ model: ModelTier;
405
+ }
406
+
407
+ /** Full nax configuration */
408
+ export interface NaxConfig {
409
+ /** Schema version */
410
+ version: 1;
411
+ /** Model mapping — abstract tiers to actual model identifiers */
412
+ models: ModelMap;
413
+ /** Auto mode / routing config */
414
+ autoMode: AutoModeConfig;
415
+ /** Routing strategy config */
416
+ routing: RoutingConfig;
417
+ /** Execution limits */
418
+ execution: ExecutionConfig;
419
+ /** Quality gates */
420
+ quality: QualityConfig;
421
+ /** TDD settings */
422
+ tdd: TddConfig;
423
+ /** Constitution settings */
424
+ constitution: ConstitutionConfig;
425
+ /** Analyze settings */
426
+ analyze: AnalyzeConfig;
427
+ /** Review settings */
428
+ review: ReviewConfig;
429
+ /** Plan settings */
430
+ plan: PlanConfig;
431
+ /** Acceptance validation settings */
432
+ acceptance: AcceptanceConfig;
433
+ /** Context injection settings */
434
+ context: ContextConfig;
435
+ /** Optimizer settings (v0.10) */
436
+ optimizer?: OptimizerConfig;
437
+ /** Plugin configurations (v0.10) */
438
+ plugins?: PluginConfigEntry[];
439
+ /** Disabled plugin names (v0.38.2) */
440
+ disabledPlugins?: string[];
441
+ /** Hooks configuration (v0.10) */
442
+ hooks?: HooksConfig;
443
+ /** Interaction settings (v0.15.0) */
444
+ interaction?: InteractionConfig;
445
+ /** Precheck settings (v0.16.0) */
446
+ precheck?: PrecheckConfig;
447
+ /** Prompt override settings (PB-003) */
448
+ prompts?: PromptsConfig;
449
+ /** Decompose settings (SD-003) */
450
+ decompose?: DecomposeConfig;
451
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * JSON Schema Type Definitions
3
+ *
4
+ * Fundamental types used to define the nax configuration schema,
5
+ * including model tier definitions and basic enumerations.
6
+ */
7
+
8
+ export type Complexity = "simple" | "medium" | "complex" | "expert";
9
+ export type TestStrategy = "test-after" | "tdd-simple" | "three-session-tdd" | "three-session-tdd-lite";
10
+ export type TddStrategy = "auto" | "strict" | "lite" | "simple" | "off";
11
+
12
+ /** Model tier names — extensible (TYPE-3 fix: preserve autocomplete for known tiers) */
13
+ export type ModelTier = "fast" | "balanced" | "powerful" | (string & {});
14
+
15
+ export interface TokenPricing {
16
+ inputPer1M: number;
17
+ outputPer1M: number;
18
+ }
19
+
20
+ export interface ModelDef {
21
+ provider: string;
22
+ model: string;
23
+ pricing?: TokenPricing;
24
+ env?: Record<string, string>;
25
+ }
26
+
27
+ export type ModelEntry = ModelDef | string;
28
+ export type ModelMap = Record<ModelTier, ModelEntry>;
29
+
30
+ export interface TierConfig {
31
+ tier: string;
32
+ attempts: number;
33
+ }
34
+
35
+ export type RoutingStrategyName = "keyword" | "llm" | "manual" | "adaptive" | "custom";
36
+
37
+ export type LlmRoutingMode = "one-shot" | "per-story" | "hybrid";
38
+
39
+ /** Resolve a ModelEntry (string shorthand or full object) into a ModelDef */
40
+ export function resolveModel(entry: ModelEntry): ModelDef {
41
+ if (typeof entry === "string") {
42
+ // Infer provider from model name
43
+ const provider = entry.startsWith("claude")
44
+ ? "anthropic"
45
+ : entry.startsWith("gpt") || entry.startsWith("o1") || entry.startsWith("o3")
46
+ ? "openai"
47
+ : entry.startsWith("gemini")
48
+ ? "google"
49
+ : "unknown";
50
+ return { provider, model: entry };
51
+ }
52
+ return entry;
53
+ }
@@ -251,6 +251,7 @@ const OptimizerConfigSchema = z.object({
251
251
  const PluginConfigEntrySchema = z.object({
252
252
  module: z.string().min(1, "plugin.module must be non-empty"),
253
253
  config: z.record(z.string(), z.unknown()).optional(),
254
+ enabled: z.boolean().default(true),
254
255
  });
255
256
 
256
257
  const HooksConfigSchema = z.object({
@@ -330,6 +331,7 @@ export const NaxConfigSchema = z
330
331
  context: ContextConfigSchema,
331
332
  optimizer: OptimizerConfigSchema.optional(),
332
333
  plugins: z.array(PluginConfigEntrySchema).optional(),
334
+ disabledPlugins: z.array(z.string()).optional(),
333
335
  hooks: HooksConfigSchema.optional(),
334
336
  interaction: InteractionConfigSchema.optional(),
335
337
  precheck: PrecheckConfigSchema.optional(),