Commit c6a47f8
Convert to library: extract core functionality to pkg/codingcontext (#105)
* Initial plan
* Convert to library: move core functionality to pkg/codingcontext
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Add library documentation and usage examples
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Remove os.Chdir call and resolve paths relative to workDir
Instead of changing the current working directory which affects
the entire process and is not thread-safe, the library now resolves
all relative paths based on the workDir parameter.
Updated AllTaskSearchPaths and AllRulePaths to accept a baseDir
parameter and properly join all relative paths with that directory.
This makes the library safe to use in multi-threaded applications
and doesn't have unexpected side effects on the process state.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Reorganize types and make helper functions private
- Moved Context type definition to context.go
- Moved FrontMatter type to new frontmatter.go
- Moved Selectors type definition to selectors.go
- Moved Params type definition to params.go
- Removed types.go (all types now in their respective files)
- Made DownloadRemoteDirectory private (downloadRemoteDirectory)
- Made EstimateTokens private (estimateTokens)
- Updated README to reflect private functions removed from API
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Change API to return Result structure instead of writing to io.Writer
- Created Result type with Rules, Task, TaskFrontmatter, and TotalTokens fields
- Created RuleContent type to represent individual rule files
- Changed Run() to return (*Result, error) instead of error
- Removed WithOutput option - no longer needed
- Updated main.go to handle Result and format output
- Updated all tests to work with new API
- Updated README with new API documentation and examples
This makes the library much more flexible and composable - consumers
can now process the result programmatically instead of just getting
formatted text output.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Convert to library: extract core functionality to pkg/codingcontext
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Remove WithCmdRunner option and TotalTokens field
- Removed WithCmdRunner() function - cmdRunner remains internal for testing
- Removed TotalTokens field from Result struct
- Updated README to remove references to both
These were deemed unnecessary for the public API.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Refactor to use unified Markdown type for rules and task
- Renamed RuleContent to Markdown
- Added FrontMatter field to Markdown type
- Changed Task field in Result from string to Markdown
- Removed TaskFrontmatter field from Result (now in Task.FrontMatter)
- Updated all code, tests, and documentation to use new structure
This provides a more consistent API where both rules and tasks are
represented the same way, including their frontmatter metadata.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Fix deadcode check by adding -test flag for library packages
The deadcode linter was reporting ParseSlashCommand as unreachable
because it's a public API function in a library package. Adding the
-test flag includes test executables as entry points, which properly
recognizes that library functions used in tests are not dead code.
This is the appropriate configuration for a project that provides
library packages (pkg/codingcontext and pkg/slashcommand) with
public APIs intended for external use.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Fix test failure: move task bootstrap execution to main.go
The library was running task bootstrap scripts internally, which caused
the stderr output to appear before stdout content was written by main.go.
This broke the expected ordering in integration tests.
Changes:
- Removed task bootstrap execution from library Run() method
- Added BootstrapPath() method to Markdown type
- main.go now runs task bootstrap between outputting rules and task
- This preserves the correct output order: rule bootstrap, rule content,
task bootstrap, task content
All tests now pass including TestTaskBootstrapWithRuleBootstrap.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>1 parent 6d9fff9 commit c6a47f8
20 files changed
Lines changed: 997 additions & 643 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
848 | | - | |
849 | | - | |
850 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
851 | 860 | | |
852 | 861 | | |
853 | 862 | | |
| |||
0 commit comments