Skip to content

Commit 9799b2b

Browse files
committed
feat: enhance gitignore check and update analysis documentation handling
1 parent c0d56ce commit 9799b2b

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

pkg/agentenv/agentenv.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agentenv
22

33
import (
4+
"bytes"
45
"context"
56
"fmt"
67
"log/slog"
@@ -157,14 +158,12 @@ func updateGitIgnore(outputPath string) error {
157158
}
158159

159160
if stat.Size() > 0 {
160-
// Check if the marker already exists
161+
// Check if the marker already exists anywhere in the file
161162
content, err := os.ReadFile(gitignorePath)
162163
if err != nil {
163164
return fmt.Errorf("failed to read .gitignore: %w", err)
164165
}
165-
contentLen := len(content)
166-
markerLen := len(gitignoreMarker)
167-
if contentLen >= markerLen && string(content[contentLen-markerLen:]) == gitignoreMarker {
166+
if bytes.Contains(content, []byte(gitignoreMarker)) {
168167
// Marker already exists, no need to add again
169168
return nil
170169
}

pkg/agentenv/analyse.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Analyze this project and extract STABLE, HIGH-LEVEL information that rarely chan
99
- Explain the mental model, not the code structure
1010
- Wrap your analysis in tags: `### BEGIN ANALYSIS ###` and `### END ANALYSIS ###` (without the backticks)
1111

12-
Example output structure (use Markdown):
12+
## Example output:
1313

1414
```Markdown
1515

@@ -73,9 +73,13 @@ The architecture follows a modular, service-oriented design philosophy where dis
7373
- Backward compatibility approach
7474
- NOT: Current roadmap or pending features
7575

76+
8. **Folder Structure Philosophy**
77+
- Rationale behind the organization of code into folders
78+
- Document every case with examples
79+
- For every example draw tree diagrams
80+
7681
## Exclude From Analysis
7782

78-
Do not include these volatile implementation details:
7983
- Current file paths and function names
8084
- Specific dependencies and versions
8185
- Implementation details and code snippets

pkg/agentenv/analyser.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
endMarker = "### END ANALYSIS ###"
2121

2222
providerClaude = "claude"
23-
modelClaude = "claude-opus-4-1"
23+
modelClaude = "claude-sonnet-4-0"
2424

2525
providerGemini = "gemini"
2626
modelGemini = "gemini-2.5-pro"
@@ -92,13 +92,25 @@ func (a *analyser) Run(ctx context.Context, provider string, model string) error
9292

9393
if err != nil {
9494
a.logger.Error("Analysis command failed", "error", err, "stderr", errorOutput)
95-
if output == "" && errorOutput != "" {
96-
output = errorOutput
95+
errorDetails := fmt.Sprintf(
96+
"# Analysis Failed\n\n## Command Error\n%v\n\n## Standard Error Output\n%s\n\n## Standard Output\n%s\n",
97+
err,
98+
errorOutput,
99+
output,
100+
)
101+
if output == "" {
102+
output = errorDetails
103+
} else {
104+
output = errorDetails + "\n\n## Original Output\n" + output
97105
}
98106
}
99107

100108
if output == "" {
101-
return fmt.Errorf("no output from analysis")
109+
output = fmt.Sprintf(
110+
"# Analysis Failed\n\nNo output generated from the analysis command.\nCommand: %s\nError: %v\n",
111+
cmd.String(),
112+
err,
113+
)
102114
}
103115

104116
output = a.extractAnalysis(output)

pkg/agentenv/template/chunks/20-operation.tpl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Operation
1+
### Operation
22

33
- Ignore anything between `[IGNORE]` and `[/IGNORE]` tags - it used for internal notes
44
- When possible always prefer executing actions (tools) in parallel.

0 commit comments

Comments
 (0)