@pi-ohm/modes 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.
@@ -0,0 +1,20 @@
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
+ type Mode = "rush" | "smart" | "deep";
6
+ interface ModesConfig {
7
+ defaultMode: Mode;
8
+ }
9
+ declare const DEFAULT_MODES_CONFIG: ModesConfig;
10
+ declare const ModesConfigSchema: Type.TObject<{
11
+ defaultMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"rush">, Type.TLiteral<"smart">, Type.TLiteral<"deep">]>>;
12
+ }>;
13
+ declare const modesConfigModule: _$_pi_ohm_core_config0.ExtensionConfigModule<{
14
+ defaultMode: Mode;
15
+ }, Type.TObject<{
16
+ defaultMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"rush">, Type.TLiteral<"smart">, Type.TLiteral<"deep">]>>;
17
+ }>>;
18
+ declare function isModesConfig(value: unknown): value is ModesConfig;
19
+ //#endregion
20
+ export { DEFAULT_MODES_CONFIG, Mode, ModesConfig, ModesConfigSchema, isModesConfig, modesConfigModule };
package/dist/config.js ADDED
@@ -0,0 +1,27 @@
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_MODES_CONFIG = { defaultMode: "smart" };
7
+ const ModesConfigSchema = Type.Object({ defaultMode: Type.Optional(Type.Union([
8
+ Type.Literal("rush"),
9
+ Type.Literal("smart"),
10
+ Type.Literal("deep")
11
+ ])) }, { additionalProperties: false });
12
+ const modesConfigModule = registerConfig({
13
+ namespace: "modes",
14
+ schema: ModesConfigSchema,
15
+ defaults: DEFAULT_MODES_CONFIG,
16
+ merge(base, patch) {
17
+ return Result.ok({ defaultMode: patch.defaultMode ?? base.defaultMode });
18
+ }
19
+ });
20
+ function isModesConfig(value) {
21
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
22
+ const mode = Reflect.get(value, "defaultMode");
23
+ return mode === "rush" || mode === "smart" || mode === "deep";
24
+ }
25
+
26
+ //#endregion
27
+ export { DEFAULT_MODES_CONFIG, ModesConfigSchema, isModesConfig, modesConfigModule };
@@ -1,4 +1,4 @@
1
- import { ExtensionAPI } from "@mariozechner/pi-coding-agent";
1
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
 
3
3
  //#region src/extension.d.ts
4
4
  declare function registerModesExtension(pi: ExtensionAPI): void;
package/dist/extension.js CHANGED
@@ -1,6 +1,25 @@
1
- import { loadOhmRuntimeConfig, registerOhmSettings, setOhmSetting } from "@pi-ohm/config";
1
+ import { isModesConfig, modesConfigModule } 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 loadModesConfig(cwd) {
7
+ const loaded = await loadConfig({
8
+ cwd,
9
+ modules: [modesConfigModule]
10
+ });
11
+ if (Result.isError(loaded)) return Result.err(loaded.error);
12
+ const config = pickConfig({
13
+ loaded: loaded.value,
14
+ module: modesConfigModule,
15
+ is: isModesConfig
16
+ });
17
+ if (Result.isError(config)) return Result.err(config.error);
18
+ return Result.ok({
19
+ loaded: loaded.value,
20
+ config: config.value
21
+ });
22
+ }
4
23
  const MODES = [
5
24
  "rush",
6
25
  "smart",
@@ -36,27 +55,31 @@ function parseRequestedMode(args) {
36
55
  return null;
37
56
  }
38
57
  async function refreshModeStatus(ctx) {
39
- const { config } = await loadOhmRuntimeConfig(ctx.cwd);
58
+ const config = await loadModesConfig(ctx.cwd);
59
+ if (Result.isError(config)) return;
40
60
  if (!ctx.hasUI) return;
41
- ctx.ui.setStatus("ohm-mode", `mode:${config.defaultMode}`);
61
+ ctx.ui.setStatus("ohm-mode", `mode:${config.value.config.defaultMode}`);
42
62
  }
43
63
  function registerModesExtension(pi) {
44
- registerOhmSettings(pi);
45
64
  pi.on("session_start", async (_event, ctx) => {
46
65
  await refreshModeStatus(ctx);
47
66
  });
48
67
  pi.registerCommand("ohm-modes", {
49
68
  description: "Show available modes and current default mode",
50
69
  handler: async (_args, ctx) => {
51
- const { config, loadedFrom } = await loadOhmRuntimeConfig(ctx.cwd);
70
+ const config = await loadModesConfig(ctx.cwd);
71
+ if (Result.isError(config)) {
72
+ console.log(config.error.message);
73
+ return;
74
+ }
52
75
  const text = [
53
76
  "Pi OHM modes",
54
77
  "",
55
- `defaultMode: ${config.defaultMode}`,
78
+ `defaultMode: ${config.value.config.defaultMode}`,
56
79
  `available: ${MODES.join(", ")}`,
57
80
  "",
58
81
  "Set mode with: /ohm-mode <rush|smart|deep>",
59
- `loadedFrom: ${loadedFrom.length > 0 ? loadedFrom.join(", ") : "defaults + extension settings"}`
82
+ `loadedFrom: ${config.value.loaded.loadedFrom.length > 0 ? config.value.loaded.loadedFrom.join(", ") : "defaults"}`
60
83
  ].join("\n");
61
84
  if (!ctx.hasUI) {
62
85
  console.log(text);
@@ -78,13 +101,12 @@ function registerModesExtension(pi) {
78
101
  await ctx.ui.editor("pi-ohm mode usage", usage);
79
102
  return;
80
103
  }
81
- setOhmSetting("default-mode", requestedMode);
82
- await refreshModeStatus(ctx);
83
104
  const text = [
84
- "Pi OHM mode updated",
105
+ "Pi OHM mode",
85
106
  "",
86
- `defaultMode: ${requestedMode}`,
87
- "Tip: run /ohm-config to inspect merged runtime config."
107
+ `requestedMode: ${requestedMode}`,
108
+ "Persist by setting modes.defaultMode in ohm.json.",
109
+ "Tip: run /ohm-config to inspect merged config."
88
110
  ].join("\n");
89
111
  if (!ctx.hasUI) {
90
112
  console.log(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-ohm/modes",
3
- "version": "0.6.4-dev.25351601005.1.815a0e8",
3
+ "version": "0.6.4-dev.25620170147.1.0b6891f",
4
4
  "homepage": "https://github.com/pi-ohm/pi-ohm/tree/dev/packages/modes#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,14 +29,16 @@
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
- "@mariozechner/pi-coding-agent": "^0.72.1",
32
- "@pi-ohm/config": "0.6.4-dev.25351601005.1.815a0e8"
35
+ "@earendil-works/pi-coding-agent": "0.74.0",
36
+ "@pi-ohm/core": "0.6.4-dev.25620170147.1.0b6891f",
37
+ "better-result": "2.9.2",
38
+ "typebox": "^1.0.68"
33
39
  },
34
40
  "peerDependencies": {
35
- "@mariozechner/pi-coding-agent": "*"
41
+ "@earendil-works/pi-coding-agent": "0.74.0"
36
42
  },
37
43
  "pi": {
38
44
  "extensions": [