How wild-work3/ww3-chatglm-cli works
chatglm-cli is a non-interactive Go CLI for ChatGLM’s private interfaces. Its main workflow reads a prompt, authenticates, streams conversation events as JSONL, and lets callers resume explicitly with a conversation ID. Separate command branches cover conversation management, account/model information, raw endpoint access, and image generation, including reference-image preparation and upload. The map reflects README-documented capabilities as well as sampled calls; unsampled command wiring is omitted where the excerpts do not establish it.
Main entry points: cli.go Command dispatch · cmd_chat.go Chat command · imagesgen.go Image generation · client.go HTTP API client
Components 21
CLI commands
- CLI entry
cmd/glm2cli/main.go - Command dispatch
internal/cli/cli.go - Chat command
internal/cli/cmd_chat.go - Conversation commands
internal/cli/cmd_conv.go - Account and model queries
internal/cli/cmd_info.go - Raw endpoint command
internal/cli/cmd_raw.go - Image command
internal/cli/cmd_chat.go
ChatGLM access
- Credential loading
internal/glm/cred.go - Token refresh
internal/glm/client.go - HTTP API client
internal/glm/client.go - SSE stream parsing
internal/glm/sse.go - Chat generation
internal/channel/chatgen.go - Conversation history and control
internal/glm/history.go
Image generation
- Image generation
internal/channel/imagesgen.go - Reference sheet builder
internal/imgutil/refsheet.go - Image hosting upload
internal/imgutil/upload.go
Output and IPC
- JSONL event output
internal/protocol/jsonl/jsonl.go - Plugin IPC runner
internal/protocol/plugin/plugin.go
Other components
- Human or agent
- Image hosting services
- ChatGLM service
Connections 22
- Human or agent → CLI entry: runs
README.md - CLI entry → Command dispatch: starts
cmd/glm2cli/main.go - Command dispatch → Chat command: routes chat
README.md - Command dispatch → Conversation commands: routes conv
README.md - Command dispatch → Account and model queries: routes info
README.md - Command dispatch → Raw endpoint command: routes raw
README.md - Chat command → Credential loading: loads credentials
README.md - HTTP API client → Token refresh: refreshes token
internal/glm/client.go - Credential loading → HTTP API client: supplies credentials
README.md - Chat command → ChatGLM service: streams chat
README.md - Chat command → SSE stream parsing: parses stream
- Chat command → JSONL event output: emits JSONL
README.md - Conversation commands → Conversation history and control: reads and controls
internal/cli/cmd_conv.go - Account and model queries → ChatGLM service: queries account data
README.md - Raw endpoint command → HTTP API client: sends endpoint request
- Image command → Plugin IPC runner: invokes image method
internal/cli/cmd_chat.go - Plugin IPC runner → Image generation: dispatches method
- Image generation → Reference sheet builder: builds reference sheet
internal/channel/imagesgen.go - Image generation → Image hosting upload: uploads references
README.md - Image hosting upload → Image hosting services: stores image
README.md - Image generation → ChatGLM service: requests image generation
README.md - Image command → JSONL event output: emits progress
README.md