@hasna/skills 0.1.57 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -50
- package/bin/index.js +3640 -3188
- package/bin/mcp.js +2621 -2428
- package/bin/migrate.js +70 -0
- package/bin/server.js +33666 -0
- package/bin/worker.js +30939 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3725 -3388
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/content-scan.d.ts +69 -0
- package/dist/lib/discovery.d.ts +1 -0
- package/dist/lib/hosted-availability.d.ts +2 -0
- package/dist/lib/packlist.d.ts +13 -0
- package/dist/lib/portable-skills.d.ts +46 -1
- package/dist/lib/project-state.d.ts +4 -1
- package/dist/lib/public-boundary.d.ts +31 -0
- package/dist/lib/registry-types.d.ts +20 -1
- package/dist/lib/remote-registry.d.ts +2 -2
- package/dist/lib/skill-validation.d.ts +5 -1
- package/dist/lib/skillinfo.d.ts +15 -0
- package/dist/storage.js +18 -6
- package/docs/skill-standard.md +34 -4
- package/migrations/0001_open_skills_self_hosted.sql +129 -0
- package/package.json +11 -3
- package/skills/browse/README.md +1 -1
- package/skills/browse/SKILL.md +1 -1
- package/skills/deepresearch/README.md +1 -1
- package/skills/deepresearch/SKILL.md +1 -1
- package/skills/image/README.md +1 -1
- package/skills/tmux-session/SKILL.md +2 -2
- package/skills/transcript/SKILL.md +1 -1
- package/skills/webcrawling/README.md +1 -1
- package/skills/apidocs/.claude/settings.json +0 -5
package/bin/migrate.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
|
|
4
|
+
// src/server/migrate.ts
|
|
5
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
|
|
8
|
+
// src/server/config.ts
|
|
9
|
+
var DEFAULT_SELF_HOSTED_API_URL = "https://skills.md";
|
|
10
|
+
function resolveServerConfig(env = process.env) {
|
|
11
|
+
const nodeEnv = env.NODE_ENV || "development";
|
|
12
|
+
return {
|
|
13
|
+
host: env.HOST || env.SKILLS_HOST || "0.0.0.0",
|
|
14
|
+
port: parsePositiveInt(env.PORT || env.SKILLS_PORT, 8787),
|
|
15
|
+
databaseUrl: env.HASNA_SKILLS_DATABASE_URL || env.DATABASE_URL || undefined,
|
|
16
|
+
bootstrapApiKey: env.HASNA_SKILLS_BOOTSTRAP_API_KEY || undefined,
|
|
17
|
+
artifactBucket: env.HASNA_SKILLS_S3_BUCKET || env.SKILLS_S3_BUCKET || undefined,
|
|
18
|
+
artifactPrefix: normalizePrefix(env.HASNA_SKILLS_S3_PREFIX || env.SKILLS_S3_PREFIX || "skills/artifacts"),
|
|
19
|
+
inlineWorker: env.HASNA_SKILLS_INLINE_WORKER === "1",
|
|
20
|
+
requestBodyLimitBytes: parsePositiveInt(env.HASNA_SKILLS_REQUEST_BODY_LIMIT_BYTES, 1e6),
|
|
21
|
+
publicBaseUrl: (env.SKILLS_PUBLIC_BASE_URL || DEFAULT_SELF_HOSTED_API_URL).replace(/\/+$/, ""),
|
|
22
|
+
nodeEnv
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function parsePositiveInt(value, fallback) {
|
|
26
|
+
const parsed = Number.parseInt(value ?? "", 10);
|
|
27
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
28
|
+
}
|
|
29
|
+
function normalizePrefix(value) {
|
|
30
|
+
return value.replace(/^\/+|\/+$/g, "") || "skills/artifacts";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/server/migrate.ts
|
|
34
|
+
async function runMigrations(databaseUrl, migrationsDir = join(process.cwd(), "migrations")) {
|
|
35
|
+
if (!existsSync(migrationsDir))
|
|
36
|
+
throw new Error(`migrations directory not found: ${migrationsDir}`);
|
|
37
|
+
const bunWithSql = Bun;
|
|
38
|
+
const sql = new bunWithSql.SQL(databaseUrl, { max: 1 });
|
|
39
|
+
await sql.unsafe("CREATE TABLE IF NOT EXISTS schema_migrations (version text PRIMARY KEY, applied_at timestamptz NOT NULL DEFAULT now())");
|
|
40
|
+
const appliedRows = await sql`SELECT version FROM schema_migrations`;
|
|
41
|
+
const applied = new Set(appliedRows.map((row) => row.version));
|
|
42
|
+
const appliedNow = [];
|
|
43
|
+
for (const file of readdirSync(migrationsDir).filter((name) => name.endsWith(".sql")).sort()) {
|
|
44
|
+
const version = file.replace(/\.sql$/, "");
|
|
45
|
+
if (applied.has(version))
|
|
46
|
+
continue;
|
|
47
|
+
const sqlText = readFileSync(join(migrationsDir, file), "utf8");
|
|
48
|
+
await sql.unsafe("BEGIN");
|
|
49
|
+
try {
|
|
50
|
+
await sql.unsafe(sqlText);
|
|
51
|
+
await sql`INSERT INTO schema_migrations (version) VALUES (${version})`;
|
|
52
|
+
await sql.unsafe("COMMIT");
|
|
53
|
+
appliedNow.push(version);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
await sql.unsafe("ROLLBACK");
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return appliedNow;
|
|
60
|
+
}
|
|
61
|
+
if (import.meta.main) {
|
|
62
|
+
const config = resolveServerConfig();
|
|
63
|
+
if (!config.databaseUrl)
|
|
64
|
+
throw new Error("HASNA_SKILLS_DATABASE_URL or DATABASE_URL is required for migrations");
|
|
65
|
+
const applied = await runMigrations(config.databaseUrl);
|
|
66
|
+
console.log(JSON.stringify({ applied, count: applied.length }, null, 2));
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
runMigrations
|
|
70
|
+
};
|