dsh-requirement-dev-workbench 4.5.8 → 4.5.10

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 CHANGED
@@ -5,6 +5,18 @@ AI Native 工作台(包名 `dsh-requirement-dev-workbench`)的版本变更
5
5
 
6
6
  ---
7
7
 
8
+ ## v4.5.10 — 2026-11-19
9
+
10
+ - **每个模块的工作区真正各自独立**:左栏模块名旁新增 📁,改的是这个模块自己的项目目录,别的模块一点不动;留空才跟随当前项目。
11
+ - **页头的目录按钮改成「只改这个模块」**:以前点它写的是全局项目设置,一改所有模块跟着换;现在只改当前模块,并顺带弹出这个模块的工作区对话框。
12
+ - **开发指令和执行记录跟着模块自己的目录走**:指令里的「工作目录」、执行记录里的项目目录,都取当前模块的工作区。
13
+
14
+ ## v4.5.9 — 2026-11-19
15
+
16
+ - **「开发需求」模板在列名不一样的表上也能用了**:以前模板只认真叫「需求标题 / 负责人 / 期望完成时间」的列,换成叫「页面 / 开发顾问 / 开发|配置计划结束时间」的表就只剩状态和优先级两列;现在按别名自动认,照样给齐标题 / 状态 / 优先级 / 负责人 / 期望完成时间。
17
+ - **认不到的列直接跳过,不再摊空列**:表里确实没有的列不会硬塞,之后在「设置」里手动补一列即可。
18
+ - **「开发任务」模板同样按别名认列**(任务标题 / 负责人 / 预估工时 / 任务类型)。
19
+
8
20
  ## v4.5.8 — 2026-11-19
9
21
 
10
22
  - **模块可以各自指定工作目录**:🔗 对话框里填「这个模块的项目目录」,留空才跟随当前项目;换项目只影响跟随的模块。
package/dsh/index.js CHANGED
@@ -3188,6 +3188,51 @@ export function apply(ctx, config) {
3188
3188
  return sendJson(res, result.ok ? 200 : 502, result)
3189
3189
  }
3190
3190
 
3191
+ // 模块级工作区:每个模块自己记项目目录(存 view.json 的模块上),改一个模块不会牵动其他模块。
3192
+ if (route === '/workspace' && req.method === 'GET') {
3193
+ const settings = await readSettings(config)
3194
+ const view = await readView(config)
3195
+ const moduleKey = String(url.searchParams.get('module') ?? '').trim()
3196
+ const module = moduleKey ? view.modules.find((item) => item.key === moduleKey) ?? null : null
3197
+ const projectDir = module ? moduleProjectDir(settings, module) : String(settings.projectDir ?? '')
3198
+ if (moduleKey && !module) return sendJson(res, 404, { ok: false, found: false, error: '没找到这个模块' })
3199
+ const tables = projectDir ? (await listTables(config, { ...settings, projectDir }, view)).tables : []
3200
+ const table = module ? moduleTable(module, { identity: config.identity }) : null
3201
+ return sendJson(res, 200, {
3202
+ ok: true,
3203
+ moduleKey,
3204
+ found: Boolean(module),
3205
+ projectDir,
3206
+ ownProjectDir: String(module?.projectDir ?? ''),
3207
+ inherited: !String(module?.projectDir ?? '').trim(),
3208
+ hasSource: Boolean(await sourceHasTable(projectDir, view)),
3209
+ tableCount: tables.length,
3210
+ moduleSource: table
3211
+ ? { tableId: table.tableId, baseToken: table.baseToken, label: table.label, identity: table.identity, readOnly: table.readOnly }
3212
+ : null,
3213
+ })
3214
+ }
3215
+
3216
+ if (route === '/workspace' && req.method === 'POST') {
3217
+ const settings = await readSettings(config)
3218
+ const body = await readBody(req)
3219
+ const view = await readView(config)
3220
+ const moduleKey = String(body?.moduleKey ?? '').trim()
3221
+ const index = view.modules.findIndex((item) => item.key === moduleKey)
3222
+ if (index < 0) return sendJson(res, 404, { ok: false, error: '没找到这个模块(模块可能已被删除,刷新一下再来)' })
3223
+ const raw = String(body?.projectDir ?? '').trim()
3224
+ if (raw && !/^[A-Za-z]:[\\/]|^\\\\|^\//.test(raw)) {
3225
+ return sendJson(res, 400, { ok: false, error: '请填绝对路径,例如 D:\\workspace\\your-project' })
3226
+ }
3227
+ if (raw && !(await stat(raw).then((info) => info.isDirectory()).catch(() => false))) {
3228
+ return sendJson(res, 400, { ok: false, error: `这个目录不存在:${raw}` })
3229
+ }
3230
+ // 只改这一个模块自己的项目目录;全局项目设置一格都不动。
3231
+ const patch = view.modules.map((item, position) => (position === index ? { ...item, projectDir: raw } : { ...item }))
3232
+ const saved = await writeView(config, { modules: patch })
3233
+ return sendJson(res, 200, { ok: true, moduleKey, projectDir: raw || String(settings.projectDir ?? ''), view: saved })
3234
+ }
3235
+
3191
3236
  // 模块级数据源:每个模块自己记一个链接(存 view.json 的模块上),改了只影响这一个模块。
3192
3237
  if (route === '/module-source' && req.method === 'GET') {
3193
3238
  const settings = await readSettings(config)
@@ -3248,7 +3293,9 @@ export function apply(ctx, config) {
3248
3293
  source.baseUrl = raw
3249
3294
  target.source = source
3250
3295
  target.tableKey = moduleKey
3251
- target.projectDir = projectDir
3296
+ // setProjectDir:明确要改(对话框保存)。否则只有原本就没有目录时才补默认,免得把用户的合并回来的旧值覆盖掉。
3297
+ if (body?.setProjectDir === true) target.projectDir = String(body?.projectDir ?? '').trim()
3298
+ else if (!String(target.projectDir ?? '').trim()) target.projectDir = projectDir
3252
3299
  }
3253
3300
  const saved = await writeView(config, { modules: patch })
3254
3301
  return sendJson(res, 200, { ok: true, view: saved })
package/lib/client.js CHANGED
@@ -13,7 +13,7 @@ window.__ModuleLoader__.load({
13
13
  const { useCallback, useEffect, useMemo, useRef, useState } = React
14
14
 
15
15
  const API = '/api/requirement-dev-workbench'
16
- const WORKBENCH_VERSION = '4.5.8'
16
+ const WORKBENCH_VERSION = '4.5.10'
17
17
  const STYLE_ID = 'rdw-business-panel-styles'
18
18
 
19
19
  const CSS = `
@@ -1040,7 +1040,8 @@ window.__ModuleLoader__.load({
1040
1040
  }
1041
1041
 
1042
1042
  function TableModule({ state, reloadState, uiWorkspace, table, view, saveView, runs, handOff, onUpdateRun, onOpenTable, onAddModule, expertData, reloadExperts, settingsOnly = false, onCloseSettings, onSavedSettings }) {
1043
- const [data, setData] = useState({ configured: false, items: [] })
1043
+ const [rawData, setData] = useState({ configured: false, items: [] })
1044
+ const moduleOwned = Boolean(table?.own)
1044
1045
  const [schema, setSchema] = useState(null)
1045
1046
  const [loading, setLoading] = useState(false)
1046
1047
  const [failure, setFailure] = useState(null)
@@ -1058,6 +1059,11 @@ window.__ModuleLoader__.load({
1058
1059
  const [dropTarget, setDropTarget] = useState('')
1059
1060
  const [progressField, setProgressField] = useState('')
1060
1061
  const [pendingWrite, setPendingWrite] = useState(null)
1062
+ // 每个模块自己的「工作区」状态:目录、有没有配源、能不能读表。
1063
+ // 以前这里直接吃全局 settings.projectDir,所以改一个模块的目录,所有模块一起变。
1064
+ const [wsInfo, setWsInfo] = useState(null)
1065
+ const [walletOpen, setWalletOpen] = useState(false)
1066
+ const moduleKey = String(table?.moduleKey ?? '')
1061
1067
  // 详情分栏:宽度可拖、可单独收起(收起后列表恢复整宽,选中的记录不丢)
1062
1068
  const [detailWidth, setDetailWidth] = useState(() => clampDetailWidth(view?.detailWidth))
1063
1069
  const [detailCollapsed, setDetailCollapsed] = useState(() => Boolean(view?.detailCollapsed))
@@ -1076,6 +1082,8 @@ window.__ModuleLoader__.load({
1076
1082
 
1077
1083
  const settings = state?.settings ?? {}
1078
1084
  const tableKey = table?.key ?? ''
1085
+ // 这个模块真正生效的工作目录:自己的目录优先,没填才跟随当前项目。
1086
+ const moduleDirNow = String(wsInfo?.projectDir || (moduleOwned ? '' : settings.projectDir) || '')
1079
1087
  const tableQuery = tableKey ? `?table=${encodeURIComponent(tableKey)}` : ''
1080
1088
 
1081
1089
  const loadSources = useCallback(async () => {
@@ -1102,6 +1110,30 @@ window.__ModuleLoader__.load({
1102
1110
  loadSources()
1103
1111
  }, [loadSources, settings.projectDir])
1104
1112
 
1113
+ // 模块的工作区:每次都向服务端要「这个模块自己的目录/源」,不拿全局设置顶替。
1114
+ const loadWorkspace = useCallback(async () => {
1115
+ if (!moduleKey) {
1116
+ setWsInfo(null)
1117
+ return
1118
+ }
1119
+ try {
1120
+ setWsInfo(await api(`/workspace?module=${encodeURIComponent(moduleKey)}`))
1121
+ } catch {
1122
+ setWsInfo(null)
1123
+ }
1124
+ }, [moduleKey])
1125
+
1126
+ useEffect(() => {
1127
+ void loadWorkspace()
1128
+ }, [loadWorkspace])
1129
+
1130
+ const saveWorkspace = useCallback(async (projectDir) => {
1131
+ if (!moduleKey) throw new Error('这个模块还没有自己的数据来源,先点 🔗 配一张表')
1132
+ const result = await api('/workspace', { method: 'POST', body: JSON.stringify({ moduleKey, projectDir }) })
1133
+ setWsInfo(result?.workspace ?? null)
1134
+ return result
1135
+ }, [moduleKey])
1136
+
1105
1137
  useEffect(() => {
1106
1138
  if (state?.configured) loadFields()
1107
1139
  }, [state?.configured, loadFields])
@@ -1345,8 +1377,8 @@ window.__ModuleLoader__.load({
1345
1377
  )
1346
1378
 
1347
1379
  useEffect(() => {
1348
- if (state?.configured) load()
1349
- }, [state?.configured, load])
1380
+ if (state?.configured || moduleOwned) load()
1381
+ }, [state?.configured, moduleOwned, load])
1350
1382
 
1351
1383
  useEffect(() => {
1352
1384
  if (!selectedId) return undefined
@@ -1361,6 +1393,9 @@ window.__ModuleLoader__.load({
1361
1393
  }
1362
1394
  }, [selectedId])
1363
1395
 
1396
+ const data = useMemo(() => (moduleOwned && wsInfo?.moduleSource?.tableId
1397
+ ? { ...rawData, source: wsInfo.moduleSource }
1398
+ : rawData), [rawData, moduleOwned, wsInfo])
1364
1399
  const schemaFields = schema?.fields ?? []
1365
1400
  const optionFields = useMemo(
1366
1401
  () => schemaFields.filter((field) => field.options?.length),
@@ -1430,7 +1465,7 @@ window.__ModuleLoader__.load({
1430
1465
 
1431
1466
  const copyInstruction = async () => {
1432
1467
  if (!selected) return
1433
- const text = instruction || buildInstruction(selected, settings, skills, resolveExpertPick(settings, expertData))
1468
+ const text = instruction || buildInstruction(selected, { ...settings, projectDir: moduleDirNow }, skills, resolveExpertPick(settings, expertData))
1434
1469
  setInstruction(text)
1435
1470
  setInstruction(text)
1436
1471
  try {
@@ -1439,7 +1474,7 @@ window.__ModuleLoader__.load({
1439
1474
  } catch {
1440
1475
  setToast('剪贴板不可用,请手动全选复制下面的指令;这条任务的执行记录只留一条')
1441
1476
  }
1442
- await handOff(selected, '已复制开发指令', tableKey)
1477
+ await handOff(selected, '已复制开发指令', tableKey, moduleDirNow)
1443
1478
  }
1444
1479
 
1445
1480
  /** 回写飞书一律先弹页面确认,确认后才真的写。 */
@@ -1539,10 +1574,17 @@ window.__ModuleLoader__.load({
1539
1574
  h(DirectoryPickerDialog, {
1540
1575
  initialPath: dirPicker.start,
1541
1576
  onPick: (dir) => {
1577
+ // 有模块身份就只写这个模块;设置页(没有模块身份)才写全局项目目录。
1578
+ const resolve = dirPicker.resolve
1542
1579
  setDirPicker(null)
1543
- void saveSettings({ projectDir: dir })
1580
+ if (typeof resolve === 'function') resolve(dir)
1581
+ else void saveSettings({ projectDir: dir })
1582
+ },
1583
+ onClose: () => {
1584
+ const resolve = dirPicker.resolve
1585
+ setDirPicker(null)
1586
+ if (typeof resolve === 'function') resolve('')
1544
1587
  },
1545
- onClose: () => setDirPicker(null),
1546
1588
  }),
1547
1589
  )
1548
1590
  : settingsView
@@ -1585,6 +1627,18 @@ window.__ModuleLoader__.load({
1585
1627
  )
1586
1628
  : null,
1587
1629
  h('button', { className: 'rdw-btn', onClick: () => setShowSettings(true) }, '设置'),
1630
+ moduleKey
1631
+ ? h(
1632
+ 'button',
1633
+ {
1634
+ className: 'rdw-btn',
1635
+ title: `这里是「${wsInfo?.projectDir || settings.projectDir || '跟随当前项目'}」;只改这个模块,别的模块不动`,
1636
+ 'aria-label': '改这个模块的工作区',
1637
+ onClick: () => setWalletOpen(true),
1638
+ },
1639
+ `📁 ${String(wsInfo?.projectDir || settings.projectDir || '未选项目').split(/[\\/]/).filter(Boolean).pop() || '未选项目'}`,
1640
+ )
1641
+ : null,
1588
1642
  ),
1589
1643
  h(
1590
1644
  'div',
@@ -1931,11 +1985,35 @@ window.__ModuleLoader__.load({
1931
1985
  initialPath: dirPicker.start,
1932
1986
  onPick: (dir) => {
1933
1987
  setDirPicker(null)
1934
- void saveSettings({ projectDir: dir })
1988
+ // 这里是「这个模块」的目录:只写模块自己的记录,别动全局项目设置。
1989
+ if (!moduleKey) {
1990
+ setToast('这个模块还没有自己的数据来源,先点左栏模块名旁的 🔗 配一张表')
1991
+ return
1992
+ }
1993
+ void saveWorkspace(dir).then(() => {
1994
+ setToast(`已把「${table?.label ?? moduleKey}」的工作区设为 ${dir}(其他模块不变)`)
1995
+ setWalletOpen(true)
1996
+ }).catch((error) => setToast(`改工作区失败:${error.message}`))
1935
1997
  },
1936
1998
  onClose: () => setDirPicker(null),
1937
1999
  })
1938
2000
  : null,
2001
+ walletOpen
2002
+ ? h(WorkspaceDialog, {
2003
+ moduleKey,
2004
+ moduleTitle: table?.label ?? moduleKey,
2005
+ data: wsInfo,
2006
+ chooseDirectory: (start) => new Promise((resolve) => {
2007
+ setDirPicker({ start: String(start ?? ''), resolve })
2008
+ }),
2009
+ onSave: async (projectDir) => {
2010
+ await saveWorkspace(projectDir)
2011
+ setToast(projectDir ? `已把「${table?.label ?? moduleKey}」的工作区设为 ${projectDir}` : '已改为跟随当前项目')
2012
+ await load(true)
2013
+ },
2014
+ onClose: () => setWalletOpen(false),
2015
+ })
2016
+ : null,
1939
2017
  ),
1940
2018
  )
1941
2019
  }
@@ -2317,7 +2395,7 @@ window.__ModuleLoader__.load({
2317
2395
  const fields = {}
2318
2396
  if (titleField.trim()) fields.title = titleField.trim()
2319
2397
  if (rawField.trim()) fields.rawRequirement = rawField.trim()
2320
- await api('/module-source', { method: 'POST', body: JSON.stringify({ moduleKey, baseUrl, projectDir: moduleDir.trim(), fields: Object.keys(fields).length ? fields : null }) })
2398
+ await api('/module-source', { method: 'POST', body: JSON.stringify({ moduleKey, baseUrl, projectDir: moduleDir.trim(), fields: Object.keys(fields).length ? fields : null, setProjectDir: true }) })
2321
2399
  setNotice(baseUrl ? '已保存到这个模块' : '已恢复为跟随项目配置')
2322
2400
  if (typeof onSaved === 'function') await onSaved()
2323
2401
  onClose()
@@ -2424,7 +2502,96 @@ window.__ModuleLoader__.load({
2424
2502
  }
2425
2503
 
2426
2504
  /**
2427
- /**
2505
+ * 模块工作区弹窗:每个模块自己的项目目录。
2506
+ * 以前「选工作区」写的是全局 settings.projectDir,所以一改全改;
2507
+ * 现在只写这个模块自己的目录,别的模块一点不动。
2508
+ */
2509
+ function WorkspaceDialog({ moduleKey, moduleTitle, data, onSave, onClose, chooseDirectory }) {
2510
+ const [dir, setDir] = useState('')
2511
+ const [busy, setBusy] = useState(false)
2512
+ const [failure, setFailure] = useState('')
2513
+ const [done, setDone] = useState('')
2514
+ useEffect(() => {
2515
+ if (data === null) return
2516
+ setDir(String(data?.ownProjectDir ?? ''))
2517
+ setFailure('')
2518
+ setDone('')
2519
+ }, [data])
2520
+ const save = async (projectDir) => {
2521
+ setBusy(true)
2522
+ setFailure('')
2523
+ try {
2524
+ await onSave(projectDir)
2525
+ setDone(projectDir ? `已把「${moduleTitle}」的工作区设为 ${projectDir}` : '已恢复为跟随当前项目')
2526
+ } catch (error) {
2527
+ setFailure(error.message)
2528
+ } finally {
2529
+ setBusy(false)
2530
+ }
2531
+ }
2532
+ const pick = async () => {
2533
+ if (typeof chooseDirectory !== 'function') return
2534
+ const picked = await chooseDirectory(String(data?.ownProjectDir ?? data?.projectDir ?? ''))
2535
+ if (picked) {
2536
+ setDir(picked)
2537
+ await save(picked)
2538
+ }
2539
+ }
2540
+ return h(
2541
+ 'div',
2542
+ { className: 'rdw-mask', role: 'presentation', onClick: onClose },
2543
+ h(
2544
+ 'div',
2545
+ {
2546
+ className: 'rdw-modal',
2547
+ role: 'dialog',
2548
+ 'aria-modal': 'true',
2549
+ 'aria-label': `模块工作区:${moduleTitle}`,
2550
+ style: { width: 'min(560px,94vw)' },
2551
+ onClick: (event) => event.stopPropagation(),
2552
+ },
2553
+ h(
2554
+ 'div',
2555
+ { className: 'rdw-modal-head' },
2556
+ h('strong', null, `工作区 · ${moduleTitle}`),
2557
+ h('span', { className: 'rdw-grow' }),
2558
+ h('button', { className: 'rdw-btn', onClick: onClose }, '关闭'),
2559
+ ),
2560
+ data === null
2561
+ ? h('div', { className: 'rdw-note' }, '读取中…')
2562
+ : h(
2563
+ 'div',
2564
+ null,
2565
+ h('div', { className: 'rdw-note', style: { marginBottom: 8 } },
2566
+ '这个目录只属于当前模块:技能扫描、开发指令里的工作目录都按它来;别的模块保持各自的选择。'),
2567
+ h(Field, {
2568
+ label: '这个模块的项目目录(留空 = 跟随当前项目)',
2569
+ value: dir,
2570
+ placeholder: data?.projectDir || 'D:\\workspace\\your-project',
2571
+ onChange: setDir,
2572
+ }),
2573
+ h('div', { className: 'rdw-note' },
2574
+ `当前实际生效:${data?.projectDir || '(还没选)'}${data?.ownProjectDir ? '(本模块自己的)' : '(跟随当前项目)'}`
2575
+ + ` · ${data?.hasSource ? `已认到 ${data?.tableCount ?? 0} 张表` : '这个目录里没认到需求表'}`),
2576
+ data?.moduleSource?.tableId
2577
+ ? h('div', { className: 'rdw-note' }, `本模块自己的表格链接:${data.moduleSource.tableId}(目录换了也不影响它)`)
2578
+ : null,
2579
+ failure ? h('div', { className: 'rdw-error', role: 'alert', style: { marginTop: 8 } }, failure) : null,
2580
+ done ? h('div', { className: 'rdw-note', style: { marginTop: 8 } }, done) : null,
2581
+ h(
2582
+ 'div',
2583
+ { className: 'rdw-toolbar', style: { marginTop: 12 } },
2584
+ h('button', { className: 'rdw-btn primary', disabled: busy, onClick: () => save(dir.trim()) }, busy ? '保存中…' : '只改这个模块'),
2585
+ h('button', { className: 'rdw-btn', disabled: busy, onClick: () => save('') }, '改为跟随当前项目'),
2586
+ h('span', { className: 'rdw-grow' }),
2587
+ h('button', { className: 'rdw-btn', disabled: busy || typeof chooseDirectory !== 'function', onClick: pick }, '用系统目录选择器挑选'),
2588
+ ),
2589
+ ),
2590
+ ),
2591
+ )
2592
+ }
2593
+
2594
+ /**
2428
2595
  * 更新日志弹窗:左栏底部「vX.Y.Z · 更新日志」点开。
2429
2596
  *
2430
2597
  * 内容来自包内 CHANGELOG.md(走 /changelog 接口解析成 sections),
@@ -3797,7 +3964,16 @@ window.__ModuleLoader__.load({
3797
3964
  groupField: '状态',
3798
3965
  listFields: ['需求标题', '状态', '优先级', '负责人', '期望完成时间'],
3799
3966
  cardFields: ['状态', '负责人', '优先级', '期望完成时间'],
3800
- note: '需求池:按状态分组看汇总清单,列取标题 / 状态 / 优先级 / 负责人 / 期望完成时间。',
3967
+ // 同一列在很多表里叫法不同:别名按「先出现的先用」认,模板的标准列名排第一(表里真有就优先用它)。
3968
+ // 认不到就跳过这一列,宁可在设置里手动补,也不摊出一排空列。
3969
+ aliases: {
3970
+ 需求标题: ['页面', '需求名称', '标题', '需求', '名称'],
3971
+ 负责人: ['开发顾问', '实施顾问', '处理人', '指派', '开发人'],
3972
+ 期望完成时间: ['开发|配置计划结束时间×', '开发|配置计划结束时间', '计划结束时间', '期望完成', '截止时间', '计划完成时间'],
3973
+ 优先级: ['需求优先级'],
3974
+ 状态: ['需求状态', '进度'],
3975
+ },
3976
+ note: '需求池:按状态分组看汇总清单,列取标题 / 状态 / 优先级 / 负责人 / 期望完成时间(表里列名不同就自动认,比如「页面 / 开发顾问 / 计划结束时间」)。',
3801
3977
  },
3802
3978
  {
3803
3979
  id: 'task',
@@ -3807,6 +3983,12 @@ window.__ModuleLoader__.load({
3807
3983
  groupField: '状态',
3808
3984
  listFields: ['任务标题', '状态', '优先级', '负责人', '任务类型', '预估工时'],
3809
3985
  cardFields: ['状态', '负责人', '优先级', '预估工时'],
3986
+ aliases: {
3987
+ 任务标题: ['任务名称', '标题', '名称', '任务'],
3988
+ 负责人: ['指派', '处理人', '开发人', '执行人'],
3989
+ 预估工时: ['工时', '预计工时', '预估人天', '人天', '工作量'],
3990
+ 任务类型: ['类型', '任务分类'],
3991
+ },
3810
3992
  note: '任务表:按状态分组看卡片看板,卡片给负责人 / 优先级 / 预估工时。',
3811
3993
  },
3812
3994
  ]
@@ -3830,15 +4012,39 @@ window.__ModuleLoader__.load({
3830
4012
  return suffix ? `${template.name} · ${suffix}` : template.name
3831
4013
  }
3832
4014
 
4015
+ /**
4016
+ * 模板里的一个标准列,在这张表里实际叫哪一列:
4017
+ * 1. 表里本来就叫这个名 -> 用它本人;
4018
+ * 2. 否则按模板的别名顺序找(先出现的先用),找到就用它;
4019
+ * 3. 别名后面被加了标记(表里常见的「上线批次×」「开发顾问×」)也算;
4020
+ * 4. 都没有 -> 返回空,调用方据此跳过这一列。
4021
+ */
4022
+ function templateColumn(template, name, known) {
4023
+ const names = Array.isArray(known) ? known.filter(Boolean) : []
4024
+ if (names.includes(name)) return name
4025
+ const marked = (target) => {
4026
+ if (!target || !/[×✕**※]$/u.test(target)) return ''
4027
+ const head = target.slice(0, -1).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
4028
+ return names.find((entry) => new RegExp(`^${head}[×✕**※]$`, 'u').test(entry)) ?? ''
4029
+ }
4030
+ for (const alias of template?.aliases?.[name] ?? []) {
4031
+ if (names.includes(alias)) return alias
4032
+ const variant = marked(alias)
4033
+ if (variant) return variant
4034
+ }
4035
+ return marked(name)
4036
+ }
4037
+
3833
4038
  /**
3834
4039
  * 模板落到某张表的配置切片。列只保留这张表真的有的字段 ——
3835
4040
  * 字段读不到(没连 lark-cli / 没缓存)时给空数组,让列表回到「自动列」,宁可不预设也别摊一排空列。
4041
+ * 列名按别名认(见 templateColumn),认到的就是这张表里的真实列名,所以写进去就能直接显示。
3836
4042
  */
3837
4043
  function templateSlice(template, fieldNames) {
3838
4044
  const known = Array.isArray(fieldNames) ? fieldNames.filter(Boolean) : []
3839
- const keep = (names) => (known.length ? names.filter((name) => known.includes(name)) : [])
4045
+ const keep = (names) => (known.length ? [...new Set(names.map((name) => templateColumn(template, name, known)).filter(Boolean))] : [])
3840
4046
  return {
3841
- groupField: template.groupField,
4047
+ groupField: templateColumn(template, template.groupField, known) || template.groupField,
3842
4048
  listFields: keep(template.listFields),
3843
4049
  cardFields: keep(template.cardFields),
3844
4050
  }
@@ -4982,6 +5188,40 @@ window.__ModuleLoader__.load({
4982
5188
  setSourceDialog(null)
4983
5189
  void reloadSources(sourceFor)
4984
5190
  }, [sourceFor, reloadSources])
5191
+ // 「模块工作区」对话框:同样只认这个模块自己的目录。
5192
+ const [workspaceFor, setWorkspaceFor] = useState('')
5193
+ const [workspaceDialog, setWorkspaceDialog] = useState(null)
5194
+ const reloadWorkspace = useCallback(async (moduleKey) => {
5195
+ try {
5196
+ setWorkspaceDialog(await api(`/workspace?module=${encodeURIComponent(moduleKey)}`))
5197
+ } catch (error) {
5198
+ setWorkspaceDialog({ error: error.message })
5199
+ }
5200
+ }, [])
5201
+ useEffect(() => {
5202
+ if (!workspaceFor) return
5203
+ setWorkspaceDialog(null)
5204
+ void reloadWorkspace(workspaceFor)
5205
+ }, [workspaceFor, reloadWorkspace])
5206
+ const saveModuleWorkspace = useCallback(async (projectDir) => {
5207
+ const result = await api('/workspace', { method: 'POST', body: JSON.stringify({ moduleKey: workspaceFor, projectDir }) })
5208
+ setWorkspaceDialog(result?.workspace ?? null)
5209
+ await reloadView()
5210
+ await reloadTables()
5211
+ return result
5212
+ }, [workspaceFor, reloadView, reloadTables])
5213
+ /** 让用户自己挑一个目录(优先系统对话框,没有就用自带的浏览器)。 */
5214
+ const pickDirectoryStarting = useCallback(async (start) => {
5215
+ if (uiWorkspace?.pickDirectory) {
5216
+ const picked = await uiWorkspace.pickDirectory()
5217
+ return picked || ''
5218
+ }
5219
+ const picked = await new Promise((resolve) => {
5220
+ setWorkspacePick({ start: String(start ?? ''), resolve })
5221
+ })
5222
+ return picked || ''
5223
+ }, [uiWorkspace])
5224
+ const [workspacePick, setWorkspacePick] = useState(null)
4985
5225
  const renameModule = useCallback(
4986
5226
  async (key, title) => {
4987
5227
  const trimmed = String(title ?? '').trim()
@@ -4995,7 +5235,7 @@ window.__ModuleLoader__.load({
4995
5235
  )
4996
5236
 
4997
5237
  const handOff = useCallback(
4998
- async (item, note, tableKey) => {
5238
+ async (item, note, tableKey, projectDir) => {
4999
5239
  if (!item) return
5000
5240
  try {
5001
5241
  const result = await api('/runs', {
@@ -5004,7 +5244,7 @@ window.__ModuleLoader__.load({
5004
5244
  tableKey: tableKey ?? '',
5005
5245
  recordId: item.id,
5006
5246
  title: item.title,
5007
- projectDir: state?.settings?.projectDir ?? '',
5247
+ projectDir: String(projectDir ?? state?.settings?.projectDir ?? ''),
5008
5248
  status: 'handed-off',
5009
5249
  note: note ?? '',
5010
5250
  }),
@@ -5069,7 +5309,7 @@ window.__ModuleLoader__.load({
5069
5309
  // 否则原来配的那张项目表被换掉后,模块会去借别的表甚至找不到表。
5070
5310
  const ownSource = module.source ? module.sourceResolved ?? module.source : null
5071
5311
  const table = (ownSource
5072
- ? { key: module.key, label: ownSource.label || ownSource.tableName || module.title, kind: ownSource.readOnly ? 'task' : 'requirement', own: true }
5312
+ ? { key: module.key, moduleKey: module.key, label: ownSource.label || ownSource.tableName || module.title, kind: ownSource.readOnly ? 'task' : 'requirement', own: true }
5073
5313
  : null) ?? tables.find((entry) => entry.key === module.tableKey)
5074
5314
  list.push({
5075
5315
  kind: 'table',
@@ -5301,6 +5541,22 @@ window.__ModuleLoader__.load({
5301
5541
  '🔗',
5302
5542
  )
5303
5543
  : null,
5544
+ entry.kind === 'table' && renamingId !== entry.id
5545
+ ? h(
5546
+ 'button',
5547
+ {
5548
+ className: 'rdw-mod-edit',
5549
+ title: `设置这个模块的工作区(只影响这个模块):${entry.label}`,
5550
+ 'aria-label': `设置工作区:${entry.label}`,
5551
+ onClick: (event) => {
5552
+ event.stopPropagation()
5553
+ setWorkspaceFor(entry.id)
5554
+ setActive(entry.id)
5555
+ },
5556
+ },
5557
+ '📁',
5558
+ )
5559
+ : null,
5304
5560
  ),
5305
5561
  ),
5306
5562
  h(
@@ -5431,6 +5687,35 @@ window.__ModuleLoader__.load({
5431
5687
  },
5432
5688
  })
5433
5689
  : null,
5690
+ workspaceFor
5691
+ ? h(WorkspaceDialog, {
5692
+ key: workspaceFor,
5693
+ moduleKey: workspaceFor,
5694
+ moduleTitle: railModules.find((entry) => entry.id === workspaceFor)?.label ?? workspaceFor,
5695
+ data: workspaceDialog,
5696
+ chooseDirectory: pickDirectoryStarting,
5697
+ onSave: saveModuleWorkspace,
5698
+ onClose: () => {
5699
+ setWorkspaceFor('')
5700
+ setWorkspaceDialog(null)
5701
+ },
5702
+ })
5703
+ : null,
5704
+ workspacePick
5705
+ ? h(DirectoryPickerDialog, {
5706
+ initialPath: workspacePick.start,
5707
+ onPick: (dir) => {
5708
+ const resolve = workspacePick.resolve
5709
+ setWorkspacePick(null)
5710
+ resolve(dir || '')
5711
+ },
5712
+ onClose: () => {
5713
+ const resolve = workspacePick.resolve
5714
+ setWorkspacePick(null)
5715
+ resolve('')
5716
+ },
5717
+ })
5718
+ : null,
5434
5719
  ])
5435
5720
  }
5436
5721
 
@@ -5861,7 +6146,7 @@ window.__ModuleLoader__.load({
5861
6146
  // Desktop 上有它就优先用(apply 里按需检测),没有就走原生 main 面板。
5862
6147
  inject: [],
5863
6148
  // 自测钩子:给 test/smoke.mjs 直接跑组件函数体与纯函数用;宿主只读 apply/inject,多余的键会被忽略。
5864
- __components: { BusinessPanel, TableModule, OverviewModule, ModuleDialog, ModuleSourceDialog, DetailView, ChangelogDialog, ViewConfigPanel, SettingsView, SkillsModule, DevModule, ExpertsModule, ExpertComposerEntry, FlowModule, DocsModule, DirectoryPickerDialog },
6149
+ __components: { BusinessPanel, TableModule, OverviewModule, ModuleDialog, ModuleSourceDialog, WorkspaceDialog, DetailView, ChangelogDialog, ViewConfigPanel, SettingsView, SkillsModule, DevModule, ExpertsModule, ExpertComposerEntry, FlowModule, DocsModule, DirectoryPickerDialog },
5865
6150
  __pure: {
5866
6151
  summarizeBuckets,
5867
6152
  runBadge,
@@ -5872,6 +6157,7 @@ window.__ModuleLoader__.load({
5872
6157
  templateForTableKind,
5873
6158
  templateTables,
5874
6159
  templateTitle,
6160
+ templateColumn,
5875
6161
  templateSlice,
5876
6162
  formatTime,
5877
6163
  formatCellValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-requirement-dev-workbench",
3
- "version": "4.5.8",
3
+ "version": "4.5.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "AI Native 工作台:把「拿任务 → 开发 → 验收」串成一条流水线。跨多张飞书多维表格看开发任务与进度,拉取飞书文档信息,用专家/专家团跑完整流程(需求分析 → 代码开发 → 代码评审 → QA 测试),选中本地项目后一键生成开发指令,并可浏览项目/全局 skill 与开发规范。模块可扩展。",