@happycastle/oh-my-openclaw 0.11.0 → 0.12.0

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.
@@ -1,3 +1,5 @@
1
+ export declare function initPersonaState(filePath?: string): void;
1
2
  export declare function setActivePersona(id: string | null): void;
2
3
  export declare function getActivePersona(): string | null;
3
4
  export declare function resetPersonaState(): void;
5
+ export declare function resetPersonaStateForTesting(): void;
@@ -1,10 +1,48 @@
1
+ import { readFileSync, writeFileSync, mkdirSync } from 'fs';
2
+ import { dirname, join } from 'path';
1
3
  let activePersonaId = null;
4
+ let loaded = false;
5
+ let stateFilePath = join('workspace', '.omoc-state', 'active-persona');
6
+ export function initPersonaState(filePath) {
7
+ if (filePath)
8
+ stateFilePath = filePath;
9
+ loadFromDisk();
10
+ }
2
11
  export function setActivePersona(id) {
3
12
  activePersonaId = id;
13
+ loaded = true;
14
+ saveToDisk();
4
15
  }
5
16
  export function getActivePersona() {
17
+ if (!loaded)
18
+ loadFromDisk();
6
19
  return activePersonaId;
7
20
  }
8
21
  export function resetPersonaState() {
9
22
  activePersonaId = null;
23
+ loaded = true;
24
+ saveToDisk();
25
+ }
26
+ export function resetPersonaStateForTesting() {
27
+ activePersonaId = null;
28
+ loaded = true;
29
+ }
30
+ function loadFromDisk() {
31
+ try {
32
+ const content = readFileSync(stateFilePath, 'utf-8').trim();
33
+ activePersonaId = content || null;
34
+ }
35
+ catch {
36
+ activePersonaId = null;
37
+ }
38
+ loaded = true;
39
+ }
40
+ function saveToDisk() {
41
+ try {
42
+ mkdirSync(dirname(stateFilePath), { recursive: true });
43
+ writeFileSync(stateFilePath, activePersonaId ?? '', 'utf-8');
44
+ }
45
+ catch {
46
+ // silent fail — in-memory state still works
47
+ }
10
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happycastle/oh-my-openclaw",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Oh-My-OpenClaw plugin — multi-agent orchestration, todo enforcer, ralph loop, and custom tools for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",