pi-requesty-discover 1.0.4 → 1.0.6

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.
@@ -0,0 +1,35 @@
1
+ = Contributing
2
+
3
+ Thanks for your interest in contributing.
4
+
5
+ == Useful scripts
6
+
7
+ These will also be run in the CI/CD pipeline.
8
+ Make sure to run them beforehand to get faster feedback
9
+ about the overall quality.
10
+
11
+ [source,bash]
12
+ ----
13
+ # install all dependencies
14
+ npm install
15
+
16
+ # linting and format checking all-in-one
17
+ npm run check
18
+
19
+ # run all the tests
20
+ npm test
21
+ ----
22
+
23
+ Use `npm run format` to fix formatting.
24
+
25
+ Refer to additional scripts in link:package.json[].
26
+
27
+ Please keep changes focused and include tests or docs when behavior changes.
28
+
29
+ Notes:
30
+
31
+ * The package is loaded directly from TypeScript; do not add a build step casually.
32
+ * Keep implementation in `src/`; root `index.ts` is just the package entrypoint.
33
+ * Edit `README.adoc` if necessary.
34
+ * See `AGENTS.md` for detailed repository conventions.
35
+ * I am pretty good at identifying AI slop 😁.
package/README.adoc CHANGED
@@ -67,7 +67,7 @@ Example:
67
67
  "requesty-export": {
68
68
  "name": "Requesty",
69
69
  "baseUrl": "https://router.requesty.ai/v1",
70
- "apiKey": "rqsty-sk-...",
70
+ "apiKey": "$REQUESTY_API_KEY",
71
71
  "api": "openai-completions",
72
72
  "models": []
73
73
  }
@@ -78,6 +78,7 @@ Example:
78
78
  IMPORTANT: The `apiKey` from `models.json` is not used by this extension.
79
79
  It may contain Pi-specific environment-variable substitution that the extension cannot reliably resolve.
80
80
  Set `REQUESTY_API_KEY` instead. This variable is required.
81
+ You can configure the real `apiKey` as you like, but it would be recommended to use the same variable as for the model discovery.
81
82
 
82
83
  IMPORTANT: Health checks are designed to use only a few tokens, but they still make real Requesty API calls and may consume credits.
83
84
 
package/README.md CHANGED
@@ -55,7 +55,7 @@ Example:
55
55
  "requesty-export": {
56
56
  "name": "Requesty",
57
57
  "baseUrl": "https://router.requesty.ai/v1",
58
- "apiKey": "rqsty-sk-...",
58
+ "apiKey": "$REQUESTY_API_KEY",
59
59
  "api": "openai-completions",
60
60
  "models": []
61
61
  }
@@ -67,6 +67,7 @@ Example:
67
67
  The `apiKey` from `models.json` is not used by this extension.
68
68
  It may contain Pi-specific environment-variable substitution that the extension cannot reliably resolve.
69
69
  Set `REQUESTY_API_KEY` instead. This variable is required.
70
+ You can configure the real `apiKey` as you like, but it would be recommended to use the same variable as for the model discovery.
70
71
 
71
72
  **❗ IMPORTANT**\
72
73
  Health checks are designed to use only a few tokens, but they still make real Requesty API calls and may consume credits.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-requesty-discover",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Discover available Requesty models for the Pi Coding Agent",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,12 +22,13 @@
22
22
  "models"
23
23
  ],
24
24
  "scripts": {
25
- "agent-lint": "agnix . -v",
26
- "format:check": "prettier --check src test",
27
- "format": "prettier --write src test",
25
+ "check": "npm run agent-lint && npm run format:check && npm run typecheck && npm run lint",
26
+ "agent-lint": "agnix . -v --strict",
27
+ "format:check": "prettier --check .",
28
+ "format": "prettier --write .",
28
29
  "typecheck": "tsc --noEmit",
29
30
  "lint": "eslint .",
30
- "release": "npm version patch && git push --follow-tags",
31
+ "release": "read -p 'Release a new version? [y/N] ' ok && [ \"$ok\" = \"y\" ] && npm version patch && git push --follow-tags",
31
32
  "test": "vitest run",
32
33
  "test:unit": "vitest run src",
33
34
  "test:unit:coverage": "vitest run src --coverage",
package/src/env.ts CHANGED
@@ -1,7 +1,7 @@
1
- import os from 'node:os'
2
1
  import path from 'node:path'
3
2
  import process from 'node:process'
4
3
  import { prettifyError, z } from 'zod'
4
+ import { getAgentDir } from '@earendil-works/pi-coding-agent'
5
5
 
6
6
  const HealthCheckModeSchema = z.enum(['off', 'basic', 'full']).default('full')
7
7
 
@@ -15,10 +15,6 @@ export type Env = {
15
15
 
16
16
  export function getEnv(): Env {
17
17
  const envVars = process.env
18
- const configuredAgentPath = envVars.PI_CODING_AGENT_DIR
19
- const defaultAgentPath = path.join(os.homedir(), '.pi', 'agent')
20
- const agentPath = configuredAgentPath || defaultAgentPath
21
-
22
18
  const result = HealthCheckModeSchema.safeParse(envVars.REQUESTY_HEALTH_CHECK_MODE)
23
19
  if (!result.success) {
24
20
  throw new Error(prettifyError(result.error))
@@ -28,7 +24,7 @@ export function getEnv(): Env {
28
24
  if (!apiKey) {
29
25
  throw new Error(`apiKey must be set via REQUESTY_API_KEY env var`)
30
26
  }
31
-
27
+ const agentPath = getAgentDir()
32
28
  return {
33
29
  models_json_path: path.join(agentPath, 'models.json'),
34
30
  health_check_log_path: path.join(agentPath, 'requesty-health-check.log'),
@@ -37,5 +33,3 @@ export function getEnv(): Env {
37
33
  health_check_mode: result.data,
38
34
  }
39
35
  }
40
-
41
- export default getEnv
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ interface AutocompleteItem {
17
17
  export type NotificationLevel = 'info' | 'warning' | 'error'
18
18
 
19
19
  export type Notifier = {
20
- notify(message: string, level?: NotificationLevel): void
20
+ notify(message: string, level: NotificationLevel): void
21
21
  }
22
22
 
23
23
  export type StatusReporter = {
@@ -62,7 +62,7 @@ export async function runCommand(args: string, status: StatusReporter, notifier:
62
62
  const parts = args.split(' ')
63
63
  const dryRun = parts.includes(DRY_RUN_ARG)
64
64
  if (dryRun) {
65
- notifier.notify('running in dry mode, no changes will be done', undefined)
65
+ notifier.notify('running in dry mode, no changes will be done', 'info')
66
66
  }
67
67
 
68
68
  try {
@@ -56,8 +56,10 @@ export function getRequestyConfig(envConfig: Env = getEnv()): RequestyConfig {
56
56
  }
57
57
 
58
58
  export function updateModelsJson(data: ModelsJson, models: ProviderModelConfig[], envConfig: Env = getEnv()): void {
59
+ const provider = data.providers[envConfig.provider_id]
59
60
  data.providers[envConfig.provider_id] = {
60
- ...data.providers[envConfig.provider_id],
61
+ ...provider,
62
+ apiKey: nonEmptyString(provider.apiKey) ?? '$REQUESTY_API_KEY',
61
63
  models: models.map(model => ({
62
64
  id: model.id,
63
65
  name: model.name,