txa 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {txa-1.2.0 → txa-1.3.0}/PKG-INFO +1 -1
  2. {txa-1.2.0 → txa-1.3.0}/src/txa/__init__.py +1 -1
  3. txa-1.3.0/src/txa/ci/agreement.py +230 -0
  4. txa-1.3.0/src/txa/ci/api.py +246 -0
  5. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/cli.py +1 -1
  6. {txa-1.2.0 → txa-1.3.0}/src/txa/cli.py +60 -23
  7. {txa-1.2.0 → txa-1.3.0}/src/txa/core/config.py +18 -1
  8. {txa-1.2.0 → txa-1.3.0}/src/txa/core/console.py +250 -21
  9. txa-1.3.0/src/txa/core/i18n.py +607 -0
  10. {txa-1.2.0 → txa-1.3.0}/src/txa/create/cli.py +101 -36
  11. {txa-1.2.0 → txa-1.3.0}/src/txa/create/draft.py +21 -0
  12. {txa-1.2.0 → txa-1.3.0}/src/txa/create/submit.py +4 -6
  13. {txa-1.2.0 → txa-1.3.0}/src/txa/create/winget.py +280 -10
  14. {txa-1.2.0 → txa-1.3.0}/src/txa/create/wizard.py +39 -26
  15. {txa-1.2.0 → txa-1.3.0}/src/txa/pm/cli.py +130 -33
  16. {txa-1.2.0 → txa-1.3.0}/src/txa/pm/installer.py +22 -8
  17. {txa-1.2.0 → txa-1.3.0}/src/txa/pm/source.py +60 -6
  18. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/PKG-INFO +1 -1
  19. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/SOURCES.txt +1 -0
  20. txa-1.2.0/src/txa/ci/agreement.py +0 -141
  21. txa-1.2.0/src/txa/ci/api.py +0 -97
  22. {txa-1.2.0 → txa-1.3.0}/README.md +0 -0
  23. {txa-1.2.0 → txa-1.3.0}/pyproject.toml +0 -0
  24. {txa-1.2.0 → txa-1.3.0}/setup.cfg +0 -0
  25. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/__init__.py +0 -0
  26. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/checks.py +0 -0
  27. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/context.py +0 -0
  28. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/gate.py +0 -0
  29. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/pending.py +0 -0
  30. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/progress.py +0 -0
  31. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/report.py +0 -0
  32. {txa-1.2.0 → txa-1.3.0}/src/txa/ci/steps.py +0 -0
  33. {txa-1.2.0 → txa-1.3.0}/src/txa/constants.py +0 -0
  34. {txa-1.2.0 → txa-1.3.0}/src/txa/core/__init__.py +0 -0
  35. {txa-1.2.0 → txa-1.3.0}/src/txa/core/credentials.py +0 -0
  36. {txa-1.2.0 → txa-1.3.0}/src/txa/core/engines.py +0 -0
  37. {txa-1.2.0 → txa-1.3.0}/src/txa/core/github.py +0 -0
  38. {txa-1.2.0 → txa-1.3.0}/src/txa/core/licenses.py +0 -0
  39. {txa-1.2.0 → txa-1.3.0}/src/txa/core/manifest.py +0 -0
  40. {txa-1.2.0 → txa-1.3.0}/src/txa/core/net.py +0 -0
  41. {txa-1.2.0 → txa-1.3.0}/src/txa/core/pe.py +0 -0
  42. {txa-1.2.0 → txa-1.3.0}/src/txa/core/portable.py +0 -0
  43. {txa-1.2.0 → txa-1.3.0}/src/txa/core/semver.py +0 -0
  44. {txa-1.2.0 → txa-1.3.0}/src/txa/core/signing.py +0 -0
  45. {txa-1.2.0 → txa-1.3.0}/src/txa/core/userpath.py +0 -0
  46. {txa-1.2.0 → txa-1.3.0}/src/txa/core/winos.py +0 -0
  47. {txa-1.2.0 → txa-1.3.0}/src/txa/create/__init__.py +0 -0
  48. {txa-1.2.0 → txa-1.3.0}/src/txa/create/ghmeta.py +0 -0
  49. {txa-1.2.0 → txa-1.3.0}/src/txa/pm/__init__.py +0 -0
  50. {txa-1.2.0 → txa-1.3.0}/src/txa/pm/uninstall.py +0 -0
  51. {txa-1.2.0 → txa-1.3.0}/src/txa/schemas/about.schema.json +0 -0
  52. {txa-1.2.0 → txa-1.3.0}/src/txa/schemas/build.schema.json +0 -0
  53. {txa-1.2.0 → txa-1.3.0}/src/txa/schemas/core.schema.json +0 -0
  54. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/dependency_links.txt +0 -0
  55. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/entry_points.txt +0 -0
  56. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/requires.txt +0 -0
  57. {txa-1.2.0 → txa-1.3.0}/src/txa.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txa
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: TXA package manager toolchain: txapm (install), txacreate (publish), txaci (16-step validator), txacli (WinGet & repo CLI)
5
5
  Author: TXA Software Dev
6
6
  License: MIT
@@ -1,3 +1,3 @@
1
1
  """TXA package manager toolchain."""
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.3.0"
@@ -0,0 +1,230 @@
1
+ """Contributor Agreement & PR Checklist verification.
2
+
3
+ The bot asks the author to:
4
+ 1. Complete and tick the required checkboxes in the PR description.
5
+ 2. Accept the TXA Contributor Agreement by commenting "@txa-repo agree" (or "@txa-bot agree").
6
+
7
+ For new packages, both the checklist and agreement comment are strictly required.
8
+ Once both requirements are satisfied, the bot removes the agreement comment,
9
+ updates its own comment with `signed=<author>`, removes `txa:needs-agreement`,
10
+ sets `txa/agreement` to success, and triggers the 16 validation checks.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import re
15
+
16
+ from txa.constants import LABELS, STATUS_CONTEXT
17
+ from txa.core.github import GitHub, GitHubError
18
+
19
+ MARK = "<!-- txa-bot:agreement"
20
+ PHRASE = "@txa-repo agree"
21
+ _PHRASE_RE = re.compile(r'^\s*@?(?:txa-repo|txa-bot)\s+agree(?:\s+company\s*=\s*"([^"\r\n]{1,80})")?\s*[.!]?\s*$', re.I)
22
+ LABEL = LABELS["agree"][0]
23
+ CONTEXT = "txa/agreement"
24
+ EXEMPT = {"MEMBER", "COLLABORATOR"} # For updates only; new packages always require explicit agreement
25
+
26
+
27
+ def pending_checklist_items(body: str | None) -> list[str]:
28
+ """Returns list of pending required checklist items from PR body."""
29
+ items: list[str] = []
30
+ for line in (body or "").splitlines():
31
+ m = re.match(r"^\s*[-*+]\s*\[\s*\]\s+(.*)$", line)
32
+ if m:
33
+ text = m.group(1).strip()
34
+ # Ignore optional items
35
+ if "(if applicable)" in text.lower() or text.lower().startswith("resolves #"):
36
+ continue
37
+ items.append(text)
38
+ return items
39
+
40
+
41
+ def _needs_action_text(login: str, pending_items: list[str], needs_agree: bool, is_new_pkg: bool) -> str:
42
+ lines = [
43
+ f"Hello @{login},", "",
44
+ "Thank you for opening this pull request! Before the automatic 16-step verification checks can proceed, "
45
+ "the following requirements must be completed:", "",
46
+ ]
47
+ step_num = 1
48
+ if pending_items:
49
+ lines.append(f"{step_num}. 🔲 **Complete the PR Checklist**:")
50
+ lines.append(" Please tick all required checkboxes in the pull request description above "
51
+ "(edit the description or click the checkboxes directly on GitHub):")
52
+ for item in pending_items:
53
+ lines.append(f" - [ ] {item}")
54
+ lines.append("")
55
+ step_num += 1
56
+
57
+ if needs_agree:
58
+ new_pkg_note = " *(Mandatory for new packages)*" if is_new_pkg else ""
59
+ lines.append(f"{step_num}. ✍️ **TXA Contributor Agreement**:{new_pkg_note}")
60
+ lines.append(" You confirm that you have the right to submit this manifest, that the installer is the "
61
+ "vendor's own official download, and that the package follows repository policy.")
62
+ lines.append(f" To accept, reply to this pull request with a single comment:\n ```\n {PHRASE}\n ```")
63
+ lines.append(f" *(Contributing for a company? Use `{PHRASE} company=\"Example Ltd\"`)*\n")
64
+ step_num += 1
65
+
66
+ if not pending_items and needs_agree:
67
+ lines.append("✓ *The PR checklist is complete!* Waiting for your agreement comment above.\n")
68
+ elif pending_items and not needs_agree:
69
+ lines.append("✓ *Contributor Agreement confirmed!* Waiting for you to check the remaining items in the PR checklist above.\n")
70
+
71
+ lines.append("Once all requirements are satisfied, the bot will accept the agreement and automatically run all 16 pipeline checks.\n")
72
+ lines.append("<sub>Template: txabot/needsAgreement</sub>")
73
+ return "\n".join(lines)
74
+
75
+
76
+ def _signed_text(login: str, how: str = "", company: str = "") -> str:
77
+ extra = f" ({how})" if how else ""
78
+ firm = f" on behalf of **{company}**" if company else ""
79
+ return (f"{MARK} signed={login} -->\n✅ **Contributor Agreement & Checklist accepted** by @{login}{firm}{extra}. "
80
+ "Thank you - the automatic 16 checks go on.\n\n<sub>Template: txabot/agreementSigned</sub>")
81
+
82
+
83
+ def find(gh: GitHub, repo: str, number: int) -> dict | None:
84
+ for comment in gh.paginate(f"repos/{repo}/issues/{number}/comments"):
85
+ if comment["body"].startswith(MARK) and comment["user"]["type"] == "Bot":
86
+ return comment
87
+ return None
88
+
89
+
90
+ def _is_signed_comment(comment: dict | None, login: str) -> bool:
91
+ return bool(comment) and f"signed={login} -->" in comment["body"].split("\n", 1)[0]
92
+
93
+
94
+ def _extract_agreed(comment: dict | None, login: str) -> tuple[bool, str]:
95
+ if not comment:
96
+ return False, ""
97
+ header = comment["body"].split("\n", 1)[0]
98
+ if f"signed={login}" in header:
99
+ return True, ""
100
+ m = re.search(rf'agreed={re.escape(login)}(?:\s+company="([^"]+)")?', header)
101
+ if m:
102
+ return True, m.group(1) or ""
103
+ return False, ""
104
+
105
+
106
+ def is_signed(gh: GitHub, repo: str, pr: dict) -> bool:
107
+ return _is_signed_comment(find(gh, repo, pr["number"]), pr["user"]["login"])
108
+
109
+
110
+ def _returning(gh: GitHub, repo: str, login: str) -> bool:
111
+ """Someone who accepted the agreement on a pull request that was merged has signed once for good."""
112
+ try:
113
+ data = gh.get("search/issues", params={"q": f"repo:{repo} is:pr is:merged author:{login}", "per_page": 5})
114
+ return any(_is_signed_comment(find(gh, repo, item["number"]), login) for item in data.get("items", []))
115
+ except GitHubError:
116
+ return False
117
+
118
+
119
+ def _set_status(gh: GitHub, repo: str, pr: dict, signed: bool, desc: str = "") -> None:
120
+ """``txa/agreement`` shows the step in the merge box; while it is open the required status is held too."""
121
+ sha = pr["head"]["sha"]
122
+ default_desc = "Contributor Agreement accepted" if signed else f"Check PR checklist & comment {PHRASE}"
123
+ gh.post(f"repos/{repo}/statuses/{sha}", json={
124
+ "state": "success" if signed else "pending", "context": CONTEXT,
125
+ "description": desc or default_desc})
126
+ if not signed:
127
+ gh.post(f"repos/{repo}/statuses/{sha}", json={
128
+ "state": "pending", "context": STATUS_CONTEXT,
129
+ "description": "Waiting for author to complete checklist & accept agreement"})
130
+
131
+
132
+ def process(gh: GitHub, repo: str, number: int, comment_id: int | None = None) -> int:
133
+ """Process checklist and agreement verification for a pull request."""
134
+ pr = gh.get(f"repos/{repo}/pulls/{number}")
135
+ if pr["state"] != "open":
136
+ return 0
137
+ author = pr["user"]["login"]
138
+ title = (pr.get("title") or "").strip().lower()
139
+ body = pr.get("body") or ""
140
+ is_new_pkg = title.startswith("new package") or "new package:" in body.lower()
141
+
142
+ current = {label["name"] for label in pr.get("labels", [])}
143
+ bot = find(gh, repo, number)
144
+ if _is_signed_comment(bot, author):
145
+ print(f"agreement: PR #{number} already accepted - nothing to do")
146
+ return 0
147
+
148
+ how, company = "", ""
149
+ comment_agreed = False
150
+ if comment_id:
151
+ try:
152
+ comment = gh.get(f"repos/{repo}/issues/comments/{comment_id}")
153
+ except GitHubError:
154
+ comment = None
155
+ if comment and comment.get("user", {}).get("login") == author:
156
+ match = _PHRASE_RE.match(comment.get("body", ""))
157
+ if match:
158
+ gh.delete(f"repos/{repo}/issues/comments/{comment_id}", ok=(404,))
159
+ comment_agreed = True
160
+ company = " ".join((match.group(1) or "").split())
161
+
162
+ prior_agreed, prior_company = _extract_agreed(bot, author)
163
+ if comment_agreed:
164
+ has_agreed = True
165
+ elif prior_agreed:
166
+ has_agreed = True
167
+ if not company:
168
+ company = prior_company
169
+ else:
170
+ has_agreed = False
171
+
172
+ # New packages ALWAYS require explicit agreement comment from the author.
173
+ # For existing package updates, previous agreements or maintainer status can be recognized.
174
+ if not is_new_pkg and not has_agreed:
175
+ if pr.get("author_association") in EXEMPT:
176
+ has_agreed, how = True, "maintainer, exempt"
177
+ elif _returning(gh, repo, author):
178
+ has_agreed, how = True, "agreed on an earlier pull request"
179
+
180
+ # Verify checklist checkboxes in PR body
181
+ pending = pending_checklist_items(body)
182
+ checklist_done = (len(pending) == 0)
183
+
184
+ signed = checklist_done and has_agreed
185
+
186
+ from txa.ci.gate import set_labels # late: gate imports this module
187
+
188
+ if signed:
189
+ signed_body = _signed_text(author, how, company)
190
+ if bot and "signed=" not in bot["body"].split("\n", 1)[0]:
191
+ gh.patch(f"repos/{repo}/issues/comments/{bot['id']}", json={"body": signed_body})
192
+ elif not bot:
193
+ gh.post(f"repos/{repo}/issues/{number}/comments", json={"body": signed_body})
194
+ set_labels(gh, repo, number, current, add=set(), remove={LABEL})
195
+ _set_status(gh, repo, pr, True)
196
+ _rerun_gate(gh, repo, pr)
197
+ print(f"agreement: PR #{number} accepted by {author} (checklist complete and agreed)")
198
+ return 0
199
+
200
+ # Still waiting for checklist and/or agreement
201
+ header = f"{MARK} pending author={author}{f' agreed={author}' if has_agreed else ''}{f' company=\"{company}\"' if company else ''} -->"
202
+ action_body = f"{header}\n" + _needs_action_text(author, pending, not has_agreed, is_new_pkg)
203
+ if bot:
204
+ gh.patch(f"repos/{repo}/issues/comments/{bot['id']}", json={"body": action_body})
205
+ else:
206
+ gh.post(f"repos/{repo}/issues/{number}/comments", json={"body": action_body})
207
+
208
+ stale = {LABELS[key][0] for key in ("validating", "verified", "fix", "review", "approved", "confirm")}
209
+ set_labels(gh, repo, number, current, add={LABEL}, remove=stale)
210
+ _set_status(gh, repo, pr, False, "Checklist or agreement pending")
211
+ print(f"agreement: PR #{number} waiting for {author} (pending={len(pending)}, agreed={has_agreed})")
212
+ return 0
213
+
214
+
215
+ def _rerun_gate(gh: GitHub, repo: str, pr: dict) -> None:
216
+ """The agreement is signed: now the 16 steps may start (re-run a skipped validation, start the live checklist)."""
217
+ from txa.ci.progress import find_validate_run
218
+
219
+ sha = pr["head"]["sha"]
220
+ try:
221
+ run = find_validate_run(gh, repo, sha)
222
+ if run and run.get("status") == "completed":
223
+ gh.post(f"repos/{repo}/actions/runs/{run['id']}/rerun")
224
+ except GitHubError as exc:
225
+ print(f"::warning::could not re-run the checks ({exc})")
226
+ try:
227
+ gh.post(f"repos/{repo}/actions/workflows/txa-progress.yml/dispatches",
228
+ json={"ref": pr["base"]["ref"], "inputs": {"pr": str(pr["number"]), "sha": sha}})
229
+ except GitHubError as exc:
230
+ print(f"::warning::could not start the live checklist ({exc})")
@@ -0,0 +1,246 @@
1
+ """Static JSON API (namespace txa.v1) published to GitHub Pages from txa-repo.
2
+
3
+ Layout under ``<out>/api/txa/v1/``::
4
+
5
+ index.json every package, newest version summary
6
+ packages/<Id>.json every version of one package, all three cards
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ from datetime import datetime, timezone
12
+ from pathlib import Path
13
+
14
+ from txa.constants import API_NAMESPACE
15
+ from txa.core import semver
16
+ from txa.core.manifest import Bundle, assemble, kind_of, schema_errors
17
+
18
+
19
+ def _valid(bundle: Bundle) -> list[str]:
20
+ problems = [f"{name}: {p}" for name, items in bundle.problems.items() for p in items]
21
+ for name, card in bundle.cards.items():
22
+ problems += [f"{name}: {e}" for e in schema_errors(kind_of(name), card)]
23
+ if not bundle.core or not bundle.build or not bundle.default_about():
24
+ problems.append("incomplete release (core, build and default about cards are required)")
25
+ return problems
26
+
27
+
28
+ def collect(repo_root: Path) -> tuple[dict[str, dict[str, dict]], list[dict]]:
29
+ """Read every valid release under manifests/ -> ({id: {version: cards}}, skipped)."""
30
+ packages: dict[str, dict[str, dict]] = {}
31
+ skipped = []
32
+ for release in sorted((repo_root / "manifests").glob("*/*/*/*")):
33
+ if not release.is_dir() or not semver.is_valid(release.name):
34
+ continue
35
+ bundle = Bundle.read(release)
36
+ problems = _valid(bundle)
37
+ if problems:
38
+ skipped.append({"path": release.relative_to(repo_root).as_posix(), "problems": problems[:5]})
39
+ continue
40
+ packages.setdefault(bundle.package_id, {})[bundle.version] = assemble(bundle)
41
+ return packages, skipped
42
+
43
+
44
+ def package_document(package_id: str, versions: dict[str, dict]) -> dict:
45
+ ordered = sorted(versions, key=semver.parse, reverse=True)
46
+ return {"api": "txa.v1", "id": package_id, "latest": ordered[0], "versions": {v: versions[v] for v in ordered}}
47
+
48
+
49
+ def index_document(packages: dict[str, dict[str, dict]]) -> dict:
50
+ from txa.core import i18n
51
+
52
+ index = []
53
+ for package_id in sorted(packages, key=str.lower):
54
+ document = package_document(package_id, packages[package_id])
55
+ latest = document["versions"][document["latest"]]
56
+ about = latest["about"].get(latest["core"]["locale"]["default"]) or next(iter(latest["about"].values()))
57
+ summaries = {loc: ab["summary"] for loc, ab in latest["about"].items() if isinstance(ab, dict) and ab.get("summary")}
58
+ vi_sum = summaries.get("vi-VN") or i18n._SUMMARIES_VI.get(package_id.split(".")[-1].lower())
59
+ if vi_sum:
60
+ summaries.setdefault("vi-VN", vi_sum)
61
+ en_sum = summaries.get("en-US") or i18n._SUMMARIES_EN.get(package_id.split(".")[-1].lower()) or about["summary"]
62
+ if en_sum:
63
+ summaries.setdefault("en-US", en_sum)
64
+ index.append({
65
+ "id": package_id,
66
+ "alias": latest["core"]["package"].get("alias"),
67
+ "aliases": latest["core"]["package"].get("aliases", []),
68
+ "latest": document["latest"],
69
+ "versions": list(document["versions"]),
70
+ "name": about["name"],
71
+ "publisher": about["publisher"],
72
+ "summary": about["summary"],
73
+ "summaries": summaries,
74
+ "tags": latest["core"].get("tags", []),
75
+ "arches": [t["arch"] for t in latest["build"]["targets"]],
76
+ })
77
+ generated = datetime.now(timezone.utc).isoformat(timespec="seconds")
78
+ return {"api": "txa.v1", "generated": generated, "count": len(index), "packages": index}
79
+
80
+
81
+ def build_api(repo_root: Path, out: Path, pending: list[dict] | None = None) -> dict:
82
+ import html
83
+
84
+ packages, skipped = collect(repo_root)
85
+ api = out / API_NAMESPACE
86
+ (api / "packages").mkdir(parents=True, exist_ok=True)
87
+ for package_id, versions in packages.items():
88
+ document = package_document(package_id, versions)
89
+ (api / "packages" / f"{package_id}.json").write_text(json.dumps(document, ensure_ascii=False, indent=1), "utf-8")
90
+ manifest = index_document(packages)
91
+ index, generated = manifest["packages"], manifest["generated"]
92
+ waiting = sorted(pending or [], key=lambda e: (e["id"].lower(), e["version"]))
93
+ (api / "pending.json").write_text(json.dumps(
94
+ {"api": "txa.v1", "generated": generated, "count": len(waiting), "packages": waiting}, ensure_ascii=False, indent=1), "utf-8")
95
+ (api / "index.json").write_text(json.dumps(manifest, ensure_ascii=False, indent=1), "utf-8")
96
+ (out / ".nojekyll").write_text("", "utf-8")
97
+
98
+ rows_list = []
99
+ for p in index:
100
+ sums = p.get("summaries") or {}
101
+ sum_en = html.escape(sums.get("en-US") or p.get("summary") or "")
102
+ sum_vi = html.escape(sums.get("vi-VN") or p.get("summary") or "")
103
+ pkg_id = html.escape(p["id"])
104
+ latest = html.escape(p["latest"])
105
+ alias = html.escape(p.get("alias") or p["id"])
106
+ install_cmd = f"txapm install {alias}"
107
+ rows_list.append(
108
+ f"<tr data-search='{pkg_id.lower()} {alias.lower()} {sum_en.lower()} {sum_vi.lower()}'>"
109
+ f"<td><a href='{API_NAMESPACE}/packages/{pkg_id}.json'><code>{pkg_id}</code></a></td>"
110
+ f"<td><span class='ver'>{latest}</span></td>"
111
+ f"<td><code class='cmd' onclick='navigator.clipboard.writeText(this.textContent)' title='Click to copy'>{install_cmd}</code></td>"
112
+ f"<td class='sum' data-en='{sum_en}' data-vi='{sum_vi}'>{sum_vi}</td>"
113
+ f"</tr>"
114
+ )
115
+ rows = "".join(rows_list)
116
+ page_html = f"""<!doctype html>
117
+ <html lang="vi">
118
+ <head>
119
+ <meta charset="utf-8">
120
+ <meta name="viewport" content="width=device-width,initial-scale=1">
121
+ <title>TXA Package Index</title>
122
+ <style>
123
+ :root {{ --bg:#0d1117; --card:#161b22; --border:#30363d; --text:#e6edf3; --muted:#8b949e; --accent:#58a6ff; --green:#3fb950; }}
124
+ @media (prefers-color-scheme: light) {{
125
+ :root {{ --bg:#ffffff; --card:#f6f8fa; --border:#d0d7de; --text:#1f2328; --muted:#656d76; --accent:#0969da; --green:#1a7f37; }}
126
+ }}
127
+ * {{ box-sizing:border-box; }}
128
+ body {{ font:15px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; background:var(--bg); color:var(--text); margin:0; padding:2rem 1rem; }}
129
+ .wrap {{ max-width:74rem; margin:0 auto; }}
130
+ .top {{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:1.2rem; }}
131
+ h1 {{ margin:0; font-size:1.65rem; }}
132
+ .meta {{ color:var(--muted); margin:.25rem 0 0; font-size:.92rem; }}
133
+ .meta a {{ color:var(--accent); text-decoration:none; }}
134
+ .lang-switch {{ display:inline-flex; border:1px solid var(--border); border-radius:8px; overflow:hidden; background:var(--card); }}
135
+ .lang-switch button {{ border:0; background:transparent; color:var(--muted); padding:.4rem .85rem; cursor:pointer; font-weight:600; font-size:.88rem; }}
136
+ .lang-switch button.active {{ background:var(--accent); color:#fff; }}
137
+ .bar {{ display:flex; flex-wrap:wrap; gap:.75rem; margin:1rem 0 1.25rem; align-items:center; }}
138
+ .search {{ flex:1; min-width:220px; padding:.55rem .85rem; border:1px solid var(--border); border-radius:8px; background:var(--card); color:var(--text); font-size:.95rem; }}
139
+ .oneliner {{ padding:.5rem .8rem; background:var(--card); border:1px solid var(--border); border-radius:8px; font-family:ui-monospace,Consolas,monospace; font-size:.84rem; cursor:pointer; color:var(--accent); }}
140
+ table {{ width:100%; border-collapse:collapse; background:var(--card); border:1px solid var(--border); border-radius:10px; overflow:hidden; }}
141
+ th, td {{ padding:.6rem .85rem; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }}
142
+ th {{ background:rgba(127,127,127,.08); font-size:.86rem; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); }}
143
+ tr:last-child td {{ border-bottom:0; }}
144
+ tr:hover td {{ background:rgba(88,166,255,.05); }}
145
+ code {{ font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-size:.88rem; }}
146
+ td a {{ color:var(--accent); text-decoration:none; font-weight:600; }}
147
+ .ver {{ color:var(--green); font-weight:600; font-family:ui-monospace,Consolas,monospace; font-size:.88rem; }}
148
+ .cmd {{ background:rgba(127,127,127,.14); padding:.18rem .45rem; border-radius:5px; cursor:pointer; white-space:nowrap; }}
149
+ .cmd:hover {{ outline:1px solid var(--accent); }}
150
+ </style>
151
+ </head>
152
+ <body>
153
+ <div class="wrap">
154
+ <div class="top">
155
+ <div>
156
+ <h1 id="title">Kho gói phần mềm TXA (TXA Package Index)</h1>
157
+ <p class="meta">
158
+ <span id="pkg-count">{len(index)}</span> <span id="lbl-pkgs">gói phần mềm</span> ·
159
+ <span id="lbl-gen">cập nhật</span> {generated} ·
160
+ <a href="{API_NAMESPACE}/index.json">index.json</a> ·
161
+ <a href="{API_NAMESPACE}/pending.json">pending.json</a> ·
162
+ <a href="https://github.com/TXAVL/txa-repo">GitHub</a>
163
+ </p>
164
+ </div>
165
+ <div class="lang-switch">
166
+ <button id="btn-vi" onclick="setLang('vi')">🇻🇳 Tiếng Việt</button>
167
+ <button id="btn-en" onclick="setLang('en')">🇬🇧 English</button>
168
+ </div>
169
+ </div>
170
+ <div class="bar">
171
+ <input id="q" class="search" type="search" placeholder="Tìm kiếm phần mềm theo tên, mã gói hoặc mô tả..." oninput="filterRows(this.value)">
172
+ <div class="oneliner" onclick="navigator.clipboard.writeText('irm https://raw.githubusercontent.com/TXAVL/txa-repo/main/install.ps1 | iex')" title="Click to copy">
173
+ irm https://raw.githubusercontent.com/TXAVL/txa-repo/main/install.ps1 | iex
174
+ </div>
175
+ </div>
176
+ <table>
177
+ <thead>
178
+ <tr>
179
+ <th id="th-id">Mã gói (Id)</th>
180
+ <th id="th-ver">Phiên bản</th>
181
+ <th id="th-cmd">Lệnh cài nhanh</th>
182
+ <th id="th-sum">Mô tả</th>
183
+ </tr>
184
+ </thead>
185
+ <tbody id="tbody">{rows}</tbody>
186
+ </table>
187
+ </div>
188
+ <script>
189
+ const I18N = {{
190
+ vi: {{
191
+ title: "Kho gói phần mềm TXA",
192
+ pkgs: "gói phần mềm",
193
+ gen: "cập nhật",
194
+ search: "Tìm kiếm phần mềm theo tên, mã gói hoặc mô tả (Tiếng Việt / Tiếng Anh)...",
195
+ thId: "Mã gói (Id)",
196
+ thVer: "Phiên bản",
197
+ thCmd: "Lệnh cài nhanh",
198
+ thSum: "Mô tả"
199
+ }},
200
+ en: {{
201
+ title: "TXA Package Index",
202
+ pkgs: "package(s)",
203
+ gen: "generated",
204
+ search: "Search packages by name, ID, alias, or description...",
205
+ thId: "Id",
206
+ thVer: "Latest",
207
+ thCmd: "Install Command",
208
+ thSum: "Summary"
209
+ }}
210
+ }};
211
+ function setLang(lang) {{
212
+ const t = I18N[lang] || I18N.vi;
213
+ localStorage.setItem("txa_lang", lang);
214
+ document.documentElement.lang = lang;
215
+ document.getElementById("title").textContent = t.title;
216
+ document.getElementById("lbl-pkgs").textContent = t.pkgs;
217
+ document.getElementById("lbl-gen").textContent = t.gen;
218
+ document.getElementById("q").placeholder = t.search;
219
+ document.getElementById("th-id").textContent = t.thId;
220
+ document.getElementById("th-ver").textContent = t.thVer;
221
+ document.getElementById("th-cmd").textContent = t.thCmd;
222
+ document.getElementById("th-sum").textContent = t.thSum;
223
+ document.getElementById("btn-vi").classList.toggle("active", lang === "vi");
224
+ document.getElementById("btn-en").classList.toggle("active", lang === "en");
225
+ document.querySelectorAll("td.sum").forEach(td => {{
226
+ td.textContent = td.getAttribute("data-" + lang) || td.textContent;
227
+ }});
228
+ }}
229
+ function filterRows(q) {{
230
+ const words = q.toLowerCase().trim().split(/\\s+/).filter(Boolean);
231
+ let shown = 0;
232
+ document.querySelectorAll("#tbody tr").forEach(tr => {{
233
+ const hay = tr.getAttribute("data-search") || "";
234
+ const ok = words.every(w => hay.includes(w));
235
+ tr.style.display = ok ? "" : "none";
236
+ if (ok) shown++;
237
+ }});
238
+ document.getElementById("pkg-count").textContent = shown;
239
+ }}
240
+ const saved = localStorage.getItem("txa_lang") || ((navigator.language || "").toLowerCase().startsWith("vi") ? "vi" : "vi");
241
+ setLang(saved);
242
+ </script>
243
+ </body>
244
+ </html>"""
245
+ (out / "index.html").write_text(page_html, "utf-8")
246
+ return {"packages": len(index), "pending": len(waiting), "skipped": skipped, "out": str(api)}
@@ -165,7 +165,7 @@ def cmd_schema(args) -> int:
165
165
 
166
166
  def main(argv: list[str] | None = None) -> int:
167
167
  console.setup()
168
- parser = argparse.ArgumentParser(prog="txaci", description="TXA 16-step manifest validator",
168
+ parser = console.SmartArgumentParser(prog="txaci", description="TXA 16-step manifest validator",
169
169
  epilog='examples:\n txaci validate manifests/t/TXAVL/HelloTool/1.4.2\n txaci validate <folder> --offline\n txaci schema build\n\ninit/step/verdict/gate are used by the GitHub bot.', formatter_class=argparse.RawDescriptionHelpFormatter)
170
170
  parser.add_argument("--version", action="version", version=f"txaci {__version__}")
171
171
  parser.add_argument("--state", default=str(Context.default_state_dir()), help="pipeline state directory")