MCPcopy Index your code
hub / github.com/MiniCodeMonkey/chief / Start

Method Start

internal/loop/manager.go:211–255  ·  view source on GitHub ↗

Start starts the loop for a specific PRD.

(name string)

Source from the content-addressed store, hash-verified

209
210// Start starts the loop for a specific PRD.
211func (m *Manager) Start(name string) error {
212 if m.provider == nil {
213 return fmt.Errorf("manager provider is not configured")
214 }
215
216 m.mu.Lock()
217 instance, exists := m.instances[name]
218 m.mu.Unlock()
219
220 if !exists {
221 return fmt.Errorf("PRD %s not found", name)
222 }
223
224 instance.mu.Lock()
225 if instance.State == LoopStateRunning {
226 instance.mu.Unlock()
227 return fmt.Errorf("PRD %s is already running", name)
228 }
229
230 // Create a new loop instance, using worktree-aware constructor if WorktreeDir is set.
231 // When no worktree is configured, run from the project root (baseDir) so that
232 // CLAUDE.md and other project-level files are visible to Claude.
233 workDir := instance.WorktreeDir
234 if workDir == "" {
235 m.mu.RLock()
236 workDir = m.baseDir
237 m.mu.RUnlock()
238 }
239 instance.Loop = NewLoopWithWorkDir(instance.PRDPath, workDir, "", m.maxIter, m.provider)
240 instance.Loop.buildPrompt = promptBuilderForPRD(instance.PRDPath)
241 m.mu.RLock()
242 instance.Loop.SetRetryConfig(m.retryConfig)
243 m.mu.RUnlock()
244 instance.ctx, instance.cancel = context.WithCancel(context.Background())
245 instance.State = LoopStateRunning
246 instance.StartTime = time.Now()
247 instance.Error = nil
248 instance.mu.Unlock()
249
250 // Start the loop in a goroutine
251 m.wg.Add(1)
252 go m.runLoop(instance)
253
254 return nil
255}
256
257// runLoop runs a loop instance and forwards events.
258func (m *Manager) runLoop(instance *LoopInstance) {

Callers 3

runIterationMethod · 0.45

Calls 4

runLoopMethod · 0.95
NewLoopWithWorkDirFunction · 0.85
promptBuilderForPRDFunction · 0.85
SetRetryConfigMethod · 0.45

Tested by 2