import { readdirSync } from "fs" import { NOSE_WWW } from "@/config" import { Thread } from "@/shell" import { appPath } from "@/webapp" export default function () { const state = Thread.getStore() if (!state) return { status: "error", output: "no state" } const project = state.project if (!project) return { status: "error", output: "no project loaded" } const root = appPath(project) if (!root) return { status: "error", output: "error loading project" } let files: string[] = [] for (const file of readdirSync(root, { withFileTypes: true })) { files.push(file.name) } if (root === NOSE_WWW) { files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`)) } return `* project: ${project}\n` + files.join(" ") }