dsh-sixlayer-memory 2.0.2 → 2.0.4
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.
- package/CHANGELOG.md +41 -0
- package/LICENSE +21 -0
- package/README.md +7 -1
- package/cordis.patch.yml +7 -3
- package/docs//347/224/237/345/221/275/345/221/250/346/234/237-/350/207/252/345/212/250/345/217/254/345/233/236/344/270/216/345/200/231/351/200/211.md +1 -1
- package/lib/index.js +24 -8
- package/lib/probe-plugin.js +1 -1
- package/package.json +6 -5
- package/tools/push-via-api.mjs +197 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# 变更记录 · dsh-sixlayer-memory(六层记忆底座)
|
|
2
2
|
|
|
3
|
+
## 2.0.4 — 2026-11-22
|
|
4
|
+
|
|
5
|
+
主题:**按社区索引 PR #121 的 review 修三处**(维护者 zhu1090093659)。
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **patch 行 id 撞名**:`cordis.patch.yml` 里原来是 `id: workbench`,而社区索引里
|
|
10
|
+
`dsh-workbench`(另一位作者)也占着同一个 id。两个插件同时安装会出现两行同 id,
|
|
11
|
+
宿主的 `applyPatches` 按 id 建 `entryMap`,后者覆盖前者 —— 插件管理按 id 读写的启用状态也会错位。
|
|
12
|
+
改为 **`id: sixlayer-memory`**(带自己的命名空间)。
|
|
13
|
+
- **补 LICENSE 文件**:README 第 4 行的 license 徽章原本指向一个不存在的文件(死链),
|
|
14
|
+
现在补上 MIT 正文,并加进 `files`,会随包发布。
|
|
15
|
+
- **诊断日志不再写插件安装目录**:`lib/index.js` 的 `DIAG_FILE` 原来是
|
|
16
|
+
`<包目录>/docs/_rpc-diag.log`,在只读挂载或升级替换时会写失败(静默 try/catch)。
|
|
17
|
+
改为 `$DSH_HOME/memory-core/diag.log`(默认 `~/.dsh/memory-core/diag.log`),
|
|
18
|
+
连 `$DSH_HOME` 都写不进去才退到系统临时目录;相关文档里的排查命令同步更新。
|
|
19
|
+
|
|
20
|
+
### 说明
|
|
21
|
+
|
|
22
|
+
- 维护者提到「npm latest 是 2.0.2」,实测是 **2.0.3**(`dist-tags.latest=2.0.3`,
|
|
23
|
+
tarball 200,`npm install` 落到 2.0.3)。大概率是镜像/本地缓存滞后,非版本被撤。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2.0.3 — 2026-11-21
|
|
28
|
+
|
|
29
|
+
主题:**发布到 npm**。
|
|
30
|
+
|
|
31
|
+
### 变更
|
|
32
|
+
|
|
33
|
+
- `repository` / `bugs` / `homepage` 从占位符 `<your-account>` 换成真实仓库 `github.com/z9134/dsh-sixlayer-memory`
|
|
34
|
+
(2.0.2 已经发到 npm,但页面上的仓库链接指向占位符,删不掉,只能靠新版本覆盖元数据)
|
|
35
|
+
- README 首屏加 npm / license / DSH 徽章与视频链接
|
|
36
|
+
|
|
37
|
+
### 发布
|
|
38
|
+
|
|
39
|
+
- `npm publish` → https://www.npmjs.com/package/dsh-sixlayer-memory
|
|
40
|
+
- 全程走 `registry.npmjs.org`(`www.npmjs.com` 在本机 403,Web 登录走不通,用 granular token + Bypass 2FA 发布)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
3
44
|
## 2.0.2 — 2026-11-20
|
|
4
45
|
|
|
5
46
|
主题:**点一个圆球,就能看这条记忆的全部**。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 z9134
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# dsh-sixlayer-memory · 六层记忆底座
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-sixlayer-memory)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
6
|
+
|
|
3
7
|
> **会先审后记、还带审计链的本地记忆。**
|
|
4
8
|
> 每一轮按你的输入自动召回;不确定的东西不会直接变成事实;每个动作都能倒查。
|
|
5
9
|
|
|
@@ -7,7 +11,9 @@
|
|
|
7
11
|
dsh plugin --profile desktop add dsh-sixlayer-memory
|
|
8
12
|
```
|
|
9
13
|
|
|
10
|
-
**当前版本**:2.0.
|
|
14
|
+
**当前版本**:2.0.4 · **32 个工具** · schema v9 · 零外部依赖 · 回归 31 个套件全绿
|
|
15
|
+
|
|
16
|
+
📦 [npm](https://www.npmjs.com/package/dsh-sixlayer-memory) · 🎬 [40 秒介绍视频](media/intro-40s.mp4) · 📝 [变更记录](CHANGELOG.md)
|
|
11
17
|
|
|
12
18
|
---
|
|
13
19
|
|
package/cordis.patch.yml
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# dsh-sixlayer-memory bundle patch
|
|
2
2
|
#
|
|
3
3
|
# 一个安装入口,内部两条线:记忆(memory)+ 零件(parts)。
|
|
4
|
-
# 装上以后 profile 里多一行
|
|
4
|
+
# 装上以后 profile 里多一行 sixlayer-memory;工具默认只常驻 mem_admin_catalog,
|
|
5
5
|
# 其余按需经 mem_admin_open 注入。
|
|
6
|
+
#
|
|
7
|
+
# 注意 id:必须带自己的命名空间。早期用过 `workbench`,而社区索引里另一个插件
|
|
8
|
+
# (dsh-workbench)占着同一个 id —— 两个同时装会出现两行同 id,
|
|
9
|
+
# 宿主的 applyPatches 按 id 建 entryMap,后者会覆盖前者(PR #121 review 指出)。
|
|
6
10
|
- insert:
|
|
7
|
-
- id:
|
|
8
|
-
name: dsh-sixlayer-memory
|
|
11
|
+
- id: sixlayer-memory
|
|
12
|
+
name: dsh-sixlayer-memory
|
package/lib/index.js
CHANGED
|
@@ -39,13 +39,28 @@ export const inject = ['tools', 'systemPrompt']
|
|
|
39
39
|
|
|
40
40
|
const HERE = path.dirname(fileURLToPath(import.meta.url))
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 诊断日志:插件加载/注册的每一步都落盘,出问题不靠猜。
|
|
44
|
+
*
|
|
45
|
+
* 不能写在插件自己的安装目录里 —— 市场装到只读挂载、或升级时旧目录被换掉,
|
|
46
|
+
* 都会写不进去(维护者 review 指出的问题)。改到 $DSH_HOME 下:
|
|
47
|
+
* ~/.dsh/memory-core/diag.log
|
|
48
|
+
* 连 $DSH_HOME 都写不了才退到系统临时目录。
|
|
49
|
+
*/
|
|
50
|
+
const DSH_HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
51
|
+
const DIAG_FILE = path.join(DSH_HOME, 'memory-core', 'diag.log')
|
|
52
|
+
const DIAG_FALLBACK = path.join(os.tmpdir(), 'dsh-memory-core-diag.log')
|
|
53
|
+
|
|
44
54
|
function diag(message) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
const line = `${new Date().toISOString()} ${message}\n`
|
|
56
|
+
for (const file of [DIAG_FILE, DIAG_FALLBACK]) {
|
|
57
|
+
try {
|
|
58
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
59
|
+
fs.appendFileSync(file, line, 'utf8')
|
|
60
|
+
return
|
|
61
|
+
} catch {
|
|
62
|
+
/* 换下一个位置 */
|
|
63
|
+
}
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
|
|
@@ -429,11 +444,12 @@ export function apply(ctx, config = {}) {
|
|
|
429
444
|
|
|
430
445
|
// P4:设置页「记忆底座」的 RPC 通道。UI 只读 + 审核,不直接读库。
|
|
431
446
|
// 宿主里 connection 服务可能在 apply 时还没就绪;这里延迟重试,
|
|
432
|
-
// 并把探测结果写进
|
|
447
|
+
// 并把探测结果写进 $DSH_HOME/memory-core/diag.log,避免靠猜。
|
|
433
448
|
ctx.effect(() => {
|
|
434
|
-
const diagFile =
|
|
449
|
+
const diagFile = DIAG_FILE
|
|
435
450
|
const diag = (msg) => {
|
|
436
451
|
try {
|
|
452
|
+
fs.mkdirSync(path.dirname(diagFile), { recursive: true })
|
|
437
453
|
fs.appendFileSync(diagFile, `${new Date().toISOString()} ${msg}\n`, 'utf8')
|
|
438
454
|
} catch {
|
|
439
455
|
/* 诊断写失败不影响主流程 */
|
package/lib/probe-plugin.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from 'node:fs'
|
|
8
8
|
|
|
9
|
-
const LOG = 'D:/001/CH002/dsh-memory-core/
|
|
9
|
+
const LOG = process.env.DSH_HOME ? process.env.DSH_HOME + '/memory-core/diag.log' : 'D:/001/CH002/dsh-memory-core/diag.log'
|
|
10
10
|
function log(message) {
|
|
11
11
|
try {
|
|
12
12
|
fs.appendFileSync(LOG, `${new Date().toISOString()} ${message}\n`, 'utf8')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sixlayer-memory",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "DSH 工作台:六层记忆底座(每轮自动召回 + 候选沉淀 + 闸门审计)+ 零件化,支持 QQ 随身使用。",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"docs/DETAIL.md",
|
|
32
32
|
"docs/DETAIL.zh.md",
|
|
33
33
|
"docs/preview.svg",
|
|
34
|
-
"docs/生命周期-自动召回与候选.md"
|
|
34
|
+
"docs/生命周期-自动召回与候选.md",
|
|
35
|
+
"LICENSE"
|
|
35
36
|
],
|
|
36
37
|
"dsh": {
|
|
37
38
|
"bundle": {
|
|
@@ -105,12 +106,12 @@
|
|
|
105
106
|
],
|
|
106
107
|
"repository": {
|
|
107
108
|
"type": "git",
|
|
108
|
-
"url": "git+https://github.com
|
|
109
|
+
"url": "git+https://github.com/z9134/dsh-sixlayer-memory.git"
|
|
109
110
|
},
|
|
110
111
|
"bugs": {
|
|
111
|
-
"url": "https://github.com
|
|
112
|
+
"url": "https://github.com/z9134/dsh-sixlayer-memory/issues"
|
|
112
113
|
},
|
|
113
|
-
"homepage": "https://github.com
|
|
114
|
+
"homepage": "https://github.com/z9134/dsh-sixlayer-memory#readme",
|
|
114
115
|
"publishConfig": {
|
|
115
116
|
"access": "public"
|
|
116
117
|
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push-via-api.mjs —— 用 GitHub REST API 把本地仓库推到 GitHub。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要这个:这台机器上 github.com:443 不通(git push / GCM 登录都会卡死),
|
|
5
|
+
* 但 api.github.com:443 通。所以走 Git Data API 建库 + 提交树,不依赖 git 传输。
|
|
6
|
+
*
|
|
7
|
+
* 用法:
|
|
8
|
+
* $env:GITHUB_TOKEN='ghp_xxx' # classic PAT,勾 repo 权限
|
|
9
|
+
* node tools/push-via-api.mjs
|
|
10
|
+
*
|
|
11
|
+
* 只读本地 git 索引(git ls-files),不会把 .gitignore 排除的东西传上去。
|
|
12
|
+
*/
|
|
13
|
+
import fs from 'node:fs'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import { execFileSync } from 'node:child_process'
|
|
16
|
+
|
|
17
|
+
const OWNER = 'z9134'
|
|
18
|
+
const REPO = 'dsh-sixlayer-memory'
|
|
19
|
+
const ROOT = process.env.REPO_ROOT ?? 'D:/001/CH002/dsh-memory-core'
|
|
20
|
+
const TOKEN = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? ''
|
|
21
|
+
|
|
22
|
+
if (!TOKEN) {
|
|
23
|
+
console.error('缺少 GITHUB_TOKEN。先在 https://github.com/settings/tokens 建一个勾了 repo 的 token,然后:')
|
|
24
|
+
console.error(" $env:GITHUB_TOKEN='ghp_...'")
|
|
25
|
+
console.error(' node tools/push-via-api.mjs')
|
|
26
|
+
process.exit(2)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const API = 'https://api.github.com'
|
|
30
|
+
|
|
31
|
+
async function callOnce(method, url, body) {
|
|
32
|
+
const res = await fetch(API + url, {
|
|
33
|
+
method,
|
|
34
|
+
headers: {
|
|
35
|
+
authorization: `Bearer ${TOKEN}`,
|
|
36
|
+
accept: 'application/vnd.github+json',
|
|
37
|
+
'x-github-api-version': '2022-11-28',
|
|
38
|
+
'user-agent': 'dsh-sixlayer-memory-release',
|
|
39
|
+
...(body ? { 'content-type': 'application/json' } : {}),
|
|
40
|
+
},
|
|
41
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
42
|
+
})
|
|
43
|
+
const text = await res.text()
|
|
44
|
+
let json = null
|
|
45
|
+
try {
|
|
46
|
+
json = text ? JSON.parse(text) : null
|
|
47
|
+
} catch {
|
|
48
|
+
/* 非 JSON 响应 */
|
|
49
|
+
}
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
const msg = json?.message ?? text.slice(0, 300)
|
|
52
|
+
throw new Error(`${method} ${url} -> ${res.status} ${msg}`)
|
|
53
|
+
}
|
|
54
|
+
return json
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 网络抖动重试:断线/超时重来 3 次,4xx 直接抛。 */
|
|
58
|
+
async function call(method, url, body) {
|
|
59
|
+
let last
|
|
60
|
+
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
|
61
|
+
try {
|
|
62
|
+
return await callOnce(method, url, body)
|
|
63
|
+
} catch (error) {
|
|
64
|
+
last = error
|
|
65
|
+
const msg = String(error?.message ?? '')
|
|
66
|
+
const retriable = /fetch failed|ECONNRESET|ETIMEDOUT|EAI_AGAIN|socket hang up|network|-> 5\d\d/.test(msg)
|
|
67
|
+
if (!retriable) throw error
|
|
68
|
+
if (attempt < 3) await new Promise((r) => setTimeout(r, 600 * attempt))
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
throw last
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function ensureRepo() {
|
|
75
|
+
try {
|
|
76
|
+
const repo = await call('GET', `/repos/${OWNER}/${REPO}`)
|
|
77
|
+
console.log(`仓库已存在:${repo.html_url}`)
|
|
78
|
+
return repo
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!/-> 404/.test(error.message)) throw error
|
|
81
|
+
}
|
|
82
|
+
const repo = await call('POST', '/user/repos', {
|
|
83
|
+
name: REPO,
|
|
84
|
+
description: '会先审后记、还带审计链的本地记忆 · DSH 六层记忆底座',
|
|
85
|
+
homepage: '',
|
|
86
|
+
private: false,
|
|
87
|
+
has_issues: true,
|
|
88
|
+
has_wiki: false,
|
|
89
|
+
auto_init: false,
|
|
90
|
+
})
|
|
91
|
+
console.log(`已创建仓库:${repo.html_url}`)
|
|
92
|
+
return repo
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 空仓库连 git/trees 都返回 409「Git Repository is empty」,
|
|
97
|
+
* 唯一可靠的办法是先用 Contents API 写一个文件把仓库"点亮",
|
|
98
|
+
* 再用 blobs/tree/commit 覆盖上去。这里直接写真实 README。
|
|
99
|
+
*/
|
|
100
|
+
async function bootstrapIfEmpty() {
|
|
101
|
+
try {
|
|
102
|
+
await call('GET', `/repos/${OWNER}/${REPO}/git/ref/heads/main`)
|
|
103
|
+
return false
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (!/-> 404|-> 409/.test(error.message)) throw error
|
|
106
|
+
}
|
|
107
|
+
const readme = fs.readFileSync(path.join(ROOT, 'README.md'))
|
|
108
|
+
await call('PUT', `/repos/${OWNER}/${REPO}/contents/README.md`, {
|
|
109
|
+
message: 'init: README',
|
|
110
|
+
content: readme.toString('base64'),
|
|
111
|
+
})
|
|
112
|
+
console.log('已用 README 初始化 main 分支(空仓库不能直接传 blob/tree)')
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function trackedFiles() {
|
|
117
|
+
const out = execFileSync('git', ['-C', ROOT, 'ls-files', '-z'], { encoding: 'utf8' })
|
|
118
|
+
return out.split('\0').filter(Boolean)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function uploadBlob(rel) {
|
|
122
|
+
const abs = path.join(ROOT, rel)
|
|
123
|
+
const content = fs.readFileSync(abs)
|
|
124
|
+
const blob = await call('POST', `/repos/${OWNER}/${REPO}/git/blobs`, {
|
|
125
|
+
content: content.toString('base64'),
|
|
126
|
+
encoding: 'base64',
|
|
127
|
+
})
|
|
128
|
+
return blob.sha
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function main() {
|
|
132
|
+
const me = await call('GET', '/user')
|
|
133
|
+
if (me.login !== OWNER) throw new Error(`token 属于 ${me.login},不是 ${OWNER}`)
|
|
134
|
+
console.log(`身份:${me.login}`)
|
|
135
|
+
|
|
136
|
+
await ensureRepo()
|
|
137
|
+
await bootstrapIfEmpty()
|
|
138
|
+
|
|
139
|
+
const files = trackedFiles()
|
|
140
|
+
console.log(`本地文件:${files.length} 个`)
|
|
141
|
+
|
|
142
|
+
const entries = []
|
|
143
|
+
let done = 0
|
|
144
|
+
const concurrency = 4
|
|
145
|
+
let cursor = 0
|
|
146
|
+
async function worker() {
|
|
147
|
+
while (cursor < files.length) {
|
|
148
|
+
const rel = files[cursor++]
|
|
149
|
+
const sha = await uploadBlob(rel)
|
|
150
|
+
entries.push({ path: rel.split(path.sep).join('/'), mode: '100644', type: 'blob', sha })
|
|
151
|
+
done += 1
|
|
152
|
+
if (done % 20 === 0) console.log(` 已上传 ${done}/${files.length}`)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
await Promise.all(Array.from({ length: concurrency }, worker))
|
|
156
|
+
console.log(` 已上传 ${done}/${files.length}`)
|
|
157
|
+
|
|
158
|
+
const tree = await call('POST', `/repos/${OWNER}/${REPO}/git/trees`, { tree: entries })
|
|
159
|
+
const message = execFileSync('git', ['-C', ROOT, 'log', '-1', '--pretty=%s'], { encoding: 'utf8' }).trim()
|
|
160
|
+
|
|
161
|
+
// 有上一次的提交就挂成父提交,让远端历史是线性的(不是每次一个孤儿快照)
|
|
162
|
+
let parents = []
|
|
163
|
+
try {
|
|
164
|
+
const head = await call('GET', `/repos/${OWNER}/${REPO}/git/ref/heads/main`)
|
|
165
|
+
if (head?.object?.sha) parents = [head.object.sha]
|
|
166
|
+
} catch {
|
|
167
|
+
/* 首次推送没有父提交 */
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const commit = await call('POST', `/repos/${OWNER}/${REPO}/git/commits`, {
|
|
171
|
+
message: `${message}\n\n(经 GitHub API 推送)`,
|
|
172
|
+
tree: tree.sha,
|
|
173
|
+
parents,
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
let hasMain = true
|
|
177
|
+
try {
|
|
178
|
+
await call('GET', `/repos/${OWNER}/${REPO}/git/ref/heads/main`)
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (!/-> 404|-> 409/.test(error.message)) throw error
|
|
181
|
+
hasMain = false
|
|
182
|
+
}
|
|
183
|
+
if (hasMain) {
|
|
184
|
+
await call('PATCH', `/repos/${OWNER}/${REPO}/git/refs/heads/main`, { sha: commit.sha, force: true })
|
|
185
|
+
} else {
|
|
186
|
+
await call('POST', `/repos/${OWNER}/${REPO}/git/refs`, { ref: 'refs/heads/main', sha: commit.sha })
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.log('')
|
|
190
|
+
console.log(`完成:https://github.com/${OWNER}/${REPO}/tree/main`)
|
|
191
|
+
console.log(`commit ${commit.sha.slice(0, 10)} · ${entries.length} 个文件`)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
main().catch((error) => {
|
|
195
|
+
console.error('失败:' + (error?.message ?? String(error)))
|
|
196
|
+
process.exit(1)
|
|
197
|
+
})
|