Move docs/ package mirror into document-navigator plugin

Relocate the ~6k-file docs tree from the repo root into
plugins/document-navigator/docs/ so the plugin is self-contained and
portable. docs/superpowers/ (specs and plans) stays at the repo root.

Moved via cp+rm rather than git mv because directory rename() fails with
EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the
identical-content files at commit time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 01:10:00 +01:00
parent fe3fedf42e
commit 9bf56a806b
6022 changed files with 12437 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
# output/format
<!-- begin:auto-docs -->
_(no submodules)_
<!-- end:auto-docs -->
## Purpose
`format` provides a collection of pure string-formatting utilities for structured CLI output. All functions take plain data and return formatted strings — no side effects, no I/O. Callers are responsible for printing the result. This design makes every function trivially testable and composable.
The module covers the most common CLI output patterns: key-value pairs, bulleted lists, directory-style trees, inline JSON, multi-column alignment, section headings, horizontal dividers, and indented blocks.
## Features
- `keyValue(obj, opts?)` — formats a record as aligned `key: value` pairs
- `list(items, opts?)` — formats an array as a bulleted list
- `tree(node, opts?)` — renders a recursive tree with `├─` / `└─` connectors
- `json(value, opts?)` — `JSON.stringify` wrapper with configurable indent
- `columns(rows, separator?)` — right-pads cells so columns align across rows
- `heading(text, level?)` — box-style heading with `═` (level 1) or `─` (level 2) borders
- `divider(char?, width?)` — repeated character line
- `indent(text, spaces?)` — prefixes every line with spaces
## Usage: Basic Example
```ts
import { keyValue, list, heading } from "@suaveplan/cli/output/format/format";
console.log(heading("Build Report"));
console.log(keyValue({ status: "success", files: 42, duration: "1.2s" }));
console.log(list(["Compiled main.ts", "Emitted dist/", "Linked types"]));
```
## Usage: Advanced Example
```ts
import { tree, columns, json, indent } from "@suaveplan/cli/output/format/format";
const structure = {
label: "src/",
children: [
{ label: "app/", children: [{ label: "app.ts" }, { label: "app.test.ts" }] },
{ label: "utils/", children: [{ label: "format.ts" }] },
],
};
console.log(tree(structure));
const rows = [
["alice", "admin", "2024-01-01"],
["bob", "user", "2024-03-15"],
];
console.log(columns([["Name", "Role", "Joined"], ...rows]));
console.log(indent(json({ ok: true, count: 7 }), 4));
```
## API Reference
### `keyValue(obj: Record<string, unknown>, opts?: KeyValueOptions): string`
Formats each entry as `key: value`. Options: `separator` (default `": "`), `indent` (spaces before each line, default 0).
### `list(items: string[], opts?: ListOptions): string`
Formats each item with a bullet marker. Options: `bullet` (default `"•"`), `indent` (default 0).
### `tree(node: TreeNode, opts?: TreeOptions, _prefix?: string): string`
Renders a nested tree with connector lines. Options: `indent` (spaces per nesting level, default 2).
### `json(value: unknown, opts?: JsonOptions): string`
Returns `JSON.stringify(value, null, indent)`. Options: `indent` (default 2).
### `columns(rows: string[][], separator?: string): string`
Pads each cell in each column to the column's maximum width, then joins with `separator` (default `" "`). Returns empty string for empty input.
### `heading(text: string, level?: number): string`
Returns a three-line block: border, centered text, border. Level 1 uses `═`, level 2 uses `─`, others use `-`.
### `divider(char?: string, width?: number): string`
Returns `char.repeat(width)`. Defaults: `"─"` and `40`.
### `indent(text: string, spaces?: number): string`
Prepends `spaces` (default 2) spaces to every line of `text`.
## Implementation Notes
All functions are stateless and have no dependencies. `tree` recurses depth-first, tracking a prefix string for connector characters at each level. `columns` computes widths in a single pass over all rows, then renders in a second pass. The `_prefix` parameter of `tree` is internal — external callers should omit it.

View File

@@ -0,0 +1,81 @@
# output/table
<!-- begin:auto-docs -->
_(no submodules)_
<!-- end:auto-docs -->
## Purpose
`table` renders structured data as a formatted ASCII table with header row, optional borders, and configurable column alignment. It computes column widths from the full data set — header and all rows — ensuring that every column is at least as wide as its widest cell. The result is a plain multi-line string ready for console output or piping.
The function is pure: it takes a `TableOptions` object and returns a `string`. No state, no I/O, no mutations.
## Features
- Automatic column width calculation: each column is as wide as its widest cell across all rows
- Three alignment modes per column: `"left"` (default), `"right"`, `"center"`
- Border mode (default on): header and data rows separated by `─┼─` divider
- Border-off mode: columns joined with two spaces
- Handles empty rows gracefully — returns header-only output
- Property-tested: column widths always `>=` max cell content width
## Usage: Basic Example
```ts
import { table } from "@suaveplan/cli/output/table/table";
const out = table({
headers: ["Name", "Role", "Since"],
rows: [
["Alice", "Admin", "2022"],
["Bob", "User", "2023"],
],
});
console.log(out);
// Name │ Role │ Since
// ──────┼───────┼──────
// Alice │ Admin │ 2022
// Bob │ User │ 2023
```
## Usage: Advanced Example
```ts
import { table } from "@suaveplan/cli/output/table/table";
const out = table({
headers: ["Package", "Version", "Size"],
rows: [
["@suaveplan/error", "0.1.0", "12 kB"],
["@suaveplan/cli", "0.1.0", "48 kB"],
],
alignment: ["left", "center", "right"],
border: true,
});
console.log(out);
```
## API Reference
### `table(opts: TableOptions): string`
Renders the table and returns the formatted string.
**`opts.headers: string[]`** — column header labels. Determines the number of columns.
**`opts.rows: string[][]`** — data rows. Each row is an array of string cells. Extra cells beyond `headers.length` are ignored; missing cells are treated as empty.
**`opts.alignment?: Alignment[]`** — per-column alignment (`"left"` | `"right"` | `"center"`). Defaults to `"left"` for any column not specified.
**`opts.border?: boolean`** — whether to render `│` column separators and `─┼─` divider line. Default `true`.
### `Alignment`
`"left" | "right" | "center"` — the alignment mode for a table column.
### `TableOptions`
The full options type. Corresponds to `TableOptionsSchema` for Zod validation.
## Implementation Notes
Column widths are computed with a single `Math.max` pass over `[headers, ...rows]`. Cells are padded with `String.prototype.padEnd` (left/center) or `String.prototype.padStart` (right via the `align` helper). The divider line joins `"─".repeat(width)` segments with `"─┼─"`. When `border` is false, the divider is omitted and segments are joined with `" "` instead of `" │ "`. Trailing whitespace on each row is trimmed to keep output clean.