dsh-project-flow 0.8.1 → 0.8.2

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 (3) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/index.js +38 -8
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -14,6 +14,22 @@ dsh-project-flow 的版本变更。版本号遵循语义化版本。
14
14
 
15
15
  ---
16
16
 
17
+ ## [0.8.2] - 2026-12-04
18
+
19
+ 给插件自己的四个 HTTP 路由加来源检查。界面和功能没动。
20
+
21
+ ### 修复
22
+
23
+ **路由没有来源检查**
24
+
25
+ - **任意网页都能打**:`/plugins/dsh-project-flow/` 下面四个路由(`ping`、`models`、`diag`、`panel`)都只读,但注册时没校验来源。浏览器里随便哪个页面都能对 `127.0.0.1` 发一条简单请求。跨域读不到响应体,可 `?cwd=` 是请求方说了算的,靠响应大小和耗时就能一位一位问出某个路径下有没有项目。
26
+ - **现在的做法**:四个 handler 统一过一层 `localOnly`。`Sec-Fetch-Site` 只放 `same-origin` 和 `none`(地址栏直开),`cross-site` 一律 403;老客户端不认这个头,退回比对 `Origin` 和 `Host`;连 `Origin` 都没有的是命令行,本地诊断还要用,照常放行。
27
+
28
+ ### 说明
29
+
30
+ - 这一版没有功能改动,装上去看到的界面和 0.8.0 一模一样。
31
+ - **版本号跳过了 `0.8.1`**。npm 上那个 `0.8.1` 是 0.8.0 那次发布撞上暂存占位后留下的空壳:内容就是 0.8.0 的代码,只是版本号写成了 0.8.1,装上去和 0.8.0 没区别。本来想用同号盖掉,但发布的 token 没有 unpublish 权限,摘不掉,只好发 0.8.2 跳过它。那个号已经标成弃用,别装。
32
+
17
33
  ## [0.8.0] - 2026-12-03
18
34
 
19
35
  修状态栏、修账、修目录门控。全部是实测出来的。
@@ -63,6 +79,48 @@ dsh-project-flow 的版本变更。版本号遵循语义化版本。
63
79
 
64
80
  从 121 条增加到 150 条。新增 `prices.test.mjs`、`panel-buttons.test.mjs`、`concurrency-limit.test.mjs`、`session-cwd.test.mjs`、`flow-root.test.mjs`、`three-fixes.test.mjs`。修掉了 `project-flow-gate/watchdog.mjs` 是过期副本、20 条 watchdog 测试一直在验旧代码的问题。
65
81
 
82
+ ### 发布记录
83
+
84
+ 这一版是**第一次真正发到 npm**。之前 0.3.0 只打了 tgz、走 GitHub 分发,注册表上查不到;`npm view dsh-project-flow` 一直是 404。过程中撞了三件事,记下来免得以后重踩:
85
+
86
+ **一、首次发布被 npm 转成暂存(staged publish)**
87
+
88
+ 新包名的第一次发布会先建一个 `0.0.0-stage` 占位,真实版本进暂存区等审批。所以 `pnpm publish` 报成功、registry 上却查不到 0.8.0,只有那个占位版本。等了一会儿它自己转正了,不用手动 approve。
89
+
90
+ **二、为了绕过暂存临时改过 0.8.1,又撤了**
91
+
92
+ 改版本号重发时撞上:
93
+
94
+ ```
95
+ 409 Cannot publish over previously staged version "0.8.0"
96
+ ```
97
+
98
+ 同时那次 0.8.0 已经转正。所以 `npm unpublish dsh-project-flow@0.8.1 --force` 撤掉了 0.8.1,版本号改回 0.8.0,与 git tag 和本条日志对齐。
99
+
100
+ > 残留:registry 的版本列表里可能还挂着 `0.8.1` 的元数据,`latest` 指向 0.8.0,装到的就是 0.8.0。`0.0.0-stage` 是包名占位,**不要删**。
101
+
102
+ **三、`latest` 被占位版本占着**
103
+
104
+ 占位版本抢了 `latest` 标签,别人装会装到它。手动改:
105
+
106
+ ```
107
+ PUT /-/package/dsh-project-flow/dist-tags/latest → 204
108
+ ```
109
+
110
+ 之后 `npm view dsh-project-flow version` 返回 `0.8.0`。
111
+
112
+ **发布凭据**:`~/.npmrc` 里现在存着 publish token(`bypass_2fa: true` 的细粒度令牌)。npm 正在逐步取消「绕过 2FA 的代币」,2027-01 后可能失效,到时要么换 Classic Automation,要么开 2FA 走 `--otp`。
113
+
114
+ ### 上架插件市场
115
+
116
+ 投稿到 `awesome-dsh-plugin/awesome-dsh-plugin`,PR **#20891**。
117
+
118
+ 市场目录**不是扫 npm 自动收的**,而是读那个仓库的 `data/plugins/*.yml` 构建:一个插件一个 YAML 文件,两个 README 都是生成的,手改 README 会被拒。提交的文件是 `data/plugins/LiuShi611__dsh-project-flow.yml`,`category: workflow`。
119
+
120
+ 提交前把 GitHub 仓库描述改对了——原来写着「Five-stage」,那是 0.3.0 的说法,0.4.0 就合并成四段了。官方明确写着描述会跟代码核对,夸大是头号退回原因。
121
+
122
+ 另外核对过官方门槛:`dsh.bundle.patch` 已声明、`cordis.patch.yml` 在仓库根、仓库创建满 1 天、有 `dsh-plugin` topic、代码真实可用。
123
+
66
124
  ---
67
125
 
68
126
  ## [0.7.9] - 2026-12-03
package/index.js CHANGED
@@ -4876,11 +4876,41 @@ async function decorateCost(result, settings, requirements, cwd) {
4876
4876
  ctx.inject(['webServer'], webCtx => {
4877
4877
  const webServer = webCtx.get('webServer')
4878
4878
  if (webServer === undefined) return
4879
+ // 下面四个路由都是只读的,但原先没有任何来源检查:浏览器里随便哪个网页
4880
+ // 都能对 127.0.0.1 发一条简单请求。跨域拿不到响应体,可 ?cwd= 是请求方
4881
+ // 可控的,靠响应大小和耗时就能一位一位地问出某个路径下有没有项目。
4882
+ // 这层壳只放同源页面和地址栏直开,别的来源一律 403。
4883
+ const localOnly = handler => (req, res) => {
4884
+ const site = req.headers['sec-fetch-site']
4885
+ if (typeof site === 'string' && site !== 'same-origin' && site !== 'none') {
4886
+ res.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' })
4887
+ res.end('cross-site blocked')
4888
+ return
4889
+ }
4890
+ // 不认 sec-fetch-site 的老客户端退回比对 Origin;Origin 也没有的
4891
+ // 是命令行(curl 之类),本地诊断还要用,照常放行。
4892
+ const origin = req.headers.origin
4893
+ if (typeof site !== 'string' && typeof origin === 'string' && origin !== '') {
4894
+ let same = false
4895
+ try {
4896
+ same = new URL(origin).host === (req.headers.host ?? '')
4897
+ } catch {
4898
+ same = false
4899
+ }
4900
+ if (!same) {
4901
+ res.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' })
4902
+ res.end('cross-site blocked')
4903
+ return
4904
+ }
4905
+ }
4906
+ return handler(req, res)
4907
+ }
4908
+
4879
4909
  webCtx.effect(() => {
4880
4910
  const offPing = webServer.register({
4881
4911
  kind: 'exact',
4882
4912
  path: '/plugins/dsh-project-flow/ping',
4883
- handler: (req, res) => {
4913
+ handler: localOnly((req, res) => {
4884
4914
  let stage = ''
4885
4915
  try {
4886
4916
  stage = new URL(req.url ?? '/', 'http://localhost').searchParams.get('stage') ?? ''
@@ -4895,7 +4925,7 @@ async function decorateCost(result, settings, requirements, cwd) {
4895
4925
  // 装到别人机器上,往自己的安装目录写文件是不该做的事(可能只读、也会留垃圾)。
4896
4926
  res.writeHead(204, { 'cache-control': 'no-store' })
4897
4927
  res.end()
4898
- },
4928
+ }),
4899
4929
  })
4900
4930
 
4901
4931
  // 模型清单:客户端下拉的选项全部来自这里,代码里不再写死模型名。
@@ -4903,7 +4933,7 @@ async function decorateCost(result, settings, requirements, cwd) {
4903
4933
  const offModels = webServer.register({
4904
4934
  kind: 'exact',
4905
4935
  path: '/plugins/dsh-project-flow/models',
4906
- handler: (req, res) => {
4936
+ handler: localOnly((req, res) => {
4907
4937
  void (async () => {
4908
4938
  try {
4909
4939
  const catalog = await listModelCatalog()
@@ -4918,7 +4948,7 @@ async function decorateCost(result, settings, requirements, cwd) {
4918
4948
  res.end(JSON.stringify({ providers: [], error: messageOf(error) }))
4919
4949
  }
4920
4950
  })()
4921
- },
4951
+ }),
4922
4952
  })
4923
4953
 
4924
4954
  // 状态栏不显示的时候,光盯着界面分不清三件事:
@@ -4927,7 +4957,7 @@ async function decorateCost(result, settings, requirements, cwd) {
4927
4957
  const offDiag = webServer.register({
4928
4958
  kind: 'exact',
4929
4959
  path: '/plugins/dsh-project-flow/diag',
4930
- handler: (req, res) => {
4960
+ handler: localOnly((req, res) => {
4931
4961
  void (async () => {
4932
4962
  let version = ''
4933
4963
  try {
@@ -4983,7 +5013,7 @@ async function decorateCost(result, settings, requirements, cwd) {
4983
5013
  })
4984
5014
  res.end(body)
4985
5015
  })()
4986
- },
5016
+ }),
4987
5017
  })
4988
5018
 
4989
5019
  // 状态栏的数据出口。命令那条路只用来触发计算,真数据从这儿取——
@@ -5011,7 +5041,7 @@ async function decorateCost(result, settings, requirements, cwd) {
5011
5041
  const offPanel = webServer.register({
5012
5042
  kind: 'exact',
5013
5043
  path: '/plugins/dsh-project-flow/panel',
5014
- handler: (req, res) => {
5044
+ handler: localOnly((req, res) => {
5015
5045
  void (async () => {
5016
5046
  let body
5017
5047
  try {
@@ -5044,7 +5074,7 @@ async function decorateCost(result, settings, requirements, cwd) {
5044
5074
  })
5045
5075
  res.end(body)
5046
5076
  })()
5047
- },
5077
+ }),
5048
5078
  })
5049
5079
 
5050
5080
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-project-flow",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "private": false,
5
5
  "description": "Four-stage project workflow: requirement, plan, build, QA, with an intent gate, a rework loop, self-healing recovery, a watchdog that stops runaway runs, snapshot rollback, a single status light, and a machine-readable Completion_Evidence.json.",
6
6
  "type": "module",
@@ -85,4 +85,4 @@
85
85
  "optional": true
86
86
  }
87
87
  }
88
- }
88
+ }