twindex-openclaw-plugin 0.8.20260409 → 0.8.20260410
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/plugin-config.ts +62 -9
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "twindex-openclaw-plugin",
|
|
3
3
|
"name": "New Lore",
|
|
4
4
|
"description": "Music intelligence for AI agents. Get notified about tours, merch drops, releases, and presales for your favorite artists.",
|
|
5
|
-
"version": "0.8.
|
|
5
|
+
"version": "0.8.20260410",
|
|
6
6
|
"skills": ["./skills"],
|
|
7
7
|
"configSchema": {
|
|
8
8
|
"type": "object",
|
package/package.json
CHANGED
package/src/plugin-config.ts
CHANGED
|
@@ -39,6 +39,60 @@ function ensurePluginEntry(api: any, pluginId: string): Record<string, any> {
|
|
|
39
39
|
return api.config.plugins.entries[pluginId];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function pruneLegacyPluginState(target: any, pluginId: string): boolean {
|
|
43
|
+
if (!isRecord(target?.plugins) || LEGACY_PLUGIN_IDS.includes(pluginId)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let changed = false;
|
|
48
|
+
|
|
49
|
+
if (isRecord(target.plugins.entries)) {
|
|
50
|
+
for (const legacyPluginId of LEGACY_PLUGIN_IDS) {
|
|
51
|
+
if (legacyPluginId !== pluginId && legacyPluginId in target.plugins.entries) {
|
|
52
|
+
delete target.plugins.entries[legacyPluginId];
|
|
53
|
+
changed = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (isRecord(target.plugins.installs)) {
|
|
59
|
+
for (const legacyPluginId of LEGACY_PLUGIN_IDS) {
|
|
60
|
+
if (legacyPluginId !== pluginId && legacyPluginId in target.plugins.installs) {
|
|
61
|
+
delete target.plugins.installs[legacyPluginId];
|
|
62
|
+
changed = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return changed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function persistConfigToDisk(
|
|
71
|
+
pluginId: string,
|
|
72
|
+
nextConfig?: NewLorePluginConfig,
|
|
73
|
+
): boolean {
|
|
74
|
+
const configPath = join(homedir(), ".openclaw", "openclaw.json");
|
|
75
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
76
|
+
const disk = JSON.parse(raw);
|
|
77
|
+
let changed = false;
|
|
78
|
+
|
|
79
|
+
if (nextConfig) {
|
|
80
|
+
if (!isRecord(disk.plugins)) disk.plugins = {};
|
|
81
|
+
if (!isRecord(disk.plugins.entries)) disk.plugins.entries = {};
|
|
82
|
+
if (!isRecord(disk.plugins.entries[pluginId])) disk.plugins.entries[pluginId] = {};
|
|
83
|
+
disk.plugins.entries[pluginId].config = nextConfig;
|
|
84
|
+
changed = true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
changed = pruneLegacyPluginState(disk, pluginId) || changed;
|
|
88
|
+
|
|
89
|
+
if (changed) {
|
|
90
|
+
writeFileSync(configPath, JSON.stringify(disk, null, 2) + "\n", "utf-8");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return changed;
|
|
94
|
+
}
|
|
95
|
+
|
|
42
96
|
export function getPluginId(api: any): string {
|
|
43
97
|
if (typeof api?.id === "string" && api.id.trim()) return api.id.trim();
|
|
44
98
|
return LEGACY_PLUGIN_IDS[0];
|
|
@@ -69,18 +123,12 @@ export function persistPluginConfig(
|
|
|
69
123
|
};
|
|
70
124
|
|
|
71
125
|
ensurePluginEntry(api, pluginId).config = nextConfig;
|
|
126
|
+
pruneLegacyPluginState(api.config, pluginId);
|
|
72
127
|
api.pluginConfig = nextConfig;
|
|
73
128
|
|
|
74
129
|
// OpenClaw does not currently expose a config.save() helper to plugins.
|
|
75
130
|
try {
|
|
76
|
-
|
|
77
|
-
const raw = readFileSync(configPath, "utf-8");
|
|
78
|
-
const disk = JSON.parse(raw);
|
|
79
|
-
if (!isRecord(disk.plugins)) disk.plugins = {};
|
|
80
|
-
if (!isRecord(disk.plugins.entries)) disk.plugins.entries = {};
|
|
81
|
-
if (!isRecord(disk.plugins.entries[pluginId])) disk.plugins.entries[pluginId] = {};
|
|
82
|
-
disk.plugins.entries[pluginId].config = nextConfig;
|
|
83
|
-
writeFileSync(configPath, JSON.stringify(disk, null, 2) + "\n", "utf-8");
|
|
131
|
+
persistConfigToDisk(pluginId, nextConfig);
|
|
84
132
|
} catch (err: any) {
|
|
85
133
|
api.logger?.warn?.(`NewLore: failed to persist config: ${err.message}`);
|
|
86
134
|
}
|
|
@@ -95,7 +143,12 @@ export function migrateLegacyPluginConfig(api: any): boolean {
|
|
|
95
143
|
const currentConfig = api?.config?.plugins?.entries?.[pluginId]?.config;
|
|
96
144
|
if (isRecord(currentConfig) && Object.keys(currentConfig).length > 0) {
|
|
97
145
|
api.pluginConfig = currentConfig;
|
|
98
|
-
|
|
146
|
+
try {
|
|
147
|
+
return pruneLegacyPluginState(api.config, pluginId) || persistConfigToDisk(pluginId);
|
|
148
|
+
} catch (err: any) {
|
|
149
|
+
api.logger?.warn?.(`NewLore: failed to prune legacy config: ${err.message}`);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
99
152
|
}
|
|
100
153
|
|
|
101
154
|
const legacyConfig = resolveLegacyConfig(api);
|