|
| 1 | +# 🧠 chimp-core |
| 2 | + |
| 3 | +> Shared configuration and environment loader for the growing chimp toolchain. |
| 4 | +
|
| 5 | +This package contains the core logic for reading `.chimprc` config files, loading environment variables, and handling shared behavior between tools like `git-chimp`, `doc-chimp`, and `review-chimp`. |
| 6 | + |
| 7 | +## 📦 Installation |
| 8 | + |
| 9 | +Install via npm: |
| 10 | + |
| 11 | +```bash |
| 12 | +npm install chimp-core |
| 13 | +``` |
| 14 | + |
| 15 | +Or in a monorepo: |
| 16 | + |
| 17 | +```bash |
| 18 | +npm install --workspace=@chimp-stack/chimp-core |
| 19 | +``` |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## 🛠 Usage |
| 24 | + |
| 25 | +In your tool package (e.g., `git-chimp`, `review-chimp`), import and use the helpers: |
| 26 | + |
| 27 | +```ts |
| 28 | +import { loadChimpConfig, getEnv } from 'chimp-core'; |
| 29 | + |
| 30 | +const config = loadChimpConfig('gitChimp'); |
| 31 | +const env = getEnv(); |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## 📁 Config File: `.chimprc` |
| 37 | + |
| 38 | +This package looks for a `.chimprc` file in the current project or in your home directory (`~/.chimprc`). |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "gitChimp": { |
| 43 | + "model": "gpt-4", |
| 44 | + "tone": "dry sarcasm", |
| 45 | + "prMode": "draft" |
| 46 | + }, |
| 47 | + "reviewChimp": { |
| 48 | + "severity": "high" |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +The structure is namespaced per tool. You can override values via CLI flags if needed. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## 🌱 Environment Variables |
| 58 | + |
| 59 | +`getEnv()` returns validated environment variables from the current process or a `.env` file, if present. |
| 60 | + |
| 61 | +### Required Variables |
| 62 | + |
| 63 | +* `OPENAI_API_KEY` |
| 64 | +* (Optionally) `GITHUB_TOKEN` if using GitHub features |
| 65 | + |
| 66 | +Supports `.env` loading via [dotenv](https://www.npmjs.com/package/dotenv), but also works fine in environments where variables are set globally. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 🏗 Exported Functions |
| 71 | + |
| 72 | +| Function | Description | |
| 73 | +| -------------------------- | ----------------------------------------------------------------------------- | |
| 74 | +| `loadChimpConfig(scope)` | Loads config for the given tool (`gitChimp`, `docChimp`, etc) from `.chimprc` | |
| 75 | +| `getEnv()` | Validates and returns required environment variables (e.g., `OPENAI_API_KEY`) | |
| 76 | +| `resolveChimpConfigPath()` | Returns the resolved file path of the active `.chimprc` | |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## 🧪 Development |
| 81 | + |
| 82 | +### Build |
| 83 | + |
| 84 | +```bash |
| 85 | +npm run build |
| 86 | +``` |
| 87 | + |
| 88 | +This uses `tsup` to emit both ESM and CJS output to `dist/`. |
| 89 | + |
| 90 | +### Lint |
| 91 | + |
| 92 | +```bash |
| 93 | +npm run lint |
| 94 | +``` |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 🚀 Publishing |
| 99 | + |
| 100 | +This package can be independently published from the monorepo (if applicable) using `npm publish` or through CI pipelines like `semantic-release`. |
| 101 | + |
| 102 | +If used inside a Turborepo or other monorepo setup, make sure its `package.json` has a `name` field and correct `main`/`exports` paths for npm publishing. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## 🐒 Part of the Chimp Stack™ |
| 107 | + |
| 108 | +* [`git-chimp`](https://github.com/MarkRabey/git-chimp) – commit & PR generator |
| 109 | +* `doc-chimp` – auto-documentation from commits and code (WIP) |
| 110 | +* `review-chimp` – coming soon: let the monkey do your code reviews |
| 111 | +* `chimp-core` – this package |
| 112 | + |
| 113 | +*“Because even the best engineers deserve a monkey on their shoulder.”* |
0 commit comments