ChatCRS 0.2.2__tar.gz → 0.2.4__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 (53) hide show
  1. chatcrs-0.2.4/.github/workflows/ci.yml +26 -0
  2. chatcrs-0.2.4/.github/workflows/deploy-docs.yml +31 -0
  3. chatcrs-0.2.4/.github/workflows/preview-docs.yml +64 -0
  4. chatcrs-0.2.4/.github/workflows/publish.yml +97 -0
  5. {chatcrs-0.2.2 → chatcrs-0.2.4}/CHANGELOG.md +28 -3
  6. {chatcrs-0.2.2 → chatcrs-0.2.4}/MANIFEST.in +2 -0
  7. chatcrs-0.2.4/PKG-INFO +154 -0
  8. chatcrs-0.2.4/README.en.md +125 -0
  9. chatcrs-0.2.4/README.md +125 -0
  10. chatcrs-0.2.4/docs/cli.en.md +137 -0
  11. chatcrs-0.2.4/docs/cli.md +137 -0
  12. chatcrs-0.2.4/docs/configuration.md +42 -0
  13. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/index.en.md +43 -34
  14. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/index.md +43 -34
  15. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/interfaces.en.md +17 -9
  16. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/interfaces.md +17 -9
  17. {chatcrs-0.2.2 → chatcrs-0.2.4}/mkdocs.yml +16 -8
  18. {chatcrs-0.2.2 → chatcrs-0.2.4}/pyproject.toml +1 -1
  19. chatcrs-0.2.4/src/ChatCRS.egg-info/PKG-INFO +154 -0
  20. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/ChatCRS.egg-info/SOURCES.txt +6 -0
  21. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/ChatCRS.egg-info/requires.txt +3 -3
  22. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/__init__.py +1 -1
  23. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/cli.py +206 -2
  24. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/remote.py +49 -6
  25. chatcrs-0.2.4/src/chatcrs/tokens.py +207 -0
  26. chatcrs-0.2.4/tests/test_cli.py +40 -0
  27. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_cli_docs_alignment.py +3 -0
  28. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_remote_management.py +99 -0
  29. chatcrs-0.2.4/tests/test_token_store.py +81 -0
  30. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_version.py +1 -1
  31. chatcrs-0.2.2/PKG-INFO +0 -134
  32. chatcrs-0.2.2/README.en.md +0 -105
  33. chatcrs-0.2.2/README.md +0 -105
  34. chatcrs-0.2.2/docs/cli.en.md +0 -120
  35. chatcrs-0.2.2/docs/cli.md +0 -120
  36. chatcrs-0.2.2/docs/configuration.md +0 -35
  37. chatcrs-0.2.2/src/ChatCRS.egg-info/PKG-INFO +0 -134
  38. chatcrs-0.2.2/tests/test_cli.py +0 -11
  39. {chatcrs-0.2.2 → chatcrs-0.2.4}/LICENSE +0 -0
  40. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/development.md +0 -0
  41. {chatcrs-0.2.2 → chatcrs-0.2.4}/docs/production-maintenance.md +0 -0
  42. {chatcrs-0.2.2 → chatcrs-0.2.4}/setup.cfg +0 -0
  43. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/ChatCRS.egg-info/dependency_links.txt +0 -0
  44. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/ChatCRS.egg-info/entry_points.txt +0 -0
  45. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/ChatCRS.egg-info/top_level.txt +0 -0
  46. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/config.py +0 -0
  47. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/local.py +0 -0
  48. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/redaction.py +0 -0
  49. {chatcrs-0.2.2 → chatcrs-0.2.4}/src/chatcrs/service.py +0 -0
  50. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_local_management.py +0 -0
  51. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_publish_workflow.py +0 -0
  52. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_readonly_management.py +0 -0
  53. {chatcrs-0.2.2 → chatcrs-0.2.4}/tests/test_service_lifecycle.py +0 -0
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+ pull_request:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Configure Git Credentials
16
+ run: |
17
+ git config user.name github-actions[bot]
18
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.10"
22
+ - run: python -m pip install --upgrade pip
23
+ - run: python -m pip install -e ".[dev,docs]"
24
+ - run: python -m pytest -q
25
+ - run: python -m mkdocs build --strict
26
+ - run: python -m build
@@ -0,0 +1,31 @@
1
+ name: Deploy Docs
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ deploy:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Configure Git Credentials
18
+ run: |
19
+ git config user.name github-actions[bot]
20
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.10"
24
+ - name: Install docs dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ python -m pip install -e ".[docs]"
28
+ - name: Build strict docs
29
+ run: python -m mkdocs build --strict
30
+ - name: Deploy stable docs
31
+ run: python -m mkdocs gh-deploy --force
@@ -0,0 +1,64 @@
1
+ name: Preview Docs
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ - master
8
+
9
+ permissions:
10
+ contents: write
11
+ pull-requests: write
12
+
13
+ jobs:
14
+ deploy:
15
+ runs-on: ubuntu-latest
16
+ if: ${{ !github.event.pull_request.head.repo.fork }}
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Configure Git Credentials
20
+ run: |
21
+ git config user.name github-actions[bot]
22
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.10"
26
+ - name: Install docs dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ python -m pip install -e ".[docs]"
30
+ - name: Build strict docs
31
+ run: python -m mkdocs build --strict
32
+ - name: Deploy preview docs
33
+ run: |
34
+ git fetch origin gh-pages || true
35
+ mike deploy dev -p --allow-empty
36
+ site_url=$(python - <<'PY'
37
+ from pathlib import Path
38
+ for line in Path("mkdocs.yml").read_text(encoding="utf-8").splitlines():
39
+ if line.startswith("site_url:"):
40
+ print(line.split(":", 1)[1].strip().rstrip("/"))
41
+ break
42
+ else:
43
+ raise SystemExit("mkdocs.yml is missing site_url")
44
+ PY
45
+ )
46
+ preview_url="${site_url}/dev/"
47
+ echo "CHATCRS_PREVIEW_URL=${preview_url}" >> "$GITHUB_ENV"
48
+ echo "Preview URL: ${preview_url}" >> "$GITHUB_STEP_SUMMARY"
49
+ - name: Comment PR with preview link
50
+ uses: actions/github-script@v7
51
+ with:
52
+ script: |
53
+ const marker = '<!-- chatcrs-docs-preview -->';
54
+ const previewLink = process.env.CHATCRS_PREVIEW_URL;
55
+ const body = `${marker}\nPreview Docs: ${previewLink}`;
56
+ const { owner, repo } = context.repo;
57
+ const issue_number = context.payload.pull_request.number;
58
+ const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 });
59
+ const existing = comments.data.find(comment => comment.body && comment.body.includes(marker));
60
+ if (existing) {
61
+ await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
62
+ } else {
63
+ await github.rest.issues.createComment({ owner, repo, issue_number, body });
64
+ }
@@ -0,0 +1,97 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ contents: read
17
+ id-token: write
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.10"
25
+ - name: Resolve package version
26
+ id: meta
27
+ run: |
28
+ python - <<'PY'
29
+ import ast
30
+ import os
31
+ from pathlib import Path
32
+
33
+ module = ast.parse(Path("src/chatcrs/__init__.py").read_text(encoding="utf-8"))
34
+ for stmt in module.body:
35
+ if not isinstance(stmt, ast.Assign):
36
+ continue
37
+ if any(isinstance(target, ast.Name) and target.id == "__version__" for target in stmt.targets):
38
+ version = ast.literal_eval(stmt.value)
39
+ break
40
+ else:
41
+ raise SystemExit("__version__ not found in src/chatcrs/__init__.py")
42
+
43
+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
44
+ print(f"version={version}", file=output)
45
+ print(f"tag=v{version}", file=output)
46
+ PY
47
+ - name: Check release ref matches package version
48
+ env:
49
+ RELEASE_TAG: ${{ steps.meta.outputs.tag }}
50
+ run: |
51
+ if [ "${GITHUB_REF_TYPE}" != "tag" ]; then
52
+ echo "Release workflow must run from tag ${RELEASE_TAG}; got ${GITHUB_REF_TYPE}:${GITHUB_REF_NAME}."
53
+ exit 1
54
+ fi
55
+ if [ "${GITHUB_REF_NAME}" != "${RELEASE_TAG}" ]; then
56
+ echo "Tag ${GITHUB_REF_NAME} does not match package version ${RELEASE_TAG}."
57
+ exit 1
58
+ fi
59
+ - name: Check PyPI version
60
+ id: pypi
61
+ env:
62
+ PACKAGE_NAME: "ChatCRS"
63
+ PACKAGE_VERSION: ${{ steps.meta.outputs.version }}
64
+ run: |
65
+ python - <<'PY'
66
+ import os
67
+ import urllib.error
68
+ import urllib.parse
69
+ import urllib.request
70
+
71
+ package = os.environ["PACKAGE_NAME"]
72
+ version = os.environ["PACKAGE_VERSION"]
73
+ url = f"https://pypi.org/pypi/{urllib.parse.quote(package)}/{urllib.parse.quote(version)}/json"
74
+ exists = "false"
75
+ try:
76
+ urllib.request.urlopen(url, timeout=10)
77
+ except urllib.error.HTTPError as exc:
78
+ if exc.code != 404:
79
+ raise
80
+ else:
81
+ exists = "true"
82
+
83
+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
84
+ print(f"exists={exists}", file=output)
85
+ PY
86
+ - name: Stop when version is already on PyPI
87
+ if: steps.pypi.outputs.exists == 'true'
88
+ run: echo "ChatCRS ${{ steps.meta.outputs.version }} is already on PyPI; skipping publish."
89
+ - name: Build distribution
90
+ if: steps.pypi.outputs.exists == 'false'
91
+ run: |
92
+ python -m pip install --upgrade pip build twine
93
+ python -m build
94
+ python -m twine check dist/*
95
+ - name: Publish to PyPI
96
+ if: steps.pypi.outputs.exists == 'false'
97
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -2,6 +2,32 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2026-08-11 - 0.2.4
6
+
7
+ ### Added
8
+
9
+ - Add a runtime CRS Admin session token store under `~/.chatarch/tokens/CRS/<profile>.json`, parallel to `envs/CRS/<profile>.env`.
10
+ - Add `chatcrs admin token status`, `chatcrs admin token refresh`, and `chatcrs admin token clear` commands with redacted JSON output and dry-run deletion by default.
11
+ - Add `chatcrs admin login --save-token` for explicitly saving a fresh login-derived Admin session token.
12
+
13
+ ### Changed
14
+
15
+ - Admin HTTP requests now prefer the runtime token file over legacy `CRS_ACCESS_TOKEN`, fall back to username/password login when needed, and retry once after a 401 by refreshing the token file.
16
+ - Document Env-vs-token state separation so stable CRS configuration stays in ChatEnv while short-lived Admin session tokens live in the token store.
17
+
18
+ ## 2026-08-10 - 0.2.3
19
+
20
+ ### Added
21
+
22
+ - Add runtime-generated `chatcrs --tree` support backed by the registered Click command tree.
23
+ - Cover `--help`, `--tree`, representative command groups, and template `hello` absence in CLI tests.
24
+
25
+ ### Changed
26
+
27
+ - Rework the MkDocs navigation into top-level documentation sections and make the homepage a card-based hub for management, configuration, operations, and development entry points.
28
+ - Sync README and bilingual CLI docs with the runtime `chatcrs --tree` output.
29
+ - Tighten ChatArch internal dependency windows for the 0.2.3 patch release.
30
+
5
31
  ## 2026-08-06 - 0.2.2
6
32
 
7
33
  ### Changed
@@ -9,9 +35,8 @@
9
35
  - Replace the host-bound remote service lifecycle wrapper with local-only
10
36
  `chatcrs service ...` commands that run on the CRS server itself and never use
11
37
  remote execution transport.
12
- - Keep one canonical CRS ChatEnv namespace under `~/.chatarch/envs/CRS/` with
13
- `CRS_API_BASE`, `CRS_API_KEY`, `CRS_USERNAME`, `CRS_PASSWORD`, and
14
- `CRS_ACCESS_TOKEN`.
38
+ - Keep one canonical CRS ChatEnv namespace for the HTTP base URL, caller API key,
39
+ admin identity, admin password, and admin bearer/session token categories.
15
40
  - Document `service` as a server-local lifecycle/install/update/status surface,
16
41
  while keeping verify/image/debug/Nginx/cutover task surfaces removed.
17
42
  - Add a CLI-to-HTTP/local interface map that ties every registered CLI leaf to its
@@ -1,4 +1,6 @@
1
+ include README.md
1
2
  include CHANGELOG.md
2
3
  include README.en.md
3
4
  include mkdocs.yml
4
5
  recursive-include docs *.md
6
+ recursive-include .github/workflows *.yml
chatcrs-0.2.4/PKG-INFO ADDED
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: ChatCRS
3
+ Version: 0.2.4
4
+ Summary: HTTP/API-first CRS management helpers for ChatArch.
5
+ Author-email: ChatArch <1073853456@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://arch.gh.wzhecnu.cn/ChatCRS/
8
+ Project-URL: Documentation, https://arch.gh.wzhecnu.cn/ChatCRS/
9
+ Project-URL: Repository, https://github.com/ChatArch/ChatCRS
10
+ Keywords: chatcrs,chatarch,cli
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: click<9.0,>=8.1
17
+ Requires-Dist: chatstyle<0.2.0,>=0.1.1
18
+ Requires-Dist: chatenv<0.3.0,>=0.2.3
19
+ Provides-Extra: dev
20
+ Requires-Dist: build; extra == "dev"
21
+ Requires-Dist: pytest; extra == "dev"
22
+ Requires-Dist: twine; extra == "dev"
23
+ Provides-Extra: docs
24
+ Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
25
+ Requires-Dist: mkdocs-material<10.0,>=9.5; extra == "docs"
26
+ Requires-Dist: mkdocs-static-i18n<2.0,>=1.2; extra == "docs"
27
+ Requires-Dist: mike<3.0,>=2.0; extra == "docs"
28
+ Dynamic: license-file
29
+
30
+ <div align="center">
31
+ <a href="https://pypi.python.org/pypi/ChatCRS">
32
+ <img src="https://img.shields.io/pypi/v/ChatCRS.svg" alt="PyPI version" />
33
+ </a>
34
+ <a href="https://github.com/ChatArch/ChatCRS/actions/workflows/ci.yml">
35
+ <img src="https://github.com/ChatArch/ChatCRS/actions/workflows/ci.yml/badge.svg" alt="Tests" />
36
+ </a>
37
+ </div>
38
+
39
+ <div align="center">
40
+
41
+ [English](README.en.md) | [简体中文](README.md)
42
+ </div>
43
+
44
+ # ChatCRS
45
+
46
+ ChatCRS 是 ChatArch 的 CRS 管理 CLI。外部管理面优先使用 CRS HTTP/Admin API;`service` 域是 server-local surface,只在 CRS 服务器本机 shell 里操作本机 CRS checkout / Node runtime / `crs` executable。
47
+
48
+ Images 验收、debug runtime、Nginx/edge、release/cutover 等花哨/任务型能力不作为当前包内命令暴露;这些属于代理站维护、专项验收或运维 runbook,后续需要时单独设计。
49
+
50
+ ## 安装与开发
51
+
52
+ ```bash
53
+ python -m pip install -e '.[dev,docs]'
54
+ chatcrs --help
55
+ chatcrs --version
56
+ python -m pytest -q
57
+ python -m mkdocs build --strict
58
+ python -m build
59
+ ```
60
+
61
+ 完整文档使用 MkDocs,本地预览:
62
+
63
+ ```bash
64
+ python -m mkdocs serve
65
+ ```
66
+
67
+ 线上文档:https://arch.gh.wzhecnu.cn/ChatCRS/
68
+
69
+ ## CLI 树
70
+
71
+ ```text
72
+ chatcrs # CRS HTTP/API helpers plus server-local service commands for ChatArch.
73
+ ├── --help # Show this help message.
74
+ ├── --version # Show the installed package version.
75
+ ├── --tree # Print the registered command tree.
76
+ ├── health [--base-url <BASE-URL>] [--json-output] # Verify the CRS /health endpoint.
77
+ ├── admin # Remote CRS administrator operations via HTTPS Admin API.
78
+ │ ├── login [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--json-output] # Verify CRS admin login without printing the session token.
79
+ │ ├── accounts # Inspect or refresh remote CRS account state via HTTP Admin API.
80
+ │ │ ├── usage [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--json-output] # List OpenAI/Codex account usage and scheduling metadata.
81
+ │ │ └── refresh-status <ACCOUNT-ID> [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Reset a CRS OpenAI account status after transient failures.
82
+ │ └── keys # Inspect remote CRS API keys with admin privileges.
83
+ │ ├── list [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--include-stats] [--time-range <TIME-RANGE>] [--json-output] # List CRS API key metadata, optionally including usage stats.
84
+ │ └── show <KEY-ID> [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--include-stats/--no-include-stats] [--time-range <TIME-RANGE>] [--json-output] # Show one CRS API key by id or name.
85
+ ├── key # CRS API-key-only operations that do not require admin login.
86
+ │ └── info [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--timeout <TIMEOUT>] [--path <INFO-PATH>] [--json-output] # Query CRS key-info using only a CRS API key.
87
+ └── service # Local CRS service lifecycle commands for the current server.
88
+ ├── install [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs install` on this server.
89
+ ├── update [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs update` on this server.
90
+ ├── start [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs start` on this server.
91
+ ├── stop [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs stop` on this server.
92
+ ├── restart [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs restart` on this server.
93
+ ├── status [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--json-output] # Execute local `crs status` on this server.
94
+ ├── switch-branch <BRANCH> [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs switch-branch <branch>` on this server.
95
+ └── update-pricing [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs update-pricing` on this server.
96
+ ```
97
+
98
+ 运行 `chatcrs --tree` 可从实际 Click 注册表回读同一棵命令树。
99
+
100
+
101
+ ## HTTP/Admin 与 API key
102
+
103
+ ```bash
104
+ chatcrs health --base-url https://crs.example.com --json-output
105
+ chatcrs admin login --profile admin --json-output
106
+ chatcrs admin accounts usage --profile admin --json-output
107
+ chatcrs admin accounts refresh-status <account_id> --profile admin --json-output
108
+ chatcrs admin accounts refresh-status <account_id> --profile admin --execute --json-output
109
+ chatcrs admin keys list --profile admin --include-stats --json-output
110
+ chatcrs admin keys show <key_id_or_name> --profile admin --json-output
111
+ chatcrs key info --profile admin --json-output
112
+ ```
113
+
114
+ ## Server-local service
115
+
116
+ 这些命令应安装在目标 CRS 服务器上,并在该服务器本机执行:
117
+
118
+ ```bash
119
+ chatcrs service status --app-dir /path/to/crs --json-output
120
+ chatcrs service update --app-dir /path/to/crs --json-output
121
+ chatcrs service update --app-dir /path/to/crs --execute --json-output
122
+ chatcrs service restart --app-dir /path/to/crs --execute --json-output
123
+ ```
124
+
125
+ `status` 默认执行本机只读 `crs status`。其它 service mutation 默认 dry-run,需要 `--execute` 才执行。
126
+
127
+ ## 配置
128
+
129
+ ChatCRS 使用一套 CRS ChatEnv profile;默认 profile 是 `admin`,也可以用 `--profile` 指定其它 profile。公开文档只描述字段类别,不写具体 secret 文件路径或 secret-bearing env key 名。
130
+
131
+ Canonical 字段类别:
132
+
133
+ ```text
134
+ HTTP base URL
135
+ caller API key
136
+ admin username
137
+ admin password
138
+ admin bearer/session token
139
+ ```
140
+
141
+ Service-local 目标不进入第二套 ChatEnv namespace;用当前工作目录或 `--app-dir` / `--crs-command` 指定本机 checkout 和 executable。
142
+
143
+ 敏感字段只应存在于 ChatEnv 或进程环境中,不进入命令行参数、文档、PR body 或日志输出。Profile 文件应使用 `0600` 权限。
144
+
145
+ ## 生产安全
146
+
147
+ 外部管理只能使用 HTTP/Admin API;没有 HTTP lifecycle 接口时,不用远端执行补洞。要么新增 CRS API/host-agent,要么在目标服务器本机运行 `chatcrs service ...`。
148
+
149
+ 更多内容见:
150
+
151
+ - `docs/cli.md`
152
+ - `docs/interfaces.md`
153
+ - `docs/configuration.md`
154
+ - `docs/production-maintenance.md`
@@ -0,0 +1,125 @@
1
+ <div align="center">
2
+ <a href="https://pypi.python.org/pypi/ChatCRS">
3
+ <img src="https://img.shields.io/pypi/v/ChatCRS.svg" alt="PyPI version" />
4
+ </a>
5
+ <a href="https://github.com/ChatArch/ChatCRS/actions/workflows/ci.yml">
6
+ <img src="https://github.com/ChatArch/ChatCRS/actions/workflows/ci.yml/badge.svg" alt="Tests" />
7
+ </a>
8
+ </div>
9
+
10
+ <div align="center">
11
+
12
+ [English](README.en.md) | [简体中文](README.md)
13
+ </div>
14
+
15
+ # ChatCRS
16
+
17
+ ChatCRS is ChatArch's CRS management CLI. Outside-server management is HTTP/Admin API-first. The `service` namespace is a server-local surface: it runs only inside the CRS server shell and operates on that server's CRS checkout / Node runtime / `crs` executable.
18
+
19
+ Image acceptance, debug runtimes, Nginx/edge work, release/cutover workflows, and similar task-specific surfaces are not package commands today. They belong to proxy-site maintenance, special acceptance, or operations runbooks and should be designed separately when scoped.
20
+
21
+ ## Install and develop
22
+
23
+ ```bash
24
+ python -m pip install -e '.[dev,docs]'
25
+ chatcrs --help
26
+ chatcrs --version
27
+ python -m pytest -q
28
+ python -m mkdocs build --strict
29
+ python -m build
30
+ ```
31
+
32
+ Serve the complete MkDocs site with:
33
+
34
+ ```bash
35
+ python -m mkdocs serve
36
+ ```
37
+
38
+ Documentation: https://arch.gh.wzhecnu.cn/ChatCRS/
39
+
40
+ ## CLI tree
41
+
42
+ ```text
43
+ chatcrs # CRS HTTP/API helpers plus server-local service commands for ChatArch.
44
+ ├── --help # Show this help message.
45
+ ├── --version # Show the installed package version.
46
+ ├── --tree # Print the registered command tree.
47
+ ├── health [--base-url <BASE-URL>] [--json-output] # Verify the CRS /health endpoint.
48
+ ├── admin # Remote CRS administrator operations via HTTPS Admin API.
49
+ │ ├── login [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--json-output] # Verify CRS admin login without printing the session token.
50
+ │ ├── accounts # Inspect or refresh remote CRS account state via HTTP Admin API.
51
+ │ │ ├── usage [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--json-output] # List OpenAI/Codex account usage and scheduling metadata.
52
+ │ │ └── refresh-status <ACCOUNT-ID> [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Reset a CRS OpenAI account status after transient failures.
53
+ │ └── keys # Inspect remote CRS API keys with admin privileges.
54
+ │ ├── list [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--include-stats] [--time-range <TIME-RANGE>] [--json-output] # List CRS API key metadata, optionally including usage stats.
55
+ │ └── show <KEY-ID> [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--username <USERNAME>] [--password <PASSWORD>] [--admin-token <ADMIN-TOKEN>] [--timeout <TIMEOUT>] [--include-stats/--no-include-stats] [--time-range <TIME-RANGE>] [--json-output] # Show one CRS API key by id or name.
56
+ ├── key # CRS API-key-only operations that do not require admin login.
57
+ │ └── info [--profile <PROFILE>] [--base-url <BASE-URL>] [--api-key <API-KEY>] [--timeout <TIMEOUT>] [--path <INFO-PATH>] [--json-output] # Query CRS key-info using only a CRS API key.
58
+ └── service # Local CRS service lifecycle commands for the current server.
59
+ ├── install [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs install` on this server.
60
+ ├── update [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs update` on this server.
61
+ ├── start [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs start` on this server.
62
+ ├── stop [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs stop` on this server.
63
+ ├── restart [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs restart` on this server.
64
+ ├── status [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--json-output] # Execute local `crs status` on this server.
65
+ ├── switch-branch <BRANCH> [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs switch-branch <branch>` on this server.
66
+ └── update-pricing [--app-dir <APP-DIR>] [--crs-command <CRS-COMMAND>] [--timeout <TIMEOUT>] [--execute] [--json-output] # Plan or execute local `crs update-pricing` on this server.
67
+ ```
68
+
69
+ Run `chatcrs --tree` to read back the same command tree from the live Click registry.
70
+
71
+
72
+ ## HTTP/Admin and API key
73
+
74
+ ```bash
75
+ chatcrs health --base-url https://crs.example.com --json-output
76
+ chatcrs admin login --profile admin --json-output
77
+ chatcrs admin accounts usage --profile admin --json-output
78
+ chatcrs admin accounts refresh-status <account_id> --profile admin --json-output
79
+ chatcrs admin accounts refresh-status <account_id> --profile admin --execute --json-output
80
+ chatcrs admin keys list --profile admin --include-stats --json-output
81
+ chatcrs admin keys show <key_id_or_name> --profile admin --json-output
82
+ chatcrs key info --profile admin --json-output
83
+ ```
84
+
85
+ ## Server-local service
86
+
87
+ These commands should be installed on and executed from the target CRS server itself:
88
+
89
+ ```bash
90
+ chatcrs service status --app-dir /path/to/crs --json-output
91
+ chatcrs service update --app-dir /path/to/crs --json-output
92
+ chatcrs service update --app-dir /path/to/crs --execute --json-output
93
+ chatcrs service restart --app-dir /path/to/crs --execute --json-output
94
+ ```
95
+
96
+ `status` runs local read-only `crs status` by default. Other service mutations are dry-run by default and require `--execute`.
97
+
98
+ ## Configuration
99
+
100
+ ChatCRS uses one CRS ChatEnv profile namespace. The default profile is `admin`; use `--profile` for another profile. Public docs describe field categories only and intentionally omit concrete secret-file paths or secret-bearing env key names.
101
+
102
+ Canonical field categories:
103
+
104
+ ```text
105
+ HTTP base URL
106
+ caller API key
107
+ admin username
108
+ admin password
109
+ admin bearer/session token
110
+ ```
111
+
112
+ Service-local targets do not create a second ChatEnv namespace; use the current working directory or `--app-dir` / `--crs-command` for the local checkout and executable.
113
+
114
+ Sensitive fields should live only in ChatEnv or the process environment, never in command arguments, documentation, PR bodies, or logs. Profile files should use `0600` permissions.
115
+
116
+ ## Production safety
117
+
118
+ Outside-server management must use HTTP/Admin API. If no HTTP lifecycle endpoint exists, do not fill the gap with remote execution. Add a CRS API/host-agent, or run `chatcrs service ...` on the target server itself.
119
+
120
+ See:
121
+
122
+ - `docs/cli.md`
123
+ - `docs/interfaces.md`
124
+ - `docs/configuration.md`
125
+ - `docs/production-maintenance.md`