# How To Develop

This guide describes the contributor workflow for the current implementation.

## Prerequisites

* Node.js.
* npm.
* Git.
* Playwright browser dependencies for e2e tests and screenshot capture.

## Install Dependencies

```bash
npm install
```

## Run In Development

```bash
npm run dev
```

This starts:

* Vite on `127.0.0.1`.
* The Wikied CLI in development mode with `--dev-client`.

Use this workflow while changing the React client because Vite handles reloads.

## Build

```bash
npm run build
```

The build produces:

* Compiled CLI, server, and shared JavaScript in `dist`.
* Bundled React client assets in `dist/client`.
* Package-ready files for `npm pack`.

## Run The Built App

```bash
node dist/cli/index.js docs/project --no-open --port 4173
```

Then open:

```text
http://127.0.0.1:4173
```

## Project Areas

* `src/cli`: command-line entrypoint, argument parsing, settings load, browser launch.
* `src/server`: Express app, filesystem APIs, settings, path safety, and assets.
* `src/client`: React editor experience.
* `src/client/components`: file tree, outline, toolbar, and conflict view components.
* `src/client/editor`: Rich, Source, and Preview editor surfaces.
* `src/shared`: API types, error codes, and Markdown helpers.
* `tests`: unit, component, server, shared, and Playwright tests.
* `scripts`: local packaging and screenshot helpers.

## Generate Documentation Screenshots

Build first, then run the Playwright screenshot script:

```bash
npm run build
node scripts/capture-doc-screenshots.mjs
```

The script starts the built CLI against `docs/project` on port `4180` and writes screenshots to:

```text
docs/project/images/
```

## Development Rules

* Keep filesystem access on the server.
* Keep path safety checks close to file operations.
* Treat Source mode as the escape hatch for Markdown syntax Rich mode cannot own.
* Preserve project files unless the user explicitly saves, creates, renames, or inserts assets.
* Keep docs current when user-facing behavior changes.
* Do not add project-level config in this version.
