feat: add global workspace search with regex and file filtering

This commit is contained in:
plenarius
2026-04-20 19:30:42 -04:00
parent d7c5f18544
commit b36391b520
4 changed files with 440 additions and 0 deletions
+13
View File
@@ -4,6 +4,7 @@ import {
readFile,
writeFile,
deleteFile,
searchFiles,
} from "../services/editor.service.js";
import { lookupResref, getResrefCount } from "../nwscript/resref-index.js";
import { lookupTlk, getTlkCount } from "../nwscript/tlk-index.js";
@@ -51,6 +52,18 @@ router.delete("/file/:repo/*path", async (req, res) => {
}
});
router.post("/search", async (req, res) => {
const { repo, query, regex, caseSensitive, includePattern, excludePattern, maxResults } = req.body;
if (!repo || !query) return res.status(400).json({ error: "repo and query required" });
try {
const results = await searchFiles(repo, query, { regex, caseSensitive, includePattern, excludePattern, maxResults });
res.json(results);
} catch (err: unknown) {
const message = err instanceof Error ? err.message : "Unknown error";
res.status(500).json({ error: message });
}
});
router.get("/resref/:resref", (req, res) => {
const entry = lookupResref(req.params.resref);
if (entry) {