Skip to content

Commit 12c805f

Browse files
author
SqlRush
committed
Resolve bridge manifest commands
1 parent 1d81046 commit 12c805f

4 files changed

Lines changed: 63 additions & 2 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ M7 补充:terminal input parser 和 configurable keybinding name parser 现在
14561456
- Chrome/computer-use/voice/native integrations。
14571457
- enterprise/gated/platform-specific behavior。
14581458

1459-
当前状态:已新增 `advanced` settings gate 地基,覆盖 bridge/LSP/telemetry/Chrome/voice/computer-use/native integrations 的独立 bool 开关解析、settings merge、headless `/config show advanced``/config search` 审计;`advanced.telemetry=true` 时会在 session 目录写入安全摘要 JSONL 诊断事件,记录事件类型、session/model、tool/progress keys、token/compact/error 摘要,不写入用户/助手正文或工具结果内容;`advanced.lsp=true` 时才向模型暴露只读 `LSPDiagnostics` 工具,用于读取 session-scoped diagnostics snapshot,并支持 file/severity/limit 过滤;`advanced.bridge=true` 时会写出 session-scoped bridge manifest,列出 bridge-safe slash/local command 元数据;未启用时仍不注册或泄露 gated 工具 schema。实际 repl bridge server、session websocket/direct connect、LSP server manager、diagnostic producer、telemetry exporter/tracing、Chrome/voice/computer-use/native runtime 仍未完成。
1459+
当前状态:已新增 `advanced` settings gate 地基,覆盖 bridge/LSP/telemetry/Chrome/voice/computer-use/native integrations 的独立 bool 开关解析、settings merge、headless `/config show advanced` 和 `/config search` 审计;`advanced.telemetry=true` 时会在 session 目录写入安全摘要 JSONL 诊断事件,记录事件类型、session/model、tool/progress keys、token/compact/error 摘要,不写入用户/助手正文或工具结果内容;`advanced.lsp=true` 时才向模型暴露只读 `LSPDiagnostics` 工具,用于读取 session-scoped diagnostics snapshot,并支持 file/severity/limit 过滤;`advanced.bridge=true` 时会写出 session-scoped bridge manifest,列出 bridge-safe slash/local command 元数据,并提供 command/display/alias 安全解析;未启用时仍不注册或泄露 gated 工具 schema。实际 repl bridge server、session websocket/direct connect、LSP server manager、diagnostic producer、telemetry exporter/tracing、Chrome/voice/computer-use/native runtime 仍未完成。
14601460

14611461
## Recommended Next Steps
14621462

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ test/parity/ # golden tests against TS/official behavior
745745
- 每个 gated feature 独立开关测试。
746746
- 不启用 feature 时二进制行为和可见 schema 不泄露 gated 工具/命令。
747747

748-
- 本轮补充:新增 `advanced` settings gate 地基,覆盖 bridge/LSP/telemetry/Chrome/voice/computer-use/native integrations 的独立 bool 开关解析、settings merge、headless `/config show advanced``/config search` 审计;`advanced.telemetry=true` 时会在 session 目录写入安全摘要 JSONL 诊断事件,记录事件类型、session/model、tool/progress keys、token/compact/error 摘要,不写入用户/助手正文或工具结果内容;`advanced.lsp=true` 时才向模型暴露只读 `LSPDiagnostics` 工具,用于读取 session-scoped diagnostics snapshot,并支持 file/severity/limit 过滤;`advanced.bridge=true` 时会写出 session-scoped bridge manifest,列出 bridge-safe slash/local command 元数据;未启用时仍不注册或泄露 gated 工具 schema。实际 repl bridge server、session websocket/direct connect、LSP server manager、diagnostic producer、telemetry exporter/tracing、Chrome/voice/computer-use/native runtime 仍未完成。
748+
- 本轮补充:新增 `advanced` settings gate 地基,覆盖 bridge/LSP/telemetry/Chrome/voice/computer-use/native integrations 的独立 bool 开关解析、settings merge、headless `/config show advanced` 和 `/config search` 审计;`advanced.telemetry=true` 时会在 session 目录写入安全摘要 JSONL 诊断事件,记录事件类型、session/model、tool/progress keys、token/compact/error 摘要,不写入用户/助手正文或工具结果内容;`advanced.lsp=true` 时才向模型暴露只读 `LSPDiagnostics` 工具,用于读取 session-scoped diagnostics snapshot,并支持 file/severity/limit 过滤;`advanced.bridge=true` 时会写出 session-scoped bridge manifest,列出 bridge-safe slash/local command 元数据,并提供 command/display/alias 安全解析;未启用时仍不注册或泄露 gated 工具 schema。实际 repl bridge server、session websocket/direct connect、LSP server manager、diagnostic producer、telemetry exporter/tracing、Chrome/voice/computer-use/native runtime 仍未完成。
749749

750750
### M12: Parity hardening
751751

internal/bridge/manifest.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"os"
77
"path/filepath"
8+
"strings"
89
"time"
910

1011
"ccgo/internal/commands"
@@ -101,3 +102,46 @@ func LoadManifest(path string) (Manifest, error) {
101102
}
102103
return manifest, nil
103104
}
105+
106+
func (m Manifest) FindCommand(raw string) (Command, bool) {
107+
name := normalizeCommandName(raw)
108+
if name == "" {
109+
return Command{}, false
110+
}
111+
for _, command := range m.Commands {
112+
if commandMatches(command, name) {
113+
return command, true
114+
}
115+
}
116+
return Command{}, false
117+
}
118+
119+
func (m Manifest) AllowsCommand(raw string) bool {
120+
_, ok := m.FindCommand(raw)
121+
return ok
122+
}
123+
124+
func commandMatches(command Command, name string) bool {
125+
if strings.EqualFold(command.Name, name) || strings.EqualFold(command.DisplayName, name) {
126+
return true
127+
}
128+
for _, alias := range command.Aliases {
129+
if strings.EqualFold(alias, name) {
130+
return true
131+
}
132+
}
133+
return false
134+
}
135+
136+
func normalizeCommandName(raw string) string {
137+
raw = strings.TrimSpace(raw)
138+
raw = strings.TrimPrefix(raw, "/")
139+
if raw == "" {
140+
return ""
141+
}
142+
fields := strings.Fields(raw)
143+
if len(fields) == 0 {
144+
return ""
145+
}
146+
return strings.TrimSpace(fields[0])
147+
}

internal/bridge/manifest_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,20 @@ func TestWriteAndLoadManifest(t *testing.T) {
6262
t.Fatalf("loaded manifest = %#v", loaded)
6363
}
6464
}
65+
66+
func TestManifestFindCommandNormalizesSlashNamesAndAliases(t *testing.T) {
67+
manifest := Manifest{Commands: []Command{
68+
{Name: "compact", Type: contracts.CommandLocal},
69+
{Name: "ask", DisplayName: "Ask", Type: contracts.CommandPrompt, Aliases: []string{"question"}},
70+
}}
71+
for _, raw := range []string{"/compact now", "compact now", "/question deploy", "Ask"} {
72+
if _, ok := manifest.FindCommand(raw); !ok {
73+
t.Fatalf("FindCommand(%q) = false", raw)
74+
}
75+
}
76+
for _, raw := range []string{"", "/", "/status", "model opus"} {
77+
if manifest.AllowsCommand(raw) {
78+
t.Fatalf("AllowsCommand(%q) = true, want false", raw)
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)