mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
Merge pull request #104 from rohitg00/feat/publish-check-stats
feat: direct publish, GitHub API update detection, quality scores
This commit is contained in:
@@ -0,0 +1,324 @@
|
||||
name: Auto-Publish Skill Submission
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: auto-publish-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
auto-publish:
|
||||
if: github.event.label.name == 'skill-submission'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Extract and validate submission
|
||||
id: validate
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
with:
|
||||
script: |
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const body = process.env.ISSUE_BODY || '';
|
||||
|
||||
const jsonMatch = body.match(/```json\s*\n([\s\S]*?)\n```/);
|
||||
if (!jsonMatch) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', 'No JSON block found in issue body. Please include your source entry between \\`\\`\\`json and \\`\\`\\` fences.');
|
||||
return;
|
||||
}
|
||||
|
||||
let entry;
|
||||
try {
|
||||
entry = JSON.parse(jsonMatch[1].trim());
|
||||
} catch (e) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', `Invalid JSON in submission: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const source = entry.source || (entry.owner && entry.repo ? `${entry.owner}/${entry.repo}` : null);
|
||||
const name = entry.name;
|
||||
const description = entry.description || '';
|
||||
|
||||
if (!source || !name) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', 'Missing required fields. JSON must include `source` (owner/repo) and `name`.');
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = source.split('/');
|
||||
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', `Invalid source format "${source}". Must be "owner/repo".`);
|
||||
return;
|
||||
}
|
||||
|
||||
const [owner, repo] = parts;
|
||||
|
||||
const sourcesData = JSON.parse(fs.readFileSync('marketplace/sources.json', 'utf-8'));
|
||||
const existing = sourcesData.sources.find(s => s.source === source);
|
||||
if (existing) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', `Source "${source}" already exists in sources.json as "${existing.name}".`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const repoCheck = await github.rest.repos.get({ owner, repo });
|
||||
if (repoCheck.status !== 200) throw new Error('not found');
|
||||
} catch (e) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', `Repository "${source}" does not exist or is not accessible on GitHub.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const cloneDir = `/tmp/skill-check-${owner}-${repo}`;
|
||||
try {
|
||||
execSync(`git clone --depth 1 https://github.com/${owner}/${repo}.git ${cloneDir}`, {
|
||||
timeout: 60000,
|
||||
stdio: 'pipe',
|
||||
});
|
||||
} catch (e) {
|
||||
core.setOutput('status', 'error');
|
||||
core.setOutput('message', `Failed to clone repository "${source}".`);
|
||||
return;
|
||||
}
|
||||
|
||||
let scanVerdict = 'pass';
|
||||
let scanSummary = '';
|
||||
let qualityScore = 0;
|
||||
let qualitySummary = '';
|
||||
|
||||
try {
|
||||
const scanScript = `
|
||||
const { SkillScanner } = require('./packages/core/dist/scanner/scanner.js');
|
||||
const scanner = new SkillScanner();
|
||||
scanner.scan('${cloneDir}').then(result => {
|
||||
console.log(JSON.stringify({
|
||||
verdict: result.verdict,
|
||||
stats: result.stats,
|
||||
findings: result.findings.length,
|
||||
}));
|
||||
});
|
||||
`;
|
||||
|
||||
const scanOutput = execSync(`node -e "${scanScript.replace(/\n/g, ' ')}"`, {
|
||||
cwd: process.cwd(),
|
||||
timeout: 30000,
|
||||
stdio: 'pipe',
|
||||
}).toString().trim();
|
||||
|
||||
const scanResult = JSON.parse(scanOutput);
|
||||
scanVerdict = scanResult.verdict;
|
||||
scanSummary = `Verdict: ${scanResult.verdict}, Findings: ${scanResult.findings}, Critical: ${scanResult.stats.critical}, High: ${scanResult.stats.high}`;
|
||||
} catch (e) {
|
||||
scanSummary = 'Scanner completed with warnings';
|
||||
}
|
||||
|
||||
const skillMdCandidates = ['SKILL.md', 'skill.md', 'README.md'];
|
||||
let skillContent = null;
|
||||
|
||||
for (const candidate of skillMdCandidates) {
|
||||
try {
|
||||
const found = execSync(`find ${cloneDir} -name "${candidate}" -maxdepth 3 -type f`, {
|
||||
stdio: 'pipe',
|
||||
}).toString().trim().split('\n').filter(Boolean);
|
||||
|
||||
if (found.length > 0) {
|
||||
skillContent = fs.readFileSync(found[0], 'utf-8');
|
||||
break;
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
if (skillContent) {
|
||||
try {
|
||||
const qualityScript = `
|
||||
const { evaluateSkillContent } = require('./packages/core/dist/quality/index.js');
|
||||
const fs = require('fs');
|
||||
const content = fs.readFileSync('${cloneDir}/.skill-content.tmp', 'utf-8');
|
||||
const result = evaluateSkillContent(content);
|
||||
console.log(JSON.stringify({ overall: result.overall, warnings: result.warnings }));
|
||||
`;
|
||||
|
||||
fs.writeFileSync(`${cloneDir}/.skill-content.tmp`, skillContent);
|
||||
|
||||
const qualityOutput = execSync(`node -e "${qualityScript.replace(/\n/g, ' ')}"`, {
|
||||
cwd: process.cwd(),
|
||||
timeout: 30000,
|
||||
stdio: 'pipe',
|
||||
}).toString().trim();
|
||||
|
||||
const qualityResult = JSON.parse(qualityOutput);
|
||||
qualityScore = qualityResult.overall;
|
||||
qualitySummary = `Score: ${qualityResult.overall}/100, Warnings: ${qualityResult.warnings.length}`;
|
||||
} catch (e) {
|
||||
qualityScore = 50;
|
||||
qualitySummary = 'Quality evaluation encountered an error; defaulting to 50';
|
||||
}
|
||||
} else {
|
||||
qualityScore = 50;
|
||||
qualitySummary = 'No SKILL.md or README.md found; defaulting to score 50';
|
||||
}
|
||||
|
||||
const scanPassed = scanVerdict !== 'fail';
|
||||
const qualityPassed = qualityScore >= 75;
|
||||
|
||||
core.setOutput('source', source);
|
||||
core.setOutput('name', name);
|
||||
core.setOutput('description', description);
|
||||
core.setOutput('official', entry.official === true ? 'true' : 'false');
|
||||
core.setOutput('scan_verdict', scanVerdict);
|
||||
core.setOutput('scan_summary', scanSummary);
|
||||
core.setOutput('quality_score', String(qualityScore));
|
||||
core.setOutput('quality_summary', qualitySummary);
|
||||
|
||||
if (scanPassed && qualityPassed) {
|
||||
core.setOutput('status', 'pass');
|
||||
core.setOutput('message', `Validation passed. Security: ${scanSummary}. Quality: ${qualitySummary}.`);
|
||||
} else {
|
||||
const reasons = [];
|
||||
if (!scanPassed) reasons.push(`Security scan failed: ${scanSummary}`);
|
||||
if (!qualityPassed) reasons.push(`Quality score ${qualityScore}/100 is below threshold of 75`);
|
||||
core.setOutput('status', 'reject');
|
||||
core.setOutput('message', reasons.join('. '));
|
||||
}
|
||||
|
||||
- name: Add source and commit
|
||||
if: steps.validate.outputs.status == 'pass'
|
||||
env:
|
||||
SKILL_SOURCE: ${{ steps.validate.outputs.source }}
|
||||
SKILL_NAME: ${{ steps.validate.outputs.name }}
|
||||
SKILL_DESCRIPTION: ${{ steps.validate.outputs.description }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const data = JSON.parse(fs.readFileSync('marketplace/sources.json', 'utf-8'));
|
||||
|
||||
const newEntry = { source: process.env.SKILL_SOURCE, name: process.env.SKILL_NAME };
|
||||
|
||||
if (process.env.SKILL_DESCRIPTION) {
|
||||
newEntry.description = process.env.SKILL_DESCRIPTION;
|
||||
}
|
||||
|
||||
const skillsSh = data.sources.pop();
|
||||
data.sources.push(newEntry);
|
||||
if (skillsSh && skillsSh.registry === 'skills-sh') {
|
||||
data.sources.push(skillsSh);
|
||||
}
|
||||
|
||||
data.updatedAt = new Date().toISOString().split('T')[0];
|
||||
fs.writeFileSync('marketplace/sources.json', JSON.stringify(data, null, 2) + '\n');
|
||||
"
|
||||
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add marketplace/sources.json
|
||||
git commit -m "feat(marketplace): add source from #${ISSUE_NUMBER}"
|
||||
git push
|
||||
|
||||
- name: Close issue on success
|
||||
if: steps.validate.outputs.status == 'pass'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SKILL_SOURCE: ${{ steps.validate.outputs.source }}
|
||||
SKILL_NAME: ${{ steps.validate.outputs.name }}
|
||||
SCAN_SUMMARY: ${{ steps.validate.outputs.scan_summary }}
|
||||
QUALITY_SUMMARY: ${{ steps.validate.outputs.quality_summary }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
cat > /tmp/comment.md <<ENDOFCOMMENT
|
||||
**Skill source auto-published!**
|
||||
|
||||
**Source:** \`${SKILL_SOURCE}\`
|
||||
**Name:** ${SKILL_NAME}
|
||||
**Security:** ${SCAN_SUMMARY}
|
||||
**Quality:** ${QUALITY_SUMMARY}
|
||||
|
||||
The source has been added to \`marketplace/sources.json\` and will be included in the next release.
|
||||
ENDOFCOMMENT
|
||||
gh issue comment "${ISSUE_NUMBER}" --body-file /tmp/comment.md
|
||||
gh issue close "${ISSUE_NUMBER}"
|
||||
|
||||
- name: Comment rejection reason
|
||||
if: steps.validate.outputs.status == 'reject'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REJECT_MESSAGE: ${{ steps.validate.outputs.message }}
|
||||
SCAN_VERDICT: ${{ steps.validate.outputs.scan_verdict }}
|
||||
SCAN_SUMMARY: ${{ steps.validate.outputs.scan_summary }}
|
||||
QUALITY_SCORE: ${{ steps.validate.outputs.quality_score }}
|
||||
QUALITY_SUMMARY: ${{ steps.validate.outputs.quality_summary }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
cat > /tmp/comment.md <<ENDOFCOMMENT
|
||||
**Skill submission did not pass automated checks.**
|
||||
|
||||
${REJECT_MESSAGE}
|
||||
|
||||
**Details:**
|
||||
- Security scan: ${SCAN_VERDICT} (${SCAN_SUMMARY})
|
||||
- Quality score: ${QUALITY_SCORE}/100 (${QUALITY_SUMMARY})
|
||||
|
||||
Please address these issues and update your submission. A maintainer will review manually.
|
||||
ENDOFCOMMENT
|
||||
gh issue comment "${ISSUE_NUMBER}" --body-file /tmp/comment.md
|
||||
gh issue edit "${ISSUE_NUMBER}" --add-label "needs-review"
|
||||
|
||||
- name: Comment parse error
|
||||
if: steps.validate.outputs.status == 'error'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ERROR_MESSAGE: ${{ steps.validate.outputs.message }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
run: |
|
||||
cat > /tmp/comment.md <<'ENDOFCOMMENT'
|
||||
**Could not process skill submission.**
|
||||
|
||||
ENDOFCOMMENT
|
||||
echo "${ERROR_MESSAGE}" >> /tmp/comment.md
|
||||
cat >> /tmp/comment.md <<'ENDOFCOMMENT'
|
||||
|
||||
**Expected format in issue body:**
|
||||
```json
|
||||
{
|
||||
"source": "owner/repo",
|
||||
"name": "Display Name",
|
||||
"description": "Optional description"
|
||||
}
|
||||
```
|
||||
|
||||
Please update the issue body and re-apply the `skill-submission` label.
|
||||
ENDOFCOMMENT
|
||||
gh issue comment "${ISSUE_NUMBER}" --body-file /tmp/comment.md
|
||||
gh issue edit "${ISSUE_NUMBER}" --add-label "needs-review"
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "./sources-schema.json",
|
||||
"version": 1,
|
||||
"updatedAt": "2026-02-28",
|
||||
"updatedAt": "2026-04-10",
|
||||
"description": "Curated skill repository sources - THE SINGLE SOURCE OF TRUTH",
|
||||
"sources": [
|
||||
{ "source": "anthropics/skills", "name": "Anthropic Official", "official": true },
|
||||
@@ -37,6 +37,7 @@
|
||||
{ "source": "intellectronica/agent-skills", "name": "Context7" },
|
||||
{ "source": "muratcankoylan/Agent-Skills-for-Context-Engineering", "name": "Context Engineering" },
|
||||
{ "source": "sickn33/antigravity-awesome-skills", "name": "Antigravity Awesome Skills" },
|
||||
{ "source": "NousResearch/hermes-agent", "name": "Hermes Agent Skills" },
|
||||
{ "source": "skills.sh", "name": "Skills.sh Leaderboard", "official": true, "registry": "skills-sh" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { existsSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { findAllSkills, findSkill, detectProvider, isLocalPath } from '@skillkit/core';
|
||||
import { getSearchDirs, loadSkillMetadata } from '../helpers.js';
|
||||
import { findAllSkills, findSkill, detectProvider, isLocalPath, evaluateSkillDirectory } from '@skillkit/core';
|
||||
import { getSearchDirs, loadSkillMetadata, formatCount, timeAgo, fetchGitHubActivity } from '../helpers.js';
|
||||
import {
|
||||
colors,
|
||||
symbols,
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
success,
|
||||
warn,
|
||||
header,
|
||||
formatQualityBadge,
|
||||
getQualityGradeFromScore,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
interface UpdateInfo {
|
||||
@@ -18,15 +20,19 @@ interface UpdateInfo {
|
||||
currentVersion?: string;
|
||||
hasUpdate: boolean;
|
||||
error?: string;
|
||||
qualityScore?: number | null;
|
||||
stars?: number | null;
|
||||
pushedAt?: string | null;
|
||||
}
|
||||
|
||||
export class CheckCommand extends Command {
|
||||
static override paths = [['check']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Check for available skill updates (dry-run)',
|
||||
description: 'Check installed skills for updates, quality, and activity',
|
||||
details: `
|
||||
Checks if installed skills have updates available from their sources.
|
||||
Shows quality scores and GitHub activity for each skill.
|
||||
Does not modify any files - just reports what would be updated.
|
||||
`,
|
||||
examples: [
|
||||
@@ -89,12 +95,15 @@ export class CheckCommand extends Command {
|
||||
|
||||
for (const skill of skillsToCheck) {
|
||||
const metadata = loadSkillMetadata(skill.path);
|
||||
const quality = evaluateSkillDirectory(skill.path);
|
||||
const qualityScore = quality?.overall ?? null;
|
||||
|
||||
if (!metadata) {
|
||||
results.push({
|
||||
name: skill.name,
|
||||
hasUpdate: false,
|
||||
error: 'No metadata (reinstall needed)',
|
||||
qualityScore,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -114,6 +123,7 @@ export class CheckCommand extends Command {
|
||||
name: skill.name,
|
||||
hasUpdate: false,
|
||||
error: 'Local source missing',
|
||||
qualityScore,
|
||||
});
|
||||
if (this.verbose) s.stop(`${skill.name}: source missing`);
|
||||
continue;
|
||||
@@ -123,20 +133,19 @@ export class CheckCommand extends Command {
|
||||
const installedSkillMd = join(skill.path, 'SKILL.md');
|
||||
|
||||
if (existsSync(sourceSkillMd) && existsSync(installedSkillMd)) {
|
||||
const { statSync } = await import('node:fs');
|
||||
const sourceTime = statSync(sourceSkillMd).mtime;
|
||||
const installedTime = statSync(installedSkillMd).mtime;
|
||||
|
||||
if (sourceTime > installedTime) {
|
||||
results.push({ name: skill.name, hasUpdate: true });
|
||||
results.push({ name: skill.name, hasUpdate: true, qualityScore });
|
||||
updatesAvailable++;
|
||||
if (this.verbose) s.stop(`${skill.name}: update available`);
|
||||
} else {
|
||||
results.push({ name: skill.name, hasUpdate: false });
|
||||
results.push({ name: skill.name, hasUpdate: false, qualityScore });
|
||||
if (this.verbose) s.stop(`${skill.name}: up to date`);
|
||||
}
|
||||
} else {
|
||||
results.push({ name: skill.name, hasUpdate: false });
|
||||
results.push({ name: skill.name, hasUpdate: false, qualityScore });
|
||||
if (this.verbose) s.stop(`${skill.name}: up to date`);
|
||||
}
|
||||
} else {
|
||||
@@ -147,15 +156,31 @@ export class CheckCommand extends Command {
|
||||
name: skill.name,
|
||||
hasUpdate: false,
|
||||
error: 'Unknown provider',
|
||||
qualityScore,
|
||||
});
|
||||
if (this.verbose) s.stop(`${skill.name}: unknown provider`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const parsed = provider.parseSource(metadata.source);
|
||||
let stars: number | null = null;
|
||||
let pushedAt: string | null = null;
|
||||
|
||||
if (parsed && provider.name === 'GitHub') {
|
||||
const activity = await fetchGitHubActivity(parsed.owner, parsed.repo);
|
||||
if (activity) {
|
||||
stars = activity.stars;
|
||||
pushedAt = activity.pushedAt;
|
||||
}
|
||||
}
|
||||
|
||||
results.push({
|
||||
name: skill.name,
|
||||
hasUpdate: false,
|
||||
currentVersion: metadata.updatedAt || metadata.installedAt,
|
||||
qualityScore,
|
||||
stars,
|
||||
pushedAt,
|
||||
});
|
||||
if (this.verbose) s.stop(`${skill.name}: remote source (run update to sync)`);
|
||||
}
|
||||
@@ -164,6 +189,7 @@ export class CheckCommand extends Command {
|
||||
name: skill.name,
|
||||
hasUpdate: false,
|
||||
error: err instanceof Error ? err.message : 'Check failed',
|
||||
qualityScore,
|
||||
});
|
||||
if (this.verbose) s.stop(`${skill.name}: error`);
|
||||
}
|
||||
@@ -178,27 +204,46 @@ export class CheckCommand extends Command {
|
||||
if (withUpdates.length > 0) {
|
||||
console.log(colors.primary('Updates available:'));
|
||||
for (const r of withUpdates) {
|
||||
console.log(` ${colors.success(symbols.arrowUp)} ${colors.primary(r.name)}`);
|
||||
const badge = this.qualityBadgeFor(r.qualityScore);
|
||||
console.log(` ${colors.success(symbols.arrowUp)} ${colors.primary(r.name)}${badge}`);
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
if (upToDate.length > 0 && this.verbose) {
|
||||
console.log(colors.muted('Up to date:'));
|
||||
for (const r of upToDate) {
|
||||
console.log(` ${colors.muted(symbols.success)} ${colors.muted(r.name)}`);
|
||||
if (upToDate.length > 0) {
|
||||
if (this.verbose) {
|
||||
console.log(colors.muted('Up to date:'));
|
||||
}
|
||||
console.log('');
|
||||
for (const r of upToDate) {
|
||||
const badge = this.qualityBadgeFor(r.qualityScore);
|
||||
const activityStr = this.formatActivity(r);
|
||||
if (this.verbose) {
|
||||
console.log(` ${colors.muted(symbols.success)} ${colors.muted(r.name)}${badge}${activityStr}`);
|
||||
}
|
||||
}
|
||||
if (this.verbose) console.log('');
|
||||
}
|
||||
|
||||
if (withErrors.length > 0) {
|
||||
console.log(colors.warning('Could not check:'));
|
||||
for (const r of withErrors) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${r.name}: ${colors.muted(r.error || 'unknown')}`);
|
||||
const badge = this.qualityBadgeFor(r.qualityScore);
|
||||
console.log(` ${colors.warning(symbols.warning)} ${r.name}${badge}: ${colors.muted(r.error || 'unknown')}`);
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
if (!this.quiet) {
|
||||
const qualityScores = results
|
||||
.map(r => r.qualityScore)
|
||||
.filter((s): s is number => typeof s === 'number');
|
||||
if (qualityScores.length > 0) {
|
||||
const avg = Math.round(qualityScores.reduce((a, b) => a + b, 0) / qualityScores.length);
|
||||
const grade = getQualityGradeFromScore(avg);
|
||||
console.log(colors.muted(`Average quality: ${avg}/100 (${grade})`));
|
||||
}
|
||||
}
|
||||
|
||||
if (updatesAvailable > 0) {
|
||||
success(`${updatesAvailable} update(s) available`);
|
||||
console.log(colors.muted('Run `skillkit update` to install updates'));
|
||||
@@ -208,4 +253,22 @@ export class CheckCommand extends Command {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private qualityBadgeFor(score: number | null | undefined): string {
|
||||
if (typeof score !== 'number') return '';
|
||||
return ` ${formatQualityBadge(score)}`;
|
||||
}
|
||||
|
||||
private formatActivity(r: UpdateInfo): string {
|
||||
const parts: string[] = [];
|
||||
if (typeof r.stars === 'number' && r.stars > 0) {
|
||||
parts.push(`${formatCount(r.stars)} stars`);
|
||||
}
|
||||
if (r.pushedAt) {
|
||||
parts.push(`pushed ${timeAgo(r.pushedAt)}`);
|
||||
}
|
||||
if (parts.length === 0) return '';
|
||||
return ` ${colors.muted(`(${parts.join(', ')})`)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,15 @@ import {
|
||||
statSync,
|
||||
} from "node:fs";
|
||||
import { join, basename, dirname, resolve, sep } from "node:path";
|
||||
import { colors, warn, success, error, step } from "../onboarding/index.js";
|
||||
import {
|
||||
colors,
|
||||
warn,
|
||||
success,
|
||||
error,
|
||||
step,
|
||||
formatQualityBadge,
|
||||
getQualityGradeFromScore,
|
||||
} from "../onboarding/index.js";
|
||||
import { Command, Option } from "clipanion";
|
||||
import {
|
||||
generateWellKnownIndex,
|
||||
@@ -15,7 +23,9 @@ import {
|
||||
SkillScanner,
|
||||
formatSummary,
|
||||
Severity,
|
||||
evaluateSkillDirectory,
|
||||
} from "@skillkit/core";
|
||||
import { formatCount, timeAgo, fetchGitHubActivity } from "../helpers.js";
|
||||
|
||||
function sanitizeSkillName(name: string): string | null {
|
||||
if (!name || typeof name !== "string") return null;
|
||||
@@ -480,6 +490,14 @@ export class PublishSubmitCommand extends Command {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const skillDir = dirname(skillMdPath);
|
||||
const quality = evaluateSkillDirectory(skillDir);
|
||||
const qualityScore = quality?.overall ?? null;
|
||||
const qualityGrade = qualityScore !== null ? getQualityGradeFromScore(qualityScore) : null;
|
||||
const qualityBadge = qualityScore !== null ? formatQualityBadge(qualityScore) : "N/A";
|
||||
|
||||
const activity = await fetchGitHubActivity(repoInfo.owner, repoInfo.repo);
|
||||
|
||||
const skillEntry = {
|
||||
id: `${repoInfo.owner}/${repoInfo.repo}/${skillSlug}`,
|
||||
name: this.formatName(skillName),
|
||||
@@ -496,6 +514,19 @@ export class PublishSubmitCommand extends Command {
|
||||
console.log(colors.muted(` Description: ${skillEntry.description}`));
|
||||
console.log(colors.muted(` Source: ${skillEntry.source}`));
|
||||
console.log(colors.muted(` Tags: ${skillEntry.tags.join(", ")}`));
|
||||
console.log(colors.muted(` Quality: ${qualityBadge}${qualityScore !== null ? ` (${qualityScore}/100)` : ""}`));
|
||||
if (activity) {
|
||||
const stars = formatCount(activity.stars);
|
||||
const pushed = activity.pushedAt ? timeAgo(activity.pushedAt) : "unknown";
|
||||
console.log(colors.muted(` Stars: ${stars}`));
|
||||
console.log(colors.muted(` Last push: ${pushed}`));
|
||||
}
|
||||
if (quality && quality.warnings.length > 0) {
|
||||
console.log(colors.warning(` Warnings:`));
|
||||
for (const w of quality.warnings.slice(0, 3)) {
|
||||
console.log(colors.muted(` - ${w}`));
|
||||
}
|
||||
}
|
||||
console.log();
|
||||
|
||||
if (this.dryRun) {
|
||||
@@ -504,33 +535,61 @@ export class PublishSubmitCommand extends Command {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const issueBody = this.createIssueBody(skillEntry);
|
||||
const issueTitle = encodeURIComponent(`[Publish] ${skillEntry.name}`);
|
||||
const issueBodyEncoded = encodeURIComponent(issueBody);
|
||||
const issueUrl = `https://github.com/rohitg00/skillkit/issues/new?title=${issueTitle}&body=${issueBodyEncoded}&labels=skill-submission,publish`;
|
||||
|
||||
success("Opening GitHub to submit your skill...\n");
|
||||
const issueBody = this.createIssueBody(skillEntry, {
|
||||
qualityScore,
|
||||
qualityGrade,
|
||||
warnings: quality?.warnings ?? [],
|
||||
stars: activity?.stars ?? null,
|
||||
pushedAt: activity?.pushedAt ?? null,
|
||||
});
|
||||
|
||||
try {
|
||||
const { execFileSync } = await import("node:child_process");
|
||||
const cmd =
|
||||
process.platform === "darwin"
|
||||
? "open"
|
||||
: process.platform === "win32"
|
||||
? "cmd"
|
||||
: "xdg-open";
|
||||
const args =
|
||||
process.platform === "win32"
|
||||
? ["/c", "start", "", issueUrl]
|
||||
: [issueUrl];
|
||||
execFileSync(cmd, args, { stdio: "ignore" });
|
||||
const result = execFileSync(
|
||||
"gh",
|
||||
[
|
||||
"issue",
|
||||
"create",
|
||||
"--repo",
|
||||
"rohitg00/skillkit",
|
||||
"--title",
|
||||
`[Publish] ${skillEntry.name}`,
|
||||
"--body",
|
||||
issueBody,
|
||||
"--label",
|
||||
"skill-submission,publish",
|
||||
],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
timeout: 15_000,
|
||||
},
|
||||
).trim();
|
||||
|
||||
success("GitHub issue page opened!");
|
||||
console.log(colors.muted("Review and submit the issue."));
|
||||
} catch {
|
||||
warn("Could not open browser automatically.");
|
||||
console.log(colors.muted("Please open this URL manually:\n"));
|
||||
console.log(colors.cyan(issueUrl));
|
||||
success("Submission created!");
|
||||
if (result) {
|
||||
console.log(colors.muted(` ${result}`));
|
||||
}
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
if (message.includes("not found") || message.includes("ENOENT")) {
|
||||
error("GitHub CLI (gh) is not installed");
|
||||
console.error(
|
||||
colors.muted("Install it from https://cli.github.com then run `gh auth login`"),
|
||||
);
|
||||
} else if (message.includes("auth") || message.includes("401")) {
|
||||
error("GitHub CLI is not authenticated");
|
||||
console.error(colors.muted("Run `gh auth login` first"));
|
||||
} else {
|
||||
error("Failed to create issue");
|
||||
console.error(colors.muted(message));
|
||||
}
|
||||
|
||||
console.log();
|
||||
warn("You can submit manually instead:");
|
||||
const manualUrl = `https://github.com/rohitg00/skillkit/issues/new?title=${encodeURIComponent(`[Publish] ${skillEntry.name}`)}&labels=skill-submission,publish`;
|
||||
console.log(colors.cyan(manualUrl));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -601,13 +660,36 @@ export class PublishSubmitCommand extends Command {
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
private createIssueBody(skill: {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
source: string;
|
||||
tags: string[];
|
||||
}): string {
|
||||
private createIssueBody(
|
||||
skill: {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
source: string;
|
||||
tags: string[];
|
||||
},
|
||||
meta: {
|
||||
qualityScore: number | null;
|
||||
qualityGrade: string | null;
|
||||
warnings: string[];
|
||||
stars: number | null;
|
||||
pushedAt: string | null;
|
||||
},
|
||||
): string {
|
||||
const qualityLine =
|
||||
meta.qualityScore !== null
|
||||
? `- **Quality:** ${meta.qualityGrade} (${meta.qualityScore}/100)`
|
||||
: "- **Quality:** N/A";
|
||||
const starsLine =
|
||||
typeof meta.stars === "number" ? `- **Stars:** ${formatCount(meta.stars)}` : "";
|
||||
const pushLine = meta.pushedAt
|
||||
? `- **Last push:** ${meta.pushedAt.slice(0, 10)}`
|
||||
: "";
|
||||
const warningLines =
|
||||
meta.warnings.length > 0
|
||||
? `\n### Warnings\n${meta.warnings.map((w) => `- ${w}`).join("\n")}`
|
||||
: "";
|
||||
|
||||
return `## Publish Skill Request
|
||||
|
||||
### Skill Details
|
||||
@@ -616,6 +698,10 @@ export class PublishSubmitCommand extends Command {
|
||||
- **Description:** ${skill.description}
|
||||
- **Source:** [${skill.source}](https://github.com/${skill.source})
|
||||
- **Tags:** ${skill.tags.map((t) => `\`${t}\``).join(", ")}
|
||||
${qualityLine}
|
||||
${starsLine}
|
||||
${pushLine}
|
||||
${warningLines}
|
||||
|
||||
### JSON Entry
|
||||
\`\`\`json
|
||||
|
||||
@@ -48,3 +48,35 @@ export function formatCount(count: number): string {
|
||||
if (count >= 1_000) return `${(count / 1_000).toFixed(1)}K`;
|
||||
return String(count);
|
||||
}
|
||||
|
||||
export function timeAgo(dateStr: string): string {
|
||||
const now = Date.now();
|
||||
const then = new Date(dateStr).getTime();
|
||||
if (Number.isNaN(then)) return 'unknown';
|
||||
const days = Math.floor((now - then) / 86_400_000);
|
||||
if (days === 0) return 'today';
|
||||
if (days === 1) return 'yesterday';
|
||||
if (days < 30) return `${days}d ago`;
|
||||
if (days < 365) return `${Math.floor(days / 30)}mo ago`;
|
||||
return `${Math.floor(days / 365)}y ago`;
|
||||
}
|
||||
|
||||
export async function fetchGitHubActivity(
|
||||
owner: string,
|
||||
repo: string,
|
||||
): Promise<{ stars: number; pushedAt: string | null } | null> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://api.github.com/repos/${owner}/${repo}`,
|
||||
{ signal: AbortSignal.timeout(5000) },
|
||||
);
|
||||
if (!response.ok) return null;
|
||||
const data = (await response.json()) as Record<string, unknown>;
|
||||
return {
|
||||
stars: typeof data.stargazers_count === 'number' ? data.stargazers_count : 0,
|
||||
pushedAt: typeof data.pushed_at === 'string' ? data.pushed_at : null,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user