pi-requesty-discover 3.0.1 → 3.0.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.
- package/README.adoc +4 -1
- package/README.md +4 -1
- package/docs/requesty-discovery-settings.schema.json +36 -0
- package/package.json +5 -2
- package/scripts/generate-settings-schema.ts +17 -0
- package/src/settings.ts +23 -2
package/README.adoc
CHANGED
|
@@ -87,13 +87,16 @@ On startup, the extension fetches `<baseUrl>/models` using the configured `apiKe
|
|
|
87
87
|
=== Discovery settings
|
|
88
88
|
|
|
89
89
|
The discovery workflow reads optional settings from `requesty-discovery-settings.json5` in the Pi config directory (`PI_CODING_AGENT_DIR`).
|
|
90
|
-
The file uses JSON5, so it supports comments.
|
|
90
|
+
The file uses JSON5, so it supports comments.
|
|
91
|
+
It is optional. When missing, it will be created including defaults.
|
|
91
92
|
|
|
92
93
|
Example:
|
|
93
94
|
|
|
94
95
|
[source,json5]
|
|
95
96
|
----
|
|
96
97
|
{
|
|
98
|
+
"$schema": "https://raw.githubusercontent.com/enolive/pi-requesty-discover/main/docs/requesty-discovery-settings.schema.json",
|
|
99
|
+
|
|
97
100
|
// override the default provider id
|
|
98
101
|
providerId: "requesty-export",
|
|
99
102
|
// configure the health check mode
|
package/README.md
CHANGED
|
@@ -76,12 +76,15 @@ On startup, the extension fetches `<baseUrl>/models` using the configured `apiKe
|
|
|
76
76
|
### Discovery settings
|
|
77
77
|
|
|
78
78
|
The discovery workflow reads optional settings from `requesty-discovery-settings.json5` in the Pi config directory (`PI_CODING_AGENT_DIR`).
|
|
79
|
-
The file uses JSON5, so it supports comments.
|
|
79
|
+
The file uses JSON5, so it supports comments.
|
|
80
|
+
It is optional. When missing, it will be created including defaults.
|
|
80
81
|
|
|
81
82
|
Example:
|
|
82
83
|
|
|
83
84
|
```json5
|
|
84
85
|
{
|
|
86
|
+
"$schema": "https://raw.githubusercontent.com/enolive/pi-requesty-discover/main/docs/requesty-discovery-settings.schema.json",
|
|
87
|
+
|
|
85
88
|
// override the default provider id
|
|
86
89
|
providerId: "requesty-export",
|
|
87
90
|
// configure the health check mode
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"bannedModels": {
|
|
6
|
+
"default": [],
|
|
7
|
+
"type": "array",
|
|
8
|
+
"items": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"minLength": 1
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"healthCheckMode": {
|
|
14
|
+
"default": "full",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": [
|
|
17
|
+
"off",
|
|
18
|
+
"basic",
|
|
19
|
+
"full"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"providerId": {
|
|
23
|
+
"default": "requesty-export",
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": [
|
|
28
|
+
"bannedModels",
|
|
29
|
+
"healthCheckMode",
|
|
30
|
+
"providerId"
|
|
31
|
+
],
|
|
32
|
+
"additionalProperties": false,
|
|
33
|
+
"$id": "https://raw.githubusercontent.com/enolive/pi-requesty/main/docs/requesty-discovery-settings.schema.json",
|
|
34
|
+
"title": "Requesty discovery settings",
|
|
35
|
+
"description": "Settings for the pi-requesty discovery extension. The file uses JSON5, so comments are allowed."
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-requesty-discover",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Discover available Requesty models for the Pi Coding Agent",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
"test:unit:coverage": "vitest run src --coverage",
|
|
35
35
|
"test:integration": "vitest run test/integration.test.ts",
|
|
36
36
|
"test:watch": "vitest",
|
|
37
|
-
"prepack": "downdoc README.adoc"
|
|
37
|
+
"prepack": "downdoc README.adoc",
|
|
38
|
+
"preversion": "npm run check && npm test",
|
|
39
|
+
"version": "npm run generate:schema && git add docs/requesty-discovery-settings.schema.json",
|
|
40
|
+
"generate:schema": "jiti scripts/generate-settings-schema.ts"
|
|
38
41
|
},
|
|
39
42
|
"license": "MIT",
|
|
40
43
|
"peerDependencies": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { DiscoverySettingsSchema } from '../src/settings'
|
|
5
|
+
|
|
6
|
+
const OUT_PATH = path.resolve('docs/requesty-discovery-settings.schema.json')
|
|
7
|
+
const SCHEMA_URL =
|
|
8
|
+
'https://raw.githubusercontent.com/enolive/pi-requesty/main/docs/requesty-discovery-settings.schema.json'
|
|
9
|
+
|
|
10
|
+
const schema = z.toJSONSchema(DiscoverySettingsSchema, { target: 'draft-2020-12', io: 'output' })
|
|
11
|
+
schema.$id = SCHEMA_URL
|
|
12
|
+
schema.title = 'Requesty discovery settings'
|
|
13
|
+
schema.description = 'Settings for the pi-requesty discovery extension. The file uses JSON5, so comments are allowed.'
|
|
14
|
+
|
|
15
|
+
fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true })
|
|
16
|
+
fs.writeFileSync(OUT_PATH, `${JSON.stringify(schema, null, 2)}\n`, 'utf8')
|
|
17
|
+
console.log(`wrote ${OUT_PATH}`)
|
package/src/settings.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
2
3
|
import { parse as JSON5Parse } from 'json5'
|
|
3
4
|
import { prettifyError, z } from 'zod'
|
|
4
5
|
import { type Env } from './env'
|
|
@@ -8,7 +9,7 @@ export const DEFAULT_PROVIDER_ID = 'requesty-export'
|
|
|
8
9
|
|
|
9
10
|
const HealthCheckModeSchema = z.enum(['off', 'basic', 'full']).default('full')
|
|
10
11
|
|
|
11
|
-
const DiscoverySettingsSchema = z
|
|
12
|
+
export const DiscoverySettingsSchema = z
|
|
12
13
|
.object({
|
|
13
14
|
bannedModels: z.array(z.string().min(1)).default([]),
|
|
14
15
|
healthCheckMode: HealthCheckModeSchema,
|
|
@@ -18,12 +19,17 @@ const DiscoverySettingsSchema = z
|
|
|
18
19
|
|
|
19
20
|
export type DiscoverySettings = z.infer<typeof DiscoverySettingsSchema>
|
|
20
21
|
|
|
22
|
+
const SCHEMA_URL =
|
|
23
|
+
'https://raw.githubusercontent.com/enolive/pi-requesty-discover/main/docs/requesty-discovery-settings.schema.json'
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* Reads the discovery settings file (JSON5, so it supports comments).
|
|
23
|
-
*
|
|
27
|
+
* Writes a commented default file (including the $schema editor reference) when it does not
|
|
28
|
+
* exist yet; throws when it exists but is invalid.
|
|
24
29
|
*/
|
|
25
30
|
export function readDiscoverySettings(envConfig: Env): DiscoverySettings {
|
|
26
31
|
if (!fs.existsSync(envConfig.settings_path)) {
|
|
32
|
+
writeDefaultSettingsFile(envConfig)
|
|
27
33
|
return {
|
|
28
34
|
bannedModels: [],
|
|
29
35
|
healthCheckMode: 'full',
|
|
@@ -45,3 +51,18 @@ export function readDiscoverySettings(envConfig: Env): DiscoverySettings {
|
|
|
45
51
|
}
|
|
46
52
|
return result.data
|
|
47
53
|
}
|
|
54
|
+
|
|
55
|
+
function writeDefaultSettingsFile(envConfig: Env): void {
|
|
56
|
+
const content = `{
|
|
57
|
+
$schema: "${SCHEMA_URL}",
|
|
58
|
+
// the provider id in models.json whose models are managed by this extension
|
|
59
|
+
providerId: "${DEFAULT_PROVIDER_ID}",
|
|
60
|
+
// health check mode: "full" (basic + reasoning/tool check), "basic", or "off"
|
|
61
|
+
healthCheckMode: "full",
|
|
62
|
+
// models excluded from discovery; useful for models that keep failing health checks
|
|
63
|
+
bannedModels: []
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
fs.mkdirSync(path.dirname(envConfig.settings_path), { recursive: true })
|
|
67
|
+
fs.writeFileSync(envConfig.settings_path, content, 'utf8')
|
|
68
|
+
}
|