# datamitsu

> Opinionated configuration management, extensible by design

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> **Alpha**: This project is in alpha. The configuration API is not yet stabilized and may change between versions.

## License

MIT - See [LICENSE](LICENSE) for details

## Contributing

This project is in early development. Contribution guidelines will be established as the project matures.

## Configuration Loading

datamitsu loads configuration in layers, each receiving the previous layer's result as input:

```text
default (embedded config.js)
  ↓
--before-config flags  (for library wrappers — runs before project config)
  ↓
auto-discovered  datamitsu.config.js,  datamitsu.config.mjs  or  datamitsu.config.ts  at git root
  ↓
--config flags  (for CI overrides — runs after project config)
  ↓
final merged Config
```

Each layer calls `getConfig(prevConfig)` and returns a new config that extends or overrides the previous one.

### Remote configs (inheritance)

Any config file can declare upstream configs it inherits from:

```ts
export function getRemoteConfigs() {
  return [{ url: "https://example.com/shared-base.ts", hash: "sha256:abcdef..." }];
}
```

The `hash` field (SHA-256) is **required** — datamitsu will refuse to download any remote config without it. Remote configs are resolved **before** `getConfig` is called on the current file — they are parents, not children. Remote configs can themselves have `getRemoteConfigs`, so the resolution is recursive depth-first.

### Library/wrapper pattern

A library that wraps datamitsu passes its config via `--before-config`. The project's auto-discovered `datamitsu.config.ts` naturally overrides it:

```text
library-base.ts  →  project/datamitsu.config.ts  →  final Config
```

## Examples

Usage examples for runtime-managed apps (multi-version isolation, UV isolation, PNPM plugins) are in [examples/](examples/).

## Research & References

For research notes and tool references, see [docs/research.md](docs/research.md).
