-
Notifications
You must be signed in to change notification settings - Fork 138
Add AI-powered documentation generation (core) #3302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mjwolf
wants to merge
16
commits into
elastic:main
Choose a base branch
from
mjwolf:doc_update_1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ead8b9b
Add AI-powered documentation generation (core)
mjwolf dc0c34b
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf 5a7b34a
Address review feedback
mjwolf 19d1f7b
Expand doc agent validators and style rules
mjwolf f5dea86
Reorganize prompt and style rule layout for clarity
mjwolf b087fbd
Correct doc template to fix unit tests
mjwolf 9ddc332
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf d4b7386
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf 35893aa
Move style prompts into embedded files
mjwolf 163af39
Add check for private address space to urlvalidator
mjwolf b02c52c
Use structs for promptBuilder return values
mjwolf 39fe93b
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf cacdf96
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf e26efe0
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf eb9d93c
Update codeowners
mjwolf 9334bc0
Merge remote-tracking branch 'upstream/main' into doc_update_1
mjwolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,3 +37,7 @@ new_package | |
|
|
||
| # default output directory for dump commands | ||
| package-dump | ||
|
|
||
| .cursor/ | ||
|
|
||
| batch_results/ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -389,7 +389,7 @@ This command combines query capabilities with command execution, allowing you to | |
| The command uses the same query flags as the 'find' command to select packages, then executes the specified subcommand for each matched package. | ||
|
|
||
| Allowed subcommands: | ||
| build, check, changelog, clean, format, install, lint, test, uninstall | ||
| build, check, changelog, clean, format, install, lint, test, uninstall, update | ||
|
|
||
| ### `elastic-package format` | ||
|
|
||
|
|
@@ -702,6 +702,30 @@ Use this command to uninstall the package in Kibana. | |
|
|
||
| The command uses Kibana API to uninstall the package in Kibana. The package must be exposed via the Package Registry. | ||
|
|
||
| ### `elastic-package update` | ||
|
|
||
| _Context: package_ | ||
|
|
||
| Use this command to update package resources. | ||
|
|
||
| The command can help update existing resources in a package. Currently only documentation is supported. | ||
|
|
||
| ### `elastic-package update documentation` | ||
|
|
||
| _Context: package_ | ||
|
|
||
| Use this command to update package documentation using an AI agent or to get manual instructions for update. | ||
|
|
||
| The AI agent analyzes your package structure, data streams, and configuration, and generates a new documentation file based on the template and the package context. | ||
|
|
||
| For packages with multiple documentation files, use the --doc-file flag to specify the file to update (defaults to README.md). | ||
|
|
||
| If no LLM provider is configured, this command will print instructions for updating the documentation manually. | ||
|
|
||
| Configuration options for LLM providers (environment variables or profile config): | ||
| - LLM_PROVIDER / llm.provider: Provider name (only Gemini provider currently supported). | ||
| - Gemini: GOOGLE_API_KEY / llm.gemini.api_key, GEMINI_MODEL / llm.gemini.model, GEMINI_THINKING_BUDGET / llm.gemini.thinking_budget. | ||
|
|
||
| ### `elastic-package version` | ||
|
|
||
| _Context: global_ | ||
|
|
@@ -796,6 +820,97 @@ The following settings are available per profile: | |
| * `stack.fleet_auto_install_task_interval` sets the interval for the Fleet auto-install content packages task. | ||
| Supported in Kibana 9.2 and later. Defaults to "10m". | ||
|
|
||
| ### AI-powered Documentation Configuration | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving this section to a file under |
||
|
|
||
| The `elastic-package update documentation` command can generate or update package documentation using an LLM. For detailed usage, flags, and configuration (including LLM provider setup), run: | ||
|
|
||
| ```bash | ||
| elastic-package update documentation --help | ||
| ``` | ||
|
|
||
| **⚠️ IMPORTANT PRIVACY NOTICE:** | ||
| When using AI-powered documentation generation, **file content from your local file system within the package directory may be sent to the configured LLM provider**. This includes manifest files, configuration files, field definitions, and other package content. The generated documentation **must be reviewed for accuracy and correctness** before being finalized, as LLMs may occasionally produce incorrect or hallucinated information. | ||
|
|
||
| #### Service knowledge base (service_info.md) | ||
|
|
||
| To give the AI authoritative information about your integration, add a knowledge base file at **`docs/knowledge_base/service_info.md`** in your package. The generator treats this as the primary source and uses it to produce more accurate, vendor-specific documentation. By using this file, you will be better able to control the content of the generated documentation, and reduce the risk of hallucinations or incorrect information. When the documentation is updated in the future, you can rely on this file to ensure the documentation is accurate, and reduce the risk of unintentionally semantic changes being made along with your intended changes. | ||
|
|
||
| - **Structure:** Use the structure template below. The section names in the knowledge base file are for organizing content for the LLM; they do not dictate the structure of the generated README. | ||
| - **Content:** Use specific, complete sentences. Include vendor documentation URLs and any known limitations or edge cases. Keep the file updated as the service or integration changes. The semantic information in the knowledge base file is used as information in the documentation. The style and format of the knowledge base file is not copied into the output. | ||
| - **Effect:** The agent reads this file first, prioritizes it over other sources, and uses it to fill the corresponding parts of the generated docs. The format of `service_info.md` is not copied into the output. | ||
|
|
||
| ##### Optional template reference | ||
|
|
||
| The following is an optional reference for structuring `service_info.md`. Section titles are only to categorize information for the LLM; they do not control the format of the generated README. | ||
|
|
||
| ```markdown | ||
| # Service Info | ||
|
|
||
| ## Common use cases | ||
|
|
||
| /* Common use cases that this will facilitate */ | ||
|
|
||
| ## Data types collected | ||
|
|
||
| /* What types of data this integration can collect */ | ||
|
|
||
| ## Compatibility | ||
|
|
||
| /* Information on the vendor versions this integration is compatible with or has been tested against */ | ||
|
|
||
| ## Scaling and Performance | ||
|
|
||
| /* Vendor-specific information on what performance can be expected, how to set up scaling, etc. */ | ||
|
|
||
| # Set Up Instructions | ||
|
|
||
| ## Vendor prerequisites | ||
|
|
||
| /* Add any vendor specific prerequisites, e.g. "an API key with permission to access <X, Y, Z> is required" */ | ||
|
|
||
| ## Elastic prerequisites | ||
|
|
||
| /* If there are any Elastic specific prerequisites, add them here | ||
|
|
||
| The stack version and agentless support is not needed, as this can be taken from the manifest */ | ||
|
|
||
| ## Vendor set up steps | ||
|
|
||
| /* List the specific steps that are needed in the vendor system to send data to Elastic. | ||
|
|
||
| If multiple input types are supported, add instructions for each in a subsection */ | ||
|
|
||
| ## Kibana set up steps | ||
|
|
||
| /* List the specific steps that are needed in Kibana to add and configure the integration to begin ingesting data */ | ||
|
|
||
| # Validation Steps | ||
|
|
||
| /* List the steps that are needed to validate the integration is working, after ingestion has started. | ||
|
|
||
| This may include steps on the vendor system to trigger data flow, and steps on how to check the data is correct in Kibana dashboards or alerts. */ | ||
|
|
||
| # Troubleshooting | ||
|
|
||
| /* Add lists of "*Issue* / *Solutions*" for troubleshooting knowledge base into the most appropriate section below */ | ||
|
|
||
| ## Common Configuration Issues | ||
|
|
||
| /* For generic problems such as "service failed to start" or "no data collected" */ | ||
|
|
||
| ## Ingestion Errors | ||
|
|
||
| /* For problems that involve "error.message" being set on ingested data */ | ||
|
|
||
| ## API Authentication Errors | ||
|
|
||
| /* For API authentication failures, credential errors, and similar */ | ||
|
|
||
| # Documentation sites | ||
|
|
||
| /* List of URLs that contain info on the service (reference pages, set up help, API docs, etc.) */ | ||
| ``` | ||
|
|
||
| ## Useful environment variables | ||
|
|
||
| There are available some environment variables that could be used to change some of the | ||
|
|
@@ -853,6 +968,10 @@ There are available some environment variables that could be used to change some | |
| - `ELASTIC_PACKAGE_ESMETRICSTORE_PASSWORD`: Password for the user. | ||
| - `ELASTIC_PACKAGE_ESMETRICSTORE_CA_CERT`: Path to the CA certificate to connect to the Elastic stack services. | ||
|
|
||
| - To configure LLM providers for AI-powered documentation generation (`elastic-package update documentation`): | ||
| - `LLM_PROVIDER` / **llm.provider**: Provider name. Gemini is the default provider. | ||
| - Gemini: `GOOGLE_API_KEY` / **llm.gemini.api_key**, `GEMINI_MODEL` / **llm.gemini.model**, `GEMINI_THINKING_BUDGET` / **llm.gemini.thinking_budget**. | ||
|
|
||
|
|
||
| ## Release process | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ func getAllowedSubCommands() []string { | |
| "lint", | ||
| "test", | ||
| "uninstall", | ||
| "update", | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License; | ||
| // you may not use this file except in compliance with the Elastic License. | ||
|
|
||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/elastic/elastic-package/internal/cobraext" | ||
| "github.com/elastic/elastic-package/internal/install" | ||
| ) | ||
|
|
||
| const updateLongDescription = `Use this command to update package resources. | ||
|
|
||
| The command can help update existing resources in a package. Currently only documentation is supported.` | ||
|
|
||
| func setupUpdateCommand() *cobraext.Command { | ||
| updateDocumentationCmd := &cobra.Command{ | ||
| Use: "documentation", | ||
| Short: "Update package documentation", | ||
| Long: updateDocumentationLongDescription, | ||
| Args: cobra.NoArgs, | ||
| RunE: updateDocumentationCommandAction, | ||
| } | ||
| updateDocumentationCmd.Flags().String("doc-file", "", "specify which markdown file to update (e.g., README.md, vpc.md). Defaults to README.md") | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "update", | ||
| Short: "Update package resources", | ||
| Long: updateLongDescription, | ||
| } | ||
| cmd.AddCommand(updateDocumentationCmd) | ||
| cmd.PersistentFlags().StringP(cobraext.ProfileFlagName, "p", "", fmt.Sprintf(cobraext.ProfileFlagDescription, install.ProfileNameEnvVar)) | ||
|
|
||
| return cobraext.NewCommand(cmd, cobraext.ContextPackage) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍