@poltergeist-ai/cli 0.1.5 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # @poltergeist-ai/cli
2
+
3
+ > Build contributor ghost profiles for simulated code reviews.
4
+
5
+ Poltergeist extracts a contributor's review style, coding patterns, and communication voice from git history, GitHub PRs, GitLab MRs, Slack messages, and design docs — then outputs a structured ghost profile that can be used to simulate their code reviews.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx @poltergeist-ai/cli extract [options]
11
+ ```
12
+
13
+ Or install globally:
14
+
15
+ ```bash
16
+ npm install -g @poltergeist-ai/cli
17
+ poltergeist extract [options]
18
+ ```
19
+
20
+ ### Set up skills for your AI coding tool
21
+
22
+ ```bash
23
+ npx @poltergeist-ai/cli setup
24
+ ```
25
+
26
+ This installs the poltergeist review and extract skills for Claude Code, Codex, Cursor, Windsurf, or Cline. You can also pass `--tool` to skip the interactive prompt:
27
+
28
+ ```bash
29
+ npx @poltergeist-ai/cli setup --tool claude-code,cursor
30
+ ```
31
+
32
+ Requires Node.js >= 18.17.0.
33
+
34
+ ## Usage
35
+
36
+ ### Basic: build a ghost from a local repo
37
+
38
+ ```bash
39
+ npx @poltergeist-ai/cli extract \
40
+ --contributor "Alice Smith" \
41
+ --email alice@company.com \
42
+ --git-repo .
43
+ ```
44
+
45
+ This mines git history for Alice's commits, coding patterns, and naming conventions. If the repo is hosted on GitHub, PR review comments are fetched automatically.
46
+
47
+ ### Full: combine multiple data sources
48
+
49
+ ```bash
50
+ npx @poltergeist-ai/cli extract \
51
+ --contributor "Alice Smith" \
52
+ --email alice@company.com \
53
+ --git-repo https://github.com/org/repo \
54
+ --gitlab-export ./exports/gitlab-notes.json \
55
+ --slack-export ./exports/slack/ \
56
+ --docs-dir ./docs/adrs/ \
57
+ --output .poltergeist/ghosts/alice-smith.md
58
+ ```
59
+
60
+ More sources produce a more accurate ghost. Review comments (GitHub/GitLab) are the single most valuable input for voice fidelity.
61
+
62
+ ### Remote repos
63
+
64
+ Pass a URL to `--git-repo` and the CLI clones it as a bare repo to `.poltergeist/repos/` (automatically added to `.gitignore`). Subsequent runs reuse the cache and fetch updates.
65
+
66
+ ```bash
67
+ npx @poltergeist-ai/cli extract \
68
+ --contributor "alice" \
69
+ --git-repo https://github.com/org/repo
70
+ ```
71
+
72
+ Use the contributor's GitHub username as `--contributor` for best results when extracting from GitHub repos — it matches against PR comment authors.
73
+
74
+ ### GitHub rate limits
75
+
76
+ For repos with many PRs, pass a personal access token to avoid rate limiting:
77
+
78
+ ```bash
79
+ npx @poltergeist-ai/cli extract \
80
+ --contributor "alice" \
81
+ --git-repo https://github.com/org/repo \
82
+ --github-token ghp_xxxxxxxxxxxx
83
+ ```
84
+
85
+ The CLI also reads `GITHUB_TOKEN` or `GITHUB_PERSONAL_ACCESS_TOKEN` from the environment, so you can skip the flag if either is set.
86
+
87
+ ## CLI reference
88
+
89
+ ```
90
+ Usage: poltergeist <command> [options]
91
+
92
+ Commands:
93
+ extract Build a contributor ghost profile from data sources
94
+ setup Install poltergeist skills for your AI coding tool
95
+
96
+ Extract options:
97
+ --contributor <name> Contributor name (required)
98
+ --email <email> Contributor email for git log filtering
99
+ --slug <slug> Output filename slug (default: derived from name)
100
+ --git-repo <path|url> Local repo path or remote URL
101
+ --gitlab-export <path> Path to GitLab MR comments JSON export
102
+ --slack-export <path> Path to Slack export directory
103
+ --docs-dir <path> Path to design docs / ADRs directory
104
+ --github-token <token> GitHub PAT for higher API rate limits
105
+ --output <path> Output path (default: .poltergeist/ghosts/<slug>.md)
106
+ --verbose Enable verbose logging
107
+
108
+ Setup options:
109
+ --tool <id> Tool to install for (claude-code,codex,cursor,windsurf,cline)
110
+ Comma-separated for multiple. Omit to choose interactively.
111
+
112
+ --help Show help
113
+ ```
114
+
115
+ At least one data source (`--git-repo`, `--gitlab-export`, `--slack-export`, or `--docs-dir`) is required.
116
+
117
+ ## Data sources
118
+
119
+ | Source | Flag | What it extracts |
120
+ |---|---|---|
121
+ | Git history | `--git-repo` | Coding patterns, naming conventions, commit style, file ownership |
122
+ | GitHub PRs | Auto-detected from `--git-repo` URL | Review voice, severity prefixes, recurring phrases |
123
+ | GitLab MRs | `--gitlab-export` | Review voice, severity prefixes, recurring phrases |
124
+ | Slack | `--slack-export` | Informal technical voice, how they discuss code |
125
+ | Design docs | `--docs-dir` | Architecture reasoning, writing style, decision values |
126
+
127
+ ### Exporting GitLab MR comments
128
+
129
+ Use the `glab` CLI to export MR notes:
130
+
131
+ ```bash
132
+ glab api "projects/:fullpath/merge_requests?state=merged&per_page=100" \
133
+ | jq -r '.[].iid' \
134
+ | while read IID; do
135
+ glab api "projects/:fullpath/merge_requests/$IID/notes?per_page=100"
136
+ done \
137
+ | jq -s 'add' > gitlab-notes.json
138
+ ```
139
+
140
+ The expected format is a flat JSON array of note objects with `author.name`, `body`, and `type` fields. The extractor filters by contributor name. See [docs/gitlab-export.md](../../docs/gitlab-export.md) for details.
141
+
142
+ ### Exporting Slack messages
143
+
144
+ Use a Slack admin export (or workspace export) and point `--slack-export` at the directory. The extractor scans all channel JSON files for messages matching the contributor name.
145
+
146
+ ## Output
147
+
148
+ The CLI generates a ghost file in Markdown with these sections:
149
+
150
+ - **Identity** — name, slug, version, status, role, primary domains, sources used, generator version
151
+ - **Review Heuristics** — weighted dimensions table with confidence levels and default severities, tradeoff preferences, scars
152
+ - **Review philosophy** — ranked values, dealbreakers, what they ignore
153
+ - **Communication style** — tone, severity prefixes, vocabulary, comment length
154
+ - **Code patterns** — patterns they prefer, push back on, and commonly suggest
155
+ - **Known blind spots** — areas they historically under-review
156
+ - **Example review comments** — verbatim excerpts for voice grounding
157
+
158
+ The Review Heuristics table is auto-generated from review comment analysis — it drives priority and comment distribution during simulated reviews. Sections marked `[fill in manually]` need human input. The manual pass is the most important step — especially ranked values, tradeoff preferences, and example comments.
159
+
160
+ ### After extraction
161
+
162
+ 1. Open the ghost file and fill in all `[fill in manually]` sections
163
+ 2. Review the sample comments — they are the most important voice signal
164
+ 3. Validate with a teammate who knows the contributor
165
+ 4. Test with a review: `git diff main | claude "review as @alice-smith"`
166
+
167
+ ## Library API
168
+
169
+ The extractors and generator are available as ES module exports for programmatic use:
170
+
171
+ ```typescript
172
+ import {
173
+ extractGitSignals,
174
+ summariseGit,
175
+ extractGitHubSignals,
176
+ extractGitLabSignals,
177
+ summariseGitLab,
178
+ extractSlackSignals,
179
+ summariseSlack,
180
+ extractDocsSignals,
181
+ buildGhostMarkdown,
182
+ slugify,
183
+ } from "@poltergeist-ai/cli";
184
+ ```
185
+
186
+ Each data source follows the same pattern: an `extract*Signals()` function that reads raw data, and a `summarise*()` function that distills it into observations. Pass the observations to `buildGhostMarkdown()` to generate the output.
187
+
188
+ ```typescript
189
+ import {
190
+ extractGitSignals,
191
+ summariseGit,
192
+ extractCodeStyleFromDiff,
193
+ summariseCodeStyle,
194
+ buildGhostMarkdown,
195
+ } from "@poltergeist-ai/cli";
196
+
197
+ const gitSignals = extractGitSignals("/path/to/repo", "Alice Smith", "alice@co.com");
198
+ const gitObs = summariseGit(gitSignals);
199
+
200
+ const codeStyleSignals = extractCodeStyleFromDiff(gitSignals.rawDiffOutput ?? "");
201
+ const codeStyleObs = summariseCodeStyle(codeStyleSignals);
202
+
203
+ const markdown = buildGhostMarkdown({
204
+ contributor: "Alice Smith",
205
+ slug: "alice-smith",
206
+ gitObs,
207
+ codeStyleObs,
208
+ reviewObs: {},
209
+ slackObs: {},
210
+ docsSignals: { authoredDocs: [], docExcerpts: [] },
211
+ sourcesUsed: ["git-history"],
212
+ });
213
+ ```
214
+
215
+ ## Ethics
216
+
217
+ Ghost profiles simulate a contributor's review style. They are not that contributor. Always:
218
+
219
+ - Get contributor consent before building their ghost
220
+ - Keep ghosts up to date (mark stale after 6 months)
221
+ - Never use ghost reviews as sole merge approval
222
+ - Make simulation explicit (reviews include a footer)
223
+
224
+ See [docs/ethics.md](../../docs/ethics.md) for full guidelines.
225
+
226
+ ## License
227
+
228
+ MIT