@go-labs-sg/bb 1.0.0 → 1.0.2

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 CHANGED
@@ -1,114 +1,84 @@
1
- # bb — Budget Builder CLI
1
+ # bb
2
2
 
3
- Lightweight CLI that wraps the same tRPC API used by the MCP server. For AI agents (e.g. Chuck/OpenClaw) that don’t support MCP: run `bb` from the shell and get JSON back.
3
+ Command-line interface for **Budget Builder**. Call budgets, bills, approvals, and suppliers from your terminal or from tools that don’t support MCP (e.g. some AI agents). Responses are JSON on stdout.
4
4
 
5
- **Why no workspace refs in the published package?**
6
- `workspace:*` only resolves inside your monorepo. When someone installs from npm (`npx @go-labs-sg/bb` or `npm i -g @go-labs-sg/bb`), their environment has no workspace, so the CLI is built with no runtime dependency on `@bb/api`, `@bb/db`, or `@bb/utils`. In the repo we keep `@bb/typescript-config` as a devDependency for typechecking; it is stripped from the tarball when publishing (or use a publish flow that omits workspace devDeps).
5
+ **Registry:** [`@go-labs-sg/bb`](https://www.npmjs.com/package/@go-labs-sg/bb)
7
6
 
8
- ## Auth
7
+ ## Requirements
9
8
 
10
- - Set **`BB_API_KEY`** in the environment (same API key as MCP / Goracle > API Keys).
11
- - The CLI targets the production API at `https://budget-builder.getout.events`.
9
+ - **Node.js** 18+
10
+ - A **Budget Builder API key** (same key used for the MCP server)
12
11
 
13
- ## Usage
14
-
15
- From the monorepo root:
12
+ ## Install
16
13
 
17
14
  ```bash
18
- export BB_API_KEY=your_api_key
19
- bun run bb -- list-budgets
20
- bun run bb -- get-budget <id>
21
- bun run bb -- update-budget-status <id> <status>
22
- bun run bb -- list-bills
23
- bun run bb -- approve-bill <id>
24
- bun run bb -- list-approvals
25
- bun run bb -- list-suppliers
15
+ npm install -g @go-labs-sg/bb
26
16
  ```
27
17
 
28
- Or from `packages/cli`:
18
+ Or run without installing:
29
19
 
30
20
  ```bash
31
- bun run src/index.ts list-budgets
21
+ npx @go-labs-sg/bb <command>
32
22
  ```
33
23
 
34
- ## Commands
35
-
36
- | Command | Description |
37
- |--------|-------------|
38
- | `list-budgets` | List budgets. Optional: `--projectId`, `--name`, `--status` (comma-separated), `--page`, `--perPage` |
39
- | `get-budget <id>` | Budget details + line items |
40
- | `update-budget-status <id> <status>` | Set status (e.g. `APPROVED`, `REJECTED`) |
41
- | `list-bills` | List bills. Optional: `--projectId`, `--budgetId`, `--status`, `--page`, `--pageSize` |
42
- | `approve-bill <id>` | Approve a pending bill |
43
- | `list-approvals` | Pending approvals. Optional: `--type` (budget \| supplier \| bill \| all) |
44
- | `list-suppliers` | List suppliers. Optional: `--name`, `--page`, `--perPage` |
45
-
46
- Output is JSON to stdout. Errors go to stderr and exit code 1.
24
+ ## Authentication
47
25
 
48
- ## Install from npm (for agents without the repo)
26
+ Set your API key before running commands:
49
27
 
50
28
  ```bash
51
- npx @go-labs-sg/bb list-budgets
52
- # or
53
- npm install -g @go-labs-sg/bb
54
- bb list-budgets
29
+ export BB_API_KEY=<your-key>
55
30
  ```
56
31
 
57
- Set `BB_API_KEY` in the environment before running.
58
-
59
- ## Testing (local)
32
+ Create or revoke keys in the web app: **Goracle → API Keys** (MCP API keys).
60
33
 
61
- 1. **Create an API key** in the web app: Goracle → API Keys → Create MCP API Key. Copy the key (shown once).
34
+ The CLI talks to the production API: `https://budget-builder.getout.events`.
62
35
 
63
- 2. **Start the web app** (or use a deployed URL):
64
- ```bash
65
- bun run web:dev
66
- ```
36
+ ## Usage
67
37
 
68
- 3. **Set env and run** from monorepo root:
69
- ```bash
70
- export BB_API_KEY=your_copied_key
71
- bun run bb -- list-budgets
72
- bun run bb -- list-suppliers
73
- ```
38
+ ```bash
39
+ bb help
40
+ bb list-budgets
41
+ bb get-budget <budget-id>
42
+ bb update-budget-status <budget-id> <status>
43
+ bb list-bills
44
+ bb approve-bill <bill-id>
45
+ bb list-approvals
46
+ bb list-suppliers
47
+ ```
74
48
 
75
- 4. **Verify JSON output** you should see structured JSON on stdout. Errors go to stderr with exit code 1.
49
+ Global options and flags use `--key=value` or `--key value` (see `bb help`).
76
50
 
77
- If you see `{"error":"Unable to connect..."}` — the production API may be unreachable or your network may be blocking the request.
51
+ ## Commands
78
52
 
79
- ## Private publishing (npm)
53
+ | Command | Description |
54
+ | --- | --- |
55
+ | `list-budgets` | List budgets. Flags: `--projectId`, `--name`, `--status` (comma-separated), `--page`, `--perPage` |
56
+ | `get-budget <id>` | Budget details and line items |
57
+ | `update-budget-status <id> <status>` | Change budget status (e.g. `APPROVED`, `REJECTED`, `DRAFT`, …) |
58
+ | `list-bills` | List bills. Flags: `--projectId`, `--budgetId`, `--status`, `--page`, `--pageSize` |
59
+ | `approve-bill <id>` | Approve a pending bill (matches your pending bill approvals) |
60
+ | `list-approvals` | Pending approvals. Flag: `--type` = `budget`, `supplier`, `bill`, or `all` |
61
+ | `list-suppliers` | List suppliers. Flags: `--name`, `--page`, `--perPage` |
80
62
 
81
- To publish privately:
63
+ ## Output
82
64
 
83
- 1. **Use a scoped package** (already `@go-labs-sg/bb`).
65
+ - **Stdout:** JSON (pretty-printed)
66
+ - **Stderr:** Error objects as JSON on failure
67
+ - **Exit code:** `0` on success, `1` on error
84
68
 
85
- 2. **Set `publishConfig`** in `package.json`:
86
- ```json
87
- "publishConfig": {
88
- "access": "restricted"
89
- }
90
- ```
91
- (`restricted` = private for scoped packages; `public` = public)
69
+ A `.env` file in the **current working directory** is loaded automatically (for `BB_API_KEY`, etc.).
92
70
 
93
- 3. **Ensure you're logged in** to npm and have access to the `@go-labs-sg` org:
94
- ```bash
95
- npm login
96
- npm org ls go-labs-sg # verify access
97
- ```
71
+ ## Developing in this repo
98
72
 
99
- 4. **Publish** from the CLI package:
100
- ```bash
101
- cd packages/cli
102
- npm publish
103
- ```
73
+ From the monorepo root:
104
74
 
105
- 5. **For Chuck/OpenClaw** — install from your private registry:
106
- ```bash
107
- npm install -g @go-labs-sg/bb
108
- # or
109
- npx @go-labs-sg/bb list-budgets
110
- ```
75
+ ```bash
76
+ export BB_API_KEY=...
77
+ bun run bb -- list-budgets
78
+ ```
111
79
 
112
- Set `BB_API_KEY` in the agent's environment.
80
+ Or from `packages/cli`:
113
81
 
114
- **Alternative: GitHub Packages** — use `@go-labs-sg/bb` with `registry: https://npm.pkg.github.com` and a `GITHUB_TOKEN` with `read:packages` / `write:packages`.
82
+ ```bash
83
+ bun run src/index.ts list-budgets
84
+ ```
package/dist/commands.js CHANGED
@@ -2,6 +2,12 @@ import { api } from "./api-client.js";
2
2
  const BUDGET = "BUDGET";
3
3
  const BILL = "BILL";
4
4
  const SUPPLIER = "SUPPLIER";
5
+ function isPendingRequest(n) {
6
+ return n.notificationType === "request" && n.status === "PENDING_APPROVAL";
7
+ }
8
+ function isApprovalType(s) {
9
+ return s === BUDGET || s === BILL || s === SUPPLIER;
10
+ }
5
11
  const out = (data) => {
6
12
  console.log(JSON.stringify(data, null, 2));
7
13
  };
@@ -43,9 +49,8 @@ export async function listBills(opts) {
43
49
  out(result);
44
50
  }
45
51
  export async function approveBill(billId) {
46
- const notifications = (await api.budget.getNotifications.query());
47
- const pending = notifications.filter((n) => n.notificationType === "request" &&
48
- n.status === "PENDING_APPROVAL" &&
52
+ const notifications = await api.budget.getNotifications.query();
53
+ const pending = notifications.filter((n) => isPendingRequest(n) &&
49
54
  n.type === BILL &&
50
55
  (n.billId === billId || n.bill?.id === billId));
51
56
  const approval = pending[0];
@@ -60,12 +65,12 @@ export async function approveBill(billId) {
60
65
  out({ ...result, success: true, message: "Bill approved" });
61
66
  }
62
67
  export async function listApprovals(opts) {
63
- const notifications = (await api.budget.getNotifications.query());
64
- const pending = notifications.filter((n) => n.notificationType === "request" && n.status === "PENDING_APPROVAL");
65
- const typeUpper = opts.type?.toUpperCase();
68
+ const notifications = await api.budget.getNotifications.query();
69
+ const pending = notifications.filter(isPendingRequest);
70
+ const raw = opts.type?.toUpperCase();
66
71
  const typeFilter = !opts.type || opts.type.toLowerCase() === "all"
67
- ? () => true
68
- : (n) => n.type === typeUpper;
72
+ ? (_n) => true
73
+ : (n) => raw !== undefined && isApprovalType(raw) && n.type === raw;
69
74
  const filtered = pending.filter(typeFilter);
70
75
  const items = filtered.map((n) => {
71
76
  let id;
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ Output: JSON to stdout. Errors to stderr and exit code 1.
48
48
  }
49
49
  async function main() {
50
50
  const { command, positional, flags } = parseArgs(process.argv);
51
- if (!command || command === "help" || flags["help"] === true) {
51
+ if (!command || command === "help" || flags.help === true) {
52
52
  printHelp();
53
53
  process.exit(0);
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-labs-sg/bb",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Budget Builder CLI — list budgets, bills, approvals, suppliers; approve bills; change status. For AI agents (e.g. Chuck/OpenClaw).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "check:write": "biome check --write .",
19
19
  "run": "bun run src/index.ts",
20
20
  "prepublishOnly": "node scripts/strip-workspace-deps.js && bun run build",
21
- "postpublish": "node scripts/restore-package-json.js"
21
+ "postpack": "node scripts/restore-package-json.js"
22
22
  },
23
23
  "dependencies": {
24
24
  "@trpc/client": "^11.10.0",