Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
run: bun run build
- name: Lint
run: bun run lint
- name: Test
run: bun test
34 changes: 17 additions & 17 deletions main.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production",
"lint": "eslint src/"
"lint": "eslint src/",
"test": "bun test"
},
"devDependencies": {
"@codemirror/autocomplete": "^6.20.1",
Expand Down
19 changes: 19 additions & 0 deletions src/scanner-ignore.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, test } from "bun:test";
import { isScannableMarkdownFile } from "./scanner-ignore";

describe("scanner metadata files", () => {
test("excludes common package metadata case-insensitively", () => {
const metadata = [
"HISTORY.md",
"changes.md",
"AUTHORS",
"notice",
".gitignore",
".gitkeep",
];

const scanResults = [...metadata, "my-skill.md"].filter(isScannableMarkdownFile);

expect(scanResults).toEqual(["my-skill.md"]);
});
});
19 changes: 19 additions & 0 deletions src/scanner-ignore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const IGNORED_FILES = new Set([
"readme.md",
"license",
"license.md",
"changelog.md",
"history.md",
"changes.md",
"authors",
"notice",
".gitignore",
".gitkeep",
".ds_store",
"thumbs.db",
]);

export function isScannableMarkdownFile(fileName: string): boolean {
const normalized = fileName.toLowerCase();
return normalized.endsWith(".md") && !IGNORED_FILES.has(normalized);
}
17 changes: 3 additions & 14 deletions src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@ import { homedir } from "os";
import { parseYaml } from "obsidian";
import { createHash } from "crypto";
import { TOOL_CONFIGS, clearInstallCache } from "./tool-configs";
import { isScannableMarkdownFile } from "./scanner-ignore";
import type { SkillItem, SkillPath, SkillType, NamingMode, ScanPattern, ChopsSettings, ToolConfig } from "./types";

const IGNORED_FILES = new Set([
"readme.md",
"license",
"license.md",
"changelog.md",
".ds_store",
"thumbs.db",
]);

function hashPath(p: string): string {
return createHash("sha256").update(p).digest("hex").slice(0, 12);
}
Expand Down Expand Up @@ -115,9 +107,7 @@ function scanFlatMd(
if (item) items.push(item);
continue;
}
const mdFiles = readdirSync(fullPath).filter(
(f) => f.endsWith(".md") && !IGNORED_FILES.has(f.toLowerCase())
);
const mdFiles = readdirSync(fullPath).filter(isScannableMarkdownFile);
const preferred =
mdFiles.find(
(f) => f.toLowerCase() === `${entry.name.toLowerCase()}.md`
Expand All @@ -135,8 +125,7 @@ function scanFlatMd(
continue;
}

const fname = entry.name.toLowerCase();
if (!fname.endsWith(".md") || IGNORED_FILES.has(fname)) continue;
if (!isScannableMarkdownFile(entry.name)) continue;
const item = parseSkillFile(fullPath, type, toolId, "flat-md", namingMode);
if (item) items.push(item);
}
Expand Down