peterfei/ai-agent-team / .claude/skills/thread-manager
thread-manager
Flaggedsrc/tools/get-current-thread.ts
View on GitHubimport { ToolDefinition, ToolInvocation } from '../types';
import { ThreadManager } from '../core/thread-manager';
export const toolDefinition: ToolDefinition = {
name: 'get_current_thread',
description: 'Get information about the currently active thread.',
inputSchema: {
type: 'object',
properties: {
includeMessages: {
type: 'boolean',
description: 'Include message history (default: false)'
},
includeFileChanges: {
type: 'boolean',
description: 'Include file change history (default: false)'
}
}
}
};
export const toolHandler = async (invocation: ToolInvocation, threadManager: ThreadManager) => {
const { includeMessages, includeFileChanges } = invocation.input as any || {};
const result = await threadManager.getCurrentThread(includeMessages, includeFileChanges);
// Format the result as a message if there's a thread
if (result.thread) {
const thread = result.thread;
const shortId = thread.id.substring(0, 8);
let messageText = `### 📋 当前线程信息
- **标题**: ${thread.title}
- **ID**: \`${shortId}\`
- **描述**: ${thread.description || '无'}
${thread.gitBranch ? `- **Git 分支**: \`${thread.gitBranch}\`` : ''}
- **统计**: ${thread.messageCount} 消息 | ${thread.metadata.filesChanged} 文件变更 | +${thread.metadata.linesAdded} -${thread.metadata.linesDeleted} 行代码
`;
if (includeMessages && result.messages && result.messages.length > 0) {
messageText += `\n**💬 消息历史** (最近 ${Math.min(result.messages.length, 10)} 条):\n`;
result.messages.slice(0, 10).reverse().forEach(msg => {
const time = new Date(msg.timestamp).toLocaleString('zh-CN');
const roleText = msg.role === 'user' ? '👤' : '🤖';
const preview = msg.content.substring(0, 80).replace(/\n/g, ' ');
messageText += `- ${time} ${roleText}: ${preview}${msg.content.length > 80 ? '...' : ''}\n`;
});
}
if (includeFileChanges && result.fileChanges && result.fileChanges.length > 0) {
messageText += `\n**📁 文件变更** (最近 ${Math.min(result.fileChanges.length, 10)} 个):\n`;
result.fileChanges.slice(0, 10).forEach(fc => {
const time = new Date(fc.timestamp).toLocaleString('zh-CN');
messageText += `- ${time} \`${fc.changeType}\` ${fc.filePath} (+${fc.linesAdded} -${fc.linesDeleted})\n`;
});
}
return {
...result,
message: messageText
};
}
// If no thread found, return the message directly
return {
message: result.message || 'No active thread found.'
};
};
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |