Skip to content

Commit 7cfffbc

Browse files
mattiamanzaticlaude
andcommitted
feat: add layerinfo CLI command
- Add `layerinfo` command to show detailed layer information - Shows provides, requires, and suggested composition order - Add tip about using Layer.mergeAll to both overview and layerinfo - Update README with layerinfo documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4569328 commit 7cfffbc

29 files changed

Lines changed: 867 additions & 13 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@effect/language-service": minor
3+
---
4+
5+
Added `layerinfo` CLI command that provides detailed information about a specific exported layer.
6+
7+
Features:
8+
- Shows layer type, location, and description
9+
- Lists services the layer provides and requires
10+
- Suggests optimal layer composition order using `Layer.provide`, `Layer.provideMerge`, and `Layer.merge`
11+
12+
Example usage:
13+
```bash
14+
effect-language-service layerinfo --file ./src/layers/app.ts --name AppLive
15+
```
16+
17+
Also added a tip to both `overview` and `layerinfo` commands about using `Layer.mergeAll(...)` to get suggested composition order.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,30 @@ Layers (2)
255255
Complete application layer
256256
```
257257

258+
### `effect-language-service layerinfo`
259+
This command provides detailed information about a specific exported layer, including what services it provides, what it requires, and a suggested composition order. Use `--file` to specify the file and `--name` to specify the layer name.
260+
261+
Example output:
262+
```
263+
AppLive
264+
./src/layers/app.ts:39:14
265+
Layer<Cache | UserRepository, never, never>
266+
267+
Provides (2):
268+
- Cache
269+
- UserRepository
270+
271+
Suggested Composition:
272+
UserRepository.Default.pipe(
273+
Layer.provide(DbConnection.Default),
274+
Layer.provideMerge(Cache.Default),
275+
Layer.provide(FileSystem.Default)
276+
)
277+
278+
Tip: Not sure you got your composition right? Just write all layers inside a Layer.mergeAll(...)
279+
command, and then run the layerinfo command to get the suggested composition order to use.
280+
```
281+
258282
## Configuring diagnostics
259283

260284
You can either disable or change the severity of specific diagnostics by using comments in your code.

src/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
66
import * as Console from "effect/Console"
77
import * as Effect from "effect/Effect"
88
import * as Layer from "effect/Layer"
9+
import packageJson from "../package.json"
910
import { check } from "./cli/check"
1011
import { codegen } from "./cli/codegen"
1112
import { diagnostics } from "./cli/diagnostics"
13+
import { layerInfo } from "./cli/layerinfo"
1214
import { overview } from "./cli/overview"
1315
import { patch } from "./cli/patch"
1416
import { setup } from "./cli/setup"
@@ -19,11 +21,11 @@ const cliCommand = Command.make(
1921
"effect-language-service",
2022
{},
2123
() => Console.log("Please select a command or run --help.")
22-
).pipe(Command.withSubcommands([setup, patch, unpatch, check, diagnostics, codegen, overview]))
24+
).pipe(Command.withSubcommands([setup, patch, unpatch, check, diagnostics, codegen, overview, layerInfo]))
2325

2426
const main = Command.run(cliCommand, {
2527
name: "effect-language-service",
26-
version: "0.0.2"
28+
version: packageJson.version
2729
})
2830

2931
const cliLayers = Layer.merge(NodeContext.layer, TypeScriptContext.live(process.cwd()))

0 commit comments

Comments
 (0)