Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

env:
KITOPS_PATH: "kitops-clone"
KITOPS_TS_DOCS_PATH: "docs/kitops-ts"
KITOPS_TS_DOCS_PATH: "docs/src/docs/kitops-ts"

jobs:
sync-docs-to-kitops:
Expand Down
56 changes: 6 additions & 50 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ console.log(`kit ${version} (${commit})`);

---

### `kit(command, args, options?)`
### `kit(command, args, stdin?, options?)`

Low-level escape hatch for running any `kit` subcommand directly. Useful when the higher-level wrappers don't expose a flag you need.

Expand All @@ -445,6 +445,7 @@ Low-level escape hatch for running any `kit` subcommand directly. Useful when th
|---|---|---|
| `command` | `KitCommand` | The `kit` subcommand to run (e.g. `'pack'`, `'push'`). |
| `args` | `string[]` | Arguments to pass to the subcommand. |
| `stdin` | `string` | Optional data to write to stdin before closing it (e.g. a password). |
| `options.cwd` | `string` | Working directory for the spawned process. |

**Returns** `Promise<ExecResult>`
Expand All @@ -460,55 +461,10 @@ type ExecResult = {
**Example**

```typescript
const result = await kit('pack', ['.', '--tag', 'my-model:latest'], { cwd: '/path/to/project' });
// Run a subcommand in a specific directory
const result = await kit('pack', ['.', '--tag', 'my-model:latest'], undefined, { cwd: '/path/to/project' });
console.log(result.stdout);
```

---

## Types

### `FilterFlag`

A filter expression used by `unpack` and `info` to select specific layers or individual paths within a layer.

```typescript
type Layer = 'model' | 'datasets' | 'code' | 'docs' | 'prompts'

// Accepted formats:
// 'model' — entire model layer
// 'datasets:training' — named dataset
// 'docs:./README.md' — single file within the docs layer
// 'model,datasets:validation' — comma-separated (multiple layers)
type FilterFlag = string
```

### `Kitfile`

Represents a parsed `Kitfile`. See [KitOps Kitfile reference](https://kitops.org/docs/kitfile/kf-overview/) for full field documentation.

```typescript
type Kitfile = {
manifestVersion?: string;
package?: Package;
model?: Model;
datasets?: Dataset[];
code?: Code[];
docs?: Doc[];
prompts?: Prompt[];
}
```

### `Manifest`

OCI image manifest returned by `inspect`.

```typescript
type Manifest = {
schemaVersion: number;
mediaType: string;
config: ManifestDescriptor;
layers: ManifestDescriptor[];
annotations?: ManifestAnnotations;
}
// Pass credentials via stdin
const result = await kit('login', ['registry.example.com', '--username', 'user'], process.env.REGISTRY_PASS!);
```
72 changes: 57 additions & 15 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Pack and publish a ModelKit from a CI environment. Reads credentials and version
```javascript
import { login, pack, push, logout } from '@kitops/kitops-ts';

function requireEnv(name) {
const value = process.env[name];
if (!value) throw new Error(`Missing required environment variable: ${name}`);
return value;
}

const registry = requireEnv('REGISTRY');
const user = requireEnv('REGISTRY_USER');
const pass = requireEnv('REGISTRY_PASS');
Expand Down Expand Up @@ -143,23 +149,59 @@ await logout(prodRegistry);
Package a prompt dataset for LLM fine-tuning. The `prompts` layer is designed for versioning prompt templates, instruction sets, and RLHF preference data alongside model weights and training code — keeping the entire fine-tuning run fully reproducible.

```javascript
import { writeFile, access, mkdir } from 'fs/promises';
import { stringify as toYaml } from 'yaml';
import { login, pack, push, logout } from '@kitops/kitops-ts';

// Generates a Kitfile if one isn't already committed, then packs and pushes.
const kitfile = {
manifestVersion: '1.0.0',
package: { name: 'llm-finetune', version: '0.2.0' },
model: { name: 'base-checkpoint', path: './checkpoints' },
prompts: [
{ path: './prompts/system.txt', description: 'System prompt template' },
{ path: './prompts/instructions.jsonl', description: 'Instruction-following examples' },
{ path: './prompts/preferences.jsonl', description: 'RLHF preference pairs' },
],
datasets: [
{ name: 'training-corpus', path: './data/train.jsonl' },
],
code: [{ path: './train.py', description: 'Fine-tuning entry point' }],
};
function requireEnv(name) {
const value = process.env[name];
if (!value) throw new Error(`Missing required environment variable: ${name}`);
return value;
}

const registry = process.env.REGISTRY ?? 'registry.example.com';
const user = requireEnv('REGISTRY_USER');
const pass = requireEnv('REGISTRY_PASS');
const version = process.env.MODEL_VERSION ?? 'latest';

const ref = `${registry}/org/llm-finetune:v${version}`;
const workdir = './fine-tune';

// Ensure the working directory exists before writing into it.
await mkdir(workdir, { recursive: true });

// Generate a Kitfile if one isn't already committed.
const kitfilePath = `${workdir}/Kitfile`;
const kitfileExists = await access(kitfilePath).then(() => true).catch(() => false);
Comment thread
javisperez marked this conversation as resolved.

if (!kitfileExists) {
const kitfile = {
manifestVersion: '1.0.0',
package: { name: 'llm-finetune', version },
model: { name: 'base-checkpoint', path: './checkpoints' },
prompts: [
{ path: './prompts/system.txt', description: 'System prompt template' },
{ path: './prompts/instructions.jsonl', description: 'Instruction-following examples' },
{ path: './prompts/preferences.jsonl', description: 'RLHF preference pairs' },
],
datasets: [
{ name: 'training-corpus', path: './data/train.jsonl' },
],
code: [{ path: './train.py', description: 'Fine-tuning entry point' }],
};

await writeFile(kitfilePath, toYaml(kitfile, { lineWidth: 0 }));
console.log('Kitfile generated.');
}

Comment thread
javisperez marked this conversation as resolved.
await login(registry, user, pass);

try {
await pack(workdir, { tag: ref });
await push(ref);
} finally {
await logout(registry);
}
```

**Run:**
Expand Down
7 changes: 1 addition & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- **Node.js >= 23**
- **KitOps CLI** installed and available on `PATH`
— [Installation instructions](https://kitops.org/docs/cli/installation/)
— [Installation instructions](/docs/cli/installation/)
— Or set the `KITOPS_CLI_PATH` environment variable to the full path of the `kit` binary

## Installation
Expand Down Expand Up @@ -54,8 +54,3 @@ try {
| Variable | Description |
|---|---|
| `KITOPS_CLI_PATH` | Full path to the `kit` binary. Defaults to `kit` (resolved via `PATH`). |

## Next steps

- [API Reference](./api-reference.md) — All available commands and their options
- [Examples](./examples.md) — Common workflow walkthroughs
11 changes: 0 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# kitops-ts

[![npm version](https://img.shields.io/npm/v/@kitops/kitops-ts)](https://www.npmjs.com/package/@kitops/kitops-ts)
[![CI](https://github.com/kitops-ml/kitops-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/kitops-ml/kitops-ts/actions/workflows/ci.yml)
[![License](https://img.shields.io/npm/l/@kitops/kitops-ts)](https://github.com/kitops-ml/kitops-ts/blob/main/LICENSE)

**kitops-ts** is a TypeScript/Node.js SDK for the [KitOps](https://kitops.org) CLI. It provides a type-safe functional API for packing, pushing, pulling, and inspecting ModelKits — without having to shell out manually.

Similar to [pykitops](https://github.com/kitops-ml/pykitops) but for TypeScript/JavaScript.
Expand All @@ -24,13 +20,6 @@ await pack('.', { tag: 'ghcr.io/my-org/my-model:v1.0.0' });
await push('ghcr.io/my-org/my-model:v1.0.0');
```

## Documentation

- [Getting Started](./getting-started.md) — Installation, requirements, and a quick start guide
- [API Reference](./api-reference.md) — Full documentation for all commands and types
- [Examples](./examples.md) — Annotated walkthroughs of common workflows
- [Contributing](./contributing.md) — How to contribute to kitops-ts

## Related

- [KitOps](https://kitops.org) — The ModelKit standard and CLI
Expand Down
Loading