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
9 changes: 3 additions & 6 deletions packages/skills/scripts/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, readdirSync } from 'node:fs';
import { readFileSync } from 'node:fs';
import { dirname, join, relative } from 'node:path';
import type { BaseContext } from '@contextbridge/context';
import { SKILL_RENDERABLE_HARNESSES } from '@contextbridge/harness';
Expand All @@ -8,7 +8,6 @@ import { createScriptContext } from './context.ts';
import { REPO_ROOT, type RenderTarget, SOURCES_DIR, outDirFor, targetsForAll } from './renderTargets.ts';

const safeReadFile = fromThrowable((path: string) => readFileSync(path, 'utf8'));
const safeReaddir = fromThrowable((dir: string) => readdirSync(dir, { withFileTypes: true }));

async function main(ctx: BaseContext): Promise<void> {
const { logger } = ctx;
Expand Down Expand Up @@ -51,10 +50,8 @@ function checkDrift({ path, body, harness }: RenderTarget): Result<void, string>
}

function findOrphans(parent: string, expectedDirs: Set<string>): string[] {
return safeReaddir(parent)
.unwrapOr([])
.filter((entry) => entry.isDirectory())
.map((entry) => join(parent, entry.name))
return Array.from(new Bun.Glob('*/SKILL.md').scanSync(parent))
.map((relPath) => join(parent, dirname(relPath)))
.filter((dir) => !expectedDirs.has(dir));
}

Expand Down
13 changes: 7 additions & 6 deletions packages/skills/src/skills.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import fm from 'front-matter';
import { z } from 'zod';

Expand Down Expand Up @@ -35,10 +35,11 @@ export function parseSkill(source: string): Skill {
}

export function loadAllFrom(sourcesDir: string): Skill[] {
return readdirSync(sourcesDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('_'))
.sort((a, b) => a.name.localeCompare(b.name))
.map((entry) => loadOne(sourcesDir, entry.name));
return Array.from(new Bun.Glob('*/SKILL.md').scanSync(sourcesDir))
.map((relPath) => dirname(relPath))
.filter((dirName) => !dirName.startsWith('_'))
.sort((a, b) => a.localeCompare(b))
.map((dirName) => loadOne(sourcesDir, dirName));
}

function loadOne(sourcesDir: string, dirName: string): Skill {
Expand Down
7 changes: 3 additions & 4 deletions packages/storage/src/db/loadMigrations.macro.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, readdirSync } from 'node:fs';
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { formatToMillis } from 'drizzle-orm/migrator.utils';
Expand All @@ -13,9 +13,8 @@ export function loadStorageMigrations(): StorageMigrationEntry[] {
const here = dirname(fileURLToPath(import.meta.url));
const drizzleDir = join(here, '..', '..', 'generated', 'drizzle');

return readdirSync(drizzleDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name)
return Array.from(new Bun.Glob('*/migration.sql').scanSync(drizzleDir))
.map((relPath) => dirname(relPath))
.sort()
.map((name) => {
const timestamp = formatToMillis(name.slice(0, 14));
Expand Down