mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(coding-agent): use pi.dev configuration schemas (#10751)
* feat(coding-agent): use pi.dev configuration schemas * refactor(coding-agent): separate schema URL from output path * docs(coding-agent): document published schema URLs
This commit is contained in:
parent
e6b9a6af5d
commit
96abe9a5ad
14 changed files with 23 additions and 19 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
### Breaking Changes
|
||||
|
||||
- Moved the published theme JSON Schema to `schemas/theme.schema.json` and made theme loading reject unknown top-level properties and unknown properties under `colors` or `export`. Update existing theme `$schema` references to the new path, define reusable custom colors under `vars`, and remove unsupported metadata.
|
||||
- Published generated configuration schemas for models, settings, keybindings, and themes at `https://pi.dev/schemas/*.schema.json`. The theme schema moved to `https://pi.dev/schemas/theme.schema.json`; themes loaded during startup now receive the same schema validation as later reloads. Update theme `$schema` references, define reusable colors under `vars`, and remove unsupported metadata.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ Map each action identifier to one key or a list of keys:
|
|||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://pi.dev/schemas/keybindings.schema.json",
|
||||
"app.session.new": "ctrl+shift+n",
|
||||
"app.session.tree": ["ctrl+shift+t", "alt+shift+t"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Use [`models.json`](configuration.md#agent-directory) when an endpoint speaks an
|
|||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://pi.dev/schemas/models.schema.json",
|
||||
"providers": {
|
||||
"ollama": {
|
||||
"baseUrl": "http://localhost:11434/v1",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
This reference lists user-configurable settings, their types, defaults, and purposes. Project settings override agent-directory settings. Resource lists are combined. See [Configuration](configuration.md) for file locations and trust behavior.
|
||||
|
||||
Add `"$schema": "https://pi.dev/schemas/settings.schema.json"` to `settings.json` for editor validation and completion.
|
||||
|
||||
## Model and thinking
|
||||
|
||||
<a id="model-cycling"></a>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ See [CLI resources](cli.md#resources) for the command-line option.
|
|||
|
||||
## Create a custom theme
|
||||
|
||||
Copy one of the [built-in themes](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/src/modes/interactive/theme) or create a new JSON file conforming to the [schema](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/schemas/theme.schema.json). The built-in themes use OKHSL colors, with variables for colors that several roles share, so you can adjust a hue, saturation, or lightness directly.
|
||||
Copy one of the [built-in themes](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/src/modes/interactive/theme) or create a new JSON file conforming to the [schema](https://pi.dev/schemas/theme.schema.json). The built-in themes use OKHSL colors, with variables for colors that several roles share, so you can adjust a hue, saturation, or lightness directly.
|
||||
|
||||
1. Save the file as `<agent-dir>/themes/my-theme.json`. The agent directory defaults to `~/.pi/agent`.
|
||||
2. Set its `name` to `my-theme`.
|
||||
|
|
@ -95,7 +95,7 @@ Terminal default colors render as the terminal's own colors. Where Pi needs a co
|
|||
|
||||
Pi resolves chained variable references. A missing variable or circular reference makes the theme invalid. Pi uses truecolor when available, gamut-maps OKLCH to sRGB, and approximates colors for 256-color terminals. HTML exports convert OKHSL values to hexadecimal because CSS does not support them. If colors differ from their source values, check your terminal's truecolor detection and contrast settings. See [Configure Your Terminal](terminal-setup.md#override-detected-capabilities).
|
||||
|
||||
Use the [theme JSON schema](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/schemas/theme.schema.json) for the exact properties, required colors, and accepted value types.
|
||||
Use the [theme JSON schema](https://pi.dev/schemas/theme.schema.json) for the exact properties, required colors, and accepted value types.
|
||||
|
||||
Pi reports invalid theme files during startup and `/reload`.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/theme.schema.json",
|
||||
"$schema": "https://pi.dev/schemas/theme.schema.json",
|
||||
"name": "dynamic-resources",
|
||||
"vars": {
|
||||
"cyan": "#00d7ff",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/keybindings.schema.json",
|
||||
"$id": "https://pi.dev/schemas/keybindings.schema.json",
|
||||
"$comment": "This file is generated from TypeScript source. Do not edit it manually; run npm run generate:schemas.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/models.schema.json",
|
||||
"$id": "https://pi.dev/schemas/models.schema.json",
|
||||
"$comment": "This file is generated from TypeScript source. Do not edit it manually; run npm run generate:schemas.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/settings.schema.json",
|
||||
"$id": "https://pi.dev/schemas/settings.schema.json",
|
||||
"$comment": "This file is generated from TypeScript source. Do not edit it manually; run npm run generate:schemas.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/theme.schema.json",
|
||||
"$id": "https://pi.dev/schemas/theme.schema.json",
|
||||
"$comment": "This file is generated from TypeScript source. Do not edit it manually; run npm run generate:schemas.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@ import { SettingsSchema } from "../src/core/settings-schema.ts";
|
|||
import { ColorValueSchema, ThemeJsonSchema } from "../src/modes/interactive/theme/theme-schema.ts";
|
||||
|
||||
const packageDirectory = fileURLToPath(new URL("..", import.meta.url));
|
||||
const schemaBaseUrl = "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent";
|
||||
const schemaBaseUrl = "https://pi.dev/schemas";
|
||||
const schemaDraft = "https://json-schema.org/draft/2020-12/schema";
|
||||
const generatedComment =
|
||||
"This file is generated from TypeScript source. Do not edit it manually; run npm run generate:schemas.";
|
||||
|
||||
interface SchemaArtifact {
|
||||
path: `schemas/${string}.schema.json`;
|
||||
filename: `${string}.schema.json`;
|
||||
schema: TSchema;
|
||||
definitions?: Readonly<Record<string, TSchema>>;
|
||||
}
|
||||
|
||||
const schemaArtifacts: readonly SchemaArtifact[] = [
|
||||
{
|
||||
path: "schemas/models.schema.json",
|
||||
filename: "models.schema.json",
|
||||
schema: ModelsConfigSchema,
|
||||
definitions: {
|
||||
ModelCost: ModelCostSchema,
|
||||
|
|
@ -42,17 +42,17 @@ const schemaArtifacts: readonly SchemaArtifact[] = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: "schemas/settings.schema.json",
|
||||
filename: "settings.schema.json",
|
||||
schema: SettingsSchema,
|
||||
definitions: { ModelThinkingLevel: ModelThinkingLevelSchema },
|
||||
},
|
||||
{
|
||||
path: "schemas/keybindings.schema.json",
|
||||
filename: "keybindings.schema.json",
|
||||
schema: KeybindingsSchema,
|
||||
definitions: { KeybindingValue: KeybindingValueSchema },
|
||||
},
|
||||
{
|
||||
path: "schemas/theme.schema.json",
|
||||
filename: "theme.schema.json",
|
||||
schema: ThemeJsonSchema,
|
||||
definitions: { ColorValue: ColorValueSchema },
|
||||
},
|
||||
|
|
@ -131,7 +131,7 @@ function serializeSchema(artifact: SchemaArtifact): string {
|
|||
return `${JSON.stringify(
|
||||
{
|
||||
$schema: schemaDraft,
|
||||
$id: `${schemaBaseUrl}/${artifact.path}`,
|
||||
$id: `${schemaBaseUrl}/${artifact.filename}`,
|
||||
$comment: generatedComment,
|
||||
...schema,
|
||||
},
|
||||
|
|
@ -144,7 +144,7 @@ export function renderConfigSchemas(): ReadonlyMap<string, string> {
|
|||
const rendered = new Map<string, string>();
|
||||
for (const artifact of schemaArtifacts) {
|
||||
const content = serializeSchema(artifact);
|
||||
rendered.set(artifact.path, content);
|
||||
rendered.set(`schemas/${artifact.filename}`, content);
|
||||
}
|
||||
return rendered;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/theme.schema.json",
|
||||
"$schema": "https://pi.dev/schemas/theme.schema.json",
|
||||
"name": "dark",
|
||||
"appearance": "dark",
|
||||
"vars": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas/theme.schema.json",
|
||||
"$schema": "https://pi.dev/schemas/theme.schema.json",
|
||||
"name": "light",
|
||||
"appearance": "light",
|
||||
"vars": {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { SettingsManager } from "../src/core/settings-manager.ts";
|
|||
import { SettingsSchema } from "../src/core/settings-schema.ts";
|
||||
import { validateThemeJson } from "../src/modes/interactive/theme/theme-schema.ts";
|
||||
|
||||
const schemaBaseUrl = "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/schemas";
|
||||
const schemaBaseUrl = "https://pi.dev/schemas";
|
||||
const temporaryDirectories: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue