@agentbrain/cli 1.0.0
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 +313 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +77 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/handoff.d.ts +3 -0
- package/dist/commands/handoff.d.ts.map +1 -0
- package/dist/commands/handoff.js +72 -0
- package/dist/commands/handoff.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +100 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/standards.d.ts +3 -0
- package/dist/commands/standards.d.ts.map +1 -0
- package/dist/commands/standards.js +125 -0
- package/dist/commands/standards.js.map +1 -0
- package/dist/display.d.ts +57 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +112 -0
- package/dist/display.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# @agentbrain/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for AgentBrain - generate smart context documentation for coding agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @agentbrain/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Configure your API key
|
|
15
|
+
agentbrain config
|
|
16
|
+
|
|
17
|
+
# Generate context docs for your repository
|
|
18
|
+
cd /path/to/your/project
|
|
19
|
+
agentbrain init
|
|
20
|
+
|
|
21
|
+
# Generate coding standards
|
|
22
|
+
agentbrain standards
|
|
23
|
+
|
|
24
|
+
# Generate session handoff
|
|
25
|
+
agentbrain handoff
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
### `agentbrain init`
|
|
31
|
+
|
|
32
|
+
Generate comprehensive context documentation for your repository.
|
|
33
|
+
|
|
34
|
+
**Usage:**
|
|
35
|
+
```bash
|
|
36
|
+
agentbrain init [options]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Options:**
|
|
40
|
+
- `--path <path>` - Repository path (default: current directory)
|
|
41
|
+
- `--max-files <number>` - Maximum files to analyze (default: 100)
|
|
42
|
+
- `--no-cache` - Skip cache and regenerate
|
|
43
|
+
- `--dry-run` - Preview without generating (free!)
|
|
44
|
+
|
|
45
|
+
**Output:**
|
|
46
|
+
Creates three files in `agentbrain/` directory:
|
|
47
|
+
- `context.md` - Full repository intelligence
|
|
48
|
+
- `dependency-map.md` - Service relationships and dependencies
|
|
49
|
+
- `patterns.md` - Coding patterns and conventions
|
|
50
|
+
|
|
51
|
+
**Example:**
|
|
52
|
+
```bash
|
|
53
|
+
# Preview cost first (free)
|
|
54
|
+
agentbrain init --dry-run
|
|
55
|
+
|
|
56
|
+
# Generate for current directory
|
|
57
|
+
agentbrain init
|
|
58
|
+
|
|
59
|
+
# Generate for specific path with custom limit
|
|
60
|
+
agentbrain init --path ~/my-project --max-files 50
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Cost:** ~$0.02-0.05 for typical repositories (cached repeats are free)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### `agentbrain standards`
|
|
68
|
+
|
|
69
|
+
Generate coding standards files for AI agents.
|
|
70
|
+
|
|
71
|
+
**Usage:**
|
|
72
|
+
```bash
|
|
73
|
+
agentbrain standards [options]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Options:**
|
|
77
|
+
- `--path <path>` - Repository path (default: current directory)
|
|
78
|
+
|
|
79
|
+
**Interactive prompts:**
|
|
80
|
+
- Primary language (e.g., TypeScript, Python)
|
|
81
|
+
- Framework (e.g., React, Django)
|
|
82
|
+
- Testing library (e.g., Jest, pytest)
|
|
83
|
+
- Style guide (e.g., Prettier + ESLint)
|
|
84
|
+
- Anti-patterns to avoid
|
|
85
|
+
- Architecture notes
|
|
86
|
+
- Target agents (Claude Code, Cursor, Windsurf)
|
|
87
|
+
|
|
88
|
+
**Output:**
|
|
89
|
+
Creates agent-specific files:
|
|
90
|
+
- `CLAUDE.md` - For Claude Code
|
|
91
|
+
- `.cursor/rules` - For Cursor
|
|
92
|
+
- `.windsurfrules` - For Windsurf
|
|
93
|
+
|
|
94
|
+
**Example:**
|
|
95
|
+
```bash
|
|
96
|
+
agentbrain standards
|
|
97
|
+
# Follow the interactive prompts
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Cost:** ~$0.01-0.02
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### `agentbrain handoff`
|
|
105
|
+
|
|
106
|
+
Generate session handoff document from git changes.
|
|
107
|
+
|
|
108
|
+
**Usage:**
|
|
109
|
+
```bash
|
|
110
|
+
agentbrain handoff [options]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Options:**
|
|
114
|
+
- `--path <path>` - Repository path (default: current directory)
|
|
115
|
+
- `--goal <goal>` - Session goal or objective
|
|
116
|
+
|
|
117
|
+
**Output:**
|
|
118
|
+
Creates `agentbrain/handoff.md` with:
|
|
119
|
+
- Summary of changes
|
|
120
|
+
- Current state
|
|
121
|
+
- Context & decisions
|
|
122
|
+
- Next steps
|
|
123
|
+
- Blockers & questions
|
|
124
|
+
|
|
125
|
+
**Example:**
|
|
126
|
+
```bash
|
|
127
|
+
# After making changes
|
|
128
|
+
agentbrain handoff --goal "Implement user authentication"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Cost:** ~$0.01
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### `agentbrain config`
|
|
136
|
+
|
|
137
|
+
Configure or view API key.
|
|
138
|
+
|
|
139
|
+
**Usage:**
|
|
140
|
+
```bash
|
|
141
|
+
agentbrain config [options]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Options:**
|
|
145
|
+
- `--show` - Display current configuration
|
|
146
|
+
|
|
147
|
+
**Example:**
|
|
148
|
+
```bash
|
|
149
|
+
# Set API key interactively
|
|
150
|
+
agentbrain config
|
|
151
|
+
|
|
152
|
+
# View current config
|
|
153
|
+
agentbrain config --show
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Supported providers:**
|
|
157
|
+
- Anthropic (Claude) - keys starting with `sk-ant-`
|
|
158
|
+
- OpenAI (GPT) - keys starting with `sk-`
|
|
159
|
+
|
|
160
|
+
Configuration stored at `~/.agentbrain/config.json` with secure permissions.
|
|
161
|
+
|
|
162
|
+
## Environment Variables
|
|
163
|
+
|
|
164
|
+
Instead of storing keys, you can use environment variables:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Anthropic
|
|
168
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
169
|
+
|
|
170
|
+
# OpenAI
|
|
171
|
+
export OPENAI_API_KEY="sk-..."
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Environment variables take priority over stored config.
|
|
175
|
+
|
|
176
|
+
## Usage with AI Agents
|
|
177
|
+
|
|
178
|
+
### Claude Code
|
|
179
|
+
|
|
180
|
+
Add to your workspace:
|
|
181
|
+
```markdown
|
|
182
|
+
<!-- In CLAUDE.md or prompt -->
|
|
183
|
+
@agentbrain/context.md
|
|
184
|
+
@agentbrain/dependency-map.md
|
|
185
|
+
@agentbrain/patterns.md
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Cursor
|
|
189
|
+
|
|
190
|
+
Cursor automatically loads `.cursor/rules` generated by `agentbrain standards`.
|
|
191
|
+
|
|
192
|
+
### Windsurf
|
|
193
|
+
|
|
194
|
+
Windsurf automatically loads `.windsurfrules` generated by `agentbrain standards`.
|
|
195
|
+
|
|
196
|
+
## Cost Estimates
|
|
197
|
+
|
|
198
|
+
All costs are approximate (as of January 2025):
|
|
199
|
+
|
|
200
|
+
| Operation | Tokens | Anthropic | OpenAI |
|
|
201
|
+
|-----------|--------|-----------|--------|
|
|
202
|
+
| Init (small) | 10-20K | $0.02-0.05 | $0.02-0.04 |
|
|
203
|
+
| Init (medium) | 30-50K | $0.08-0.15 | $0.07-0.12 |
|
|
204
|
+
| Standards | 5-8K | $0.01-0.02 | $0.01-0.02 |
|
|
205
|
+
| Handoff | 3-5K | $0.01 | $0.01 |
|
|
206
|
+
| **Cached repeat** | 0 | **$0.00** | **$0.00** |
|
|
207
|
+
|
|
208
|
+
**Cache-first:** Repeat runs on same git commit are instant and free!
|
|
209
|
+
|
|
210
|
+
## Workflow Example
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# 1. Initial setup
|
|
214
|
+
cd /path/to/project
|
|
215
|
+
agentbrain config
|
|
216
|
+
|
|
217
|
+
# 2. Generate context (do once per repo)
|
|
218
|
+
agentbrain init --dry-run # Preview first
|
|
219
|
+
agentbrain init # Actually generate
|
|
220
|
+
|
|
221
|
+
# 3. Generate standards (do once per repo)
|
|
222
|
+
agentbrain standards
|
|
223
|
+
|
|
224
|
+
# 4. During development sessions
|
|
225
|
+
# ... make changes ...
|
|
226
|
+
agentbrain handoff --goal "Add authentication feature"
|
|
227
|
+
|
|
228
|
+
# 5. Regenerate context after major changes
|
|
229
|
+
agentbrain init # Only costs money if git hash changed
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Troubleshooting
|
|
233
|
+
|
|
234
|
+
### "No API key found"
|
|
235
|
+
|
|
236
|
+
Set your API key:
|
|
237
|
+
```bash
|
|
238
|
+
agentbrain config
|
|
239
|
+
# or
|
|
240
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### "Command not found: agentbrain"
|
|
244
|
+
|
|
245
|
+
Reinstall globally:
|
|
246
|
+
```bash
|
|
247
|
+
npm install -g @agentbrain/cli
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Permission errors
|
|
251
|
+
|
|
252
|
+
Fix npm permissions:
|
|
253
|
+
```bash
|
|
254
|
+
mkdir ~/.npm-global
|
|
255
|
+
npm config set prefix '~/.npm-global'
|
|
256
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
|
257
|
+
source ~/.bashrc
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Examples
|
|
261
|
+
|
|
262
|
+
### Generate docs for multiple projects
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
for project in ~/projects/*; do
|
|
266
|
+
echo "Processing $project..."
|
|
267
|
+
agentbrain init --path "$project"
|
|
268
|
+
done
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### CI/CD integration
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# In CI pipeline
|
|
275
|
+
export ANTHROPIC_API_KEY="${ANTHROPIC_KEY}"
|
|
276
|
+
agentbrain init --path . --no-cache
|
|
277
|
+
# Commit generated docs to repo
|
|
278
|
+
git add agentbrain/
|
|
279
|
+
git commit -m "Update context docs"
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Advanced Usage
|
|
283
|
+
|
|
284
|
+
### Custom file limits
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# For large repos, limit files
|
|
288
|
+
agentbrain init --max-files 50
|
|
289
|
+
|
|
290
|
+
# For small repos, increase limit
|
|
291
|
+
agentbrain init --max-files 200
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Force regeneration
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Skip cache even if git hash unchanged
|
|
298
|
+
agentbrain init --no-cache
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Related Packages
|
|
302
|
+
|
|
303
|
+
- [@agentbrain/core](../core) - Core library
|
|
304
|
+
- [@agentbrain/mcp-server](../mcp-server) - MCP server for agents
|
|
305
|
+
|
|
306
|
+
## Support
|
|
307
|
+
|
|
308
|
+
- GitHub Issues: [Report bugs](https://github.com/yourusername/agentbrain/issues)
|
|
309
|
+
- Documentation: [Full docs](https://github.com/yourusername/agentbrain)
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,wBAAgB,mBAAmB,IAAI,OAAO,CAkB7C"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Config command - set/view API key
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { input } from '@inquirer/prompts';
|
|
4
|
+
import { saveAPIKey, loadAPIKey, getConfigPath, detectProvider } from '@agentbrain/core';
|
|
5
|
+
import { success, error, info, warn } from '../display.js';
|
|
6
|
+
export function createConfigCommand() {
|
|
7
|
+
const cmd = new Command('config')
|
|
8
|
+
.description('Configure AgentBrain API key')
|
|
9
|
+
.option('--show', 'Show current configuration')
|
|
10
|
+
.action(async (options) => {
|
|
11
|
+
try {
|
|
12
|
+
if (options.show) {
|
|
13
|
+
await showConfig();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
await setConfig();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
error(err instanceof Error ? err.message : 'Configuration failed');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return cmd;
|
|
25
|
+
}
|
|
26
|
+
async function showConfig() {
|
|
27
|
+
const config = await loadAPIKey();
|
|
28
|
+
if (!config) {
|
|
29
|
+
info('No API key configured');
|
|
30
|
+
info(`Config file: ${getConfigPath()}`);
|
|
31
|
+
console.log('\nYou can set an API key with: agentbrain config');
|
|
32
|
+
console.log('Or use environment variables: ANTHROPIC_API_KEY or OPENAI_API_KEY');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const maskedKey = maskAPIKey(config.apiKey);
|
|
36
|
+
success(`API key configured: ${maskedKey}`);
|
|
37
|
+
info(`Provider: ${config.provider}`);
|
|
38
|
+
info(`Config file: ${getConfigPath()}`);
|
|
39
|
+
if (process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY) {
|
|
40
|
+
warn('Note: Environment variable will take priority over stored config');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function setConfig() {
|
|
44
|
+
console.log('\nš Configure API Key\n');
|
|
45
|
+
console.log('AgentBrain supports Anthropic (Claude) and OpenAI (GPT) APIs.');
|
|
46
|
+
console.log('Your key will be stored securely at:', getConfigPath());
|
|
47
|
+
console.log();
|
|
48
|
+
const apiKey = await input({
|
|
49
|
+
message: 'Enter your API key:',
|
|
50
|
+
validate: (value) => {
|
|
51
|
+
if (!value.trim()) {
|
|
52
|
+
return 'API key cannot be empty';
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
detectProvider(value.trim());
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return 'Invalid API key format. Must start with "sk-ant-" (Anthropic) or "sk-" (OpenAI)';
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const trimmedKey = apiKey.trim();
|
|
64
|
+
const provider = detectProvider(trimmedKey);
|
|
65
|
+
await saveAPIKey(trimmedKey);
|
|
66
|
+
success(`API key saved successfully!`);
|
|
67
|
+
info(`Provider: ${provider}`);
|
|
68
|
+
info(`Stored at: ${getConfigPath()}`);
|
|
69
|
+
console.log('\n⨠You can now run: agentbrain init');
|
|
70
|
+
}
|
|
71
|
+
function maskAPIKey(key) {
|
|
72
|
+
if (key.length <= 8) {
|
|
73
|
+
return '***';
|
|
74
|
+
}
|
|
75
|
+
return key.slice(0, 8) + '...' + key.slice(-4);
|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EAAE,CAAA;IAChC,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;IAE3C,MAAM,UAAU,CAAC,UAAU,CAAC,CAAA;IAE5B,OAAO,CAAC,6BAA6B,CAAC,CAAA;IACtC,IAAI,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IAC7B,IAAI,CAAC,cAAc,aAAa,EAAE,EAAE,CAAC,CAAA;IAErC,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAA;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,wBAAgB,oBAAoB,IAAI,OAAO,CAe9C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Handoff command - generate handoff.md from git diff
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { input } from '@inquirer/prompts';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { loadAIConfig, generateHandoff } from '@agentbrain/core';
|
|
9
|
+
import { displayBanner, success, error, info, spinner, displayGeneratedFiles } from '../display.js';
|
|
10
|
+
export function createHandoffCommand() {
|
|
11
|
+
const cmd = new Command('handoff')
|
|
12
|
+
.description('Generate handoff document from git diff')
|
|
13
|
+
.option('--path <path>', 'Repository path', process.cwd())
|
|
14
|
+
.option('--goal <goal>', 'Session goal or objective')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
try {
|
|
17
|
+
await runHandoff(options);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
error(err instanceof Error ? err.message : 'Handoff generation failed');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return cmd;
|
|
25
|
+
}
|
|
26
|
+
async function runHandoff(options) {
|
|
27
|
+
displayBanner();
|
|
28
|
+
const repoPath = resolve(options.path);
|
|
29
|
+
info(`Repository: ${repoPath}`);
|
|
30
|
+
// Load AI config
|
|
31
|
+
const aiConfig = await loadAIConfig();
|
|
32
|
+
info(`Using ${aiConfig.provider} API\n`);
|
|
33
|
+
// Get session goal if not provided
|
|
34
|
+
let goal = options.goal;
|
|
35
|
+
if (!goal) {
|
|
36
|
+
goal = await input({
|
|
37
|
+
message: 'Session goal (optional):',
|
|
38
|
+
default: '',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Generate handoff
|
|
42
|
+
const spin = spinner('Analyzing changes and generating handoff...');
|
|
43
|
+
const result = await generateHandoff({
|
|
44
|
+
repoPath,
|
|
45
|
+
aiConfig,
|
|
46
|
+
goal: goal || undefined,
|
|
47
|
+
});
|
|
48
|
+
spin.succeed('Handoff generation complete!');
|
|
49
|
+
// Write to disk
|
|
50
|
+
const outputDir = join(repoPath, 'agentbrain');
|
|
51
|
+
if (!existsSync(outputDir)) {
|
|
52
|
+
await mkdir(outputDir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
const filePath = join(outputDir, 'handoff.md');
|
|
55
|
+
await writeFile(filePath, result.doc.content, 'utf-8');
|
|
56
|
+
displayGeneratedFiles([
|
|
57
|
+
{ name: 'agentbrain/handoff.md', description: 'Session handoff document' },
|
|
58
|
+
]);
|
|
59
|
+
if (result.tokenCount > 0) {
|
|
60
|
+
const cost = aiConfig.provider === 'anthropic' ? result.tokenCount / 1_000_000 * 3.0 : result.tokenCount / 1_000_000 * 2.5;
|
|
61
|
+
info(`Tokens used: ${result.tokenCount.toLocaleString()} (~$${cost.toFixed(4)})`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
info('No AI tokens used (no changes detected)');
|
|
65
|
+
}
|
|
66
|
+
success('Handoff document generated!');
|
|
67
|
+
console.log('\nš Next steps:\n');
|
|
68
|
+
console.log(' ⢠Share agentbrain/handoff.md with the next developer or session');
|
|
69
|
+
console.log(' ⢠Reference it at the start of your next session for context');
|
|
70
|
+
console.log();
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAEnG,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;SAC/B,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,eAAe,EAAE,iBAAiB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;SACzD,MAAM,CAAC,eAAe,EAA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AAM,WAAW,CAAA;AA0BnC,wBAAgB,iBAAiB,IAAI,OAAO,CAiB3C"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Init command - generate context docs
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { confirm } from '@inquirer/prompts';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { loadAIConfig, generateContext, estimateContextCost, scanRepository, } from '@agentbrain/core';
|
|
9
|
+
import { displayBanner, success, error, info, spinner, displayFileTable, displayCostEstimate, displayActualCost, displayGeneratedFiles, displayNextSteps, displayProviderInfo, } from '../display.js';
|
|
10
|
+
export function createInitCommand() {
|
|
11
|
+
const cmd = new Command('init')
|
|
12
|
+
.description('Generate context documentation for your repository')
|
|
13
|
+
.option('--path <path>', 'Repository path', process.cwd())
|
|
14
|
+
.option('--max-files <number>', 'Maximum files to analyze', '100')
|
|
15
|
+
.option('--no-cache', 'Skip cache and regenerate')
|
|
16
|
+
.option('--dry-run', 'Show what would be generated without actually generating')
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
try {
|
|
19
|
+
await runInit(options);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
error(err instanceof Error ? err.message : 'Initialization failed');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return cmd;
|
|
27
|
+
}
|
|
28
|
+
async function runInit(options) {
|
|
29
|
+
displayBanner();
|
|
30
|
+
const repoPath = resolve(options.path);
|
|
31
|
+
const maxFiles = parseInt(options.maxFiles, 10);
|
|
32
|
+
const useCache = options.cache;
|
|
33
|
+
info(`Repository: ${repoPath}`);
|
|
34
|
+
// Load AI config
|
|
35
|
+
const aiConfig = await loadAIConfig();
|
|
36
|
+
displayProviderInfo(aiConfig.provider, aiConfig.models);
|
|
37
|
+
// Scan repository
|
|
38
|
+
const spin = spinner('Scanning repository...');
|
|
39
|
+
const scanResult = await scanRepository(repoPath, { maxFiles });
|
|
40
|
+
spin.succeed(`Found ${scanResult.totalFiles} files, selected ${scanResult.relevantFiles.length} relevant files`);
|
|
41
|
+
console.log();
|
|
42
|
+
displayFileTable(scanResult.relevantFiles, 8);
|
|
43
|
+
// Estimate cost
|
|
44
|
+
info('Estimating cost...');
|
|
45
|
+
const estimate = await estimateContextCost(repoPath, aiConfig, maxFiles);
|
|
46
|
+
displayCostEstimate(estimate);
|
|
47
|
+
if (options.dryRun) {
|
|
48
|
+
info('Dry run complete - no files generated');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Confirm generation
|
|
52
|
+
const confirmed = await confirm({
|
|
53
|
+
message: 'Generate context docs?',
|
|
54
|
+
default: true,
|
|
55
|
+
});
|
|
56
|
+
if (!confirmed) {
|
|
57
|
+
info('Cancelled');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Generate context
|
|
61
|
+
const genSpin = spinner('Generating context documents...');
|
|
62
|
+
let lastProgress = '';
|
|
63
|
+
const result = await generateContext({
|
|
64
|
+
repoPath,
|
|
65
|
+
aiConfig,
|
|
66
|
+
maxFiles,
|
|
67
|
+
useCache,
|
|
68
|
+
onProgress: (msg) => {
|
|
69
|
+
if (msg !== lastProgress) {
|
|
70
|
+
genSpin.text = msg;
|
|
71
|
+
lastProgress = msg;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
genSpin.succeed('Context generation complete!');
|
|
76
|
+
// Write files to disk
|
|
77
|
+
const outputDir = join(repoPath, 'agentbrain');
|
|
78
|
+
if (!existsSync(outputDir)) {
|
|
79
|
+
await mkdir(outputDir, { recursive: true });
|
|
80
|
+
}
|
|
81
|
+
for (const doc of result.docs) {
|
|
82
|
+
const fileName = `${doc.type}.md`;
|
|
83
|
+
const filePath = join(outputDir, fileName);
|
|
84
|
+
await writeFile(filePath, doc.content, 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
// Display summary
|
|
87
|
+
displayGeneratedFiles([
|
|
88
|
+
{ name: 'agentbrain/context.md', description: 'Full repo intelligence' },
|
|
89
|
+
{ name: 'agentbrain/dependency-map.md', description: 'Service relationships' },
|
|
90
|
+
{ name: 'agentbrain/patterns.md', description: 'Coding patterns' },
|
|
91
|
+
]);
|
|
92
|
+
displayActualCost(result.totalTokens, result.cost);
|
|
93
|
+
displayNextSteps([
|
|
94
|
+
'Add to your CLAUDE.md: @agentbrain/context.md',
|
|
95
|
+
'Run "agentbrain standards" to generate coding standards files',
|
|
96
|
+
'Run "agentbrain handoff" before ending sessions',
|
|
97
|
+
]);
|
|
98
|
+
success('AgentBrain initialization complete!');
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,aAAa,EACb,OAAO,EACP,KAAK,EACL,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AAEtB,MAAM,UAAU,iBAAiB;IAC/B,MAAM,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/C,sBAAsB;IACtB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;IAC9C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,IAAI,KAAK,CAAA;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAC1C,MAAM,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAED,kBAAkB;IAClB,qBAAqB,CAAC;QACpB,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,wBAAwB,EAAE;QACxE,EAAE,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,uBAAuB,EAAE;QAC9E,EAAE,IAAI,EAAE,wBAAwB,EAAE,WAAW,EAAE,iBAAiB,EAAE;KACnE,CAAC,CAAA;IAEF,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAElD,gBAAgB,CAAC;QACf,+CAA+C;QAC/C,+DAA+D;QAC/D,iDAAiD;KAClD,CAAC,CAAA;IAEF,OAAO,CAAC,qCAAqC,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../../src/commands/standards.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUnC,wBAAgB,sBAAsB,IAAI,OAAO,CAchD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Standards command - generate CLAUDE.md / .cursorrules / .windsurfrules
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { input, checkbox } from '@inquirer/prompts';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { join, dirname } from 'node:path';
|
|
8
|
+
import { loadAIConfig, generateStandards, AGENT_FILE_PATHS } from '@agentbrain/core';
|
|
9
|
+
import { displayBanner, success, error, info, spinner, displayGeneratedFiles } from '../display.js';
|
|
10
|
+
export function createStandardsCommand() {
|
|
11
|
+
const cmd = new Command('standards')
|
|
12
|
+
.description('Generate coding standards files for AI agents')
|
|
13
|
+
.option('--path <path>', 'Repository path', process.cwd())
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
try {
|
|
16
|
+
await runStandards(options);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
error(err instanceof Error ? err.message : 'Standards generation failed');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return cmd;
|
|
24
|
+
}
|
|
25
|
+
async function runStandards(options) {
|
|
26
|
+
displayBanner();
|
|
27
|
+
const repoPath = resolve(options.path);
|
|
28
|
+
info(`Repository: ${repoPath}`);
|
|
29
|
+
// Load AI config
|
|
30
|
+
const aiConfig = await loadAIConfig();
|
|
31
|
+
info(`Using ${aiConfig.provider} API\n`);
|
|
32
|
+
// Gather stack information
|
|
33
|
+
console.log('š Tell me about your stack:\n');
|
|
34
|
+
const language = await input({
|
|
35
|
+
message: 'Primary language:',
|
|
36
|
+
default: 'TypeScript',
|
|
37
|
+
});
|
|
38
|
+
const framework = await input({
|
|
39
|
+
message: 'Framework:',
|
|
40
|
+
default: 'Node.js',
|
|
41
|
+
});
|
|
42
|
+
const testingLib = await input({
|
|
43
|
+
message: 'Testing library:',
|
|
44
|
+
default: 'Jest',
|
|
45
|
+
});
|
|
46
|
+
const styleGuide = await input({
|
|
47
|
+
message: 'Style guide:',
|
|
48
|
+
default: 'Prettier + ESLint',
|
|
49
|
+
});
|
|
50
|
+
const antiPatternsInput = await input({
|
|
51
|
+
message: 'Anti-patterns to avoid (comma-separated):',
|
|
52
|
+
default: 'global state, any types, console.log in production',
|
|
53
|
+
});
|
|
54
|
+
const architectureNotes = await input({
|
|
55
|
+
message: 'Architecture notes:',
|
|
56
|
+
default: 'Clean architecture, dependency injection',
|
|
57
|
+
});
|
|
58
|
+
const antiPatterns = antiPatternsInput.split(',').map((s) => s.trim());
|
|
59
|
+
const stackAnswers = {
|
|
60
|
+
language,
|
|
61
|
+
framework,
|
|
62
|
+
testingLib,
|
|
63
|
+
styleGuide,
|
|
64
|
+
antiPatterns,
|
|
65
|
+
architectureNotes,
|
|
66
|
+
};
|
|
67
|
+
// Select target agents
|
|
68
|
+
const agents = await checkbox({
|
|
69
|
+
message: 'Generate standards for which agents?',
|
|
70
|
+
choices: [
|
|
71
|
+
{ name: 'Claude Code (CLAUDE.md)', value: 'claude-code', checked: true },
|
|
72
|
+
{ name: 'Cursor (.cursor/rules)', value: 'cursor', checked: true },
|
|
73
|
+
{ name: 'Windsurf (.windsurfrules)', value: 'windsurf', checked: true },
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
if (agents.length === 0) {
|
|
77
|
+
info('No agents selected, exiting');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Generate standards
|
|
81
|
+
const spin = spinner('Generating standards files...');
|
|
82
|
+
const output = await generateStandards({
|
|
83
|
+
repoPath,
|
|
84
|
+
aiConfig,
|
|
85
|
+
stackAnswers,
|
|
86
|
+
agents,
|
|
87
|
+
});
|
|
88
|
+
spin.succeed('Standards generation complete!');
|
|
89
|
+
// Write files to disk
|
|
90
|
+
const generatedFiles = [];
|
|
91
|
+
for (const agent of agents) {
|
|
92
|
+
const content = output[agent];
|
|
93
|
+
if (!content)
|
|
94
|
+
continue;
|
|
95
|
+
const filePath = join(repoPath, AGENT_FILE_PATHS[agent]);
|
|
96
|
+
const dir = dirname(filePath);
|
|
97
|
+
if (!existsSync(dir)) {
|
|
98
|
+
await mkdir(dir, { recursive: true });
|
|
99
|
+
}
|
|
100
|
+
await writeFile(filePath, content, 'utf-8');
|
|
101
|
+
const descriptions = {
|
|
102
|
+
'claude-code': 'Claude Code standards',
|
|
103
|
+
cursor: 'Cursor AI rules',
|
|
104
|
+
windsurf: 'Windsurf AI rules',
|
|
105
|
+
};
|
|
106
|
+
generatedFiles.push({
|
|
107
|
+
name: AGENT_FILE_PATHS[agent],
|
|
108
|
+
description: descriptions[agent],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
displayGeneratedFiles(generatedFiles);
|
|
112
|
+
success('Standards files generated successfully!');
|
|
113
|
+
console.log('\nš Next steps:\n');
|
|
114
|
+
if (agents.includes('claude-code')) {
|
|
115
|
+
console.log(' ⢠Claude Code will automatically load CLAUDE.md on session start');
|
|
116
|
+
}
|
|
117
|
+
if (agents.includes('cursor')) {
|
|
118
|
+
console.log(' ⢠Cursor will automatically apply .cursor/rules');
|
|
119
|
+
}
|
|
120
|
+
if (agents.includes('windsurf')) {
|
|
121
|
+
console.log(' ⢠Windsurf will automatically apply .windsurfrules');
|
|
122
|
+
}
|
|
123
|
+
console.log();
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=standards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standards.js","sourceRoot":"","sources":["../../src/commands/standards.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAA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AC,CAAA;IAErC,OAAO,CAAC,yCAAyC,CAAC,CAAA;IAElD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjC,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAA;IACnF,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;IAClE,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FileEntry, CostEstimate } from '@agentbrain/core';
|
|
2
|
+
/**
|
|
3
|
+
* Display welcome banner
|
|
4
|
+
*/
|
|
5
|
+
export declare function displayBanner(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Display success message
|
|
8
|
+
*/
|
|
9
|
+
export declare function success(message: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Display error message
|
|
12
|
+
*/
|
|
13
|
+
export declare function error(message: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Display info message
|
|
16
|
+
*/
|
|
17
|
+
export declare function info(message: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Display warning message
|
|
20
|
+
*/
|
|
21
|
+
export declare function warn(message: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Create a spinner
|
|
24
|
+
*/
|
|
25
|
+
export declare function spinner(text: string): import("ora").Ora;
|
|
26
|
+
/**
|
|
27
|
+
* Display file table
|
|
28
|
+
*/
|
|
29
|
+
export declare function displayFileTable(files: FileEntry[], maxRows?: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Display cost estimate
|
|
32
|
+
*/
|
|
33
|
+
export declare function displayCostEstimate(estimate: CostEstimate): void;
|
|
34
|
+
/**
|
|
35
|
+
* Display actual cost after generation
|
|
36
|
+
*/
|
|
37
|
+
export declare function displayActualCost(tokens: number, usd: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Display generated files summary
|
|
40
|
+
*/
|
|
41
|
+
export declare function displayGeneratedFiles(files: Array<{
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
}>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Display next steps
|
|
47
|
+
*/
|
|
48
|
+
export declare function displayNextSteps(steps: string[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Display provider info
|
|
51
|
+
*/
|
|
52
|
+
export declare function displayProviderInfo(provider: string, models: {
|
|
53
|
+
fast: string;
|
|
54
|
+
mid: string;
|
|
55
|
+
smart: string;
|
|
56
|
+
}): void;
|
|
57
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/D;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,qBAEnC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,MAAU,GAAG,IAAI,CAyB9E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAchE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAMnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAQ/F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAQtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMhH"}
|
package/dist/display.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// CLI UI helpers using chalk, ora, and cli-table3
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import Table from 'cli-table3';
|
|
5
|
+
/**
|
|
6
|
+
* Display welcome banner
|
|
7
|
+
*/
|
|
8
|
+
export function displayBanner() {
|
|
9
|
+
console.log(chalk.cyan.bold('\nš§ AgentBrain\n'));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Display success message
|
|
13
|
+
*/
|
|
14
|
+
export function success(message) {
|
|
15
|
+
console.log(chalk.green('ā'), message);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Display error message
|
|
19
|
+
*/
|
|
20
|
+
export function error(message) {
|
|
21
|
+
console.error(chalk.red('ā'), message);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Display info message
|
|
25
|
+
*/
|
|
26
|
+
export function info(message) {
|
|
27
|
+
console.log(chalk.blue('ā¹'), message);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Display warning message
|
|
31
|
+
*/
|
|
32
|
+
export function warn(message) {
|
|
33
|
+
console.log(chalk.yellow('ā '), message);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a spinner
|
|
37
|
+
*/
|
|
38
|
+
export function spinner(text) {
|
|
39
|
+
return ora(text).start();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Display file table
|
|
43
|
+
*/
|
|
44
|
+
export function displayFileTable(files, maxRows = 8) {
|
|
45
|
+
const table = new Table({
|
|
46
|
+
head: [chalk.cyan('File'), chalk.cyan('Language'), chalk.cyan('Size (KB)')],
|
|
47
|
+
colWidths: [50, 20, 15],
|
|
48
|
+
});
|
|
49
|
+
const displayFiles = files.slice(0, maxRows);
|
|
50
|
+
for (const file of displayFiles) {
|
|
51
|
+
table.push([
|
|
52
|
+
file.path.length > 47 ? '...' + file.path.slice(-44) : file.path,
|
|
53
|
+
file.language,
|
|
54
|
+
(file.size / 1024).toFixed(1),
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
if (files.length > maxRows) {
|
|
58
|
+
table.push([
|
|
59
|
+
chalk.gray(`... and ${files.length - maxRows} more files`),
|
|
60
|
+
chalk.gray(''),
|
|
61
|
+
chalk.gray(''),
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
console.log(table.toString());
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Display cost estimate
|
|
68
|
+
*/
|
|
69
|
+
export function displayCostEstimate(estimate) {
|
|
70
|
+
console.log(chalk.bold('\nš° Cost estimate:'));
|
|
71
|
+
for (const item of estimate.breakdown) {
|
|
72
|
+
console.log(` ${chalk.gray('ā¢')} ${item.label}: ${chalk.cyan(`~${item.tokens.toLocaleString()} tokens`)}`);
|
|
73
|
+
}
|
|
74
|
+
console.log(chalk.bold(`\n ā Total: ${chalk.cyan(`~${estimate.tokens.toLocaleString()} tokens`)} ${chalk.green(`(~$${estimate.usd.toFixed(4)})`)}\n`));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Display actual cost after generation
|
|
78
|
+
*/
|
|
79
|
+
export function displayActualCost(tokens, usd) {
|
|
80
|
+
console.log(chalk.bold(`\nšø Actual cost: ${chalk.cyan(`~${tokens.toLocaleString()} tokens`)} ${chalk.green(`(~$${usd.toFixed(4)})`)}\n`));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Display generated files summary
|
|
84
|
+
*/
|
|
85
|
+
export function displayGeneratedFiles(files) {
|
|
86
|
+
console.log(chalk.bold('\nš Generated files:\n'));
|
|
87
|
+
for (const file of files) {
|
|
88
|
+
console.log(` ${chalk.green('ā')} ${chalk.bold(file.name)} ā ${chalk.gray(file.description)}`);
|
|
89
|
+
}
|
|
90
|
+
console.log();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Display next steps
|
|
94
|
+
*/
|
|
95
|
+
export function displayNextSteps(steps) {
|
|
96
|
+
console.log(chalk.bold('\nš Next steps:\n'));
|
|
97
|
+
for (const step of steps) {
|
|
98
|
+
console.log(` ${chalk.gray('ā¢')} ${step}`);
|
|
99
|
+
}
|
|
100
|
+
console.log();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Display provider info
|
|
104
|
+
*/
|
|
105
|
+
export function displayProviderInfo(provider, models) {
|
|
106
|
+
console.log(chalk.bold(`\nš Using ${provider === 'anthropic' ? 'Anthropic' : 'OpenAI'} API\n`));
|
|
107
|
+
console.log(` ${chalk.gray('Fast model:')} ${chalk.cyan(models.fast)}`);
|
|
108
|
+
console.log(` ${chalk.gray('Mid model:')} ${chalk.cyan(models.mid)}`);
|
|
109
|
+
console.log(` ${chalk.gray('Smart model:')} ${chalk.cyan(models.smart)}`);
|
|
110
|
+
console.log();
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,MAAM,YAAY,CAAA;AAG9B;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAA;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,UAAkB,CAAC;IACtE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACtB,IAAI,EA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CLI entry point
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { createConfigCommand } from './commands/config.js';
|
|
5
|
+
import { createInitCommand } from './commands/init.js';
|
|
6
|
+
import { createStandardsCommand } from './commands/standards.js';
|
|
7
|
+
import { createHandoffCommand } from './commands/handoff.js';
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name('agentbrain')
|
|
11
|
+
.description('Generate smart context docs for coding agents')
|
|
12
|
+
.version('1.0.0');
|
|
13
|
+
// Add commands
|
|
14
|
+
program.addCommand(createInitCommand());
|
|
15
|
+
program.addCommand(createStandardsCommand());
|
|
16
|
+
program.addCommand(createHandoffCommand());
|
|
17
|
+
program.addCommand(createConfigCommand());
|
|
18
|
+
// Parse arguments
|
|
19
|
+
program.parse();
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,6BAA6B;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnB,eAAe;AACf,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACvC,OAAO,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAA;AAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAA;AAC1C,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAA;AAEzC,kBAAkB;AAClB,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentbrain/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI for AgentBrain - generate smart context documentation for coding agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agentbrain": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cli",
|
|
15
|
+
"ai",
|
|
16
|
+
"context",
|
|
17
|
+
"documentation",
|
|
18
|
+
"codebase",
|
|
19
|
+
"claude",
|
|
20
|
+
"cursor",
|
|
21
|
+
"windsurf",
|
|
22
|
+
"coding-agent"
|
|
23
|
+
],
|
|
24
|
+
"author": "AgentBrain",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/yourusername/agentbrain.git",
|
|
29
|
+
"directory": "packages/cli"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/yourusername/agentbrain/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/yourusername/agentbrain#readme",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc -p tsconfig.json",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@agentbrain/core": "*",
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"inquirer": "^12.4.0",
|
|
44
|
+
"chalk": "^5.4.1",
|
|
45
|
+
"ora": "^8.1.1",
|
|
46
|
+
"cli-table3": "^0.6.5"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.10.7",
|
|
50
|
+
"typescript": "^5.7.2"
|
|
51
|
+
}
|
|
52
|
+
}
|