@pi-ohm/painter 0.6.4-dev.25351601005.1.815a0e8 → 0.6.4-dev.25620170147.1.0b6891f
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/dist/config.d.ts +75 -0
- package/dist/config.js +75 -0
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +38 -15
- package/package.json +12 -6
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as _$_pi_ohm_core_config0 from "@pi-ohm/core/config";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
interface PainterConfig {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
googleNanoBanana: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
model: string;
|
|
10
|
+
};
|
|
11
|
+
openai: {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
model: string;
|
|
14
|
+
};
|
|
15
|
+
azureOpenai: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
deployment: string;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
apiVersion: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare const DEFAULT_PAINTER_CONFIG: PainterConfig;
|
|
23
|
+
declare const PainterConfigSchema: Type.TObject<{
|
|
24
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
25
|
+
googleNanoBanana: Type.TOptional<Type.TObject<{
|
|
26
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
27
|
+
model: Type.TOptional<Type.TString>;
|
|
28
|
+
}>>;
|
|
29
|
+
openai: Type.TOptional<Type.TObject<{
|
|
30
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
31
|
+
model: Type.TOptional<Type.TString>;
|
|
32
|
+
}>>;
|
|
33
|
+
azureOpenai: Type.TOptional<Type.TObject<{
|
|
34
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
35
|
+
deployment: Type.TOptional<Type.TString>;
|
|
36
|
+
endpoint: Type.TOptional<Type.TString>;
|
|
37
|
+
apiVersion: Type.TOptional<Type.TString>;
|
|
38
|
+
}>>;
|
|
39
|
+
}>;
|
|
40
|
+
declare const painterConfigModule: _$_pi_ohm_core_config0.ExtensionConfigModule<{
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
googleNanoBanana: {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
model: string;
|
|
45
|
+
};
|
|
46
|
+
openai: {
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
model: string;
|
|
49
|
+
};
|
|
50
|
+
azureOpenai: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
deployment: string;
|
|
53
|
+
endpoint: string;
|
|
54
|
+
apiVersion: string;
|
|
55
|
+
};
|
|
56
|
+
}, Type.TObject<{
|
|
57
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
58
|
+
googleNanoBanana: Type.TOptional<Type.TObject<{
|
|
59
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
60
|
+
model: Type.TOptional<Type.TString>;
|
|
61
|
+
}>>;
|
|
62
|
+
openai: Type.TOptional<Type.TObject<{
|
|
63
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
64
|
+
model: Type.TOptional<Type.TString>;
|
|
65
|
+
}>>;
|
|
66
|
+
azureOpenai: Type.TOptional<Type.TObject<{
|
|
67
|
+
enabled: Type.TOptional<Type.TBoolean>;
|
|
68
|
+
deployment: Type.TOptional<Type.TString>;
|
|
69
|
+
endpoint: Type.TOptional<Type.TString>;
|
|
70
|
+
apiVersion: Type.TOptional<Type.TString>;
|
|
71
|
+
}>>;
|
|
72
|
+
}>>;
|
|
73
|
+
declare function isPainterConfig(value: unknown): value is PainterConfig;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { DEFAULT_PAINTER_CONFIG, PainterConfig, PainterConfigSchema, isPainterConfig, painterConfigModule };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Result } from "better-result";
|
|
2
|
+
import { registerConfig } from "@pi-ohm/core/config";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
|
+
|
|
5
|
+
//#region src/config.ts
|
|
6
|
+
const DEFAULT_PAINTER_CONFIG = {
|
|
7
|
+
enabled: true,
|
|
8
|
+
googleNanoBanana: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
model: "gemini-2.5-flash-image-preview"
|
|
11
|
+
},
|
|
12
|
+
openai: {
|
|
13
|
+
enabled: true,
|
|
14
|
+
model: "gpt-image-1"
|
|
15
|
+
},
|
|
16
|
+
azureOpenai: {
|
|
17
|
+
enabled: false,
|
|
18
|
+
deployment: "",
|
|
19
|
+
endpoint: "",
|
|
20
|
+
apiVersion: "2025-04-01-preview"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const ProviderConfigSchema = Type.Object({
|
|
24
|
+
enabled: Type.Optional(Type.Boolean()),
|
|
25
|
+
model: Type.Optional(Type.String())
|
|
26
|
+
}, { additionalProperties: false });
|
|
27
|
+
const AzureOpenAiConfigSchema = Type.Object({
|
|
28
|
+
enabled: Type.Optional(Type.Boolean()),
|
|
29
|
+
deployment: Type.Optional(Type.String()),
|
|
30
|
+
endpoint: Type.Optional(Type.String()),
|
|
31
|
+
apiVersion: Type.Optional(Type.String())
|
|
32
|
+
}, { additionalProperties: false });
|
|
33
|
+
const PainterConfigSchema = Type.Object({
|
|
34
|
+
enabled: Type.Optional(Type.Boolean()),
|
|
35
|
+
googleNanoBanana: Type.Optional(ProviderConfigSchema),
|
|
36
|
+
openai: Type.Optional(ProviderConfigSchema),
|
|
37
|
+
azureOpenai: Type.Optional(AzureOpenAiConfigSchema)
|
|
38
|
+
}, { additionalProperties: false });
|
|
39
|
+
function mergeProvider(base, patch) {
|
|
40
|
+
return {
|
|
41
|
+
enabled: patch?.enabled ?? base.enabled,
|
|
42
|
+
model: patch?.model ?? base.model
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const painterConfigModule = registerConfig({
|
|
46
|
+
namespace: "painter",
|
|
47
|
+
schema: PainterConfigSchema,
|
|
48
|
+
defaults: DEFAULT_PAINTER_CONFIG,
|
|
49
|
+
merge(base, patch) {
|
|
50
|
+
return Result.ok({
|
|
51
|
+
enabled: patch.enabled ?? base.enabled,
|
|
52
|
+
googleNanoBanana: mergeProvider(base.googleNanoBanana, patch.googleNanoBanana),
|
|
53
|
+
openai: mergeProvider(base.openai, patch.openai),
|
|
54
|
+
azureOpenai: {
|
|
55
|
+
enabled: patch.azureOpenai?.enabled ?? base.azureOpenai.enabled,
|
|
56
|
+
deployment: patch.azureOpenai?.deployment ?? base.azureOpenai.deployment,
|
|
57
|
+
endpoint: patch.azureOpenai?.endpoint ?? base.azureOpenai.endpoint,
|
|
58
|
+
apiVersion: patch.azureOpenai?.apiVersion ?? base.azureOpenai.apiVersion
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
function isProviderConfig(value) {
|
|
64
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
65
|
+
return typeof Reflect.get(value, "enabled") === "boolean" && typeof Reflect.get(value, "model") === "string";
|
|
66
|
+
}
|
|
67
|
+
function isPainterConfig(value) {
|
|
68
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
69
|
+
const azure = Reflect.get(value, "azureOpenai");
|
|
70
|
+
if (typeof azure !== "object" || azure === null || Array.isArray(azure)) return false;
|
|
71
|
+
return typeof Reflect.get(value, "enabled") === "boolean" && isProviderConfig(Reflect.get(value, "googleNanoBanana")) && isProviderConfig(Reflect.get(value, "openai")) && typeof Reflect.get(azure, "enabled") === "boolean" && typeof Reflect.get(azure, "deployment") === "string" && typeof Reflect.get(azure, "endpoint") === "string" && typeof Reflect.get(azure, "apiVersion") === "string";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { DEFAULT_PAINTER_CONFIG, PainterConfigSchema, isPainterConfig, painterConfigModule };
|
package/dist/extension.d.ts
CHANGED
package/dist/extension.js
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPainterConfig, painterConfigModule } from "./config.js";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
|
+
import { loadConfig, pickConfig } from "@pi-ohm/core/config";
|
|
2
4
|
|
|
3
5
|
//#region src/extension.ts
|
|
6
|
+
async function loadPainterConfig(cwd) {
|
|
7
|
+
const loaded = await loadConfig({
|
|
8
|
+
cwd,
|
|
9
|
+
modules: [painterConfigModule]
|
|
10
|
+
});
|
|
11
|
+
if (Result.isError(loaded)) return Result.err(loaded.error);
|
|
12
|
+
const painter = pickConfig({
|
|
13
|
+
loaded: loaded.value,
|
|
14
|
+
module: painterConfigModule,
|
|
15
|
+
is: isPainterConfig
|
|
16
|
+
});
|
|
17
|
+
if (Result.isError(painter)) return Result.err(painter.error);
|
|
18
|
+
return Result.ok({
|
|
19
|
+
loaded: loaded.value,
|
|
20
|
+
painter: painter.value
|
|
21
|
+
});
|
|
22
|
+
}
|
|
4
23
|
function registerPainterExtension(pi) {
|
|
5
|
-
registerOhmSettings(pi);
|
|
6
24
|
pi.on("session_start", async (_event, ctx) => {
|
|
7
|
-
const
|
|
25
|
+
const config = await loadPainterConfig(ctx.cwd);
|
|
26
|
+
if (Result.isError(config)) return;
|
|
8
27
|
if (!ctx.hasUI) return;
|
|
9
|
-
if (!config.
|
|
28
|
+
if (!config.value.painter.enabled) {
|
|
10
29
|
ctx.ui.setStatus("ohm-painter", "painter:off");
|
|
11
30
|
return;
|
|
12
31
|
}
|
|
13
32
|
const providers = [
|
|
14
|
-
config.painter.googleNanoBanana.enabled ? "google" : null,
|
|
15
|
-
config.painter.openai.enabled ? "openai" : null,
|
|
16
|
-
config.painter.azureOpenai.enabled ? "azure" : null
|
|
33
|
+
config.value.painter.googleNanoBanana.enabled ? "google" : null,
|
|
34
|
+
config.value.painter.openai.enabled ? "openai" : null,
|
|
35
|
+
config.value.painter.azureOpenai.enabled ? "azure" : null
|
|
17
36
|
].filter(Boolean);
|
|
18
37
|
ctx.ui.setStatus("ohm-painter", `painter:on · providers:${providers.length > 0 ? providers.join("+") : "none"}`);
|
|
19
38
|
});
|
|
20
39
|
pi.registerCommand("ohm-painter", {
|
|
21
40
|
description: "Show painter provider configuration",
|
|
22
41
|
handler: async (_args, ctx) => {
|
|
23
|
-
const
|
|
42
|
+
const config = await loadPainterConfig(ctx.cwd);
|
|
43
|
+
if (Result.isError(config)) {
|
|
44
|
+
console.log(config.error.message);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
24
47
|
const text = [
|
|
25
48
|
"Pi OHM: painter/imagegen",
|
|
26
49
|
"",
|
|
27
|
-
`
|
|
28
|
-
`googleNanoBanana: ${config.painter.googleNanoBanana.enabled ? "on" : "off"} (${config.painter.googleNanoBanana.model})`,
|
|
29
|
-
`openai: ${config.painter.openai.enabled ? "on" : "off"} (${config.painter.openai.model})`,
|
|
30
|
-
`azureOpenAI: ${config.painter.azureOpenai.enabled ? "on" : "off"}`,
|
|
31
|
-
`azureDeployment: ${config.painter.azureOpenai.deployment || "<unset>"}`,
|
|
32
|
-
`azureEndpoint: ${config.painter.azureOpenai.endpoint || "<unset>"}`,
|
|
33
|
-
`azureApiVersion: ${config.painter.azureOpenai.apiVersion}`
|
|
50
|
+
`enabled: ${config.value.painter.enabled ? "yes" : "no"}`,
|
|
51
|
+
`googleNanoBanana: ${config.value.painter.googleNanoBanana.enabled ? "on" : "off"} (${config.value.painter.googleNanoBanana.model})`,
|
|
52
|
+
`openai: ${config.value.painter.openai.enabled ? "on" : "off"} (${config.value.painter.openai.model})`,
|
|
53
|
+
`azureOpenAI: ${config.value.painter.azureOpenai.enabled ? "on" : "off"}`,
|
|
54
|
+
`azureDeployment: ${config.value.painter.azureOpenai.deployment || "<unset>"}`,
|
|
55
|
+
`azureEndpoint: ${config.value.painter.azureOpenai.endpoint || "<unset>"}`,
|
|
56
|
+
`azureApiVersion: ${config.value.painter.azureOpenai.apiVersion}`
|
|
34
57
|
].join("\n");
|
|
35
58
|
if (!ctx.hasUI) {
|
|
36
59
|
console.log(text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-ohm/painter",
|
|
3
|
-
"version": "0.6.4-dev.
|
|
3
|
+
"version": "0.6.4-dev.25620170147.1.0b6891f",
|
|
4
4
|
"homepage": "https://github.com/pi-ohm/pi-ohm/tree/dev/packages/painter#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/extension.d.ts",
|
|
20
20
|
"default": "./dist/extension.js"
|
|
21
|
+
},
|
|
22
|
+
"./config": {
|
|
23
|
+
"types": "./dist/config.d.ts",
|
|
24
|
+
"default": "./dist/config.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"publishConfig": {
|
|
@@ -25,15 +29,17 @@
|
|
|
25
29
|
"provenance": true
|
|
26
30
|
},
|
|
27
31
|
"scripts": {
|
|
28
|
-
"build": "vp pack src/extension.ts"
|
|
32
|
+
"build": "vp pack src/extension.ts src/config.ts"
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@pi-ohm/
|
|
35
|
+
"@earendil-works/pi-coding-agent": "0.74.0",
|
|
36
|
+
"@earendil-works/pi-tui": "0.74.0",
|
|
37
|
+
"@pi-ohm/core": "0.6.4-dev.25620170147.1.0b6891f",
|
|
38
|
+
"better-result": "2.9.2",
|
|
39
|
+
"typebox": "^1.0.68"
|
|
34
40
|
},
|
|
35
41
|
"peerDependencies": {
|
|
36
|
-
"@
|
|
42
|
+
"@earendil-works/pi-coding-agent": "0.74.0"
|
|
37
43
|
},
|
|
38
44
|
"pi": {
|
|
39
45
|
"extensions": [
|