Skip to content
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

i/prompting: render path patterns variants using recursive descent parser #14059

Merged

Commits on Jun 18, 2024

  1. i/prompting: implement path pattern expansion

    Path patterns may include arbitrary nested groups, delimited by '{' and
    '}', up to a limit on the total number of groups. In order to compare
    the precedence of path patterns which match a given path, these path
    patterns must be expanded until no groups remain, and thus the
    particular group-free patterns which was resolved from the original
    patterns when matching the path can be compared.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    52d7978 View commit details
    Browse the repository at this point in the history
  2. i/prompting: add PathPattern type for pattern validation and expansion

    Rather than separately validate and expand path patterns, storing the
    result as a list of expanded patterns, parse a pattern into a
    PathPattern type, which can dynamically render expanded path patterns as
    needed with minimal overhead.
    
    When path patterns are received from prompting clients, path patterns
    can be unmarshalled and automatically validated, and any future use of
    the pattern in-memory can use the pre-parsed PathPattern to iterate
    through expanded path patterns without needing to explicitly expand and
    store all path patterns.
    
    Additionally, the new PathPattern type should be used in Constraints in
    place of the old path pattern string.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    d88824e View commit details
    Browse the repository at this point in the history
  3. i/prompting: refactor path pattern parsing

    Rather than keep separate stacks for the sequences and paths which the
    parser is currently inside, instead keep a single stack, to which the
    existing sequence and a new group is added whenever a '{' rune is
    encountered.
    
    Then there is no need to no need for a variable to hold the current
    group, peeking the stack yields the most recent group, to which the
    current sequence can be added whenever a ',' or '}' is encountered.
    
    When a '}' is encountered, the most recent group is popped off the
    stack, the current sequence is added to it (completing the group), and
    then the previous sequence is popped off the stack and the completed
    group is added to it. From there, that previous sequence is now
    considered the current sequence until another '{' is encountered.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    9103d89 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b3a1890 View commit details
    Browse the repository at this point in the history
  5. i/prompting: improve error message prefixes

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    e07b2f8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a234c82 View commit details
    Browse the repository at this point in the history
  7. i/prompting/patterns: add scanner, parser, and renderer for path patt…

    …erns
    
    Co-authored-by: Oliver Calder <[email protected]>
    Signed-off-by: Oliver Calder <[email protected]>
    zyga and olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    aceda6d View commit details
    Browse the repository at this point in the history
  8. i/prompting/patterns: add minimal tests for scan and render

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    cc11b65 View commit details
    Browse the repository at this point in the history
  9. i/prompting/patterns: replace parser in path pattern struct

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    66bdfb3 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8fbe448 View commit details
    Browse the repository at this point in the history
  11. i/prompting/patterns: adjusted error messages

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    0c932d4 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    19ba21e View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    ae6c7ab View commit details
    Browse the repository at this point in the history
  14. i/prompting: fix formatting

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    9199760 View commit details
    Browse the repository at this point in the history
  15. i/prompting/patterns: add helper for converting read runes into text …

    …token
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    737b4b8 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    8322440 View commit details
    Browse the repository at this point in the history
  17. i/prompting/patterns: only re-render differences from previous config…

    …uration
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    1aa4d14 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    8de2450 View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2024

  1. Configuration menu
    Copy the full SHA
    7e6d97d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8119d73 View commit details
    Browse the repository at this point in the history
  3. i/prompting/patterns: rename renderConfig to variantState

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 20, 2024
    Configuration menu
    Copy the full SHA
    d17875b View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2024

  1. i/prompting/patterns: unexported internal renderAllVariants

    Also improved naming and documentation.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    048b233 View commit details
    Browse the repository at this point in the history
  2. i/prompting/patterns: renamed local variables to match new variantSta…

    …te naming
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    8f581fe View commit details
    Browse the repository at this point in the history
  3. i/prompting/patterns: variantState has Render method and renderNode

    Add a reference to the `renderNode` used to generate a given
    `variantState` to that state itself. This allows methods on
    `variantState` to be called without needing to pass as a parameter the
    same `renderNode` which was used to generate the `variantState`.
    
    Also, move the `Render` function to be a method on `variantState`
    instead of `renderNode`. This makes sense semantically, since we render
    particular variants, rather than nodes themselves, and makes sense
    ergonomically since we now have a reference to the `renderNode` within
    each `variantState`, so there is no need to pass parameters around for
    nodes and variants which are required to be associated anyway.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    3460f58 View commit details
    Browse the repository at this point in the history
  4. i/prompting/patterns: consolidate optimize and fix nodeEqual

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    b0736f3 View commit details
    Browse the repository at this point in the history
  5. i/prompting/patterns: add tests for tokenType.String

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    433e0e9 View commit details
    Browse the repository at this point in the history
  6. i/prompting/patterns: use dedicated flag to tell when all seq variant…

    …s are exhausted
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    ec1f272 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2024

  1. i/prompting/patterns: use ..._internal_test.go for non-exported test …

    …files
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 24, 2024
    Configuration menu
    Copy the full SHA
    07dea08 View commit details
    Browse the repository at this point in the history

Commits on Jun 25, 2024

  1. Configuration menu
    Copy the full SHA
    88cf44a View commit details
    Browse the repository at this point in the history
  2. i/prompting/patterns: merge literalVariant into literal

    Add comment as such to the `literal` type definition, and have
    `literal.NextVariant` return length 0 to make it consistent with other
    `variantState` types.
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 25, 2024
    Configuration menu
    Copy the full SHA
    7fbec1d View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2024

  1. Configuration menu
    Copy the full SHA
    9b8b2f3 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2024

  1. i/prompting/patterns: improve error handling

    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 27, 2024
    Configuration menu
    Copy the full SHA
    b8e76bc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    930bc88 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    aa5b886 View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2024

  1. i/prompting/patterns: simplify check if more variants remain when ren…

    …dering
    
    Signed-off-by: Oliver Calder <[email protected]>
    olivercalder committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    49e7d97 View commit details
    Browse the repository at this point in the history