feat!: publish as @dsh-plugin/session-delete with an automated Gitea npm release
publish / npm (push) Failing after 1m49s
publish / npm (push) Failing after 1m49s
The registry owner is the scope the package must publish under, so the name moves from @local/ to @dsh-plugin/ in all three places that must agree: package.json, cordis.patch.yml, and the client module id. `private` goes away because npm refuses to publish such a package, and publishConfig pins the registry to this organization's npm endpoint. The tag workflow publishes whatever version the pushed v* tag names, using the built-in Gitea job token, and refuses a tag that disagrees with package.json.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# 把打了 v* 标签的版本发布到 Gitea 的 npm 包仓库。
|
||||
#
|
||||
# 触发方式:
|
||||
# 1. 推送版本标签(推荐):git tag -a v1.0.1 -m "..." && git push origin v1.0.1
|
||||
# 2. 仓库 → Actions → 选择本工作流 → Run workflow(手动,发布当前 commit 的版本)
|
||||
#
|
||||
# 需要的权限:
|
||||
# 本工作流用 Gitea 内置的任务令牌 ${{ secrets.GITEA_TOKEN }} 发布,无需额外配置密钥。
|
||||
# 组织(或仓库)Settings → Actions → General 里的 token 权限不能被限制到读,
|
||||
# 且 packages 需要写权限 —— 工作流里的 permissions: 已经声明,但仍会被管理员配置的上限(clamping)压回。
|
||||
# 如果实例把默认权限设为 Restricted,请在这里(或组织级)确认 packages 至少为 write。
|
||||
#
|
||||
# 依赖前提:
|
||||
# - 实例启用了 Actions,且注册了 act_runner(否则工作流只会排队)。
|
||||
# - runner 需要能拉取 actions/checkout 与 actions/setup-node(默认从 github.com 取)。
|
||||
# 若 runner 在无外网环境,请在 app.ini 里设 actions.DEFAULT_ACTIONS_URL = self 并把这两个
|
||||
# action 镜像到自己的实例上。
|
||||
# - runs-on 的标签要与 runner 配置的标签一致(默认 ubuntu-latest;自建 runner 常用 docker/ubuntu-22.04 等)。
|
||||
name: publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
# 读取代码用于 checkout,向本组织写包。
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
npm:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
REGISTRY: https://gitea.iwake.top/api/packages/dsh-plugin/npm/
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
registry-url: https://gitea.iwake.top/api/packages/dsh-plugin/npm/
|
||||
|
||||
- name: Check the tag against package.json
|
||||
run: |
|
||||
set -eu
|
||||
version="$(node -p "require('./package.json').version")"
|
||||
name="$(node -p "require('./package.json').name")"
|
||||
case "${GITHUB_REF}" in
|
||||
refs/tags/*)
|
||||
tag="${GITHUB_REF_NAME#v}"
|
||||
if [ "$tag" != "$version" ]; then
|
||||
echo "标签 ${GITHUB_REF_NAME} 与 package.json 的版本 ${version} 不一致" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "将发布 ${name}@${version}"
|
||||
|
||||
- name: Pack (preview the published contents)
|
||||
run: npm pack --dry-run
|
||||
|
||||
- name: Publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
# 作用域与默认注册表都指向本组织的 npm 仓库;token 由 setup-node 写进 .npmrc。
|
||||
npm config set @dsh-plugin:registry "${REGISTRY}"
|
||||
npm publish --registry "${REGISTRY}"
|
||||
@@ -51,10 +51,50 @@ DeepSeek Harness 原本只能归档会话,归档只是从列表里移开、日
|
||||
这是一个 DeepSeek Harness **bundle** 包(普通 Node 包 + `cordis.patch.yml`),由 Harness 的插件管理机制安装,而不是单独运行的程序:
|
||||
|
||||
- `package.json` 声明 `dsh.bundle.patch`(bundle 补丁)与 `dsh.client`(web 平台客户端半)
|
||||
- `cordis.patch.yml` 把 `@local/dsh-session-delete` 插进 profile
|
||||
- 安装后 profile 的依赖会是 `link:<本目录绝对路径>`,并在 `node_modules` 下建立链接
|
||||
- `cordis.patch.yml` 把 `@dsh-plugin/session-delete` 插进 profile
|
||||
- 安装后 profile 的依赖是 `link:<本目录绝对路径>`(本地目录安装)或注册表/git 解析出的版本,并在 `node_modules` 下建立链接
|
||||
|
||||
> 包名在三个地方必须完全一致:`package.json` 的 `name`、`cordis.patch.yml` 里 `name:`、以及 `client.js` 顶部 `__ModuleLoader__.load({ id })`。Cordis 是按 `name` 在 profile 的 `node_modules` 里解析模块的。
|
||||
|
||||
### 安装方式
|
||||
|
||||
在 DeepSeek Harness 的 **插件 → 添加插件** 里,以下三种都可用:
|
||||
|
||||
| 方式 | 输入 |
|
||||
| --- | --- |
|
||||
| 本地目录 | 本仓库在本机的绝对路径(`D:\DeepSeek Harness Plugins\dsh-session-delete`),适合边改边用 |
|
||||
| Git 仓库地址 | `https://gitea.iwake.top/dsh-plugin/session-delete.git#v1.0.0`(`#` 后可跟标签或提交) |
|
||||
| npm 源 | 安装源选「自定义地址」填 `https://gitea.iwake.top/api/packages/dsh-plugin/npm/`,包名填 `@dsh-plugin/session-delete` |
|
||||
|
||||
用 npm 源或私有源时,凭据放在本机 `~/.npmrc`(客户端提示里也是这么说的):
|
||||
|
||||
```bash
|
||||
npm config set @dsh-plugin:registry=https://gitea.iwake.top/api/packages/dsh-plugin/npm/
|
||||
npm config set //gitea.iwake.top/api/packages/dsh-plugin/npm/:_authToken=<带 package 权限的 token>
|
||||
```
|
||||
|
||||
公开的 git 地址不需要凭据。安装或升级后:**宿主半需要重启客户端**,只改浏览器半时刷新页面即可。
|
||||
|
||||
### 发布到 Gitea 的 npm 仓库
|
||||
|
||||
仓库自带工作流 [`.gitea/workflows/publish.yml`](.gitea/workflows/publish.yml):推送 `v*` 标签(或在 Actions 页面手动运行)就会把当前版本发布到 `https://gitea.iwake.top/api/packages/dsh-plugin/npm/`,用的是 Gitea 内置的任务令牌,不需要额外配置密钥。
|
||||
|
||||
```bash
|
||||
git tag -a v1.0.1 -m "v1.0.1" && git push origin v1.0.1
|
||||
```
|
||||
|
||||
前提:实例启用了 Actions 并注册了 runner(`runs-on` 的标签要与 runner 一致),且 Actions 的令牌权限没有把 `packages` 限制成只读(组织 Settings → Actions → General)。
|
||||
|
||||
手工发布等价于:
|
||||
|
||||
```bash
|
||||
npm config set @dsh-plugin:registry=https://gitea.iwake.top/api/packages/dsh-plugin/npm/
|
||||
npm config set //gitea.iwake.top/api/packages/dsh-plugin/npm/:_authToken=<TOKEN>
|
||||
npm publish # registry 已写在 package.json 的 publishConfig 里,无需再传 --registry
|
||||
```
|
||||
|
||||
同一版本不能重复发布:改内容要同时提升 `package.json` 的 `version`。
|
||||
|
||||
安装或升级后:**宿主半需要重启客户端**,只改浏览器半时刷新页面即可。
|
||||
|
||||
## 结构
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* `--dsw-*` theme-token references. React comes from the page's module table.
|
||||
*/
|
||||
window.__ModuleLoader__.load({
|
||||
id: '@local/dsh-session-delete',
|
||||
id: '@dsh-plugin/session-delete',
|
||||
factory(require) {
|
||||
const React = require('react')
|
||||
const h = React.createElement
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@
|
||||
# deletion operation and the authenticated route the browser half calls.
|
||||
- insert:
|
||||
- id: session-delete
|
||||
name: '@local/dsh-session-delete'
|
||||
name: '@dsh-plugin/session-delete'
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* Fetch route registered below; it is the only cross-half entry point this
|
||||
* package needs.
|
||||
*
|
||||
* @module @local/dsh-session-delete
|
||||
* @module @dsh-plugin/session-delete
|
||||
*/
|
||||
import { createHash } from 'node:crypto'
|
||||
import { lstat, open, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises'
|
||||
|
||||
+9
-2
@@ -1,10 +1,17 @@
|
||||
{
|
||||
"name": "@local/dsh-session-delete",
|
||||
"name": "@dsh-plugin/session-delete",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Permanently delete a conversation: stop it, remove its session log, subagent logs, and spilled tool output, and drop every registry reference. Settings → General can sweep orphaned temporary files left by conversations that are gone.",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitea.iwake.top/dsh-plugin/session-delete.git"
|
||||
},
|
||||
"homepage": "https://gitea.iwake.top/dsh-plugin/session-delete",
|
||||
"publishConfig": {
|
||||
"registry": "https://gitea.iwake.top/api/packages/dsh-plugin/npm/"
|
||||
},
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./client": "./client.js",
|
||||
|
||||
Reference in New Issue
Block a user