urai.config API Reference (நிரலாக்க இடைமுகக் குறிப்பேடு)
urai-ecma reads its runtime configuration from urai.config.jsonc or urai.config.json in your current working directory. The parser is powered by the Rust json5 engine, natively supporting single-line comments (//), multi-line comments (/* */), trailing commas, and unquoted identifiers.
Configuration Precedence Architecture
urai-ecma applies configuration via a strict 4-tier waterfall model:
When an option is specified via the CLI, it overrides the configuration file and environment variables. If an option is omitted everywhere, the internal Rust engine falls back to its deterministic defaults.
Master Template (urai.config.jsonc)
Generate this file automatically by running:
Detailed Field Specification
$schema
- Type:
string(URI) - Required:
No(Recommended) - Default:
"https://sanjaiyan-dev.github.io/urai-ecma/json-schema/v0/config.schema.json"
Enables JSON Schema validation and intelligent IntelliSense autocompletion in VS Code, Cursor, Windsurf, and JetBrains IDEs. As you type inside urai.config.jsonc, your editor will surface field descriptions, type checks, and valid enum values.
input_project
- Type:
string(File Path or Directory Path) - Required:
Yes(if not supplied via-i/--input-project) - CLI Flag:
-i <PATH>,--input-project <PATH> - Default:
None
Specifies the root directory of your JavaScript/TypeScript project or the path to an individual source file.
- Directory Mode (
"./src"): Scans all.js,.jsx,.ts,.tsx,.mjs,.cjsfiles recursively usingignore::WalkBuilder, respecting.gitignore,.ignore, and skipping build directories (node_modules,dist,build,target). - Single File Mode (
"./src/App.tsx"): Analyzes and optimizes only that file.
Relative paths are resolved relative to the current working directory from which urai-ecma is invoked, not the location of the config file.
output_file
- Type:
string(File Path) - Required:
Yes(if not supplied via-o/--output-file) - CLI Flag:
-o <PATH>,--output-file <PATH> - Default:
None
The destination path where the assembled, token-dense Markdown prompt will be written. If the file already exists, urai-ecma truncates and overwrites it. If parent directories do not exist, they will be created automatically.
ollama_endpoint
- Type:
string(HTTP URL) - Required:
No - CLI Flag:
-e <URL>,--ollama-endpoint <URL> - Env Variable:
OLLAMA_ENDPOINT - Default:
http://localhost:11434
The base URL of an active local or remote Ollama server (typically http://localhost:11434).
- When provided,
urai-ecmainitializes thefoyerHybrid Cache and uses the Ollama instance for:- Summarizing function bodies that lack JSDoc comments (
summarize_functions: true). - Generating natural language style descriptions for Tailwind classes (
tailwind_mode: "summarize").
- Summarizing function bodies that lack JSDoc comments (
- When omitted (
null),urai-ecmaruns in pure offline AST mode, falling back to JSDoc extraction or generating concise structural stubs without making network calls.
ollama_modelname
- Type:
string - Required:
No - CLI Flag:
-m <NAME>,--ollama-modelname <NAME> - Default:
"gemma4"(Internal Rust fallback) /"gemma4"(Config template)
The specific model tag pulled into your Ollama instance to use for semantic code summarization. High-speed, instruction-following small parameter models are recommended to minimize latency.
tailwind_mode
- Type:
string(Enum) - Allowed Values:
"remove"|"remove_aggr"|"summarize"|"preserve" - CLI Flag:
--tailwind-mode <MODE> - Default:
"remove"
Controls how the SWC JSX Visitor (ReactJsxPruner) handles className and style attributes on JSX elements:
Mode Breakdown
1. "remove" Default
Strips static string literals when their length exceeds tailwind_threshold. Crucially preserves dynamic expressions (JSXExprContainer) such as clsx(), cn(), and ternary conditions.
2. "remove_aggr"
Aggressively strips static className strings regardless of character count. Ideal for backend migrations, data modeling, or refactoring where CSS is irrelevant.
3. "summarize"
Passes class strings exceeding tailwind_threshold to the configured Ollama model with a specialized system prompt, replacing verbose strings with a single-line natural language descriptor:
4. "preserve"
Leaves all className and style attributes intact. Use this when asking an LLM to debug responsive styling or pixel-perfect layout issues.
tailwind_threshold
- Type:
number(Positive integer) - Required:
No - CLI Flag:
--tailwind-threshold <CHARS> - Default:
96
The minimum character count of a static className string required to trigger pruning in "remove" and "summarize" modes.
- Strings shorter than this threshold (e.g.,
"flex items-center") are kept intact. - Strings equal to or longer than this threshold are pruned or summarized.
summarize_functions
- Type:
boolean - Required:
No - CLI Flag:
--summarize-functions <BOOL> - Default:
true
Enables semantic function and class method pruning. When set to true:
- The visitor inspects functions (
FnDecl,ArrowExpr,ClassMethod,PrivateMethod, constructors). - It checks for JSDoc annotations (
@description,@param,@return). - If no JSDoc is present and the function line count exceeds
summarize_functions_threshold, it queries Ollama for a 1-sentence summary. - The internal body statements are cleared using
is_structural_stub_stmt—retaining hooks (use*), timers (setTimeout), DOM listeners, and JSX return statements—and a summary expression comment is appended:
summarize_functions_threshold
- Type:
number(Positive integer) - Required:
No - CLI Flag:
--summarize-functions-threshold <LINES> - Default:
5
The line count threshold required to trigger function summarization. Short utility functions (e.g., 2–4 lines) are kept intact without calling Ollama.
generate_route_table
- Type:
boolean - Required:
No - CLI Flag:
--generate-route-table <BOOL> - Default:
true
Enables the AST RouteVisitor to discover API route handlers and output a structured Markdown routing table:
- Next.js App Router: Discovers exported HTTP verbs (
GET,POST,PUT,DELETE,PATCH,HEAD,OPTIONS) fromapp/**/route.tsandpages/api/**. - NestJS: Discovers
@Controller('prefix')and method-level decorators (@Get,@Post,@Put,@Delete, etc.). - Express & Fastify: Discovers
app.get(),router.post(),fastify.delete(), including template literals (e.g.,`/users/${id}`).
analyze_react_components
- Type:
boolean - Required:
No - CLI Flag:
--analyze-react-components <BOOL> - Default:
true
Enables ReactComponentAnalyzer. Introspects uppercase functional and arrow components to extract:
- Props: Destructured keys and explicit TypeScript type annotations (
resolve_ts_type). - State Variables: Variable and setter pairs declared via
useState. - Hooks & Side-Effects: Detects and counts
useEffect,useLayoutEffect, and customuse*hooks. - Event Handlers: Attaches registered event listeners (
onClick,onChange,onSubmit). - Rendered JSX Hierarchy: Lists rendered child element tag names.
generate_file_graph
- Type:
boolean - Required:
No - CLI Flag:
--generate-file-graph <BOOL> - Default:
true
Constructs and injects two architectural overviews into the final prompt:
- ASCII Project Directory Tree: A clean visual file tree respecting
.gitignorerules. - Mermaid.js Dependency Graph: Built using
petgraph::graph::UnGraph, tracking relative ESMimport ... from './path'relationships across modules.
Complete CLI Flag Mapping
Every config option maps directly to an equivalent CLI flag:
Production Recipes
🛠️ Interactive Configuration Architect
Design, tweak, test presets, and export your configuration file right inside this interactive studio:
urai.config.jsonc Visual Architect
{
"$schema": "https://sanjaiyan-dev.github.io/urai-ecma/json-schema/v0/config.schema.json",
// Path to the project directory or single source file
"input_project": "./src",
// Target output Markdown file path
"output_file": "./output.md",
// Ollama local endpoint URL (Optional, e.g., "http://localhost:11434")
"ollama_endpoint": "http://localhost:11434",
// Ollama Model Name (e.g., "gemma4", "llama3.2")
"ollama_modelname": "gemma4",
// Tailwind CSS pruning mode: "remove" | "remove_aggr" | "summarize" | "preserve"
"tailwind_mode": "remove",
// Character length threshold for Tailwind pruning (default: 96 characters)
"tailwind_threshold": 96,
// Summarize function block bodies using local Ollama or fallback to JSDoc comments
"summarize_functions": true,
// Line count threshold to trigger function summarization (default: 5 lines)
"summarize_functions_threshold": 5,
// Extract and generate Express/Fastify/Next.js/NestJS API Route Table
"generate_route_table": true,
// Analyze React / React Native components and output detailed explanations
"analyze_react_components": true,
// Generate ASCII File Structure & Module Dependency Graph
"generate_file_graph": true
}