app · a935e7c

Dev index Recent changes / versions Changelog About TODO Python API

0.13.3:capabilities 能力清單與技能探測

a935e7c · 2026-11-27 11:41 · app
CHANGELOG.mdDocs/usage.mdpyproject.tomlsrc/changelogkit/__init__.pysrc/changelogkit/capabilities.pysrc/changelogkit/cli.pysrc/changelogkit/lang/en.jsonsrc/changelogkit/lang/ja.jsonsrc/changelogkit/lang/zh-CN.jsonsrc/changelogkit/lang/zh-TW.jsontests/test_changelogkit.py
commit a935e7c5dff8486f43e73841e28cca8bcb040d8eAuthor: Nuclear0709 <agp05432@gmail.com>Date:   Fri Nov 27 11:41:36 2026 +0800     0.13.3:capabilities 能力清單與技能探測 diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e842194..e2a99ab 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,20 @@ # Changelog +## 2026.11.27 11:40 changelogkit 0.13.3 發佈++**類型**: 功能 · **檔案**: `capabilities.py`、`cli.py`、`Docs/usage.md`、skills++### 問題 - 功能持續增加,技能無法可靠知道目前安裝版本具備哪些能力++### 修改 - `capabilities --json` 能力清單與技能探測步驟++- 新增 `changelogkit capabilities [--json]`:列出已知功能、命令與設定鍵。+- `features` 含 `since` 的項目可判斷最低版本;清單明確標示不是完整規格。+- setup 技能改為先執行 `capabilities --json`;缺少功能時改查 `--help`/Docs/原始碼,不假設支援。+- 舊版沒有 `capabilities` 時,技能會退回 `--help`/Docs 並提示升級。++---+ ## 2026.11.27 11:27 changelogkit 0.13.2 發佈  **類型**: 功能 · **檔案**: `assets/theme.js`、`export.py`、`Docs/pages.md`、`Docs/usage.md`diff --git a/Docs/usage.md b/Docs/usage.mdindex 921540d..d1aba53 100644--- a/Docs/usage.md+++ b/Docs/usage.md@@ -16,6 +16,7 @@ changelogkit sort [--apply]                    # 依標題日期/時間排序 changelogkit community-init                    # 產生「社群與開發交流」範本(Docs/community.md) changelogkit docs [--check] [--summary]        # 檢查文件分類(錯誤回 1) changelogkit docs-init                         # 印出可貼上的 docs TOML 範本+changelogkit capabilities [--json]              # 列出此安裝版本的已知功能 ```  `add` 的標題是唯一的位置參數;內文用 `--problem`/`--cause`/`--change` 提供。各節第一行是摘要(會接在 `### 問題 - …` 等標題後),其餘行是細節;`--change` 可重複,第一筆當摘要、其餘轉成條列;`--change-detail` 在修改摘要下補一段多行說明。Web 表單分「修改摘要」(單行)、「修改細節」(段落)、「其他修改」(每行一項)。只給標題時插入空骨架。@@ -30,7 +31,9 @@ changelogkit docs-init                         # 印出可貼上的 docs TOML   > 新增/修改字串時,`tests/test_changelogkit.py` 的 `I18nKeyTests` 會檢查:程式/HTML/JS 用到的 key 是否都已定義,以及各語系是否缺 key(語系漂移)——CI 會擋下少翻。 -查詢類子命令:`languages`(列出**程式語言**:API 宣告掃描涵蓋範圍)與 `locales`(列出 **UI 語系**,`*` 標示目前生效者)。+查詢類子命令:`languages`(列出**程式語言**:API 宣告掃描涵蓋範圍)、`locales`(列出 **UI 語系**,`*` 標示目前生效者)與 `capabilities`(列出此安裝版本的已知功能)。++`capabilities --json` 是給技能/腳本使用的機器可讀清單;它只描述穩定的功能邊界,不取代 `--help` 與本文件。清單未列出的功能不代表不存在,應以實際版本的 `--help`/原始碼為準。  ## 本機開發(用工作區原始碼) diff --git a/pyproject.toml b/pyproject.tomlindex 3892359..3df9949 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"  [project] name = "changelogkit"-version = "0.13.2"+version = "0.13.3" description = "本機變更歷史 GUI 與開發索引:解析 ChangeHistory.md、唯讀索引 Git/文件/API 宣告" readme = "README.md" requires-python = ">=3.10"diff --git a/src/changelogkit/__init__.py b/src/changelogkit/__init__.pyindex 0f4aaf2..ed2ef84 100644--- a/src/changelogkit/__init__.py+++ b/src/changelogkit/__init__.py@@ -53,4 +53,4 @@ def _installed_version():  # 版號來源優先序:原始碼 checkout 的 pyproject → 已安裝中介資料 → 字面值備援。 # 優先原始碼,讓 `PYTHONPATH=src` 直接跑時「所見即所跑」,不被環境中殘留的舊安裝誤導。-__version__ = _pyproject_version() or _installed_version() or "0.13.2"+__version__ = _pyproject_version() or _installed_version() or "0.13.3"diff --git a/src/changelogkit/capabilities.py b/src/changelogkit/capabilities.pynew file mode 100644index 0000000..280e76f--- /dev/null+++ b/src/changelogkit/capabilities.py@@ -0,0 +1,184 @@+"""已知功能的機器可讀清單(``changelogkit capabilities``)。++這份清單刻意只描述**穩定的功能邊界**,不重抄所有旗標與欄位;旗標仍以+``--help`` 與 ``Docs/usage.md`` 為準。技能可先讀本清單,再依版本決定是否+具備某項能力;清單未列出的功能不代表不存在,必須回頭查目前版本。+"""++import json++from . import buildinfo++SCHEMA = 1++# 建立清單時的人工維護區:新增功能時同步補上,避免技能只能猜。+FEATURES = [+    {+        "id": "history.core",+        "summary": "Parse, insert, edit, delete and sort ChangeHistory-style Markdown entries.",+        "surfaces": ["cli", "web"],+        "config": ["history"],+    },+    {+        "id": "history.cli",+        "summary": "CLI add/list/show/sort/backfill-dates for change history.",+        "surfaces": ["cli"],+        "commands": ["add", "list", "show", "sort", "backfill-dates"],+    },+    {+        "id": "dev.index",+        "summary": "Development index: features, source symbols, documents and recent commits.",+        "surfaces": ["web", "static"],+        "config": ["features", "sources", "include", "exclude", "recent_commits"],+    },+    {+        "id": "symbols.scan",+        "summary": "Source-level API declaration scanning for supported languages.",+        "surfaces": ["cli", "web", "static"],+        "commands": ["symbols", "languages"],+    },+    {+        "id": "docs.classification",+        "summary": "Document groups, notes, colors, folder fallback and group filters.",+        "surfaces": ["cli", "web", "static"],+        "config": ["docs.unlisted", "docs.auto", "docs.groups", "docs.entries"],+        "commands": ["docs", "docs-init"],+    },+    {+        "id": "docs.localized",+        "summary": "Localized group and entry titles/notes.",+        "surfaces": ["web", "static"],+        "config": ["docs.groups", "docs.entries"],+    },+    {+        "id": "todo",+        "summary": "TODO.md task parsing, filtering, progress and live refresh.",+        "surfaces": ["web", "static"],+        "config": ["todo"],+    },+    {+        "id": "static.export",+        "summary": "Read-only static site export with stable document URLs and per-commit pages.",+        "surfaces": ["cli", "static"],+        "commands": ["export"],+    },+    {+        "id": "static.search",+        "summary": "Client-side document search on the static development index.",+        "surfaces": ["static"],+    },+    {+        "id": "api.docs",+        "since": "0.12.11",+        "summary": "Mount one or more local HTML or external API documentation sites.",+        "surfaces": ["web", "static"],+        "config": ["api"],+    },+    {+        "id": "serve.lan",+        "since": "0.13.0",+        "summary": "Optional LAN binding with read-only default for non-loopback clients.",+        "surfaces": ["cli", "web"],+        "commands": ["serve"],+    },+    {+        "id": "static.footer-timezone",+        "since": "0.13.1",+        "summary": "Static footer time with UTC offset and configurable timezone/epoch.",+        "surfaces": ["static"],+        "config": ["timezone"],+    },+    {+        "id": "static.footer-local",+        "since": "0.13.2",+        "summary": "Browser-localized static footer time with a no-JS fallback.",+        "surfaces": ["static"],+    },+    {+        "id": "i18n",+        "summary": "UI and CLI localization (en, zh-TW, zh-CN, ja).",+        "surfaces": ["cli", "web", "static"],+    },+    {+        "id": "capabilities",+        "since": "0.13.3",+        "summary": "Machine-readable known-feature and command index.",+        "surfaces": ["cli"],+        "commands": ["capabilities"],+    },+]++COMMANDS = [+    "serve",+    "add",+    "list",+    "show",+    "languages",+    "locales",+    "docs",+    "docs-init",+    "symbols",+    "export",+    "backfill-dates",+    "sort",+    "community-init",+    "capabilities",+]++CONFIG_KEYS = [+    "title",+    "project",+    "timezone",+    "history",+    "todo",+    "features",+    "community",+    "assets",+    "recent_commits",+    "sources",+    "include",+    "exclude",+    "docs",+    "api",+]++NOTES = [+    "This is a known-feature index, not an exhaustive command/config reference.",+    "If a requested feature is absent, inspect --help, Docs/usage.md and the installed source before assuming support.",+]+++def snapshot():+    """回傳目前安裝版本的能力清單(可直接序列化為 JSON)。"""+    return {+        "schema": SCHEMA,+        "tool": "changelogkit",+        "version": buildinfo.version(),+        "commit": buildinfo.commit(),+        "scope": "known features; not exhaustive",+        "features": [dict(feature) for feature in FEATURES],+        "commands": list(COMMANDS),+        "config": list(CONFIG_KEYS),+        "notes": list(NOTES),+    }+++def dumps():+    """輸出穩定的 JSON;技能與腳本應使用這個格式。"""+    return json.dumps(snapshot(), ensure_ascii=False, indent=2)+++def render():+    """人類可讀摘要;``--json`` 才是給程式解析的介面。"""+    data = snapshot()+    lines = [+        "changelogkit %s (%s)" % (data["version"], data["commit"] or "unknown"),+        "capabilities schema %d · %s" % (data["schema"], data["scope"]),+        "",+        "Features:",+    ]+    for feature in data["features"]:+        since = " (since %s)" % feature["since"] if feature.get("since") else ""+        lines.append("  %-24s %s%s" % (feature["id"], feature["summary"], since))+    lines += ["", "Commands: " + ", ".join(data["commands"])]+    return "\n".join(lines)diff --git a/src/changelogkit/cli.py b/src/changelogkit/cli.pyindex 504c1f7..bd1eefd 100644--- a/src/changelogkit/cli.py+++ b/src/changelogkit/cli.py@@ -7,7 +7,17 @@ import argparse import sys -from . import backfill, buildinfo, community, config, export as static_export, history, i18n, server+from . import (+    backfill,+    buildinfo,+    capabilities,+    community,+    config,+    export as static_export,+    history,+    i18n,+    server,+)   def _prescan_locale(argv):@@ -20,6 +30,11 @@ def _prescan_locale(argv):     return None  +def cmd_capabilities(args):+    """印出目前版本的能力清單;``--json`` 供技能與腳本解析。"""+    print(capabilities.dumps() if args.json else capabilities.render())++ def cmd_add(args):     """插入新紀錄;日期/時間留空時帶入現在時刻。 @@ -271,6 +286,8 @@ def main(argv=None):      sub.add_parser("languages", help=i18n.t("cli.languages.help"))     sub.add_parser("locales", help=i18n.t("cli.locales.help"))+    cap = sub.add_parser("capabilities", help=i18n.t("cli.capabilities.help"))+    cap.add_argument("--json", action="store_true", help=i18n.t("cli.capabilities.json"))      dc = sub.add_parser("docs", help=i18n.t("cli.docs.help"))     dc.add_argument("--check", action="store_true", help=i18n.t("cli.docs.check"))@@ -317,6 +334,8 @@ def main(argv=None):         cmd_languages(args)     elif args.cmd == "locales":         cmd_locales(args)+    elif args.cmd == "capabilities":+        cmd_capabilities(args)     elif args.cmd == "docs":         raise SystemExit(cmd_docs(args))     elif args.cmd == "docs-init":diff --git a/src/changelogkit/lang/en.json b/src/changelogkit/lang/en.jsonindex 7a3df08..565823d 100644--- a/src/changelogkit/lang/en.json+++ b/src/changelogkit/lang/en.json@@ -28,6 +28,8 @@   "cli.show.query": "Index or keyword",   "cli.languages.help": "List supported programming languages",   "cli.locales.help": "List supported UI languages",+  "cli.capabilities.help": "List known features supported by this installation",+  "cli.capabilities.json": "Machine-readable JSON (for skills and scripts)",   "cli.docs.help": "Check document grouping or print a starter config",   "cli.docs.check": "Validate and list resolved groups (default)",   "cli.docs.summary": "Only show group counts",diff --git a/src/changelogkit/lang/ja.json b/src/changelogkit/lang/ja.jsonindex 484a31b..be1184e 100644--- a/src/changelogkit/lang/ja.json+++ b/src/changelogkit/lang/ja.json@@ -28,6 +28,8 @@   "cli.show.query": "番号またはキーワード",   "cli.languages.help": "対応プログラミング言語を一覧",   "cli.locales.help": "対応 UI 言語を一覧",+  "cli.capabilities.help": "このインストールで利用できる既知の機能を一覧",+  "cli.capabilities.json": "機械可読 JSON(スキル/スクリプト用)",   "cli.docs.help": "ドキュメント分類を検査、または開始設定を出力",   "cli.docs.check": "解決後のグループを検証・一覧(既定)",   "cli.docs.summary": "グループ数だけ表示",diff --git a/src/changelogkit/lang/zh-CN.json b/src/changelogkit/lang/zh-CN.jsonindex d2ed1bf..413ab73 100644--- a/src/changelogkit/lang/zh-CN.json+++ b/src/changelogkit/lang/zh-CN.json@@ -28,6 +28,8 @@   "cli.show.query": "编号或关键词",   "cli.languages.help": "列出支持的编程语言",   "cli.locales.help": "列出支持的 UI 语言",+  "cli.capabilities.help": "列出此安装版本支持的已知功能",+  "cli.capabilities.json": "机器可读 JSON(供技能与脚本使用)",   "cli.docs.help": "检查文档分类,或打印起始设置",   "cli.docs.check": "验证并列出解析后的群组(默认)",   "cli.docs.summary": "只显示群组数量",diff --git a/src/changelogkit/lang/zh-TW.json b/src/changelogkit/lang/zh-TW.jsonindex 579d1f4..6f3090d 100644--- a/src/changelogkit/lang/zh-TW.json+++ b/src/changelogkit/lang/zh-TW.json@@ -28,6 +28,8 @@   "cli.show.query": "編號或關鍵字",   "cli.languages.help": "列出支援的程式語言",   "cli.locales.help": "列出支援的 UI 語系",+  "cli.capabilities.help": "列出此安裝版本支援的已知功能",+  "cli.capabilities.json": "機器可讀 JSON(供技能與腳本使用)",   "cli.docs.help": "檢查文件分類,或印出起始設定",   "cli.docs.check": "驗證並列出解析後的群組(預設)",   "cli.docs.summary": "只顯示群組數量",diff --git a/tests/test_changelogkit.py b/tests/test_changelogkit.pyindex 6da4c84..eda611a 100644--- a/tests/test_changelogkit.py+++ b/tests/test_changelogkit.py@@ -28,6 +28,7 @@ from changelogkit import (  # noqa: E402     apidocs,     assets,     backfill,+    capabilities,     cli,     community,     config,@@ -104,6 +105,25 @@ class TempRepo:         self._tmp.cleanup()  +class CapabilitiesTests(unittest.TestCase):+    def test_snapshot_lists_recent_features(self):+        data = capabilities.snapshot()+        ids = {feature["id"] for feature in data["features"]}+        for expected in ("history.core", "api.docs", "serve.lan", "static.footer-local", "capabilities"):+            self.assertIn(expected, ids)+        self.assertEqual(data["tool"], "changelogkit")+        self.assertEqual(data["schema"], 1)+        self.assertIn("capabilities", data["commands"])++    def test_cli_capabilities_json(self):+        output = io.StringIO()+        with redirect_stdout(output):+            cli.main(["capabilities", "--json"])+        data = json.loads(output.getvalue())+        self.assertEqual(data["version"], capabilities.snapshot()["version"])+        self.assertTrue(any(feature["id"] == "static.export" for feature in data["features"]))++ class ServerTests(unittest.TestCase):     def test_writable_defaults_to_loopback_only(self):         self.assertTrue(server.writable_for("127.0.0.1"))