Skip to content

Commit ad5accf

Browse files
authored
Merge pull request #8 from Coding-Meet/release/v1.3.0
Add local source scanning support for version 1.3.0
2 parents 9e0f344 + d6f5576 commit ad5accf

24 files changed

Lines changed: 1630 additions & 190 deletions

File tree

‎.agents/skills/library-insight/SKILL.md‎

Lines changed: 238 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,163 @@
11
---
22
name: library-insight
3-
description: JVM API Explorer & MCP Server that indexes public APIs, visualizes dependency graphs, audits version deprecations, and extracts JVM archive signatures (JAR/AAR) or Maven coordinates for AI context.
3+
description: JVM API Explorer & MCP Server that indexes public APIs from compiled libraries (JAR/AAR) or local Java/Kotlin source code, enabling API exploration, dependency analysis, migration reports, and AI-ready context generation.
44
---
55

66
# Library Insight Agent Skill
77

8-
Use this skill when you need to understand, inspect, or build AI prompts for external JVM libraries (Java/Kotlin JAR or AAR files) or public Maven dependency coordinates.
8+
Use this skill when you need to understand, inspect, or build AI prompts for:
99

10-
This tool extracts all classes, interfaces, methods, properties, and Javadoc/KDoc comments from bytecode and sources, creating an indexed database and a split AI-friendly directory structure.
10+
- External JVM libraries (Java/Kotlin JAR or AAR files)
11+
- Maven Central dependencies
12+
- Local Java or Kotlin source code projects
13+
14+
Library Insight analyzes both compiled JVM libraries and local source code to build a searchable API index. It extracts public APIs, type information, documentation, source metadata, and Kotlin-specific language features, allowing AI agents to work with the exact code being used instead of relying on outdated documentation or web examples.
1115

1216
> [!IMPORTANT]
1317
> **AI Agent Token Optimization Rule:**
14-
> **DO NOT** read the entire `build/library-insight-index.json` or `API_REFERENCE.md` files directly using file-viewing tools. They contain massive raw dumps of the entire library surface which will exhaust your context window.
15-
> Instead, you **MUST** use the CLI query subcommands to interactively look up only the specific information you need:
16-
> - Use **`library-insight search <query>`** to find packages or classes.
17-
> - Use **`library-insight explain <class>`** to print the public API signature and Javadocs of a specific class.
18-
> - Use **`library-insight diff <old> <new>`** to compare versions.
19-
> - Use **`library-insight audit`** to check project dependency API deprecations recursively.
20-
> - Use **`library-insight migrate <old> <new>`** to get a migration advisor report with replacement suggestions.
21-
> - Use **`library-insight search-central <query>`** to search Maven Central.
22-
> - Use **`library-insight dependency-graph <coord>`** to visualize dependency trees.
23-
> - Use **`library-insight semver <old> <new>`** to lint Semantic Versioning API compliance.
24-
> - Use **`library-insight mcp`** to communicate as a Model Context Protocol (MCP) server.
25-
> - Use **`library-insight dsl-report [--package <pkg>]`** to generate a Kotlin DSL surface report (type aliases, `@DslMarker` scopes, extension functions, lambda receivers, reified functions).
26-
> - Use **`library-insight examples <class>`** to generate typical usage code examples from bytecode signatures.
27-
> - Use **`library-insight health`** to generate a Package Health & API Complexity Report.
28-
> - Use **`library-insight dependency-check`** to audit all transitive classpath dependencies for runtime conflicts.
29-
> - Use **`library-insight callgraph <class.method>`** to trace internal library method invocation call graphs recursively.
3018
>
31-
> **MCP Integration Rule:**
32-
> If an MCP server is already configured and available (e.g., in Cursor, Claude Desktop, or another IDE with MCP support), **prefer the MCP server over shelling out to the CLI**. The MCP server exposes `scan_library`, `search_symbols`, and `explain_class` tools natively without subprocess overhead.
19+
> **DO NOT** read the entire `build/library-insight-index.json` or generated `API_REFERENCE.md` files directly using file-viewing tools. These files can be extremely large and will quickly exhaust the available context window.
20+
>
21+
> Instead, interact with the indexed database using the CLI query commands so that only the required symbols are loaded into context.
22+
>
23+
> **Indexing**
24+
>
25+
> - Use **`library-insight scan <jar|aar|directory|maven-coordinate>`** to index compiled JVM libraries.
26+
> - Use **`library-insight scan-source <directory>`** to index a local Java/Kotlin source project without compilation.
27+
>
28+
> **Querying**
29+
>
30+
> - Use **`library-insight search <query>`** to locate packages, classes, methods, or properties.
31+
> - Use **`library-insight explain <class>`** to inspect a class, including signatures, documentation, imports, and source locations when available.
32+
> - Use **`library-insight examples <class>`** to generate typical usage examples.
33+
>
34+
> **Analysis**
35+
>
36+
> - Use **`library-insight diff <old> <new>`** to compare two library versions.
37+
> - Use **`library-insight migrate <old> <new>`** to generate a migration report with replacement suggestions.
38+
> - Use **`library-insight audit`** to audit project dependency APIs recursively.
39+
> - Use **`library-insight dependency-check`** to detect runtime linkage and ABI conflicts across transitive dependencies.
40+
> - Use **`library-insight dependency-graph <coordinate>`** to visualize dependency trees.
41+
> - Use **`library-insight semver <old> <new>`** to validate Semantic Versioning API compatibility.
42+
> - Use **`library-insight health`** to generate package health and API complexity reports.
43+
> - Use **`library-insight dsl-report [--package <pkg>]`** to inspect Kotlin DSL surfaces, including `@DslMarker` scopes, type aliases, extension functions, lambda receivers, and inline reified functions.
44+
> - Use **`library-insight callgraph <class.method>`** to recursively trace internal library method invocation call graphs.
45+
>
46+
> **AI Context**
47+
>
48+
> - Use **`library-insight ai-export`** to generate a token-optimized AI context package.
49+
> - Use **`library-insight export`** to export the indexed API as JSON or Markdown documentation.
50+
>
51+
> **Important**
52+
>
53+
> Both **`scan`** and **`scan-source`** generate the same API index format. Once an index has been created, existing commands such as **`search`**, **`explain`**, **`export`**, and **`ai-export`** work identically regardless of whether the data originated from compiled bytecode or local source code.
54+
55+
> [!NOTE]
56+
> **What Library Insight extracts**
57+
>
58+
> Depending on the input, Library Insight indexes:
59+
>
60+
> - Packages
61+
> - Classes
62+
> - Interfaces
63+
> - Enums
64+
> - Java Records
65+
> - Kotlin Objects
66+
> - Companion Objects
67+
> - Constructors
68+
> - Methods
69+
> - Properties and Fields
70+
> - Generic type parameters
71+
> - Nullability information
72+
> - Modifiers
73+
> - Annotations
74+
> - Package imports
75+
> - Source locations (`file:line`)
76+
> - Javadoc
77+
> - KDoc
78+
> - Kotlin metadata (`@Metadata`)
79+
> - Data classes
80+
> - Value classes
81+
> - Sealed classes and interfaces
82+
> - Extension functions
83+
> - Kotlin DSL constructs
84+
85+
> [!TIP]
86+
> **MCP Integration Rule**
87+
>
88+
> If an MCP server is already configured (for example in Cursor, Claude Desktop, VS Code, Windsurf, or another MCP-compatible IDE), prefer using the MCP server instead of invoking the CLI through subprocesses.
89+
>
90+
> The MCP server provides native tools for indexing libraries or source projects, searching indexed symbols, explaining APIs, and serving AI context with lower overhead than repeatedly executing CLI commands.
91+
92+
## Typical Workflows
93+
94+
### Analyze a compiled library
95+
96+
```bash
97+
library-insight scan my-library.jar
98+
99+
library-insight search Retrofit
100+
101+
library-insight explain retrofit2.Retrofit
102+
103+
library-insight ai-export
104+
```
105+
106+
### Analyze a local source project
107+
108+
```bash
109+
library-insight scan-source app/src/main
110+
111+
library-insight search LoginRepository
112+
113+
library-insight explain LoginRepository
114+
115+
library-insight ai-export
116+
```
117+
118+
### Compare two versions
119+
120+
```bash
121+
library-insight diff old.jar new.jar
122+
123+
library-insight migrate old.jar new.jar
124+
125+
library-insight semver old.jar new.jar
126+
```
33127

34128
## Command Reference
35129

36-
The command line tool `library-insight` can be executed globally by:
37-
* Installing via installer script: `curl -fsSL https://raw.githubusercontent.com/Coding-Meet/Library-Insight/main/install.sh | bash`
38-
* Running local build: `~/.library-insight/bin/library-insight` (linked globally as `library-insight`)
130+
The `library-insight` CLI can be executed globally by:
131+
132+
- Installing using the installer:
133+
134+
```bash
135+
curl -fsSL https://raw.githubusercontent.com/Coding-Meet/Library-Insight/main/install.sh | bash
136+
```
137+
138+
- Running the locally installed binary:
139+
140+
```bash
141+
library-insight
142+
```
143+
144+
or
145+
146+
```bash
147+
~/.library-insight/bin/library-insight
148+
```
149+
150+
## Additional Guidance for AI Agents
151+
152+
When answering questions about a library or project:
153+
154+
1. Index the target if it has not already been indexed.
155+
2. Search before explaining.
156+
3. Explain only the symbols relevant to the user's request.
157+
4. Avoid loading the full index into context.
158+
5. Prefer focused symbol lookups over large exports.
159+
6. Generate AI context (`ai-export`) only when broad project understanding is required.
160+
7. When an MCP server is available, prefer MCP tools over spawning CLI processes.
39161

40162
### 1. `scan` — Scan a Library
41163

@@ -97,9 +219,13 @@ library-insight search "anno:Keep" --db custom-index.json
97219
**Example output:**
98220

99221
```
100-
Found 2 matching classes:
101-
- retrofit2.Retrofit
102-
- retrofit2.Retrofit$Builder
222+
Found 2 matches for 'Retrofit':
223+
--------------------------------------------------
224+
[CLASS] class retrofit2.Retrofit
225+
Source: src/main/java/retrofit2/Retrofit.java:18
226+
[CLASS] class retrofit2.Retrofit$Builder
227+
Source: src/main/java/retrofit2/Retrofit.java:82
228+
--------------------------------------------------
103229
```
104230

105231
---
@@ -125,13 +251,32 @@ library-insight explain HtmlBuilder --db custom-index.json
125251
**Example output:**
126252

127253
```
128-
Class: retrofit2.Retrofit (public class)
129-
Constructors:
130-
+ public constructor(okhttp3.Call$Factory, ...)
131-
Methods:
132-
+ public fun <T> create(java.lang.Class<T>): T
133-
+ public fun baseUrl(): okhttp3.HttpUrl
134-
+ public fun callFactory(): okhttp3.Call$Factory
254+
==================================================
255+
CLASS EXPLAIN REPORT
256+
==================================================
257+
Class: com.meet.sample.HtmlBuilder
258+
Package: com.meet.sample
259+
Kind: class
260+
Visibility: public
261+
Source: sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:25
262+
Annotations: @HtmlDsl
263+
==================================================
264+
265+
Imports:
266+
- kotlin.text.*
267+
- retrofit2.Retrofit
268+
269+
Properties:
270+
- private val children: Any (sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:27)
271+
272+
Methods:
273+
// /** Adds a paragraph element to the HTML output. */
274+
- public fun p(text: String): Unit (sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:29)
275+
// /** Adds a heading element. */
276+
- public fun h1(text: String): Unit (sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:32)
277+
// /** Adds a nested div block. */
278+
- public fun div(block: HtmlBuilder.() -> Unit): Unit (sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:35)
279+
- public fun build(): String (sample/src/main/kotlin/com/meet/sample/SampleLibrary.kt:41)
135280
```
136281

137282
---
@@ -223,17 +368,21 @@ library-insight export json
223368
```
224369

225370
**Positional Arguments:**
371+
226372
- `[output-file]`: Optional target output file path to write export content to. If not specified, defaults to `build/API_REFERENCE.md` or `build/library-insight-index.json`. Use `-` to print to stdout.
227373

228374
**Optional Parameters:**
375+
229376
- `--db <file>`: Index database JSON file path to read from (default: `build/library-insight-index.json`)
230377

231378
**Example with options:**
379+
232380
```bash
233381
library-insight export markdown API_REFERENCE.md --db custom-index.json
234382
```
235383

236384
**Example output:**
385+
237386
```
238387
Exported MARKDOWN to: build/API_REFERENCE.md
239388
```
@@ -249,17 +398,21 @@ library-insight ai-export
249398
```
250399

251400
**Positional Arguments:**
401+
252402
- `[output-dir]`: Optional target output directory to save AI context files (default: `build/ai-context/`)
253403

254404
**Optional Parameters:**
405+
255406
- `--db <file>`: Index database JSON file path to read from (default: `build/library-insight-index.json`)
256407

257408
**Example with options:**
409+
258410
```bash
259411
library-insight ai-export custom-ai-context/ --db custom-index.json
260412
```
261413

262414
**Example output:**
415+
263416
```
264417
Generated compact LLM context directory structure at: build/ai-context
265418
```
@@ -307,6 +460,7 @@ library-insight search-central clikt
307460
```
308461

309462
**Example output:**
463+
310464
```
311465
Searching Maven Central for 'clikt'...
312466
@@ -380,6 +534,7 @@ library-insight mcp --db /path/to/project/custom-index.json
380534
```
381535

382536
**Example output (JSON-RPC tools list response):**
537+
383538
```json
384539
{
385540
"jsonrpc": "2.0",
@@ -389,12 +544,18 @@ library-insight mcp --db /path/to/project/custom-index.json
389544
{
390545
"name": "scan_library",
391546
"description": "Scans a Java/Kotlin library and creates an API index.",
392-
"inputSchema": { "type": "object", "properties": { "pathOrCoordinate": { "type": "string" } } }
547+
"inputSchema": {
548+
"type": "object",
549+
"properties": { "pathOrCoordinate": { "type": "string" } }
550+
}
393551
},
394552
{
395553
"name": "search_symbols",
396554
"description": "Search for symbols in the active library index.",
397-
"inputSchema": { "type": "object", "properties": { "query": { "type": "string" } } }
555+
"inputSchema": {
556+
"type": "object",
557+
"properties": { "query": { "type": "string" } }
558+
}
398559
}
399560
]
400561
}
@@ -414,6 +575,7 @@ library-insight init
414575
```
415576

416577
**Example output:**
578+
417579
```
418580
Initializing Library Insight agent environment...
419581
Creating directory: .agents/skills/library-insight/
@@ -437,6 +599,7 @@ library-insight skills list
437599
```
438600

439601
**Example output (skills list):**
602+
440603
```
441604
Workspace AI Agent Skills:
442605
- [Installed] library-insight
@@ -453,6 +616,7 @@ library-insight clear-cache
453616
```
454617

455618
**Example output:**
619+
456620
```
457621
Clearing local cache at: ~/.library-insight/cache...
458622
Cache cleared successfully. Deleted 12.4 MB.
@@ -738,3 +902,41 @@ library-insight callgraph AppConfigBuilder.database --db custom-index.json
738902
└── com.meet.sample.DatabaseConfigBuilder.<init>()
739903
==================================================
740904
```
905+
906+
---
907+
908+
### 22. `scan-source` — Local Source Directory Scanner
909+
910+
Scan a local raw source directory containing Kotlin (`.kt`) and Java (`.java`) files to build an API index database.
911+
912+
```bash
913+
library-insight scan-source sample/src/main/kotlin
914+
```
915+
916+
**Optional Parameters:**
917+
918+
- `--db <file>`: Target index database JSON file path to write to (default: `build/library-insight-index.json`)
919+
- `--lib-name <name>`: Override the library name tag in the generated index
920+
- `--lib-version <version>`: Override the version tag in the generated index
921+
922+
**Example with options:**
923+
924+
```bash
925+
library-insight scan-source src/main/kotlin --db build/my-app-index.json --lib-name MyApp --lib-version 1.0.0
926+
```
927+
928+
**Example output:**
929+
930+
```
931+
Scanning source directory: /Users/meet/AndroidStudioProjects/Library-Insight/sample/src/main/kotlin
932+
933+
Detected:
934+
• Kotlin files : 1
935+
• Java files : 0
936+
937+
Scan complete!
938+
Found 15 classes across 3 packages.
939+
940+
Saved API index to:
941+
/Users/meet/AndroidStudioProjects/Library-Insight/build/library-insight-index.json
942+
```

0 commit comments

Comments
 (0)