dsh-gufa-code 1.3.104 → 1.3.108
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/client.js +8 -1
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/host/completion.js +29 -1
- package/host/fs.js +11 -3
- package/package.json +1 -1
- package/src/client/20-editor.js +7 -0
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.108'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -3105,6 +3105,13 @@ const GUFA_DEFINITION_STRONG_KINDS = new Set(['function', 'class', 'method', 'de
|
|
|
3105
3105
|
scrollbar: { verticalScrollbarSize: 10, horizontalScrollbarSize: 10, useShadows: false },
|
|
3106
3106
|
mouseWheelZoom: false,
|
|
3107
3107
|
contextmenu: true,
|
|
3108
|
+
/* 基础代码联想:显式打开自动补全与单词建议,避免依赖 Monaco 版本默认值 */
|
|
3109
|
+
quickSuggestions: { other: true, comments: false, strings: false },
|
|
3110
|
+
quickSuggestionsDelay: 10,
|
|
3111
|
+
suggestOnTriggerCharacters: true,
|
|
3112
|
+
wordBasedSuggestions: 'currentDocument',
|
|
3113
|
+
acceptSuggestionOnEnter: 'on',
|
|
3114
|
+
tabCompletion: 'on',
|
|
3108
3115
|
inlineSuggest: { enabled: true, showToolbar: 'never' },
|
|
3109
3116
|
}
|
|
3110
3117
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.108</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.108</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/host/completion.js
CHANGED
|
@@ -20,6 +20,7 @@ const SUPPORTED = new Set([
|
|
|
20
20
|
'csharp', 'cpp', 'c', 'shell', 'yaml', 'sql', 'php', 'ruby',
|
|
21
21
|
])
|
|
22
22
|
|
|
23
|
+
|
|
23
24
|
function sanitize(text) {
|
|
24
25
|
let value = String(text ?? '')
|
|
25
26
|
/* 去掉模型偶尔带出的 markdown 围栏 */
|
|
@@ -44,6 +45,26 @@ function selectionOf(ctx) {
|
|
|
44
45
|
return undefined
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
const effortCache = new Map()
|
|
49
|
+
|
|
50
|
+
/** 补全要求低延迟:优先选最小 reasoning effort(不同模型 id 不同,如 off/minimal/low)。 */
|
|
51
|
+
async function pickReasoningEffort(llm, provider, model) {
|
|
52
|
+
const key = `${provider}|${model}`
|
|
53
|
+
if (effortCache.has(key)) return effortCache.get(key)
|
|
54
|
+
let chosen = ''
|
|
55
|
+
try {
|
|
56
|
+
const info = await llm.resolveModelInfo(provider, model)
|
|
57
|
+
const efforts = info !== null && info !== undefined && info.reasoning !== null && info.reasoning !== undefined && Array.isArray(info.reasoning.efforts)
|
|
58
|
+
? info.reasoning.efforts.map((entry) => String(entry?.id ?? '')).filter((id) => id !== '')
|
|
59
|
+
: []
|
|
60
|
+
chosen = efforts.find((id) => /^(off|none|minimal|low)$/i.test(id)) ?? efforts[0] ?? ''
|
|
61
|
+
} catch {
|
|
62
|
+
chosen = ''
|
|
63
|
+
}
|
|
64
|
+
effortCache.set(key, chosen)
|
|
65
|
+
return chosen
|
|
66
|
+
}
|
|
67
|
+
|
|
47
68
|
export async function suggest(body, env) {
|
|
48
69
|
if (typeof body.prefix !== 'string' && typeof body.suffix !== 'string') throw badRequest('prefix is required')
|
|
49
70
|
const ctx = env.ctx
|
|
@@ -79,15 +100,19 @@ export async function suggest(body, env) {
|
|
|
79
100
|
'Insertion:',
|
|
80
101
|
].join('\n')
|
|
81
102
|
|
|
103
|
+
const reasoningEffort = await pickReasoningEffort(llm, provider, model)
|
|
82
104
|
const controller = new AbortController()
|
|
83
105
|
const timer = setTimeout(() => controller.abort(), 9000)
|
|
84
106
|
let text = ''
|
|
85
107
|
let failure = null
|
|
108
|
+
let finishKind = ''
|
|
109
|
+
let usage = null
|
|
86
110
|
const startedAt = Date.now()
|
|
87
111
|
try {
|
|
88
112
|
const stream = llm.stream({
|
|
89
113
|
provider,
|
|
90
114
|
model,
|
|
115
|
+
...(reasoningEffort === '' ? {} : { reasoningEffort }),
|
|
91
116
|
system: SYSTEM_PROMPT,
|
|
92
117
|
messages: [{ role: 'user', content: [{ type: 'text', text: userPrompt }] }],
|
|
93
118
|
maxTokens: 160,
|
|
@@ -99,8 +124,10 @@ export async function suggest(body, env) {
|
|
|
99
124
|
if (chunk === null || typeof chunk !== 'object') continue
|
|
100
125
|
if (chunk.type === 'text-delta' && typeof chunk.text === 'string') text += chunk.text
|
|
101
126
|
if (chunk.type === 'reasoning-delta') continue
|
|
127
|
+
if (chunk.type === 'usage') usage = chunk.usage
|
|
102
128
|
if (chunk.type === 'finish') {
|
|
103
129
|
const reason = chunk.reason
|
|
130
|
+
finishKind = reason !== null && typeof reason === 'object' && typeof reason.kind === 'string' ? reason.kind : ''
|
|
104
131
|
if (reason !== null && typeof reason === 'object' && (reason.kind === 'error' || reason.kind === 'aborted')) {
|
|
105
132
|
failure = reason.failure ?? { message: reason.kind }
|
|
106
133
|
}
|
|
@@ -117,10 +144,11 @@ export async function suggest(body, env) {
|
|
|
117
144
|
if (controller.signal.aborted) throw new ApiError('llm-timeout', '补全请求超时', 504)
|
|
118
145
|
throw new ApiError('llm-failed', `补全模型调用失败:${message}`, 502)
|
|
119
146
|
}
|
|
147
|
+
const sanitized = sanitize(text)
|
|
120
148
|
return {
|
|
121
149
|
provider,
|
|
122
150
|
model,
|
|
123
|
-
text:
|
|
151
|
+
text: sanitized,
|
|
124
152
|
latencyMs: Date.now() - startedAt,
|
|
125
153
|
}
|
|
126
154
|
}
|
package/host/fs.js
CHANGED
|
@@ -13,7 +13,6 @@ import { tmpdir } from 'node:os'
|
|
|
13
13
|
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
14
14
|
import { ApiError, badRequest } from './context.js'
|
|
15
15
|
import { registerLsp } from './lsp.js'
|
|
16
|
-
import { registerCompletion } from './completion.js'
|
|
17
16
|
|
|
18
17
|
const TEXT_LIMIT = 4 * 1024 * 1024
|
|
19
18
|
const runCommand = promisify(execFile)
|
|
@@ -286,8 +285,17 @@ export function register(router, env) {
|
|
|
286
285
|
/* Python 语言服务(LSP/pyright):/lsp/definition API;Cmd+点击与悬停由客户端调用 */
|
|
287
286
|
registerLsp(router, env)
|
|
288
287
|
|
|
289
|
-
/* Tab 行内补全:借用 Harness
|
|
290
|
-
|
|
288
|
+
/* Tab 行内补全:借用 Harness 自己的模型服务(completion.js 用带 mtime 的动态 import,改它免重启) */
|
|
289
|
+
router.method('completion.suggest', async (body) => {
|
|
290
|
+
let stamp = '0'
|
|
291
|
+
try {
|
|
292
|
+
stamp = String(statSync(new URL('./completion.js', import.meta.url)).mtimeMs)
|
|
293
|
+
} catch {
|
|
294
|
+
stamp = '0'
|
|
295
|
+
}
|
|
296
|
+
const module = await import(new URL(`./completion.js?gufa-completion=${stamp}`, import.meta.url).href)
|
|
297
|
+
return module.suggest(body, env)
|
|
298
|
+
})
|
|
291
299
|
|
|
292
300
|
/* ⌘⇧N:打开新的 Harness 实例窗口(Electron 单实例下新建 BrowserWindow)。
|
|
293
301
|
app-window.js 用带 mtime 的动态 import,改它不必重启 Host。 */
|
package/package.json
CHANGED
package/src/client/20-editor.js
CHANGED
|
@@ -481,6 +481,13 @@ const GUFA_DEFINITION_STRONG_KINDS = new Set(['function', 'class', 'method', 'de
|
|
|
481
481
|
scrollbar: { verticalScrollbarSize: 10, horizontalScrollbarSize: 10, useShadows: false },
|
|
482
482
|
mouseWheelZoom: false,
|
|
483
483
|
contextmenu: true,
|
|
484
|
+
/* 基础代码联想:显式打开自动补全与单词建议,避免依赖 Monaco 版本默认值 */
|
|
485
|
+
quickSuggestions: { other: true, comments: false, strings: false },
|
|
486
|
+
quickSuggestionsDelay: 10,
|
|
487
|
+
suggestOnTriggerCharacters: true,
|
|
488
|
+
wordBasedSuggestions: 'currentDocument',
|
|
489
|
+
acceptSuggestionOnEnter: 'on',
|
|
490
|
+
tabCompletion: 'on',
|
|
484
491
|
inlineSuggest: { enabled: true, showToolbar: 'never' },
|
|
485
492
|
}
|
|
486
493
|
}
|