transproof-dsh-plugin 0.1.4 → 0.1.5

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/app/index.html CHANGED
@@ -1668,6 +1668,8 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
1668
1668
  <tr><td><b>🔎 专名百科自动查证(v4.41 新)</b></td><td>专有译词库「专名核验」卡片每行新增「🔎 查维基」:按外文名查中英维基百科,带回通行译名 + 简介 + 真 URL,人工确认后入词库;已批准专名的背景简介会自动带进翻译/校对提示词。查不到或被拦时给友好提示(开代理 / 换渠道)</td></tr>
1669
1669
  <tr><td><b>🌱 一边译一边填术语表(v4.42 新)</b></td><td>翻译页再勾「翻译时收集新词到译词库」,译完自动把新术语、专业词、反复出现的关键词连同建议译名收进译词库(默认待审核,与「抽专名」互不干扰、自动去重)——术语库不用手敲,越翻越全</td></tr>
1670
1670
  <tr><td><b>📎 导出引用头(v4.43 新)</b></td><td>复制结果弹窗顶部新增「📎 引用头」:可选粘贴 ①中译标题 ②作者(中译名)+ 研究机构 ③APA 格式出处 ④版权声明(CC BY-NC-SA 4.0,仅供个人学习),四样都可勾选;元数据点「🤖 自动提取」从原文抽、查不到的手填,勾选后拼在译文最前面一起复制</td></tr>
1671
+ <tr><td><b>📦 规范包(v4.44 新)</b></td><td>设置页新增「📦 规范包」卡片:把外部规范说明(粘贴文本 / GitHub 链接 / 本地文件)导成可开关的文字包,预览后启用,每次请求自动附带、冲突以内置规则为准,不执行任何第三方脚本</td></tr>
1672
+ <tr><td><b>🔁 错误回流(v4.45 新)</b></td><td>批注卡每条新增三个按钮:「📌术语」把改法存进词库并批准锁定;「🚫禁用」禁止再犯该译法;「✍文风」把理由存进文风偏好——同样的错修一次,以后不再犯</td></tr>
1671
1673
  </tbody>
1672
1674
  </table>
1673
1675
  <div class="alert i" style="margin-top:12px">
@@ -1810,6 +1812,8 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
1810
1812
  <tr><td><b>近期</b></td><td><b>专名百科自动查证</b>:专名核验点「🔎 查维基」直连中英维基百科,带回译名 + 简介 + 真 URL,批准后背景简介进提示词</td><td>✅ 已上线(v4.41.0,专名核验卡片「🔎 查维基」)</td></tr>
1811
1813
  <tr><td><b>近期</b></td><td><b>一边译一边填术语表</b>:翻译页勾「收集新词到译词库」,译完自动把新术语+建议译名收进词库(默认待审、自动去重)</td><td>✅ 已上线(v4.42.0,翻译页「翻译时收集新词到译词库」)</td></tr>
1812
1814
  <tr><td><b>近期</b></td><td><b>导出引用头</b>:复制结果时最前面可选加「中译标题 / 作者+机构 / APA 出处 / 版权声明」四样,元数据 AI 抽 + 手填</td><td>✅ 已上线(v4.43.0,复制结果弹窗「📎 引用头」)</td></tr>
1815
+ <tr><td><b>近期</b></td><td><b>规范包</b>:外部规范说明(粘贴 / GitHub / 本地文件)导成可开关文字包,预览后启用、冲突以内置为准</td><td>✅ 已上线(v4.44.0,设置页「📦 规范包」)</td></tr>
1816
+ <tr><td><b>近期</b></td><td><b>错误回流</b>:批注卡一键「升为术语 / 禁用 / 文风规则」,同样的错修一次以后不再犯</td><td>✅ 已上线(v4.45.0,批注卡三按钮)</td></tr>
1813
1817
  <tr><td><b>云端版</b></td><td><b>改动留痕、可回溯</b>:每次重要校对留下不可篡改的备份点,谁改了什么、当时发生了什么都能查,不再靠猜</td><td>规划中</td></tr>
1814
1818
  </tbody>
1815
1819
  </table>
@@ -1858,5 +1862,6 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
1858
1862
  <script src="js/16-wiki-verify.js"></script>
1859
1863
  <script src="js/17-cite-header.js"></script>
1860
1864
  <script src="js/18-specpack.js"></script>
1865
+ <script src="js/19-error-feedback.js"></script>
1861
1866
  </body>
1862
1867
  </html>
package/app/js/01-core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* ═══════════ 配置与状态 ═══════════ */
2
- const APP_VERSION = '4.44.0'; // 全局版本号:TransProof.version 与 #g-version 标签共用
2
+ const APP_VERSION = '4.45.0'; // 全局版本号:TransProof.version 与 #g-version 标签共用
3
3
  /* 左下角版本显示(v4.39.1) */
4
4
  (function(){
5
5
  function addVerTag(){
@@ -56,6 +56,15 @@ function buildSystem(){
56
56
  });
57
57
  }
58
58
  }
59
+ // T-017:禁用译法(升为禁用后,下次请求禁止使用)
60
+ const _banned = (GLOSS.terms || []).filter(t => t && t.status === 'rejected' && t.recommend === 'ban' && t.foreign);
61
+ if(_banned.length){
62
+ L.push('');
63
+ L.push('【禁用译法】以下译法已被禁止,一律不要使用:');
64
+ _banned.slice(0, 60).forEach(t => {
65
+ L.push('· ' + t.foreign + (t.zh ? '(应译为「' + t.zh + '」)' : ''));
66
+ });
67
+ }
59
68
  }
60
69
 
61
70
  if($('#c-ext').checked){ L.push(''); L.push(TPL.extHeader); L.push(fill(TPL.ext, V)); }
@@ -1544,7 +1544,17 @@ function auditParseLi(li){
1544
1544
  const xm = body.match(/改为\s*[「"'](.+?)[」"']/);
1545
1545
  const frag = ((fm && fm[1]) || '').trim();
1546
1546
  const fix = ((xm && xm[1]) || '').trim();
1547
- return { type: type, frag: frag, fix: fix, fp: type + '|' + frag + '|' + fix };
1547
+ const fi = body.indexOf(fix);
1548
+ let reason = '';
1549
+ if(fix && fi >= 0){
1550
+ reason = body.slice(fi + fix.length);
1551
+ const c0 = reason.charAt(0);
1552
+ if(c0 === '」' || c0 === '"' || c0 === "'") reason = reason.slice(1);
1553
+ const c1 = reason.charAt(0);
1554
+ if(c1 === ':' || c1 === ':') reason = reason.slice(1);
1555
+ reason = reason.trim();
1556
+ }
1557
+ return { type: type, frag: frag, fix: fix, reason: reason, fp: type + '|' + frag + '|' + fix };
1548
1558
  }
1549
1559
  function renderAuditControls(){
1550
1560
  const out = $('#out'); if(!out) return;
@@ -1565,6 +1575,23 @@ function renderAuditControls(){
1565
1575
  btn.classList.toggle('on', done);
1566
1576
  li.classList.toggle('ef-done', done);
1567
1577
  btn.onclick = (ev) => { ev.stopPropagation(); toggleAuditFix(a.fp, li, btn); };
1578
+ // T-017:错误回流三按钮(升为术语 / 禁用 / 文风规则)
1579
+ let promo = li.querySelector('.ef-promote');
1580
+ if(!promo){
1581
+ promo = document.createElement('span');
1582
+ promo.className = 'ef-promote';
1583
+ li.appendChild(promo);
1584
+ }
1585
+ promo.innerHTML = '';
1586
+ function mkPromo(cls, label, title, fn){
1587
+ const b = document.createElement('button');
1588
+ b.type = 'button'; b.className = 'ef-p ' + cls; b.title = title; b.textContent = label;
1589
+ b.onclick = function(ev){ ev.stopPropagation(); if(typeof fn === 'function') fn(auditParseLi(li)); };
1590
+ promo.appendChild(b);
1591
+ }
1592
+ if(typeof efPromoteTerm === 'function') mkPromo('ef-term', '📌术语', '把这个译法存进词库并批准(锁定一致)', efPromoteTerm);
1593
+ if(typeof efPromoteBan === 'function') mkPromo('ef-ban', '🚫禁用', '禁止再使用这个译法(下次请求生效)', efPromoteBan);
1594
+ if(typeof efPromoteStyle === 'function') mkPromo('ef-style', '✍文风', '把理由存进文风偏好(下次请求自动附带)', efPromoteStyle);
1568
1595
  });
1569
1596
  updateFixProgress();
1570
1597
  }
@@ -0,0 +1,82 @@
1
+ /* ═══════════ T-017 错误回流 · 一键升为规则(v4.45.0)═══════════
2
+ 批注卡「升为术语 / 升为禁用 / 升为文风规则」三按钮背后的逻辑。
3
+ 术语/禁用 → GLOSS.terms(saveGloss);文风规则 → PREFS(下次 buildSystem 自动附带)。 */
4
+ (function(){
5
+ 'use strict';
6
+ const EF_SOURCE = 's-err-feedback';
7
+ function efEnsureSource(){
8
+ if(!GLOSS.sources || !GLOSS.sources.some(function(s){ return s && s.id === EF_SOURCE; })){
9
+ GLOSS.sources = GLOSS.sources || [];
10
+ GLOSS.sources.push({ id: EF_SOURCE, name: '错误回流', kind: 'feedback', date: new Date().toISOString(), count: 0 });
11
+ }
12
+ }
13
+ function efAddTag(hit){
14
+ hit.tags = hit.tags || [];
15
+ if(hit.tags.indexOf('错误回流') < 0) hit.tags.push('错误回流');
16
+ if(hit.sources.indexOf(EF_SOURCE) < 0) hit.sources.push(EF_SOURCE);
17
+ }
18
+ function efNote(hit, reason){
19
+ if(reason && (hit.note || '').indexOf(reason) < 0){
20
+ hit.note = (hit.note ? hit.note + ';' : '') + reason;
21
+ }
22
+ }
23
+ function efPromoteTerm(a){
24
+ if(!a || !a.frag || !a.fix){ toast('这条批注缺原文或新译,无法升为术语', 'w'); return false; }
25
+ const from = normText(a.frag), to = normText(a.fix);
26
+ if(!from || !to){ toast('这条批注缺原文或新译', 'w'); return false; }
27
+ efEnsureSource();
28
+ const fk = fKey(from);
29
+ let hit = (GLOSS.terms || []).find(function(t){ return t && t.foreign && fKey(t.foreign) === fk; });
30
+ if(hit){
31
+ if(hit.status === 'confirmed' && hit.zh !== to){
32
+ hit.aliases = hit.aliases || [];
33
+ if(hit.aliases.indexOf(to) < 0) hit.aliases.push(to);
34
+ } else {
35
+ hit.zh = to; hit.status = 'confirmed'; hit.recommend = 'rec';
36
+ }
37
+ efNote(hit, a.reason); efAddTag(hit); hit.updated = Date.now();
38
+ } else {
39
+ GLOSS.terms.push({ id: GID++, zh: to, foreign: from, aliases: [], type: guessType(to, from),
40
+ tags: ['错误回流'], note: a.reason || '', sources: [EF_SOURCE], occurrences: [],
41
+ collections: [], status: 'confirmed', recommend: 'rec', url: '', created: Date.now(), updated: Date.now() });
42
+ }
43
+ saveGloss(); glossLog('feedback', 'term:' + from, null, { to: to, reason: a.reason });
44
+ if(typeof renderGloss === 'function') renderGloss();
45
+ toast('已升为术语 ✓ 「' + from + '」→「' + to + '」');
46
+ return true;
47
+ }
48
+ function efPromoteBan(a){
49
+ if(!a || !a.frag){ toast('这条批注缺原文', 'w'); return false; }
50
+ const from = normText(a.frag), to = normText(a.fix || '');
51
+ efEnsureSource();
52
+ const fk = fKey(from);
53
+ let hit = (GLOSS.terms || []).find(function(t){ return t && t.foreign && fKey(t.foreign) === fk; });
54
+ if(hit){
55
+ hit.status = 'rejected'; hit.recommend = 'ban';
56
+ if(to) hit.zh = to;
57
+ efNote(hit, a.reason); efAddTag(hit); hit.updated = Date.now();
58
+ } else {
59
+ GLOSS.terms.push({ id: GID++, zh: to, foreign: from, aliases: [], type: guessType(to, from),
60
+ tags: ['错误回流'], note: a.reason || '', sources: [EF_SOURCE], occurrences: [],
61
+ collections: [], status: 'rejected', recommend: 'ban', url: '', created: Date.now(), updated: Date.now() });
62
+ }
63
+ saveGloss(); glossLog('feedback', 'ban:' + from, null, { to: to, reason: a.reason });
64
+ if(typeof renderGloss === 'function') renderGloss();
65
+ toast('已升为禁用 ✕ 「' + from + '」' + (to ? '(应译为「' + to + '」)' : ''));
66
+ return true;
67
+ }
68
+ function efPromoteStyle(a){
69
+ if(!a || (!a.reason && !a.fix)){ toast('这条批注缺规则内容', 'w'); return false; }
70
+ const rule = normText(a.reason || (a.frag + ' → ' + a.fix));
71
+ if(!rule){ toast('这条批注缺规则内容', 'w'); return false; }
72
+ if(String(PREFS || '').indexOf(rule) >= 0){ toast('这条规则已在文风偏好里', 'w'); return false; }
73
+ PREFS = (String(PREFS || '').trim() ? PREFS.trim() + String.fromCharCode(10) : '') + rule;
74
+ save(LS.prefs, PREFS);
75
+ const el = $('#prefs'); if(el) el.value = PREFS;
76
+ toast('已升为文风规则 ✓(下次请求自动附带)');
77
+ return true;
78
+ }
79
+ window.efPromoteTerm = efPromoteTerm;
80
+ window.efPromoteBan = efPromoteBan;
81
+ window.efPromoteStyle = efPromoteStyle;
82
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transproof-dsh-plugin",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "译校助手 TransProof 的 DeepSeek Harness 插件薄壳原型:把纯前端网页包进 DSH 页面入口 + 暴露「跑本地体检」Agent 工具。本地体检保持纯 JS 不联网。",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",