{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "https://github.com/user/pi-agent-extensions/auto-rename/auto-rename.schema.json",
	"title": "Auto-Rename Configuration",
	"description": "Configuration for the pi auto-rename extension that automatically generates session names.",
	"type": "object",
	"definitions": {
		"modelConfig": {
			"type": "object",
			"description": "LLM model configuration.",
			"properties": {
				"provider": {
					"type": "string",
					"description": "LLM provider name (e.g., 'anthropic', 'openai', 'google', 'ollama').",
					"examples": ["anthropic", "openai", "google", "ollama", "groq", "mistral", "xai"]
				},
				"id": {
					"type": "string",
					"description": "Model ID within the provider.",
					"examples": ["claude-3-5-haiku-20241022", "gpt-4o-mini", "gemini-2.0-flash", "llama3.2"]
				}
			},
			"required": ["provider", "id"],
			"additionalProperties": false
		}
	},
	"properties": {
		"model": {
			"oneOf": [
				{ "$ref": "#/definitions/modelConfig" },
				{ "type": "null" }
			],
			"description": "Primary LLM model to use for generating session names. Set to null to use auto-selection strategy.",
			"default": null
		},
		"fallbackModel": {
			"oneOf": [
				{ "$ref": "#/definitions/modelConfig" },
				{ "type": "null" }
			],
			"description": "Fallback LLM model if primary is unavailable or fails. Set to null to skip explicit fallback.",
			"default": null
		},
		"fallbackDeterministic": {
			"type": "string",
			"enum": ["truncate", "words", "none", "readable-id"],
			"description": "Deterministic fallback method if all LLM models fail. 'truncate': first 50 chars. 'words': first 6 words. 'readable-id': adjective-noun-noun from session ID. 'none': don't set a name.",
			"default": "readable-id"
		},
		"modelSelection": {
			"type": "string",
			"enum": ["current", "cheapest"],
			"description": "Auto-selection strategy when model and fallbackModel are null. 'current': current model first, then cheapest. 'cheapest': cheapest first, then current.",
			"default": "current"
		},
		"wordlistPath": {
			"type": ["string", "null"],
			"description": "Path to a custom word_lists.toml file for readable-id generation. Relative paths are resolved from the session cwd.",
			"default": null
		},
		"wordlist": {
			"type": "object",
			"description": "Inline wordlist override for readable-id generation.",
			"properties": {
				"adjectives": { "type": "array", "items": { "type": "string" } },
				"nouns": { "type": "array", "items": { "type": "string" } }
			},
			"additionalProperties": false
		},
		"prompt": {
			"type": "string",
			"description": "Prompt template for name generation. Use {{query}} as placeholder for the user's first message.",
			"default": "Generate a short, descriptive title (max 6 words) for a chat session based on this first message:\n\n<message>\n{{query}}\n</message>\n\nRules:\n- Be concise and specific\n- Use title case\n- No quotes or punctuation at the end\n- Focus on the main topic or intent\n- If unclear, use a generic but relevant title\n\nReply with ONLY the title, nothing else."
		},
		"prefix": {
			"type": "string",
			"description": "Static prefix added before generated names. Ignored if prefixCommand is set and succeeds.",
			"default": "",
			"examples": ["[auto] ", "🔧 ", "work: "]
		},
		"prefixCommand": {
			"type": ["string", "null"],
			"description": "Shell command to generate dynamic prefix. Runs in session's cwd, stdout is trimmed. Falls back to static prefix on error. Has 5-second timeout.",
			"default": null,
			"examples": [
				"basename $(git rev-parse --show-toplevel 2>/dev/null || pwd)",
				"git branch --show-current 2>/dev/null || echo 'main'",
				"basename $(pwd)",
				"echo $PROJECT_NAME"
			]
		},
		"prefixOnly": {
			"type": "boolean",
			"description": "If true, skip LLM generation and use only the prefix (static or from command) as the full session name.",
			"default": false
		},
		"readableIdSuffix": {
			"type": "boolean",
			"description": "If true, append a deterministic readable-id (adjective-noun-noun) to the generated name.",
			"default": false
		},
		"readableIdEnv": {
			"type": ["string", "null"],
			"description": "Environment variable that can provide a readable-id suffix override. When set and non-empty, its value is used instead of the wordlist-derived suffix.",
			"default": "PI_SESSION_READABLE_ID"
		},
		"maxQueryLength": {
			"type": "integer",
			"description": "Maximum number of characters from the user query to include in the LLM prompt. Longer queries have their middle cut out, preserving the beginning and end. Prevents excessive token usage on very long first messages.",
			"default": 2000,
			"minimum": 100,
			"maximum": 50000
		},
		"maxNameLength": {
			"type": "integer",
			"description": "Maximum number of characters allowed for the generated session name (before prefix/suffix). LLM responses exceeding this limit are truncated at a word boundary with an ellipsis.",
			"default": 80,
			"minimum": 10,
			"maximum": 500
		},
		"enabled": {
			"type": "boolean",
			"description": "Enable or disable auto-rename functionality.",
			"default": true
		},
		"debug": {
			"type": "boolean",
			"description": "Enable debug notifications for troubleshooting.",
			"default": false
		}
	},
	"additionalProperties": false,
	"examples": [
		{
			"model": null,
			"fallbackModel": null,
			"modelSelection": "current",
			"enabled": true
		},
		{
			"prefixCommand": "basename $(git rev-parse --show-toplevel 2>/dev/null || pwd)",
			"prefixOnly": true
		},
		{
			"model": { "provider": "openai", "id": "gpt-4o-mini" },
			"fallbackModel": null,
			"fallbackDeterministic": "words",
			"prefixCommand": "git branch --show-current",
			"prefix": "main"
		},
		{
			"model": { "provider": "ollama", "id": "llama3.2" },
			"fallbackModel": { "provider": "anthropic", "id": "claude-3-5-haiku-20241022" },
			"fallbackDeterministic": "readable-id"
		}
	]
}
