@skroyc/librarian 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/LICENSE +210 -0
  3. package/README.md +614 -0
  4. package/biome.jsonc +9 -0
  5. package/dist/agents/context-schema.d.ts +17 -0
  6. package/dist/agents/context-schema.d.ts.map +1 -0
  7. package/dist/agents/context-schema.js +16 -0
  8. package/dist/agents/context-schema.js.map +1 -0
  9. package/dist/agents/react-agent.d.ts +38 -0
  10. package/dist/agents/react-agent.d.ts.map +1 -0
  11. package/dist/agents/react-agent.js +719 -0
  12. package/dist/agents/react-agent.js.map +1 -0
  13. package/dist/agents/tool-runtime.d.ts +7 -0
  14. package/dist/agents/tool-runtime.d.ts.map +1 -0
  15. package/dist/agents/tool-runtime.js +2 -0
  16. package/dist/agents/tool-runtime.js.map +1 -0
  17. package/dist/cli.d.ts +4 -0
  18. package/dist/cli.d.ts.map +1 -0
  19. package/dist/cli.js +172 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/config.d.ts +4 -0
  22. package/dist/config.d.ts.map +1 -0
  23. package/dist/config.js +243 -0
  24. package/dist/config.js.map +1 -0
  25. package/dist/index.d.ts +41 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +470 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/tools/file-finding.tool.d.ts +24 -0
  30. package/dist/tools/file-finding.tool.d.ts.map +1 -0
  31. package/dist/tools/file-finding.tool.js +198 -0
  32. package/dist/tools/file-finding.tool.js.map +1 -0
  33. package/dist/tools/file-listing.tool.d.ts +12 -0
  34. package/dist/tools/file-listing.tool.d.ts.map +1 -0
  35. package/dist/tools/file-listing.tool.js +132 -0
  36. package/dist/tools/file-listing.tool.js.map +1 -0
  37. package/dist/tools/file-reading.tool.d.ts +9 -0
  38. package/dist/tools/file-reading.tool.d.ts.map +1 -0
  39. package/dist/tools/file-reading.tool.js +112 -0
  40. package/dist/tools/file-reading.tool.js.map +1 -0
  41. package/dist/tools/grep-content.tool.d.ts +27 -0
  42. package/dist/tools/grep-content.tool.d.ts.map +1 -0
  43. package/dist/tools/grep-content.tool.js +229 -0
  44. package/dist/tools/grep-content.tool.js.map +1 -0
  45. package/dist/utils/file-utils.d.ts +2 -0
  46. package/dist/utils/file-utils.d.ts.map +1 -0
  47. package/dist/utils/file-utils.js +28 -0
  48. package/dist/utils/file-utils.js.map +1 -0
  49. package/dist/utils/logger.d.ts +32 -0
  50. package/dist/utils/logger.d.ts.map +1 -0
  51. package/dist/utils/logger.js +177 -0
  52. package/dist/utils/logger.js.map +1 -0
  53. package/dist/utils/path-utils.d.ts +2 -0
  54. package/dist/utils/path-utils.d.ts.map +1 -0
  55. package/dist/utils/path-utils.js +9 -0
  56. package/dist/utils/path-utils.js.map +1 -0
  57. package/package.json +84 -0
  58. package/src/agents/context-schema.ts +61 -0
  59. package/src/agents/react-agent.ts +928 -0
  60. package/src/agents/tool-runtime.ts +21 -0
  61. package/src/cli.ts +206 -0
  62. package/src/config.ts +309 -0
  63. package/src/index.ts +628 -0
  64. package/src/tools/file-finding.tool.ts +324 -0
  65. package/src/tools/file-listing.tool.ts +212 -0
  66. package/src/tools/file-reading.tool.ts +154 -0
  67. package/src/tools/grep-content.tool.ts +325 -0
  68. package/src/utils/file-utils.ts +39 -0
  69. package/src/utils/logger.ts +295 -0
  70. package/src/utils/path-utils.ts +17 -0
  71. package/tsconfig.json +37 -0
  72. package/tsconfig.test.json +17 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,176 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-01-15
9
+
10
+ ### Added
11
+
12
+ - **Core CLI Functionality**
13
+ - Initial CLI implementation with Commander.js for command parsing
14
+ - `explore` command for technology research with support for `--tech` and `--group` options
15
+ - `list` command to display available technologies with filtering by group
16
+ - Comprehensive help system with `-h` and `--help` flags
17
+
18
+ - **Agent System**
19
+ - LangChain-powered ReAct agent implementation for intelligent codebase exploration
20
+ - Dynamic system prompt construction based on selected technology/group context
21
+ - Sandboxed tool execution within isolated working directories
22
+ - Memory management using LangGraph with MemorySaver checkpointing
23
+
24
+ - **Repository Management**
25
+ - Auto-clone repositories from Git before each query
26
+ - Auto-update repositories with git pull before exploration
27
+ - Branch support with automatic fallback to main/master
28
+ - Organized storage structure: `{repos_path}/{group}/{technology}`
29
+
30
+ - **Tool Suite**
31
+ - `File Listing Tool`: List files and directories within sandboxed working directory
32
+ - `File Reading Tool`: Read file contents with support for various file types
33
+ - `Grep Search Tool`: Search file contents using regex patterns
34
+ - `Glob Search Tool`: Find files by name patterns using glob syntax
35
+
36
+ - **LLM Provider Support**
37
+ - Unified model abstraction through LangChain's `initChatModel`
38
+ - OpenAI integration via `@langchain/openai`
39
+ - Anthropic integration via `@langchain/anthropic`
40
+ - Google GenAI integration via `@langchain/google-genai`
41
+ - OpenAI-compatible provider support
42
+ - Anthropic-compatible provider support
43
+ - CLI-based providers: Claude Code and Gemini CLI
44
+ - Built-in OpenCode Zen integration (no API key required by default)
45
+
46
+ - **Configuration System**
47
+ - YAML-based configuration file support
48
+ - Configuration validation using Zod schemas
49
+ - Environment variable support via `.env` files
50
+ - Path expansion and normalization
51
+ - Backward compatibility with legacy configuration keys
52
+
53
+ - **Security Features**
54
+ - Path validation preventing directory traversal attacks
55
+ - Sandboxed working directory isolation for all tools
56
+ - Absolute path validation to prevent escape attempts
57
+ - Security verification script for testing sandboxing
58
+
59
+ - **Logging System**
60
+ - Comprehensive logging with timestamped log files
61
+ - Sensitive information redaction (API keys, paths, URLs)
62
+ - Multiple log levels: INFO, DEBUG, WARN, ERROR
63
+ - Performance timing measurements
64
+ - Silent file logging with no impact on stdout
65
+
66
+ ### Changed
67
+
68
+ - **Architecture**
69
+ - Modular structure separating CLI, core logic, agents, tools, and utilities
70
+ - TypeScript-first development with strict type checking
71
+ - ES module system with proper exports configuration
72
+ - Source map generation for better debugging experience
73
+
74
+ ### Dependencies
75
+
76
+ - **Core Runtime**
77
+ - `commander`: ^14.0.2 (CLI argument parsing)
78
+ - `yaml`: ^2.8.2 (Configuration parsing)
79
+ - `isomorphic-git`: ^1.36.1 (Git operations)
80
+ - `zod`: ^4.2.1 (Runtime validation)
81
+
82
+ - **Agent Framework**
83
+ - `langchain`: ^1.2.2 (Core LangChain framework)
84
+ - `@langchain/langgraph`: ^1.0.7 (State management)
85
+ - `@langchain/openai`: ^1.2.0 (OpenAI integration)
86
+ - `@langchain/anthropic`: ^1.3.2 (Anthropic integration)
87
+ - `@langchain/google-genai`: ^2.1.2 (Google integration)
88
+
89
+ - **Development Tools**
90
+ - `typescript`: ^5.9.3
91
+ - `@biomejs/biome`: ^2.3.11
92
+ - `eslint`: ^9.39.2
93
+
94
+ ### Features by Category
95
+
96
+ #### Repository Management
97
+ - Auto-clone repositories on first access
98
+ - Auto-update before each query
99
+ - Custom repository path configuration
100
+ - Branch specification support
101
+ - Organized group/technology hierarchy
102
+
103
+ #### Agent Capabilities
104
+ - Intelligent codebase exploration
105
+ - Context-aware prompts
106
+ - Streaming responses
107
+ - Memory persistence across sessions
108
+ - Tool execution sandboxing
109
+
110
+ #### CLI Experience
111
+ - Interactive command parsing
112
+ - Colored output support
113
+ - Error handling with appropriate exit codes
114
+ - Configuration validation feedback
115
+ - Help text generation
116
+
117
+ #### Multi-Provider Support
118
+ - Zero-configuration OpenCode Zen integration
119
+ - OpenAI API key support
120
+ - Anthropic API key support
121
+ - Google API key support
122
+ - Custom OpenAI-compatible endpoints
123
+ - Claude CLI integration
124
+ - Gemini CLI integration
125
+
126
+ ### Security
127
+
128
+ - Input validation on all configuration parameters
129
+ - Path traversal prevention
130
+ - Sandboxed file system access
131
+ - API key protection through environment variables
132
+ - Comprehensive logging without sensitive data exposure
133
+
134
+ ### Installation Methods
135
+
136
+ - **NPM**: `@skroyc/librarian`
137
+ - **Bun**: `@skroyc/librarian`
138
+ - **Nix**: `nix run github:SkrOYC/librarian`
139
+ - **Source**: Manual build from GitHub repository
140
+
141
+ ### System Requirements
142
+
143
+ - **Node.js**: >= 18.0.0
144
+ - **Bun**: >= 1.0.0
145
+ - **Git**: Any recent version with HTTPS/SSH support
146
+ - **Platform**: Cross-platform (Linux, macOS, Windows with WSL)
147
+
148
+ ### Known Limitations
149
+
150
+ - Initial release (v0.1.0) - first public version
151
+ - Limited to Git-based repositories
152
+ - Requires network access for repository cloning
153
+ - LLM API calls require internet connectivity (except OpenCode Zen)
154
+
155
+ ### Roadmap
156
+
157
+ Future versions will include:
158
+ - Support for other VCS systems (Mercurial, Subversion)
159
+ - Local caching optimization
160
+ - Additional LLM providers
161
+ - Plugin system for custom tools
162
+ - Web-based dashboard for configuration management
163
+ - Batch processing capabilities
164
+ - Export formats for research results
165
+
166
+ ### Contributing
167
+
168
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
169
+
170
+ ### License
171
+
172
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
173
+
174
+ ---
175
+
176
+ **Full Changelog**: https://github.com/SkrOYC/librarian/compare/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,210 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which
42
+ the editorial revisions, annotations, elaborations, or other
43
+ modifications represent, as a whole, an original work of
44
+ authorship. For the purposes of this License, Derivative Works
45
+ shall not include works that remain separable from, or merely
46
+ link (or bind by name) to the interfaces of, the Work and
47
+ Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including the
50
+ original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the
53
+ copyright owner or by an individual or Legal Entity authorized
54
+ to submit on behalf of the copyright owner. For the purposes of
55
+ this definition, "submitted" means any form of electronic,
56
+ verbal, or written communication sent to the Licensor or its
57
+ representatives, including but not limited to communication on
58
+ electronic mailing lists, source code control systems, and issue
59
+ tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work,
61
+ but excluding communication that is conspicuously marked or
62
+ otherwise designated in writing by the copyright owner as "Not
63
+ a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal
66
+ Entity on behalf of whom a Contribution has been received by
67
+ Licensor and subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions
70
+ of this License, each Contributor hereby grants to You a
71
+ perpetual, worldwide, non-exclusive, no-charge, royalty-free,
72
+ irrevocable copyright license to reproduce, prepare Derivative
73
+ Works of, publicly display, publicly perform, sublicense, and
74
+ distribute the Work and such Derivative Works in Source or
75
+ Object form.
76
+
77
+ 3. Grant of Patent License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ (except as stated in this section) patent license to make, have
81
+ made, use, offer to sell, sell, import, and otherwise transfer
82
+ the Work, where such license applies only to those patent claims
83
+ licensable by such Contributor that are necessarily infringed
84
+ by their Contribution(s) alone or by combination of their
85
+ Contribution(s) with the Work to which such Contribution(s) was
86
+ submitted. If You institute patent litigation against any entity
87
+ (including a cross-claim or counterclaim in a lawsuit) alleging
88
+ that the Work or a Contribution incorporated within the Work
89
+ constitutes direct or contributory patent infringement, then any
90
+ patent licenses granted to You under this License for that Work
91
+ shall terminate as of the date such litigation is filed.
92
+
93
+ 4. Redistribution. You may reproduce and distribute copies of the
94
+ Work or Derivative Works thereof in any medium, with or without
95
+ modifications, and in Source or Object form, provided that You
96
+ meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or
99
+ Derivative Works a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works
105
+ that You distribute, all copyright, patent, trademark, and
106
+ attribution notices from the Source form of the Work,
107
+ excluding those notices that do not pertain to any part of
108
+ the Derivative Works; and
109
+
110
+ (d) If the Work includes a "NOTICE" text file as part of its
111
+ distribution, then any Derivative Works that You distribute
112
+ must include a readable copy of the attribution notices
113
+ contained within such NOTICE file, excluding those notices
114
+ that do not pertain to any part of the Derivative Works, in
115
+ at least one of the following places: within a NOTICE text
116
+ file distributed as part of the Derivative Works; within the
117
+ Source form or documentation, if provided along with the
118
+ Derivative Works; or, within a display generated by the
119
+ Derivative Works, if and wherever such third-party notices
120
+ normally appear. The contents of the NOTICE file are for
121
+ informational purposes only and do not modify the License.
122
+ You may add Your own attribution notices within Derivative
123
+ Works that You distribute, alongside or as an addendum to
124
+ the NOTICE text from the Work, provided that such additional
125
+ attribution notices cannot be construed as modifying the
126
+ License.
127
+
128
+ You may add Your own copyright statement to Your modifications
129
+ and may provide additional or different license terms and
130
+ conditions for use, reproduction, or distribution of Your
131
+ modifications, or for any such Derivative Works as a whole,
132
+ provided Your use, reproduction, and distribution of the Work
133
+ otherwise complies with the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state
136
+ otherwise, any Contribution intentionally submitted for inclusion
137
+ in the Work by You to the Licensor shall be under the terms and
138
+ conditions of this License, without any additional terms or
139
+ conditions. Notwithstanding the above, nothing herein shall
140
+ supersede or modify the terms of any separate license agreement
141
+ you may have executed with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the
144
+ trade names, trademarks, service marks, or product names of the
145
+ Licensor, except as required for reasonable and customary use in
146
+ describing the origin of the Work and reproducing the content of
147
+ the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or
154
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
155
+ FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible
156
+ for determining the appropriateness of using or redistributing
157
+ the Work and assume any risks associated with Your exercise of
158
+ permissions under this License.
159
+
160
+ 8. Limitation of Liability. In no event and under no legal theory,
161
+ whether in tort (including negligence), contract, or otherwise,
162
+ unless required by applicable law (such as deliberate and
163
+ grossly negligent acts) or agreed to in writing, shall any
164
+ Contributor be liable to You for damages, including any direct,
165
+ indirect, special, incidental, or consequential damages of any
166
+ character arising as a result of this License or out of the use
167
+ or inability to use the Work (including but not limited to
168
+ damages for loss of goodwill, work stoppage, computer failure or
169
+ malfunction, or any and all other commercial damages or losses),
170
+ even if such Contributor has been advised of the possibility of
171
+ such damages.
172
+
173
+ 9. Accepting Warranty or Additional Liability. While redistributing
174
+ the Work or Derivative Works thereof, You may choose to offer,
175
+ and charge a fee for, acceptance of support, warranty, indemnity,
176
+ or other liability obligations and/or rights consistent with
177
+ this License. However, in accepting such obligations, You may
178
+ act only on Your own behalf and on Your sole responsibility,
179
+ not on behalf of any other Contributor, and only if You agree
180
+ to indemnify, defend, and hold each Contributor harmless for
181
+ any liability incurred by, or claims asserted against, such
182
+ Contributor by reason of your accepting any such warranty or
183
+ additional liability.
184
+
185
+ END OF TERMS AND CONDITIONS
186
+
187
+ APPENDIX: How to apply the Apache License to your work.
188
+
189
+ To apply the Apache License to your work, attach the following
190
+ boilerplate notice, with the fields enclosed by brackets "[]"
191
+ replaced with your own identifying information. (Don't include
192
+ the brackets!) The text should be enclosed in the appropriate
193
+ comment syntax for the file format. We also recommend that a
194
+ file or class name and description of purpose be included on the
195
+ same "printed page" as the copyright notice for easier
196
+ identification within third-party archives.
197
+
198
+ Copyright [2026] [SkrOYC]
199
+
200
+ Licensed under the Apache License, Version 2.0 (the "License");
201
+ you may not use this file except in compliance with the License.
202
+ You may obtain a copy of the License at
203
+
204
+ http://www.apache.org/licenses/LICENSE-2.0
205
+
206
+ Unless required by applicable law or agreed to in writing, software
207
+ distributed under the License is distributed on an "AS IS" BASIS,
208
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
209
+ implied. See the License for the specific language governing
210
+ permissions and limitations under the License.