Skip to content

Commit bbd6148

Browse files
committed
chore: 前端资源更新与后端权限逻辑重构
1. 前端:更新静态资源哈希版本,替换旧版chunk与diagram文件 2. 后端:重构权限审批逻辑,移除旧的缓存授权机制,改用magic word方式处理权限恢复 3. 测试:更新测试用例中的校验关键词 4. 配置:调整模型温度参数,更新go依赖与本地替换配置 5. 文档:精简产品经理与代码评审助手的角色文档
1 parent d0b722c commit bbd6148

94 files changed

Lines changed: 527 additions & 1170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

REFACTORING.md

Lines changed: 0 additions & 194 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
require (
2626
github.com/DotNetAge/gochat v0.2.7
2727
github.com/DotNetAge/gograph v0.2.6
28-
github.com/DotNetAge/goharness v0.2.5
28+
github.com/DotNetAge/goharness v0.2.6
2929
github.com/DotNetAge/gorag/v2 v2.0.3
3030
github.com/creack/pty v1.1.24
3131
go.etcd.io/bbolt v1.4.3
@@ -140,4 +140,4 @@ require (
140140

141141
replace github.com/coder/hnsw => ./third_party/hnsw
142142

143-
replace github.com/DotNetAge/goharness => ../goharness
143+
// replace github.com/DotNetAge/goharness => ../goharness

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ github.com/DotNetAge/gochat v0.2.7 h1:W06T9dRx46QlWkFDlpRSGtpdgNb8m9meTPxycRX/xZ
1515
github.com/DotNetAge/gochat v0.2.7/go.mod h1:w7m36rMZoDwmReJNTLUGHhok6DSqnIidg9wFKwYM1dM=
1616
github.com/DotNetAge/gograph v0.2.6 h1:LhYERtYTPaWXvbBy9bO/6XGmYTW/OZGXQ+zyfycsexo=
1717
github.com/DotNetAge/gograph v0.2.6/go.mod h1:Ia2wvbkpdJvFJEZ1vw+IklbhNbWjPli2dnU21jbmy7I=
18+
github.com/DotNetAge/goharness v0.2.6 h1:WNaMfX8Hk9JZ8LUxyAtC9X/pwWhWHX6guRsSdS0NId8=
19+
github.com/DotNetAge/goharness v0.2.6/go.mod h1:2+Ze4Att5hP3oRR9/5Rqv506hr38G5qwaWQz6ChOu8c=
1820
github.com/DotNetAge/gorag/v2 v2.0.3 h1:utCl5dKBoMQPkqUYDS1xS5S46gW4tR/L58thEhYNuzg=
1921
github.com/DotNetAge/gorag/v2 v2.0.3/go.mod h1:K8YAydeJR41JMY59xrzgMNDKRHVg3cwB2pYwJSwVjbE=
2022
github.com/DotNetAge/gort v0.1.4 h1:nUZdy3cN3Kif21GWIYkxlIS/iFr62eN5boBmCzmI3xw=

internal/client/client.go

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ type rootModel struct {
9595
rpc *daemonRPCClient
9696
rpcConnected bool
9797

98-
// localGrantCache stores granted permissions for the current session (non-RPC only).
99-
// Used by WithGrantCache to allow non-blocking permission resumption in local mode.
100-
localGrantCache map[string]map[string]bool
101-
10298
// currentSessionID tracks the active session ID used in RPC messages.
10399
currentSessionID string
104100
}
@@ -1024,7 +1020,6 @@ func (m *rootModel) Update(e tea.Msg) (tea.Model, tea.Cmd) {
10241020

10251021
case clientmsg.ChoiceSelectedMsg:
10261022
m.statusBar.CurrentState = i18n.T("client.status.idle")
1027-
toolName := m.permBar.ToolName
10281023
m.permBar = permission.PermissionBar{}
10291024

10301025
if msg.Index < 0 {
@@ -1033,30 +1028,27 @@ func (m *rootModel) Update(e tea.Msg) (tea.Model, tea.Cmd) {
10331028
}
10341029

10351030
if msg.Index == permission.PermissionAllow {
1031+
// Permission resumption is now driven entirely by the
1032+
// PermissionAllow / PermissionDeny magic words. The runtime
1033+
// intercepts the magic word, drains session.PendingPermission,
1034+
// and runs (Allow) or denies (Deny) the tool.
1035+
//
1036+
// The legacy non-blocking "store-then-resend" flow (which relied
1037+
// on a server-side GrantCache) has been removed. We keep the
1038+
// resend step so the LLM gets a fresh turn to call the tool
1039+
// again with the magic word now in flight as a user message —
1040+
// the runtime will resolve it before re-running the tool.
10361041
if m.rpcConnected {
1037-
// RPC path: call execution.resume to store grant in daemon cache,
1038-
// then resend last user message to re-enter the LLM loop.
1039-
if m.currentSessionID != "" && toolName != "" {
1040-
go func() {
1041-
_, _ = m.rpc.client.Call(context.Background(), "execution.resume", map[string]any{
1042-
"session_id": m.currentSessionID,
1043-
"tool_name": toolName,
1044-
})
1045-
}()
1046-
// Resend last user message silently.
1047-
if lastMsg := m.getLastUserMessage(); lastMsg != "" {
1048-
m.rpcSendMessage(lastMsg)
1049-
}
1042+
// RPC path: resend the last user message. The user message
1043+
// should already carry the PermissionAllow magic word
1044+
// (set by the chat store when the user clicked Approve).
1045+
if lastMsg := m.getLastUserMessage(); lastMsg != "" {
1046+
m.rpcSendMessage(lastMsg)
10501047
}
10511048
} else {
1052-
// Local path: store in local grant cache, then resend.
1053-
if m.localGrantCache == nil {
1054-
m.localGrantCache = make(map[string]map[string]bool)
1055-
}
1056-
if m.localGrantCache[m.currentSessionID] == nil {
1057-
m.localGrantCache[m.currentSessionID] = make(map[string]bool)
1058-
}
1059-
m.localGrantCache[m.currentSessionID][toolName] = true
1049+
// Local path: resend last user message through the
1050+
// program. The user message carries the PermissionAllow
1051+
// magic word that the runtime intercepts.
10601052
if lastMsg := m.getLastUserMessage(); lastMsg != "" {
10611053
m.program.Send(clientmsg.UserSendMsg{Text: lastMsg})
10621054
}
@@ -1290,14 +1282,13 @@ func (m *rootModel) handleSend(e clientmsg.UserSendMsg) (tea.Model, tea.Cmd) {
12901282
TokensUsed: tokenUsage,
12911283
})
12921284
})
1293-
// Set up local grant cache for non-blocking permission resumption.
1294-
rt.WithGrantCache(func(sessionID, toolName string) bool {
1295-
if m.localGrantCache == nil {
1296-
return false
1297-
}
1298-
tools, ok := m.localGrantCache[sessionID]
1299-
return ok && tools[toolName]
1300-
})
1285+
// NOTE: Old WithGrantCache / localGrantCache non-blocking permission
1286+
// flow has been removed. Permission resumption now flows through
1287+
// the PermissionAllow / PermissionDeny magic words (see
1288+
// agents.resolvePermissionMagicWord). The runtime intercepts the
1289+
// magic word before it reaches the LLM, drains
1290+
// session.PendingPermission, and runs the tool (Allow) or appends
1291+
// a "Permission Denied" result (Deny).
13011292

13021293
ask.OnAskUserPending(func(d events.AskUserPendingData) {
13031294
m.pendingAskUserData = &d

internal/core/app.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,12 @@ func (a *App) IsModelAvailable(name ...string) bool {
837837
}
838838

839839
func BuildDelegationGuidance() string {
840-
return `## Delegation
841-
When a task is outside your expertise, choose one path:
840+
return `## Execution
841+
Pick one path:
842842
843-
- **Know who handles it** → call **SubAgent** tool directly (agent_name + task), then **CollectResults**
844-
- **Don't know who** → load **find-experts** skill first (discovers experts, then delegates via same workflow)`
843+
- **Within your remit, multiple steps** → decompose with task tools
844+
- **Outside your remit, single expert** → delegate to the right expert
845+
- **Cross-domain collaboration** → form a team and delegate to an expert panel`
845846
}
846847

847848
func (a *App) SwitchSession(sessionID string) (*session.SessionInfo, error) {

internal/core/app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ func TestBuildDelegationGuidance(t *testing.T) {
259259
if guidance == "" {
260260
t.Error("BuildDelegationGuidance should not return empty")
261261
}
262-
if !contains(guidance, "SubAgent") {
263-
t.Error("BuildDelegationGuidance should mention SubAgent")
262+
if !contains(guidance, "Execution") {
263+
t.Error("BuildDelegationGuidance should mention Execution")
264264
}
265265
}
266266

0 commit comments

Comments
 (0)