-
Notifications
You must be signed in to change notification settings - Fork 52
feat: add greptimedb-quickstart skill with onboarding card #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
15e5c5c
feat: add greptimedb-quickstart skill with onboarding card and expand…
killme2008 055a3d5
chore: refactor code
killme2008 839337e
fix: address by CR
killme2008 b38f115
chore: render version in skill.md
killme2008 0af4d81
fix: missing skills in workflow
killme2008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/usr/bin/env node | ||
| // Mirrors every skills/<name>/SKILL.md to static/ so Docusaurus publishes them | ||
| // at the site root: | ||
| // skills/greptimedb-quickstart/SKILL.md -> static/SKILL.md | ||
| // -> static/skills/greptimedb-quickstart/SKILL.md | ||
| // skills/<other>/SKILL.md -> static/skills/<other>/SKILL.md | ||
| // | ||
| // The root /SKILL.md is the agent-onboarding entrypoint (copied from | ||
| // greptimedb-quickstart). The /skills/<name>/SKILL.md endpoints let agents | ||
| // fetch sister skills directly from the docs site instead of guessing GitHub | ||
| // paths. | ||
| // | ||
| // Runs as a prestart / prebuild npm hook. Never edit anything under | ||
| // static/SKILL.md or static/skills/ by hand. | ||
|
|
||
| import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; | ||
| import { dirname, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const skillsDir = resolve(repoRoot, 'skills'); | ||
| const staticDir = resolve(repoRoot, 'static'); | ||
| const ROOT_SKILL = 'greptimedb-quickstart'; | ||
|
|
||
| // Wipe previous outputs so a renamed or deleted skill does not leave a stale | ||
| // SKILL.md behind under static/skills/. | ||
| const staticSkillsDir = resolve(staticDir, 'skills'); | ||
| const staticRootSkill = resolve(staticDir, 'SKILL.md'); | ||
| if (existsSync(staticSkillsDir)) rmSync(staticSkillsDir, { recursive: true, force: true }); | ||
| if (existsSync(staticRootSkill)) rmSync(staticRootSkill, { force: true }); | ||
|
|
||
| // Load version variables from variables/variables-<latestStable>.ts and resolve | ||
| // VAR::name placeholders in each skill, mirroring what llms-txt-generator.ts | ||
| // does for the .md endpoints. Without this, version-pinned commands in | ||
| // SKILL.md (Docker tag, install.sh argument) would ship the literal | ||
| // "VAR::greptimedbVersion" string to agents. | ||
| const latestVersion = JSON.parse(readFileSync(resolve(repoRoot, 'versions.json'), 'utf8'))[0]; | ||
| const variables = loadVariables(latestVersion); | ||
|
|
||
| function loadVariables(version) { | ||
| const file = resolve(repoRoot, 'variables', `variables-${version}.ts`); | ||
| if (!existsSync(file)) { | ||
| console.warn(`[sync-skill] variables-${version}.ts not found; VAR:: placeholders will not be resolved`); | ||
| return {}; | ||
| } | ||
| const text = readFileSync(file, 'utf8'); | ||
| const out = {}; | ||
| for (const m of text.matchAll(/(\w+):\s*['"]([^'"]+)['"]/g)) { | ||
| out[m[1]] = m[2]; | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| function resolveVariables(content) { | ||
| return content.replace(/VAR::([A-Z_]+)/gi, (match, name) => variables[name] ?? match); | ||
| } | ||
|
|
||
| // Inject the breadcrumb as a YAML comment inside the frontmatter so strict | ||
| // frontmatter parsers (Anthropic Skill loaders, etc.) still see `---` as the | ||
| // first byte of the file. Falls back to an HTML comment prefix when the | ||
| // source has no frontmatter. | ||
| function withBanner(body, srcRel) { | ||
| const yamlComment = `# Generated from ${srcRel}. Do not edit by hand.\n`; | ||
| const match = body.match(/^---\r?\n/); | ||
| if (match) { | ||
| return body.slice(0, match[0].length) + yamlComment + body.slice(match[0].length); | ||
| } | ||
| return `<!-- Generated from ${srcRel}. Do not edit by hand. -->\n` + body; | ||
| } | ||
|
|
||
| function writeWithBanner(srcAbs, dstAbs, srcRel) { | ||
| mkdirSync(dirname(dstAbs), { recursive: true }); | ||
| const body = resolveVariables(readFileSync(srcAbs, 'utf8')); | ||
| writeFileSync(dstAbs, withBanner(body, srcRel), 'utf8'); | ||
| console.log(`[sync-skill] ${srcRel} -> ${dstAbs.slice(repoRoot.length + 1)}`); | ||
| } | ||
|
|
||
| for (const name of readdirSync(skillsDir, { withFileTypes: true })) { | ||
| if (!name.isDirectory()) continue; | ||
| const src = resolve(skillsDir, name.name, 'SKILL.md'); | ||
| const srcRel = `skills/${name.name}/SKILL.md`; | ||
| try { | ||
| readFileSync(src); | ||
| } catch { | ||
| continue; | ||
| } | ||
| writeWithBanner(src, resolve(staticDir, 'skills', name.name, 'SKILL.md'), srcRel); | ||
| if (name.name === ROOT_SKILL) { | ||
| writeWithBanner(src, resolve(staticDir, 'SKILL.md'), srcRel); | ||
| } | ||
| } | ||
|
killme2008 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.