Skip to content

peterfei/ai-agent-team / .claude/skills/thread-manager

thread-manager

Flagged

FileKindSize
.claude/.threads/current-context.mdmarkdown648 B
.gitignoreother76 B
.npmignoreother138 B
CHANGELOG.mdmarkdown1.1 KB
README.mdmarkdown4.7 KB
SKILL.mdskill md1.7 KB
USAGE_GUIDE.mdmarkdown6.7 KB
docs/clt-aliases.mdmarkdown2.2 KB
find-module.jsscript166 B
jest.config.jsscript1.1 KB
models/Xenova/all-MiniLM-L6-v2/config.jsonconfig650 B
models/Xenova/all-MiniLM-L6-v2/onnx/model_quantized.onnxother21.9 MB
models/Xenova/all-MiniLM-L6-v2/special_tokens_map.jsonconfig125 B
models/Xenova/all-MiniLM-L6-v2/tokenizer.jsonconfig695.0 KB
models/Xenova/all-MiniLM-L6-v2/tokenizer_config.jsonconfig366 B
package-lock.jsonmanifest406.8 KB
package.jsonmanifest1.1 KB
scripts/download-model.jsscript1.7 KB
scripts/migrate-embeddings.tsscript3.4 KB
src/core/embedding-service.tsscript4.3 KB
src/core/thread-manager.tsscript14.3 KB
src/core/vector-search-engine.tsscript1.2 KB
src/core/vector-utils.tsscript1.0 KB
src/database/db.tsscript4.5 KB
src/database/file-changes-dao.tsscript2.8 KB
src/database/index.tsscript121 B
src/database/messages-dao.tsscript5.1 KB
src/database/threads-dao.tsscript6.4 KB
src/git/git-integration.tsscript5.6 KB
src/index.tsscript257 B
src/server.tsscript6.1 KB
src/tools/add-message.tsscript1.5 KB
src/tools/create-thread.tsscript1.3 KB
src/tools/delete-thread.tsscript925 B
src/tools/get-current-thread.tsscript2.6 KB
src/tools/get-thread.tsscript1.2 KB
src/tools/list-threads.tsscript1.2 KB
src/tools/search-messages.tsscript4.4 KB
src/tools/switch-thread.tsscript1.4 KB
src/tools/track-file-change.tsscript1.7 KB
src/tools/update-thread.tsscript1.2 KB
src/types/index.tsscript2.6 KB
test-add-message.jsscript2.3 KB
test-output-format.jsscript546 B
tests/integration/file-tracker.test.tsscript3.3 KB
tests/integration/mcp-tools.test.tsscript5.4 KB
tests/integration/search-messages.test.tsscript5.8 KB
tests/unit/__mocks__/embedding-service.tsscript1.3 KB
tests/unit/database.test.tsscript1.6 KB
tests/unit/file-changes-dao.test.tsscript3.6 KB
tests/unit/git-integration.test.tsscript4.9 KB
tests/unit/messages-dao.test.tsscript3.9 KB
tests/unit/thread-manager.test.tsscript9.2 KB
tests/unit/threads-dao.test.tsscript6.0 KB
tests/unit/vector-search.test.tsscript3.7 KB
tsconfig.jsonconfig464 B

src/git/git-integration.ts

View on GitHub
import simpleGit, { SimpleGit, DiffResult } from 'simple-git';
import path from 'path';
import fs from 'fs-extra';

export interface DiffStats {
  filesChanged: number;
  linesAdded: number;
  linesDeleted: number;
  fileStats: Record<string, { added: number; deleted: number; changeType: 'added' | 'modified' | 'deleted' }>;
}

export class GitIntegration {
  private git: SimpleGit;
  private rootDir: string;

  constructor(rootDir?: string) {
    this.rootDir = rootDir || process.cwd();
    this.git = simpleGit(this.rootDir);
  }

  public async isGitRepo(): Promise<boolean> {
    try {
      return await this.git.checkIsRepo();
    } catch (e) {
      return false;
    }
  }

  public async getCurrentCommit(): Promise<string | undefined> {
    try {
      const log = await this.git.log({ maxCount: 1 });
      return log.latest?.hash;
    } catch (e) {
      return undefined;
    }
  }

  public async getUnstagedDiff(filePath?: string): Promise<string> {
    try {
      const options = filePath ? [filePath] : [];
      return await this.git.diff(options);
    } catch (e) {
      console.error('Error getting unstaged diff:', e);
      return '';
    }
  }

  public async getStagedDiff(filePath?: string): Promise<string> {
    try {
      const options = ['--cached'];
      if (filePath) options.push(filePath);
      return await this.git.diff(options);
    } catch (e) {
      console.error('Error getting staged diff:', e);
      return '';
    }
  }

  /**
   * Get stats for a specific file based on its current state on disk vs HEAD
   * This includes both staged and unstaged changes.
   */
  public async getFileStats(filePath: string): Promise<{ added: number; deleted: number; changeType: 'added' | 'modified' | 'deleted' }> {
    try {
      // Use git diff --numstat HEAD -- filePath
      // This compares working directory (and stage) against HEAD
      const raw = await this.git.raw(['diff', '--numstat', 'HEAD', '--', filePath]);
      
      if (!raw.trim()) {
        // If no output, maybe it's a new untracked file?
        const status = await this.git.status();
        const isUntracked = status.not_added.includes(filePath);
        if (isUntracked) {
           // For untracked files, count all lines as added
           try {
             const content = await fs.readFile(path.resolve(this.rootDir, filePath), 'utf-8');
             const lines = content.split('\n').length;
             return { added: lines, deleted: 0, changeType: 'added' };
           } catch (e) {
             return { added: 0, deleted: 0, changeType: 'modified' }; // Should not happen if file exists
           }
        }
        return { added: 0, deleted: 0, changeType: 'modified' };
      }

      const parts = raw.trim().split(/\s+/);
      if (parts.length >= 2) {
        const added = parseInt(parts[0], 10) || 0;
        const deleted = parseInt(parts[1], 10) || 0;
        
        // Determine change type
        // This is a simplification. 'added' usually means new file, 'deleted' means file removed.
        // git diff --numstat doesn't explicitly say 'new file'.
        // We can check git status for more precision if needed.
        let changeType: 'added' | 'modified' | 'deleted' = 'modified';
        
        // Check status for better type determination
        const status = await this.git.status();
        if (status.created.includes(filePath) || status.not_added.includes(filePath)) {
            changeType = 'added';
        } else if (status.deleted.includes(filePath)) {
            changeType = 'deleted';
        }

        return { added, deleted, changeType };
      }

      return { added: 0, deleted: 0, changeType: 'modified' };
    } catch (e) {
      console.error(`Error getting file stats for ${filePath}:`, e);
      return { added: 0, deleted: 0, changeType: 'modified' };
    }
  }

  /**
   * Parse a unified diff string to count lines (fallback if numstat isn't enough)
   */
  public parseDiff(diff: string): { added: number, deleted: number } {
    let added = 0;
    let deleted = 0;
    
    const lines = diff.split('\n');
    for (const line of lines) {
      if (line.startsWith('+++') || line.startsWith('---')) continue;
      if (line.startsWith('+')) added++;
      if (line.startsWith('-')) deleted++;
    }
    
    return { added, deleted };
  }

  /**
   * Get current branch name
   */
  public async getCurrentBranch(): Promise<string | null> {
    try {
      const result = await this.git.branch();
      return result.current;
    } catch (e) {
      return null;
    }
  }

  /**
   * Create and checkout a new branch
   */
  public async createAndCheckoutBranch(branchName: string): Promise<boolean> {
    try {
      await this.git.checkoutLocalBranch(branchName);
      return true;
    } catch (e) {
      console.error('Error creating branch:', e);
      return false;
    }
  }

  /**
   * Checkout an existing branch
   */
  public async checkoutBranch(branchName: string): Promise<boolean> {
    try {
      await this.git.checkout(branchName);
      return true;
    } catch (e) {
      console.error('Error checking out branch:', e);
      return false;
    }
  }

  /**
   * Check if branch exists
   */
  public async branchExists(branchName: string): Promise<boolean> {
    try {
      const branches = await this.git.branch();
      return branches.all.includes(branchName);
    } catch (e) {
      return false;
    }
  }

  /**
   * Delete a branch
   */
  public async deleteBranch(
    branchName: string,
    force: boolean = false
  ): Promise<boolean> {
    try {
      await this.git.branch([force ? '-D' : '-d', branchName]);
      return true;
    } catch (e) {
      console.error('Error deleting branch:', e);
      return false;
    }
  }
}
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: 197kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall