dsh-coding-subscription-oauth 0.6.2 → 0.6.3

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 (121) hide show
  1. package/CHANGELOG.md +222 -206
  2. package/CONTRIBUTING.md +129 -120
  3. package/INSTALL.md +218 -218
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +289 -289
  7. package/README.es.md +290 -290
  8. package/README.fr.md +290 -290
  9. package/README.ja.md +290 -290
  10. package/README.ko.md +290 -290
  11. package/README.md +304 -304
  12. package/README.pt-BR.md +290 -290
  13. package/README.ru.md +290 -290
  14. package/README.zh-CN.md +302 -302
  15. package/compatibility/dsh-bom.json +0 -0
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +212 -195
  18. package/docs/02-architecture.md +130 -130
  19. package/docs/02-architecture.zh-CN.md +130 -130
  20. package/lib/bin.js.map +1 -1
  21. package/lib/capability-settings.d.ts +8 -2
  22. package/lib/capability-settings.d.ts.map +1 -1
  23. package/lib/capability-tools.d.ts +7 -2
  24. package/lib/capability-tools.d.ts.map +1 -1
  25. package/lib/client.js +3 -3
  26. package/lib/client.js.map +2 -2
  27. package/lib/codex-images.d.ts +8 -0
  28. package/lib/codex-images.d.ts.map +1 -1
  29. package/lib/index.js +32 -7
  30. package/lib/index.js.map +2 -2
  31. package/lib/invariant.js.map +1 -1
  32. package/media/en/settings_accounts.png +0 -0
  33. package/media/en/settings_capabilities.png +0 -0
  34. package/media/en/settings_gateway.png +0 -0
  35. package/media/settings_accounts.png +0 -0
  36. package/media/settings_capabilities.png +0 -0
  37. package/media/settings_gateway.png +0 -0
  38. package/media/settings_overview.png +0 -0
  39. package/media/zh-CN/settings_accounts.png +0 -0
  40. package/media/zh-CN/settings_capabilities.png +0 -0
  41. package/media/zh-CN/settings_gateway.png +0 -0
  42. package/package.json +148 -148
  43. package/patches/dsh-agy@0.1.2.patch +25 -25
  44. package/scripts/release.mjs +186 -186
  45. package/scripts/smoke-deployed-routes.mjs +146 -146
  46. package/scripts/verify-deployed-catalog.mjs +87 -87
  47. package/src/adapter.ts +273 -273
  48. package/src/alias-adapter.ts +130 -130
  49. package/src/auth-routes.ts +921 -921
  50. package/src/auth.ts +67 -67
  51. package/src/bin.ts +350 -350
  52. package/src/capability-routes.ts +279 -279
  53. package/src/capability-runtime.ts +314 -313
  54. package/src/capability-settings.ts +671 -658
  55. package/src/capability-tools.ts +685 -666
  56. package/src/catalog.ts +271 -271
  57. package/src/client/GrokBuildSettings.tsx +771 -770
  58. package/src/client/api.ts +88 -88
  59. package/src/client/components/AboutTab.tsx +30 -30
  60. package/src/client/components/AccountsTab.tsx +241 -241
  61. package/src/client/components/Badge.tsx +33 -33
  62. package/src/client/components/CapabilitiesTab.tsx +265 -265
  63. package/src/client/components/CliPullPreview.tsx +116 -116
  64. package/src/client/components/CopyButton.tsx +57 -57
  65. package/src/client/components/GatewayTab.tsx +469 -469
  66. package/src/client/components/NoticeBanner.tsx +46 -46
  67. package/src/client/components/ProgressBar.tsx +53 -53
  68. package/src/client/components/ProviderCard.tsx +606 -606
  69. package/src/client/components/SettingsTabs.tsx +75 -75
  70. package/src/client/components/ToggleSwitch.tsx +71 -71
  71. package/src/client/constants.ts +230 -224
  72. package/src/client/display.ts +61 -61
  73. package/src/client/dshClientAdapter.ts +127 -127
  74. package/src/client/gatewaySnippets.ts +37 -37
  75. package/src/client/index.tsx +156 -156
  76. package/src/client/locales.ts +540 -535
  77. package/src/client/microStyles.ts +52 -52
  78. package/src/client/parsers.ts +398 -396
  79. package/src/client/styles.ts +325 -325
  80. package/src/client/types.ts +199 -197
  81. package/src/codex-http.ts +447 -447
  82. package/src/codex-images.ts +503 -485
  83. package/src/codex-model-capabilities.ts +320 -320
  84. package/src/codex-search.ts +245 -245
  85. package/src/codex-usage.ts +263 -263
  86. package/src/compatibility.ts +41 -41
  87. package/src/dsh-host-adapter.ts +173 -173
  88. package/src/gateway-anthropic-messages.ts +84 -84
  89. package/src/gateway-auth.ts +102 -102
  90. package/src/gateway-backend.ts +274 -274
  91. package/src/gateway-body.ts +49 -49
  92. package/src/gateway-config.ts +76 -76
  93. package/src/gateway-http.ts +104 -104
  94. package/src/gateway-openai-chat.ts +124 -124
  95. package/src/gateway-openai-responses.ts +53 -53
  96. package/src/gateway-parse.ts +224 -224
  97. package/src/gateway-protocol.ts +52 -52
  98. package/src/gateway-routes.ts +158 -158
  99. package/src/gateway.ts +258 -258
  100. package/src/grok-errors.ts +24 -24
  101. package/src/grok-imagine.ts +1627 -1627
  102. package/src/grok-import.ts +151 -151
  103. package/src/http-json.ts +82 -82
  104. package/src/ids.ts +59 -59
  105. package/src/imagine-routes.ts +463 -463
  106. package/src/index.ts +709 -709
  107. package/src/invariant.ts +17 -17
  108. package/src/kimi-errors.ts +26 -26
  109. package/src/media-store.ts +927 -927
  110. package/src/oauth-import-routes.ts +324 -324
  111. package/src/oauth-providers.ts +152 -152
  112. package/src/oauth-session.ts +183 -183
  113. package/src/oauth-sources.ts +1104 -1104
  114. package/src/oauth.ts +620 -620
  115. package/src/provider.ts +128 -128
  116. package/src/proxy.ts +11 -11
  117. package/src/redact.ts +72 -72
  118. package/src/session.ts +218 -218
  119. package/src/store.ts +217 -217
  120. package/src/web-origin.ts +296 -296
  121. package/src/web-routes.ts +38 -38
package/cordis.patch.yml CHANGED
@@ -1,13 +1,13 @@
1
- # Optional coding-subscription routes over the base composition. Grok Build
2
- # remains the bundle fallback for backward compatibility; a saved
3
- # agent-default-model setting still wins over this value.
4
-
5
- - id: agent-default-model
6
- config:
7
- provider: grok-build
8
- model: grok-4.6
9
-
10
- - insert:
11
- # `id` is the stable Cordis plugin identifier; `name` is the bundle/package display name.
12
- - id: llm-grok-build-oauth
13
- name: dsh-coding-subscription-oauth
1
+ # Optional coding-subscription routes over the base composition. Grok Build
2
+ # remains the bundle fallback for backward compatibility; a saved
3
+ # agent-default-model setting still wins over this value.
4
+
5
+ - id: agent-default-model
6
+ config:
7
+ provider: grok-build
8
+ model: grok-4.6
9
+
10
+ - insert:
11
+ # `id` is the stable Cordis plugin identifier; `name` is the bundle/package display name.
12
+ - id: llm-grok-build-oauth
13
+ name: dsh-coding-subscription-oauth
@@ -1,195 +1,212 @@
1
- # 00 · Project Rules: Versions, Releases & Maintenance
2
-
3
- > Applies to the `dsh-coding-subscription-oauth` open-source plugin repository (formerly `dsh-grok-build`).
4
- > This file is the single source of truth for the repo's conventions and governs `README` and the release flow.
5
- > Principle: **publish like any general open source project, and never leak development privacy.** Anything facing external users must be public, generic and durable; anything internal (accounts, hosts, tokens, paths, credentials) stays local and must never reach git or the npm artifact.
6
-
7
- ---
8
-
9
- ## 0. Open-Source Principles
10
-
11
- ### 0.1 Why we open source
12
-
13
- This project is published open source so that others can use, study, fork and improve the coding-subscription OAuth integration for DeepSeek Harness — the same way its upstream (`dsh-xai`) was shared with us. Openness is a goal, not an accident of hosting.
14
-
15
- ### 0.2 License & attribution
16
-
17
- - The project is **Apache-2.0**. Every contribution is licensed under the same terms (see `LICENSE`).
18
- - Derived work is credited in `NOTICE`, as required by Apache-2.0; derived code is never relicensed.
19
- - Third-party review favours pinned, auditable versions (e.g. `dsh-agy@0.1.2`) so that what we link against is known and reproducible.
20
-
21
- ### 0.3 The hard boundary: no development-privacy leak
22
-
23
- Open source does **not** mean publishing everything. The following must never reach git, the npm artifact, or any public channel:
24
-
25
- - real credentials, tokens, passwords, API keys, private keys, `authorized_keys`;
26
- - personal accounts / account-pool details, host aliases, exact machine paths, internal IPs;
27
- - fault-investigation notes that describe a private machine or a specific personal incident (keep these in `docs/local/`).
28
-
29
- When in doubt, **do not publish** — put the note in the local-only layer instead.
30
-
31
- ### 0.4 "Publishable documentation will be published"
32
-
33
- Adopting the community norm, any document judged to be genuinely useful to contributors and free of development-privacy content **is expected to be published** (tracked in git, shipped via `files`, reachable from `README`), not merely written and left local. This includes: architecture, install/usage, contributor/release rules, changelog, and the compliance note. Documents that fail the §0.3 boundary check stay local-only. The publish/local split in §1 exists to make that call explicit and auditable.
34
-
35
- ### 0.5 Community commitments
36
-
37
- - Welcome and respond to issues and PRs (see `CONTRIBUTING.md`).
38
- - Keep a real changelog and a predictable release cadence (§5).
39
- - Publish release notes and version tags so history is traceable.
40
- - Keep git history atomic and conventional (§7); never commit secrets or mix unrelated concerns.
41
- - Do not invent capabilities, pad releases, or impersonate vendors/clients (§5, `README` compliance note).
42
-
43
- ---
44
-
45
- ## 1. Document Layers: Publish vs Local-only
46
-
47
- Every document in the repo belongs to one of two layers, and the two never mix:
48
-
49
- | Layer | Location | In git / npm? | Examples | Requirements |
50
- |---|---|---|---|---|
51
- | **Publishable (public)** | Repo root: `README.md` + `README.zh-CN.md` + other community-language READMEs, `CONTRIBUTING.md`, `INSTALL.md`, `CHANGELOG.md`, `LICENSE`, `NOTICE`, and explicitly promoted generic `docs/` files (this rules doc, `docs/02-architecture.md` + `docs/02-architecture.zh-CN.md`) | ✅ git, shipped via `files` | architecture, install/usage, route table, compliance notes, contribution & release rules | privacy-free: no host aliases, accounts, credentials, absolute paths; external-facing tone |
52
- | **Local-only (personal)** | `docs/local/` — investigation, risk and fault-analysis notes (e.g. `docs/local/01-research.md`, `docs/local/05-INVALID_REPLAY_STATE-调查.md`); `reference/` (vendored third-party source) | ❌ in `.gitignore`, never in `files` | concrete fault debugging, internal details, account-risk analysis | reference only; ignored by git by default |
53
-
54
- **Hard constraints**
55
-
56
- - `package.json` `files` whitelist contains **only** publishable docs; `docs/` must **not** be added wholesale — any doc shipped with the package is listed explicitly.
57
- - `.gitignore` keeps `docs/local/`, `docs/` and `reference/` ignored. To promote a doc into version control, explicitly `git add -f` after moving it to the root or adopting the naming convention in §2.
58
- - Before adding any doc, ask: *does an unrelated contributor need to see this?* Anything involving personal accounts, hosts, tokens, paths, regional-risk details or internal debugging goes to the local-only layer.
59
-
60
- ---
61
-
62
- ## 2. Document Naming & "Document Version"
63
-
64
- - Docs use `NN-<topic>.md`, numbered from `00` (`00-project-rules` is the fixed rule file — it is not re-versioned on every release).
65
- - **A "new document version" exists when any of the following happens**:
66
- - substantive content added/removed/changed (not just wording);
67
- - a doc is split, merged, or added;
68
- - `README.md` / `INSTALL.md` must be updated to stay consistent.
69
- - A document's version **is the npm package version** (see §3); there is no separate doc versioning scheme.
70
-
71
- ### Language policy
72
-
73
- - **`README.md` is English-first.** It also ships community translations selected for the widest open-source reach: `README.zh-CN.md` (简体中文), `README.ja.md` (日本語), `README.ko.md` (한국어), `README.pt-BR.md` (Português do Brasil), `README.es.md` (Español), `README.fr.md` (Français), `README.de.md` (Deutsch) and `README.ru.md` (Русский). All 9 files carry an identical language-switch line at the top so readers can jump between them, and every translation must be kept in sync with `README.md` (same sections, same version references).
74
- - Any user-facing change to `README.md` implies updating **all** translations. If that is not feasible for a very-large change, translators can open follow-up PRs, but the language switch line must never be broken.
75
- - Publishable docs under `docs/` are written English-first as well, to match the general-OSS publishing style. `docs/local/` may stay in whatever language the author prefers, since it is never published.
76
-
77
- ---
78
-
79
- ## 3. Versioning & The Release Loop
80
-
81
- [Semantic Versioning (SemVer)](https://semver.org/): `MAJOR.MINOR.PATCH`.
82
-
83
- | Change | Version action |
84
- |---|---|
85
- | New public capability / route / provider | minor (in the `0.x` phase this bumps the second digit) |
86
- | Bug fix, docs wording, process patch | patch |
87
- | Breaking change to imports/config in an existing capability | major (pre-1.0, handled on a case-by-case basis) |
88
-
89
- **The release loop (every document version → README → release) is a mandatory pipeline:**
90
-
91
- ```text
92
- new document version formed
93
-
94
-
95
- CHANGELOG.md updated (entry added under the matching release)
96
-
97
-
98
- README.md synced (new capability / new doc entry / new command / new notes)
99
-
100
-
101
- pnpm run check passes in the Docker sandbox
102
-
103
-
104
- version bumped (package.json + built artifact metadata, see §4)
105
-
106
-
107
- git commit + annotated tag v<version> (clean tree only)
108
-
109
-
110
- publish only after the verified local pack and explicit maintainer approval
111
-
112
-
113
- confirm GitHub release / milestone stays active
114
- ```
115
-
116
- **Every time a document version is formed, the full loop above must run.** Never change docs without syncing README, and never update README without releasing.
117
-
118
- **Commit, tag and tree hygiene** (detail in §7): each commit is conventional and atomic; generated `lib/` is committed with the source/build change that produced it; the release commit is made only on a clean tree; the annotated tag is `v<version>` and must match `package.json` and the top `CHANGELOG.md` heading.
119
-
120
- ---
121
-
122
- ## 4. Automated Release Script
123
-
124
- The repo provides `scripts/release.mjs` (see its header comment):
125
-
126
- - `--dry-run` validates the current `CHANGELOG.md`/`package.json` version, verifies the already-built release artifacts, previews the real packed file list with lifecycle scripts disabled, and rejects local-only files.
127
- - `--pack` rebuilds and verifies the release, then writes a local tarball under `output/`.
128
- - The helper never bumps versions, commits, tags, pushes, or publishes. Those remain explicit maintainer operations after human approval.
129
-
130
- Example:
131
-
132
- ```bash
133
- # validate + preview only; no tarball, Git, or registry changes
134
- node scripts/release.mjs --dry-run
135
-
136
- # rebuild + verify + create a local candidate tarball
137
- node scripts/release.mjs --pack
138
- ```
139
-
140
- > Publishing and remote Git writes are intentionally outside the script.
141
-
142
- ---
143
-
144
- ## 5. Keeping the Project Active
145
-
146
- "Active" is not about publishing many versions it is a stable, predictable, handover-friendly rhythm:
147
-
148
- - **Predictable release cadence**: run the release loop after every substantive feature PR; aim for at least one meaningful minor release per quarter to keep discoverability up.
149
- - **Honest changelog**: accumulate pending entries under `Unreleased` and fold them into a version on release; never pad releases with empty entries.
150
- - **Responsive PRs/issues**: keep the templates and conventions in `CONTRIBUTING.md` so any contributor knows how to open a PR.
151
- - **CI & gates**: `pnpm run check` (lint + typecheck + test + build/verify) is a release precondition; CI also rebuilds committed `lib/` and rejects artifact drift.
152
- - **Security stance**: the compliance note in `README` (own accounts only; no bulk accounts, resale, impersonation) is a hard line; any new provider or endpoint must respect it.
153
- - **Docs/code in sync**: when adding or changing a capability, update `README.md` and `docs/02-architecture.md` (public layer) before releasing.
154
-
155
- ---
156
-
157
- ## 6. Pre-Release Self-Check (Privacy Line)
158
-
159
- Before every real release, verify:
160
-
161
- - [ ] `npm pack --dry-run --json --ignore-scripts` output contains **nothing** matching `*调查*`, `docs/local/`, `reference/`, account/host aliases, tokens, or absolute paths.
162
- - [ ] `README.md` / `INSTALL.md` reference only public, generic commands, domains and accounts.
163
- - [ ] The `files` whitelist does **not** include the whole `docs/` directory.
164
- - [ ] `CHANGELOG.md` has an entry matching the about-to-be-released version; pending notes have been folded from `Unreleased` into `## v<version>`.
165
- - [ ] `pnpm run check` passes.
166
- - [ ] `git status` is clean: no leftover source, docs, lockfile or `lib/` drift.
167
- - [ ] The annotated tag will be `v<version>` and matches `package.json` plus the top `CHANGELOG.md` heading. Never move or reuse a published tag.
168
-
169
- ---
170
-
171
- ## 7. Commits, Pushes & Tags
172
-
173
- Contributor-facing wording lives in `CONTRIBUTING.md`. This section is the source of truth for maintainers.
174
-
175
- ### 7.1 Atomic conventional commits
176
-
177
- - Messages follow [Conventional Commits](https://www.conventionalcommits.org/): `type(optional-scope): summary` in the imperative (`feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `build:`, `ci:`, `chore:`). Optional scopes such as `M1` / `M3` or a module name are fine.
178
- - **One coherent concern per commit.** Never mix documentation, build/toolchain and feature/fix changes unless they cannot be reviewed or built separately (a capability that is meaningless without its README/changelog note, or a source change that must ship with the `lib/` it generated).
179
- - Build the tracked Dockerfile's `check` and `verify` targets before the commit. Do not install dependencies, typecheck, lint, test, build, or pack this plugin directly on a shared developer host. The build context is filtered by `.dockerignore`; dependencies download in their own stage, while all project-code `RUN` steps use `--network=none`. Never use privileged mode, credential mounts, the Docker socket, or host-directory bind mounts. Host networking is prohibited except for the narrow, explicitly authorized preview fallback below. Commit that passing slice promptly — do not leave a finished, verified change sitting uncommitted next to later work, and do not commit a red tree.
180
- - **Host DSH boundary:** unless the maintainer explicitly requests it for the current operation, never install into, modify, stop, restart, or run validation against a DSH instance already installed on the shared host. Development checks and interactive Web previews use a dedicated Docker DSH instance with an isolated home/profile. A preview may publish an explicitly selected high host port on `0.0.0.0` for remote review, must not reuse the host DSH port or state directories, and must remain resource-limited and individually removable. Host networking is prohibited by default; it is allowed only after ordinary Docker port publishing has been proven unavailable and the maintainer explicitly authorizes that specific run. An authorized host-network preview must bind only pre-checked high ports, keep its DSH backend on a separate loopback high port, and never bind or probe the host DSH port.
181
- - Generated `lib/` is a committed release artifact (git installs and the CI `git diff --exit-code -- lib` drift gate). Rebuild it and include it in the **same** commit as the `src/` or build-script change that produced it. Do not land stale `lib/` against newer source, and do not land a `lib/`-only commit unless the only change is a verified rebuild with no source delta.
182
- - Secrets, credentials, tokens, private keys, `.env` files, host aliases, absolute machine paths, and local-only notes (`docs/local/`, `reference/`) never enter git (§0.3).
183
-
184
- ### 7.2 Pushes
185
-
186
- - Feature branches are pushed as **checkpoints** at each version or milestone (branch names such as `work/<topic>-v0.3` are fine), not only when the PR is finished.
187
- - Force-push is forbidden without **explicit approval**, including `--force-with-lease`, once a branch has been pushed. Default history is append-only. Never force-push `main` or a published release tag.
188
- - Do not push a dirty or failing tree "to save it"; commit the passing slice first.
189
-
190
- ### 7.3 Changelog, versions and tags
191
-
192
- - Day-to-day user-facing work accumulates under `CHANGELOG.md` `## Unreleased`.
193
- - A release folds `Unreleased` into `## v<version>`, bumps `package.json` (and any built artifact metadata) to that same version, and creates an **annotated** tag `v<version>` on a **clean** working tree. The top changelog heading, `package.json` version and tag name must be identical (the `v` prefix is tag/heading only).
194
- - `scripts/release.mjs` does **not** bump, commit, tag, push or publish; those stay explicit maintainer steps after `pnpm run check`, `--dry-run` and `--pack` succeed.
195
- - Never tag or publish from a dirty tree, and never move or reuse a published tag.
1
+ # 00 · Project Rules: Versions, Releases & Maintenance
2
+
3
+ > Applies to the `dsh-coding-subscription-oauth` open-source plugin repository (formerly `dsh-grok-build`).
4
+ > This file is the single source of truth for the repo's conventions and governs `README` and the release flow.
5
+ > Principle: **publish like any general open source project, and never leak development privacy.** Anything facing external users must be public, generic and durable; anything internal (accounts, hosts, tokens, paths, credentials) stays local and must never reach git or the npm artifact.
6
+
7
+ ---
8
+
9
+ ## 0. Open-Source Principles
10
+
11
+ ### 0.1 Why we open source
12
+
13
+ This project is published open source so that others can use, study, fork and improve the coding-subscription OAuth integration for DeepSeek Harness — the same way its upstream (`dsh-xai`) was shared with us. Openness is a goal, not an accident of hosting.
14
+
15
+ ### 0.2 License & attribution
16
+
17
+ - The project is **Apache-2.0**. Every contribution is licensed under the same terms (see `LICENSE`).
18
+ - Derived work is credited in `NOTICE`, as required by Apache-2.0; derived code is never relicensed.
19
+ - Third-party review favours pinned, auditable versions (e.g. `dsh-agy@0.1.2`) so that what we link against is known and reproducible.
20
+
21
+ ### 0.3 The hard boundary: no development-privacy leak
22
+
23
+ Open source does **not** mean publishing everything. The following must never reach git, the npm artifact, or any public channel:
24
+
25
+ - real credentials, tokens, passwords, API keys, private keys, `authorized_keys`;
26
+ - personal accounts / account-pool details, host aliases, exact machine paths, internal IPs;
27
+ - fault-investigation notes that describe a private machine or a specific personal incident (keep these in `docs/local/`).
28
+
29
+ When in doubt, **do not publish** — put the note in the local-only layer instead.
30
+
31
+ ### 0.4 "Publishable documentation will be published"
32
+
33
+ Adopting the community norm, any document judged to be genuinely useful to contributors and free of development-privacy content **is expected to be published** (tracked in git, shipped via `files`, reachable from `README`), not merely written and left local. This includes: architecture, install/usage, contributor/release rules, changelog, and the compliance note. Documents that fail the §0.3 boundary check stay local-only. The publish/local split in §1 exists to make that call explicit and auditable.
34
+
35
+ ### 0.5 Community commitments
36
+
37
+ - Welcome and respond to issues and PRs (see `CONTRIBUTING.md`).
38
+ - Keep a real changelog and a predictable release cadence (§5).
39
+ - Publish release notes and version tags so history is traceable.
40
+ - Keep git history atomic and conventional (§7); never commit secrets or mix unrelated concerns.
41
+ - Do not invent capabilities, pad releases, or impersonate vendors/clients (§5, `README` compliance note).
42
+
43
+ ---
44
+
45
+ ## 1. Document Layers: Publish vs Local-only
46
+
47
+ Every document in the repo belongs to one of two layers, and the two never mix:
48
+
49
+ | Layer | Location | In git / npm? | Examples | Requirements |
50
+ |---|---|---|---|---|
51
+ | **Publishable (public)** | Repo root: `README.md` + `README.zh-CN.md` + other community-language READMEs, `CONTRIBUTING.md`, `INSTALL.md`, `CHANGELOG.md`, `LICENSE`, `NOTICE`, and explicitly promoted generic `docs/` files (this rules doc, `docs/02-architecture.md` + `docs/02-architecture.zh-CN.md`) | ✅ git, shipped via `files` | architecture, install/usage, route table, compliance notes, contribution & release rules | privacy-free: no host aliases, accounts, credentials, absolute paths; external-facing tone |
52
+ | **Local-only (personal)** | `docs/local/` — investigation, risk and fault-analysis notes (e.g. `docs/local/01-research.md`, `docs/local/05-INVALID_REPLAY_STATE-调查.md`); `reference/` (vendored third-party source) | ❌ in `.gitignore`, never in `files` | concrete fault debugging, internal details, account-risk analysis | reference only; ignored by git by default |
53
+
54
+ **Hard constraints**
55
+
56
+ - `package.json` `files` whitelist contains **only** publishable docs; `docs/` must **not** be added wholesale — any doc shipped with the package is listed explicitly.
57
+ - `.gitignore` keeps `docs/local/`, `docs/` and `reference/` ignored. To promote a doc into version control, explicitly `git add -f` after moving it to the root or adopting the naming convention in §2.
58
+ - Before adding any doc, ask: *does an unrelated contributor need to see this?* Anything involving personal accounts, hosts, tokens, paths, regional-risk details or internal debugging goes to the local-only layer.
59
+
60
+ ---
61
+
62
+ ## 2. Document Naming & "Document Version"
63
+
64
+ - Docs use `NN-<topic>.md`, numbered from `00` (`00-project-rules` is the fixed rule file — it is not re-versioned on every release).
65
+ - **A "new document version" exists when any of the following happens**:
66
+ - substantive content added/removed/changed (not just wording);
67
+ - a doc is split, merged, or added;
68
+ - `README.md` / `INSTALL.md` must be updated to stay consistent.
69
+ - A document's version **is the npm package version** (see §3); there is no separate doc versioning scheme.
70
+
71
+ ### Language policy
72
+
73
+ - **`README.md` is English-first.** It also ships community translations selected for the widest open-source reach: `README.zh-CN.md` (简体中文), `README.ja.md` (日本語), `README.ko.md` (한국어), `README.pt-BR.md` (Português do Brasil), `README.es.md` (Español), `README.fr.md` (Français), `README.de.md` (Deutsch) and `README.ru.md` (Русский). All 9 files carry an identical language-switch line at the top so readers can jump between them, and every translation must be kept in sync with `README.md` (same sections, same version references).
74
+ - Any user-facing change to `README.md` implies updating **all** translations. If that is not feasible for a very-large change, translators can open follow-up PRs, but the language switch line must never be broken.
75
+ - Publishable docs under `docs/` are written English-first as well, to match the general-OSS publishing style. `docs/local/` may stay in whatever language the author prefers, since it is never published.
76
+
77
+ ---
78
+
79
+ ## 3. Versioning & The Release Loop
80
+
81
+ [Semantic Versioning (SemVer)](https://semver.org/): `MAJOR.MINOR.PATCH`.
82
+
83
+ | Change | Version action |
84
+ |---|---|
85
+ | New public capability / route / provider | minor (in the `0.x` phase this bumps the second digit) |
86
+ | Bug fix, docs wording, process patch | patch |
87
+ | Breaking change to imports/config in an existing capability | major (pre-1.0, handled on a case-by-case basis) |
88
+
89
+ **The release loop (every document version → README → release) is a mandatory pipeline:**
90
+
91
+ ```text
92
+ new document version formed
93
+
94
+
95
+ CHANGELOG.md updated (entry added under the matching release)
96
+
97
+
98
+ README.md synced (new capability / new doc entry / new command / new notes)
99
+
100
+
101
+ pnpm run check passes in the Docker sandbox
102
+
103
+
104
+ version bumped (package.json + built artifact metadata, see §4)
105
+
106
+
107
+ git commit + annotated tag v<version> (clean tree only)
108
+
109
+
110
+ publish only after the verified local pack and explicit maintainer approval
111
+
112
+
113
+ confirm GitHub release / milestone stays active
114
+ ```
115
+
116
+ **Every time a document version is formed, the full loop above must run.** Never change docs without syncing README, and never update README without releasing.
117
+
118
+ **Commit, tag and tree hygiene** (detail in §7): each commit is conventional and atomic; generated `lib/` is committed with the source/build change that produced it; the release commit is made only on a clean tree; the annotated tag is `v<version>` and must match `package.json` and the top `CHANGELOG.md` heading.
119
+
120
+ ---
121
+
122
+ ## 4. Automated Release Script
123
+
124
+ The repo provides `scripts/release.mjs` (see its header comment):
125
+
126
+ - `--dry-run` validates the current `CHANGELOG.md`/`package.json` version, verifies the already-built release artifacts, previews the real packed file list with lifecycle scripts disabled, and rejects local-only files.
127
+ - `--pack` rebuilds and verifies the release, then writes a local tarball under `output/`.
128
+ - The helper never bumps versions, commits, tags, pushes, or publishes. Those remain explicit maintainer operations after human approval.
129
+
130
+ Example:
131
+
132
+ ```bash
133
+ # validate + preview only; no tarball, Git, or registry changes
134
+ node scripts/release.mjs --dry-run
135
+
136
+ # rebuild + verify + create a local candidate tarball
137
+ node scripts/release.mjs --pack
138
+ ```
139
+
140
+ > Publishing and remote Git writes are intentionally outside the script.
141
+
142
+ ### 4.1 Maintainer-run npm publish handoff
143
+
144
+ For every release candidate, the assistant must proactively hand the maintainer an exact PowerShell command before any registry write. The handoff must name the verified candidate `.tgz`, include its expected SHA-256, use the public npm registry, and include a post-publish `npm view` check. The assistant must not run `npm publish`, `npm login`, or copy npm credentials.
145
+
146
+ The maintainer runs the handoff command, reports the resulting published version and `latest` dist-tag, and only then does the assistant continue with registry verification, PR merge, annotated tag/GitHub Release work, and issue evidence replies. A failed or ambiguous publish keeps the release and issues open. The exact release gate still requires a clean tree, successful Docker verification, a maintainer decision, and explicit maintainer release approval; publishing an unverified or dirty candidate is prohibited.
147
+
148
+ The standard handoff shape is:
149
+
150
+ ```powershell
151
+ $candidate = ".\\output\\<package>-<version>.tgz"
152
+ if ((Get-FileHash $candidate -Algorithm SHA256).Hash -ne "<verified-sha256>") { throw "candidate hash mismatch" }
153
+ npm publish $candidate --access public --ignore-scripts --registry=https://registry.npmjs.org/
154
+ npm view <package>@<version> version dist-tags --json --registry=https://registry.npmjs.org/
155
+ ```
156
+
157
+ The assistant must not treat a local pack or a user-reported command start as a successful release; success requires the registry result to show the exact version and expected `latest` tag.
158
+
159
+ ---
160
+
161
+ ## 5. Keeping the Project Active
162
+
163
+ "Active" is not about publishing many versions it is a stable, predictable, handover-friendly rhythm:
164
+
165
+ - **Predictable release cadence**: run the release loop after every substantive feature PR; aim for at least one meaningful minor release per quarter to keep discoverability up.
166
+ - **Honest changelog**: accumulate pending entries under `Unreleased` and fold them into a version on release; never pad releases with empty entries.
167
+ - **Responsive PRs/issues**: keep the templates and conventions in `CONTRIBUTING.md` so any contributor knows how to open a PR.
168
+ - **CI & gates**: `pnpm run check` (lint + typecheck + test + build/verify) is a release precondition; CI also rebuilds committed `lib/` and rejects artifact drift.
169
+ - **Security stance**: the compliance note in `README` (own accounts only; no bulk accounts, resale, impersonation) is a hard line; any new provider or endpoint must respect it.
170
+ - **Docs/code in sync**: when adding or changing a capability, update `README.md` and `docs/02-architecture.md` (public layer) before releasing.
171
+
172
+ ---
173
+
174
+ ## 6. Pre-Release Self-Check (Privacy Line)
175
+
176
+ Before every real release, verify:
177
+
178
+ - [ ] `npm pack --dry-run --json --ignore-scripts` output contains **nothing** matching `*调查*`, `docs/local/`, `reference/`, account/host aliases, tokens, or absolute paths.
179
+ - [ ] `README.md` / `INSTALL.md` reference only public, generic commands, domains and accounts.
180
+ - [ ] The `files` whitelist does **not** include the whole `docs/` directory.
181
+ - [ ] `CHANGELOG.md` has an entry matching the about-to-be-released version; pending notes have been folded from `Unreleased` into `## v<version>`.
182
+ - [ ] `pnpm run check` passes.
183
+ - [ ] `git status` is clean: no leftover source, docs, lockfile or `lib/` drift.
184
+ - [ ] The annotated tag will be `v<version>` and matches `package.json` plus the top `CHANGELOG.md` heading. Never move or reuse a published tag.
185
+
186
+ ---
187
+
188
+ ## 7. Commits, Pushes & Tags
189
+
190
+ Contributor-facing wording lives in `CONTRIBUTING.md`. This section is the source of truth for maintainers.
191
+
192
+ ### 7.1 Atomic conventional commits
193
+
194
+ - Messages follow [Conventional Commits](https://www.conventionalcommits.org/): `type(optional-scope): summary` in the imperative (`feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `build:`, `ci:`, `chore:`). Optional scopes such as `M1` / `M3` or a module name are fine.
195
+ - **One coherent concern per commit.** Never mix documentation, build/toolchain and feature/fix changes unless they cannot be reviewed or built separately (a capability that is meaningless without its README/changelog note, or a source change that must ship with the `lib/` it generated).
196
+ - Build the tracked Dockerfile's `check` and `verify` targets before the commit. Do not install dependencies, typecheck, lint, test, build, or pack this plugin directly on a shared developer host. The build context is filtered by `.dockerignore`; dependencies download in their own stage, while all project-code `RUN` steps use `--network=none`. Never use privileged mode, credential mounts, the Docker socket, or host-directory bind mounts. Host networking is prohibited except for the narrow, explicitly authorized preview fallback below. Commit that passing slice promptly — do not leave a finished, verified change sitting uncommitted next to later work, and do not commit a red tree.
197
+ - **Host DSH boundary:** unless the maintainer explicitly requests it for the current operation, never install into, modify, stop, restart, or run validation against a DSH instance already installed on the shared host. Development checks and interactive Web previews use a dedicated Docker DSH instance with an isolated home/profile. A preview may publish an explicitly selected high host port on `0.0.0.0` for remote review, must not reuse the host DSH port or state directories, and must remain resource-limited and individually removable. Host networking is prohibited by default; it is allowed only after ordinary Docker port publishing has been proven unavailable and the maintainer explicitly authorizes that specific run. An authorized host-network preview must bind only pre-checked high ports, keep its DSH backend on a separate loopback high port, and never bind or probe the host DSH port.
198
+ - Generated `lib/` is a committed release artifact (git installs and the CI `git diff --exit-code -- lib` drift gate). Rebuild it and include it in the **same** commit as the `src/` or build-script change that produced it. Do not land stale `lib/` against newer source, and do not land a `lib/`-only commit unless the only change is a verified rebuild with no source delta.
199
+ - Secrets, credentials, tokens, private keys, `.env` files, host aliases, absolute machine paths, and local-only notes (`docs/local/`, `reference/`) never enter git (§0.3).
200
+
201
+ ### 7.2 Pushes
202
+
203
+ - Feature branches are pushed as **checkpoints** at each version or milestone (branch names such as `work/<topic>-v0.3` are fine), not only when the PR is finished.
204
+ - Force-push is forbidden without **explicit approval**, including `--force-with-lease`, once a branch has been pushed. Default history is append-only. Never force-push `main` or a published release tag.
205
+ - Do not push a dirty or failing tree "to save it"; commit the passing slice first.
206
+
207
+ ### 7.3 Changelog, versions and tags
208
+
209
+ - Day-to-day user-facing work accumulates under `CHANGELOG.md` → `## Unreleased`.
210
+ - A release folds `Unreleased` into `## v<version>`, bumps `package.json` (and any built artifact metadata) to that same version, and creates an **annotated** tag `v<version>` on a **clean** working tree. The top changelog heading, `package.json` version and tag name must be identical (the `v` prefix is tag/heading only).
211
+ - `scripts/release.mjs` does **not** bump, commit, tag, push or publish; those stay explicit maintainer steps after `pnpm run check`, `--dry-run` and `--pack` succeed.
212
+ - Never tag or publish from a dirty tree, and never move or reuse a published tag.