dsh-source-cnki 0.0.0-stage → 0.1.1
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 +52 -0
- package/LICENSE +201 -0
- package/README-zh.md +106 -0
- package/README.md +105 -2
- package/SECURITY.md +19 -0
- package/THIRD_PARTY_NOTICES.md +10 -0
- package/cordis.patch.yml +17 -0
- package/lib/cite.d.ts +33 -0
- package/lib/cite.d.ts.map +1 -0
- package/lib/cite.js +117 -0
- package/lib/cite.js.map +1 -0
- package/lib/config.d.ts +32 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +44 -0
- package/lib/config.js.map +1 -0
- package/lib/formats.d.ts +61 -0
- package/lib/formats.d.ts.map +1 -0
- package/lib/formats.js +217 -0
- package/lib/formats.js.map +1 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +1 -0
- package/lib/runtime.d.ts +84 -0
- package/lib/runtime.d.ts.map +1 -0
- package/lib/runtime.js +228 -0
- package/lib/runtime.js.map +1 -0
- package/lib/tools/cnki-check.d.ts +12 -0
- package/lib/tools/cnki-check.d.ts.map +1 -0
- package/lib/tools/cnki-check.js +56 -0
- package/lib/tools/cnki-check.js.map +1 -0
- package/lib/tools/cnki-cite.d.ts +12 -0
- package/lib/tools/cnki-cite.d.ts.map +1 -0
- package/lib/tools/cnki-cite.js +62 -0
- package/lib/tools/cnki-cite.js.map +1 -0
- package/lib/tools/cnki-import.d.ts +12 -0
- package/lib/tools/cnki-import.d.ts.map +1 -0
- package/lib/tools/cnki-import.js +75 -0
- package/lib/tools/cnki-import.js.map +1 -0
- package/lib/tools/shared.d.ts +20 -0
- package/lib/tools/shared.d.ts.map +1 -0
- package/lib/tools/shared.js +14 -0
- package/lib/tools/shared.js.map +1 -0
- package/lib/validate.d.ts +29 -0
- package/lib/validate.d.ts.map +1 -0
- package/lib/validate.js +51 -0
- package/lib/validate.js.map +1 -0
- package/lib/version.d.ts +7 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +7 -0
- package/lib/version.js.map +1 -0
- package/package.json +81 -4
- package/src/cite.ts +124 -0
- package/src/config.ts +64 -0
- package/src/formats.ts +236 -0
- package/src/index.ts +62 -0
- package/src/runtime.ts +254 -0
- package/src/tools/cnki-check.ts +56 -0
- package/src/tools/cnki-cite.ts +62 -0
- package/src/tools/cnki-import.ts +74 -0
- package/src/tools/shared.ts +14 -0
- package/src/validate.ts +65 -0
- package/src/version.ts +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.1] - 2026-11-08
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Release-engineering refresh: CHANGELOG accuracy, package metadata and authors; no runtime changes.
|
|
12
|
+
|
|
13
|
+
## [0.1.0] - 2026-11-08
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `cnki_cite`/`cnki_check` now validate imported record objects and return
|
|
18
|
+
`INVALID_INPUT` for malformed JSON payloads instead of throwing a `TypeError`.
|
|
19
|
+
- `cnki_import` rejects non-string `text` and unknown `format` values at the
|
|
20
|
+
runtime boundary; `cnki_cite` rejects `startIndex < 1`.
|
|
21
|
+
- The implausible-year check used a hard-coded upper bound of 2100; it now
|
|
22
|
+
accepts the current year plus one and rejects genuinely far-future dates.
|
|
23
|
+
- RIS and labeled parsers normalize CRLF/CR line endings and strip a leading
|
|
24
|
+
UTF-8 BOM. Windows-authored exports previously produced zero records (RIS) or
|
|
25
|
+
lost the first field (labeled).
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Tests for malformed records, `null` text, invalid `startIndex`, symlink
|
|
30
|
+
escape, far-future years, CRLF/BOM exports, and the function-plugin mount
|
|
31
|
+
contract (23 tests total).
|
|
32
|
+
|
|
33
|
+
First release: Chinese-literature export import and citation formatting.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- `cnki_import`: RIS/EndNote-style and labeled (`题名:`) export parsing,
|
|
38
|
+
stable record ids (DOI-based when available), language detection, and
|
|
39
|
+
structural validation; the export becomes REP evidence when persisted.
|
|
40
|
+
- `cnki_cite`: GB/T 7714-2015 顺序编码制 (with or without `[n]`) and APA 7,
|
|
41
|
+
including the ≤3 / >3 author rules and `等` / `et al` handling.
|
|
42
|
+
- `cnki_check`: structural issues (missing fields, implausible year, malformed
|
|
43
|
+
DOI, odd pages, duplicates).
|
|
44
|
+
- 18 tests.
|
|
45
|
+
|
|
46
|
+
### Notes
|
|
47
|
+
|
|
48
|
+
- **No CNKI access of any kind**: no login, no scraping, no CNKI API. The user
|
|
49
|
+
exports; the plugin parses. This is a deliberate scope and licensing decision,
|
|
50
|
+
not a missing feature.
|
|
51
|
+
- Missing fields are reported, never invented.
|
|
52
|
+
- GB/T 著者-出版年制 and `[J/OL]`/`[EB/OL]` carriers are out of scope in v0.1.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README-zh.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# dsh-source-cnki
|
|
2
|
+
|
|
3
|
+
**中文文献记录:导入你自己的导出文件,按 GB/T 7714 引用,检查元数据——全程不抓取 CNKI。**
|
|
4
|
+
|
|
5
|
+
*不登录、不抓取、不调用 CNKI API(该用途没有公开 API)。插件读取 RIS/EndNote 风格或带标签的文本导出,分配稳定的记录 id,按 GB/T 7714-2015(顺序编码制)或 APA 7 排版,并做结构校验。*
|
|
6
|
+
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[]()
|
|
9
|
+
|
|
10
|
+
[English](README.md) · 简体中文
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 范围说明(请先阅读)
|
|
15
|
+
|
|
16
|
+
CNKI 没有面向此用途的公开 API。因此本插件**不会**登录、抓取或绕过任何访问控制。记录由你自行导出(RIS/EndNote 风格标签文本,或带 `题名:`/`作者:`/`来源:` 的标签文本),插件只在这份导出上工作。如果导出缺少某个字段,插件会明确说“缺失”,绝不会凭空编造期刊、年份、卷、页码或 DOI。
|
|
17
|
+
|
|
18
|
+
## 它做什么
|
|
19
|
+
|
|
20
|
+
- **`cnki_import`** — 解析 RIS/EndNote 风格和带标签的文本导出,分配稳定的 `recordId`(有 DOI 时基于 DOI,否则基于标题+年份),识别语言并校验结构。开启 `persist` 时,导出会成为 REP 证据。
|
|
21
|
+
- **`cnki_cite`** — 支持 GB/T 7714-2015 顺序编码制(`[1] 作者. 题名[J]. 刊名, 年, 卷(期): 页码.`)、同样格式但不带编号,或 APA 7。作者规则:GB/T 在作者不超过 3 位时全部列出,否则列前 3 位 + `等`/`et al`;西文姓名转为 `SURNAME I`;APA 转为 `Surname, I.`。
|
|
22
|
+
- **`cnki_check`** — 结构校验:缺少标题/期刊/年份/作者、年份不合理、DOI 格式错误、页码非数字、重复记录,以及有期刊但没有卷或期。
|
|
23
|
+
|
|
24
|
+
## 它不做什么
|
|
25
|
+
|
|
26
|
+
- **不访问 CNKI。** 不登录、不使用 cookie、不抓取、不调用非官方端点。
|
|
27
|
+
- **不核实内容。** 不检查记录与真实论文是否一致;DOI 核验请用 `dsh-cite-verify`。
|
|
28
|
+
- **不提供语义字段。** 没有被引次数、影响因子或基金编号。
|
|
29
|
+
- **不处理 DOCX/PDF。** 请导出为 RIS/带标签文本(PDF 文本提取用 `dsh-doc-anchor`)。
|
|
30
|
+
- **不宣称覆盖 GB/T 的全部情形。** 该标准存在变体(著者-出版年制、[EB/OL] 载体、带 URL 的 [J/OL]);v0.1 实现常见的期刊/学位论文/会议/图书情形,并如实说明这一点。
|
|
31
|
+
|
|
32
|
+
## 格式
|
|
33
|
+
|
|
34
|
+
| 格式 | 可识别内容 |
|
|
35
|
+
|---|---|
|
|
36
|
+
| RIS/EndNote | `TY`、`AU`、`TI`、`JO`、`PY`、`VL`、`IS`、`SP`、`EP`、`DO`、`KW`、`AB`、`ER`(每个字段以第一个标签为准,作者累加) |
|
|
37
|
+
| 带标签文本 | `题名`/`标题`/`篇名`、`作者`、`来源`/`刊名`、`年`/`发表时间`、`卷`、`期`、`页码`、`DOI`、`关键词`、`摘要`、`类型`;空行分隔记录 |
|
|
38
|
+
|
|
39
|
+
未知标签会被忽略,不做猜测。
|
|
40
|
+
|
|
41
|
+
## 工具
|
|
42
|
+
|
|
43
|
+
### `cnki_import`
|
|
44
|
+
|
|
45
|
+
`{ text? | path?, format?, persist? }` → `{ ok, records, validation, evidenceId?, recordPath? }`.
|
|
46
|
+
|
|
47
|
+
### `cnki_cite`
|
|
48
|
+
|
|
49
|
+
`{ records, style?, startIndex? }` → `{ ok, citations, text }`.
|
|
50
|
+
|
|
51
|
+
### `cnki_check`
|
|
52
|
+
|
|
53
|
+
`{ records }` → `{ ok, validation }`.
|
|
54
|
+
|
|
55
|
+
### 错误码
|
|
56
|
+
|
|
57
|
+
`INVALID_INPUT` · `NOT_FOUND` · `PATH_ESCAPE` · `NOT_A_FILE` · `TOO_LARGE` · `UNSUPPORTED_FILE` · `NO_RECORDS` · `STORE_ERROR`
|
|
58
|
+
|
|
59
|
+
## 兼容性与安装
|
|
60
|
+
|
|
61
|
+
| | |
|
|
62
|
+
|---|---|
|
|
63
|
+
| DeepSeek Harness | **`dsh-v0.2.1-rc.5`**(2026-11-08 实测);peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
|
|
64
|
+
| Node | `^22.19.0 \|\| >=24.9.0`(实测 `24.22.1`),仅 ESM |
|
|
65
|
+
| Peer 依赖 | `@perrylink/dsh-research-core ^0.1.0`、`@deepseek-ai/cordis ^4.0.5-alpha.1`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/schemastery ^3.18.5-alpha.1` |
|
|
66
|
+
| 运行时依赖 | **零** |
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-source-cnki
|
|
70
|
+
dsh --profile <name> --dump-config | grep dsh-source-cnki
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 配置
|
|
74
|
+
|
|
75
|
+
| 键 | 默认值 | 含义 |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `enabled` | `true` | `false` 时不挂载任何内容 |
|
|
78
|
+
| `root` | `.source-cnki` | 存储/记录根目录 |
|
|
79
|
+
| `workspaceRoot` | `process.cwd()` | 路径必须解析到该目录内 |
|
|
80
|
+
| `maxChars` | `2000000` | 导出文件上限(超限即失败,绝不截断) |
|
|
81
|
+
| `persist` | `true` | 把导出存为 REP 证据 + 记录 |
|
|
82
|
+
| `style` | `gbt7714-numeric` | 默认引用格式 |
|
|
83
|
+
|
|
84
|
+
## 安全边界
|
|
85
|
+
|
|
86
|
+
- 完全无网络:不访问 CNKI,不做 DOI 解析,不上报遥测。
|
|
87
|
+
- 对导出文件只读;只在 `root` 下写入。
|
|
88
|
+
- `realpath` 包含性校验;DOCX/PDF 会被拒绝并给出转换提示。
|
|
89
|
+
- 导出文件视为数据。标题或摘要中的指令性文本永远不会被执行(没有执行器)。
|
|
90
|
+
|
|
91
|
+
## 评测
|
|
92
|
+
|
|
93
|
+
**23 个测试**:RIS 与带标签解析(中英文记录、CRLF/BOM 导出、基于 DOI 的 id、语言识别)、自动格式识别与空内容/无法识别内容的拒绝、GB/T 期刊引用(页码使用 en dash 连接)、≤3 位与 >3 位作者规则(等 / et al)、缺期刊标记、学位论文标记、顺序编号、APA 的作者/年份/期刊/卷/DOI、校验代码(缺标题/期刊、不合理年份(含极远未来日期)、DOI 格式错误、页码异常、重复)、运行时(有效 REP 记录、cite/check、路径穿越/符号链接/DOCX/超大文件拒绝、畸形记录与 `null` 文本拒绝)、工具 schema、import→cite→check 端到端、失败分支、插件契约、包契约。
|
|
94
|
+
|
|
95
|
+
不宣称任何基准成绩:基准真值就是你的导出文件;格式化器的正确性按上面的 GB/T 规则用 fixture 校验。
|
|
96
|
+
|
|
97
|
+
## 已知限制(v0.1)
|
|
98
|
+
|
|
99
|
+
- 未实现 GB/T 7714 著者-出版年制、`[J/OL]`/`[EB/OL]` 载体以及英文期刊缩写规则。
|
|
100
|
+
- 会议与图书记录复用 `journal` 字段存放会议录/出版社信息(导出格式通常没有独立字段)。
|
|
101
|
+
- 解析按行进行;带标签导出中折了很多行的摘要可能并入上一个字段。
|
|
102
|
+
- 除导出文件本身包含的内容外,不保留 CNKI 记录 id(`CNKI:`/`DBID`)。
|
|
103
|
+
|
|
104
|
+
## 许可
|
|
105
|
+
|
|
106
|
+
Apache-2.0。运行时零第三方代码。
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-source-cnki
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Chinese-literature records: import your export, cite it in GB/T 7714, check the metadata — without scraping CNKI.**
|
|
4
|
+
|
|
5
|
+
*No login, no scraping, no CNKI API (none is public for this purpose). The plugin reads RIS/EndNote-style or labeled text exports, assigns stable record ids, formats GB/T 7714-2015 (顺序编码制) or APA 7, and runs structural validation.*
|
|
6
|
+
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[]()
|
|
9
|
+
|
|
10
|
+
English · [简体中文](README-zh.md)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Scope decision (read first)
|
|
15
|
+
|
|
16
|
+
CNKI has no public API for this purpose. This plugin therefore **does not** log in, scrape, or bypass any access control. You export the records yourself (RIS/EndNote-style tagged text, or labeled text with `题名:`/`作者:`/`来源:`), and the plugin works on that export. If your export lacks a field, the plugin says "missing" — it never invents a journal, year, volume, page range or DOI.
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
|
|
20
|
+
- **`cnki_import`** — parses RIS/EndNote-style and labeled text exports, assigns a stable `recordId` (DOI-based when present, otherwise title+year), detects language, and validates structure. The export becomes REP evidence when `persist` is on.
|
|
21
|
+
- **`cnki_cite`** — GB/T 7714-2015 顺序编码制 (`[1] 作者. 题名[J]. 刊名, 年, 卷(期): 页码.`), the same without numbering, or APA 7. Author rules: GB/T ≤3 all, otherwise first 3 + `等`/`et al`; Western names become `SURNAME I`; APA becomes `Surname, I.`.
|
|
22
|
+
- **`cnki_check`** — structural validation: missing title/journal/year/authors, implausible year, malformed DOI, non-numeric pages, duplicates, journal without volume or issue.
|
|
23
|
+
|
|
24
|
+
## What it does not do
|
|
25
|
+
|
|
26
|
+
- **No CNKI access.** No login, no cookies, no scraping, no unofficial endpoints.
|
|
27
|
+
- **No content verification.** It does not check that the record matches the real paper; use `dsh-cite-verify` for DOIs.
|
|
28
|
+
- **No semantic fields.** No cited-by counts, impact factors or fund numbers.
|
|
29
|
+
- **No DOCX/PDF.** Export as RIS/labeled text (PDF text extraction: `dsh-doc-anchor`).
|
|
30
|
+
- **No claim of GB/T completeness.** Variants exist (著者-出版年制, [EB/OL] carriers, [J/OL] with URLs); v0.1 implements the common journal/thesis/conference/book cases and says so.
|
|
31
|
+
|
|
32
|
+
## Formats
|
|
33
|
+
|
|
34
|
+
| Format | Recognized |
|
|
35
|
+
|---|---|
|
|
36
|
+
| RIS/EndNote | `TY`, `AU`, `TI`, `JO`, `PY`, `VL`, `IS`, `SP`, `EP`, `DO`, `KW`, `AB`, `ER` (first tag wins per field, authors accumulate) |
|
|
37
|
+
| Labeled text | `题名`/`标题`/`篇名`, `作者`, `来源`/`刊名`, `年`/`发表时间`, `卷`, `期`, `页码`, `DOI`, `关键词`, `摘要`, `类型`; blank line separates records |
|
|
38
|
+
|
|
39
|
+
Unknown tags are ignored, not guessed.
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
### `cnki_import`
|
|
44
|
+
|
|
45
|
+
`{ text? | path?, format?, persist? }` → `{ ok, records, validation, evidenceId?, recordPath? }`.
|
|
46
|
+
|
|
47
|
+
### `cnki_cite`
|
|
48
|
+
|
|
49
|
+
`{ records, style?, startIndex? }` → `{ ok, citations, text }`.
|
|
50
|
+
|
|
51
|
+
### `cnki_check`
|
|
52
|
+
|
|
53
|
+
`{ records }` → `{ ok, validation }`.
|
|
54
|
+
|
|
55
|
+
### Error codes
|
|
56
|
+
|
|
57
|
+
`INVALID_INPUT` · `NOT_FOUND` · `PATH_ESCAPE` · `NOT_A_FILE` · `TOO_LARGE` · `UNSUPPORTED_FILE` · `NO_RECORDS` · `STORE_ERROR`
|
|
58
|
+
|
|
59
|
+
## Compatibility & install
|
|
60
|
+
|
|
61
|
+
| | |
|
|
62
|
+
|---|---|
|
|
63
|
+
| DeepSeek Harness | **`dsh-v0.2.1-rc.5`** (verified 2026-11-08); peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
|
|
64
|
+
| Node | `^22.19.0 \|\| >=24.9.0` (tested `24.22.1`), ESM only |
|
|
65
|
+
| Peers | `@perrylink/dsh-research-core ^0.1.0`, `@deepseek-ai/cordis ^4.0.5-alpha.1`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/schemastery ^3.18.5-alpha.1` |
|
|
66
|
+
| Runtime dependencies | **zero** |
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-source-cnki
|
|
70
|
+
dsh --profile <name> --dump-config | grep dsh-source-cnki
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
| Key | Default | Meaning |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `enabled` | `true` | `false` mounts nothing |
|
|
78
|
+
| `root` | `.source-cnki` | store/record root |
|
|
79
|
+
| `workspaceRoot` | `process.cwd()` | paths must resolve inside it |
|
|
80
|
+
| `maxChars` | `2000000` | export cap (fails, never truncates) |
|
|
81
|
+
| `persist` | `true` | store the export as REP evidence + record |
|
|
82
|
+
| `style` | `gbt7714-numeric` | default citation style |
|
|
83
|
+
|
|
84
|
+
## Security boundaries
|
|
85
|
+
|
|
86
|
+
- No network at all: no CNKI, no DOI resolution, no telemetry.
|
|
87
|
+
- Read-only on the export; writes only under `root`.
|
|
88
|
+
- `realpath` containment; DOCX/PDF rejected with a conversion hint.
|
|
89
|
+
- The export is data. Instruction-like text inside a title or abstract is never executed (there is no executor).
|
|
90
|
+
|
|
91
|
+
## Evaluation
|
|
92
|
+
|
|
93
|
+
**23 tests**: RIS and labeled parsing (Chinese and English records, CRLF/BOM exports, DOI-based ids, language detection), auto-detection and empty/unrecognized rejection, GB/T journal citation with en-dash pages, ≤3 vs >3 author rules (等 / et al), missing-journal marker, thesis marker, sequential numbering, APA author/year/journal/volume/DOI, validation codes (missing title/journal, implausible year including far-future dates, malformed DOI, odd pages, duplicates), runtime (valid REP record, cite/check, traversal/symlink/DOCX/oversize rejection, malformed records and `null` text rejected), tool schemas, import→cite→check end to end, failure branches, plugin contract, package contract.
|
|
94
|
+
|
|
95
|
+
No benchmark is claimed: the ground truth is your export; correctness of the formatter is checked against the GB/T rules above with fixtures.
|
|
96
|
+
|
|
97
|
+
## Known limitations (v0.1)
|
|
98
|
+
|
|
99
|
+
- GB/T 7714 著者-出版年制, `[J/OL]`/`[EB/OL]` carriers and English journal abbreviation rules are not implemented.
|
|
100
|
+
- Conference and book records reuse the `journal` field for proceedings/publisher (the export formats rarely carry separate fields).
|
|
101
|
+
- Parsing is line-oriented; deeply wrapped multi-line abstracts in labeled exports may merge into the previous field.
|
|
102
|
+
- No CNKI record id (`CNKI:`/`DBID`) retention beyond what the export contains.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
Apache-2.0. No third-party runtime code.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
The latest published `0.1.x` release of this package receives security fixes.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Please use GitHub's private vulnerability reporting (Security → Advisories) on
|
|
10
|
+
the repository, or open a minimal issue asking for a private channel if
|
|
11
|
+
advisories are unavailable. Do not include credentials, personal data or
|
|
12
|
+
working exploits in a public issue.
|
|
13
|
+
|
|
14
|
+
## Scope notes
|
|
15
|
+
|
|
16
|
+
- This package performs local file analysis only unless its README documents a
|
|
17
|
+
network provider; when it does, only the documented hosts are contacted.
|
|
18
|
+
- Inputs are treated as untrusted data: document text is never executed.
|
|
19
|
+
- No secrets are read or written by the package.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
This package contains **no third-party runtime code**: `dependencies` is empty.
|
|
4
|
+
|
|
5
|
+
Development-only tooling (TypeScript, Vitest, `@deepseek-ai/*` type packages and
|
|
6
|
+
the shared `@perrylink/dsh-research-core` peer, when present) is not bundled and
|
|
7
|
+
is not distributed in the published tarball.
|
|
8
|
+
|
|
9
|
+
If that ever changes, the affected license texts must be added here before a
|
|
10
|
+
release.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# dsh-source-cnki bundle patch: mount the Chinese-literature tools.
|
|
2
|
+
#
|
|
3
|
+
# Every key below is a Config field (Schemastery schema); invalid values fail the
|
|
4
|
+
# profile load loudly. Local export parsing only: no login, no scraping, no CNKI
|
|
5
|
+
# API (none is public for this purpose).
|
|
6
|
+
- insert:
|
|
7
|
+
- id: dsh-source-cnki
|
|
8
|
+
name: dsh-source-cnki
|
|
9
|
+
config:
|
|
10
|
+
enabled: true
|
|
11
|
+
root: .source-cnki
|
|
12
|
+
# Character cap for an export: over-limit fails, never truncates.
|
|
13
|
+
maxChars: 2000000
|
|
14
|
+
# Store the parsed export as REP evidence + record.
|
|
15
|
+
persist: true
|
|
16
|
+
# Default citation style.
|
|
17
|
+
style: gbt7714-numeric
|
package/lib/cite.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Citation formatting: GB/T 7714-2015 (顺序编码制) and APA 7th.
|
|
3
|
+
*
|
|
4
|
+
* Only fields present in the record are emitted — nothing is invented (no
|
|
5
|
+
* publisher, place or page range is guessed). The README lists the mapping and
|
|
6
|
+
* the simplifications.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-source-cnki/cite
|
|
9
|
+
*/
|
|
10
|
+
import type { BibRecord } from './formats.ts';
|
|
11
|
+
/** Citation styles. */
|
|
12
|
+
export type CiteStyle = 'gbt7714' | 'gbt7714-numeric' | 'apa';
|
|
13
|
+
/** Formatting options. */
|
|
14
|
+
export interface CiteOptions {
|
|
15
|
+
readonly style?: CiteStyle;
|
|
16
|
+
/** First number for the numeric style (default 1). */
|
|
17
|
+
readonly startIndex?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Format one citation.
|
|
21
|
+
* @param record - the record.
|
|
22
|
+
* @param options - style and starting number.
|
|
23
|
+
* @returns the formatted citation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatCitation(record: BibRecord, options?: CiteOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format a bibliography.
|
|
28
|
+
* @param records - the records, in citation order.
|
|
29
|
+
* @param options - style and starting number.
|
|
30
|
+
* @returns one formatted string per record.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatBibliography(records: readonly BibRecord[], options?: CiteOptions): string[];
|
|
33
|
+
//# sourceMappingURL=cite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cite.d.ts","sourceRoot":"","sources":["../src/cite.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,uBAAuB;AACvB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,iBAAiB,GAAG,KAAK,CAAA;AAE7D,0BAA0B;AAC1B,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAqDD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAiCnF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,EAAE,CAGrG"}
|