Feature/delta team/epic r04 (#7)
CI / test (push) Canceled after 0s

## Summary

epic r04 - begin refactor

## Change Type

- [x] Cowork feature
- [ ] Bug fix
- [ ] Core AI contribution
- [ ] Test / hardening
- [ ] Performance
- [ ] Documentation

## Related Work

Cowork Task:

Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets

Core AI Issue:

Core Task:

Related PR:

## Scope

What is intentionally included?

What is intentionally NOT included?

## Validation

- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual verification
- [ ] Regression check

Commands / evidence:

## Security Impact

Permission / credential / network / customer data impact:

## Compatibility

- [ ] No breaking change
- [ ] Breaking change documented

## Reviewer Notes

Anything Cowork reviewers should pay attention to.

---------

Co-authored-by: Anh Tran Nguyen Minh <anhtnm1@fpt.com>
Co-authored-by: Huong Le Thi Thien <huongltt35@fpt.com>
Co-authored-by: Nam Pham Dinh Thanh <nampdt@fpt.com>
Co-authored-by: Vu Dam Tuan <vudt15@fpt.com>
Co-authored-by: Hiep Ha Van <hiephv3@fpt.com>
Co-authored-by: Lam Hoang Van <lamhv7@fpt.com>
Reviewed-on: #7
Co-authored-by: Duy Le Huu <duylh19@fpt.com>
This commit was merged in pull request #7.
This commit is contained in:
2026-08-31 05:15:13 +00:00
committed by gitea-admin
co-authored by anhtnm1 huongltt35 Nam Pham Dinh Thanh vudt15 Hiep Ha Van lamhv7
parent 86c27e2e79
commit f9f6bc01fd
496 changed files with 68421 additions and 19688 deletions
+15
View File
@@ -36,6 +36,7 @@ LIBRARY_DIR = Path(__file__).resolve().parent.parent / "skill_library"
@dataclass
class Skill:
"""Một Skill: tên, mô tả, phần chỉ dẫn chèn vào prompt, và cờ bật/tắt."""
name: str
description: str = ""
instructions: str = ""
@@ -43,12 +44,14 @@ class Skill:
@property
def slug(self) -> str:
"""Định danh an toàn cho tên file, suy từ tên skill."""
keep = "-_"
s = "".join(c if (c.isalnum() or c in keep) else "-" for c in self.name.strip().lower())
return "-".join(filter(None, s.split("-"))) or "skill"
def skills_dir() -> Path:
"""Thư mục chứa skill của người dùng."""
return SKILLS_DIR
@@ -180,6 +183,9 @@ def builtin_skills() -> List[Skill]:
def _builtin_slugs() -> set[str]:
"""Tập slug của các skill dựng sẵn — dùng để không gieo trùng và không cho sửa
chúng như skill thường.
"""
return {s.slug for s in builtin_skills()}
@@ -277,6 +283,11 @@ def list_skills(directory: Path | None = None) -> List[Skill]:
def save_skill(skill: Skill, directory: Path | None = None, old_name: str = "") -> Path:
"""Ghi một skill xuống đĩa.
Đổi tên thì XOÁ file cũ trước — tên file suy từ tên skill, không xoá sẽ để
lại một bản sao dưới tên cũ.
"""
directory = directory or SKILLS_DIR
directory.mkdir(parents=True, exist_ok=True)
if old_name and old_name != skill.name:
@@ -287,6 +298,7 @@ def save_skill(skill: Skill, directory: Path | None = None, old_name: str = "")
def delete_skill(name: str, directory: Path | None = None) -> None:
"""Xoá file skill theo tên; không có thì bỏ qua."""
directory = directory or SKILLS_DIR
path = directory / f"{Skill(name=name).slug}.json"
if path.exists():
@@ -304,6 +316,9 @@ def _load_skill_from_zip(path: Path) -> "Skill | None":
import zipfile
def _rank(n: str) -> int:
"""Thứ tự ưu tiên khi gói zip có nhiều file Markdown: ``skill.md`` trước, rồi
tới file ở gốc gói, cuối cùng mới tới file nằm sâu.
"""
low = n.lower()
if low.endswith("skill.md"):
return 0