Commit 134c7f1
committed
feat(adk): align filesystem backend Path field behavior with Python glob and ls command
Enhanced the filesystem backend to align Path field behavior with Python glob patterns and standard ls command output.
Also improved documentation for enhanced tool call wrapper methods.
Key Changes:
1. Updated FileInfo.Path field documentation:
- Changed from "absolute path only" to support filename, relative path, or absolute path
- Clarified that Path value depends on the command context (Ls vs Glob)
2. Modified LsInfo implementation:
- Returns only filename/directory name instead of full path
- Uses filepath.Base() for file entries
- Uses parts[0] for immediate children in directory listings
- Behavior now matches standard ls command output
3. Enhanced GlobInfo with Python glob compatibility:
- Replaced custom recursive matching with github.com/bmatcuk/doublestar/v4 library
- Implemented ** (double star) support for recursive directory traversal
- Added absolute pattern detection (patterns starting with /)
- Absolute patterns return absolute paths; relative patterns return relative paths
- Supports ** in any position: beginning, middle, or end of pattern
4. Comprehensive test coverage:
- Added TestInMemoryBackend_LsInfo_PathIsFilename: validates Ls returns filenames only
- Added TestInMemoryBackend_GlobInfo_RelativePath: tests relative/absolute pattern behavior
- Added TestInMemoryBackend_GlobInfo_RecursivePattern: validates ** recursive matching
- Updated existing tests to match new Path field behavior
5. Documentation improvements:
- Added comprehensive documentation for WrapEnhancedInvokableToolCall method
- Added comprehensive documentation for WrapEnhancedStreamableToolCall method
- Documentation follows the same pattern as existing WrapInvokableToolCall and WrapStreamableToolCall methods
Technical Implementation:
- Uses doublestar.Match() for robust glob pattern matching with ** support
- Pattern matching handles complex patterns like "**/*.go", "src/**/*.go"
- Absolute patterns (starting with /) bypass basePath filtering and return full paths
- Relative patterns respect basePath and return paths relative to it
Impact:
- Ls command now returns clean filenames like standard Unix ls
- Glob patterns behave identically to Python glob.glob() with recursive=True
- Supports complex patterns like "**/*.go", "src/**/*.go", and "/absolute/path/**/*.go"
- Enhanced tool wrapper methods are now properly documented for middleware developers1 parent 235a286 commit 134c7f1
File tree
16 files changed
+500
-57
lines changed- adk
- filesystem
- middlewares
- filesystem
- reduction
- components/tool
- utils
- compose
- schema
16 files changed
+500
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
97 | | - | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | | - | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
588 | 590 | | |
589 | 591 | | |
590 | 592 | | |
| 593 | + | |
591 | 594 | | |
592 | 595 | | |
593 | 596 | | |
594 | 597 | | |
595 | 598 | | |
596 | 599 | | |
597 | | - | |
598 | | - | |
599 | | - | |
| 600 | + | |
| 601 | + | |
600 | 602 | | |
601 | | - | |
602 | | - | |
603 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
604 | 606 | | |
605 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
606 | 617 | | |
607 | 618 | | |
608 | | - | |
| 619 | + | |
609 | 620 | | |
610 | 621 | | |
611 | 622 | | |
612 | 623 | | |
613 | 624 | | |
614 | 625 | | |
615 | | - | |
| 626 | + | |
616 | 627 | | |
617 | 628 | | |
618 | 629 | | |
| |||
0 commit comments