forge-openclaw-plugin 0.2.51 → 0.2.52
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.
|
@@ -135,6 +135,7 @@ function findSpaceForFile(dataRoot, filePath, parsed) {
|
|
|
135
135
|
if (row) {
|
|
136
136
|
return row.id;
|
|
137
137
|
}
|
|
138
|
+
return ensurePersonalWikiSpaceForLegacyUser(parts[1]);
|
|
138
139
|
}
|
|
139
140
|
return "wiki_space_shared";
|
|
140
141
|
}
|
|
@@ -152,6 +153,28 @@ function findExistingNote(input) {
|
|
|
152
153
|
.get(input.spaceId, input.slug);
|
|
153
154
|
return bySlug?.id ?? null;
|
|
154
155
|
}
|
|
156
|
+
function ensurePersonalWikiSpaceForLegacyUser(userId) {
|
|
157
|
+
const row = getDatabase()
|
|
158
|
+
.prepare(`SELECT id FROM wiki_spaces
|
|
159
|
+
WHERE owner_user_id = ? OR slug = ? OR slug = ? OR id = ?
|
|
160
|
+
ORDER BY created_at ASC
|
|
161
|
+
LIMIT 1`)
|
|
162
|
+
.get(userId, userId, `user-${slugify(userId)}`, `wiki_space_user_${slugify(userId)}`);
|
|
163
|
+
if (row) {
|
|
164
|
+
return row.id;
|
|
165
|
+
}
|
|
166
|
+
const now = new Date().toISOString();
|
|
167
|
+
const id = `wiki_space_user_${slugify(userId)}`;
|
|
168
|
+
getDatabase()
|
|
169
|
+
.prepare(`INSERT INTO wiki_spaces (id, slug, label, description, owner_user_id, visibility, created_at, updated_at)
|
|
170
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
171
|
+
ON CONFLICT(id) DO NOTHING`)
|
|
172
|
+
.run(id, `user-${slugify(userId)}`, `${userId} Wiki`, "Personal Forge wiki space recovered from legacy wiki files.", userId, "personal", now, now);
|
|
173
|
+
const inserted = getDatabase()
|
|
174
|
+
.prepare("SELECT id FROM wiki_spaces WHERE id = ?")
|
|
175
|
+
.get(id);
|
|
176
|
+
return inserted?.id ?? "wiki_space_shared";
|
|
177
|
+
}
|
|
155
178
|
function upsertLinks(noteId, links) {
|
|
156
179
|
getDatabase().prepare("DELETE FROM note_links WHERE note_id = ?").run(noteId);
|
|
157
180
|
const createdAt = new Date().toISOString();
|
|
@@ -179,7 +202,8 @@ export async function importLegacyWikiMarkdownToSqlite(input = {}) {
|
|
|
179
202
|
apply: input.apply ?? false,
|
|
180
203
|
deleteFiles: input.deleteFiles ?? false,
|
|
181
204
|
backupBeforeApply: input.backupBeforeApply ?? false,
|
|
182
|
-
backupLabel: input.backupLabel ?? "legacy-wiki-markdown-pre-sqlite-import"
|
|
205
|
+
backupLabel: input.backupLabel ?? "legacy-wiki-markdown-pre-sqlite-import",
|
|
206
|
+
preserveExistingNotes: input.preserveExistingNotes ?? false
|
|
183
207
|
};
|
|
184
208
|
const wikiRoot = path.join(options.dataRoot, "wiki");
|
|
185
209
|
const files = await walkMarkdownFiles(wikiRoot);
|
|
@@ -234,6 +258,17 @@ export async function importLegacyWikiMarkdownToSqlite(input = {}) {
|
|
|
234
258
|
continue;
|
|
235
259
|
}
|
|
236
260
|
if (noteId) {
|
|
261
|
+
const existingNote = getNoteById(noteId, { skipCleanup: true });
|
|
262
|
+
if (options.preserveExistingNotes &&
|
|
263
|
+
existingNote &&
|
|
264
|
+
existingNote.contentMarkdown.trim().length > 0) {
|
|
265
|
+
getDatabase()
|
|
266
|
+
.prepare("UPDATE notes SET source_path = '' WHERE id = ? AND source_path <> ''")
|
|
267
|
+
.run(noteId);
|
|
268
|
+
syncNoteWikiArtifacts(existingNote);
|
|
269
|
+
updated += 1;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
237
272
|
getDatabase()
|
|
238
273
|
.prepare(`UPDATE notes
|
|
239
274
|
SET kind = ?, title = ?, slug = ?, space_id = ?, parent_slug = ?, index_order = ?, show_in_index = ?,
|
|
@@ -321,7 +356,8 @@ export async function importLegacyWikiMarkdownOnStartup(dataRoot = getEffectiveD
|
|
|
321
356
|
dataRoot,
|
|
322
357
|
apply: true,
|
|
323
358
|
deleteFiles: false,
|
|
324
|
-
backupBeforeApply: true
|
|
359
|
+
backupBeforeApply: true,
|
|
360
|
+
preserveExistingNotes: true
|
|
325
361
|
});
|
|
326
362
|
markStartupImportComplete();
|
|
327
363
|
return result;
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED