README (badges from Gitea Actions and shields' Gitea release badge, "Where things live", downloads from releases.poli0981.dev, checksums and the CycloneDX SBOM instead of `gh attestation verify`, a note that 2.2.0 and older must update once by hand), USAGE, UPDATES (the HTTP feed, the file layout on R2, the delta from `vpk download s3`), RELEASING (the new release workflow, its dry run, user-level R2 secrets), BUILD (the CI table on Gitea Actions, Renovate), PRIVACY (the update check goes to releases.poli0981.dev through Cloudflare), SECURITY (e-mail only, never a public issue on the mirror; Qodana, gitleaks, Opengrep, osv-scanner, NuGetAudit, Renovate instead of CodeQL, Scorecard, SonarCloud, Snyk and Dependabot; no attestations), CONTRIBUTING (Gitea read-only, issues and merge requests on GitLab, patches by e-mail), CODE_OF_CONDUCT, EULA, DISCLAIMER and MAINTAINERS lose their GitHub references, THIRD-PARTY-NOTICES swaps SonarScanner for CycloneDX, Directory.Build.props points RepositoryUrl at Gitea, and CLAUDE.md gets the new rules 6 and 7 and a "Forge & CI" section. CHANGELOG entries stay as they were; only the compare links at the bottom point at Gitea. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 KiB
CLAUDE.md
File này là ngữ cảnh + luật bắt buộc cho AI coding agent (Claude Code) khi làm việc trong repo này. Đọc kỹ trước khi sinh/sửa code. Mọi tài liệu chi tiết nằm trong thư mục
docs/(xem Chỉ mục tài liệu).
1. Dự án là gì
CommandForge (tên tạm) — ứng dụng desktop Windows giúp người dùng chạy các lệnh hệ thống phức tạp (winget, DISM, God Mode, registry tweak, network reset…) qua giao diện trực quan, có phân loại, không cần nhớ cú pháp.
- Chỉ Windows 10 (22H2) và 11, x64 (ARM64 nếu được).
- Open-source, GPLv3.
- Cài & cập nhật bằng Velopack (unpackaged, không qua Store); feed + gói trên Cloudflare R2
https://releases.poli0981.dev/commandforge. - Mã nguồn chuẩn trên Gitea
git.poli0981.dev/poli0981/CommandForge(tài khoản GitHub đã bị khóa từ 11/2026); issue/MR qua mirror GitLabgitlab.com/poli0981/CommandForge(xem mục 9). - Trạng thái: ổn định, chế độ bảo trì từ v2.2.0 (2026-11-16). Chỉ nhận: cập nhật dependency;
vá bảo mật (High/Critical → bản vá khẩn, Moderate → đợt cập nhật định kỳ kế tiếp); nâng cấp nền
tảng lớn (.NET mới); thêm/bớt/sửa lệnh catalog (lỗi thời, sai cú pháp, có thể gây hại — loại gây
hại báo riêng qua email
security@); sửa lỗi, UI/UX, accessibility; sửa bản dịch. Tính năng mới chỉ khi thật sự phù hợp và cần thiết. Nguồn chuẩn của chính sách:.github/CONTRIBUTING.md#maintenance-mode-what-we-accept.
2. Luật vàng (KHÔNG được vi phạm)
- An toàn lệnh: Catalog lệnh là tài nguyên nhúng, chỉ-đọc. TUYỆT ĐỐI KHÔNG nạp lệnh tùy ý từ file/người dùng rồi tự nâng quyền Admin. Mọi lệnh chạy với quyền cao phải nằm trong catalog đã kiểm duyệt.
- Nâng quyền theo nhu cầu: UI chính chạy
asInvoker(không elevated). Lệnh cần Admin đi qua tiến trình phụCommandForge.Elevator(xemdocs/architectures.md). Không bắt cả app chạy Admin trừ khi bất khả kháng. - Khởi động lại: Phát hiện cần reboot bằng exit code
3010(ERROR_SUCCESS_REBOOT_REQUIRED), không chỉ parse text. - Ranh giới kiến trúc:
Domainkhông phụ thuộc gì.Applicationchỉ phụ thuộcDomain.Infrastructure/Wpfhiện thực các interface củaApplication. Không bao giờ đểDomain/Applicationtham chiếu WPF hay Win32. - Không obfuscate. Mã GPLv3 vốn công khai; obfuscate vừa vô nghĩa vừa gây false-positive antivirus.
- Hiện chưa ký số Authenticode (sẽ thêm Azure Trusted Signing/SignPath sau — xem
docs/Build.md). Đừng thêm bước ký Authenticode vào build/CI lúc này. SBOM (CycloneDX) vàSHA256SUMSdoscripts/release-assets.ps1tạo trongrelease.yml(tải lênreleases.poli0981.dev/commandforge/<version>/) là bắt buộc và phải giữ. Attestation build-provenance đã bỏ khi rời GitHub (Gitea không có OIDC — quyết định D7 của runbook). - Không telemetry. Mạng duy nhất được phép: kiểm tra/tải cập nhật từ
https://releases.poli0981.dev/commandforge(ProductLinks.UpdateFeed). Bất kỳ thu thập dữ liệu nào khác đều bị cấm (vi phạmdocs/Privacy.md). - Xác nhận trước lệnh nguy hiểm. Lệnh
Caution/Dangerousphải có hộp thoại xác nhận; không cho phép tắt xác nhận với nhómDangerous.
3. Tech stack (tóm tắt — chi tiết ở docs/tech.md)
- .NET 10 (LTS), C# 14 · WPF + WPF-UI 4.3 (Fluent, lepoco) — đã thay Material Design từ v2.0.0
- CommunityToolkit.Mvvm (MVVM) · Microsoft.Extensions.DependencyInjection (
ServiceCollection+ValidateOnBuild; không dùng Generic Host) - CsWin32 (P/Invoke) · Serilog (logging) ·
System.Threading.Channels - Velopack (
vpkpin làm local tool trong.config/dotnet-tools.json) cho cài đặt + cập nhật qua Cloudflare R2 (HTTP source); CycloneDX (local tool) tạo SBOM khi phát hành - Test: xUnit v3 (
xunit.v3.mtp-off, chạy qua VSTest) · SonarAnalyzer.CSharp (Roslyn analyzer) chạy trong build · Qodana trong CI (không còn SonarCloud — D1) - i18n:
.resx5 ngôn ngữ (EN/VI/JA/zh-Hans/ES)
4. Bố cục solution (chi tiết ở docs/architectures.md)
src/
CommandForge.Domain/ # entities thuần
CommandForge.Application/ # use-cases + interfaces (ports)
CommandForge.Infrastructure/ # Process, registry, Velopack, Serilog
CommandForge.Wpf/ # View + ViewModel + DI bootstrap + .resx (namespace: CommandForge.Desktop)
helper/
CommandForge.Elevator/ # tiến trình phụ chạy lệnh Admin (named pipe)
tests/
CommandForge.Tests/ # xUnit
5. Lệnh build/run/test (chi tiết ở docs/Build.md)
dotnet restore
dotnet build -c Debug
dotnet run --project src/CommandForge.Wpf
dotnet test
dotnet format CommandForge.slnx --verify-no-changes
# Phát hành + đóng gói (publish ReadyToRun + vpk pack → Releases/):
dotnet tool restore
pwsh ./scripts/pack.ps1 -Version <ver>
Phát hành thật: tag ký GPG vX.Y.Z trên main (khớp <Version>) → .gitea/workflows/release.yml → R2 + release Gitea + Discord (xem RELEASING.md). Chạy tay Release trên nhánh = dry run (không upload).
6. Quy ước code (chi tiết ở docs/codestyle.md)
- Code, định danh, comment kỹ thuật: tiếng Anh. Chuỗi hiển thị cho người dùng:
.resx(EN/VI/JA/zh-Hans/ES) — không hardcode chuỗi UI; mỗi key phải có ở cả 5 file (testResxKeyTestsquét UI để kiểm tra). - Namespace tầng giao diện là
CommandForge.Desktop(project/assembly/exe vẫn tênCommandForge.Wpf): namespaceCommandForge.Wpfche namespace gốcWpfcủa WPF-UI trong code XAML sinh ra. - Accessibility (xem
ACCESSIBILITY.md): control không có chữ phải cóAutomationProperties.Nametừ.resx; item của danh sách được đặt tên quaItemContainerStyle; icon dùngctl:DecorativeIcon(không dùngui:SymbolIcon/new SymbolIcon— glyph vùng Unicode riêng bị Narrator đọc); không truyền thông tin chỉ bằng màu; thông báo cho Narrator quaINotificationService.Announce.AccessibilityTestsvàWpfAccessibilityRuntimeTests(STA, template WPF-UI thật) kiểm tra. - WPF-UI: mỗi trang (UserControl trong NavigationView) phải đặt
Foreground="{DynamicResource TextFillColorPrimaryBrush}"ở gốc (Frame không truyền màu chữ xuống); lớp con củaContentDialogphải gọiSetResourceReference(StyleProperty, typeof(ContentDialog))—XamlConventionsTestskiểm tra cả hai. Cỡ chữ dùngDynamicResource AppFontSize*. - Version package đặt trong từng
.csproj(không dùng Central Package Management — quy ước có từ thời GitHub; Renovate đọc được cả hai). - Nullable reference types bật;
TreatWarningsAsErrorsbật; analyzers bật. async/awaitxuyên suốt cho I/O; khôngasync void(trừ event handler); luôn truyềnCancellationToken.- MVVM bằng source-generator của CommunityToolkit (
[ObservableProperty],[RelayCommand]). - File-scoped namespace; một type/file (trừ ngoại lệ hợp lý).
- Đẩy output process về UI bằng
Channel<T>+ dispatcher; không chạm UI từ thread nền.
7. Bất biến quan trọng khi đụng tới các vùng nhạy cảm
- Thêm lệnh mới: chỉ thêm vào catalog JSON (
Infrastructure/Catalog/commands.json) theo schema ởdocs/CatalogCommand.md; thêm key chuỗi vào cả 5 file.resx; icon phải có trongConverters/IconMap.cs; PowerShell luôn-NoProfile -NonInteractive; dùng token{SystemDrive}/{SystemRoot}/{UserProfile}thay vì đường dẫn cứng; viết test validate catalog. Catalog sẽ được bổ sung/cập nhật liên tục theo thời gian — giữ schema ổn định, dễ mở rộng. - Sửa luồng nâng quyền: đọc kỹ
docs/Security.mdtrước. - Sửa luồng cập nhật: xử lý đủ
404 / 403 / 429 / 5xx / offline(KHÔNG có mã419).
8. Chỉ mục tài liệu
| File | Nội dung |
|---|---|
docs/tech.md |
Tech stack, third-party (font, update…), phiên bản |
docs/architectures.md |
Kiến trúc chi tiết, ports/adapters, elevation broker, threading |
docs/codestyle.md |
Chuẩn code C#/XAML, .editorconfig, analyzers |
docs/UI.md |
Đặc tả giao diện từng thành phần (Fluent / WPF-UI) |
docs/CatalogCommand.md |
Toàn bộ lệnh + nhóm lệnh + schema |
docs/roadmap.md |
Lộ trình theo phase, milestone, version |
docs/note.md |
Ghi chú, quyết định, "gotcha", nhắc nhở |
docs/Extra.md |
Ý tưởng/tính năng tương lai (v2+) |
docs/Security.md |
Mô hình bảo mật, threat model, disclosure |
docs/Build.md |
Build, test, publish, release, CI |
docs/Testing.md |
Chiến lược kiểm thử |
docs/Changelog.md |
Chỉ trỏ về CHANGELOG.md (gốc repo) |
docs/LICENSE.md / Privacy.md / EULA.md / Disclaimer.md |
Bản pháp lý nội bộ (bản công khai ở gốc repo là chuẩn) |
⚠️ Thư mục
docs/nằm trong.gitignore(tài liệu nội bộ, chỉ có trên máy).
Tài liệu công khai (ở gốc repo, được commit): README.md, ACCESSIBILITY.md (tuyên bố trợ năng — mục tiêu WCAG 2.2 AA, không phải tuyên bố tuân thủ; link "Accessibility" trong About), USAGE.md (hướng dẫn người dùng — link "User guide" trong app), CHANGELOG.md, BUILD.md, RELEASING.md, UPDATES.md, PRIVACY.md, EULA.md, DISCLAIMER.md, THIRD-PARTY-NOTICES.md, MAINTAINERS.md, LICENSE, và trong .github/: SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md. Legal Gate trỏ tới EULA/PRIVACY/DISCLAIMER/LICENSE công khai (trên Gitea, qua ProductLinks). Template issue/MR cho GitLab ở .gitlab/; .github/ISSUE_TEMPLATE giữ cho Gitea.
Email liên hệ (@poli0981.dev): security@ (lỗ hổng — kênh riêng tư duy nhất, không bao giờ qua issue công khai) · accessibility@ (rào cản trợ năng, cùng template Accessibility trên GitLab) · privacy@ · legal@ · copyright@ / dmca@ / takedown@ (bản quyền, DMCA, yêu cầu gỡ bỏ khác) · code@ (mã nguồn, đóng góp, báo cáo Code of Conduct) · collab@ · press@ · sponsor@. Không dùng games@ cho dự án này.
9. Forge & CI
- Gitea (
https://git.poli0981.dev, Gitea 28.x) là nhà chính; remoteorigin= Gitea (SSH cổng 2222),github= remote cũ (tài khoản bị khóa — không bao giờ push/xóa). Mirror công khai GitLab nhận issue/MR; registration của Gitea đóng. Runbook di chuyển:E:\.github\docs\GITEA-MIGRATION.md(repo opspoli0981/.github). - CI = Gitea Actions trong
.gitea/workflows/(không còn.github/workflows). Runner là PC của maintainer:windows-latest= host mode (PowerShell, không cô lập;setup-dotnetcài vào tool cache),ubuntu-latest= Docker. Cron chỉ trong 13:00–16:00 UTC, phút lẻ, slot đăng ký trongdocs/migration/README.mdcủa repo ops (CommandForge:Securitythứ Sáu 14:11 UTC). - Workflow dùng chung từ repo ops, pin theo SHA của tag ops (
# ops vYYYY.MM.N) kèmops_refcùng SHA; Renovate không bump các pin này — bump tay khi repo ops có tag mới. Mọi action bên thứ ba pin SHA 40 ký tự + comment version. Upload artifact bằngchristopherhx/gitea-upload-artifact. - Không có trên Gitea: CodeQL, Dependabot, SonarCloud, Scorecard, dependency review, attestations/OIDC, GitHub Pages/Discussions/Releases,
ghCLI (dùng Gitea REST API với job token). Thay bằng: Qodana (CLI),security.yml(gitleaks, Opengrep, osv-scanner, NuGetAudit, actionlint), Renovate (renovate.json+ presetpoli0981/renovate-config). - Bí mật phát hành (
R2_RELEASES_*, biếnR2_ACCOUNT_ID, cấp user) chỉ dùng trongrelease.yml(tag/dispatch), qua biến môi trườngVPK_*, không bao giờ trên dòng lệnh hay trong jobpull_request/schedule.