open-index/open-npm huggingface dataset:
npm package: @silkweave/cli
Description: Silkweave CLI Adapter
Latest version: 1.4.0

# @silkweave/cli

CLI adapter for [Silkweave](https://github.com/silkweave/silkweave) - turn your actions into a complete command-line application with help text, option parsing, and styled terminal output via clack.

## Install

```bash
pnpm add @silkweave/core @silkweave/cli
```

## Usage

```typescript
import { silkweave } from '@silkweave/core'
import { cli } from '@silkweave/cli'
import { GreetAction } from './actions/greet.js'

await silkweave({ name: 'mytool', description: 'My CLI Tool', version: '1.0.0' })
  .adapter(cli())
  .action(GreetAction)
  .start()
```

```
$ mytool greet --name "World" --enthusiastic
◇ mytool - greet
ℹ HELLO, WORLD!!!
```

## How Zod Types Map to CLI Options

| Zod Type | CLI Representation |
|----------|-------------------|
| `z.string()` | `--option-name <string>` |
| `z.number()` | `--option-name <number>` |
| `z.boolean()` | `--option-name` / `--no-option-name` |
| `z.enum([...])` | `--option-name <choice>` with choices validation |
| `z.record()` | `--option-name <json>` |
| `.default(value)` | Sets the default in help text |
| `.describe('...')` | Sets the option description |

Field names are automatically converted to `kebab-case`. Action names become subcommands.

## Positional Arguments

Use the `args` property on an action to promote fields to positional arguments:

```typescript
const DeployAction = createAction({
  name: 'deploy',
  input: z.object({
    environment: z.string(),
    dryRun: z.boolean().default(false)
  }),
  args: ['environment'],
  // ...
})
```

```
$ mytool deploy production --dry-run
```

## See Also

- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core) - Core library
npm package: @silkweave/core
Description: Silkweave Core
Latest version: 1.4.0

# @silkweave/core

Core library for [Silkweave](https://github.com/silkweave/silkweave) - the TypeScript toolkit for building MCP servers and CLI tools from a single set of Actions.

## Install

```bash
pnpm add @silkweave/core
```

## What's Inside

This package provides the foundational building blocks that all Silkweave adapters depend on:

- **`silkweave()`** - Fluent builder to wire up adapters and actions
- **`createAction()`** - Define transport-agnostic actions with Zod input schemas
- **Adapter types** - `Adapter`, `AdapterGenerator`, `AdapterFactory` interfaces for building custom adapters
- **Context** - `SilkweaveContext` key-value store with `fork()` for per-adapter/per-request isolation
- **Zod utilities** - `unwrap()` to recursively unwrap Zod wrapper types

## Usage

```typescript
import { silkweave, createAction } from '@silkweave/core'
import z from 'zod'

const GreetAction = createAction({
  name: 'greet',
  description: 'Greet someone by name',
  input: z.object({
    name: z.string().describe('Name to greet')
  }),
  run: async ({ name }, context) => {
    return { message: `Hello, ${name}!` }
  }
})

// Wire up with any adapter
await silkweave({ name: 'my-app', description: 'My App', version: '1.0.0' })
  .adapter(someAdapter)
  .action(GreetAction)
  .start()
```

## API

### `silkweave(options): Silkweave`

| Option | Type | Description |
|--------|------|-------------|
| `name` | `string` | Server/app name |
| `description` | `string` | Human-readable description |
| `version` | `string` | Semantic version |

Returns a builder with `.adapter()`, `.action()`, `.actions()`, `.set()`, and `.start()`.

### `createAction(action): Action`

| Field | Type | Description |
|-------|------|-------------|
| `name` | `string` | Unique action identifier |
| `description` | `string` | Human-readable description |
| `input` | `z.ZodObject` | Zod schema for input validation |
| `args` | `(keyof I)[]` | Fields to expose as CLI positional arguments |
| `isEnabled` | `(context) => boolean` | Gate action availability per adapter |
| `run` | `(input, context) => Promise<O>` | The action implementation |
| `toolResult` | `(response, context) => CallToolResult \| undefined` | Custom MCP result formatting (optional) |

### Adapter Interfaces

```typescript
interface Adapter {
  context: SilkweaveContext
  start(actions: Action[]): Promise<void>
  stop(): Promise<void>
}

type AdapterGenerator = (options: SilkweaveOptions, baseContext: SilkweaveContext) => Adapter
type AdapterFactory<T = void> = (options: T) => AdapterGenerator
```

## See Also

- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
- [`@silkweave/mcp`](https://www.npmjs.com/package/@silkweave/mcp) - MCP stdio and HTTP adapters
- [`@silkweave/fastify`](https://www.npmjs.com/package/@silkweave/fastify) - Fastify REST adapter
- [`@silkweave/cli`](https://www.npmjs.com/package/@silkweave/cli) - CLI adapter
- [`@silkweave/vercel`](https://www.npmjs.com/package/@silkweave/vercel) - Vercel serverless adapter
npm package: @silkweave/fastify
Description: Silkweave Fastify REST Adapter
Latest version: 1.4.0

# @silkweave/fastify

Fastify REST adapter for [Silkweave](https://github.com/silkweave/silkweave) - expose your actions as a REST API with auto-generated OpenAPI/Swagger documentation.

## Install

```bash
pnpm add @silkweave/core @silkweave/fastify
```

## Usage

```typescript
import { silkweave } from '@silkweave/core'
import { fastify } from '@silkweave/fastify'
import { SearchAction } from './actions/search.js'

await silkweave({ name: 'my-api', description: 'My REST API', version: '1.0.0' })
  .adapter(fastify({ host: 'localhost', port: 8080, logger: true }))
  .action(SearchAction)
  .start()
```

Visit `http://localhost:8080/` for the interactive Scalar API reference.

## Route Mapping

Each action becomes a `POST /{action.name}` route. Zod schemas are converted to JSON Schema for request body validation and OpenAPI documentation.

| Action | Route | Body |
|--------|-------|------|
| `name: 'search'` | `POST /search` | `{ "query": "...", "limit": 10 }` |
| `name: 'greet'` | `POST /greet` | `{ "name": "World" }` |

## Options

`FastifyAdapterOptions` extends Fastify's native `FastifyHttpOptions`, so any Fastify config is supported:

```typescript
fastify({
  host: 'localhost',
  port: 8080,
  logger: {
    level: 'debug',
    transport: { target: 'pino-pretty' }
  },
  connectionTimeout: 30000
})
```

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `host` | `string` | `undefined` | Bind address |
| `port` | `number` | `undefined` | Listen port |
| *...* | | | Any `FastifyHttpOptions` |

## See Also

- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core) - Core library
npm package: @silkweave/logger
Description: Silkweave Logger
Latest version: 1.4.0

# @silkweave/logger

Logging utilities for [Silkweave](https://github.com/silkweave/silkweave). Provides a unified `Logger` interface with multiple backends - pino for stream logging, clack for terminal UI, and callback hooks for MCP notifications.

## Install

```bash
pnpm add @silkweave/logger
```

## What's Inside

- **`Logger`** interface - 8 severity levels (`debug` through `emergency`) plus `progress()`
- **`createLogger()`** - Factory that creates a Logger backed by pino, with optional `onLog` and `onProgress` callbacks
- **`createCLILogger()`** - Logger that outputs via `@clack/prompts` for beautiful terminal UI
- **`buildLogLevels()`** - Build a log-level record from a single callback function

## Usage

```typescript
import { createLogger } from '@silkweave/logger'

const logger = createLogger({
  stream: process.stderr,
  onLog: (level, data) => {
    // Hook into log events (e.g., send MCP notifications)
  },
  onProgress: ({ progress, total, message }) => {
    // Hook into progress events
  }
})

logger.info('Starting operation')
logger.progress({ progress: 5, total: 10, message: 'Halfway there' })
```

## Logger Interface

```typescript
interface Logger {
  debug: (data: unknown) => void
  info: (data: unknown) => void
  notice: (data: unknown) => void
  warning: (data: unknown) => void
  error: (data: unknown) => void
  critical: (data: unknown) => void
  alert: (data: unknown) => void
  emergency: (data: unknown) => void
  progress: (options: ProgressOptions) => void
}

interface ProgressOptions {
  progress: number
  total?: number
  message?: string
}
```

## See Also

- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core) - Core library