-
Notifications
You must be signed in to change notification settings - Fork 62
feat(wizard): 添加可选分组和全局 --wizard 标志支持 #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wuchulonly
wants to merge
39
commits into
chainreactors:dev
Choose a base branch
from
wuchulonly:feat/wizard-grouped-commands
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(wizard): 添加可选分组和全局 --wizard 标志支持 #79
wuchulonly
wants to merge
39
commits into
chainreactors:dev
from
wuchulonly:feat/wizard-grouped-commands
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
为 Wizard 交互式表单功能添加 huh 库支持 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- wizard.go: 定义 Wizard 结构和 Builder 模式方法 - result.go: 实现 WizardResult 结果存储和类型转换 - runner.go: 集成 huh 库实现表单执行逻辑 支持的字段类型: Input, Text, Select, MultiSelect, Confirm, Number, FilePath 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
预置常用配置向导模板: - listener_setup: 监听器配置向导 - tcp_pipeline: TCP 管道配置向导 - http_pipeline: HTTP 管道配置向导 - profile_create: Profile 创建向导 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
实现 Wizard 的 Lua 接口,支持在 MAL 脚本中构建交互式向导: - wizard(id, title): 创建新向导 - wizard_template(name): 加载预定义模板 - wizard_templates(): 列出所有模板 支持链式调用: wiz:input():select():confirm():run() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
实现 wizard 命令行接口: - wizard list: 列出所有可用向导模板 - wizard run <name>: 运行指定向导 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
在 NewLuaVM 中注册 wizard metatable 和全局函数, 使所有 MAL 脚本都能使用 wizard 功能 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
测试覆盖: - Wizard Builder 模式 - WizardResult 类型转换 - 模板注册和获取 - Wizard 克隆功能 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
移除未使用的 wizardfw 导入和 Initialize 调用, wizard 功能已通过 vm.go 中的 Lua VM 初始化集成 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- ai.go: 实现 AI API 客户端,支持 OpenAI 和 Claude - 支持流式响应 - 支持多种模型配置 - ai_cache.go: 实现 AI 补全缓存机制 - LRU 缓存策略 - 减少重复 API 调用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
实现 AI 相关命令: - ai config: 配置 AI 设置 (API Key, 模型等) - ai ask: 向 AI 提问 - ai analyze: 分析命令输出或会话数据 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
实现命令有效性验证,用于 AI 补全功能: - 验证命令是否存在 - 验证命令参数格式 - 支持子命令验证 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
实现基于 AI 的智能命令补全: - 根据上下文生成补全建议 - 支持自然语言描述转命令 - 集成到 readline 补全系统 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- ai_complete.go: 实现控制台 AI 补全接口 - console.go: 添加 AI 补全支持和配置 - go.mod: 更新依赖 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
修改 readline 组件以支持 AI 补全功能: - completion.go: 集成 AI 补全回调 - inputrc/bind.go: 添加 AI 补全快捷键绑定 - internal/display/engine.go: 优化显示引擎 - shell.go: 添加 AI 补全配置接口 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
在设置中添加 AI 相关配置: - API Key 配置 - 模型选择 - 超时设置 - 补全开关 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
在 Console 结构中添加 AI 相关组件: - AICompletionEngine: AI 补全引擎 - AICache: 补全缓存 - CommandValidator: 命令验证器 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 Field() 方法返回当前字段以便链式设置属性 - 添加 SetRequired() 和 SetValidate() 方法支持字段验证 - 添加常用验证器: ValidateHost, ValidatePort, ValidateRange, ValidateFloat - 完善测试用例 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 新增 WizardSpec 和 FieldSpec 结构体用于序列化定义 - 支持从 YAML/JSON 文件加载 wizard 定义 - 支持从嵌入资源 (embed://) 加载 spec - 支持从 Lua map 转换为 WizardSpec - 添加 RegisterTemplateFromSpec 方便注册 spec 定义的模板 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 Lua wizard builder API - 支持在 Lua 中定义和运行 wizard - 支持从 Lua table 注册 wizard 模板 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 WizardCategory 和 WizardEntry 类型定义 wizard 分组 - 定义四个分类: build, pipeline, cert, config - 定义三个独立命令: listener, profile, infra - 添加 RunSelect() 函数实现交互式选择菜单 - 为 Select 字段添加默认选中第一项的逻辑 - 重构 commands.go 支持分组子命令 - 改进 wizard list 以分组方式展示 用法示例: wizard build # 交互式选择构建类型 wizard build beacon # 直接运行 build_beacon wizard pipeline tcp # 直接运行 tcp_pipeline wizard listener # 运行 listener_setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 WizardExecutor 类型和注册机制 - wizard 完成后可自动调用对应执行器执行实际操作 - 添加 executors.go 存放各 wizard 的具体执行逻辑 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 插件可通过 Lua API 注册自定义 wizard 模板 - 添加 wizard_templates.go 管理插件注册的模板 - 支持从插件 resources/wizards 目录加载 spec 文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 AI 补全快捷键支持 - 改进补全引擎逻辑 - 添加新的快捷键绑定 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 build_beacon 执行器 - 添加 build_pulse 执行器 - 添加 build_prelude 执行器 - 添加 build_module 执行器 - 添加 getFloat64 和 getStringSlice 辅助函数 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 新增 WizardForm 组件实现两层选择器界面 - 新增 HorizontalSelect 和 HorizontalMultiSelect 组件 - 添加 RunCompact() 和 RunTwoPhase() 运行模式 - 重构 executors.go 辅助函数,统一类型处理 - 重构 wizard_templates.go 使用 specWalker 简化逻辑 - 添加 executors_test.go 测试用例 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加菜单作用域缓存 (GetScoped/SetScoped/GetPrefixScoped) - 改进补全逻辑,只显示补全部分而非完整命令 - 添加 GetCommandsForMenu/IsCommandAllowedInMenu 方法实现菜单感知验证 - 添加 NewCommandValidatorWithMenu 和 AddCommandsFromCobra 支持按菜单注册命令 - 过滤与用户输入完全相同的建议 - 增加建议数量上限到 10 个 - 跳过 shell 转义语法 (! 前缀) - 添加 command_validator_test.go 测试用例 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 智能处理补全前缀:当用户输入以空格结尾时剥离命令前缀 - 跳过与用户输入完全相同的建议 - 避免显示空候选项 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 OptionsProvider 接口支持运行时动态填充选项 - 添加 PrepareOptions() 方法在运行前调用所有提供者 - 水平选择器添加编辑模式 (按 e 键进入) - 将模板中的静态 Input 改为 Select 以支持动态选项 - 改进空值显示为 "(空)" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 wizard run 命令的模板名称补全 - 添加分类命令的子命令补全 - 新增 providers.go 实现动态选项提供者: - ProfileOptionsProvider: 从服务器获取配置文件列表 - ListenerOptionsProvider: 从服务器获取监听器列表 - PipelineOptionsProvider: 从服务器获取管道列表 - ArtifactOptionsProvider: 从服务器获取构件列表 - AddressOptionsProvider: 从管道中提取 C2 地址 - 添加 setupDynamicProviders 自动为已知字段设置提供者 - executors.go 添加 checkPortAvailable 端口可用性检查 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- explorer: 改进 reg_explorer 命令用法说明和示例 - privilege: 修正 runas 命令参数名 (--program -> --path),添加路径补全 - reg: 为 reg add 命令的 --type 参数添加值补全 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
主要改动: - 用 grouped_form 替换 horizontal_select/multiselect 组件 - 添加 AskPrediction 方法支持低延迟 AI 预测 - 改进 readline 补全引擎和显示逻辑 - 优化 build/cert 命令和 flagset 处理 - 改进 cryptography 和 certutils 模块 - 更新 intl/community 子模块 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- WizardGroup 新增 Optional 和 Expanded 属性 - 可选分组默认折叠,用户可按 Enter/Space 展开 - 按 c 键可折叠已展开的可选分组 - 支持在 YAML/JSON spec 中通过 optional 字段定义可选分组 - 添加 AsOptional() 和 SetExpanded() 链式方法 - 修复 lipgloss OSC 终端查询与 readline 冲突问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 新增 CobraToWizard() 将 cobra.Command 的 flags 自动转换为 Wizard - 支持 ui:group 注解按组分类字段 - 支持 ui:order 注解控制字段排序 - 支持 ui:options 注解将字段转为 Select 类型 - 支持 ui:required/ui:widget 等注解 - 新增 ApplyWizardResultToFlags() 将结果写回 flags - 支持编辑模式:读取当前 flag 值作为默认值 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 新增 RegisterWizardFlag() 注册全局 --wizard 标志 - 新增 WrapWithWizardSupport() 包装 PreRunE 支持 wizard 模式 - 任意命令添加 --wizard 即可启动交互式向导填写参数 - 在 root.go 和 client.go 中集成 wizard 支持 - 添加 carapace 补全使子命令继承 PersistentFlags 用法: iom <command> --wizard 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 添加 TestGroupedWizardForm_OptionalGroups 测试可选分组功能 - 添加 cobra_test.go 测试 CobraToWizard 转换逻辑 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 将 wizard 相关的中文注释和消息改为英文 - 添加 minInt 辅助函数以兼容旧版 Go(不依赖内置 min) - 调整依赖版本以提高兼容性 - 移除 RunSelect 的 Inline 选项 - 更新配置文件模板 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 恢复 go.mod 到原版(使用新版 charmbracelet) - 完成剩余文件的中文注释英文化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
f028fbd to
11536ce
Compare
- Go 版本升级到 1.23.0(miekg/dns 依赖要求) - 添加 charmbracelet/huh 依赖 - 使用 chainreactors/tui 原版 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
11536ce to
fccd136
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
本 PR 包含完整的 Wizard 交互式向导系统 和 AI 命令补全引擎。
1. Wizard 核心框架
client/wizard/包,实现交互式表单向导2. Wizard 模板系统
3. Wizard 执行器
executors.go,wizard 完成后自动执行对应操作4. Cobra 命令转 Wizard
CobraToWizard()自动将 cobra.Command flags 转为 Wizardui:group、ui:order、ui:options等注解--wizard标志,任意命令可启动向导模式5. Lua 脚本集成
lua.go,提供 Lua API 创建和运行 wizardwizard.new()、wizard:add_field()、wizard:run()等方法6. AI 命令补全引擎
client/core/ai.go,AI 驱动的智能命令补全client/core/command_validator.go,命令语法验证client/command/ai/子命令:ask、analyze、config?快捷命令,等价于ai ask7. readline 增强
8. 其他改进
主要文件
client/wizard/*.goclient/command/wizard/client/core/ai.goclient/core/command_validator.goclient/command/ai/external/readline/用法示例