@kaitranntt/ccs 4.3.1 → 4.3.3

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.
@@ -1,174 +0,0 @@
1
- # Headless Workflow
2
-
3
- **Last Updated**: 2025-11-15
4
-
5
- CCS delegation uses Claude Code headless mode with enhanced features for token optimization.
6
-
7
- ## Core Concept
8
-
9
- CCS delegation executes tasks via alternative models using enhanced Claude Code headless mode with stream-JSON output, session management, and cost tracking.
10
-
11
- **Actual Command:**
12
- ```bash
13
- ccs {profile} -p "prompt"
14
- ```
15
-
16
- Internally executes:
17
- ```bash
18
- claude -p "prompt" --settings ~/.ccs/{profile}.settings.json --output-format stream-json --permission-mode acceptEdits
19
- ```
20
-
21
- **Docs:** https://code.claude.com/docs/en/headless.md
22
-
23
- ## How It Works
24
-
25
- **Workflow:**
26
- 1. User: `/ccs:glm "task"` in Claude Code session
27
- 2. CCS detects `-p` flag and routes to HeadlessExecutor
28
- 3. HeadlessExecutor spawns: `claude -p "task" --settings ~/.ccs/glm.settings.json --output-format stream-json --permission-mode acceptEdits`
29
- 4. Claude Code runs headless with GLM profile + enhanced flags
30
- 5. Returns stream-JSON with session_id, cost, turns
31
- 6. Real-time tool use visibility in TTY
32
- 7. ResultFormatter displays formatted results with metadata
33
-
34
- **Enhanced Features:**
35
- - Stream-JSON output parsing (`--output-format stream-json`)
36
- - Real-time tool use visibility (e.g., `[Tool Use: Bash]`)
37
- - Session persistence (`~/.ccs/delegation-sessions.json`)
38
- - Cost tracking (displays USD cost per execution)
39
- - Time-based limits (10 min default timeout with graceful termination)
40
- - Multi-turn session management (resume via session_id)
41
- - Formatted ASCII box output
42
-
43
- ## Profile Settings
44
-
45
- **Location:** `~/.ccs/{profile}.settings.json`
46
-
47
- **Examples:**
48
- - GLM: `~/.ccs/glm.settings.json`
49
- - Kimi: `~/.ccs/kimi.settings.json`
50
-
51
- **Example content:**
52
- ```json
53
- {
54
- "env": {
55
- "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
56
- "ANTHROPIC_AUTH_TOKEN": "your-glm-api-key",
57
- "ANTHROPIC_MODEL": "glm-4.6"
58
- }
59
- }
60
- ```
61
-
62
- ## Output Format
63
-
64
- **Stream-JSON Mode** (automatically enabled):
65
- Each message is a separate JSON object (jsonl format):
66
- ```json
67
- {"type":"init","session_id":"abc123def456"}
68
- {"type":"user","message":{"role":"user","content":"Task description"}}
69
- {"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","name":"Bash"}]}}
70
- {"type":"result","subtype":"success","total_cost_usd":0.0025,"num_turns":3,"session_id":"abc123def456","result":"Task completed"}
71
- ```
72
-
73
- **Real-time Progress** (TTY only):
74
- ```
75
- [i] Delegating to GLM-4.6...
76
- [Tool Use: Write]
77
- [Tool Use: Write]
78
- [Tool Use: Bash]
79
- [i] Execution completed in 1.5s
80
- ```
81
-
82
- **Formatted Output** (displayed to user):
83
- ```
84
- ╔══════════════════════════════════════════════════════╗
85
- ║ Working Directory: /path/to/project ║
86
- ║ Model: GLM-4.6 ║
87
- ║ Duration: 1.5s ║
88
- ║ Exit Code: 0 ║
89
- ║ Session ID: abc123de ║
90
- ║ Cost: $0.0025 ║
91
- ║ Turns: 3 ║
92
- ╚══════════════════════════════════════════════════════╝
93
- ```
94
-
95
- **Extracted Fields:**
96
- - `session_id` - For multi-turn (--resume)
97
- - `total_cost_usd` - Cost per execution
98
- - `num_turns` - Turn count
99
- - `is_error` - Error flag
100
- - `result` - Task output
101
-
102
- **Exit codes:** 0 = success, non-zero = error
103
-
104
- ## Multi-Turn Sessions
105
-
106
- **Start session:**
107
- ```bash
108
- ccs glm -p "implement feature"
109
- ```
110
-
111
- **Continue session:**
112
- ```bash
113
- ccs glm:continue -p "add tests"
114
- ccs glm:continue -p "run tests"
115
- ```
116
-
117
- Via slash commands:
118
- ```
119
- /ccs:glm "implement feature"
120
- /ccs:glm:continue "add tests"
121
- ```
122
-
123
- **Session Storage:** `~/.ccs/delegation-sessions.json`
124
-
125
- **Metadata:**
126
- - Session ID
127
- - Total cost (aggregated across turns)
128
- - Turn count
129
- - Last turn timestamp
130
- - Working directory
131
-
132
- **Expiration:** ~30 days, auto-cleanup
133
-
134
- ## Usage Patterns
135
-
136
- **Single execution:**
137
- ```bash
138
- ccs glm -p "task description"
139
- ```
140
-
141
- **With options:**
142
- ```bash
143
- ccs glm -p "task" --permission-mode plan
144
- ```
145
-
146
- **Continue session:**
147
- ```bash
148
- ccs glm:continue -p "follow-up task"
149
- ```
150
-
151
- All standard Claude Code headless flags are supported. See: https://code.claude.com/docs/en/headless.md
152
-
153
- ## Error Handling
154
-
155
- **Common errors:**
156
- - `Settings file not found` - Profile not configured (`ccs doctor` to diagnose)
157
- - `Claude CLI not found` - Install Claude Code
158
- - `Invalid API key` - Check profile settings in `~/.ccs/{profile}.settings.json`
159
-
160
- **Diagnostics:**
161
- ```bash
162
- ccs doctor # Check configuration
163
- ccs --version # Show delegation status
164
- ```
165
-
166
- ---
167
-
168
- ## Related Documentation
169
-
170
- **Entry Point**: `../SKILL.md` - Quick start and decision framework
171
- **Decision Guide**: `delegation-guidelines.md` - When to delegate
172
- **Error Recovery**: `troubleshooting.md` - Common issues
173
-
174
- **Official Docs**: https://code.claude.com/docs/en/headless.md