refactor: extract shared utilities (isMarkdownFile, isPlainObject, resolveSymlink) (#33)

This commit is contained in:
Junho Yeo
2025-12-13 14:23:04 +09:00
committed by GitHub
parent ed84d6911e
commit 26abaaba00
9 changed files with 42 additions and 49 deletions
+2 -3
View File
@@ -3,6 +3,7 @@ import { existsSync, readdirSync, readFileSync } from "fs"
import { homedir } from "os"
import { join, basename, dirname } from "path"
import { parseFrontmatter, resolveCommandsInText, resolveFileReferencesInText, sanitizeModelField } from "../../shared"
import { isMarkdownFile } from "../../shared/file-utils"
import type { CommandScope, CommandMetadata, CommandInfo } from "./types"
function discoverCommandsFromDir(commandsDir: string, scope: CommandScope): CommandInfo[] {
@@ -14,9 +15,7 @@ function discoverCommandsFromDir(commandsDir: string, scope: CommandScope): Comm
const commands: CommandInfo[] = []
for (const entry of entries) {
if (entry.name.startsWith(".")) continue
if (!entry.name.endsWith(".md")) continue
if (!entry.isFile()) continue
if (!isMarkdownFile(entry)) continue
const commandPath = join(commandsDir, entry.name)
const commandName = basename(entry.name, ".md")