-
Notifications
You must be signed in to change notification settings - Fork 1
Add repository agent guidance #47
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
Draft
apstndb
wants to merge
3
commits into
main
Choose a base branch
from
codex/repo-agent-config
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.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| code_review: | ||
| comment_severity_threshold: HIGH |
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,9 @@ | ||
| # Local scratch space for generated artifacts and temporary notes. | ||
| .tmp/ | ||
|
|
||
| # Local editor and OS metadata. | ||
| .DS_Store | ||
| .idea/ | ||
|
|
||
| # Local Go build output. | ||
| spannerplanviz | ||
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,88 @@ | ||
| # AGENTS.md | ||
|
apstndb marked this conversation as resolved.
|
||
|
|
||
| This file provides guidance to AI coding agents when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| spannerplanviz is a Cloud Spanner Query Plan Visualizer that converts Spanner query plans into visual diagrams using Graphviz and Mermaid.js. The tool reads JSON/YAML input containing Spanner query plans and generates visual output in various formats (SVG, PNG, DOT, Mermaid). | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Components | ||
|
|
||
| - **main.go**: Entry point that parses CLI options, reads input, and orchestrates visualization | ||
| - **option/options.go**: Defines CLI flags and options for controlling output format and content | ||
| - **visualize/**: Core visualization logic | ||
| - **visualize.go**: Main rendering coordinator, handles both Graphviz and Mermaid output paths | ||
| - **mermaid.go**: Mermaid.js-specific rendering logic with structured configuration | ||
| - **build_tree.go**: Converts Spanner plan nodes into internal tree structure and defines node formatting logic for HTML and Mermaid labels | ||
| - **util.go**: Utility functions for formatting and text processing | ||
|
|
||
| ### Dependencies | ||
|
|
||
| - **github.com/apstndb/spannerplan**: External library for parsing Spanner query plans | ||
| - **github.com/goccy/go-graphviz**: Graphviz rendering engine | ||
| - **cloud.google.com/go/spanner**: Google Cloud Spanner client library for protobuf definitions | ||
| - **github.com/jessevdk/go-flags**: CLI argument parsing | ||
|
|
||
| ### Input/Output Flow | ||
|
|
||
| 1. Input: JSON/YAML containing QueryPlan, ResultSetStats, or ResultSet from Spanner | ||
| 2. Parse using spannerplan.ExtractQueryPlan() | ||
| 3. Build internal tree structure via buildTree() | ||
| 4. Render output based on --type flag (svg/png/dot/mermaid) | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Testing | ||
|
|
||
| ```bash | ||
| make test | ||
| # Or directly: | ||
| go test -v ./... | ||
|
|
||
| # Test with sample data: | ||
| go run . --type=mermaid --full < visualize/testdata/dca_profile.json | ||
| go run . --type=svg --full --output=test.svg < visualize/testdata/dca_profile.json | ||
| ``` | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| go build -o spannerplanviz . | ||
| ``` | ||
|
|
||
| ### Running | ||
|
|
||
| ```bash | ||
| # Basic usage - reads from stdin, outputs to stdout | ||
| echo '{"queryPlan": {...}}' | go run . --type=svg | ||
|
|
||
| # With file input/output | ||
| go run . --input=plan.json --output=plan.svg --type=svg --full | ||
| ``` | ||
|
|
||
| ### CLI Options | ||
|
|
||
| - `--type`: Output format (svg, png, dot, mermaid) | ||
| - `--full`: Enable all metadata options (execution-stats, metadata, etc.) | ||
| - `--output`: Output file path | ||
| - `--show-query`: Include query text in visualization | ||
| - `--show-query-stats`: Include query statistics | ||
|
|
||
| ### Test Data | ||
|
|
||
| Sample files in `visualize/testdata/` for testing: | ||
|
|
||
| - `dca_profile.json`: Complex distributed cross apply query with profile data | ||
| - `various_characters_profile.json`: Tests special character handling | ||
| - `*.golden.mermaid`: Expected Mermaid output for regression testing | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| - Standard Go formatting with gofmt | ||
| - Follow existing tree node helper methods for node operations, such as GetName(), HTML(), and MermaidLabel() | ||
| - Wrap errors with fmt.Errorf() and %w when preserving the underlying cause | ||
| - Defer cleanup for resources (files, graphviz objects) | ||
| - Use cgraph.EdgeStyle constants for edge styling | ||
| - Mermaid output uses structured JSON configuration for theming | ||
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 @@ | ||
| @AGENTS.md |
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
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.
Uh oh!
There was an error while loading. Please reload this page.