dsh-requirement-dev-workbench 4.5.8 → 4.5.11

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