features-cli 0.9.5

A CLI tool for discovering the features in a folder
Documentation
# Features CLI

A zero-config CLI tool for discovering and managing features in a feature-based architecture project by detecting README.md or README.mdx files in directories.

## Getting Started

```bash
npm install -g features-cli
# or
cargo binstall features-cli


features /path/to/project # list all features in the directory and subdirectories
```

## Feature Detection

The CLI automatically detects features using two methods:

### Method 1: Features folder (default)
Any directory that is a direct subfolder of a `features` directory is considered a feature.

### Method 2: Feature flag in README
Any directory with a README.md or README.mdx file containing `feature: true` in the YAML frontmatter is considered a feature.

Both methods support:
- **README formats**: Both README.md and README.mdx files
- **Metadata parsing**: Extracts owner and metadata from YAML frontmatter
- **Description extraction**: Uses content after the first heading as feature description
- **Nested features**: Supports hierarchical feature organization (via `features` subfolder or nested directories with `feature: true`)
- **Documentation exclusion**: Ignores README files in documentation directories (docs, __docs__, decisions, etc.)

### README Format Examples

#### Standard feature (in features folder):
```markdown
---
owner: Team Name
figma: https://www.figma.com/file/1234567890/Feature-Name?node-id=0%3A1
status: active
version: 1.0.0
tags: ["authentication", "security"]
---

# Feature Name

This is the feature description that will be extracted by the CLI.

## Additional sections are included in the description
```

#### Explicit feature (anywhere with feature flag):
```markdown
---
feature: true
owner: Team Name
status: active
---

# Feature Name

This feature can be located anywhere in your codebase, not just in a features folder.
```

Commands and their descriptions are listed below:

| Command | Description |
| ------- | ----------- |
| `--json` | Output features as JSON |
| `--flat` | Output features as a flat array instead of nested structure |
| `--description` | Include feature descriptions in the output. The description is automatically included in the json format |
| `--list-owners` | Display only unique list of owners |
| `--find-owner <path>` | Find the owner of a specific file or folder |
| `--check` | Run validation checks on features (e.g., duplicate names) |
| `--skip-changes` | Skip computing git commit history (faster for large repos) |
| `--serve` | Start an HTTP server to serve features and the web dashboard UI |
| `--serve --port 8080` | Start an HTTP server on specified port |
| `--build` | Build a static version of the web dashboard UI |
| `--build-dir <path>` | Output directory for the static build (default: `build`) |
| `--coverage-dir <path>` | Specify a custom coverage directory (overrides automatic search) |
| `--generate-codeowners` | Generate or update a CODEOWNERS file with feature ownership information |
| `--project-dir <path>` | Project directory for CODEOWNERS generation and additional coverage search locations |

## Coverage Support

The CLI automatically searches for coverage reports in multiple locations:
- `base_path/.coverage` and `base_path/coverage` (path provided as first argument)
- `current_dir/.coverage` and `current_dir/coverage` (path the executable runs)
- `project_dir/.coverage` and `project_dir/coverage` (if `--project-dir` is provided)

Stops at the first directory containing coverage data. Use `--coverage-dir` to explicitly specify a coverage directory.

## CODEOWNERS Generation

Generate or update a CODEOWNERS file based on feature ownership:

```bash
# Generate CODEOWNERS in current directory
features ./src --generate-codeowners

# Generate CODEOWNERS in project directory with proper relative paths
features ./src --generate-codeowners --project-dir ./

# Can be combined with other commands
features ./src --generate-codeowners --build --project-dir ./
```

The generated CODEOWNERS file will have a managed section between markers:
```
# ==== GENERATED BY FEATURES-CLI ====
/src/features/feature-1 @team1
/src/features/feature-2 @team2
# ==== END SECTION GENERATED BY FEATURES-CLI ====
```

Any content outside these markers is preserved when regenerating.

## Contributing

From the CLI directory:

```bash

cargo run ../../examples/javascript-basic/src/features

# For the web dashboard
cd ../web
pnpm build_for_cli
cd ../cli

cargo run ../../examples/javascript-basic/src/features --serve # for the Web dashboard
```

## Deploy

```bash
cd ../web
pnpm build_for_cli
cd ../cli

cargo publish --allow-dirty
```