Skip to content

Commit 8cbdfba

Browse files
feat(init-deep): restructure Phase 1 to fire background explore first, then LSP codemap
- Step 1: Fire ALL background explore agents immediately (non-blocking) - Step 2: Main session builds codemap understanding using LSP tools while background runs - Step 3: Collect background results after main session analysis This maximizes throughput by having agents discover patterns while the main session analyzes code structure semantically via LSP.
1 parent 7cb3f23 commit 8cbdfba

File tree

1 file changed

+51
-28
lines changed

1 file changed

+51
-28
lines changed

src/features/builtin-commands/templates/init-deep.ts

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,18 @@ TodoWrite([
4646
4747
**Mark "p1-analysis" as in_progress.**
4848
49-
Launch **ALL tasks simultaneously**:
50-
51-
<parallel-tasks>
52-
53-
### Structural Analysis (bash - run in parallel)
54-
\`\`\`bash
55-
# Task A: Directory depth analysis
56-
find . -type d -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c
57-
58-
# Task B: File count per directory
59-
find . -type f -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30
49+
<critical>
50+
**EXECUTION PATTERN**: Fire background agents FIRST (non-blocking), then main session builds codemap understanding using LSP tools in parallel. This maximizes throughput—agents discover while you analyze.
51+
</critical>
6052
61-
# Task C: Code concentration
62-
find . -type f \\( -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.go" -o -name "*.rs" -o -name "*.java" \\) -not -path '*/node_modules/*' -not -path '*/venv/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20
53+
---
6354
64-
# Task D: Existing knowledge files
65-
find . -type f \\( -name "AGENTS.md" -o -name "CLAUDE.md" \\) -not -path '*/node_modules/*' 2>/dev/null
66-
\`\`\`
55+
### Step 1: Fire Background Explore Agents (IMMEDIATELY)
6756
68-
### Context Gathering (Explore agents - background_task in parallel)
57+
Fire ALL background tasks at once. They run asynchronously—don't wait for results yet.
6958
7059
\`\`\`
60+
// Fire immediately - these run in parallel, non-blocking
7161
background_task(agent="explore", prompt="Project structure: PREDICT standard {lang} patterns → FIND package.json/pyproject.toml/go.mod → REPORT deviations only")
7262
7363
background_task(agent="explore", prompt="Entry points: PREDICT typical (main.py, index.ts) → FIND actual → REPORT non-standard organization")
@@ -81,32 +71,56 @@ background_task(agent="explore", prompt="Build/CI: FIND .github/workflows, Makef
8171
background_task(agent="explore", prompt="Test patterns: FIND pytest.ini, jest.config, test structure → REPORT unique testing conventions")
8272
\`\`\`
8373
84-
### Code Intelligence Analysis (LSP tools - run in parallel)
74+
---
75+
76+
### Step 2: Main Session Codemap Understanding (while background runs)
77+
78+
While background agents discover patterns, main session builds codemap understanding using direct tools.
79+
80+
<parallel-tools>
81+
82+
#### Structural Analysis (bash)
83+
\`\`\`bash
84+
# Task A: Directory depth analysis
85+
find . -type d -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c
86+
87+
# Task B: File count per directory
88+
find . -type f -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30
89+
90+
# Task C: Code concentration
91+
find . -type f \\( -name "*.py" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.go" -o -name "*.rs" -o -name "*.java" \\) -not -path '*/node_modules/*' -not -path '*/venv/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20
92+
93+
# Task D: Existing knowledge files
94+
find . -type f \\( -name "AGENTS.md" -o -name "CLAUDE.md" \\) -not -path '*/node_modules/*' 2>/dev/null
95+
\`\`\`
96+
97+
#### LSP Codemap Analysis (main session - semantic understanding)
8598
86-
LSP provides semantic understanding beyond text search. Use for accurate code mapping.
99+
LSP provides semantic understanding beyond text search. Build the codemap while background agents run.
87100
88101
\`\`\`
89-
# Step 1: Check LSP availability
102+
# Check LSP availability first
90103
lsp_servers() # Verify language server is available
91104
92-
# Step 2: Analyze entry point files (run in parallel)
93-
# Find entry points first, then analyze each with lsp_document_symbols
105+
# Analyze entry point files (run in parallel)
94106
lsp_document_symbols(filePath="src/index.ts") # Main entry
95107
lsp_document_symbols(filePath="src/main.py") # Python entry
96108
lsp_document_symbols(filePath="cmd/main.go") # Go entry
97109
98-
# Step 3: Discover key symbols across workspace (run in parallel)
110+
# Discover key symbols across workspace (run in parallel)
99111
lsp_workspace_symbols(filePath=".", query="class") # All classes
100112
lsp_workspace_symbols(filePath=".", query="interface") # All interfaces
101113
lsp_workspace_symbols(filePath=".", query="function") # Top-level functions
102114
lsp_workspace_symbols(filePath=".", query="type") # Type definitions
103115
104-
# Step 4: Analyze symbol centrality (for top 5-10 key symbols)
116+
# Analyze symbol centrality (for top 5-10 key symbols)
105117
# High reference count = central/important concept
106118
lsp_find_references(filePath="src/index.ts", line=X, character=Y) # Main export
107119
\`\`\`
108120
109-
#### LSP Analysis Output Format
121+
</parallel-tools>
122+
123+
#### Codemap Output Format
110124
111125
\`\`\`
112126
CODE_INTELLIGENCE = {
@@ -125,12 +139,21 @@ CODE_INTELLIGENCE = {
125139
\`\`\`
126140
127141
<critical>
128-
**LSP Fallback**: If LSP unavailable (no server installed), skip this section and rely on explore agents + AST-grep patterns.
142+
**LSP Fallback**: If LSP unavailable (no server installed), skip LSP section and rely on explore agents + AST-grep patterns.
129143
</critical>
130144
131-
</parallel-tasks>
145+
---
146+
147+
### Step 3: Collect Background Results
148+
149+
After main session analysis complete, collect background agent results:
150+
151+
\`\`\`
152+
// Collect all background_task results
153+
// background_output(task_id="...") for each fired task
154+
\`\`\`
132155
133-
**Collect all results. Mark "p1-analysis" as completed.**
156+
**Merge bash + LSP + background agent findings. Mark "p1-analysis" as completed.**
134157
135158
---
136159

0 commit comments

Comments
 (0)