dsh-literature-lab 0.2.0 → 0.2.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.
- package/README.md +0 -14
- package/client/src/90-settings.js +2 -2
- package/client.js +2 -2
- package/package.json +1 -1
- package/scripts/make-public.mjs +0 -130
package/README.md
CHANGED
|
@@ -209,20 +209,6 @@ dsh plugin --profile desktop add dsh-literature-lab
|
|
|
209
209
|
- 插件 bundle 不热重载:改完要**完全退出 DSH 再打开**。
|
|
210
210
|
- 内部实现(去重、过滤、各渠道细节、状态机、数据结构)见 [docs/DETAIL.md](docs/DETAIL.md)。
|
|
211
211
|
|
|
212
|
-
### 分支与发布
|
|
213
|
-
|
|
214
|
-
- **`main`**:开发分支,保留完整历史。设计记录与交接笔记放在本地 `local-notes/`,不进仓库。
|
|
215
|
-
- **`public`**:发布分支。由 `node scripts/make-public.mjs` 从 `main` 生成——每次都是**单提交、无父历史**的快照,
|
|
216
|
-
只包含需要发布的文件;作者身份可在生成时覆盖(`--author="Name <email>"`)。
|
|
217
|
-
- 一键生成并推送:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
node scripts/make-public.mjs --push
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
推 `origin`(Gitea)的 `public`,以及 `github` 的 `main`(需先 `git remote add github ...`)。
|
|
224
|
-
- npm 发布:在 `public` 分支上 `npm publish`,`prepublishOnly` 会先构建并跑完测试。
|
|
225
|
-
|
|
226
212
|
## License
|
|
227
213
|
|
|
228
214
|
MIT
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// ── 设置页:左分区导航 + 草稿 + sticky 保存栏 ──────────────
|
|
211
|
-
//
|
|
211
|
+
// 这里只做分区,不新增或删除任何配置项。
|
|
212
212
|
const SETTINGS_SECTIONS = [
|
|
213
213
|
{ id: 'general', label: '抓取' },
|
|
214
214
|
{ id: 'quota', label: '额度' },
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
const [promptDefaults, setPromptDefaults] = useState({});
|
|
262
262
|
const [advancedPrompts, setAdvancedPrompts] = useState(false);
|
|
263
263
|
const narrow = useSettingsNarrow();
|
|
264
|
-
// 有未保存草稿时,外部 config
|
|
264
|
+
// 有未保存草稿时,外部 config 更新不得覆盖它。
|
|
265
265
|
// 用可变标记而不是 state:effect 里要同步读到最新值,且不希望它触发额外渲染。
|
|
266
266
|
const dirtyFlag = useState(() => ({ on: false }))[0];
|
|
267
267
|
|
package/client.js
CHANGED
|
@@ -3851,7 +3851,7 @@ window.__ModuleLoader__.load({
|
|
|
3851
3851
|
}
|
|
3852
3852
|
|
|
3853
3853
|
// ── 设置页:左分区导航 + 草稿 + sticky 保存栏 ──────────────
|
|
3854
|
-
//
|
|
3854
|
+
// 这里只做分区,不新增或删除任何配置项。
|
|
3855
3855
|
const SETTINGS_SECTIONS = [
|
|
3856
3856
|
{ id: 'general', label: '抓取' },
|
|
3857
3857
|
{ id: 'quota', label: '额度' },
|
|
@@ -3904,7 +3904,7 @@ window.__ModuleLoader__.load({
|
|
|
3904
3904
|
const [promptDefaults, setPromptDefaults] = useState({});
|
|
3905
3905
|
const [advancedPrompts, setAdvancedPrompts] = useState(false);
|
|
3906
3906
|
const narrow = useSettingsNarrow();
|
|
3907
|
-
// 有未保存草稿时,外部 config
|
|
3907
|
+
// 有未保存草稿时,外部 config 更新不得覆盖它。
|
|
3908
3908
|
// 用可变标记而不是 state:effect 里要同步读到最新值,且不希望它触发额外渲染。
|
|
3909
3909
|
const dirtyFlag = useState(() => ({ on: false }))[0];
|
|
3910
3910
|
|
package/package.json
CHANGED
package/scripts/make-public.mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 从当前 main 生成「公开分支」:单提交、中性作者、只含要发布的文件。
|
|
4
|
-
*
|
|
5
|
-
* 为什么不用 merge/rebase:公开分支要的是**干净历史**(旧提交里有私有地址与个人邮箱),
|
|
6
|
-
* 所以每次发布都重新造一个无父提交的快照,再强制更新 public 分支。
|
|
7
|
-
*
|
|
8
|
-
* 用法:
|
|
9
|
-
* node scripts/make-public.mjs # 生成 public 分支(不改远端)
|
|
10
|
-
* node scripts/make-public.mjs --push # 同时推 gitea 的 public 与 github 的 main
|
|
11
|
-
* node scripts/make-public.mjs --skip-verify # 跳过 build + test(不推荐)
|
|
12
|
-
* node scripts/make-public.mjs --author="Name <email>" # 覆盖作者身份
|
|
13
|
-
*
|
|
14
|
-
* 前提:工作区干净(否则退出),当前在 main 上。
|
|
15
|
-
*/
|
|
16
|
-
import { execFileSync } from 'node:child_process';
|
|
17
|
-
import { readFileSync, readdirSync, mkdtempSync, rmSync } from 'node:fs';
|
|
18
|
-
import { tmpdir } from 'node:os';
|
|
19
|
-
import path from 'node:path';
|
|
20
|
-
|
|
21
|
-
const PUBLIC_BRANCH = 'public';
|
|
22
|
-
const NEUTRAL_AUTHOR = 'dsh-literature-lab <noreply@users.noreply.github.com>';
|
|
23
|
-
const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..');
|
|
24
|
-
|
|
25
|
-
const argv = process.argv.slice(2);
|
|
26
|
-
const has = (flag) => argv.some((a) => a === flag || a.startsWith(`${flag}=`));
|
|
27
|
-
const valueOf = (flag, fallback) => {
|
|
28
|
-
const hit = argv.find((a) => a.startsWith(`${flag}=`));
|
|
29
|
-
return hit ? hit.slice(flag.length + 1) : fallback;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const author = valueOf('--author', NEUTRAL_AUTHOR);
|
|
33
|
-
const shouldPush = has('--push');
|
|
34
|
-
const skipVerify = has('--skip-verify');
|
|
35
|
-
|
|
36
|
-
function git(args, options = {}) {
|
|
37
|
-
return execFileSync('git', args, { cwd: ROOT, encoding: 'utf8', ...options }).trim();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function fail(message) {
|
|
41
|
-
console.error(`make-public: ${message}`);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ── 1. 前置检查 ──────────────────────────────────────────────
|
|
46
|
-
const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
47
|
-
if (branch !== 'main') fail(`请在 main 上运行(当前:${branch})`);
|
|
48
|
-
const dirty = git(['status', '--porcelain']);
|
|
49
|
-
if (dirty) fail(`工作区不干净,先提交或清理:\n${dirty}`);
|
|
50
|
-
|
|
51
|
-
const pkg = JSON.parse(readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
|
|
52
|
-
|
|
53
|
-
// ── 2. 构建与测试 ────────────────────────────────────────────
|
|
54
|
-
if (!skipVerify) {
|
|
55
|
-
console.log('· 构建 client.js');
|
|
56
|
-
execFileSync(process.execPath, ['scripts/build-client.mjs'], { cwd: ROOT, stdio: 'inherit' });
|
|
57
|
-
const afterBuild = git(['status', '--porcelain']);
|
|
58
|
-
if (afterBuild) fail(`构建改动了文件,说明提交里的 client.js 与源码不同步:\n${afterBuild}`);
|
|
59
|
-
console.log('· 运行测试');
|
|
60
|
-
// execFileSync 不走 shell,glob 要自己展开
|
|
61
|
-
const testFiles = readdirSync(path.join(ROOT, 'test'))
|
|
62
|
-
.filter((f) => f.endsWith('.test.mjs'))
|
|
63
|
-
.sort()
|
|
64
|
-
.map((f) => path.join('test', f));
|
|
65
|
-
execFileSync(process.execPath, ['--test', ...testFiles], { cwd: ROOT, stdio: 'inherit' });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ── 3. 用 HEAD 的树造一个无父提交(不动工作区)───────────────
|
|
69
|
-
const scratch = mkdtempSync(path.join(tmpdir(), 'make-public-'));
|
|
70
|
-
const indexFile = path.join(scratch, 'index');
|
|
71
|
-
const env = { ...process.env, GIT_INDEX_FILE: indexFile };
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
git(['read-tree', 'HEAD'], { env });
|
|
75
|
-
const tree = git(['write-tree'], { env });
|
|
76
|
-
if (!tree) fail('写入树失败');
|
|
77
|
-
|
|
78
|
-
const message = [
|
|
79
|
-
`feat: ${pkg.name} v${pkg.version} — 每日文献发现与精读流水线`,
|
|
80
|
-
'',
|
|
81
|
-
'DeepSeek Harness 插件。从 arXiv / RSS / 跨库检索 / 邮件等渠道采集新论文,',
|
|
82
|
-
'按 L1 摘要判读 → L2 分诊 → L3 精读逐层筛选,只把值得读的论文做精读、',
|
|
83
|
-
'取原文并写入 Zotero。',
|
|
84
|
-
'',
|
|
85
|
-
`本提交由 scripts/make-public.mjs 从 main@${git(['rev-parse', '--short', 'HEAD'])} 生成。`,
|
|
86
|
-
].join('\n');
|
|
87
|
-
|
|
88
|
-
const commit = git(['commit-tree', tree, '-m', message], {
|
|
89
|
-
env: {
|
|
90
|
-
...process.env,
|
|
91
|
-
GIT_AUTHOR_NAME: author.replace(/\s*<.*$/, ''),
|
|
92
|
-
GIT_AUTHOR_EMAIL: (author.match(/<(.+)>/) || [, 'noreply@users.noreply.github.com'])[1],
|
|
93
|
-
GIT_COMMITTER_NAME: author.replace(/\s*<.*$/, ''),
|
|
94
|
-
GIT_COMMITTER_EMAIL: (author.match(/<(.+)>$/) || [, 'noreply@users.noreply.github.com'])[1],
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
if (!commit) fail('创建提交失败');
|
|
98
|
-
|
|
99
|
-
let previous = '';
|
|
100
|
-
try {
|
|
101
|
-
previous = git(['rev-parse', '--verify', '--quiet', PUBLIC_BRANCH], { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
102
|
-
} catch {
|
|
103
|
-
previous = '';
|
|
104
|
-
}
|
|
105
|
-
if (previous) {
|
|
106
|
-
const changed = git(['diff', '--name-only', previous, commit]);
|
|
107
|
-
console.log(changed ? `· 自上次公开以来改动:\n${changed.split('\n').map((f) => ` ${f}`).join('\n')}` : '· 内容与上次公开一致(仅重打时间)');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
git(['branch', '-f', PUBLIC_BRANCH, commit]);
|
|
111
|
-
const files = git(['ls-tree', '-r', '--name-only', commit]).split('\n').filter(Boolean).length;
|
|
112
|
-
console.log(`· 已更新 ${PUBLIC_BRANCH} → ${commit.slice(0, 7)}(${files} 个文件,作者 ${author})`);
|
|
113
|
-
} finally {
|
|
114
|
-
rmSync(scratch, { recursive: true, force: true });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ── 4. 推送(可选)───────────────────────────────────────────
|
|
118
|
-
if (shouldPush) {
|
|
119
|
-
const remotes = git(['remote']).split('\n').filter(Boolean);
|
|
120
|
-
if (remotes.includes('origin')) {
|
|
121
|
-
console.log('· 推送到 origin(Gitea):public');
|
|
122
|
-
git(['push', 'origin', `${PUBLIC_BRANCH}:${PUBLIC_BRANCH}`, '--force'], { stdio: 'inherit' });
|
|
123
|
-
}
|
|
124
|
-
if (remotes.includes('github')) {
|
|
125
|
-
console.log('· 推送到 github:public → main');
|
|
126
|
-
git(['push', 'github', `${PUBLIC_BRANCH}:main`, '--force'], { stdio: 'inherit' });
|
|
127
|
-
} else {
|
|
128
|
-
console.log('· 未配置 github remote,跳过(git remote add github git@github.com:<你>/<仓库>.git)');
|
|
129
|
-
}
|
|
130
|
-
}
|