@braingrid/cli 0.2.12 → 0.2.13
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/CHANGELOG.md +17 -0
- package/README.md +61 -0
- package/dist/cli.js +161 -1
- package/dist/cli.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.13] - 2025-12-08
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Shell tab completion support**
|
|
15
|
+
- Added `braingrid completion` command to generate shell completion scripts
|
|
16
|
+
- Support for bash and zsh shells (fish support planned for future release)
|
|
17
|
+
- Automated setup with `braingrid completion --setup` flag
|
|
18
|
+
- Auto-detects shell from `$SHELL` environment variable
|
|
19
|
+
- Completes commands, subcommands, options, and values
|
|
20
|
+
- Includes status values (IDEA, PLANNED, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED)
|
|
21
|
+
- Includes format options (table, json, xml, markdown)
|
|
22
|
+
- Comprehensive documentation in README.md with installation instructions
|
|
23
|
+
- Uses omelette library for cross-shell compatibility
|
|
24
|
+
|
|
8
25
|
## [0.2.12] - 2025-12-05
|
|
9
26
|
|
|
10
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -258,6 +258,67 @@ braingrid --help # Show help information
|
|
|
258
258
|
|
|
259
259
|
---
|
|
260
260
|
|
|
261
|
+
## Shell Completion
|
|
262
|
+
|
|
263
|
+
BrainGrid CLI supports tab completion for bash and zsh shells, making it faster to type commands and discover available options.
|
|
264
|
+
|
|
265
|
+
### Quick Setup (Recommended)
|
|
266
|
+
|
|
267
|
+
Automatically install completion for your current shell:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
braingrid completion --setup
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Then restart your terminal or source your shell config:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# For bash
|
|
277
|
+
source ~/.bashrc
|
|
278
|
+
|
|
279
|
+
# For zsh
|
|
280
|
+
source ~/.zshrc
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Manual Installation
|
|
284
|
+
|
|
285
|
+
#### Bash
|
|
286
|
+
|
|
287
|
+
Add to your `~/.bashrc`:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Option 1: Add to shell config
|
|
291
|
+
braingrid completion bash >> ~/.bashrc
|
|
292
|
+
|
|
293
|
+
# Option 2: Eval in current session (temporary)
|
|
294
|
+
eval "$(braingrid completion bash)"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### Zsh
|
|
298
|
+
|
|
299
|
+
Add to your `~/.zshrc`:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Option 1: Add to shell config
|
|
303
|
+
braingrid completion zsh >> ~/.zshrc
|
|
304
|
+
|
|
305
|
+
# Option 2: Eval in current session (temporary)
|
|
306
|
+
eval "$(braingrid completion zsh)"
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### What Gets Completed
|
|
310
|
+
|
|
311
|
+
- **Commands**: `login`, `logout`, `project`, `requirement`, `task`, etc.
|
|
312
|
+
- **Subcommands**: `list`, `show`, `create`, `update`, `delete`, `breakdown`, `build`
|
|
313
|
+
- **Options**: `--help`, `--format`, `--status`, `--project`, `--requirement`
|
|
314
|
+
- **Values**: Status values (`IDEA`, `PLANNED`, `IN_PROGRESS`, etc.), format options (`table`, `json`, `xml`, `markdown`)
|
|
315
|
+
|
|
316
|
+
### Fish Shell
|
|
317
|
+
|
|
318
|
+
Fish shell support is planned for a future release.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
261
322
|
## Updating
|
|
262
323
|
|
|
263
324
|
Update to the latest version:
|
package/dist/cli.js
CHANGED
|
@@ -422,7 +422,7 @@ import axios3, { AxiosError as AxiosError2 } from "axios";
|
|
|
422
422
|
|
|
423
423
|
// src/build-config.ts
|
|
424
424
|
var BUILD_ENV = true ? "production" : process.env.NODE_ENV === "test" ? "development" : "production";
|
|
425
|
-
var CLI_VERSION = true ? "0.2.
|
|
425
|
+
var CLI_VERSION = true ? "0.2.13" : "0.0.0-test";
|
|
426
426
|
var PRODUCTION_CONFIG = {
|
|
427
427
|
apiUrl: "https://app.braingrid.ai",
|
|
428
428
|
workosAuthUrl: "https://auth.braingrid.ai",
|
|
@@ -6670,9 +6670,162 @@ async function handleUpdate(opts) {
|
|
|
6670
6670
|
}
|
|
6671
6671
|
}
|
|
6672
6672
|
|
|
6673
|
+
// src/handlers/completion.handlers.ts
|
|
6674
|
+
import chalk15 from "chalk";
|
|
6675
|
+
|
|
6676
|
+
// src/completion/index.ts
|
|
6677
|
+
import omelette from "omelette";
|
|
6678
|
+
import { homedir } from "os";
|
|
6679
|
+
import { join as join3 } from "path";
|
|
6680
|
+
var SUPPORTED_SHELLS = ["bash", "zsh"];
|
|
6681
|
+
function createCompletion() {
|
|
6682
|
+
const completion = omelette("braingrid <command> <subcommand>");
|
|
6683
|
+
completion.on("command", ({ reply }) => {
|
|
6684
|
+
reply([
|
|
6685
|
+
"login",
|
|
6686
|
+
"logout",
|
|
6687
|
+
"whoami",
|
|
6688
|
+
"status",
|
|
6689
|
+
"init",
|
|
6690
|
+
"update",
|
|
6691
|
+
"specify",
|
|
6692
|
+
"setup",
|
|
6693
|
+
"project",
|
|
6694
|
+
"requirement",
|
|
6695
|
+
"task",
|
|
6696
|
+
"completion"
|
|
6697
|
+
]);
|
|
6698
|
+
});
|
|
6699
|
+
completion.on("setup", ({ reply }) => {
|
|
6700
|
+
reply(["claude-code", "cursor"]);
|
|
6701
|
+
});
|
|
6702
|
+
completion.on("project", ({ reply }) => {
|
|
6703
|
+
reply(["list", "show", "create", "update", "delete"]);
|
|
6704
|
+
});
|
|
6705
|
+
completion.on("requirement", ({ reply }) => {
|
|
6706
|
+
reply(["list", "show", "create", "update", "delete", "breakdown", "build"]);
|
|
6707
|
+
});
|
|
6708
|
+
completion.on("task", ({ reply }) => {
|
|
6709
|
+
reply(["list", "summary", "show", "create", "update", "delete"]);
|
|
6710
|
+
});
|
|
6711
|
+
completion.on("completion", ({ reply }) => {
|
|
6712
|
+
reply(["bash", "zsh"]);
|
|
6713
|
+
});
|
|
6714
|
+
return completion;
|
|
6715
|
+
}
|
|
6716
|
+
function initCompletion() {
|
|
6717
|
+
const completion = createCompletion();
|
|
6718
|
+
completion.init();
|
|
6719
|
+
}
|
|
6720
|
+
function detectShell() {
|
|
6721
|
+
const shellPath = process.env.SHELL || "";
|
|
6722
|
+
const shellName = shellPath.split("/").pop()?.toLowerCase();
|
|
6723
|
+
if (shellName === "bash" || shellName === "zsh") {
|
|
6724
|
+
return shellName;
|
|
6725
|
+
}
|
|
6726
|
+
return null;
|
|
6727
|
+
}
|
|
6728
|
+
function getShellConfigPath(shell) {
|
|
6729
|
+
const home = homedir();
|
|
6730
|
+
switch (shell) {
|
|
6731
|
+
case "bash":
|
|
6732
|
+
return join3(home, ".bashrc");
|
|
6733
|
+
case "zsh":
|
|
6734
|
+
return join3(home, ".zshrc");
|
|
6735
|
+
}
|
|
6736
|
+
}
|
|
6737
|
+
function generateCompletionScript(shell) {
|
|
6738
|
+
const completion = createCompletion();
|
|
6739
|
+
return completion.setupShellInitFile(shell);
|
|
6740
|
+
}
|
|
6741
|
+
function setupCompletion(shell) {
|
|
6742
|
+
const completion = createCompletion();
|
|
6743
|
+
completion.setupShellInitFile(shell);
|
|
6744
|
+
}
|
|
6745
|
+
|
|
6746
|
+
// src/handlers/completion.handlers.ts
|
|
6747
|
+
function getUnsupportedShellError() {
|
|
6748
|
+
return {
|
|
6749
|
+
success: false,
|
|
6750
|
+
message: chalk15.red("\u274C Could not detect shell type.\n\n") + chalk15.dim("Please specify a shell:\n") + chalk15.cyan(" braingrid completion bash\n") + chalk15.cyan(" braingrid completion zsh\n\n") + chalk15.dim("Supported shells: bash, zsh")
|
|
6751
|
+
};
|
|
6752
|
+
}
|
|
6753
|
+
async function handleCompletion(shellArg, opts) {
|
|
6754
|
+
try {
|
|
6755
|
+
let shell = null;
|
|
6756
|
+
if (shellArg) {
|
|
6757
|
+
if (SUPPORTED_SHELLS.includes(shellArg)) {
|
|
6758
|
+
shell = shellArg;
|
|
6759
|
+
} else {
|
|
6760
|
+
return getUnsupportedShellError();
|
|
6761
|
+
}
|
|
6762
|
+
} else if (opts?.shell) {
|
|
6763
|
+
if (SUPPORTED_SHELLS.includes(opts.shell)) {
|
|
6764
|
+
shell = opts.shell;
|
|
6765
|
+
} else {
|
|
6766
|
+
return getUnsupportedShellError();
|
|
6767
|
+
}
|
|
6768
|
+
} else {
|
|
6769
|
+
shell = detectShell();
|
|
6770
|
+
}
|
|
6771
|
+
if (!shell) {
|
|
6772
|
+
return getUnsupportedShellError();
|
|
6773
|
+
}
|
|
6774
|
+
if (opts?.setup) {
|
|
6775
|
+
try {
|
|
6776
|
+
setupCompletion(shell);
|
|
6777
|
+
const configPath = getShellConfigPath(shell);
|
|
6778
|
+
return {
|
|
6779
|
+
success: true,
|
|
6780
|
+
message: chalk15.green(`\u2705 Completion installed for ${shell}
|
|
6781
|
+
|
|
6782
|
+
`) + chalk15.dim("To activate in your current shell, run:\n") + chalk15.cyan(` source ${configPath}
|
|
6783
|
+
|
|
6784
|
+
`) + chalk15.dim("Or restart your terminal.")
|
|
6785
|
+
};
|
|
6786
|
+
} catch (error) {
|
|
6787
|
+
return {
|
|
6788
|
+
success: false,
|
|
6789
|
+
message: chalk15.red("\u274C Failed to install completion\n\n") + chalk15.dim("Error: ") + formatError(error)
|
|
6790
|
+
};
|
|
6791
|
+
}
|
|
6792
|
+
}
|
|
6793
|
+
try {
|
|
6794
|
+
const script = generateCompletionScript(shell);
|
|
6795
|
+
const configPath = getShellConfigPath(shell);
|
|
6796
|
+
const instructions = chalk15.blue(`# BrainGrid CLI completion for ${shell}
|
|
6797
|
+
`) + chalk15.dim("# To install, run one of the following:\n\n") + chalk15.cyan(`# 1. Automatic installation (recommended):
|
|
6798
|
+
`) + chalk15.cyan(` braingrid completion --setup
|
|
6799
|
+
|
|
6800
|
+
`) + chalk15.cyan(`# 2. Add to your shell config:
|
|
6801
|
+
`) + chalk15.cyan(` braingrid completion ${shell} >> ${configPath}
|
|
6802
|
+
|
|
6803
|
+
`) + chalk15.cyan(`# 3. Source directly (temporary, current session only):
|
|
6804
|
+
`) + chalk15.cyan(` eval "$(braingrid completion ${shell})"
|
|
6805
|
+
|
|
6806
|
+
`) + chalk15.dim("# Completion script:\n\n");
|
|
6807
|
+
return {
|
|
6808
|
+
success: true,
|
|
6809
|
+
message: instructions + script
|
|
6810
|
+
};
|
|
6811
|
+
} catch (error) {
|
|
6812
|
+
return {
|
|
6813
|
+
success: false,
|
|
6814
|
+
message: chalk15.red("\u274C Failed to generate completion script\n\n") + chalk15.dim("Error: ") + formatError(error)
|
|
6815
|
+
};
|
|
6816
|
+
}
|
|
6817
|
+
} catch (error) {
|
|
6818
|
+
return {
|
|
6819
|
+
success: false,
|
|
6820
|
+
message: formatError(error)
|
|
6821
|
+
};
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
|
|
6673
6825
|
// src/cli.ts
|
|
6674
6826
|
var require2 = createRequire(import.meta.url);
|
|
6675
6827
|
var packageJson = require2("../package.json");
|
|
6828
|
+
initCompletion();
|
|
6676
6829
|
var program = new Command();
|
|
6677
6830
|
program.name("braingrid").description("BrainGrid CLI - Manage projects, requirements, and tasks").version(packageJson.version, "-v, --version", "output the current version").showHelpAfterError("(use --help for usage)");
|
|
6678
6831
|
program.command("login").description("Authenticate with BrainGrid").action(async () => {
|
|
@@ -6896,5 +7049,12 @@ task.command("delete <id>").description("Delete a task").option("-r, --requireme
|
|
|
6896
7049
|
process.exit(1);
|
|
6897
7050
|
}
|
|
6898
7051
|
});
|
|
7052
|
+
program.command("completion [shell]").description("Generate shell completion script (bash, zsh)").option("--setup", "automatically install completion for current shell").option("-s, --shell <shell>", "shell type (bash, zsh)").action(async (shell, opts) => {
|
|
7053
|
+
const result = await handleCompletion(shell, opts);
|
|
7054
|
+
console.log(result.message);
|
|
7055
|
+
if (!result.success) {
|
|
7056
|
+
process.exit(1);
|
|
7057
|
+
}
|
|
7058
|
+
});
|
|
6899
7059
|
program.parse();
|
|
6900
7060
|
//# sourceMappingURL=cli.js.map
|