MCPcopy Create free account
hub / github.com/JordanCoin/codemap / Start

Method Start

watch/daemon.go:70–103  ·  view source on GitHub ↗

Start begins watching and returns immediately

()

Source from the content-addressed store, hash-verified

68
69// Start begins watching and returns immediately
70func (d *Daemon) Start() error {
71 // Ensure .codemap directory exists
72 codemapDir := filepath.Join(d.root, ".codemap")
73 if err := os.MkdirAll(codemapDir, 0755); err != nil {
74 return fmt.Errorf("failed to create .codemap dir: %w", err)
75 }
76
77 // Initial full scan
78 if err := d.fullScan(); err != nil {
79 return fmt.Errorf("initial scan failed: %w", err)
80 }
81
82 // Compute dependency graph (best effort). Skip on very large repos to avoid
83 // expensive startup memory/CPU spikes in background hook flows.
84 fileCount := d.FileCount()
85 if fileCount <= limits.LargeRepoFileCount {
86 d.computeDeps()
87 } else if d.verbose {
88 fmt.Printf("[watch] Skipping dependency graph for large repo (%d files)\n", fileCount)
89 }
90
91 // Add directories to watcher
92 if err := d.addWatchDirs(); err != nil {
93 return fmt.Errorf("failed to add watch dirs: %w", err)
94 }
95
96 // Write initial state for hooks to read immediately
97 d.writeState()
98
99 // Start event loop
100 go d.eventLoop()
101
102 return nil
103}
104
105// Stop gracefully shuts down the daemon
106func (d *Daemon) Stop() {

Callers 10

handleStartWatchFunction · 0.95
TestDaemonStartStopFunction · 0.95
TestEventDetectionFunction · 0.95
TestLineDeltaFunction · 0.95
TestNewFileCreationFunction · 0.95
TestFileRemovalFunction · 0.95
TestDebounceFunction · 0.95
TestNonSourceFileIgnoredFunction · 0.95

Calls 6

fullScanMethod · 0.95
FileCountMethod · 0.95
computeDepsMethod · 0.95
addWatchDirsMethod · 0.95
writeStateMethod · 0.95
eventLoopMethod · 0.95

Tested by 9

TestDaemonStartStopFunction · 0.76
TestEventDetectionFunction · 0.76
TestLineDeltaFunction · 0.76
TestNewFileCreationFunction · 0.76
TestFileRemovalFunction · 0.76
TestDebounceFunction · 0.76
TestNonSourceFileIgnoredFunction · 0.76