dsh-form-fill-agent 0.2.18 → 0.2.20

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  AI填表智能体:支持自动填表、表格填充、表格补全、Excel填表与 Excel回填;使用企查查 MCP 填写 XLSX 空白字段,预览确认后导出新副本。
6
6
 
7
7
  ```sh
8
- dsh plugin --profile web add dsh-form-fill-agent@0.2.18
8
+ dsh plugin --profile web add dsh-form-fill-agent@0.2.20
9
9
  ```
10
10
 
11
11
  请先满足下文的 DSH、连接器及侧边栏依赖要求;安装后完整停止并重启对应 Profile。
@@ -55,7 +55,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
55
55
  - 结果筛选显示当前/总数及已选格数,下载始终包含全部确认内容。
56
56
  - 简单 XLSX 安全解析、工作表与表头识别、企业名称或信用代码锚点识别。
57
57
  - 确定性字段语义映射、只填空白、单元格级预览与来源追溯。
58
- - 133 字段目录:工商、企业简介、联系方式、上市、开票、进出口、自身及关联风险、实际控制人。唯一完整实控人记录可填写,多名/分页/异常留空待核验。事实和确定性摘要区分来源,不生成风险结论。
58
+ - 137 字段目录:工商、企业简介、联系方式、上市、开票、进出口、自身及关联风险、实际控制人。唯一完整实控人记录可填写,多名/分页/异常留空待核验。事实和确定性摘要区分来源,不生成风险结论。
59
59
  - 五步工作台、指令回填、任务历史、可恢复单元格选择、取消/失败重试与重启恢复。
60
60
  - 可选择工作表、表头行并修正字段映射;修改后需重新预览。
61
61
  - 查询主体不一致时展示返回候选,人工选择或补充已核验的完整主体后重新查询,原表名称不覆盖。
@@ -64,7 +64,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
64
64
 
65
65
  ## 使用边界与数据保存
66
66
 
67
- 补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.18,共享内核为 0.2.10,Provider 为 0.2.1,共享字段契约为 0.1.0。
67
+ 补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.20,共享内核为 0.2.10,Provider 为 0.2.2,共享字段契约为 0.1.0。
68
68
 
69
69
  支持企业完整登记名称或 18 位信用代码;简称、主体不一致或多候选不会自动猜选。仅有信用代码的表格也可作为查询锚点。连接候选检索工具时可检索简称,仍需人工确认;缺少工具时降级人工输入。字段映射采用确定性规则及人工确认,不让模型编造事实。支持普通内部公式、固定区域下拉、基础条件格式和普通表格对象;复杂 Excel 结构和 Word 暂不支持,保真边界见下方安全说明。
70
70
 
@@ -72,7 +72,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
72
72
 
73
73
  显式设置 DSH_HOME 时,任务保存至其 form-fill-tasks 目录,默认 24 小时过期;未设置时使用内存。任务保存输入表格和归一化预览,不持久化原始 MCP 响应,可主动删除任务。模型及 MCP 凭据由宿主管理。
74
74
 
75
- 0.2.18 保存任务 schema 5,兼容读取旧 schema 1–4;回退旧版本须使用升级前任务目录副本或新目录,防止丢失已确认的字段/主体设置。
75
+ 0.2.20 保存任务 schema 5,兼容读取旧 schema 1–4;回退旧版本须使用升级前任务目录副本或新目录,防止丢失已确认的字段/主体设置。
76
76
 
77
77
  ## 文档与反馈
78
78
 
@@ -44,5 +44,5 @@ export function renderEnrichmentResult(value) {
44
44
  const reasons=value.diagnostics?.reasons||[];
45
45
  return 'AI填表:可填写 '+value.filled+' 格,未完成 '+value.incomplete+' 项。'
46
46
  +(reasons.length?'原因分类:'+reasons.map(r=>r.label+' '+r.count+r.unit).join(';')+'。':'')
47
- +'可填写仅代表预览,尚未写入副本;必须在工作台确认后下载。未完成包含范围排除、映射或查询问题,不可统一解释为企查查查不到。预览:'+value.previewPath;
47
+ +'可填写仅代表预览,尚未写入副本;必须在工作台确认后下载。未完成包含范围排除、映射或查询问题,不可统一解释为企查查查不到,也不能仅凭可填写为 0 推断授权异常;请依据具体错误记录。预览:'+value.previewPath;
48
48
  }
package/lib/http.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { randomUUID, createHash } from 'node:crypto';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { applyChangeSet, parseWorkbook } from 'form-fill-core';
4
- import { FIELD_CATALOG, QCC_FIELD_CATALOG, ACTUAL_CONTROLLER_GROUP, isCompleteAnchor } from 'qcc-form-fill-provider';
4
+ import { FIELD_CATALOG, QCC_FIELD_CATALOG, ACTUAL_CONTROLLER_GROUP, SNAPSHOT_GROUPS, isCompleteAnchor } from 'qcc-form-fill-provider';
5
5
  import { previewBytes } from './workflow.js';
6
6
  import { createTaskStore } from './task-store.js';
7
7
  import { allCandidates, selectCandidates } from './task-model.js';
8
8
  import { gridPage } from './grid.js';
9
9
  import { diagnostics } from './diagnostics.js';
10
- import { mappingRecommendations } from './mapping-recommendations.js';
10
+ import { mappingRecommendations, mappingSearchAliases } from './mapping-recommendations.js';
11
11
  const XLSX_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
12
12
  const FIXTURES = ['客户台账', '供应商准入表', '合同主体信息表'];
13
13
  export function createFormFillHandler({ basePath = '', getPort, now = Date.now, ttlMs = 15 * 60 * 1000, maxTasks = 10, taskDirectory, getQccStatus = () => false } = {}) {
@@ -26,8 +26,8 @@ export function createFormFillHandler({ basePath = '', getPort, now = Date.now,
26
26
  progress: task.progress,
27
27
  candidates: allCandidates(task).changes,
28
28
  selectedIds: task.preview.changeSet.changes.map(c=>c.id),
29
- catalog: FIELD_CATALOG,
30
- catalogGroups: [...QCC_FIELD_CATALOG,ACTUAL_CONTROLLER_GROUP].map(g=>({id:g.id,label:g.label,fields:g.fields.flatMap(item=>FIELD_CATALOG.filter(f=>f.key===item.id||f.aliases?.includes(item.id)).map(f=>f.key))})),
29
+ catalog: FIELD_CATALOG.map(field=>({...field,searchAliases:mappingSearchAliases(field.key)})),
30
+ catalogGroups: [...QCC_FIELD_CATALOG,ACTUAL_CONTROLLER_GROUP,...SNAPSHOT_GROUPS].map(g=>({id:g.id,label:g.label,fields:g.fields.flatMap(item=>FIELD_CATALOG.filter(f=>f.key===item.id||f.aliases?.includes(item.id)).map(f=>f.key))})),
31
31
  structure: parseWorkbook(task.bytes).sheets.filter(s => !s.hidden).map(s => ({
32
32
  name: s.name,
33
33
  rows: s.rows.filter(r => !r.hidden).slice(0,30).map(r => ({ number: r.number, cells: Object.values(s.cells).filter(c => c.row === r.number && !c.hidden && c.value.trim()).map(c => ({ column: c.column, label: c.value, recommendations: mappingRecommendations(c.value,FIELD_CATALOG) })) })),
@@ -17,14 +17,19 @@ const aliases = {
17
17
  actual_controller_voting_ratio:['实际控制人表决权比例'],
18
18
  };
19
19
  const ambiguous = {
20
+ 受益人:['beneficial_owner_first_name'],受益所有人:['beneficial_owner_first_name'],UBO:['beneficial_owner_first_name'],
21
+ 主营业务收入:['financial_total_revenue'],
20
22
  地址:['registered_address','mailing_address','invoice_address'],
21
23
  address:['registered_address','mailing_address'],企业地址:['registered_address','mailing_address'],公司地址:['registered_address','mailing_address'],
22
24
  开业时间:['established_date'],开业日期:['established_date'],
23
25
  所属行业:['industry_category','qcc_industry'],行业:['industry_category','qcc_industry'],法人:['legal_person'],
24
26
  };
25
27
  const normalize=value=>String(value??'').normalize('NFKC').toLowerCase().replace(/[\s_\-·]/g,'');
28
+ export function mappingSearchAliases(key){
29
+ return [...(aliases[key]||[]),...Object.entries(ambiguous).filter(([,keys])=>keys.includes(key)).map(([label])=>label)];
30
+ }
26
31
  export function mappingRecommendations(header,catalog){
27
- const label=normalize(String(header??'').normalize('NFKC').replace(/\s*\(?\s*YYYY[-/]MM[-/]DD\s*\)?\s*$/i,''));
32
+ const label=normalize(String(header??'').normalize('NFKC').replace(/\s*\(重复列\s*\d+\)\s*$/,'').replace(/\s*\(?\s*YYYY[-/]MM[-/]DD\s*\)?\s*$/i,''));
28
33
  if(!label)return [];
29
34
  const available=new Set(catalog.map(f=>f.key));
30
35
  const hinted=Object.entries(ambiguous).find(([name])=>normalize(name)===label)?.[1];
package/lib/ui.html CHANGED
@@ -68,14 +68,14 @@ function syncActions(){
68
68
  const running=current?.state==='enriching';$('cancel-run').hidden=!running;$('cancel-run').disabled=busy||!running;
69
69
  $('retry-run').hidden=!current||current.confirmed||!current.changeSet.incomplete.some(i=>['provider-error','cancelled','not-started'].includes(i.reason));
70
70
  $('retry-run').disabled=busy||!current||current.confirmed||running||!current.changeSet.incomplete.some(i=>['provider-error','cancelled','not-started'].includes(i.reason));
71
- $('execution-progress').textContent=running?(current.progress?.total?'正在查询 '+(current.progress?.completed||0)+' / '+current.progress.total:'正在准备查询…'):current?.state==='cancelled'?'已取消,成功结果保留。':current?.state==='interrupted'?'上次查询中断,已保存进度,可重试剩余部分。':'';
71
+ $('execution-progress').textContent=running?(current.progress?.total?'已处理查询计划项 '+(current.progress?.completed||0)+' / '+current.progress.total+'(含失败,不代表填写成功)':'正在准备查询…'):current?.state==='cancelled'?'已取消,成功结果保留。':current?.state==='interrupted'?'上次查询中断,已保存进度,可重试剩余部分。':'';
72
72
  for(const id of ['confirm','selection','configure'])$(id).disabled=busy||!current||current.confirmed||running;
73
73
  }
74
74
  $('cancel-run').onclick=async()=>{try{await api('/cancel',{id:current.id});$('status').textContent='已请求取消。已发出的请求可能已在远端执行,本地不再继续后续查询。';await restore()}catch(e){$('status').textContent=e.message}};
75
75
  $('retry-run').onclick=()=>{openWizard(true);wizardStep=3;renderWizard()};
76
76
  async function api(path,body){if(current&&body?.id===current.id)body={...body,expectedRevision:current.revision};const response=await fetch(basePath+path,{...(body===undefined?{}:{method:'POST',body:JSON.stringify(body)}),headers:{'Content-Type':'application/json','X-Form-Fill-Owner':owner}});const data=await response.json();if(!response.ok)throw Error(data.message);return data}
77
77
  function navigate(target){if(target==='wizard'){openWizard();return}if(target!=='import'&&!current){$('status').textContent='请先导入表格。';return}step=target;$('history').hidden=true;$('current').hidden=false;$('current-tab').setAttribute('aria-pressed','true');$('history-tab').setAttribute('aria-pressed','false');document.querySelectorAll('[data-pane]').forEach(p=>p.hidden=p.dataset.pane!==target);document.querySelectorAll('[data-step]').forEach(b=>b.setAttribute('aria-current',String(b.dataset.step===target)))}
78
- function downloads(){ $('downloads').replaceChildren();for(const [kind,label,suffix] of [['xlsx','下载已填副本','-已填副本.xlsx'],['changes','下载变更清单','-变更.json'],['incomplete','下载未完成项','-未完成.json']]){const a=document.createElement('a');Object.assign(a,{className:'download',href:basePath+'/download/'+current.id+'/'+kind,download:filename+suffix,textContent:label});$('downloads').append(a)}}
78
+ function downloads(){ $('downloads').replaceChildren();for(const [kind,label,suffix] of [['xlsx','下载已填副本','-已填副本.xlsx'],['changes','下载变更清单','-变更.json'],['incomplete','下载未完成项','-未完成.json']]){if(kind==='incomplete'&&!current.changeSet.incomplete.length)continue;const a=document.createElement('a');Object.assign(a,{className:'download',href:basePath+'/download/'+current.id+'/'+kind,download:filename+suffix,textContent:label});$('downloads').append(a)}}
79
79
  function businessSummary(){return current?(retryIntent?'仅重试失败、取消或未执行的部分,保留成功结果。':'')+'填写文件“'+current.filename+'”中的空白字段。共 '+current.analysis.tables.length+' 个工作表,'+wizardFields.size+' 个填写字段,'+current.analysis.opportunities.filter(p=>wizardFields.has(p.field)).length+' 个待补空位置。字段范围以本次保存的映射为准。保留已有值、公式与未确认位置,核验预览后生成新副本。':'请先上传 XLSX 文件。'}
80
80
  function command(){return current?businessSummary()+'\n'+$('requirements').value+'\n执行关联:调用 form_fill_enrich:taskId='+current.id+',expectedRevision='+current.revision+(retryIntent?',mode=retry':'')+'。字段范围以工作台确认设置为准。':''}
81
81
  function mappingVersion(){return JSON.stringify({tables:current?.analysis.tables.map(t=>({sheet:t.sheet,headerRow:t.headerRow,anchors:t.anchors,mappings:t.mappings.map(m=>[m.column,m.field,m.role,m.evidence])})),scope:current?.selectedFields??null})}
@@ -121,17 +121,17 @@ function renderWizard(){
121
121
  if($('scope-ack').dataset.signature!==signature){$('scope-ack').checked=false;$('scope-ack').dataset.signature=signature}
122
122
  $('scope-review').textContent=(review.omitted.length?'本次不填写 '+review.omitted.length+' 列:'+review.omitted.slice(0,3).join('、')+(review.omitted.length>3?'等,详见明细':'')+'。':'所有已映射的非主体字段均已纳入。')+(review.missing.length?'有 '+review.missing.length+' 行缺少可用主体标识;请检查企业名称列,不能使用整列为空的信用代码定位主体。':'');
123
123
  $('wizard-positions').textContent=(current?.analysis.opportunities||[]).filter(p=>wizardFields.has(p.field)).slice(0,200).map(p=>p.sheet+'!'+p.cell+':'+p.label).join('\n')+'\n最多展示前 200 个位置;完整计划保存在任务中。\n保留列:'+review.omitted.join('、');
124
- $('wizard-message').textContent=review.blocked?review.problem:review.omitted.length&&!$('scope-ack').checked?'请在第四步核对并确认本次保留列。':'';
125
- $('scope-ack-label').hidden=!review.omitted.length;
124
+ $('wizard-message').textContent=review.blocked?review.problem:'';
125
+ $('scope-ack-label').hidden=true;
126
126
  $('wizard-next').textContent=wizardStep===1?'应用映射并继续':'下一步';
127
127
  $('wizard-prev').disabled=wizardStep===0||busy;$('wizard-next').hidden=wizardStep===3;$('wizard-next').disabled=!current||busy;
128
- $('draft').hidden=wizardStep!==3;$('copy-command').hidden=wizardStep!==3;$('draft').disabled=!current||!wizardFields.size||busy||review.blocked||!!review.omitted.length&&!$('scope-ack').checked;$('copy-command').disabled=$('draft').disabled;
128
+ $('draft').hidden=wizardStep!==3;$('copy-command').hidden=wizardStep!==3;$('draft').disabled=!current||!wizardFields.size||busy||review.blocked;$('copy-command').disabled=$('draft').disabled;
129
129
  }
130
130
  function openWizard(retry=false){retryIntent=retry===true;initWizard();renderWizard();if(!$('wizard').open)$('wizard').showModal();renderWizard();if(parent!==window){document.body.classList.add('ff-modal-host');parent.postMessage({type:'ff-wizard-state',open:true},location.origin)}}
131
131
  function closeWizard(focusComposer=false){saveWizard();$('draft-conflict').close();$('wizard').close();mappingHome.after(sharedMapping);sharedMapping.hidden=step!=='rules';document.body.classList.remove('ff-modal-host');if(parent!==window)parent.postMessage({type:'ff-wizard-state',open:false,focusComposer},location.origin);if(!focusComposer)$('wizard-open').focus()}
132
132
  async function applyScope(){
133
133
  if(!current||!wizardFields.size)throw Error('请至少选择一个已映射的填写字段');
134
- const review=scopeReview();if(review.blocked)throw Error('没有可用主体标识,请先到字段设置映射企业名称列。');if(review.omitted.length&&!$('scope-ack').checked)throw Error('请确认未纳入的列,或返回字段设置完善映射。');
134
+ const review=scopeReview();if(review.blocked)throw Error('没有可用主体标识,请先到字段设置映射企业名称列。');
135
135
  const original=current.selectedFields||[...new Set(current.analysis.tables.flatMap(t=>t.mappings.filter(m=>m.field&&!isInput(t,m)).map(m=>m.field)))];
136
136
  if(retryIntent&&JSON.stringify([...original].sort())!==JSON.stringify([...wizardFields].sort()))throw Error('重试时请保留原字段范围;如需更改,请重新生成完整核验指令。');
137
137
  if(JSON.stringify([...original].sort())!==JSON.stringify([...wizardFields].sort()))render(await api('/scope',{id:current.id,selectedFields:[...wizardFields]}));
@@ -149,14 +149,14 @@ function directScope(){
149
149
  if($('direct-ack').dataset.signature!==signature){$('direct-ack').checked=false;$('direct-ack').dataset.signature=signature}
150
150
  $('direct-scope').textContent=review.problem||'将填写 '+wizardFields.size+' 个已确认字段。'+(review.omitted.length?'另有 '+review.omitted.length+' 列未纳入,可展开查看。':'');
151
151
  $('scope-omissions').hidden=!review.omitted.length;$('scope-omissions-list').textContent=review.omitted.slice(0,3).join('、')+(review.omitted.length>3?'等,详见明细':'');
152
- $('direct-ack-label').hidden=!review.omitted.length;
152
+ $('direct-ack-label').hidden=true;
153
153
  return review;
154
154
  }
155
155
  async function directDraft(){
156
156
  if(busy||!current)return;
157
157
  const review=directScope();
158
158
  if(review.blocked){$('status').textContent=review.problem;navigate('rules');$('anchor-alert').textContent=review.problem;$('anchor-alert').scrollIntoView({block:'center'});return}
159
- if(review.omitted.length&&!$('direct-ack').checked){$('status').textContent='请确认本页未纳入的字段,或返回字段设置完善映射。';return}
159
+
160
160
  $('scope-ack').checked=$('direct-ack').checked;
161
161
  if(parent===window){$('direct-command').hidden=false;$('direct-command').value=command();$('direct-command').focus();$('direct-command').select();$('status').textContent='指令已生成,请复制到 DSH 对话框发送。';return}
162
162
  $('status').textContent='正在回填到对话框…';await sendDraft();
@@ -196,7 +196,7 @@ function renderSettings(data){
196
196
  for(const [value,text] of [['input','用于定位企业'],['output','仅接收填写']]){const o=document.createElement('option');o.value=value;o.textContent=text;role.append(o)}
197
197
  role.value=override?.role||'input';
198
198
  const normalize=s=>String(s).normalize('NFKC').toLowerCase().replace(/[\s_()()·-]/g,'');
199
- const matches=(field,query)=>{const text=normalize([field.label,field.key,...(field.aliases||[])].join(' '));return query.trim().split(/\s+/).every(word=>{const q=normalize(word);if(text.includes(q))return true;if(q.length<2)return false;let i=0;for(const c of text)if(c===q[i])i++;return i===q.length})};
199
+ const matches=(field,query)=>{const text=normalize([field.label,field.key,...(field.aliases||[]),...(field.searchAliases||[])].join(' '));return query.trim().split(/\s+/).every(word=>{const q=normalize(word);if(text.includes(q))return true;if(q.length<2)return false;let i=0;for(const c of text)if(c===q[i])i++;return i===q.length})};
200
200
  const search=document.createElement('input');search.type='search';search.placeholder='关键词,例如:电话、信用代码';search.setAttribute('aria-label',sheet.name+' 搜索目标字段 '+cell.label);
201
201
  const dimension=document.createElement('select');dimension.setAttribute('aria-label',sheet.name+' 字段维度 '+cell.label);
202
202
  const groups=[{id:'',label:'全部维度'},...(data.catalogGroups||[]),{id:'other',label:'其他字段'}];
@@ -208,9 +208,11 @@ function renderSettings(data){
208
208
  const status=document.createElement('p');status.className='ff-mapping-status';status.setAttribute('aria-live','polite');
209
209
  const count=document.createElement('small');count.className='muted';
210
210
  const suggestions=document.createElement('div');suggestions.className='ff-mapping-suggestions';
211
+ const selectionNote=document.createElement('p');selectionNote.className='muted';label.append(selectionNote);
211
212
  const updateStatus=()=>{const f=data.catalog.find(f=>f.key===chosen);role.hidden=!(f?.anchor||f?.anchorFallback);select.dataset.manual=String(manual);select.dataset.primary=String(!role.hidden);status.dataset.state=chosen?(manual?'confirmed':'automatic'):manual?'skipped':suggestions.childElementCount?'pending':'unmatched';status.textContent=chosen?(manual?'已确认':'自动通过')+':'+(f?.label||chosen):manual?'已跳过:保留原值,不填写':suggestions.childElementCount?'待人工确认:请选择推荐字段':'未匹配:保留原值,不填写;可搜索字段';};
212
213
  label.updateMappingStatus=updateStatus;
213
- role.onchange=()=>{manual=true;updateStatus();highlightMappingConflicts()};
214
+ const originalUpdate=label.updateMappingStatus;label.updateMappingStatus=()=>{originalUpdate();selectionNote.textContent=(data.catalog.find(f=>f.key===(chosen||cell.recommendations?.[0]))?.selectionNote||'')+((chosen||cell.recommendations?.[0])==='financial_total_revenue'&&cell.label.includes('主营业务收入')?';主营业务收入与营业总收入口径不同,采用前请确认。':'')};
215
+ role.onchange=()=>{manual=true;label.updateMappingStatus();highlightMappingConflicts()};
214
216
  const options=()=>{
215
217
  const group=data.catalogGroups?.find(g=>g.id===dimension.value);
216
218
  const found=(data.catalog||[]).filter(f=>matches(f,search.value)&&(!dimension.value||(dimension.value==='other'?!data.catalogGroups?.some(g=>g.fields.includes(f.key)):group?.fields.includes(f.key))));
@@ -220,9 +222,9 @@ function renderSettings(data){
220
222
  const buckets=new Map();
221
223
  for(const field of list){const option=document.createElement('option');option.value=field.key;option.textContent=field.label;const group=field.key?data.catalogGroups?.find(g=>g.fields.includes(field.key)):null;if(group){if(!buckets.has(group.id)){const optgroup=document.createElement('optgroup');optgroup.label=group.label;select.append(optgroup);buckets.set(group.id,optgroup)}buckets.get(group.id).append(option)}else select.append(option)}
222
224
  trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'选择填写字段';
223
- select.value=chosen;count.textContent=found.length?'匹配 '+found.length+' 个字段':'没有匹配字段,请更换关键词或维度';updateStatus();
225
+ select.value=chosen;count.textContent=found.length?'匹配 '+found.length+' 个字段':'没有匹配字段,请更换关键词或维度';label.updateMappingStatus();
224
226
  };
225
- const choose=()=>{chosen=select.value;manual=true;suggestions.replaceChildren();trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'不填写';updateStatus();$('mapping-next').hidden=true};
227
+ const choose=()=>{chosen=select.value;manual=true;suggestions.replaceChildren();trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'不填写';label.updateMappingStatus();$('mapping-next').hidden=true};
226
228
  const finish=()=>{choose();highlightMappingConflicts();picker.open=false;trigger.focus()};
227
229
  select.onchange=choose;
228
230
  select.ondblclick=finish;
@@ -266,7 +268,7 @@ function render(data){
266
268
  current=data;directScope();$('direct-command').hidden=true;filename=(data.filename||'已填表格.xlsx').replace(/\.xlsx$/i,'');location.hash='task='+data.id;
267
269
  if(gridTask!==data.id){gridTask=data.id;gridPageNumber=1;gridColumn=1;$('grid-sheet').replaceChildren();$('grid-query').value=''}$('grid').hidden=false;loadGrid();
268
270
  if(parent!==window)parent.postMessage({type:'ff-task',taskId:data.id},location.origin);
269
- $('changes').replaceChildren();$('incomplete').replaceChildren();$('downloads').replaceChildren();
271
+ $('incomplete').closest('.card').style.display=data.changeSet.incomplete.length?'':'none';$('changes').replaceChildren();$('incomplete').replaceChildren();$('downloads').replaceChildren();
270
272
  $('task-meta').dataset.state=data.state;
271
273
  $('task-meta').textContent=(data.filename||'表格')+' · '+({'enriching':'查询中','completed':'已生成副本'+(data.changeSet.incomplete.length?',仍有 '+data.changeSet.incomplete.length+' 项未完成':''),'interrupted':'查询中断,请重新核验','partial':'部分完成','preview_ready':'可核验'}[data.state]||data.state)+' · 有效期至 '+new Date(data.expiresAt).toLocaleString();
272
274
  $('summary').textContent='可填写 '+data.changeSet.changes.length+' 格 · '+(data.plan.paidCalls?'企查查来源':'本地分析 / 合成示例 · 费用 0')+' · 未完成 '+data.changeSet.incomplete.length+' 项';
@@ -282,7 +284,7 @@ initWizard();filterResults();syncActions();if($('wizard').open)renderWizard();
282
284
  const missing=data.analysis.incomplete.filter(i=>i.reason==='missing-anchor');
283
285
  $('anchor-alert').textContent=missing.length?'有 '+missing.length+' 行缺少可用主体标识。请把实际包含名称的列映射为“企业名称”,或提供非空信用代码;当前不会查询这些行。':'';
284
286
  }
285
- async function restore(silent=false){if(busy||!current&& !location.hash)return;const id=new URLSearchParams(location.hash.slice(1)).get('task');if(!id)return;try{const data=await api('/task/'+encodeURIComponent(id));if(!silent||data.id!==current?.id||data.revision!==current?.revision){render(data);if(!silent){const target=pendingNavigation||(data.confirmed?'download':'preview');pendingNavigation=undefined;if(target==='history')$('history-tab').click();else navigate(target)}}}catch(e){if(!silent)$('status').textContent=e.message}}
287
+ async function restore(silent=false){if(busy||!current&& !location.hash)return;const id=new URLSearchParams(location.hash.slice(1)).get('task');if(!id)return;try{const data=await api('/task/'+encodeURIComponent(id));if(!silent||data.id!==current?.id||data.revision!==current?.revision){const wasRunning=current?.state==='enriching';render(data);if(silent&&data.state==='enriching'){navigate('identity');$('status').textContent=$('execution-progress').textContent}else if(silent&&wasRunning){navigate('preview');$('status').textContent='查询已结束,请检查填写预览。'}if(!silent){const target=pendingNavigation||(data.confirmed?'download':'preview');pendingNavigation=undefined;if(target==='history')$('history-tab').click();else navigate(target)}}}catch(e){if(!silent)$('status').textContent=e.message}}
286
288
  async function preview(buffer,name,demo=false){controls(true);try{const bytes=new Uint8Array(buffer);if(bytes.length>8388608)throw Error('文件超过 8 MiB');let binary='';for(let i=0;i<bytes.length;i+=32768)binary+=String.fromCharCode(...bytes.subarray(i,i+32768));$('grid').open=true;render(await api('/preview',{base64:btoa(binary),filename:name,sessionId,analyzeOnly:!demo}));navigate(demo?'preview':'rules');$('status').textContent='预览已准备好,请检查后确认。'}catch(e){$('status').textContent=e.message;$('wizard-message').textContent=e.message}finally{controls(false)}}
287
289
  document.querySelectorAll('[data-step]').forEach(b=>b.onclick=()=>navigate(b.dataset.step));
288
290
  $('file').onchange=async()=>{const input=$('file'),f=input.files[0];if(!f||busy)return;input.disabled=true;controls(true);$('status').textContent='正在自动解析表格…';try{await preview(await f.arrayBuffer(),f.name)}catch(e){$('status').textContent=e.message}finally{input.disabled=false;input.value='';controls(false)}};
@@ -312,7 +314,7 @@ $('draft-cancel').onclick=()=>$('draft-conflict').close();
312
314
  for(const mode of ['append','replace'])$('draft-'+mode).onclick=()=>{$('draft-conflict').close();sendDraft(mode)};
313
315
  $('mapping-search').oninput=()=>{const query=$('mapping-search').value.trim().toLowerCase();$('mapping').querySelectorAll('.ff-mapping-row').forEach(row=>row.hidden=!row.dataset.sourceLabel.toLowerCase().includes(query))};
314
316
  $('result-search').oninput=filterResults;$('changes').onchange=filterResults;
315
- window.addEventListener('message',e=>{if(e.origin!==location.origin||e.source!==parent)return;if(e.data?.type==='ff-theme'&&['light','dark'].includes(e.data.theme))document.body.dataset.ffTheme=e.data.theme;if(e.data?.type==='ff-draft-conflict'){expectedDraft=e.data.draft;if(!$('draft-conflict').open)$('draft-conflict').showModal()}if(e.data?.type==='ff-draft-result'){$('status').textContent=e.data.ok?'已回填,请在对话框修改或发送。':'回填失败,任务已保留。';if(e.data.ok)closeWizard(true)}if(e.data?.type==='ff-navigate'){if(!current&&location.hash)pendingNavigation=e.data.step;if(e.data.step==='history')$('history-tab').click();else navigate(e.data.step)}});
317
+ window.addEventListener('message',e=>{if(e.origin!==location.origin||e.source!==parent)return;if(e.data?.type==='ff-theme'&&['light','dark'].includes(e.data.theme))document.body.dataset.ffTheme=e.data.theme;if(e.data?.type==='ff-draft-conflict'){expectedDraft=e.data.draft;if(!$('draft-conflict').open)$('draft-conflict').showModal()}if(e.data?.type==='ff-draft-result'){$('status').textContent=e.data.ok?'已回填,请在对话框修改或发送。':'回填失败,任务已保留。';if(e.data.ok){closeWizard(true);navigate('identity');$('status').textContent='指令已回填,发送后将在此显示查询进度。'}}if(e.data?.type==='ff-navigate'){if(!current&&location.hash)pendingNavigation=e.data.step;if(e.data.step==='history')$('history-tab').click();else navigate(e.data.step)}});
316
318
  api('/health').then(s=>{$('connection').textContent=s.qccAvailable?'已发现企查查工商工具,可在对话中执行。':'尚未发现企查查工商工具;请先连接 MCP。合成模板仍可体验。'}).catch(()=>{});
317
319
  $('preview-continue').onclick=async()=>{if(busy||!current)return;controls(true);try{const ids=[...$('changes').querySelectorAll('input:checked')].map(x=>x.value);if(!current.confirmed&&JSON.stringify([...ids].sort())!==JSON.stringify([...(current.selectedIds||[])].sort()))render(await api('/select',{id:current.id,selectedIds:ids}));navigate('download');$('confirm').scrollIntoView({block:'center'});$('confirm').focus();$('status').textContent=current.confirmed?'副本已生成,请点击下载。':'请确认填写结果,点击蓝色按钮生成新副本。'}catch(e){$('status').textContent=e.message}finally{controls(false)}};
318
320
  $('mapping-continue').onclick=()=>{if(busy||!current)return;navigate('identity');$('wizard-open').focus()};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-form-fill-agent",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "private": false,
5
5
  "description": "AI form filling and spreadsheet autofill for XLSX in DeepSeek Harness, using authorized Qichacha MCP facts with cell previews, user confirmation and export to a new copy.",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "form-fill-core": "0.2.10",
36
- "qcc-form-fill-provider": "0.2.1"
36
+ "qcc-form-fill-provider": "0.2.2"
37
37
  },
38
38
  "dsh": {
39
39
  "client": {