Skip to content

Commit bb37f11

Browse files
committed
chore: Add Prettier and format codebase (pb: MB-7ef)
- Added Prettier config/ignore and format scripts with CI check - Formatted source and docs to satisfy Prettier - Updated bun.lock and pebbles log
1 parent 05d9846 commit bb37f11

File tree

16 files changed

+455
-183
lines changed

16 files changed

+455
-183
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
bun-version: "latest"
1818
- name: Install deps
1919
run: bun install --frozen-lockfile
20+
- name: Format
21+
run: bun run format:check
2022
- name: Lint
2123
run: bun run lint
2224
- name: Typecheck

.pebbles/events.jsonl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,7 @@
166166
{"type":"create","timestamp":"2026-01-30T17:44:28.970096Z","issue_id":"MB-c3e","payload":{"description":"Break mb.ts into per-command modules and shared helpers; keep CLI behavior identical, improve maintainability, reduce file length.","priority":"2","title":"Refactor: split src/mb.ts into command modules","type":"task"}}
167167
{"type":"create","timestamp":"2026-01-30T17:44:35.60457Z","issue_id":"MB-4f7","payload":{"description":"Add tests for safety scanning (API key patterns, social engineering, decoding), rate limits, and command output schema; include regression tests for past bugs.","priority":"2","title":"Tests: expand safety + CLI coverage","type":"task"}}
168168
{"type":"create","timestamp":"2026-01-30T17:44:41.621403Z","issue_id":"MB-e66","payload":{"description":"Make qmd indexing incremental and fail-soft; add caching of embeddings, avoid re-embedding unchanged collections, surface qmd status in CLI, and improve timeout/backoff behavior.","priority":"2","title":"Improve qmd integration","type":"task"}}
169+
{"type":"create","timestamp":"2026-01-30T18:10:05.969649Z","issue_id":"MB-7ef","payload":{"description":"Add Prettier config, scripts, and CI check for formatting.","priority":"2","title":"CI: add Prettier formatting","type":"task"}}
170+
{"type":"status_update","timestamp":"2026-01-30T18:10:12.013175Z","issue_id":"MB-7ef","payload":{"status":"in_progress"}}
171+
{"type":"comment","timestamp":"2026-01-30T18:35:19.501907Z","issue_id":"MB-7ef","payload":{"body":"COMPLETE: added Prettier config, scripts, ignore file, and CI format check; formatted repository."}}
172+
{"type":"close","timestamp":"2026-01-30T18:35:28.757619Z","issue_id":"MB-7ef","payload":{}}

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.local/
4+
.pebbles/
5+
coverage/

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": false,
4+
"trailingComma": "all"
5+
}

DESIGN.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
All safety filtering runs locally. No data leaves the machine. We reuse the same model stack as [qmd](https://github.com/user/qmd):
66

7-
| Component | Model | Size | Location |
8-
|-----------|-------|------|----------|
9-
| **Embeddings** | `embeddinggemma-300M` | ~300MB | `~/.cache/qmd/models/` |
10-
| **Reranker** | `qwen3-reranker-0.6b` | ~639MB | `~/.cache/qmd/models/` |
11-
| **Query expansion** | `Qwen3-0.6B` | ~600MB | `~/.cache/qmd/models/` |
7+
| Component | Model | Size | Location |
8+
| ------------------- | --------------------- | ------ | ---------------------- |
9+
| **Embeddings** | `embeddinggemma-300M` | ~300MB | `~/.cache/qmd/models/` |
10+
| **Reranker** | `qwen3-reranker-0.6b` | ~639MB | `~/.cache/qmd/models/` |
11+
| **Query expansion** | `Qwen3-0.6B` | ~600MB | `~/.cache/qmd/models/` |
1212

1313
All models run on Apple Silicon via MLX. Total footprint ~1.5GB on disk, fast inference on M-series chips.
1414

@@ -29,6 +29,7 @@ Before any outgoing message (post, comment, DM) leaves the machine, we check it
2929
### Example
3030

3131
Sensitive facts collection:
32+
3233
```
3334
Eric Helal, full name
3435
+1 (816) 729-5454, phone number
@@ -101,7 +102,7 @@ Agent
101102
mb-cli
102103
├── Outbound filter ──→ Sensitive facts collection (local embeddings)
103104
│ └── Block if threshold exceeded
104-
├── Inbound filter ──→ Jailbreak pattern library (local embeddings)
105+
├── Inbound filter ──→ Jailbreak pattern library (local embeddings)
105106
│ └── Flag with warning header
106107
└── Moltbook API ←──→ REST calls
107108
```

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -159,45 +159,45 @@ mb --profile tom secrets list
159159

160160
## Command Reference
161161

162-
| Command | Description |
163-
|---------|-------------|
164-
| `register` | Register a new agent on Moltbook |
165-
| `claim` | Check/wait for Twitter claim verification |
166-
| `verify` | Show verification code |
167-
| `whoami` | Show current agent profile |
168-
| `feed` | View personalized feed |
169-
| `posts list` | List posts (global or `--mine`) |
170-
| `posts create` | Create a post |
171-
| `comments list <id>` | List comments on a post |
172-
| `comments add <id>` | Add a comment |
173-
| `comments reply <id>` | Reply to a comment |
174-
| `vote up/down <id>` | Vote on a post |
175-
| `search <query>` | Search posts, agents, submolts |
176-
| `follow add/remove/list` | Manage follows |
177-
| `dm check` | Check DM requests and unread |
178-
| `dm list/show/send` | Manage DM conversations |
179-
| `dm request` | Request a new DM conversation |
180-
| `secrets add/list/remove` | Manage sensitive facts |
181-
| `safety scan` | Manually scan text for safety |
182-
| `auth status` | Check authentication status |
183-
| `profile show/update` | View/update agent profile |
184-
| `submolts list/subscribe` | Browse and subscribe to submolts |
185-
| `version` | Show version and build flags |
162+
| Command | Description |
163+
| ------------------------- | ----------------------------------------- |
164+
| `register` | Register a new agent on Moltbook |
165+
| `claim` | Check/wait for Twitter claim verification |
166+
| `verify` | Show verification code |
167+
| `whoami` | Show current agent profile |
168+
| `feed` | View personalized feed |
169+
| `posts list` | List posts (global or `--mine`) |
170+
| `posts create` | Create a post |
171+
| `comments list <id>` | List comments on a post |
172+
| `comments add <id>` | Add a comment |
173+
| `comments reply <id>` | Reply to a comment |
174+
| `vote up/down <id>` | Vote on a post |
175+
| `search <query>` | Search posts, agents, submolts |
176+
| `follow add/remove/list` | Manage follows |
177+
| `dm check` | Check DM requests and unread |
178+
| `dm list/show/send` | Manage DM conversations |
179+
| `dm request` | Request a new DM conversation |
180+
| `secrets add/list/remove` | Manage sensitive facts |
181+
| `safety scan` | Manually scan text for safety |
182+
| `auth status` | Check authentication status |
183+
| `profile show/update` | View/update agent profile |
184+
| `submolts list/subscribe` | Browse and subscribe to submolts |
185+
| `version` | Show version and build flags |
186186

187187
## Global Flags
188188

189-
| Flag | Description |
190-
|------|-------------|
191-
| `--profile <name>` | Select agent profile |
192-
| `--json` | JSON output (for scripting) |
193-
| `--dry-run` | Preview request without sending |
194-
| `--verbose` | Show request URLs and timing |
195-
| `--quiet` | Suppress non-essential output |
196-
| `--allow-sensitive` | Override outbound safety block |
197-
| `--yes` | Skip confirmations |
198-
| `--wait` | Wait when rate limited |
199-
| `--max-wait <sec>` | Max wait for rate limits (default: 600) |
200-
| `--no-color` | Disable color output |
189+
| Flag | Description |
190+
| ------------------- | --------------------------------------- |
191+
| `--profile <name>` | Select agent profile |
192+
| `--json` | JSON output (for scripting) |
193+
| `--dry-run` | Preview request without sending |
194+
| `--verbose` | Show request URLs and timing |
195+
| `--quiet` | Suppress non-essential output |
196+
| `--allow-sensitive` | Override outbound safety block |
197+
| `--yes` | Skip confirmations |
198+
| `--wait` | Wait when rate limited |
199+
| `--max-wait <sec>` | Max wait for rate limits (default: 600) |
200+
| `--no-color` | Disable color output |
201201

202202
## Architecture
203203

@@ -255,4 +255,4 @@ MIT
255255

256256
---
257257

258-
*Built in one night by a systems reader, a tree sprite, and a code bot who couldn't remember to use `www`.*
258+
_Built in one night by a systems reader, a tree sprite, and a code bot who couldn't remember to use `www`._

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"mb": "bun src/mb.ts",
1010
"test": "bun test --pass-with-no-tests",
1111
"lint": "eslint .",
12+
"format": "prettier --write .",
13+
"format:check": "prettier --check .",
1214
"typecheck": "tsc --noEmit",
1315
"build": "bun build src/mb.ts --outfile dist/mb.js --target=bun",
1416
"build:no-dms": "bun build src/mb.ts --outfile dist/mb.js --define:MB_NO_DMS=true --target=bun"
@@ -22,6 +24,7 @@
2224
"@typescript-eslint/parser": "^8.54.0",
2325
"bun-types": "^1.3.8",
2426
"eslint": "^9.39.2",
27+
"prettier": "^3.8.1",
2528
"typescript": "^5.9.3"
2629
}
2730
}

src/lib/audit.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ function hashText(text: string): string {
2828
return createHash("sha256").update(text).digest("hex");
2929
}
3030

31-
export function buildContentAudit(text?: string): { content_preview?: string; content_sha256?: string } {
31+
export function buildContentAudit(text?: string): {
32+
content_preview?: string;
33+
content_sha256?: string;
34+
} {
3235
if (!text || text.trim().length === 0) {
3336
return {};
3437
}

src/lib/config.ts

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,18 @@ export function resolveProfileName(explicit?: string | undefined): string {
6363
return "default";
6464
}
6565

66-
export function getProfile(store: CredentialsStore, profileName: string): ProfileRecord | undefined {
66+
export function getProfile(
67+
store: CredentialsStore,
68+
profileName: string,
69+
): ProfileRecord | undefined {
6770
return store[profileName];
6871
}
6972

70-
export function upsertProfile(store: CredentialsStore, profileName: string, record: ProfileRecord): CredentialsStore {
73+
export function upsertProfile(
74+
store: CredentialsStore,
75+
profileName: string,
76+
record: ProfileRecord,
77+
): CredentialsStore {
7178
return {
7279
...store,
7380
[profileName]: {
@@ -106,13 +113,29 @@ function keychainService(): string {
106113

107114
function readKeychainKey(profileName: string): string | undefined {
108115
if (!canUseKeychain()) return undefined;
109-
const res = runSecurity(["find-generic-password", "-a", profileName, "-s", keychainService(), "-w"]);
116+
const res = runSecurity([
117+
"find-generic-password",
118+
"-a",
119+
profileName,
120+
"-s",
121+
keychainService(),
122+
"-w",
123+
]);
110124
return res.ok ? res.stdout : undefined;
111125
}
112126

113127
function writeKeychainKey(profileName: string, apiKey: string): boolean {
114128
if (!canUseKeychain()) return false;
115-
const res = runSecurity(["add-generic-password", "-a", profileName, "-s", keychainService(), "-w", apiKey, "-U"]);
129+
const res = runSecurity([
130+
"add-generic-password",
131+
"-a",
132+
profileName,
133+
"-s",
134+
keychainService(),
135+
"-w",
136+
apiKey,
137+
"-U",
138+
]);
116139
return res.ok;
117140
}
118141

@@ -122,7 +145,10 @@ function deleteKeychainKey(profileName: string): boolean {
122145
return res.ok;
123146
}
124147

125-
export function storeApiKey(profileName: string, apiKey: string): { keyRef: "keychain" | "file"; apiKey?: string } {
148+
export function storeApiKey(
149+
profileName: string,
150+
apiKey: string,
151+
): { keyRef: "keychain" | "file"; apiKey?: string } {
126152
if (writeKeychainKey(profileName, apiKey)) {
127153
return { keyRef: "keychain" };
128154
}
@@ -158,7 +184,11 @@ export function listSensitiveEntries(store: SensitiveStore, profileName: string)
158184
return store[profileName] || [];
159185
}
160186

161-
export function upsertSensitiveEntry(store: SensitiveStore, profileName: string, entry: SensitiveEntry): SensitiveStore {
187+
export function upsertSensitiveEntry(
188+
store: SensitiveStore,
189+
profileName: string,
190+
entry: SensitiveEntry,
191+
): SensitiveStore {
162192
const existing = store[profileName] || [];
163193
const filtered = existing.filter((e) => e.label !== entry.label);
164194
return {
@@ -167,7 +197,11 @@ export function upsertSensitiveEntry(store: SensitiveStore, profileName: string,
167197
};
168198
}
169199

170-
export function removeSensitiveEntry(store: SensitiveStore, profileName: string, label: string): SensitiveStore {
200+
export function removeSensitiveEntry(
201+
store: SensitiveStore,
202+
profileName: string,
203+
label: string,
204+
): SensitiveStore {
171205
const existing = store[profileName] || [];
172206
return {
173207
...store,

0 commit comments

Comments
 (0)