Skip to content

Add modify mode to elastic-package update documentation#3688

Merged
mjwolf merged 7 commits into
elastic:mainfrom
mjwolf:doc_update_3
Jul 7, 2026
Merged

Add modify mode to elastic-package update documentation#3688
mjwolf merged 7 commits into
elastic:mainfrom
mjwolf:doc_update_3

Conversation

@mjwolf

@mjwolf mjwolf commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Extends the AI-powered documentation command with a targeted modification mode, complementing the existing full-rewrite mode.

With modify mode, the user will be prompted for a description of the change to apply to the existing documentation.

The LLM will apply the described change by first analyzing what section(s) the change applies to. It will then apply the change to all relevent sections. In interactive mode, the user will be shown a preview of the prompt, and be given an option to accept it, or repeat the process to make futher changes to the documentation.

How modify mode works:

  • Scope analysis (modificationanalyzer.go): Before making changes, the LLM analyzes the modification request and classifies it as global (affects the whole document), specific (affects named sections), or ambiguous. Specific-scope modifications only regenerate the relevant sections, leaving the rest untouched.
  • Section-aware application: Modifications are applied section-by-section. For specific scope, only affected sections (including their subsections) are regenerated; for global/ambiguous scope, all sections are rewritten with the modification context.
  • Interactive revision loop: In interactive mode, after reviewing the output users can now choose "Request changes" in addition to Accept/Cancel. This prompts for new instructions and re-runs the modification workflow, allowing iterative refinement without starting over.

mjwolf and others added 2 commits June 19, 2026 14:25
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>
- Pass existingSections (not templateSections) to analyzeModificationScope
  so scope analysis matches against the actual document's section titles
- Check backupOriginalReadme error in ModifyDocumentation, consistent with
  UpdateDocumentation
- Let ScopeAmbiguous flow through parseScopeAnalysisResponse so the user
  warning in applyModificationScope is reachable; low-confidence specific
  scope now becomes ScopeAmbiguous instead of silently falling back to global
- Return ShouldContinue=true on empty text area input in handleRequestChanges
  so the interactive loop re-prompts rather than terminating the session
- Remove unused sections parameter from runInteractiveSectionReview
- Parallelize modifyAllSections and modifySpecificSections with goroutines,
  matching the pattern used by GenerateAllSectionsWithValidation
- Pre-compute affected sections before modification to use an accurate
  denominator in modifySpecificSections progress messages
- Add dedicated SectionList field to PromptContext instead of overloading
  SectionTitle in scope analysis prompt building
- Remove false-positive direction from isSectionAffected fuzzy match
- Replace inline ModificationScope error literals with defaultModificationScope

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mjwolf mjwolf requested review from a team as code owners June 19, 2026 22:26
@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

make check-static is failing on lint issues introduced in internal/llmagent/docagent/modificationanalyzer.go: two staticcheck QF1012 findings and one unparam finding. This is a code cleanup fix, not an infrastructure or flaky-test failure.

Remediation

  • In internal/llmagent/docagent/modificationanalyzer.go, replace both sectionsBuilder.WriteString(fmt.Sprintf(...)) calls with fmt.Fprintf(&sectionsBuilder, ...).
  • Make analyzeModificationScope return only *ModificationScope because every path currently returns a nil error, then update the two call sites in internal/llmagent/docagent/docagent.go to stop checking an impossible error.
  • Re-run make check-static after the cleanup.
Investigation details

Root Cause

The failed job is :go: Run check-static, running make check-static, and golangci-lint reports three deterministic lint failures in PR-added code:

  • internal/llmagent/docagent/modificationanalyzer.go:89 and :94 use sectionsBuilder.WriteString(fmt.Sprintf(...)), which staticcheck flags as QF1012.
  • internal/llmagent/docagent/modificationanalyzer.go:59 declares func (d *DocumentationAgent) analyzeModificationScope(...) (*ModificationScope, error), but the implementation always returns nil for the error. That triggers unparam.

The error result is not needed for the current behavior: modificationanalyzer.go:67-78 logs failures and returns defaultModificationScope(...) with nil, while both call sites already fall back to the same global-scope behavior if an error were possible:

  • internal/llmagent/docagent/docagent.go:366-370
  • internal/llmagent/docagent/docagent.go:625-629

So the behavior-preserving fix is to remove the error return from analyzeModificationScope and simplify those call sites.

Evidence

internal/llmagent/docagent/modificationanalyzer.go:89:3: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
internal/llmagent/docagent/modificationanalyzer.go:94:4: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
internal/llmagent/docagent/modificationanalyzer.go:59:153: (*DocumentationAgent).analyzeModificationScope - result 1 (error) is always nil (unparam)
3 issues:
* staticcheck: 2
* unparam: 1
make: *** [Makefile:42: lint] Error 1

Verification

Not run locally; this detective pass inspected the failing Buildkite log and PR-head source. The recommended validation is make check-static.


What is this? | From workflow: PR Buildkite Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

mjwolf and others added 2 commits June 22, 2026 15:02
- Replace WriteString(fmt.Sprintf(...)) with fmt.Fprintf() (QF1012)
- Remove always-nil error return from analyzeModificationScope (unparam)
- Update call sites in docagent.go to match new signature

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@jsoriano jsoriano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in cmd LGTM.

@vinit-chauhan vinit-chauhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mjwolf mjwolf requested a review from a team July 2, 2026 15:01
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

Change the default LLM model to gemini-3.5-flash, as the
gemini-3-flash-preview model is deprecated.
@mjwolf mjwolf enabled auto-merge (squash) July 6, 2026 18:35

@mrodm mrodm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes related to cmd LGTM 👍

@mjwolf mjwolf merged commit dd83883 into elastic:main Jul 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants