kiro-tap 0.1.0__tar.gz
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.
- kiro_tap-0.1.0/.gitignore +11 -0
- kiro_tap-0.1.0/LICENSE +21 -0
- kiro_tap-0.1.0/PKG-INFO +172 -0
- kiro_tap-0.1.0/README.md +141 -0
- kiro_tap-0.1.0/README_en.md +143 -0
- kiro_tap-0.1.0/kiro_tap/__init__.py +62 -0
- kiro_tap-0.1.0/kiro_tap/__main__.py +5 -0
- kiro_tap-0.1.0/kiro_tap/aws_event_stream.py +411 -0
- kiro_tap-0.1.0/kiro_tap/certs.py +277 -0
- kiro_tap-0.1.0/kiro_tap/cli.py +1052 -0
- kiro_tap-0.1.0/kiro_tap/dashboard.html +1738 -0
- kiro_tap-0.1.0/kiro_tap/dashboard.py +860 -0
- kiro_tap-0.1.0/kiro_tap/export.py +315 -0
- kiro_tap-0.1.0/kiro_tap/forward_proxy.py +885 -0
- kiro_tap-0.1.0/kiro_tap/history.py +34 -0
- kiro_tap-0.1.0/kiro_tap/live.py +442 -0
- kiro_tap-0.1.0/kiro_tap/proxy.py +443 -0
- kiro_tap-0.1.0/kiro_tap/py.typed +0 -0
- kiro_tap-0.1.0/kiro_tap/shared_dashboard.py +236 -0
- kiro_tap-0.1.0/kiro_tap/sse.py +274 -0
- kiro_tap-0.1.0/kiro_tap/trace.py +97 -0
- kiro_tap-0.1.0/kiro_tap/trace_log_handler.py +34 -0
- kiro_tap-0.1.0/kiro_tap/trace_store.py +936 -0
- kiro_tap-0.1.0/kiro_tap/usage.py +35 -0
- kiro_tap-0.1.0/kiro_tap/viewer.html +5708 -0
- kiro_tap-0.1.0/kiro_tap/viewer.py +771 -0
- kiro_tap-0.1.0/kiro_tap/viewer_i18n.json +707 -0
- kiro_tap-0.1.0/kiro_tap/ws_proxy.py +501 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/PKG-INFO +172 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/SOURCES.txt +39 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/dependency_links.txt +1 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/entry_points.txt +2 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/requires.txt +13 -0
- kiro_tap-0.1.0/kiro_tap.egg-info/top_level.txt +1 -0
- kiro_tap-0.1.0/pyproject.toml +90 -0
- kiro_tap-0.1.0/setup.cfg +4 -0
- kiro_tap-0.1.0/tests/__init__.py +0 -0
- kiro_tap-0.1.0/tests/conftest.py +13 -0
- kiro_tap-0.1.0/tests/test_aws_event_stream.py +219 -0
- kiro_tap-0.1.0/tests/test_kiro_launch.py +82 -0
- kiro_tap-0.1.0/tests/test_path_allowlist.py +28 -0
kiro_tap-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Harllan He
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
kiro_tap-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kiro-tap
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Trace Kiro CLI and Kiro IDE API requests via a local forward proxy. Inspect system prompts, messages, tools, and token usage.
|
|
5
|
+
Author: kiro-tap contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: kiro,kiro-cli,trace,proxy,api,llm,aws,codewhisperer
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
16
|
+
Classifier: Topic :: Software Development :: Testing
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: aiohttp<4,>=3.9
|
|
21
|
+
Requires-Dist: backports-zstd>=1.0; python_version < "3.14"
|
|
22
|
+
Requires-Dist: cryptography>=42.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-timeout>=2.3; extra == "dev"
|
|
27
|
+
Requires-Dist: pexpect>=4.9; extra == "dev"
|
|
28
|
+
Requires-Dist: coverage>=7.6; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff>=0.11; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# kiro-tap
|
|
33
|
+
|
|
34
|
+
[](https://www.python.org/)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
|
|
37
|
+
`kiro-tap` 是 Kiro CLI 和 Kiro IDE 的本地代理与请求追踪工具。通过它运行 Kiro,即可实时捕获所有 API 请求:系统提示词、对话历史、工具定义、工具调用、流式响应和 Token 用量。
|
|
38
|
+
|
|
39
|
+
支持 [Kiro CLI](https://kiro.dev)(`kiro-cli-chat`)和 [Kiro IDE](https://kiro.dev)。
|
|
40
|
+
|
|
41
|
+
## 为什么用它
|
|
42
|
+
|
|
43
|
+
- 👀 **看清真实上下文**:查看发往 Kiro API 的完整请求,包括系统提示、消息历史、工具定义、工具调用和响应内容
|
|
44
|
+
- 🔎 **有据可查地调试**:对比相邻请求,精确定位哪条消息、哪个工具或哪个参数发生了变化
|
|
45
|
+
- 📦 **一个可分享的文件**:每次运行生成本地 trace,可导出为自包含的 HTML 查看器,方便存档或分享
|
|
46
|
+
- 🔒 **数据留在本机**:无需任何云端 Dashboard,常见认证 Header 在记录前自动脱敏
|
|
47
|
+
- ⚡ **AWS Event Stream 原生支持**:正确解析 Kiro 使用的 AWS Event Stream 二进制帧协议,完整还原流式响应
|
|
48
|
+
|
|
49
|
+
## 安装
|
|
50
|
+
|
|
51
|
+
需要 Python 3.11+。
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 推荐
|
|
55
|
+
uv tool install kiro-tap
|
|
56
|
+
|
|
57
|
+
# 或使用 pip
|
|
58
|
+
pip install kiro-tap
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
升级:`kiro-tap update`、`uv tool upgrade kiro-tap` 或 `pip install --upgrade kiro-tap`
|
|
62
|
+
|
|
63
|
+
## 快速开始
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Kiro CLI(默认,实时 Dashboard 默认开启)
|
|
67
|
+
kiro-tap
|
|
68
|
+
|
|
69
|
+
# Kiro IDE
|
|
70
|
+
kiro-tap --tap-client kiro-ide
|
|
71
|
+
|
|
72
|
+
# 关闭实时 Dashboard
|
|
73
|
+
kiro-tap --tap-no-live
|
|
74
|
+
|
|
75
|
+
# 不自动打开浏览器
|
|
76
|
+
kiro-tap --tap-no-open
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 工作原理
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
kiro-tap 启动本地正向代理
|
|
83
|
+
↓
|
|
84
|
+
注入 HTTPS_PROXY + SSL_CERT_FILE 到子进程环境
|
|
85
|
+
↓
|
|
86
|
+
启动 kiro-cli-chat(或 kiro)
|
|
87
|
+
↓
|
|
88
|
+
所有 HTTPS 流量经过本地代理 → TLS 终止 → 转发到 q.us-east-1.amazonaws.com
|
|
89
|
+
↓
|
|
90
|
+
AWS Event Stream 二进制帧解析 → 重建完整响应
|
|
91
|
+
↓
|
|
92
|
+
写入本地 SQLite trace 数据库
|
|
93
|
+
↓
|
|
94
|
+
实时推送到浏览器 Dashboard(SSE)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
kiro-tap 使用**正向代理模式**(CONNECT + TLS 终止),因为 Kiro CLI 没有暴露 base URL 环境变量。代理会自动生成本地 CA 证书并注入到子进程,无需 sudo。
|
|
98
|
+
|
|
99
|
+
## CLI 选项
|
|
100
|
+
|
|
101
|
+
所有 `--tap-*` 之外的参数都会透传给 Kiro 客户端。
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
--tap-client CLIENT 要启动的客户端:kiro(默认)或 kiro-ide
|
|
105
|
+
--tap-target URL 上游 API URL(默认:https://q.us-east-1.amazonaws.com)
|
|
106
|
+
--tap-live 运行时开启实时 Dashboard(默认:开)
|
|
107
|
+
--tap-no-live 关闭实时 Dashboard
|
|
108
|
+
--tap-live-port PORT 实时 Dashboard 端口(默认:19528)
|
|
109
|
+
--tap-no-open 不自动在浏览器中打开 Dashboard 或生成的 HTML
|
|
110
|
+
--tap-output-dir DIR 旧版 trace 目录(默认:./.traces)
|
|
111
|
+
--tap-port PORT 代理端口(默认:自动)
|
|
112
|
+
--tap-host HOST 绑定地址(默认:127.0.0.1)
|
|
113
|
+
--tap-no-launch 只启动代理,不启动客户端
|
|
114
|
+
--tap-max-traces N 保留的最大 trace 会话数(默认:50,0 = 不限)
|
|
115
|
+
--tap-store-stream-events 持久化原始 AWS Event Stream 帧数组(默认:关)
|
|
116
|
+
--tap-no-update-check 禁用启动时的 PyPI 更新检查
|
|
117
|
+
--tap-no-auto-update 检查更新但不自动下载
|
|
118
|
+
--tap-trust-ca 在 macOS 用户登录钥匙串中信任本地 CA(无需 sudo)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 子命令
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 浏览历史 trace
|
|
125
|
+
kiro-tap dashboard
|
|
126
|
+
|
|
127
|
+
# 将 JSONL trace 导出为 HTML / Markdown / JSON
|
|
128
|
+
kiro-tap export .traces/session.jsonl -o trace.html
|
|
129
|
+
|
|
130
|
+
# 升级 kiro-tap
|
|
131
|
+
kiro-tap update
|
|
132
|
+
|
|
133
|
+
# 在 macOS 钥匙串中信任本地 CA(正向代理模式需要)
|
|
134
|
+
kiro-tap trust-ca
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## 仅代理模式
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# 只启动代理,在另一个终端手动启动 Kiro
|
|
141
|
+
kiro-tap --tap-no-launch --tap-port 8080
|
|
142
|
+
|
|
143
|
+
# 然后在另一个终端:
|
|
144
|
+
HTTPS_PROXY=http://127.0.0.1:8080 SSL_CERT_FILE=~/.kiro-tap/ca.pem kiro-cli-chat
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Viewer 功能
|
|
148
|
+
|
|
149
|
+
生成的 HTML 查看器(零外部依赖)支持:
|
|
150
|
+
|
|
151
|
+
- **结构化 Diff**:对比相邻请求,查看消息、系统提示、工具的变化
|
|
152
|
+
- **路径过滤**:按 API 端点过滤(如只看 `/generateAssistantResponse`)
|
|
153
|
+
- **Token 用量**:输入 / 输出 / 缓存读取 / 缓存写入
|
|
154
|
+
- **工具检查器**:可展开的工具卡片,含名称、描述和参数 schema
|
|
155
|
+
- **全文搜索**:跨消息、工具、提示词和响应搜索
|
|
156
|
+
- **深色模式**:跟随系统偏好
|
|
157
|
+
- **键盘导航**:`j`/`k` 或方向键
|
|
158
|
+
- **一键复制**:复制请求 JSON 或 cURL 命令
|
|
159
|
+
- **多语言**:English、简体中文、日本語、한국어、Français、العربية、Deutsch、Русский
|
|
160
|
+
|
|
161
|
+
## AWS Event Stream 解析
|
|
162
|
+
|
|
163
|
+
Kiro API 使用 AWS Event Stream 二进制帧协议(非标准 SSE)。kiro-tap 实现了完整的帧解析器:
|
|
164
|
+
|
|
165
|
+
- CRC32 校验(ISO-HDLC,与 AWS SDK 一致)
|
|
166
|
+
- 所有 Header 值类型(bool、byte、short、int、long、bytes、string、timestamp、uuid)
|
|
167
|
+
- 事件类型:`assistantResponseEvent`、`toolUseEvent`、`meteringEvent`、`contextUsageEvent`、`codeReferenceEvent`
|
|
168
|
+
- 错误/异常消息类型
|
|
169
|
+
|
|
170
|
+
## 许可证
|
|
171
|
+
|
|
172
|
+
MIT
|
kiro_tap-0.1.0/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# kiro-tap
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
`kiro-tap` 是 Kiro CLI 和 Kiro IDE 的本地代理与请求追踪工具。通过它运行 Kiro,即可实时捕获所有 API 请求:系统提示词、对话历史、工具定义、工具调用、流式响应和 Token 用量。
|
|
7
|
+
|
|
8
|
+
支持 [Kiro CLI](https://kiro.dev)(`kiro-cli-chat`)和 [Kiro IDE](https://kiro.dev)。
|
|
9
|
+
|
|
10
|
+
## 为什么用它
|
|
11
|
+
|
|
12
|
+
- 👀 **看清真实上下文**:查看发往 Kiro API 的完整请求,包括系统提示、消息历史、工具定义、工具调用和响应内容
|
|
13
|
+
- 🔎 **有据可查地调试**:对比相邻请求,精确定位哪条消息、哪个工具或哪个参数发生了变化
|
|
14
|
+
- 📦 **一个可分享的文件**:每次运行生成本地 trace,可导出为自包含的 HTML 查看器,方便存档或分享
|
|
15
|
+
- 🔒 **数据留在本机**:无需任何云端 Dashboard,常见认证 Header 在记录前自动脱敏
|
|
16
|
+
- ⚡ **AWS Event Stream 原生支持**:正确解析 Kiro 使用的 AWS Event Stream 二进制帧协议,完整还原流式响应
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
需要 Python 3.11+。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 推荐
|
|
24
|
+
uv tool install kiro-tap
|
|
25
|
+
|
|
26
|
+
# 或使用 pip
|
|
27
|
+
pip install kiro-tap
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
升级:`kiro-tap update`、`uv tool upgrade kiro-tap` 或 `pip install --upgrade kiro-tap`
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Kiro CLI(默认,实时 Dashboard 默认开启)
|
|
36
|
+
kiro-tap
|
|
37
|
+
|
|
38
|
+
# Kiro IDE
|
|
39
|
+
kiro-tap --tap-client kiro-ide
|
|
40
|
+
|
|
41
|
+
# 关闭实时 Dashboard
|
|
42
|
+
kiro-tap --tap-no-live
|
|
43
|
+
|
|
44
|
+
# 不自动打开浏览器
|
|
45
|
+
kiro-tap --tap-no-open
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 工作原理
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
kiro-tap 启动本地正向代理
|
|
52
|
+
↓
|
|
53
|
+
注入 HTTPS_PROXY + SSL_CERT_FILE 到子进程环境
|
|
54
|
+
↓
|
|
55
|
+
启动 kiro-cli-chat(或 kiro)
|
|
56
|
+
↓
|
|
57
|
+
所有 HTTPS 流量经过本地代理 → TLS 终止 → 转发到 q.us-east-1.amazonaws.com
|
|
58
|
+
↓
|
|
59
|
+
AWS Event Stream 二进制帧解析 → 重建完整响应
|
|
60
|
+
↓
|
|
61
|
+
写入本地 SQLite trace 数据库
|
|
62
|
+
↓
|
|
63
|
+
实时推送到浏览器 Dashboard(SSE)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
kiro-tap 使用**正向代理模式**(CONNECT + TLS 终止),因为 Kiro CLI 没有暴露 base URL 环境变量。代理会自动生成本地 CA 证书并注入到子进程,无需 sudo。
|
|
67
|
+
|
|
68
|
+
## CLI 选项
|
|
69
|
+
|
|
70
|
+
所有 `--tap-*` 之外的参数都会透传给 Kiro 客户端。
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
--tap-client CLIENT 要启动的客户端:kiro(默认)或 kiro-ide
|
|
74
|
+
--tap-target URL 上游 API URL(默认:https://q.us-east-1.amazonaws.com)
|
|
75
|
+
--tap-live 运行时开启实时 Dashboard(默认:开)
|
|
76
|
+
--tap-no-live 关闭实时 Dashboard
|
|
77
|
+
--tap-live-port PORT 实时 Dashboard 端口(默认:19528)
|
|
78
|
+
--tap-no-open 不自动在浏览器中打开 Dashboard 或生成的 HTML
|
|
79
|
+
--tap-output-dir DIR 旧版 trace 目录(默认:./.traces)
|
|
80
|
+
--tap-port PORT 代理端口(默认:自动)
|
|
81
|
+
--tap-host HOST 绑定地址(默认:127.0.0.1)
|
|
82
|
+
--tap-no-launch 只启动代理,不启动客户端
|
|
83
|
+
--tap-max-traces N 保留的最大 trace 会话数(默认:50,0 = 不限)
|
|
84
|
+
--tap-store-stream-events 持久化原始 AWS Event Stream 帧数组(默认:关)
|
|
85
|
+
--tap-no-update-check 禁用启动时的 PyPI 更新检查
|
|
86
|
+
--tap-no-auto-update 检查更新但不自动下载
|
|
87
|
+
--tap-trust-ca 在 macOS 用户登录钥匙串中信任本地 CA(无需 sudo)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 子命令
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 浏览历史 trace
|
|
94
|
+
kiro-tap dashboard
|
|
95
|
+
|
|
96
|
+
# 将 JSONL trace 导出为 HTML / Markdown / JSON
|
|
97
|
+
kiro-tap export .traces/session.jsonl -o trace.html
|
|
98
|
+
|
|
99
|
+
# 升级 kiro-tap
|
|
100
|
+
kiro-tap update
|
|
101
|
+
|
|
102
|
+
# 在 macOS 钥匙串中信任本地 CA(正向代理模式需要)
|
|
103
|
+
kiro-tap trust-ca
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 仅代理模式
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 只启动代理,在另一个终端手动启动 Kiro
|
|
110
|
+
kiro-tap --tap-no-launch --tap-port 8080
|
|
111
|
+
|
|
112
|
+
# 然后在另一个终端:
|
|
113
|
+
HTTPS_PROXY=http://127.0.0.1:8080 SSL_CERT_FILE=~/.kiro-tap/ca.pem kiro-cli-chat
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Viewer 功能
|
|
117
|
+
|
|
118
|
+
生成的 HTML 查看器(零外部依赖)支持:
|
|
119
|
+
|
|
120
|
+
- **结构化 Diff**:对比相邻请求,查看消息、系统提示、工具的变化
|
|
121
|
+
- **路径过滤**:按 API 端点过滤(如只看 `/generateAssistantResponse`)
|
|
122
|
+
- **Token 用量**:输入 / 输出 / 缓存读取 / 缓存写入
|
|
123
|
+
- **工具检查器**:可展开的工具卡片,含名称、描述和参数 schema
|
|
124
|
+
- **全文搜索**:跨消息、工具、提示词和响应搜索
|
|
125
|
+
- **深色模式**:跟随系统偏好
|
|
126
|
+
- **键盘导航**:`j`/`k` 或方向键
|
|
127
|
+
- **一键复制**:复制请求 JSON 或 cURL 命令
|
|
128
|
+
- **多语言**:English、简体中文、日本語、한국어、Français、العربية、Deutsch、Русский
|
|
129
|
+
|
|
130
|
+
## AWS Event Stream 解析
|
|
131
|
+
|
|
132
|
+
Kiro API 使用 AWS Event Stream 二进制帧协议(非标准 SSE)。kiro-tap 实现了完整的帧解析器:
|
|
133
|
+
|
|
134
|
+
- CRC32 校验(ISO-HDLC,与 AWS SDK 一致)
|
|
135
|
+
- 所有 Header 值类型(bool、byte、short、int、long、bytes、string、timestamp、uuid)
|
|
136
|
+
- 事件类型:`assistantResponseEvent`、`toolUseEvent`、`meteringEvent`、`contextUsageEvent`、`codeReferenceEvent`
|
|
137
|
+
- 错误/异常消息类型
|
|
138
|
+
|
|
139
|
+
## 许可证
|
|
140
|
+
|
|
141
|
+
MIT
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# kiro-tap
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
[中文文档](README.md)
|
|
7
|
+
|
|
8
|
+
`kiro-tap` is a local proxy and trace viewer for Kiro CLI and Kiro IDE. Run Kiro through it to inspect real API traffic: system prompts, conversation history, tool schemas, tool calls, streaming responses, and token usage.
|
|
9
|
+
|
|
10
|
+
Supports [Kiro CLI](https://kiro.dev) (`kiro-cli-chat`) and [Kiro IDE](https://kiro.dev).
|
|
11
|
+
|
|
12
|
+
## Why use it
|
|
13
|
+
|
|
14
|
+
- 👀 **See the exact context**: inspect every request sent to the Kiro API, including system prompts, message history, tool definitions, tool calls, and responses
|
|
15
|
+
- 🔎 **Debug with evidence**: compare adjacent requests and pinpoint which message, tool, or parameter changed
|
|
16
|
+
- 📦 **Share one portable artifact**: each run writes a local trace that can be exported to a self-contained HTML viewer for review or archiving
|
|
17
|
+
- 🔒 **Keep traces on your machine**: no hosted dashboard required, and common auth headers are redacted before recording
|
|
18
|
+
- ⚡ **Native AWS Event Stream support**: correctly parses Kiro's AWS Event Stream binary frame protocol and fully reconstructs streaming responses
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
Requires Python 3.11+.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Recommended
|
|
26
|
+
uv tool install kiro-tap
|
|
27
|
+
|
|
28
|
+
# Or with pip
|
|
29
|
+
pip install kiro-tap
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Upgrade: `kiro-tap update`, `uv tool upgrade kiro-tap`, or `pip install --upgrade kiro-tap`
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Kiro CLI (default, live dashboard enabled by default)
|
|
38
|
+
kiro-tap
|
|
39
|
+
|
|
40
|
+
# Kiro IDE
|
|
41
|
+
kiro-tap --tap-client kiro-ide
|
|
42
|
+
|
|
43
|
+
# Disable live dashboard
|
|
44
|
+
kiro-tap --tap-no-live
|
|
45
|
+
|
|
46
|
+
# Don't auto-open browser
|
|
47
|
+
kiro-tap --tap-no-open
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
kiro-tap starts a local forward proxy
|
|
54
|
+
↓
|
|
55
|
+
Injects HTTPS_PROXY + SSL_CERT_FILE into the child process environment
|
|
56
|
+
↓
|
|
57
|
+
Launches kiro-cli-chat (or kiro)
|
|
58
|
+
↓
|
|
59
|
+
All HTTPS traffic → local proxy → TLS termination → forwarded to q.us-east-1.amazonaws.com
|
|
60
|
+
↓
|
|
61
|
+
AWS Event Stream binary frame parsing → full response reconstruction
|
|
62
|
+
↓
|
|
63
|
+
Written to local SQLite trace database
|
|
64
|
+
↓
|
|
65
|
+
Pushed to browser dashboard in real time (SSE)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
kiro-tap uses **forward proxy mode** (CONNECT + TLS termination) because Kiro CLI does not expose a base URL environment variable. The proxy auto-generates a local CA certificate and injects it into the child process — no sudo required.
|
|
69
|
+
|
|
70
|
+
## CLI Options
|
|
71
|
+
|
|
72
|
+
All flags except `--tap-*` are forwarded to the selected Kiro client.
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
--tap-client CLIENT Client to launch: kiro (default) or kiro-ide
|
|
76
|
+
--tap-target URL Upstream API URL (default: https://q.us-east-1.amazonaws.com)
|
|
77
|
+
--tap-live Start real-time dashboard while client runs (default: on)
|
|
78
|
+
--tap-no-live Disable the real-time dashboard
|
|
79
|
+
--tap-live-port PORT Port for the live dashboard (default: 19528)
|
|
80
|
+
--tap-no-open Don't auto-open dashboard or generated HTML in a browser
|
|
81
|
+
--tap-output-dir DIR Legacy trace directory (default: ./.traces)
|
|
82
|
+
--tap-port PORT Proxy port (default: auto)
|
|
83
|
+
--tap-host HOST Bind address (default: 127.0.0.1)
|
|
84
|
+
--tap-no-launch Only start the proxy, don't launch client
|
|
85
|
+
--tap-max-traces N Max trace sessions to keep (default: 50, 0 = unlimited)
|
|
86
|
+
--tap-store-stream-events Persist raw AWS Event Stream frame arrays (default: off)
|
|
87
|
+
--tap-no-update-check Disable PyPI update check on startup
|
|
88
|
+
--tap-no-auto-update Check for updates but don't auto-download
|
|
89
|
+
--tap-trust-ca Trust local CA in macOS user login keychain (no sudo)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Subcommands
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Browse trace history
|
|
96
|
+
kiro-tap dashboard
|
|
97
|
+
|
|
98
|
+
# Export a JSONL trace to HTML / Markdown / JSON
|
|
99
|
+
kiro-tap export .traces/session.jsonl -o trace.html
|
|
100
|
+
|
|
101
|
+
# Upgrade kiro-tap
|
|
102
|
+
kiro-tap update
|
|
103
|
+
|
|
104
|
+
# Trust local CA in macOS keychain (needed for forward proxy mode)
|
|
105
|
+
kiro-tap trust-ca
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Proxy-only mode
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Start proxy only, launch Kiro manually in another terminal
|
|
112
|
+
kiro-tap --tap-no-launch --tap-port 8080
|
|
113
|
+
|
|
114
|
+
# Then in another terminal:
|
|
115
|
+
HTTPS_PROXY=http://127.0.0.1:8080 SSL_CERT_FILE=~/.kiro-tap/ca.pem kiro-cli-chat
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Viewer Features
|
|
119
|
+
|
|
120
|
+
The generated HTML viewer (zero external dependencies) supports:
|
|
121
|
+
|
|
122
|
+
- **Structural diff** — compare consecutive requests to see exactly what changed: new/removed messages, system prompt diffs, character-level inline highlighting
|
|
123
|
+
- **Path filtering** — filter by API endpoint (e.g. `/generateAssistantResponse` only)
|
|
124
|
+
- **Token usage breakdown** — input / output / cache read / cache creation
|
|
125
|
+
- **Tool inspector** — expandable cards with tool name, description, and parameter schema
|
|
126
|
+
- **Search** — full-text search across messages, tools, prompts, and responses
|
|
127
|
+
- **Dark mode** — toggle light/dark themes (respects system preference)
|
|
128
|
+
- **Keyboard navigation** — `j`/`k` or arrow keys
|
|
129
|
+
- **Copy helpers** — one-click copy of request JSON or cURL command
|
|
130
|
+
- **i18n** — English, 简体中文, 日本語, 한국어, Français, العربية, Deutsch, Русский
|
|
131
|
+
|
|
132
|
+
## AWS Event Stream Parsing
|
|
133
|
+
|
|
134
|
+
The Kiro API uses the AWS Event Stream binary framing protocol (not standard SSE). kiro-tap implements a full frame parser:
|
|
135
|
+
|
|
136
|
+
- CRC32 verification (ISO-HDLC, matching the AWS SDK)
|
|
137
|
+
- All header value types (bool, byte, short, int, long, bytes, string, timestamp, uuid)
|
|
138
|
+
- Event types: `assistantResponseEvent`, `toolUseEvent`, `meteringEvent`, `contextUsageEvent`, `codeReferenceEvent`
|
|
139
|
+
- Error and exception message types
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""kiro-tap: Proxy to trace Kiro CLI and Kiro IDE API requests.
|
|
2
|
+
|
|
3
|
+
A CLI tool that wraps Kiro CLI with a local forward proxy to intercept
|
|
4
|
+
and record all API requests. Useful for studying Kiro's context engineering.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from kiro_tap.certs import CertificateAuthority, ensure_ca
|
|
10
|
+
from kiro_tap.cli import (
|
|
11
|
+
__version__,
|
|
12
|
+
_build_update_command,
|
|
13
|
+
_detect_installer,
|
|
14
|
+
_version_tuple,
|
|
15
|
+
async_main,
|
|
16
|
+
dashboard_main,
|
|
17
|
+
main_entry,
|
|
18
|
+
parse_args,
|
|
19
|
+
parse_dashboard_args,
|
|
20
|
+
parse_trust_ca_args,
|
|
21
|
+
parse_update_args,
|
|
22
|
+
trust_ca_main,
|
|
23
|
+
update_main,
|
|
24
|
+
)
|
|
25
|
+
from kiro_tap.forward_proxy import ForwardProxyServer
|
|
26
|
+
from kiro_tap.history import cleanup_trace_sessions, delete_trace_history, migrate_legacy_traces
|
|
27
|
+
from kiro_tap.live import LiveViewerServer
|
|
28
|
+
from kiro_tap.proxy import filter_headers
|
|
29
|
+
from kiro_tap.aws_event_stream import AWSEventStreamReassembler
|
|
30
|
+
from kiro_tap.trace import TraceWriter
|
|
31
|
+
from kiro_tap.trace_store import get_trace_store, reset_trace_store, resolve_db_path
|
|
32
|
+
from kiro_tap.viewer import _generate_html_viewer
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"__version__",
|
|
36
|
+
"_build_update_command",
|
|
37
|
+
"_detect_installer",
|
|
38
|
+
"_version_tuple",
|
|
39
|
+
"main_entry",
|
|
40
|
+
"parse_args",
|
|
41
|
+
"parse_dashboard_args",
|
|
42
|
+
"parse_trust_ca_args",
|
|
43
|
+
"parse_update_args",
|
|
44
|
+
"trust_ca_main",
|
|
45
|
+
"update_main",
|
|
46
|
+
"async_main",
|
|
47
|
+
"dashboard_main",
|
|
48
|
+
"CertificateAuthority",
|
|
49
|
+
"ensure_ca",
|
|
50
|
+
"ForwardProxyServer",
|
|
51
|
+
"AWSEventStreamReassembler",
|
|
52
|
+
"TraceWriter",
|
|
53
|
+
"LiveViewerServer",
|
|
54
|
+
"filter_headers",
|
|
55
|
+
"_generate_html_viewer",
|
|
56
|
+
"cleanup_trace_sessions",
|
|
57
|
+
"delete_trace_history",
|
|
58
|
+
"migrate_legacy_traces",
|
|
59
|
+
"get_trace_store",
|
|
60
|
+
"reset_trace_store",
|
|
61
|
+
"resolve_db_path",
|
|
62
|
+
]
|