Skip to content

Commit fad7e79

Browse files
authored
Merge pull request #9 from Coding-Meet/release/v1.4.0
Add Kotlin Multiplatform support and update documentation
2 parents 2993faa + b1ab3d7 commit fad7e79

32 files changed

Lines changed: 2023 additions & 1304 deletions

File tree

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

Lines changed: 445 additions & 381 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
---
22
name: library-insight
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.
3+
description: API Explorer & MCP Server for Java, Kotlin & KMP that indexes public APIs from compiled libraries (JAR/AAR), Kotlin Multiplatform libraries (KLib), 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

88
Use this skill when you need to understand, inspect, or build AI prompts for:
99

10-
- External JVM libraries (Java/Kotlin JAR or AAR files)
10+
- Java and Kotlin libraries (JAR/AAR files)
11+
- Kotlin Multiplatform libraries (KLib files)
1112
- Maven Central dependencies
1213
- Local Java or Kotlin source code projects
1314

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.
15+
Library Insight analyzes compiled libraries (JVM artifacts and Kotlin Multiplatform 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.
1516

1617
> [!IMPORTANT]
1718
> **AI Agent Token Optimization Rule:**
@@ -22,7 +23,7 @@ Library Insight analyzes both compiled JVM libraries and local source code to bu
2223
>
2324
> **Indexing**
2425
>
25-
> - Use **`library-insight scan <jar|aar|directory|maven-coordinate>`** to index compiled JVM libraries.
26+
> - Use **`library-insight scan <jar|aar|klib|directory|maven-coordinate>`** to index compiled libraries.
2627
> - Use **`library-insight scan-source <directory>`** to index a local Java/Kotlin source project without compilation.
2728
>
2829
> **Querying**

README.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Library Insight 🔍
44

5-
### JVM API Explorer & MCP Server
5+
### API Explorer & MCP Server for Java, Kotlin & KMP
66

7-
Analyze Java & Kotlin libraries and source code with a standalone CLI or integrate directly into AI IDEs via MCP.
7+
Analyze Java and Kotlin libraries, JVM artifacts, Kotlin Multiplatform libraries, and local source code with a standalone CLI or integrate directly into AI IDEs via MCP.
88

99
AI coding assistants often guess Java/Kotlin APIs from outdated documentation, web examples, or a different version than the one used in your project. That leads to missing methods, deprecated usage, incorrect signatures, and wasted debugging time.
1010

@@ -26,6 +26,7 @@ The complete documentation, architecture diagrams, command reference, and integr
2626
<!-- --8<-- [start:features] -->
2727

2828
- **MCP Server**: Connect Cursor, Claude Desktop, or any MCP-compatible IDE to query APIs directly.
29+
- **Kotlin Multiplatform (KMP) Support**: Resolve coordinates from Gradle Module Metadata (`.module` JSON), parse Native `.klib` metadata files, and merge platform variant API targets (`common`, `jvm`, `ios`, `js`, `wasm`).
2930
- **Local Source Code Scanner (`scan-source`)**: Analyze Kotlin and Java source projects without compilation, preserving KDoc/Javadoc, imports, and declaration source locations (`file:line`).
3031
- **Version-Correct API Lookup**: Build an API index from the exact JAR, AAR, Maven dependency, Gradle output, or source code used by your project to prevent AI hallucinations.
3132
- **Deep Metadata Extraction**: Extract classes, constructors, methods, properties, nullability, generics, annotations, modifiers, and source metadata.
@@ -85,28 +86,14 @@ For setup instructions in Cursor or Claude Desktop, see the [MCP Integration Gui
8586

8687
<!-- --8<-- [start:roadmap] -->
8788

88-
We plan to expand Library Insight with deep source-level analysis capabilities, a three-layer clean architecture, and unified Kotlin Multiplatform (KMP) support:
89+
We plan to expand Library Insight with deep source-level analysis capabilities:
8990

9091
### 🔍 Source Analysis Engine (Planned)
9192

9293
- **References Engine**: Build a symbol-to-usage index to locate references for any class, method, or property across the codebase (e.g. `library-insight references LoginRepository`).
9394
- **Implementations**: Query all interface implementations or subclass declarations (e.g. `library-insight implementations Repository` -> `RoomRepository`, `NetworkRepository`).
9495
- **Hierarchy**: Render the visual inheritance tree for any base class or interface (e.g. `library-insight hierarchy BaseViewModel`).
9596
- **Source Call Graph**: Trace internal method execution paths using raw source file declaration locations.
96-
97-
### 🏗️ Clean Architectural Layers
98-
99-
To simplify maintenance, we are partitioning the codebase into three clean layers:
100-
101-
1. **Scanner Layer** (`scan`, `scan-source`) — Processes raw inputs (bytecode, sources, metadata) and compiles them.
102-
2. **Unified Database** — Serves as the single serialization schema and repository index.
103-
3. **Analysis & Tooling Layer** (`search`, `explain`, `references`, `implementations`, `hierarchy`, `callgraph`, `ai-export`, `export`) — Consumes the database and provides rich diagnostic tools.
104-
105-
### 📦 Kotlin Multiplatform (KMP) Support
106-
107-
- **KLib Metadata Reader**: Parse `.klib` metadata to extract signatures for iOS/Native, JS, and Wasm targets directly (bypassing JVM bytecode dependencies).
108-
- **Platform-Aware Indexing**: Store platform target markers (`common`, `jvm`, `ios`, `js`, `wasm`) in the database schema.
109-
- **KMP Coordinate Resolution**: Auto-resolve platform split coordinates (e.g. `ktor-client-core-iosarm64`) from the root KMP library Maven coordinate.
11097
<!-- --8<-- [end:roadmap] -->
11198

11299
---
@@ -157,8 +144,8 @@ mkdocs gh-deploy --force
157144
Release and publish a new version tag to GitHub:
158145

159146
```bash
160-
git tag v1.3.0
161-
git push origin v1.3.0
147+
git tag v1.4.0
148+
git push origin v1.4.0
162149
```
163150

164151
### 5. Demos

build.gradle.kts

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55

66
allprojects {
77
group = "com.meet.libraryinsight"
8-
version = "1.3.0"
8+
version = "1.4.0"
99

1010
repositories {
1111
mavenCentral()
@@ -61,52 +61,56 @@ tasks.register("setupGitHooks") {
6161
tasks.register("generateAgentSkill") {
6262
dependsOn("setupGitHooks")
6363
group = "documentation"
64-
description = "Generates .agents/skills/library-insight/SKILL.md from docs/cli.md and a template."
64+
description = "Generates .agents/skills/library-insight/SKILL.md from split docs/cli/*.md and a template."
6565

66-
val cliFile = file("docs/cli.md")
66+
val cliDir = file("docs/cli")
6767
val templateFile = file(".agents/skills/library-insight/SKILL.template.md")
6868
val outputFile = file(".agents/skills/library-insight/SKILL.md")
6969

70-
inputs.file(cliFile)
70+
val scannersFile = file("docs/cli/scanners.md")
71+
val explorerFile = file("docs/cli/explorer.md")
72+
val analysisFile = file("docs/cli/analysis.md")
73+
val versioningFile = file("docs/cli/versioning.md")
74+
val dependenciesFile = file("docs/cli/dependencies.md")
75+
val aiIntegrationFile = file("docs/cli/ai-integration.md")
76+
77+
inputs.dir(cliDir)
7178
inputs.file(templateFile)
7279
outputs.file(outputFile)
7380

7481
doLast {
75-
if (!cliFile.exists()) {
76-
throw GradleException("docs/cli.md does not exist")
82+
if (!cliDir.exists() || !cliDir.isDirectory) {
83+
throw GradleException("docs/cli directory does not exist")
7784
}
7885
if (!templateFile.exists()) {
7986
throw GradleException("SKILL.template.md does not exist")
8087
}
8188

82-
val cliContent = cliFile.readText()
83-
val startMarker = "<!-- --8<-- [start:commands] -->"
84-
val endMarker = "<!-- --8<-- [end:commands] -->"
85-
86-
val startIndex = cliContent.indexOf(startMarker)
87-
val endIndex = cliContent.indexOf(endMarker)
88-
89-
if (startIndex == -1 || endIndex == -1 || startIndex >= endIndex) {
90-
throw GradleException("Could not find start/end command markers in docs/cli.md")
91-
}
92-
93-
val commandsSection = cliContent.substring(startIndex + startMarker.length, endIndex).trim()
94-
95-
// Shift headers: ## to ### (to fit in SKILL.md under ## Command Reference)
96-
val shiftedCommands = commandsSection.lines().joinToString("\n") { line ->
97-
if (line.startsWith("## ")) {
98-
"### " + line.substring(3)
99-
} else if (line.startsWith("### ")) {
100-
"#### " + line.substring(4)
101-
} else {
102-
line
89+
// Ordered categories/files
90+
val categoryFiles = listOf(
91+
"Scanners & Indexing" to scannersFile,
92+
"API Explorer & Lookup" to explorerFile,
93+
"Analysis & Diagnostics" to analysisFile,
94+
"Versioning & Migration" to versioningFile,
95+
"Maven & Dependency Resolution" to dependenciesFile,
96+
"AI Context & Integration" to aiIntegrationFile
97+
)
98+
99+
val commandsSection = buildString {
100+
categoryFiles.forEachIndexed { index, (catTitle, file) ->
101+
if (!file.exists()) {
102+
throw GradleException("${file.name} does not exist")
103+
}
104+
file.readLines().forEach { line ->
105+
append(line + "\n")
106+
}
103107
}
104-
}
108+
}.trim()
105109

106110
val templateContent = templateFile.readText()
107-
val finalContent = templateContent.replace("{{COMMAND_REFERENCE}}", shiftedCommands)
111+
val finalContent = templateContent.replace("{{COMMAND_REFERENCE}}", commandsSection)
108112
outputFile.writeText(finalContent)
109-
logger.lifecycle("Successfully generated ${outputFile.path} from docs/cli.md")
113+
logger.lifecycle("Successfully generated ${outputFile.path} from split CLI docs")
110114
}
111115
}
112116

demo.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,23 @@ echo ""
268268
library-insight doctor
269269
echo ""
270270

271+
# ------------------------------------------------------------------
272+
# 23. KMP SCAN & EXPLAIN
273+
# Resolve target platforms and print platform indicators
274+
# ------------------------------------------------------------------
275+
echo ">> 23. KMP SCAN & EXPLAIN - Resolve KMP targets and merge API indexes"
276+
echo " library-insight scan io.ktor:ktor-client-core:3.0.0 --db build/ktor-index.json"
277+
library-insight scan io.ktor:ktor-client-core:3.0.0 --db build/ktor-index.json > /dev/null
278+
echo " library-insight explain io.ktor.client.HttpClient --db build/ktor-index.json"
279+
echo ""
280+
library-insight explain io.ktor.client.HttpClient --db build/ktor-index.json | head -n 35
281+
echo ""
282+
271283
# Cleanup
272284
rm -rf "$DEMO_WORKSPACE"
285+
rm -f build/ktor-index.json
273286

274287
echo "$SEPARATOR"
275-
echo " All 22 commands completed successfully!"
288+
echo " All 23 commands completed successfully!"
276289
echo "$SEPARATOR"
277290
echo ""

docs/ai-agents.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ The skill is designed around one core rule: **do not guess from web examples whe
1010

1111
When you install the CLI globally via the recommended shell installer (`install.sh`), the script automatically copies the agent skill file into your user profile configurations:
1212

13-
* `~/.cursor/skills/library-insight`
14-
* `~/.gemini/config/skills/library-insight`
15-
* `~/.claude/skills/library-insight`
16-
* `~/.agents/skills/library-insight`
17-
* `~/.copilot/skills/library-insight`
18-
* `~/.junie/skills/library-insight`
13+
- `~/.cursor/skills/library-insight`
14+
- `~/.gemini/config/skills/library-insight`
15+
- `~/.claude/skills/library-insight`
16+
- `~/.agents/skills/library-insight`
17+
- `~/.copilot/skills/library-insight`
18+
- `~/.junie/skills/library-insight`
1919

2020
Any active AI agent running on your computer will instantly discover and utilize the `library-insight` command tree when you ask a question.
2121

2222
---
2323

2424
## 2. Project Workspace Scoping
2525

26-
If you want to install the skill scoped *only* to your current project directory (so that any developer working in the repository gets the skill context), run the following command in the project root:
26+
If you want to install the skill scoped _only_ to your current project directory (so that any developer working in the repository gets the skill context), run the following command in the project root:
2727

2828
```bash
2929
library-insight init

docs/architecture.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,22 @@ graph TD
5050

5151
### Module Responsibilities
5252

53-
* `library-insight-common`: Low-level utility classes for ZIP/JAR/AAR archives extraction, Ktor asynchronous HTTP engines, and directory operations.
54-
* `library-insight-model`: Contains immutable Kotlin serialization structures representing the public API schema (`LibraryApiIndex`).
55-
* `library-insight-parser`: Performs raw Java bytecode parsing using the **ASM** library, extracting class fields, methods, generic signatures, and structures.
56-
* `library-insight-kotlin`: Reads and parses compiled Kotlin Metadata header annotations (`@Metadata` via `kotlin-metadata-jvm`) to enrich signatures with Kotlin properties, nullability flags, and suspend keywords.
57-
* `library-insight-search`: The query/search engine that matches search keywords against compiled packages, classes, constructors, methods, and variables.
58-
* `library-insight-export`: Exporters that format API indices into target representations: **JSON**, **Markdown** reference documentation, and token-optimized **AI Context** pages.
59-
* `library-insight-core`: The main orchestration hub. It coordinates the parsing, metadata enrichment, search routines, and calculates API differences/compatibility alerts.
60-
* `library-insight-cli`: Command Line Interface definitions using **Clikt** mapping option/argument configurations.
53+
- `library-insight-common`: Low-level utility classes for ZIP/JAR/AAR archives extraction, Ktor asynchronous HTTP engines, and directory operations.
54+
- `library-insight-model`: Contains immutable Kotlin serialization structures representing the public API schema (`LibraryApiIndex`).
55+
- `library-insight-parser`: Performs raw Java bytecode parsing using the **ASM** library, extracting class fields, methods, generic signatures, and structures.
56+
- `library-insight-kotlin`: Reads and parses compiled Kotlin Metadata header annotations (`@Metadata` via `kotlin-metadata-jvm`) to enrich signatures with Kotlin properties, nullability flags, and suspend keywords.
57+
- `library-insight-search`: The query/search engine that matches search keywords against compiled packages, classes, constructors, methods, and variables.
58+
- `library-insight-export`: Exporters that format API indices into target representations: **JSON**, **Markdown** reference documentation, and token-optimized **AI Context** pages.
59+
- `library-insight-core`: The main orchestration hub. It coordinates the parsing, metadata enrichment, search routines, and calculates API differences/compatibility alerts.
60+
- `library-insight-cli`: Command Line Interface definitions using **Clikt** mapping option/argument configurations.
6161

6262
## Unified API Indexing Pipelines
6363

64-
Library Insight exposes two different parsing pipelines depending on the target input:
64+
Library Insight exposes three different parsing pipelines depending on the target input:
6565

6666
1. **Bytecode Scan Pipeline (`scan` command)**: Extracts signatures from compiled `.class` files (inside JAR/AAR/Maven artifacts) using the ASM library, enriched by `kotlin-metadata-jvm`.
67-
2. **Source Scan Pipeline (`scan-source` command)**: Extracts signatures directly from raw Java (`.java`) and Kotlin (`.kt`) source project files using JavaParser and Kotlin PSI compiler APIs.
67+
2. **Kotlin Multiplatform (KMP) Scan Pipeline (`scan` command)**: Resolves Maven coordinates, inspects Gradle Module Metadata (`.module` JSON), extracts platform targets from Kotlin Native `.klib` metadata files, and merges platform variants (`common`, `jvm`, `ios`, `js`, `wasm`) into a unified index.
68+
3. **Source Scan Pipeline (`scan-source` command)**: Extracts signatures directly from raw Java (`.java`) and Kotlin (`.kt`) source project files using JavaParser and Kotlin PSI compiler APIs.
6869

6970
Both pipelines converge into the same unified `LibraryApiIndex` schema, allowing existing downstream search, explain, and export subcommands to function identically without separate workflows.
7071

0 commit comments

Comments
 (0)