Grepai Watch Daemon

yoanbernabeu/grepai-skills/skills/indexing/grepai-watch-daemon

作者 yoanbernabeu382d40261c0d41109c6e11872574ba0be9b064d0无许可证收录于 2026年10月9日更新于 2026年10月9日

Configure and manage the GrepAI watch daemon. Use this skill for real-time code indexing and file monitoring.

仅含说明DevOps & Cloud
AI 生成的概览

配置和管理 GrepAI 监视守护进程,用于实时代码索引和文件监控。

功能
该技能说明如何启动、后台运行、查看状态和停止 GrepAI 监视守护进程;该进程会扫描项目源文件、切分代码块、生成嵌入并将向量存入配置的后端。它还涵盖防抖配置、初始索引行为、实时变更检测以及多项目或工作区设置。内容包括故障排查步骤和 launchd、systemd 的自动启动示例。
适用场景
适用于为项目设置或管理实时代码索引、在后台运行守护进程,或诊断索引与文件监控问题。也适用于在 macOS 或 Linux 上配置自动启动,或用工作区组织多个项目。
运行要求
需要 grepai 命令行工具,以及已配置的嵌入提供方和存储后端,例如 Ollama 或 OpenAI。后台运行和自动启动依赖 launchd 或 systemd 等操作系统机制,Linux 文件监控可能需要提高 inotify 限制。该技能不包含脚本,仅为说明文档。

GrepAI Watch Daemon

This skill covers the grepai watch command and daemon management for real-time code indexing.

When to Use This Skill

  • Starting initial code indexing
  • Setting up real-time file monitoring
  • Running the daemon in background
  • Troubleshooting indexing issues

What the Watch Daemon Does

The watch daemon:

  1. Scans all source files in your project
  2. Chunks code into segments (~512 tokens)
  3. Generates embeddings via your configured provider
  4. Stores vectors in your configured backend
  5. Monitors for file changes in real-time
  6. Updates the index when files change

Basic Usage

Start Watching (Foreground)

bash
cd /your/projectgrepai watch

Output:

🔍 GrepAI Watch   Scanning files...   Found 245 files   Processing chunks...   ████████████████████████████████ 100%   Indexed 1,234 chunks   Watching for changes...

Press Ctrl+C to stop.

Start in Background

bash
grepai watch --background

Output:

🔍 GrepAI Watch (background)   Daemon started with PID 12345   Log file: ~/.grepai/daemon.log

Check Daemon Status

bash
grepai watch --status

Output:

✅ GrepAI Daemon Running
   PID: 12345   Started: 2025-01-28 10:30:00   Project: /path/to/project
   Statistics:   - Files indexed: 245   - Chunks: 1,234   - Last update: 2 minutes ago

Stop the Daemon

bash
grepai watch --stop

Output:

✅ Daemon stopped (PID 12345)

Command Reference

CommandDescription
grepai watchStart daemon in foreground
grepai watch --backgroundStart daemon in background
grepai watch --statusCheck daemon status
grepai watch --stopStop running daemon

Configuration

Watch Settings

yaml
# .grepai/config.yamlwatch:  # Debounce delay in milliseconds  # Groups rapid file changes together  debounce_ms: 500

Debounce Explained

When you save a file, editors often write multiple times quickly. Debouncing waits for changes to settle:

ValueBehavior
100More responsive, more reindexing
500Balanced (default)
1000Less responsive, fewer reindexing

Initial Indexing

What Gets Indexed

The daemon indexes files:

  • Matching supported extensions (.go, .js, .ts, .py, etc.)
  • Not in ignore patterns (node_modules, .git, etc.)
  • Respecting .gitignore

Indexing Progress

Large codebases show progress:

Scanning files...Found 10,245 filesProcessing chunks...████████████████░░░░░░░░░░░░░░░░ 50% (5,122/10,245)

Indexing Time Estimates

CodebaseFilesTime (Ollama)Time (OpenAI)
Small100~30s~10s
Medium1,000~5min~1min
Large10,000~30min~5min

Real-Time Monitoring

After initial indexing, the daemon watches for:

  • File creation
  • File modification
  • File deletion
  • File renames

File Change Detection

Uses OS-native file watching:

  • macOS: FSEvents
  • Linux: inotify
  • Windows: ReadDirectoryChangesW

What Triggers Reindexing

ActionResult
Save existing fileRe-embed file chunks
Create new fileIndex new chunks
Delete fileRemove from index
Rename fileUpdate path, keep vectors

Background Daemon Management

Starting on System Boot

macOS (launchd)

Create ~/Library/LaunchAgents/com.grepai.watch.plist:

xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict>    <key>Label</key>    <string>com.grepai.watch</string>    <key>ProgramArguments</key>    <array>        <string>/usr/local/bin/grepai</string>        <string>watch</string>    </array>    <key>WorkingDirectory</key>    <string>/path/to/your/project</string>    <key>RunAtLoad</key>    <true/>    <key>KeepAlive</key>    <true/></dict></plist>

Load:

bash
launchctl load ~/Library/LaunchAgents/com.grepai.watch.plist
Linux (systemd)

Create ~/.config/systemd/user/grepai-watch.service:

ini
[Unit]Description=GrepAI Watch DaemonAfter=network.target
[Service]Type=simpleWorkingDirectory=/path/to/your/projectExecStart=/usr/local/bin/grepai watchRestart=always
[Install]WantedBy=default.target

Enable:

bash
systemctl --user enable grepai-watchsystemctl --user start grepai-watch

Checking Logs

bash
# Background daemon logstail -f ~/.grepai/daemon.log
# Or with systemdjournalctl --user -u grepai-watch -f

Multiple Projects

One Daemon Per Project

Run separate daemons for each project:

bash
# Terminal 1: Project Acd /path/to/project-agrepai watch --background
# Terminal 2: Project Bcd /path/to/project-bgrepai watch --background

Using Workspaces

For multi-project setups:

bash
grepai workspace create my-workspacegrepai workspace add my-workspace /path/to/project-agrepai workspace add my-workspace /path/to/project-bgrepai watch --workspace my-workspace

Troubleshooting

Daemon Won't Start

❌ Problem: "Another daemon is already running" ✅ Solution:

bash
grepai watch --stopgrepai watch --background

❌ Problem: "Config not found" ✅ Solution: Initialize first:

bash
grepai initgrepai watch

❌ Problem: "Embedder connection failed" ✅ Solution: Start your embedding provider:

bash
ollama serve  # For Ollama

Indexing Issues

❌ Problem: Files not being indexed ✅ Solution: Check ignore patterns in config, ensure file extension is supported

❌ Problem: Indexing very slow ✅ Solutions:

  • Use OpenAI for faster cloud embeddings
  • Add more ignore patterns
  • Increase chunking size

❌ Problem: Index seems outdated ✅ Solution: Clear and reindex:

bash
rm .grepai/index.gobgrepai watch

File Watch Issues

❌ Problem: Changes not detected ✅ Solutions:

  • Reduce debounce_ms
  • Check inotify limits (Linux):
    bash
    echo 65536 | sudo tee /proc/sys/fs/inotify/max_user_watches

Best Practices

  1. Run in background: For continuous monitoring
  2. Use workspace for monorepos: Better organization
  3. Set up auto-start: launchd or systemd
  4. Check logs periodically: Monitor for errors
  5. Reindex after config changes: Especially after changing embedding model

Status Check

Regular health check:

bash
grepai status

Output:

✅ GrepAI Status
   Project: /path/to/project   Config: .grepai/config.yaml
   Embedder: Ollama (nomic-embed-text)   Storage: GOB (.grepai/index.gob)
   Index:   - Files: 245   - Chunks: 1,234   - Size: 12.5 MB   - Last updated: 2025-01-28 10:30:00
   Daemon: Running (PID 12345)

Output Format

Watch daemon status:

✅ Watch Daemon Active
   Mode: Background   PID: 12345   Project: /path/to/project
   Initial Index:   - Files scanned: 245   - Chunks created: 1,234   - Duration: 45s
   Real-time Monitor:   - Debounce: 500ms   - Events processed: 23   - Last event: 5 minutes ago
   Next steps:   - Run 'grepai search "query"' to search   - Run 'grepai watch --status' to check status   - Run 'grepai watch --stop' to stop daemon

来源与署名

来源:yoanbernabeu/grepai-skills位于skills/indexing/grepai-watch-daemon提交382d402

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架