-
Notifications
You must be signed in to change notification settings - Fork 957
feat(skills): hierarchical skill optimization and search command #507
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| "gws": patch | ||
| --- | ||
|
|
||
| feat(skills): implement hierarchical skill discovery and search command | ||
|
|
||
| - Restructure skills/ into hierarchical references/ subdirectory to avoid agent context pollution. | ||
| - Add `gws skills search <query>` command for semantic/keyword discovery of 40+ API services. | ||
| - Restore essential safety tips (zsh ! expansion, JSON quoting) in the gws-shared skill. | ||
| - Refactor generate-skills logic to automate artifact generation and link validation. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,4 @@ docs/plans/ | |
|
|
||
| # Generated | ||
| demo.mp4 | ||
| download.html | ||
| download.htmlskills/ | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||
| import os | ||||||
| import re | ||||||
| from pathlib import Path | ||||||
|
|
||||||
| def check_links(): | ||||||
| basedir = Path("skills").resolve() | ||||||
| docsdir = Path("docs").resolve() | ||||||
|
|
||||||
| # regex to find markdown links: [text](path) | ||||||
| link_regex = re.compile(r'\[.*?\]\(([^http].*?)\)') | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regular expression to find links is incorrect. The character set The regex should match any path, and then HTTP links should be filtered out inside the loop. After applying the suggested change to this line, you should also add a check for
Suggested change
|
||||||
|
|
||||||
| broken_links = 0 | ||||||
| total_links = 0 | ||||||
|
|
||||||
| files_to_check = list(basedir.rglob("*.md")) + list(docsdir.rglob("*.md")) | ||||||
|
|
||||||
| for filepath in files_to_check: | ||||||
| with open(filepath, 'r') as f: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's best practice to specify the file encoding when opening text files. Without it, the script may fail on systems with a different default encoding (like Windows) if a file contains non-ASCII characters. Please add
Suggested change
|
||||||
| content = f.read() | ||||||
|
|
||||||
| for match in link_regex.finditer(content): | ||||||
| link_path = match.group(1).strip() | ||||||
|
|
||||||
| # Skip empty links, mailto:, etc | ||||||
| if not link_path or link_path.startswith(('mailto:', 'tel:')): | ||||||
| continue | ||||||
|
|
||||||
| # Skip absolute web paths like /chat/api/guides/... | ||||||
| if link_path.startswith('/'): | ||||||
| continue | ||||||
|
|
||||||
| # Skip anchor-only links | ||||||
| if link_path.startswith('#'): | ||||||
| continue | ||||||
|
|
||||||
| # Remove anchor from filename | ||||||
| file_part = link_path.split('#')[0] | ||||||
| if not file_part: | ||||||
| continue | ||||||
|
|
||||||
| total_links += 1 | ||||||
| target_path = (filepath.parent / file_part).resolve() | ||||||
| if not target_path.exists(): | ||||||
| print(f"Broken link in {filepath}: {link_path} (resolved to {target_path})") | ||||||
| broken_links += 1 | ||||||
|
|
||||||
| print(f"Checked {total_links} local links.") | ||||||
| if broken_links > 0: | ||||||
| print(f"Found {broken_links} broken links!") | ||||||
| exit(1) | ||||||
| else: | ||||||
| print("All local links are valid!") | ||||||
|
|
||||||
| if __name__ == "__main__": | ||||||
| check_links() | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
skills/directory was appended to the same line asdownload.html, creating a single entrydownload.htmlskills/. This is likely a mistake and will not ignore theskills/directory as intended. Each entry in.gitignoreshould be on its own line.