ai-cli-log 1.0.4 → 1.0.6

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.
Files changed (50) hide show
  1. package/.ai-cli-log/0001.txt +360 -0
  2. package/.ai-cli-log/0002.txt +1791 -0
  3. package/.ai-cli-log/0003.txt +338 -0
  4. package/.ai-cli-log/0004.txt +116 -0
  5. package/.ai-cli-log/0005.txt +105 -0
  6. package/.ai-cli-log/config.json +32 -0
  7. package/.ai-cli-log/gemini-2025-07-13T13-33-13-a-quick-gemini-test.txt +174 -0
  8. package/.ai-cli-log/gemini-2025-07-13T13-37-00-typescript-check-pass.txt +105 -0
  9. package/.ai-cli-log/gemini-2025-07-13T13-44-15-rename-ai-cli-logs-to-log.txt +164 -0
  10. package/.ai-cli-log/gemini-20250705-154601.txt +1320 -0
  11. package/.ai-cli-log/gemini-20250705-155547.txt +726 -0
  12. package/.ai-cli-log/gemini-20250705-165038.txt +66 -0
  13. package/.ai-cli-log/gemini-20250705-171429.txt +216 -0
  14. package/.ai-cli-log/gemini-20250705-191202.txt +448 -0
  15. package/.ai-cli-log/gemini-20250705-193741.txt +901 -0
  16. package/.ai-cli-log/gemini-20250705-194435.txt +110 -0
  17. package/.ai-cli-log/gemini-20250705-195926.txt +415 -0
  18. package/.ai-cli-log/gemini-20250705-201738.txt +246 -0
  19. package/.ai-cli-log/gemini-20250713-204921.txt +3036 -0
  20. package/.ai-cli-log/gemini-20250713-215941-update-ai-cli-log-documentation.txt +400 -0
  21. package/.ai-cli-log/gemini-20250713-220544-removed-debug-logs-successfully.txt +258 -0
  22. package/.ai-cli-log/gemini-20250713-221128-sessionsummarytxt.txt +112 -0
  23. package/.ai-cli-log/gemini-20250714-084659.txt +86 -0
  24. package/.ai-cli-log/gemini-20250714-085847-update-prompt-configuration.txt +189 -0
  25. package/.ai-cli-log/gemini-20250714-090905-add-sgpt-custom-summarizer.txt +284 -0
  26. package/.ai-cli-log/gemini-20250714-092329.txt +110 -0
  27. package/.ai-cli-log/gemini-20250714-092935.txt +183 -0
  28. 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 +140 -0
  29. package/.ai-cli-log/gemini-20250714-094141-heres-the-concise-summary-build-check-clean-this-captures-1.txt +111 -0
  30. package/.ai-cli-log/gemini-20250714-094405-heres-the-concise-summary-clean-build-check-this-captures-1.txt +111 -0
  31. package/.ai-cli-log/gemini-20250714-094816-json-summary-format.txt +132 -0
  32. package/.ai-cli-log/gemini-20250714-094833-optimize-summary-logic.txt +342 -0
  33. package/.ai-cli-log/gemini-20250714-133202-refactor-config-initialization.txt +1729 -0
  34. package/.ai-cli-log/gemini-20250714-134138-update-summary-logic.txt +153 -0
  35. package/.ai-cli-log/gemini-20250714-134749-json-summary-format.txt +214 -0
  36. package/.ai-cli-log/gemini-20250714-140527.txt +715 -0
  37. package/.ai-cli-log/gemini-20250714-142018.txt +86 -0
  38. package/.ai-cli-log/gemini-20250714-142027-update-summary-format.txt +86 -0
  39. package/.ai-cli-log/gemini-20250714-142100-session-complete.txt +86 -0
  40. package/.ai-cli-log/gemini-20250714-142129-refactor-readme-structure.txt +584 -0
  41. package/.ai-cli-log/gemini-20250714-213153.txt +1195 -0
  42. package/.ai-cli-log/gemini-20250714-222508-refactor-command-parser.txt +2110 -0
  43. package/.ai-cli-log/session-20250705-150655.txt +174 -0
  44. package/.ai-cli-log/session-20250705-151726.txt +313 -0
  45. package/.github/workflows/node.js.yml +30 -0
  46. package/GEMINI.md +5 -4
  47. package/README.md +229 -45
  48. package/dist/index.js +373 -80
  49. package/package.json +3 -1
  50. package/src/index.ts +424 -89
@@ -0,0 +1,132 @@
1
+ ███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████
2
+ ░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
3
+ ░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███
4
+ ░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███
5
+ ███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███
6
+ ███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███
7
+ ███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████
8
+ ░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
9
+
10
+
11
+ Tips for getting started:
12
+ 1. Ask questions, edit files, or run commands.
13
+ 2. Be specific for the best results.
14
+ 3. /help for more information.
15
+
16
+
17
+ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
18
+ │ > 你觉得src/index.ts 里面生成 aiSummary 的是否应该要求返回 json 格式呢,比如 {"summary": "fix-login-bug"} │
19
+ │ 这样是不是 ai 更容易学会呢?而不用强调要求它返回更短的短语呢?你怎么看 │
20
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
21
+
22
+ ✦ 您提的建议非常好,我完全同意。
23
+
24
+ 要求 AI 返回 JSON 格式(如 {"summary": "fix-login-bug"})相比于返回一个特定格式的短语,有几个显著的优点:
25
+
26
+
27
+ 1. 结构化与可靠性:JSON 是一种机器可读的、标准化的格式。AI 模型通常在生成 JSON
28
+ 方面训练有素,这使得输出结果更稳定、更可靠,大大减少了解析错误的可能性。
29
+ 2. 易于解析:在代码中,使用 JSON.parse()
30
+ 来处理响应比编写正则表达式或字符串分割逻辑来解析一个自定义格式的短语要简单和健壮得多。
31
+ 3. 可扩展性:如果未来我们想让 AI 提供更多信息(例如,变更类型、涉及的文件、风险评估等),JSON
32
+ 格式可以轻松扩展,而不会破坏现有逻辑。例如:
33
+
34
+ 1 {
35
+ 2 "summary": "fix-login-bug",
36
+ 3 "type": "bugfix",
37
+ 4 "confidence": 0.95
38
+ 5 }
39
+
40
+ 4. 更清晰的 AI 指令:给 AI 的指令可以更明确:“请根据本次会话生成一个总结,并以 JSON 格式返回,其中必须包含一个
41
+ summary 键。” 这比描述一个模糊的“短语”格式要清晰得多,减少了 AI 的误解。
42
+
43
+
44
+ 总而言之,切换到 JSON 格式是一个更健壮、更具前瞻性的选择。
45
+
46
+
47
+ 如果您同意,我可以立即开始分析和修改 src/index.ts 中的相关代码来实现这一功能。我将首先阅读文件内容以确定修改点。
48
+ ╭───────────────────────────╮
49
+ │ ✔ ReadFile src/index.ts │
50
+ ╰───────────────────────────╯
51
+
52
+ ℹ Request cancelled.
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ ╭───────────╮
110
+ │ > /quit │
111
+ ╰───────────╯
112
+
113
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
114
+ │ │
115
+ │ Agent powering down. Goodbye! │
116
+ │ │
117
+ │ Interaction Summary │
118
+ │ Tool Calls: 1 ( ✔ 1 ✖ 0 ) │
119
+ │ Success Rate: 100.0% │
120
+ │ │
121
+ │ Performance │
122
+ │ Wall Time: 1m 50s │
123
+ │ Agent Active: 38.2s │
124
+ │ » API Time: 38.1s (100.0%) │
125
+ │ » Tool Time: 19ms (0.0%) │
126
+ │ │
127
+ │ │
128
+ │ Model Usage Reqs Input Tokens Output Tokens │
129
+ │ ─────────────────────────────────────────────────────────────── │
130
+ │ gemini-2.5-pro 2 9,251 389 │
131
+ │ │
132
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -0,0 +1,342 @@
1
+ ███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████
2
+ ░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
3
+ ░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███
4
+ ░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███
5
+ ███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███
6
+ ███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███
7
+ ███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████
8
+ ░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
9
+
10
+
11
+ Tips for getting started:
12
+ 1. Ask questions, edit files, or run commands.
13
+ 2. Be specific for the best results.
14
+ 3. /help for more information.
15
+
16
+
17
+ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
18
+ │ > 请你修改 1.补充日志在写入文件之前,需要打印改文件名是由谁(哪个 │
19
+ │ model)总结的,总结结果的前N个词。另生成的文件名过长,我也需要你考虑按空格或者 - │
20
+ │ 分割,取前10个词然后再拼接恢复。同时优化一下 prompt ,现在模型有点傻。 │
21
+ │ heres-a-concise-summary-of-the-terminal-session-fix-sgpt-option-error-this-captures-1-the-action-fix-2-the-tool-i │
22
+ │ nvolved-sgpt-3-the-issue-option-error-4-follows-the-requested-lowercase-hyphenated-format │
23
+ │ 生成的太宽泛了,不够总结,请你一定要强调一下是总结内容的行为的概括,不是一个个精细的描述。 │
24
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
25
+
26
+ ✦ 好的,我将按您的要求修改 ai-cli-log 工具。
27
+
28
+ 计划如下:
29
+
30
+
31
+ 1. 优化总结提示 (Prompt): 我会修改发送给总结模型的提示,要求它生成更概括、更侧重于“行为”的摘要,而不是详细描述。
32
+ 2. 修改文件名逻辑:
33
+ * 在生成文件名时,我会将摘要按空格或连字符分割,只取前10个词。
34
+ * 在写入文件前,我会在控制台打印出是哪个模型生成的摘要,以及摘要的前几个词。
35
+
36
+
37
+ 我将首先阅读 src/index.ts 文件来定位并修改相关代码。
38
+ ╭───────────────────────────╮
39
+ │ ✔ ReadFile src/index.ts │
40
+ ╰───────────────────────────╯
41
+ ✦ 好的,我将执行您的请求。
42
+
43
+ 首先,我会用更优化的版本替换 src/index.ts 的全部内容。新版本将包含以下更改:
44
+
45
+
46
+ 1. 优化了 Prompt: 更新了默认的 Prompt,以生成更精确、面向操作的文件名摘要。
47
+ 2. 改进了文件名处理: 文件名将基于摘要的前10个词生成,避免过长。
48
+ 3. 增加了摘要信息打印: 在写入日志文件前,会先在控制台显示生成摘要的模型和摘要内容预览。
49
+
50
+
51
+ 我将用以下代码替换文件的全部内容。
52
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
53
+ │ ✔ Edit src/index.ts: #!/usr/bin/env node... => #!/usr/bin/env node... │
54
+ │ │
55
+ │ 90 const ask = (question: string) => new Promise<string>(resolve => rl.question(question, │
56
+ │ resolve)); │
57
+ │ 91 │
58
+ │ 92 const newSummarizers: Summarizer[] = []; │
59
+ │ 93 + const newPrompt = 'Analyze the following terminal session and provide a concise summary of │
60
+ │ the user\'s actions. The summary should be a 3-5 word, lowercase, filename-friendly phrase that │
61
+ │ describes the primary goal or activity, for example: "refactor-database-schema", │
62
+ │ "fix-login-bug", "install-new-dependencies". Do not describe the output, focus on the action. │
63
+ │ The session content is:'; │
64
+ │ 94 │
65
+ │ 95 if (availableTools.includes('gemini')) { │
66
+ │ 96 const add = await ask('\n> Create a summarizer configuration for Gemini? (Y/n): '); │
67
+ │ 98 newSummarizers.push({ │
68
+ │ 99 name: 'gemini-pro', │
69
+ │ 100 tool: 'gemini', │
70
+ │ 100 - prompt: 'Summarize the following terminal session into a 3-5 english word, │
71
+ │ lowercase, filename-friendly phrase, example: "a-quick-gemini-test" "typescript-check-pass", │
72
+ │ the session content is:', │
73
+ │ 101 + prompt: newPrompt, │
74
+ │ 102 maxLines: 100, │
75
+ │ 103 }); │
76
+ │ 104 } │
77
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
78
+ │ 114 name: `ollama-${model}`, │
79
+ │ 115 tool: 'ollama', │
80
+ │ 116 model: model, │
81
+ │ 116 - prompt: 'Summarize the following terminal session into a 3-5 english word, │
82
+ │ lowercase, filename-friendly phrase (e.g., "refactor-database-schema", "fix-login-bug"). │
83
+ │ The session content is:', │
84
+ │ 117 + prompt: newPrompt, │
85
+ │ 118 maxLines: 50, │
86
+ │ 119 }); │
87
+ │ 120 } │
88
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
89
+ │ 128 name: 'sgpt', │
90
+ │ 129 tool: 'custom', │
91
+ │ 130 command: ['sgpt', '--chat', 'session-summary', '"{{prompt}}"'], │
92
+ │ 130 - prompt: 'Summarize the following terminal session into a 3-5 english word, │
93
+ │ lowercase, filename-friendly phrase (e.g., "refactor-database-schema", "fix-login-bug"). The │
94
+ │ session content is:', │
95
+ │ 131 + prompt: newPrompt, │
96
+ │ 132 maxLines: 100, │
97
+ │ 133 }); │
98
+ │ 134 } │
99
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
100
+ │ 173 const name = summarizerName || config.summarizer.default; │
101
+ │ 174 │
102
+ │ 175 if (!name) { │
103
+ │ 175 - console.warn(` │
104
+ │ 176 - Warning: No default summarizer set. Please run 'ai-cli-log --init'.`); │
105
+ │ 176 + console.warn(`\nWarning: No default summarizer set. Please run 'ai-cli-log --init'.`); │
106
+ │ 177 return null; │
107
+ │ 178 } │
108
+ │ 179 │
109
+ │ 180 const summarizer = config.summarizer.summarizers.find(s => s.name === name); │
110
+ │ 181 │
111
+ │ 182 if (!summarizer) { │
112
+ │ 183 - console.warn(` │
113
+ │ 184 - Warning: No summarizer named "${name}" found. Please check your configuration.`); │
114
+ │ 183 + console.warn(`\nWarning: No summarizer named "${name}" found. Please check your │
115
+ │ configuration.`); │
116
+ │ 184 return null; │
117
+ │ 185 } │
118
+ │ 186 │
119
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
120
+ │ 225 const [cmd, ...args] = command; │
121
+ │ 226 │
122
+ │ 227 return new Promise((resolve) => { │
123
+ │ 229 - const slugify = (text: string) => text.toLowerCase().replace(/\s+/g, │
124
+ │ '-').replace(/[^a-z0-9-]/g, ''); │
125
+ │ 228 const proc = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'] }); │
126
+ │ 229 let summary = '', errorOutput = ''; │
127
+ │ 230 proc.stdout.on('data', data => { │
128
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
129
+ │ 240 console.error(`\nSummarizer command exited with code ${code}. Stderr: │
130
+ │ ${errorOutput}`); │
131
+ │ 241 resolve(null); │
132
+ │ 242 } else { │
133
+ │ 245 - const finalSummary = slugify(summary.trim()); │
134
+ │ 246 - resolve(finalSummary); │
135
+ │ 243 + resolve(summary.trim()); │
136
+ │ 244 } │
137
+ │ 245 }); │
138
+ │ 246 proc.on('error', err => { │
139
+ │ ══════════════════════════════════════════════════════════════════════════════════════════════════════ │
140
+ │ 312 let logFileName = `${prefix}-${timestamp}.txt`; │
141
+ │ 313 │
142
+ │ 314 if (summaryArg) { │
143
+ │ 318 - const summary = await getAiSummary(renderedOutput, typeof summaryArg === │
144
+ │ 'string' ? summaryArg : undefined); │
145
+ │ 319 - if (summary) { │
146
+ │ 320 - logFileName = `${prefix}-${timestamp}-${summary}.txt`; │
147
+ │ 315 + const rawSummary = await getAiSummary(renderedOutput, typeof summaryArg === │
148
+ │ 'string' ? summaryArg : undefined); │
149
+ │ 316 + if (rawSummary) { │
150
+ │ 317 + const config = readConfig(); │
151
+ │ 318 + const summarizerName = (typeof summaryArg === 'string' ? summaryArg : │
152
+ │ config.summarizer.default) || 'default'; │
153
+ │ 319 + │
154
+ │ 320 + const summaryWords = rawSummary.split(/\s+/); │
155
+ │ 321 + const summaryPreview = summaryWords.slice(0, 10).join(' '); │
156
+ │ 322 + console.log(`\nSummary by ${summarizerName}: │
157
+ │ "${summaryPreview}${summaryWords.length > 10 ? '...' : ''}"`); │
158
+ │ 323 + │
159
+ │ 324 + const slugify = (text: string) => text.toLowerCase().replace(/\s+/g, │
160
+ │ '-').replace(/[^a-z0-9-]/g, ''); │
161
+ │ 325 + const slug = slugify(rawSummary).split('-').slice(0, 10).join('-'); │
162
+ │ 326 + logFileName = `${prefix}-${timestamp}-${slug}.txt`; │
163
+ │ 327 } │
164
+ │ 328 } │
165
+ │ 329 │
166
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
167
+ ✦ 好的,代码修改已完成。
168
+
169
+ 我已根据您的要求更新了 src/index.ts 文件,主要包含以下三点:
170
+
171
+
172
+ 1. 优化了提示(Prompt):新的提示会引导 AI 生成更侧重于“行为”概括的摘要。
173
+ 2. 文件名长度限制:现在会自动截取摘要的前10个词来生成文件名,避免了文件名过长的问题。
174
+ 3. 增加摘要信息:在保存日志前,会在终端打印出生成该摘要的模型名称和摘要内容的预览。
175
+
176
+
177
+ 接下来,我将执行 npm run build 来编译 TypeScript 代码,以确保修改没有引入任何错误。
178
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
179
+ │ ✔ Shell npm run build (Compile the TypeScript code to JavaScript to apply the changes.) │
180
+ │ │
181
+ │ │
182
+ │ > ai-cli-log@1.0.4 build │
183
+ │ > tsc │
184
+ │ │
185
+ │ │
186
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
187
+ ✦ 编译成功。您的修改现在已经生效。
188
+
189
+
190
+ 如果您还有其他需要,请随时告诉我。
191
+
192
+ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮
193
+ │ > 还是有问题 "Here's the concise summary: build-check-clean This captures: 1 The build... │
194
+ │ 请你能否强调一下只输出总结的词本身比如 build-check-clean │
195
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯
196
+
197
+ ✦ 您指出的问题很明确,模型在生成摘要时加入了多余的解释性文字,而我们只需要纯粹的、符合文件名格式的短语。
198
+
199
+
200
+ 这是典型的提示工程问题。为了解决它,我将再次修改 src/index.ts 文件中的提示(Prompt),使其更加严格和明确。
201
+
202
+ 我的计划如下:
203
+
204
+
205
+ 1. 强化提示(Prompt):我会更新提示,用非常明确的语言指示模型只能输出最终的、连字符分隔的短语,禁止任何形式的引言、解
206
+ 释或额外文字。
207
+ 2. 重新编译:修改后,我会再次运行构建命令以应用更改。
208
+
209
+
210
+ 现在,我将开始修改 src/index.ts。
211
+ ╭───────────────────────────╮
212
+ │ ✔ ReadFile src/index.ts │
213
+ ╰───────────────────────────╯
214
+ ✦ 好的,我明白了。AI 模型在提供摘要时仍然过于“健谈”,我们需要更严格地限制其输出。
215
+
216
+
217
+ 我将通过更新 src/index.ts
218
+ 文件中的提示(Prompt)来解决这个问题,使其指令更加明确和强制,确保模型只返回我们需要的文本。
219
+
220
+ 这是我的计划:
221
+
222
+
223
+ 1. 强化提示(Prompt):我会用一个更严格的提示替换现有的提示,明确指示模型只能输出摘要短语,不包含任何额外的单词或解释
224
+
225
+ 2. 应用更改:我将使用新提示更新 src/index.ts 文件。
226
+ 3. 重新编译:为了使更改生效,我将重新编译 TypeScript 代码。
227
+
228
+
229
+ 现在,我将执行替换操作。
230
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
231
+ │ ✔ Edit src/index.ts: const newPrompt = 'Analyze... => const newPrompt = 'CRITICA... │
232
+ │ │
233
+ │ 90 const ask = (question: string) => new Promise<string>(resolve => rl.question(question, │
234
+ │ resolve)); │
235
+ │ 91 │
236
+ │ 92 const newSummarizers: Summarizer[] = []; │
237
+ │ 93 - const newPrompt = 'Analyze the following terminal session and provide a concise summary of the │
238
+ │ user\'s actions. The summary should be a 3-5 word, lowercase, filename-friendly phrase that │
239
+ │ describes the primary goal or activity, for example: "refactor-database-schema", │
240
+ │ "fix-login-bug", "install-new-dependencies". Do not describe the output, focus on the action. │
241
+ │ The session content is:'; │
242
+ │ 93 + const newPrompt = 'CRITICAL: Your response MUST be ONLY a 3-5 word, lowercase, │
243
+ │ filename-friendly phrase summarizing the user\'s actions in the following terminal session. DO │
244
+ │ NOT include any other words, explanations, or introductory phrases. Examples of valid │
245
+ │ responses: "refactor-database-schema", "fix-login-bug", "install-new-dependencies". Your entire │
246
+ │ output should be just the phrase. The session content is:' │
247
+ │ 94 │
248
+ │ 95 if (availableTools.includes('gemini')) { │
249
+ │ 96 const add = await ask('\n> Create a summarizer configuration for Gemini? (Y/n): '); │
250
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
251
+ ✦ 提示(Prompt)已经更新。
252
+
253
+
254
+ 现在,我将运行 npm run build 来编译修改后的 TypeScript 代码,确保更改生效。
255
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
256
+ │ ✔ Shell npm run build (Compile the TypeScript code to JavaScript to apply the changes.) │
257
+ │ │
258
+ │ │
259
+ │ > ai-cli-log@1.0.4 build │
260
+ │ > tsc │
261
+ │ │
262
+ │ │
263
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
264
+ ✦ 编译成功。
265
+
266
+ 我已经使用更严格的提示更新了代码,该提示强制模型只输出摘要短语,不含任何额外文本。这应该能解决您之前遇到的问题。
267
+
268
+
269
+ 您可以再次尝试使用该工具,看看效果如何。如果还有其他问题,请随时提出。
270
+
271
+ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
272
+ │ > 我执行 --init --local 发现并没有修改本地的config 的配置的 json 里面的prompt 是否是因为现在用代码里面的了2呢 │
273
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
274
+
275
+ ✦ 您观察得非常准确,一针见血!
276
+
277
+
278
+ 您本地 config.json 文件中的 prompt 没有被更新,正是因为 --init
279
+ 命令被设计为非破坏性的。它只会添加新的、不存在的配置,而不会覆盖您现有的配置。
280
+
281
+ 在代码中,这部分逻辑在这里:
282
+
283
+
284
+
285
+ 1 // ... inside handleInitCommand
286
+ 2 newSummarizers.forEach(s => {
287
+ 3 if (!existingNames.has(s.name)) { // <--- 这里检查配置是否已存在
288
+ 4 mergedSummarizers.push(s);
289
+ 5 }
290
+ 6 });
291
+
292
+
293
+
294
+ 因为您的配置文件中已经存在名为 gemini-pro 的配置,所以程序会跳过它,不会用代码中新的 prompt去更新它。
295
+
296
+ 如何解决?
297
+
298
+ 您有两个选择:
299
+
300
+
301
+ 1. 手动更新:最快的方法是手动编辑您的本地配置文件。
302
+ * 文件路径: /Users/zhihu/output/github/ai-cli-log/.ai-cli-log/config.json
303
+ * 将 prompt 的值替换为我们最新优化的版本:
304
+
305
+
306
+ 1 "CRITICAL: Your response MUST be ONLY a 3-5 word, lowercase, filename-friendly phrase summarizing
307
+ the user's actions in the following terminal session. DO NOT include any other words, explanations, or
308
+ introductory phrases. Examples of valid responses: \"refactor-database-schema\", \"fix-login-bug\",
309
+ \"install-new-dependencies\". Your entire output should be just the phrase. The session content is:"
310
+
311
+
312
+
313
+ 2. 修改代码:如果您希望,我可以修改 --init 命令,比如增加一个 --force 标志,让它能够强制覆盖现有的配置。
314
+
315
+
316
+ 您希望选择哪种方式?如果您希望我修改代码,请告诉我。
317
+
318
+ ╭───────────╮
319
+ │ > /quit │
320
+ ╰───────────╯
321
+
322
+ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
323
+ │ │
324
+ │ Agent powering down. Goodbye! │
325
+ │ │
326
+ │ Interaction Summary │
327
+ │ Tool Calls: 6 ( ✔ 6 ✖ 0 ) │
328
+ │ Success Rate: 100.0% │
329
+ │ User Agreement: 100.0% (3 reviewed) │
330
+ │ │
331
+ │ Performance │
332
+ │ Wall Time: 15m 10s │
333
+ │ Agent Active: 5m 2s │
334
+ │ » API Time: 4m 7s (81.6%) │
335
+ │ » Tool Time: 55.7s (18.4%) │
336
+ │ │
337
+ │ │
338
+ │ Model Usage Reqs Input Tokens Output Tokens │
339
+ │ ─────────────────────────────────────────────────────────────── │
340
+ │ gemini-2.5-pro 9 190,456 9,309 │
341
+ │ │
342
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯