Repository navigation
chore(skills): keep one skills catalog index under backend/docs/skills (TASK-029) #2938
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { | ||
| backendRootFrom, | ||
| BUNDLED_CATALOG_PATH, | ||
| resolveSkillsCatalogPath, | ||
| } = require('../../../services/skillsCatalogPath'); | ||
|
|
||
| const BACKEND_ROOT = path.resolve(__dirname, '../../..'); | ||
| const REPO_ROOT = path.resolve(BACKEND_ROOT, '..'); | ||
|
|
||
| describe('skillsCatalogPath', () => { | ||
| let savedPath; | ||
| let savedDir; | ||
|
|
||
| beforeEach(() => { | ||
| savedPath = process.env.SKILLS_CATALOG_PATH; | ||
| savedDir = process.env.SKILLS_CATALOG_DIR; | ||
| delete process.env.SKILLS_CATALOG_PATH; | ||
| delete process.env.SKILLS_CATALOG_DIR; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| if (savedPath === undefined) delete process.env.SKILLS_CATALOG_PATH; | ||
| else process.env.SKILLS_CATALOG_PATH = savedPath; | ||
| if (savedDir === undefined) delete process.env.SKILLS_CATALOG_DIR; | ||
| else process.env.SKILLS_CATALOG_DIR = savedDir; | ||
| }); | ||
|
|
||
| it('resolves the backend root from both the source and the built layout', () => { | ||
| expect(backendRootFrom('/repo/backend/services')).toBe('/repo/backend'); | ||
| expect(backendRootFrom('/app/dist/services')).toBe('/app'); | ||
| }); | ||
|
|
||
| it('defaults to the one checked-in copy under backend/docs/skills', () => { | ||
| expect(BUNDLED_CATALOG_PATH).toBe( | ||
| path.join(BACKEND_ROOT, 'docs', 'skills', 'awesome-agent-skills-index.json'), | ||
| ); | ||
| expect(resolveSkillsCatalogPath()).toBe(BUNDLED_CATALOG_PATH); | ||
| expect(fs.existsSync(BUNDLED_CATALOG_PATH)).toBe(true); | ||
| }); | ||
|
|
||
| it('keeps a single copy of the catalog in the repo', () => { | ||
| // The root and Helm copies were deleted in TASK-029. Nothing reads them, | ||
| // so a reappearance would be drift, not a fallback. | ||
| expect(fs.existsSync(path.join(REPO_ROOT, 'docs/skills/awesome-agent-skills-index.json'))).toBe(false); | ||
| expect( | ||
| fs.existsSync(path.join(REPO_ROOT, 'k8s/helm/commonly/configs/awesome-agent-skills-index.json')), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it('prefers SKILLS_CATALOG_PATH, then SKILLS_CATALOG_DIR', () => { | ||
| process.env.SKILLS_CATALOG_DIR = '/catalog-dir'; | ||
| expect(resolveSkillsCatalogPath()).toBe('/catalog-dir/awesome-agent-skills-index.json'); | ||
| process.env.SKILLS_CATALOG_PATH = '/explicit/index.json'; | ||
| expect(resolveSkillsCatalogPath()).toBe('/explicit/index.json'); | ||
| }); | ||
| }); |
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,35 @@ | ||
| import path from 'path'; | ||
|
|
||
| // The one checked-in copy of the skills catalog lives at | ||
| // backend/docs/skills/, the only location inside the backend Docker build | ||
| // context. The image bakes it at /app/docs/skills/, and the Helm init | ||
| // container copies it from there when SKILLS_CATALOG_URL is unset or fails. | ||
|
|
||
| const CATALOG_FILE = 'awesome-agent-skills-index.json'; | ||
|
|
||
| // This module runs from backend/services/ under ts-node and jest, and from | ||
| // backend/dist/services/ in the built image. Either way the answer is the | ||
| // backend package root. | ||
| export const backendRootFrom = (dir: string): string => { | ||
| const parent = path.resolve(dir, '..'); | ||
| return path.basename(parent) === 'dist' ? path.resolve(parent, '..') : parent; | ||
| }; | ||
|
|
||
| export const BUNDLED_CATALOG_PATH = path.join( | ||
| backendRootFrom(__dirname), | ||
| 'docs', | ||
| 'skills', | ||
| CATALOG_FILE, | ||
| ); | ||
|
|
||
| // SKILLS_CATALOG_PATH wins, then SKILLS_CATALOG_DIR, then the bundled copy. | ||
| // Every reader and the refresh writer go through here so they agree. | ||
| export const resolveSkillsCatalogPath = (): string => { | ||
| if (process.env.SKILLS_CATALOG_PATH) { | ||
| return process.env.SKILLS_CATALOG_PATH; | ||
| } | ||
| if (process.env.SKILLS_CATALOG_DIR) { | ||
| return path.join(process.env.SKILLS_CATALOG_DIR, CATALOG_FILE); | ||
| } | ||
| return BUNDLED_CATALOG_PATH; | ||
| }; |
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
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.