Add AI-powered documentation generation (core)#3302
Add AI-powered documentation generation (core)#3302mjwolf wants to merge 7 commits intoelastic:mainfrom
Conversation
Co-authored-by: Jonathan Molinatto <jonathan.molinatto@gmail.com> Co-authored-by: Quan Nguyen <quan.nguyen@elastic.co> Co-authored-by: Cursor <cursoragent@cursor.com>
| ## Evaluation Criteria | ||
| Evaluate against these criteria (rate each 1-10): | ||
|
|
||
| 1. **Voice/Tone**: Friendly, uses "you", contractions, active voice |
There was a problem hiding this comment.
make sure this coincides with the vale rules
| 3. **Grammar**: American English, present tense, Oxford comma, sentence case headings | ||
| - Sentence case: "### Vendor-specific issues" NOT "### Vendor-Specific Issues" | ||
|
|
||
| 4. **Structure**: Clear summary, scannable sections, short paragraphs |
There was a problem hiding this comment.
maybe add the avoid 'via' here?
| if _, exists := r.agents[name]; !exists { | ||
| r.order = append(r.order, name) | ||
| } | ||
| r.agents[name] = agent |
There was a problem hiding this comment.
could probably move this inside the if block, too
There was a problem hiding this comment.
No, this is right as it is. If the agent already exists with the name, the last line will replace it with the new one. If it was moved in, this couldn't modify the agent if the name already exists.
| @@ -0,0 +1,142 @@ | |||
| # Style guide for Elastic integration documentation | |||
There was a problem hiding this comment.
is this still used? i saw a similar prompt in the generator code
There was a problem hiding this comment.
It was still needed, it's used as the system prompt when making revisions.
I think it wasn't in a good location though, it's not clear what the use was. I reorganized all the prompts to keep them closer to the location where they're used, and I've added more of the Vale rules to the generator and validator instructions, so a lot of the code around the prompts has been changed and reorganized now.
| // ConfirmInstructionsUnderstood asks the LLM to confirm it understood the system instructions. | ||
| // This should be called before any documentation workflow to ensure proper adherence. | ||
| func (d *DocumentationAgent) ConfirmInstructionsUnderstood(ctx context.Context) error { | ||
| fmt.Println("🔍 Verifying LLM understands documentation guidelines...") |
There was a problem hiding this comment.
have you found this necessary? it seems like it would just waste context and another LLM call.
There was a problem hiding this comment.
No, I haven't ever seen a difference without this, and I've never seen the LLM respond that it doesn't understand. I'll take out this prompt.
| } | ||
|
|
||
| // Skip AI-generated notice | ||
| if strings.HasPrefix(line, "> **Note**: This documentation was generated") { |
There was a problem hiding this comment.
I've updated this to the new prompt
| // GenerateAllSectionsWithWorkflow generates all sections using the multi-agent workflow. | ||
| // This method uses a configurable pipeline of agents (generator, critic, validator, etc.) | ||
| // to iteratively refine each section. Sections are generated in parallel. | ||
| func (d *DocumentationAgent) GenerateAllSectionsWithWorkflow(ctx context.Context, workflowCfg workflow.Config) ([]Section, error) { |
There was a problem hiding this comment.
this doesn't seem to be used. is this used somewhere?
There was a problem hiding this comment.
No, it wasn't used, I've removed it.
| */}} | ||
|
|
||
| ## Scaling | ||
| ### Vendor resources |
There was a problem hiding this comment.
Are we keeping links in only 2 places, next to setup steps and at the end. So should we remove this?
There was a problem hiding this comment.
Yeah, I removed it. There's almost never troubleshooting specific documentation available, so this section isn't useful.
cmd/update.go
Outdated
| cmd.AddCommand(updateDocumentationCmd) | ||
| cmd.PersistentFlags().StringP(cobraext.ProfileFlagName, "p", "", fmt.Sprintf(cobraext.ProfileFlagDescription, install.ProfileNameEnvVar)) | ||
|
|
||
| return cobraext.NewCommand(cmd, cobraext.ContextGlobal) |
There was a problem hiding this comment.
I can't think of any scenario where we would run it outside of a Package. Should we change the context to cobraext.ContextPackage?
There was a problem hiding this comment.
yeah, I changed this to ContextPackage
| var outputs []string | ||
|
|
||
| // Track input for LLM span | ||
| inputMessages := []tracing.Message{{Role: "user", Content: truncate(prompt, truncateLen)}} |
There was a problem hiding this comment.
I think we should not truncate messages used for Tracing. For logs it's okay, but if we do it in traces, it would reduce visibility.
Same comment for L281 ( outputMessagers )
There was a problem hiding this comment.
I think we should not truncate messages used for Tracing. For logs it's okay, but if we do it in traces, it would reduce visibility.
Same comment for L281 (
outputMessagers)
I've removed truncate from the tracing, and it's only used for debug logging now.
Add broader inclusive-language checks (disability-defining terms, gendered job titles, execute/abort variants), Git conflict marker detection, and new static style checks (banned words, latinisms, exclamation points, ellipses, version terms, article misuse). Extend style-rule prompts with wordiness, negation, and device-agnostic language guidance. Remove unused parallel generation helpers and trim the readme template. Made-with: Cursor
Move stylerules/ into prompts/ (now a dependency-free leaf package), relocate sectioninstructions.go to docagent/ (its only consumer), drop the _static/ subdirectory, compose AgentInstructions from FullFormattingRules to eliminate duplication, and extract shared validator JSON output suffix into prompts.ValidatorOutputSuffix. Made-with: Cursor
💚 Build Succeeded
History
cc @mjwolf |
Add the
elastic-package update documentationcommand that uses an LLM (Gemini) to generate package documentation via a section-based generate-validate workflow.Core components: