ai-cli-log 1.0.6 → 1.0.10
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.
- package/README.md +77 -77
- package/dist/index.js +15 -6
- package/package.json +1 -1
- package/src/index.ts +14 -6
- package/.ai-cli-log/0001.txt +0 -360
- package/.ai-cli-log/0002.txt +0 -1791
- package/.ai-cli-log/0003.txt +0 -338
- package/.ai-cli-log/0004.txt +0 -116
- package/.ai-cli-log/0005.txt +0 -105
- package/.ai-cli-log/config.json +0 -32
- package/.ai-cli-log/gemini-2025-07-13T13-33-13-a-quick-gemini-test.txt +0 -174
- package/.ai-cli-log/gemini-2025-07-13T13-37-00-typescript-check-pass.txt +0 -105
- package/.ai-cli-log/gemini-2025-07-13T13-44-15-rename-ai-cli-logs-to-log.txt +0 -164
- package/.ai-cli-log/gemini-20250705-154601.txt +0 -1320
- package/.ai-cli-log/gemini-20250705-155547.txt +0 -726
- package/.ai-cli-log/gemini-20250705-165038.txt +0 -66
- package/.ai-cli-log/gemini-20250705-171429.txt +0 -216
- package/.ai-cli-log/gemini-20250705-191202.txt +0 -448
- package/.ai-cli-log/gemini-20250705-193741.txt +0 -901
- package/.ai-cli-log/gemini-20250705-194435.txt +0 -110
- package/.ai-cli-log/gemini-20250705-195926.txt +0 -415
- package/.ai-cli-log/gemini-20250705-201738.txt +0 -246
- package/.ai-cli-log/gemini-20250713-204921.txt +0 -3036
- package/.ai-cli-log/gemini-20250713-215941-update-ai-cli-log-documentation.txt +0 -400
- package/.ai-cli-log/gemini-20250713-220544-removed-debug-logs-successfully.txt +0 -258
- package/.ai-cli-log/gemini-20250713-221128-sessionsummarytxt.txt +0 -112
- package/.ai-cli-log/gemini-20250714-084659.txt +0 -86
- package/.ai-cli-log/gemini-20250714-085847-update-prompt-configuration.txt +0 -189
- package/.ai-cli-log/gemini-20250714-090905-add-sgpt-custom-summarizer.txt +0 -284
- package/.ai-cli-log/gemini-20250714-092329.txt +0 -110
- package/.ai-cli-log/gemini-20250714-092935.txt +0 -183
- package/.ai-cli-log/gemini-20250714-093205-heres-a-concise-summary-of-the-terminal-session-fix-sgpt-option-error-this-captures-1-the-action-fix-2-the-tool-involved-sgpt-3-the-issue-option-error-4-follows-the-requested-lowercase-hyphenated-format.txt +0 -140
- package/.ai-cli-log/gemini-20250714-094141-heres-the-concise-summary-build-check-clean-this-captures-1.txt +0 -111
- package/.ai-cli-log/gemini-20250714-094405-heres-the-concise-summary-clean-build-check-this-captures-1.txt +0 -111
- package/.ai-cli-log/gemini-20250714-094816-json-summary-format.txt +0 -132
- package/.ai-cli-log/gemini-20250714-094833-optimize-summary-logic.txt +0 -342
- package/.ai-cli-log/gemini-20250714-133202-refactor-config-initialization.txt +0 -1729
- package/.ai-cli-log/gemini-20250714-134138-update-summary-logic.txt +0 -153
- package/.ai-cli-log/gemini-20250714-134749-json-summary-format.txt +0 -214
- package/.ai-cli-log/gemini-20250714-140527.txt +0 -715
- package/.ai-cli-log/gemini-20250714-142018.txt +0 -86
- package/.ai-cli-log/gemini-20250714-142027-update-summary-format.txt +0 -86
- package/.ai-cli-log/gemini-20250714-142100-session-complete.txt +0 -86
- package/.ai-cli-log/gemini-20250714-142129-refactor-readme-structure.txt +0 -584
- package/.ai-cli-log/gemini-20250714-213153.txt +0 -1195
- package/.ai-cli-log/gemini-20250714-222508-refactor-command-parser.txt +0 -2110
- package/.ai-cli-log/session-20250705-150655.txt +0 -174
- package/.ai-cli-log/session-20250705-151726.txt +0 -313
- package/.github/workflows/node.js.yml +0 -30
- package/GEMINI.md +0 -54
package/README.md
CHANGED
|
@@ -24,13 +24,36 @@ ai-cli-log [global-options] run <command-to-log> [args...]
|
|
|
24
24
|
```
|
|
25
25
|
*Logs are saved to the `.ai-cli-log/` directory.*
|
|
26
26
|
|
|
27
|
-
- **AI-Powered Filenames:** Use an AI summary for the log's filename. The
|
|
27
|
+
- **AI-Powered Filenames:** Use an AI summary for the log's filename. The options must come **before** the `run` command.
|
|
28
28
|
```bash
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
# Enable summary with the default summarizer
|
|
30
|
+
ai-cli-log -s run gemini
|
|
31
|
+
# or
|
|
32
|
+
ai-cli-log --with-summary run gemini
|
|
33
|
+
|
|
34
|
+
# Enable summary and specify a summarizer
|
|
35
|
+
ai-cli-log --by gemini-pro run gemini
|
|
36
|
+
# or
|
|
37
|
+
ai-cli-log --summarizer gemini-pro run gemini
|
|
32
38
|
```
|
|
33
|
-
This will use your default (or specified) summarizer to generate a descriptive filename like `gemini-20250713-153000-fix-database-connection-error.
|
|
39
|
+
This will use your default (or specified) summarizer to generate a descriptive filename like `gemini-20250713-153000-fix-database-connection-error.txt`.
|
|
40
|
+
|
|
41
|
+
## Alias for Quick Access
|
|
42
|
+
|
|
43
|
+
For even faster access, you can create shell aliases. This allows you to start a logged session with a short command. Add these to your shell's configuration file (e.g., `~/.bashrc`, `~/.zshrc`).
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Start a logged Gemini session with an AI-generated summary
|
|
47
|
+
alias ag='ai-cli-log -s run gemini'
|
|
48
|
+
|
|
49
|
+
# Start a logged Claude session with an AI-generated summary
|
|
50
|
+
alias ac='ai-cli-log -s run claude'
|
|
51
|
+
|
|
52
|
+
# You can also omit the -s flag for basic logging
|
|
53
|
+
alias ag-log='ai-cli-log run gemini'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Now, you can simply run `ag` to start a recorded Gemini session.
|
|
34
57
|
|
|
35
58
|
## Configuration
|
|
36
59
|
|
|
@@ -44,7 +67,7 @@ You can create these files manually or by using the interactive setup command.
|
|
|
44
67
|
|
|
45
68
|
### Interactive Setup (`init`)
|
|
46
69
|
|
|
47
|
-
The `init` command helps you create a configuration file.
|
|
70
|
+
The `init` command helps you create a configuration file. It will scan for available AI tools, guide you through creating summarizer profiles, and set a default.
|
|
48
71
|
|
|
49
72
|
* **To create a global configuration:**
|
|
50
73
|
```bash
|
|
@@ -83,23 +106,14 @@ Here is an example of a manual `config.json`:
|
|
|
83
106
|
{
|
|
84
107
|
"name": "sgpt",
|
|
85
108
|
"tool": "custom",
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* **To create a local, project-specific configuration file (at `.ai-cli-log/config.json`):**
|
|
95
|
-
```bash
|
|
96
|
-
ai-cli-log --init --local
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
This command will:
|
|
100
|
-
1. Scan for available AI tools on your system (like `gemini`, `sgpt`, or `ollama`).
|
|
101
|
-
2. Guide you through creating summarizer profiles for them.
|
|
102
|
-
3. Set a default summarizer.
|
|
109
|
+
"prompt": "You are a log summarizer. Your response MUST be a valid JSON object with one key: \"summary\" (a 3-5 word, lowercase, filename-friendly phrase). Example: {\"summary\": \"refactor-database-schema\"}. The session content is:",
|
|
110
|
+
"command": ["sgpt", "--chat", "session-summary", "\"{{prompt}}\""],
|
|
111
|
+
"maxLines": 50
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
103
117
|
|
|
104
118
|
## Features
|
|
105
119
|
|
|
@@ -108,11 +122,11 @@ This command will:
|
|
|
108
122
|
* **Accurate Rendering:** Uses `@xterm/headless` to interpret ANSI escape codes, ensuring the log accurately reflects the final terminal state (spinners, progress bars, etc.).
|
|
109
123
|
* **Configurable:** Supports different AI backends (`gemini`, `sgpt`, `ollama`, etc.) for generating summaries.
|
|
110
124
|
* **Performance-Aware:** When summarizing long sessions, it intelligently samples the beginning and end of the output to ensure fast and cost-effective summary generation.
|
|
111
|
-
* **
|
|
125
|
+
* **Plain Text Output:** Saves sessions as clean plain text files.
|
|
112
126
|
|
|
113
127
|
## Development Notes
|
|
114
128
|
|
|
115
|
-
This project was generated with the assistance of Google Gemini. You can review the detailed development process and interactions in the `.ai-cli-log` directory
|
|
129
|
+
This project was generated with the assistance of Google Gemini. You can review the detailed development process and interactions in the `.ai-cli-log` directory of the project's GitHub repository: [https://github.com/alingse/ai-cli-log/tree/main/.ai-cli-log](https://github.com/alingse/ai-cli-log/tree/main/.ai-cli-log). The development prompts are primarily in Chinese.
|
|
116
130
|
|
|
117
131
|
Special thanks to Gemini for its invaluable help in the development of this tool!
|
|
118
132
|
|
|
@@ -148,13 +162,36 @@ ai-cli-log [全局选项] run <要记录的命令> [参数...]
|
|
|
148
162
|
```
|
|
149
163
|
*日志将保存到 `.ai-cli-log/` 目录中。*
|
|
150
164
|
|
|
151
|
-
- **AI 驱动的文件名:** 使用 AI
|
|
165
|
+
- **AI 驱动的文件名:** 使用 AI 摘要作为日志文件名。选项必须在 `run` 命令**之前**。
|
|
152
166
|
```bash
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
# 使用默认摘要器启用摘要
|
|
168
|
+
ai-cli-log -s run gemini
|
|
169
|
+
# 或
|
|
170
|
+
ai-cli-log --with-summary run gemini
|
|
171
|
+
|
|
172
|
+
# 启用摘要并指定一个摘要器
|
|
173
|
+
ai-cli-log --by gemini-pro run gemini
|
|
174
|
+
# 或
|
|
175
|
+
ai-cli-log --summarizer gemini-pro run gemini
|
|
156
176
|
```
|
|
157
|
-
这将使用您默认(或指定)的摘要器生成一个描述性的文件名,例如 `gemini-20250713-153000-fix-database-connection-error.
|
|
177
|
+
这将使用您默认(或指定)的摘要器生成一个描述性的文件名,例如 `gemini-20250713-153000-fix-database-connection-error.txt`。
|
|
178
|
+
|
|
179
|
+
## 快捷别名 (Alias)
|
|
180
|
+
|
|
181
|
+
为了更快捷地启动,您可以创建 shell 别名。这样,您可以用一个简短的命令开始一个带日志记录的会话。将以下内容添加到您的 shell 配置文件中(例如 `~/.bashrc`, `~/.zshrc`)。
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# 启动一个带 AI 摘要的 Gemini 会话
|
|
185
|
+
alias ag='ai-cli-log -s run gemini'
|
|
186
|
+
|
|
187
|
+
# 启动一个带 AI 摘要的 Claude 会话
|
|
188
|
+
alias ac='ai-cli-log -s run claude'
|
|
189
|
+
|
|
190
|
+
# 您也可以省略 -s 标志以进行基本日志记录
|
|
191
|
+
alias ag-log='ai-cli-log run gemini'
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
现在,您只需运行 `ag` 即可启动一个被记录的 Gemini 会话。
|
|
158
195
|
|
|
159
196
|
## 配置
|
|
160
197
|
|
|
@@ -168,13 +205,13 @@ ai-cli-log [全局选项] run <要记录的命令> [参数...]
|
|
|
168
205
|
|
|
169
206
|
### 交互式设置 (`init`)
|
|
170
207
|
|
|
171
|
-
`init`
|
|
208
|
+
`init` 命令可以帮助您创建配置文件。它会扫描可用的 AI 工具,引导您完成摘要器配置的创建,并设置一个默认值。
|
|
172
209
|
|
|
173
210
|
* **创建全局配置文件:**
|
|
174
211
|
```bash
|
|
175
212
|
ai-cli-log init
|
|
176
213
|
```
|
|
177
|
-
|
|
214
|
+
这会将配置保存到 `~/.config/ai-cli-log/config.json`。
|
|
178
215
|
|
|
179
216
|
* **创建本地(项目特定)配置文件:**
|
|
180
217
|
```bash
|
|
@@ -194,22 +231,22 @@ ai-cli-log [全局选项] run <要记录的命令> [参数...]
|
|
|
194
231
|
{
|
|
195
232
|
"name": "gemini-pro",
|
|
196
233
|
"tool": "gemini",
|
|
197
|
-
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON
|
|
234
|
+
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON 对象,其中包含一个键:\"summary\"(一个 3-5 个单词的、小写的、文件名友好的短语)。示例:{\"summary\": \"refactor-database-schema\"}。会话内容是:",
|
|
198
235
|
"maxLines": 100
|
|
199
236
|
},
|
|
200
237
|
{
|
|
201
238
|
"name": "ollama",
|
|
202
239
|
"tool": "ollama",
|
|
203
240
|
"model": "llama3",
|
|
204
|
-
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON
|
|
241
|
+
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON 对象,其中包含一个键:\"summary\"(一个 3-5 个单词的、小写的、文件名友好的短语)。示例:{\"summary\": \"refactor-database-schema\"}。会话内容是:",
|
|
205
242
|
"maxLines": 50
|
|
206
243
|
},
|
|
207
244
|
{
|
|
208
245
|
"name": "sgpt",
|
|
209
246
|
"tool": "custom",
|
|
210
|
-
"command": ["sgpt", "--chat", "session-summary", ""{{prompt}}""],
|
|
211
|
-
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON
|
|
212
|
-
"maxLines":
|
|
247
|
+
"command": ["sgpt", "--chat", "session-summary", "\"{{prompt}}\""],
|
|
248
|
+
"prompt": "你是一个日志摘要器。你的响应必须是一个有效的 JSON 对象,其中包含一个键\"summary\"(一个 3-5 个单词的、小写的、文件名友好的短语)。示例:{\"summary\": \"refactor-database-schema\"}。会话内容是:",
|
|
249
|
+
"maxLines": 50
|
|
213
250
|
},
|
|
214
251
|
{
|
|
215
252
|
"name": "my-custom-summarizer",
|
|
@@ -237,40 +274,7 @@ ai-cli-log [全局选项] run <要记录的命令> [参数...]
|
|
|
237
274
|
* **`prompt`**: 传递给摘要器命令的提示。会话内容将作为标准输入传递。
|
|
238
275
|
* **`maxLines`** (可选): 限制传递给摘要器的会话内容行数。如果会话内容超过此限制,将只采样开头和结尾的行。
|
|
239
276
|
* **`command`** (可选): 对于 `custom` 工具,指定要执行的命令数组。会话内容会通过管道传递给该命令的 `stdin`。`{{prompt}}` 占位符将被实际的提示字符串替换。例如: `["my-summarizer-script", "--prompt", "{{prompt}}"]`。
|
|
240
|
-
* **重要**: 摘要器的输出**必须**是一个有效的 JSON 对象,其中包含一个名为 `summary` 的键(例如,`{"summary": "
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Field Descriptions:**
|
|
244
|
-
|
|
245
|
-
* `summarizer.default` (optional): The name of the default summarizer configuration to use.
|
|
246
|
-
* `summarizer.summarizers`: An array of different summarizer configurations.
|
|
247
|
-
* **`name`**: A unique name you give to the summarizer configuration (e.g., `gemini-pro`, `ollama`, `claude-opus`, `my-custom-summarizer`).
|
|
248
|
-
* **`tool`**: The type of tool the summarizer uses.
|
|
249
|
-
* `gemini`: Uses the `gemini` CLI tool.
|
|
250
|
-
* `ollama`: Uses the `ollama` CLI tool.
|
|
251
|
-
* `claude`: Uses the `claude` CLI tool.
|
|
252
|
-
* `custom`: Uses a custom command.
|
|
253
|
-
* **`model`** (optional): For the `ollama` tool, specifies the model name to use (e.g., `llama3`).
|
|
254
|
-
* **`prompt`**: The prompt passed to the summarizer command. The session content will be passed as standard input.
|
|
255
|
-
* **`maxLines`** (optional): Limits the number of session content lines passed to the summarizer. If the session exceeds this limit, only the beginning and end lines will be sampled.
|
|
256
|
-
* **`command`** (optional): For the `custom` tool, specifies the command array to execute. The session content is piped to this command's `stdin`. The `{{prompt}}` placeholder will be replaced with the actual prompt string. Example: `["my-summarizer-script", "--prompt", "{{prompt}}"]`.
|
|
257
|
-
* **Important**: The output from the summarizer **MUST** be a valid JSON object containing a key named `summary` (e.g., `{"summary": "your-summary-phrase"}`).
|
|
258
|
-
|
|
259
|
-
### 交互式设置 (`--init`)
|
|
260
|
-
|
|
261
|
-
运行交互式设置来创建配置文件。
|
|
262
|
-
|
|
263
|
-
* **创建全局配置文件 (位于 `~/.config/ai-cli-log/config.json`):**
|
|
264
|
-
```bash
|
|
265
|
-
ai-cli-log --init
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
* **创建本地、项目特定的配置文件 (位于 `.ai-cli-log/config.json`):**
|
|
269
|
-
```bash
|
|
270
|
-
ai-cli-log --init --local
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
该命令将引导您完成配置过程,包括扫描可用的 AI 工具、创建摘要器配置和设置默认摘要器。
|
|
277
|
+
* **重要**: 摘要器的输出**必须**是一个有效的 JSON 对象,其中包含一个名为 `summary` 的键(例如,`{"summary": "fix-login-bug"}`)。
|
|
274
278
|
|
|
275
279
|
## 功能特性
|
|
276
280
|
|
|
@@ -283,14 +287,10 @@ ai-cli-log [全局选项] run <要记录的命令> [参数...]
|
|
|
283
287
|
|
|
284
288
|
## 开发说明
|
|
285
289
|
|
|
286
|
-
本项目是在 Google Gemini
|
|
290
|
+
本项目是在 Google Gemini 的协助下生成的。您可以在本项目的 GitHub 仓库中查看详细的开发过程和交互记录,所有开发记录(中文 Prompt)都保存在 `.ai-cli-log` 目录中:[https://github.com/alingse/ai-cli-log/tree/main/.ai-cli-log](https://github.com/alingse/ai-cli-log/tree/main/.ai-cli-log)。
|
|
287
291
|
|
|
288
292
|
特别感谢 Gemini 在本项目开发过程中提供的宝贵帮助!
|
|
289
293
|
|
|
290
294
|
## 待办事项 (TODO)
|
|
291
295
|
|
|
292
|
-
*
|
|
293
|
-
* 当会话输出为空时,避免保存空的日志文件。
|
|
294
|
-
* 尾随空格和空行现在已从输出中删除,以解决内容不足导致大片空白区域的问题。
|
|
295
|
-
* **文件名约定:** 当前基于时间戳的文件名虽然功能上可行,但可能过于单调。评估其他更具描述性的文件名方案,同时仔细考虑如果使用 AI 摘要进行命名可能导致的信息泄露问题。
|
|
296
|
-
|
|
296
|
+
* **Markdown 支持:** 探寻并实现将日志保存为 Markdown 格式的可能性,可在文件的 frontmatter 中包含会话元数据(如:命令、时间戳、摘要等)。
|
package/dist/index.js
CHANGED
|
@@ -350,10 +350,12 @@ function runLoggingSession(command, commandArgs, summaryArg) {
|
|
|
350
350
|
const jsonMatch = rawSummaryJson.match(/\{.*\}/s);
|
|
351
351
|
const cleanJson = jsonMatch ? jsonMatch[0] : rawSummaryJson;
|
|
352
352
|
const summaryData = JSON.parse(cleanJson);
|
|
353
|
-
const
|
|
354
|
-
if (typeof
|
|
353
|
+
const slugFromAi = summaryData.summary;
|
|
354
|
+
if (typeof slugFromAi !== 'string') {
|
|
355
355
|
throw new Error('Invalid JSON structure from summarizer: "summary" key is missing or not a string.');
|
|
356
356
|
}
|
|
357
|
+
const slugify = (text) => text.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
358
|
+
const slug = slugify(slugFromAi).split('-').filter(Boolean).slice(0, 6).join('-');
|
|
357
359
|
console.log(`\nSummary by ${summarizerName} (took ${duration.toFixed(1)}s): "${slug}"`);
|
|
358
360
|
logFileName = `${prefix}-${timestamp}-${slug}.txt`;
|
|
359
361
|
}
|
|
@@ -361,7 +363,7 @@ function runLoggingSession(command, commandArgs, summaryArg) {
|
|
|
361
363
|
console.error(`\nError parsing summary JSON from ${summarizerName}. Using raw output as fallback.`);
|
|
362
364
|
console.error(`Raw output: ${rawSummaryJson}`);
|
|
363
365
|
const slugify = (text) => text.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
364
|
-
const slug = slugify(rawSummaryJson).split('-').slice(0,
|
|
366
|
+
const slug = slugify(rawSummaryJson).split('-').filter(Boolean).slice(0, 6).join('-');
|
|
365
367
|
logFileName = `${prefix}-${timestamp}-${slug}.txt`;
|
|
366
368
|
}
|
|
367
369
|
}
|
|
@@ -393,7 +395,8 @@ function main() {
|
|
|
393
395
|
.name('ai-cli-log')
|
|
394
396
|
.description('A CLI tool to seamlessly log terminal sessions with AI models.')
|
|
395
397
|
.version(pkg.version, '-v, --version', 'Output the current version')
|
|
396
|
-
.option('-s, --with-summary
|
|
398
|
+
.option('-s, --with-summary', 'Enable AI summary for the session using the default summarizer.')
|
|
399
|
+
.option('--by <name>, --summarizer <name>', 'Specify a summarizer to use. Implies --with-summary.');
|
|
397
400
|
program
|
|
398
401
|
.command('init')
|
|
399
402
|
.description('Initialize or update the configuration file.')
|
|
@@ -411,8 +414,14 @@ function main() {
|
|
|
411
414
|
.action((command, args) => {
|
|
412
415
|
const options = program.opts();
|
|
413
416
|
let summaryArg = false;
|
|
414
|
-
if (options.
|
|
415
|
-
summaryArg =
|
|
417
|
+
if (options.by) {
|
|
418
|
+
summaryArg = options.by;
|
|
419
|
+
}
|
|
420
|
+
else if (options.summarizer) {
|
|
421
|
+
summaryArg = options.summarizer;
|
|
422
|
+
}
|
|
423
|
+
else if (options.withSummary) {
|
|
424
|
+
summaryArg = true;
|
|
416
425
|
}
|
|
417
426
|
runLoggingSession(command, args, summaryArg);
|
|
418
427
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-cli-log",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Seamlessly log your AI-powered coding conversations. This command-line interface (CLI) tool captures your terminal interactions with AI models like Gemini and Claude, saving entire sessions as clean plain text documents for easy review and documentation.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
package/src/index.ts
CHANGED
|
@@ -363,12 +363,15 @@ function runLoggingSession(command: string, commandArgs: string[], summaryArg?:
|
|
|
363
363
|
const cleanJson = jsonMatch ? jsonMatch[0] : rawSummaryJson;
|
|
364
364
|
|
|
365
365
|
const summaryData = JSON.parse(cleanJson);
|
|
366
|
-
const
|
|
366
|
+
const slugFromAi = summaryData.summary;
|
|
367
367
|
|
|
368
|
-
if (typeof
|
|
368
|
+
if (typeof slugFromAi !== 'string') {
|
|
369
369
|
throw new Error('Invalid JSON structure from summarizer: "summary" key is missing or not a string.');
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
const slugify = (text: string) => text.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
373
|
+
const slug = slugify(slugFromAi).split('-').filter(Boolean).slice(0, 6).join('-');
|
|
374
|
+
|
|
372
375
|
console.log(`\nSummary by ${summarizerName} (took ${duration.toFixed(1)}s): "${slug}"`);
|
|
373
376
|
logFileName = `${prefix}-${timestamp}-${slug}.txt`;
|
|
374
377
|
|
|
@@ -376,7 +379,7 @@ function runLoggingSession(command: string, commandArgs: string[], summaryArg?:
|
|
|
376
379
|
console.error(`\nError parsing summary JSON from ${summarizerName}. Using raw output as fallback.`);
|
|
377
380
|
console.error(`Raw output: ${rawSummaryJson}`);
|
|
378
381
|
const slugify = (text: string) => text.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
379
|
-
const slug = slugify(rawSummaryJson).split('-').slice(0,
|
|
382
|
+
const slug = slugify(rawSummaryJson).split('-').filter(Boolean).slice(0, 6).join('-');
|
|
380
383
|
logFileName = `${prefix}-${timestamp}-${slug}.txt`;
|
|
381
384
|
}
|
|
382
385
|
}
|
|
@@ -412,7 +415,8 @@ function main() {
|
|
|
412
415
|
.name('ai-cli-log')
|
|
413
416
|
.description('A CLI tool to seamlessly log terminal sessions with AI models.')
|
|
414
417
|
.version(pkg.version, '-v, --version', 'Output the current version')
|
|
415
|
-
.option('-s, --with-summary
|
|
418
|
+
.option('-s, --with-summary', 'Enable AI summary for the session using the default summarizer.')
|
|
419
|
+
.option('--by <name>, --summarizer <name>', 'Specify a summarizer to use. Implies --with-summary.');
|
|
416
420
|
|
|
417
421
|
program
|
|
418
422
|
.command('init')
|
|
@@ -432,8 +436,12 @@ function main() {
|
|
|
432
436
|
.action((command, args) => {
|
|
433
437
|
const options = program.opts();
|
|
434
438
|
let summaryArg: string | boolean = false;
|
|
435
|
-
if (options.
|
|
436
|
-
summaryArg =
|
|
439
|
+
if (options.by) {
|
|
440
|
+
summaryArg = options.by;
|
|
441
|
+
} else if (options.summarizer) {
|
|
442
|
+
summaryArg = options.summarizer;
|
|
443
|
+
} else if (options.withSummary) {
|
|
444
|
+
summaryArg = true;
|
|
437
445
|
}
|
|
438
446
|
runLoggingSession(command, args, summaryArg);
|
|
439
447
|
});
|