ronds_ai 0.1.28 → 0.1.29
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/lib/analyze_session.js +38 -1
- package/package.json +1 -1
package/lib/analyze_session.js
CHANGED
|
@@ -12,6 +12,37 @@ const PREVIEW_LIMIT = 150;
|
|
|
12
12
|
const REQUEST_TIMEOUT_MS = 250;
|
|
13
13
|
const STALE_QUEUE_LOCK_MS = 30_000;
|
|
14
14
|
|
|
15
|
+
// 用户直敲 slash 命令时,Claude Code 内置命令不计入 Skill 统计。
|
|
16
|
+
// 名单来自官方 commands 文档(code.claude.com/docs/en/commands),补充少量未文档化内置命令。
|
|
17
|
+
const BUILTIN_COMMANDS = new Set([
|
|
18
|
+
// 官方文档列出的内置命令
|
|
19
|
+
'agents', 'artifacts', 'auto-mode-setup', 'chrome', 'cost', 'design-login', 'desktop', 'diff',
|
|
20
|
+
'doctor', 'exit', 'fewer-permission-prompts', 'focus', 'heapdump', 'help', 'hooks', 'ide',
|
|
21
|
+
'init', 'insights', 'install-github-app', 'install-slack-app', 'keybindings', 'list-agents',
|
|
22
|
+
'login', 'logout', 'memory', 'mobile', 'passes', 'permissions', 'powerup', 'privacy-settings',
|
|
23
|
+
'radio', 'rate-limit-options', 'recap', 'release-notes', 'reload-skills', 'remote-control',
|
|
24
|
+
'remote-env', 'rewind', 'run-skill-generator', 'run', 'sandbox', 'scroll-speed', 'security-review',
|
|
25
|
+
'setup-bedrock', 'setup-vertex', 'skill-doctor', 'skills', 'stats', 'status', 'statusline',
|
|
26
|
+
'stickers', 'stop', 'tasks', 'team-onboarding', 'teleport', 'terminal-setup', 'theme', 'upgrade',
|
|
27
|
+
'usage-credits', 'usage', 'verify', 'vim', 'web-setup', 'workflow-authoring', 'workflows',
|
|
28
|
+
// 未在文档列出但实际存在的内置命令
|
|
29
|
+
'clear', 'model', 'compact', 'resume', 'continue', 'config', 'mcp', 'bug', 'context', 'todos',
|
|
30
|
+
'export', 'quit', 'add-dir', 'output-style',
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
// 用户直敲的 slash 命令标记;字符集覆盖插件技能的 plugin:skill 命名形式。
|
|
34
|
+
const COMMAND_NAME_PATTERN = /<command-name>\/([a-zA-Z0-9_:-]+)\s*<\/command-name>/g;
|
|
35
|
+
|
|
36
|
+
/** 从用户直敲的 slash 命令消息中提取技能名,排除内置命令。 */
|
|
37
|
+
function extractSkillCommandNames(text) {
|
|
38
|
+
const names = new Set();
|
|
39
|
+
for (const match of String(text || '').matchAll(COMMAND_NAME_PATTERN)) {
|
|
40
|
+
const name = match[1].trim();
|
|
41
|
+
if (name && !BUILTIN_COMMANDS.has(name)) names.add(name);
|
|
42
|
+
}
|
|
43
|
+
return names;
|
|
44
|
+
}
|
|
45
|
+
|
|
15
46
|
/** 流式扫描 Claude JSONL,只保留会话摘要字段,避免构造完整对话树。 */
|
|
16
47
|
async function summarizeTranscript(filePath) {
|
|
17
48
|
const summary = { startedAt: null, endedAt: null, turnCount: 0, firstPromptPreview: '', skills: {} };
|
|
@@ -33,6 +64,12 @@ async function summarizeTranscript(filePath) {
|
|
|
33
64
|
const text = typeof content === 'string' ? content : blocks.filter((b) => b?.type === 'text').map((b) => b.text || '').join('\n');
|
|
34
65
|
if (text.trim()) summary.firstPromptPreview = text.trim().slice(0, PREVIEW_LIMIT);
|
|
35
66
|
}
|
|
67
|
+
if (role === 'user' && !row.isMeta && typeof content === 'string') {
|
|
68
|
+
// 用户直敲 /skill-name 的调用路径不产生 Skill 工具调用,从命令标记补计。
|
|
69
|
+
for (const name of extractSkillCommandNames(content)) {
|
|
70
|
+
summary.skills[name] = (summary.skills[name] || 0) + 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
36
73
|
if (role === 'user' && !row.isMeta && (typeof content === 'string' || blocks.some((b) => b?.type === 'text'))) summary.turnCount += 1;
|
|
37
74
|
for (const block of blocks) {
|
|
38
75
|
if (block?.type === 'tool_use' && block.name === 'Skill' && typeof block.input?.skill === 'string' && block.input.skill.trim()) {
|
|
@@ -127,4 +164,4 @@ async function collectAndReportSession({ transcriptPath, sessionId, config, proj
|
|
|
127
164
|
return payload;
|
|
128
165
|
}
|
|
129
166
|
|
|
130
|
-
module.exports = { MAX_QUEUE_ITEMS, collectAndReportSession, enqueueSnapshot, flushSnapshotQueue, postSnapshot, summarizeTranscript };
|
|
167
|
+
module.exports = { MAX_QUEUE_ITEMS, collectAndReportSession, enqueueSnapshot, extractSkillCommandNames, flushSnapshotQueue, postSnapshot, summarizeTranscript };
|