You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-11Lines changed: 45 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,25 @@
1
1
# Library Insight 🔍
2
2
3
-
Library Insight is a command-line tool that analyzes Java and Kotlin libraries (JAR/AAR) to inspect, extract, and index their complete public API surface from compiled bytecode and Kotlin metadata.
3
+
AI coding assistants often guess Java/Kotlin library APIs from old docs, latest web examples, or a different version than the one installed in your project. That leads to missing methods, deprecated usage, wrong signatures, and wasted debugging time.
4
4
5
-
Instead of requiring source code, the tool reads compiled `.class` structures (using ASM) and `@Metadata` annotations (using `kotlin-metadata-jvm`) to construct an accurate public API index.
5
+
Library Insight fixes that by scanning the exact JAR/AAR, Gradle output, or Maven version you use. It reads compiled `.class` structures (using ASM) and Kotlin `@Metadata` annotations (using `kotlin-metadata-jvm`) to build a searchable, version-correct public API index.
6
6
7
-
This is incredibly useful for:
7
+
Use it when you need to:
8
8
9
-
- Documentation generation
10
-
- API compatibility verification (checking for breaking changes)
11
-
- IDE extensions and indexing engines
12
-
- Context generators supplying AI assistants with exact signatures
9
+
- Know how to implement a library after adding it to a project.
10
+
- Check which classes, methods, constructors, and properties exist in your installed version.
11
+
- Stop AI from using examples from a newer, older, or undocumented version.
12
+
- Find deprecated APIs and compare versions before rewriting code.
13
+
- Give AI assistants exact signatures without dumping huge documentation files into context.
14
+
15
+
> **Core idea:** AI should code against the library version you actually use, not the version it remembers from the web.
-**Version-Correct API Lookup**: Scans the exact artifact you point it at, so AI agents and developers see the real public API for that dependency version.
When you add a dependency, the first question is simple: "How do I use this version correctly?"
37
+
38
+
In real projects, that answer is often messy:
39
+
40
+
- AI may write code for the latest release while your project uses an older version.
41
+
- AI may copy an old blog post where the method name no longer exists.
42
+
- Official docs may be incomplete or not updated for the release you installed.
43
+
- Deprecated methods may still appear in examples, while the replacement is hidden in release notes or source comments.
44
+
- Huge generated docs waste AI context and make one class hard to find.
45
+
46
+
Library Insight turns the compiled library itself into the source of truth. Scan the dependency, then use `search`, `explain`, `diff`, or `ai-export` to give humans and AI agents exact, version-aware API information.
47
+
48
+
---
49
+
30
50
## Architecture & Modular Design
31
51
32
52
Library Insight follows **Clean Architecture** principles. Below is the modular dependency flow:
@@ -122,7 +142,9 @@ The executable binary will be generated at:
122
142
123
143
## AI Agent Skill Integration
124
144
125
-
Library Insight bundles a Custom AI Agent Skill (`SKILL.md`) that teaches AI assistants (like Claude, Gemini, Cursor, Copilot, Junie, etc.) how to execute scan and query commands automatically.
145
+
Library Insight bundles a Custom AI Agent Skill (`SKILL.md`) that teaches AI assistants (like Claude, Gemini, Cursor, Copilot, Junie, etc.) to verify real dependency APIs before writing code.
146
+
147
+
The skill is designed around one rule: do not guess from web examples when the installed library version can be scanned directly. Agents should use `search`, `explain`, `diff`, and `ai-export` to confirm what exists in the actual artifact.
126
148
127
149
### 1. Global Auto-Integration
128
150
@@ -158,16 +180,22 @@ This creates `.agents/skills/library-insight/SKILL.md` in the project root, enab
158
180
> `library-insight <command> [options]`
159
181
160
182
> [!IMPORTANT]
183
+
> **AI Agent Accuracy Rule:**
184
+
> If you are an AI assistant, do not assume the library API from memory, latest web docs, or random examples. First scan or query the exact library version used by the project whenever possible.
185
+
>
161
186
> **AI Agent Token Optimization Rule:**
162
-
> If you are an AI assistant (such as Cursor, Gemini, Claude, etc.), **DO NOT** read the entire raw `build/library-insight-index.json` or generated `API_REFERENCE.md` files directly using file-viewing tools. Doing so will bloat your context window and exceed token limits.
163
-
> Instead, you **MUST**use the dedicated CLI query subcommands to lookup only the class details or signatures you need:
187
+
> Do **not** read the entire raw `build/library-insight-index.json` or generated `API_REFERENCE.md` files directly using file-viewing tools. Doing so will bloat your context window and exceed token limits.
188
+
> Instead, use the dedicated CLI query subcommands to lookup only the class details or signatures you need:
164
189
> - Use **`library-insight search <query>`** to locate packages or classes.
165
190
> - Use **`library-insight explain <class>`** to inspect full signatures and docs.
191
+
> - Use **`library-insight diff <old> <new>`** before upgrading or replacing deprecated APIs.
166
192
167
193
### 1. Scan Library
168
194
169
195
Scan a JAR, AAR, local directory, or Maven coordinate.
170
196
197
+
Use this first when you need to know how a dependency should be implemented in the exact version your project uses.
198
+
171
199
> [!TIP]
172
200
> **Offline-First & Smart Caching:**
173
201
> -**Gradle Cache Lookup**: Before downloading from repositories over the network, `library-insight` scans your machine's Gradle cache (`~/.gradle/caches/modules-2/files-2.1/`). If the dependency coordinate has already been downloaded by Gradle/Android Studio, it is referenced directly without performing any disk copies—saving space and enabling fully offline scanning!
@@ -194,6 +222,8 @@ Saved API index to: /Users/meet/AndroidStudioProjects/Library-Insight/build/libr
194
222
195
223
Search for packages, classes, methods, or properties in the saved index.
196
224
225
+
Use this when you know part of a class or method name and need to find the matching API in the scanned version.
226
+
197
227
```bash
198
228
# Search for Retrofit class matching patterns
199
229
library-insight search Retrofit
@@ -210,6 +240,8 @@ Found 2 matching classes:
210
240
211
241
Print detailed structural details (modifiers, superclass, constructors, properties, methods, and documentation) about a specific class.
212
242
243
+
Use this before writing code that calls a class, especially when AI examples disagree with your installed dependency version.
244
+
213
245
```bash
214
246
# Get full API structure of Retrofit class
215
247
library-insight explain Retrofit
@@ -244,6 +276,8 @@ Exported MARKDOWN to: /Users/meet/AndroidStudioProjects/Library-Insight/build/AP
244
276
245
277
Compare two library archives directly to check for changes and potential breaking changes.
246
278
279
+
Use this when a method is deprecated, removed, renamed, or behaving differently between versions.
280
+
247
281
```bash
248
282
# Detect breaking changes between Retrofit 2.9.0 and 2.11.0
Generate a compact, token-efficient split context folder structure (`build/ai-context/` by default) containing individual class JSON files optimized for LLM prompts.
272
306
273
-
This solves the problem of massive single files (like `API_REFERENCE.md`) by splitting package namespaces and classes into separate, tiny files. AI agents (Cursor, Claude, Gemini) can read `metadata.json` first, and then load only the specific class JSON files they need, reducing token usage by over 95%.
307
+
This solves two problems at once: AI gets exact APIs from the scanned dependency version, and it avoids massive single files like `API_REFERENCE.md`. Agents can read `metadata.json` first, then load only the specific class JSON files they need, reducing token usage by over 95%.
0 commit comments