dsh-ide-window 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/CHANGELOG.md +12 -0
- package/client.js +223 -29
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -273,6 +273,7 @@ tail -f /tmp/dsh-ide-test/logs/dsh-ide-window.log # 自测实例
|
|
|
273
273
|
- 请求 `dsh-data-window:request`(`openTable` / `openSql`),回执 `dsh-data-window:response`,按 `id` 匹配,2s 超时;
|
|
274
274
|
- 文件树右键 Java/Kotlin 文件 → 解析 `@TableName` 发 `openTable`;编辑器符号右键 → Mapper 方法发 `openSql`(`@Select` 等注解优先,其次按 namespace 在 XML 里找 statement,动态 SQL 会带注释提示原文粘贴);
|
|
275
275
|
- MyBatis 动态 SQL 会先转成可执行 SQL:`<foreach>` 展开 3 条默认值、`#{}`/`${}` 按方法签名里的参数类型填默认值(数字 `1`、字符串 `'demo'`、日期时间),SQL 头部注释列出默认参数;XML 的 `<if>/<where>/<set>/<trim>/<choose>` 会展开成静态 SQL。仍不自动执行,用户在数据窗口里改值后自己跑。
|
|
276
|
+
- **`<include refid="..."/>` 会展开再拼**(`test/data-bridge.mjs` 有用例):同文件 `<sql id>`、跨命名空间的片段、嵌套 include、include 自带的 `<property>` 都解析;解析不到的 refid 在 SQL 里留 `/* include not found: x */` 并在头部注释列出,条件被吃光后剩下的空 `WHERE` 直接去掉——绝不给数据窗口一段 `WHERE` 后面直接 `ORDER BY` 的语法错误 SQL。
|
|
276
277
|
- 本插件只解析、不执行 SQL;定位库、只读校验都在数据窗口与它的 Host 里。
|
|
277
278
|
|
|
278
279
|
### 4.4 与对话联动
|
|
@@ -301,7 +302,7 @@ tail -f /tmp/dsh-ide-test/logs/dsh-ide-window.log # 自测实例
|
|
|
301
302
|
- `tool/call` 的 `arguments`(原始 JSON,能解析就缩进)与 `tool/result` 的文本 / `isError` / `reason` 挂在批次行上,展开能看到 `▸ 工具名` + 参数 + `↳ 输出`
|
|
302
303
|
- 其余事件一律成 **notice 行**:审批(`approval/asked|decided|policy`)、后台作业(`job/registered|settled`)、压缩(`compaction/start|summary|end|prune`)、重试(`llm/retry`)、失败尝试(`assistant/attempt`)、待办(`todo/write`)、模型/权限/沙箱切换、`workspace/changes`、`system/message`、`request/context`、`session/title*`、`developer/message`(工具增删),**未知类型兜底成 `floatEvent` + 原始 JSON**(真实会话里发现过 `request/context`/`session/title*` 这些插件事件)
|
|
303
304
|
- **只吞纯簿记**(`IDE_FLOAT_SILENT_EVENTS`):`turn/start`、`step/start`、`step/end`、`request/header`、`session/end-seed`、`llm/retry-started`、`agent/inbox/spliced`、`session-log-deepseek/delivery-accepted`——一次长会话里这些有 1.4 万条,且没有任何可读内容;`turn/end` 只在**非 completed** 时成行(回合成败要看得见)
|
|
304
|
-
-
|
|
305
|
+
- **默认是「本轮状态板」,不是阅读器**:`ideFloatVisibleRows(rows, running, detail)` 在 `detail !== true` 时只留 **最后一条你说的消息 + 它之后的每一条输出**(一轮里 agent 会在工具调用之间说好几段话,对话里逐条显示,卡片也逐条显示)+ 待回答的问题卡 + 最新文件卡;`思考`、`上下文注入`、`工具批次`、notice 全部不进正文(细节去对话看)。踩过两次:①一口气把事件都摊出来,用户看到的是一屏行,反而看不清"现在在做什么";②反过来只留最新一条输出,一轮里前面那些「改完了,再补个用例」全被吞掉(用户实测反馈)。
|
|
305
306
|
- **省略号只属于状态行,回答必须完整**(踩过:一度把助手输出压成一行,用户直接指出来「输出到对话的内容不要省略,省略的是『正在调用工具』这个框」)。所以:
|
|
306
307
|
- 助手回答照对话的排版**整段渲染**(`IdeFloatMarkdown`,段落/代码块/表格都在),绝不 clamp
|
|
307
308
|
- 用户消息用 `iw-float-pre`(`white-space: pre-wrap` + `-webkit-line-clamp: 4`):**保留你打的换行**(markdown 会把单个换行折成空格),超 4 行才截
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
升级方式:DSH →「插件」→ 打开插件的「版本」区 →「检查更新」,或直接卸载后重新安装。
|
|
7
7
|
(`link:` 本地安装不参与版本检查,拉取仓库即可。)
|
|
8
8
|
|
|
9
|
+
## [0.4.1] — 2026-11-25
|
|
10
|
+
|
|
11
|
+
### 修复
|
|
12
|
+
|
|
13
|
+
- **在数据窗口打开 Mapper SQL,复用的筛选条件整段丢失**:语句里 `WHERE <include refid="orderFilters"/>` 的 include 以前被直接删掉,数据窗口拿到的 SQL 变成 `WHERE` 后面直接接 `ORDER BY`,一执行就报语法错误。现在会把 `<sql id>` 片段展开再拼——同文件、跨命名空间、嵌套 include、include 自带的 `<property>` 都解析;解析不到的 refid 在 SQL 里留一条注释并在头部列出,条件被吃光后剩下的空 `WHERE` 直接去掉。
|
|
14
|
+
- **SQL 里的 `<` 比较符和 CDATA 内容会被当成标签删掉**:`a < 5 AND b > 3` 以前会被吞成 `a 3`,`<![CDATA[ ... ]]>` 里的内容整段消失。现在只清理真正的 XML 标签形状,比较运算符与 CDATA 里的 SQL 原样保留。
|
|
15
|
+
- **悬浮卡只显示本轮最后一条输出**:一轮里 agent 会在工具调用之间说好几段话,对话里逐条显示,卡片却只剩最后一句。现在按本轮逐条展示(你说的最后一条消息 + 之后每一段输出)。
|
|
16
|
+
|
|
17
|
+
### 改进
|
|
18
|
+
|
|
19
|
+
- **`WHERE` 不再单独占一行**:以前 `WHERE` 独占一行、条件从下一行开始,看起来和「条件被吃掉」的空 `WHERE` 一模一样;现在紧跟第一个条件。
|
|
20
|
+
|
|
9
21
|
## [0.4.0] — 2026-11-25
|
|
10
22
|
|
|
11
23
|
### 改进
|
package/client.js
CHANGED
|
@@ -7951,6 +7951,20 @@ function ideIsMarkdownPath(path) {
|
|
|
7951
7951
|
|
|
7952
7952
|
function IdeCodeView({ tab, tr, store, navigate }) {
|
|
7953
7953
|
const scrollRef = useRef(null)
|
|
7954
|
+
// The scrolling element is not the same element for the whole life of this
|
|
7955
|
+
// view: a freshly opened tab first paints the "loading" placeholder and only
|
|
7956
|
+
// then the source, and the Markdown preview swaps the container too. Effects
|
|
7957
|
+
// that read `scrollRef.current` once would keep listening to an element that
|
|
7958
|
+
// is no longer on screen (the scroll listener never attached at all for a
|
|
7959
|
+
// file opened in this session), so the offset was never remembered and
|
|
7960
|
+
// returning to the window put the reader back at line 1. Mirroring the
|
|
7961
|
+
// element into state gives those effects a dependency that changes whenever
|
|
7962
|
+
// the real container does.
|
|
7963
|
+
const [scrollHost, setScrollHost] = useState(null)
|
|
7964
|
+
const holdScroll = useCallback((element) => {
|
|
7965
|
+
scrollRef.current = element
|
|
7966
|
+
setScrollHost(element)
|
|
7967
|
+
}, [])
|
|
7954
7968
|
// While this view is on screen, the page outside it is not selectable, so
|
|
7955
7969
|
// Cmd+A answers with the file instead of the whole shell.
|
|
7956
7970
|
useEffect(() => {
|
|
@@ -8612,6 +8626,8 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8612
8626
|
// remembered offset — otherwise returning to a tab would always jump to the top.
|
|
8613
8627
|
const reveal = tab.reveal
|
|
8614
8628
|
useEffect(() => {
|
|
8629
|
+
// Read the ref rather than the state: the ref is attached during commit,
|
|
8630
|
+
// so the first paint already lands on the remembered line.
|
|
8615
8631
|
const element = scrollRef.current
|
|
8616
8632
|
if (element === null || tab.status !== 'ready') return
|
|
8617
8633
|
if (typeof reveal === 'number' && reveal > 0 && tab.revealApplied !== reveal) {
|
|
@@ -8621,12 +8637,12 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8621
8637
|
return
|
|
8622
8638
|
}
|
|
8623
8639
|
element.scrollTop = store.getState().scroll[tab.path] ?? 0
|
|
8624
|
-
}, [tab.path, reveal, tab.revealApplied, tab.status, store])
|
|
8640
|
+
}, [tab.path, reveal, tab.revealApplied, tab.status, store, scrollHost])
|
|
8625
8641
|
|
|
8626
8642
|
// Persist the offset while reading, throttled so a scroll does not re-render
|
|
8627
8643
|
// the whole panel on every frame.
|
|
8628
8644
|
useEffect(() => {
|
|
8629
|
-
const element =
|
|
8645
|
+
const element = scrollHost
|
|
8630
8646
|
if (element === null) return undefined
|
|
8631
8647
|
let timer
|
|
8632
8648
|
const onScroll = () => {
|
|
@@ -8641,7 +8657,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8641
8657
|
if (timer !== undefined) clearTimeout(timer)
|
|
8642
8658
|
element.removeEventListener('scroll', onScroll)
|
|
8643
8659
|
}
|
|
8644
|
-
}, [tab.path, store])
|
|
8660
|
+
}, [tab.path, store, scrollHost])
|
|
8645
8661
|
|
|
8646
8662
|
// Enrich the declarations on screen (counts) and the file once (blame). Both
|
|
8647
8663
|
// are cached per file version, so scrolling back costs nothing.
|
|
@@ -8705,7 +8721,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8705
8721
|
|
|
8706
8722
|
const code = h('div', {
|
|
8707
8723
|
className: 'iw-code',
|
|
8708
|
-
ref:
|
|
8724
|
+
ref: holdScroll,
|
|
8709
8725
|
tabIndex: 0,
|
|
8710
8726
|
onClick: (event) => {
|
|
8711
8727
|
// A licence page parked after an LSP refusal opens on the next gesture.
|
|
@@ -8823,7 +8839,7 @@ function IdeCodeView({ tab, tr, store, navigate }) {
|
|
|
8823
8839
|
])
|
|
8824
8840
|
: null
|
|
8825
8841
|
const markdownView = isMarkdown && tab.status === 'ready' && mdSource !== true
|
|
8826
|
-
? h('div', { key: 'md', className: 'iw-md', ref:
|
|
8842
|
+
? h('div', { key: 'md', className: 'iw-md', ref: holdScroll, tabIndex: 0 }, h('div', {
|
|
8827
8843
|
key: 'body',
|
|
8828
8844
|
className: 'iw-md-body',
|
|
8829
8845
|
}, h(IdeFloatMarkdown, { text: tab.text, tr })))
|
|
@@ -13684,12 +13700,151 @@ function ideDataWindowDecodeXml(text) {
|
|
|
13684
13700
|
.replace(/&/g, '&')
|
|
13685
13701
|
}
|
|
13686
13702
|
|
|
13703
|
+
/** 嵌套 `<include>` 最多展开这么多层,超过就按未解析处理,防止递归失控。 */
|
|
13704
|
+
const IDE_DATA_WINDOW_INCLUDE_DEPTH = 8
|
|
13705
|
+
|
|
13687
13706
|
/**
|
|
13688
|
-
*
|
|
13707
|
+
* 一个 mapper 文件里所有 `<sql id="...">` 片段,按 id 建索引。
|
|
13708
|
+
*
|
|
13709
|
+
* 片段是 mapper 语句的另一半:语句用 `<include refid="..."/>` 复用筛选条件块。
|
|
13710
|
+
* 早先这里直接把 include 标签删掉,于是 `WHERE <include .../>` 变成光秃秃的
|
|
13711
|
+
* `WHERE`,数据窗口拿到的 SQL 语法都不成立。
|
|
13712
|
+
*/
|
|
13713
|
+
function ideDataWindowSqlFragments(text) {
|
|
13714
|
+
const fragments = {}
|
|
13715
|
+
const pattern = /<sql\b[^>]*\bid\s*=\s*["']([^"']+)["'][^>]*>([\s\S]*?)<\/\s*sql\s*>/gi
|
|
13716
|
+
let match
|
|
13717
|
+
while ((match = pattern.exec(String(text ?? ''))) !== null) {
|
|
13718
|
+
fragments[match[1]] = match[2]
|
|
13719
|
+
}
|
|
13720
|
+
return fragments
|
|
13721
|
+
}
|
|
13722
|
+
|
|
13723
|
+
/** 把 refid 拆成「命名空间 + 片段名」,裸名字没有命名空间。 */
|
|
13724
|
+
function ideDataWindowRefId(refid) {
|
|
13725
|
+
const text = String(refid ?? '').trim()
|
|
13726
|
+
const dot = text.lastIndexOf('.')
|
|
13727
|
+
return dot > 0 ? { namespace: text.slice(0, dot), id: text.slice(dot + 1) } : { namespace: '', id: text }
|
|
13728
|
+
}
|
|
13729
|
+
|
|
13730
|
+
/** 某个命名空间的片段表;一次调用内只查一次,跨文件 include 靠它加载。 */
|
|
13731
|
+
async function ideDataWindowMapperFragments(root, files, namespace) {
|
|
13732
|
+
if (files.has(namespace)) return files.get(namespace)
|
|
13733
|
+
const found = await ideGrepQuery(root, `namespace="${namespace}"`, { extensions: ['xml'] })
|
|
13734
|
+
const paths = found.ok === true ? found.matches.map((match) => String(match.path ?? '')) : []
|
|
13735
|
+
const path = paths.find((entry) => entry.includes('/src/main/resources/')) ?? paths[0] ?? ''
|
|
13736
|
+
const text = path === '' ? '' : await ideDataWindowReadFile(root, path)
|
|
13737
|
+
const fragments = text === '' ? null : ideDataWindowSqlFragments(text)
|
|
13738
|
+
files.set(namespace, fragments)
|
|
13739
|
+
return fragments
|
|
13740
|
+
}
|
|
13741
|
+
|
|
13742
|
+
/** 文本里每个 `<include>` 的位置,成对(带 `<property>` 子标签)和自闭合都认。 */
|
|
13743
|
+
function ideDataWindowIncludes(body) {
|
|
13744
|
+
const text = String(body ?? '')
|
|
13745
|
+
const items = []
|
|
13746
|
+
const open = /<include\b/gi
|
|
13747
|
+
let match
|
|
13748
|
+
while ((match = open.exec(text)) !== null) {
|
|
13749
|
+
const start = match.index
|
|
13750
|
+
const end = text.indexOf('>', start)
|
|
13751
|
+
if (end < 0) break
|
|
13752
|
+
const raw = text.slice(start + '<include'.length, end)
|
|
13753
|
+
const head = raw.replace(/\/\s*$/, '')
|
|
13754
|
+
if (/\/\s*$/.test(raw)) {
|
|
13755
|
+
items.push({ index: start, length: end + 1 - start, attrs: head, body: '' })
|
|
13756
|
+
open.lastIndex = end + 1
|
|
13757
|
+
continue
|
|
13758
|
+
}
|
|
13759
|
+
// 自闭合标签后面紧跟的内容不属于它;只有成对标签才向后找 `</include>`。
|
|
13760
|
+
const closing = /<\/\s*include\s*>/i.exec(text.slice(end + 1))
|
|
13761
|
+
if (closing === null) {
|
|
13762
|
+
items.push({ index: start, length: end + 1 - start, attrs: head, body: '' })
|
|
13763
|
+
open.lastIndex = end + 1
|
|
13764
|
+
continue
|
|
13765
|
+
}
|
|
13766
|
+
const bodyEnd = end + 1 + closing.index
|
|
13767
|
+
items.push({
|
|
13768
|
+
index: start,
|
|
13769
|
+
length: bodyEnd + closing[0].length - start,
|
|
13770
|
+
attrs: head,
|
|
13771
|
+
body: text.slice(end + 1, bodyEnd),
|
|
13772
|
+
})
|
|
13773
|
+
open.lastIndex = bodyEnd + closing[0].length
|
|
13774
|
+
}
|
|
13775
|
+
return items
|
|
13776
|
+
}
|
|
13777
|
+
|
|
13778
|
+
/** `<include>` 里 `<property name=... value=.../>` 提供的占位符值。 */
|
|
13779
|
+
function ideDataWindowIncludeProps(body) {
|
|
13780
|
+
const props = {}
|
|
13781
|
+
for (const match of String(body ?? '').matchAll(/<property\b[^>]*\/?\s*>/gi)) {
|
|
13782
|
+
const attrs = ideDataWindowXmlAttrs(match[0])
|
|
13783
|
+
if (attrs.name !== undefined && attrs.value !== undefined) props[attrs.name] = attrs.value
|
|
13784
|
+
}
|
|
13785
|
+
return props
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13788
|
+
/** 用 include 的 property 值替换片段里的 `${name}`,其余占位符留给参数填充。 */
|
|
13789
|
+
function ideDataWindowApplyProps(sql, props) {
|
|
13790
|
+
const names = Object.keys(props)
|
|
13791
|
+
if (names.length === 0) return String(sql ?? '')
|
|
13792
|
+
return String(sql ?? '').replace(/\$\{\s*([^}]+?)\s*\}/g, (whole, name) => (
|
|
13793
|
+
Object.prototype.hasOwnProperty.call(props, name) ? props[name] : whole
|
|
13794
|
+
))
|
|
13795
|
+
}
|
|
13796
|
+
|
|
13797
|
+
/**
|
|
13798
|
+
* 展开 `<include refid="..."/>`:同文件片段、跨命名空间片段、嵌套 include 与
|
|
13799
|
+
* include 自带的 property 都解析。
|
|
13800
|
+
*
|
|
13801
|
+
* 解析不出来的片段换成一条 SQL 注释而不是静默消失——注释能看出缺了谁,空洞
|
|
13802
|
+
* 只会让数据窗口执行一段语法错误的 SQL。`missing` 收集这些 refid 交给调用方
|
|
13803
|
+
* 写进头部注释。
|
|
13804
|
+
*/
|
|
13805
|
+
async function ideDataWindowExpandIncludes(root, files, namespace, body, seen, missing, depth) {
|
|
13806
|
+
const text = String(body ?? '')
|
|
13807
|
+
const items = ideDataWindowIncludes(text)
|
|
13808
|
+
if (items.length === 0 || depth > IDE_DATA_WINDOW_INCLUDE_DEPTH) return text
|
|
13809
|
+
let result = ''
|
|
13810
|
+
let cursor = 0
|
|
13811
|
+
for (const item of items) {
|
|
13812
|
+
result += text.slice(cursor, item.index)
|
|
13813
|
+
cursor = item.index + item.length
|
|
13814
|
+
const refid = String(ideDataWindowXmlAttrs(item.attrs).refid ?? '').trim()
|
|
13815
|
+
if (refid === '') {
|
|
13816
|
+
result += '/* include without refid */'
|
|
13817
|
+
missing.push('(without refid)')
|
|
13818
|
+
continue
|
|
13819
|
+
}
|
|
13820
|
+
const ref = ideDataWindowRefId(refid)
|
|
13821
|
+
const owner = ref.namespace === '' ? namespace : ref.namespace
|
|
13822
|
+
const key = `${owner}|${ref.id}`
|
|
13823
|
+
if (seen.has(key)) {
|
|
13824
|
+
result += `/* include cycle: ${refid} */`
|
|
13825
|
+
missing.push(refid)
|
|
13826
|
+
continue
|
|
13827
|
+
}
|
|
13828
|
+
const fragments = await ideDataWindowMapperFragments(root, files, owner)
|
|
13829
|
+
const fragment = fragments === null ? undefined : fragments[ref.id]
|
|
13830
|
+
if (fragment === undefined) {
|
|
13831
|
+
result += `/* include not found: ${refid} */`
|
|
13832
|
+
missing.push(refid)
|
|
13833
|
+
continue
|
|
13834
|
+
}
|
|
13835
|
+
const provided = ideDataWindowApplyProps(fragment, ideDataWindowIncludeProps(item.body))
|
|
13836
|
+
result += await ideDataWindowExpandIncludes(root, files, owner, provided, new Set(seen).add(key), missing, depth + 1)
|
|
13837
|
+
}
|
|
13838
|
+
result += text.slice(cursor)
|
|
13839
|
+
return result
|
|
13840
|
+
}
|
|
13841
|
+
|
|
13842
|
+
/**
|
|
13843
|
+
* The SQL of one mapper statement from its XML file, with `<include>` expanded.
|
|
13689
13844
|
*
|
|
13690
13845
|
* The namespace search is a content grep, so the mapper does not have to sit at a
|
|
13691
|
-
* conventional path.
|
|
13692
|
-
*
|
|
13846
|
+
* conventional path. `missing` lists the refids that could not be resolved, so the
|
|
13847
|
+
* header can say which filter block is absent instead of pretending the SQL is whole.
|
|
13693
13848
|
*/
|
|
13694
13849
|
async function ideDataWindowXmlSql(root, fqcn, symbol) {
|
|
13695
13850
|
const found = await ideGrepQuery(root, `namespace="${fqcn}"`, { extensions: ['xml'] })
|
|
@@ -13707,7 +13862,10 @@ async function ideDataWindowXmlSql(root, fqcn, symbol) {
|
|
|
13707
13862
|
if (match === null) return null
|
|
13708
13863
|
const body = match[2]
|
|
13709
13864
|
if (body.trim() === '') return null
|
|
13710
|
-
|
|
13865
|
+
const files = new Map([[fqcn, ideDataWindowSqlFragments(text)]])
|
|
13866
|
+
const missing = []
|
|
13867
|
+
const expanded = await ideDataWindowExpandIncludes(root, files, fqcn, body, new Set(), missing, 0)
|
|
13868
|
+
return { sql: ideDataWindowDecodeXml(expanded).trim(), missing }
|
|
13711
13869
|
}
|
|
13712
13870
|
|
|
13713
13871
|
/** Parse the attributes of one XML-ish tag, single or double quoted. */
|
|
@@ -13803,6 +13961,8 @@ function ideDataWindowExpandForeach(sql, params) {
|
|
|
13803
13961
|
/** Remove the MyBatis dynamic tags, keeping the SQL they contain. */
|
|
13804
13962
|
function ideDataWindowStripTags(sql) {
|
|
13805
13963
|
let result = String(sql ?? '')
|
|
13964
|
+
// CDATA 里是原样 SQL,先去壳,否则会被下面「未知标签」那条清理连内容一起吞掉。
|
|
13965
|
+
result = result.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
|
|
13806
13966
|
result = result.replace(/<\s*script\b[^>]*>/gi, '').replace(/<\s*\/\s*script\s*>/gi, '')
|
|
13807
13967
|
result = result.replace(/<choose\b[^>]*>([\s\S]*?)<\/choose>/gi, (whole, body) => {
|
|
13808
13968
|
const when = /<when\b[^>]*>([\s\S]*?)<\/when>/i.exec(body)
|
|
@@ -13833,11 +13993,14 @@ function ideDataWindowStripTags(sql) {
|
|
|
13833
13993
|
result = result.replace(pattern, '$1')
|
|
13834
13994
|
}
|
|
13835
13995
|
result = result.replace(/<bind\b[^>]*\/?\s*>/gi, '')
|
|
13836
|
-
|
|
13837
|
-
//
|
|
13838
|
-
|
|
13996
|
+
// Anything left (foreach and include are already expanded) is an unsupported tag: drop it.
|
|
13997
|
+
// 只认「XML 形状」的标签(字母或 `!` 开头):`a < 5` 解出来是比较运算符,
|
|
13998
|
+
// 按 `<[^>]+>` 删会把 `<` 到后面某个 `>` 之间的真实 SQL 一起吞掉。
|
|
13999
|
+
result = result.replace(/<\/?[A-Za-z!][^>]*>/g, '')
|
|
13839
14000
|
// `<where>` may have wrapped its leading AND/OR inside a stripped `<if>`.
|
|
13840
14001
|
result = result.replace(/\bWHERE\s+(AND|OR)\b/gi, 'WHERE')
|
|
14002
|
+
// 条件被动态标签或解析失败的 include 吃光后只剩一个 WHERE,留着就是语法错误。
|
|
14003
|
+
result = result.replace(/\bWHERE\b(?=(?:\s*\/\*[\s\S]*?\*\/)*\s*(?:ORDER\s+BY|GROUP\s+BY|HAVING|LIMIT|UNION|FOR\s+UPDATE|\)|;|$))/gi, '')
|
|
13841
14004
|
return result
|
|
13842
14005
|
}
|
|
13843
14006
|
|
|
@@ -13867,6 +14030,9 @@ function ideDataWindowExecutableSql(raw, params) {
|
|
|
13867
14030
|
.filter((line) => line !== '')
|
|
13868
14031
|
.join('\n')
|
|
13869
14032
|
.replace(/\b(IN|in)\s*\(/g, 'IN (')
|
|
14033
|
+
// `WHERE` 独占一行时,看上去和「条件被吃掉了」的空 WHERE 一模一样;把紧跟着
|
|
14034
|
+
// 它的第一个条件接上去,一眼就能看出条件在不在。`SET` 同理。
|
|
14035
|
+
.replace(/\b(WHERE|SET)[ \t]*\n[ \t]*(?=\S)/gi, (whole, keyword) => `${keyword.toUpperCase()} `)
|
|
13870
14036
|
.trim()
|
|
13871
14037
|
}
|
|
13872
14038
|
|
|
@@ -13892,15 +14058,22 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
|
|
|
13892
14058
|
const fqcn = packageMatch === null ? typeName : `${packageMatch[1]}.${typeName}`
|
|
13893
14059
|
const methodOffset = ideDataWindowMethodOffset(text, name, line)
|
|
13894
14060
|
const params = ideDataWindowMethodParams(text, methodOffset)
|
|
13895
|
-
const
|
|
13896
|
-
|
|
13897
|
-
const
|
|
14061
|
+
const annotation = ideDataWindowAnnotationSql(text, name, line)
|
|
14062
|
+
const statement = annotation === '' ? await ideDataWindowXmlSql(root, fqcn, name) : { sql: annotation, missing: [] }
|
|
14063
|
+
const raw = statement === null ? '' : String(statement.sql ?? '')
|
|
14064
|
+
const sql = raw === '' ? '' : ideDataWindowExecutableSql(raw, params)
|
|
13898
14065
|
if (sql === '') {
|
|
13899
14066
|
store.setNotice(tr('dataWindowNoSql'))
|
|
13900
14067
|
return
|
|
13901
14068
|
}
|
|
13902
14069
|
const defaults = ideDataWindowDefaultSummary(params)
|
|
13903
|
-
|
|
14070
|
+
// 解析不出来的 include 必须说出来:否则用户以为拿到了完整条件,实际少了过滤块。
|
|
14071
|
+
const unresolved = [...new Set(statement?.missing ?? [])]
|
|
14072
|
+
const notes = [
|
|
14073
|
+
defaults === '' ? '' : `-- defaults: ${defaults}`,
|
|
14074
|
+
unresolved.length === 0 ? '' : `-- unresolved include: ${unresolved.join(', ')}`,
|
|
14075
|
+
].filter((line) => line !== '').join('\n')
|
|
14076
|
+
const header = notes === '' ? '' : `${notes}\n`
|
|
13904
14077
|
store.setNotice(tr('dataWindowOpening'))
|
|
13905
14078
|
const ack = await ideDataWindowRequest({
|
|
13906
14079
|
action: 'openSql',
|
|
@@ -14609,26 +14782,47 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
|
|
|
14609
14782
|
*/
|
|
14610
14783
|
function ideFloatVisibleRows(rows, running, detail) {
|
|
14611
14784
|
if (!Array.isArray(rows)) return []
|
|
14785
|
+
// 还没作答的问题卡片不管在哪个位置都要露出来,否则用户永远看不到「要你选」。
|
|
14786
|
+
const pendingQuestion = (row) => row?.role === 'question' && !(Array.isArray(row?.answers) && row.answers.length > 0)
|
|
14612
14787
|
if (detail !== true) {
|
|
14613
|
-
// The card is a status board
|
|
14614
|
-
//
|
|
14615
|
-
//
|
|
14616
|
-
|
|
14617
|
-
|
|
14788
|
+
// The card is a status board for the current turn: what you last said, then
|
|
14789
|
+
// every line the agent printed after it. An agent narrates between Tool calls
|
|
14790
|
+
// ("改完了,再补个用例"), and the conversation prints each narration as its own
|
|
14791
|
+
// message — keeping only the newest one dropped everything said before it,
|
|
14792
|
+
// which is exactly what the card used to do.
|
|
14793
|
+
let lastUser = -1
|
|
14794
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14795
|
+
if (rows[index]?.role === 'user') {
|
|
14796
|
+
lastUser = index
|
|
14797
|
+
break
|
|
14798
|
+
}
|
|
14799
|
+
}
|
|
14800
|
+
if (lastUser < 0) {
|
|
14801
|
+
// 没有 user 行可以锚定(历史被截断或会话是种子消息):退回「最新一条输出」。
|
|
14802
|
+
const keep = new Set()
|
|
14618
14803
|
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14619
|
-
if (
|
|
14620
|
-
keep.
|
|
14621
|
-
|
|
14804
|
+
if (rows[index]?.role === 'assistant') {
|
|
14805
|
+
keep.add(index)
|
|
14806
|
+
break
|
|
14622
14807
|
}
|
|
14623
14808
|
}
|
|
14809
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) {
|
|
14810
|
+
if (rows[index]?.role === 'files') {
|
|
14811
|
+
keep.add(index)
|
|
14812
|
+
break
|
|
14813
|
+
}
|
|
14814
|
+
}
|
|
14815
|
+
rows.forEach((row, index) => {
|
|
14816
|
+
if (pendingQuestion(row)) keep.add(index)
|
|
14817
|
+
})
|
|
14818
|
+
return [...keep].sort((left, right) => left - right).map((index) => rows[index])
|
|
14624
14819
|
}
|
|
14625
|
-
|
|
14626
|
-
lastWhere((row) => row?.role === 'assistant')
|
|
14627
|
-
lastWhere((row) => row?.role === 'files')
|
|
14820
|
+
const keep = new Set([lastUser])
|
|
14628
14821
|
rows.forEach((row, index) => {
|
|
14629
|
-
if (row?.role === '
|
|
14822
|
+
if (index > lastUser && (row?.role === 'assistant' || row?.role === 'files' || pendingQuestion(row))) keep.add(index)
|
|
14823
|
+
else if (index < lastUser && pendingQuestion(row)) keep.add(index)
|
|
14630
14824
|
})
|
|
14631
|
-
return [...
|
|
14825
|
+
return [...keep].sort((left, right) => left - right).map((index) => rows[index])
|
|
14632
14826
|
}
|
|
14633
14827
|
// Detail mode: the whole record. The batch that is still running is pinned
|
|
14634
14828
|
// under the clock, so it leaves the transcript to avoid showing it twice.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ide-window",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "IDEA-style code workspace for DeepSeek Harness: a centre panel with a workspace file tree, editor tabs and live-updating source, while the left navigation column hides.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "icon.svg",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "node build.mjs",
|
|
32
32
|
"check": "node --check index.js && node --check client.js",
|
|
33
|
-
"test": "node test/platform.mjs && node test/diagnostics.mjs && node test/status.mjs && node test/harness.mjs && node test/inference.mjs && node test/maven.mjs && node test/theme.mjs && node test/screenshot.mjs"
|
|
33
|
+
"test": "node test/platform.mjs && node test/diagnostics.mjs && node test/status.mjs && node test/harness.mjs && node test/data-bridge.mjs && node test/inference.mjs && node test/maven.mjs && node test/theme.mjs && node test/screenshot.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dsh": {
|
|
36
36
|
"bundle": {
|