{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "Pi compaction configuration",
	"type": "object",
	"additionalProperties": false,
	"properties": {
		"$schema": {
			"type": "string"
		},
		"defaults": {
			"$ref": "#/$defs/policy"
		},
		"models": {
			"type": "object",
			"propertyNames": {
				"pattern": "^[^/\\s]+/\\S+$"
			},
			"additionalProperties": {
				"$ref": "#/$defs/policy"
			}
		}
	},
	"$defs": {
		"policy": {
			"type": "object",
			"additionalProperties": false,
			"properties": {
				"model": {
					"type": "string",
					"anyOf": [
						{
							"const": "current"
						},
						{
							"pattern": "^[^/\\s]+/\\S+$"
						}
					]
				},
				"effort": {
					"enum": [
						"off",
						"minimal",
						"low",
						"medium",
						"high",
						"xhigh"
					]
				},
				"auto": {
					"type": "object",
					"additionalProperties": false,
					"properties": {
						"enabled": {
							"type": "boolean"
						},
						"thresholdPercent": {
							"type": "number",
							"exclusiveMinimum": 0,
							"exclusiveMaximum": 100
						},
						"thresholdTokens": {
							"type": "integer",
							"minimum": 1,
							"maximum": 9007199254740991
						}
					},
					"not": {
						"required": [
							"thresholdPercent",
							"thresholdTokens"
						]
					}
				},
				"instructions": {
					"type": "string"
				},
				"onError": {
					"enum": [
						"cancel",
						"default"
					]
				},
				"style": {
					"enum": [
						"native",
						"claude-code",
						"codex",
						"custom"
					]
				},
				"prompt": {
					"oneOf": [
						{
							"type": "object",
							"additionalProperties": false,
							"required": [
								"system",
								"summary"
							],
							"properties": {
								"system": {
									"type": "string",
									"pattern": "\\S"
								},
								"summary": {
									"type": "string",
									"pattern": "\\S"
								}
							}
						},
						{
							"type": "string",
							"pattern": "^(global|project)/[a-zA-Z0-9][a-zA-Z0-9_-]*$"
						}
					]
				}
			}
		}
	}
}
