Skip to content

Commit 32d52c4

Browse files
committed
feat: update onboarding
1 parent 6e9426f commit 32d52c4

8 files changed

Lines changed: 104 additions & 20 deletions

File tree

‎README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ If you use the user-level install, ensure your user Python bin is on `PATH`:
4343
export PATH="$(python3 -m site --user-base)/bin:$PATH"
4444
```
4545

46+
For Codex Desktop and similar tool shells, put both the PATH export and `SHELLBRAIN_DB_DSN` in `~/.zprofile`, not `~/.zshrc`, so non-interactive login shells can see them.
47+
4648
## Bootstrap
4749

4850
Export `SHELLBRAIN_DB_DSN` from your shell profile, then apply packaged migrations once:
@@ -52,6 +54,18 @@ export SHELLBRAIN_DB_DSN='postgresql+psycopg://shellbrain:shellbrain@localhost:5
5254
shellbrain admin migrate
5355
```
5456

57+
When running Shellbrain from Codex Desktop or a similar tool shell, treat this as the normal startup pattern:
58+
59+
```bash
60+
zsh -lc 'source ~/.zprofile >/dev/null 2>&1; shellbrain --help'
61+
```
62+
63+
Then use the same wrapper shape for actual invocations if needed:
64+
65+
```bash
66+
zsh -lc "source ~/.zprofile >/dev/null 2>&1; shellbrain read --json '{\"query\":\"Have we seen this migration lock timeout before?\",\"kinds\":[\"problem\",\"solution\",\"failed_tactic\"]}'"
67+
```
68+
5569
## Migrate Existing Local Postgres
5670

5771
If your local Docker-backed Postgres is still the older `memory-postgres` setup, run:

‎docs/external-quickstart.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ python3 -m pip install --user --break-system-packages --editable /absolute/path/
2727
export PATH="$(python3 -m site --user-base)/bin:$PATH"
2828
```
2929

30+
For Codex Desktop and similar tool shells, put that PATH export and `SHELLBRAIN_DB_DSN` in `~/.zprofile`, not `~/.zshrc`, so non-interactive login shells can see them.
31+
3032
## Bootstrap
3133

3234
Set this once in your shell profile, then apply migrations:
@@ -36,6 +38,20 @@ export SHELLBRAIN_DB_DSN='postgresql+psycopg://shellbrain:shellbrain@localhost:5
3638
shellbrain admin migrate
3739
```
3840

41+
## Codex Startup Pattern
42+
43+
When running Shellbrain from Codex Desktop or a similar tool shell, treat this as the normal startup step:
44+
45+
```bash
46+
zsh -lc 'source ~/.zprofile >/dev/null 2>&1; shellbrain --help'
47+
```
48+
49+
Then use the same wrapper shape for real commands when needed:
50+
51+
```bash
52+
zsh -lc "source ~/.zprofile >/dev/null 2>&1; shellbrain read --json '{\"query\":\"Have we seen this migration lock timeout before?\",\"kinds\":[\"problem\",\"solution\",\"failed_tactic\"]}'"
53+
```
54+
3955
## Query First, But Query Precisely
4056

4157
Shellbrain `read` uses lexical retrieval plus semantic similarity. Query it with the concrete problem, subsystem, constraint, or decision you are working on. Do not start with vague prompts like "what should I know about this repo?"

‎next_steps.md‎

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,43 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
162162
- decide later whether git-root inference is worth adding
163163
- Consider making first-run embedding downloads less surprising on the `read` path.
164164

165-
### 8. Agent-Facing Context Pack Metadata
165+
### 8. Product Ideas Worth Borrowing
166+
167+
- MoltBrain is worth treating as a useful comparison point for operator experience, not as a blueprint for Shellbrain's trust model.
168+
- Borrow the parts that improve discoverability, observability, and day-to-day usability without giving up Shellbrain's explicit evidence discipline.
169+
170+
Near-term product ideas worth borrowing:
171+
172+
- make the install and bootstrap path feel more like a polished user tool:
173+
- prefer a crisp global-install story
174+
- consider a `shellbrain doctor` or equivalent environment check
175+
- make database/bootstrap state easier to verify at a glance
176+
- add a proper operator-facing viewer:
177+
- browse memories by repo, kind, and recency
178+
- inspect evidence links and utility history
179+
- inspect what a read returned and why
180+
- inspect episodes and episode events without raw SQL
181+
- add analytics and export surfaces:
182+
- session-level usage summaries
183+
- memory creation / retrieval / utility trends
184+
- lightweight export for backup, analysis, or sharing
185+
- add curation affordances where they help humans manage the corpus:
186+
- favorites / pins for especially important memories
187+
- lightweight tags or labels if they improve navigation
188+
- manual review surfaces for high-value memories
189+
190+
What not to borrow by default:
191+
192+
- do not make durable memory creation fully automatic
193+
- do not replace explicit `events -> evidence_refs -> create/update` with summary-only extraction
194+
- do not blur the distinction between episodic capture and durable semantic / procedural memory
195+
196+
The right borrowing strategy is:
197+
198+
- borrow MoltBrain's product polish and operator visibility
199+
- keep Shellbrain's evidence-backed, typed, case-based reasoning core intact
200+
201+
### 9. Agent-Facing Context Pack Metadata
166202

167203
- The read result already returns structured JSON with top-level sections:
168204
- `meta`
@@ -178,7 +214,7 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
178214
- Keep `scenarios` explicitly deferred for now.
179215
- Do not treat scenario lift as part of the current v1 output surface until it is intentionally reintroduced.
180216

181-
### 9. Retrieval Metadata and Usage Signals
217+
### 10. Retrieval Metadata and Usage Signals
182218

183219
- Add lightweight metadata to every read result so behavior is inspectable without digging through logs.
184220
- Useful fields to include:
@@ -197,7 +233,7 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
197233
- stale-shellbrain hit rate
198234
- duplicate / near-duplicate retrieval rate
199235

200-
### 10. System Performance Metrics
236+
### 11. System Performance Metrics
201237

202238
- Define a small metrics set that tells us whether the shellbrain setup is becoming more useful.
203239
- Candidate metrics:
@@ -213,15 +249,15 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
213249

214250
## Later Work
215251

216-
### 11. Episodes and Session Transfer Support
252+
### 12. Episodes and Session Transfer Support
217253

218254
- `episodes` and `episode_events` are implemented and validated end to end.
219255
- Remaining work is to operationalize the rest of the episodic model:
220256
- wire `session_transfers` into real handoff flows
221257
- add execution tests that prove transfer writes work against PostgreSQL
222258
- decide how transfer events should participate in agent-facing analytics
223259

224-
### 12. Later: Local Model for Triage / Filtering
260+
### 13. Later: Local Model for Triage / Filtering
225261

226262
- Consider a smaller local model ahead of the main model for cheap first-pass categorization or filtering.
227263
- Possible uses:
@@ -231,7 +267,7 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
231267
- perform cheap reranking before the higher-cost model sees context
232268
- Treat this as a later optimization after baseline metadata and metrics exist, so we can measure whether it actually improves quality, latency, or cost.
233269

234-
### 13. Usability: Batch Questions for Memory Reads
270+
### 14. Usability: Batch Questions for Memory Reads
235271

236272
- Support a single shellbrain-read call that accepts multiple questions at once, instead of forcing the LLM into sequential reads.
237273
- The goal is to let the model ask for "everything I need to know" in one interaction when it has several sub-questions.
@@ -243,7 +279,7 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
243279
- This should reduce extra tool turns and token burn caused by back-to-back shellbrain queries.
244280
- Design the interface so batching is a first-class usability path, not just a thin wrapper around repeated single-question retrieval.
245281

246-
### 14. Later: Scenario Lift
282+
### 15. Later: Scenario Lift
247283

248284
- Keep scenario lift out of the current v1 read output.
249285
- Revisit it later as a separate project once the atomic-shellbrain path, metadata, and operational surface are stable.
@@ -253,7 +289,7 @@ This is worth exploring because a supervisor loop could reduce protocol entropy
253289
- constructor trigger boundaries
254290
- pack quotas and display shape
255291

256-
### 15. V2: Automatic Related-Memory Reinforcement
292+
### 16. V2: Automatic Related-Memory Reinforcement
257293

258294
- Treat this as v2, not v1.
259295
- Add a background task that looks at which memories are repeatedly retrieved, cited, or used together.

‎shellbrain/periphery/cli/main.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class _HelpFormatter(argparse.RawDescriptionHelpFormatter):
2626
- `create` authors durable memories from that evidence.
2727
- `update` records utility, truth-evolution links, and explicit associations.
2828
29+
Codex shell bootstrap:
30+
- In Codex Desktop or similar tool shells, start via `zsh -lc 'source ~/.zprofile >/dev/null 2>&1; shellbrain --help'`.
31+
- Use the same wrapper shape for actual Shellbrain commands when the session depends on machine-level PATH and `SHELLBRAIN_DB_DSN`.
32+
2933
Protocol:
3034
1. Query with the concrete bug, subsystem, decision, or constraint you are working on.
3135
Avoid generic prompts like "what should I know about this repo?"
@@ -37,6 +41,7 @@ class _HelpFormatter(argparse.RawDescriptionHelpFormatter):
3741
- Shellbrain should already be available from a one-time global install.
3842
- If it is missing, restore the machine-level install (`pipx install --editable /path/to/shellbrain` or `python3 -m pip install --user --break-system-packages --editable /path/to/shellbrain`).
3943
- Export `SHELLBRAIN_DB_DSN` from your shell profile.
44+
- In Codex Desktop or similar tool shells, put the PATH export and `SHELLBRAIN_DB_DSN` in `~/.zprofile`, not `~/.zshrc`.
4045
- Run `shellbrain admin migrate` once against the target database.
4146
4247
Examples:
@@ -48,7 +53,8 @@ class _HelpFormatter(argparse.RawDescriptionHelpFormatter):
4853
shellbrain admin migrate
4954
5055
Common recovery steps:
51-
- `SHELLBRAIN_DB_DSN is not set`: export the database DSN before running the CLI.
56+
- `shellbrain: command not found` inside Codex: verify you used the `zsh -lc 'source ~/.zprofile ...'` startup pattern before declaring Shellbrain blocked.
57+
- `SHELLBRAIN_DB_DSN is not set`: verify the same startup pattern and that the export lives in `~/.zprofile`, then export the database DSN if needed.
5258
- No active host session found: verify Codex/Claude Code transcript availability, then rerun `events`.
5359
- Evidence ref rejected: rerun `events` and use the returned `episode_event` ids verbatim.
5460
- Wrong working tree: rerun with `--repo-root` (and optionally `--repo-id`) for the target repo.

‎skills/shellbrain-session-start/SKILL.md‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ Treat current repo state as ground truth. Treat Shellbrain as advisory long-term
2727

2828
## Quick Start
2929

30-
1. Check that Shellbrain is available with `shellbrain --help`.
31-
2. Assume Shellbrain is already available from a one-time global install. If the CLI is missing, ask the operator to restore that machine-level install instead of reinstalling per repo. The operator should also have `SHELLBRAIN_DB_DSN` set and `shellbrain admin migrate` already applied.
30+
1. In Codex or similar tool shells, bootstrap Shellbrain through a login shell that sources `~/.zprofile`:
31+
`zsh -lc 'source ~/.zprofile >/dev/null 2>&1; command -v shellbrain && printf "%s\n" "$SHELLBRAIN_DB_DSN"'`
32+
2. Assume Shellbrain is already available from a one-time global install. If direct `shellbrain` calls fail in the current session, keep using the `zsh -lc 'source ~/.zprofile >/dev/null 2>&1; ...'` wrapper for Shellbrain invocations before declaring Shellbrain blocked. Only ask the operator to restore the machine-level install if the wrapped check still fails. The operator should also have `SHELLBRAIN_DB_DSN` set and `shellbrain admin migrate` already applied.
3233
3. Resolve the target repo:
3334
- Use the current working directory when already inside the repo.
3435
- Pass `--repo-root /absolute/path/to/repo` when working from somewhere else.
@@ -41,20 +42,22 @@ Treat current repo state as ground truth. Treat Shellbrain as advisory long-term
4142
`shellbrain read --json '{"query":"What repo constraints or user preferences matter for this task?","kinds":["fact","preference","change"]}'`
4243
- area-specific facts:
4344
`shellbrain read --json '{"query":"What facts or changes matter in this subsystem?","kinds":["fact","change","problem","solution"]}'`
44-
6. Inspect the returned context pack:
45+
6. When running from Codex, wrap the actual Shellbrain invocations the same way if needed:
46+
`zsh -lc "source ~/.zprofile >/dev/null 2>&1; shellbrain read --json '{\"query\":\"Have we seen this failure mode before?\",\"kinds\":[\"problem\",\"solution\",\"failed_tactic\"]}'"`
47+
7. Inspect the returned context pack:
4548
- `direct` = direct matches
4649
- `explicit_related` = linked memories, including authored associations and problem/fact chains
4750
- `implicit_related` = semantic neighbors and bounded associative hops
48-
7. Re-run `read` liberally during the task whenever the search shifts, you hit a new subproblem, or you suspect the right memory will only become relevant mid-journey.
49-
8. Before `create` or any evidence-bearing `update`, run `shellbrain events --json '{"limit":10}'`.
50-
9. Reuse returned `data.events[].id` values verbatim as `evidence_refs`.
51-
10. At session end, normalize the episode into durable memories:
51+
8. Re-run `read` liberally during the task whenever the search shifts, you hit a new subproblem, or you suspect the right memory will only become relevant mid-journey.
52+
9. Before `create` or any evidence-bearing `update`, run `shellbrain events --json '{"limit":10}'`.
53+
10. Reuse returned `data.events[].id` values verbatim as `evidence_refs`.
54+
11. At session end, normalize the episode into durable memories:
5255
- store the `problem`
5356
- store each `failed_tactic`
5457
- store the `solution`
5558
- store any durable `fact`, `preference`, or `change`
5659
- record `utility_vote` updates for memories that helped or misled
57-
11. Use the exact payload shapes in [references/request-shapes.md](references/request-shapes.md).
60+
12. Use the exact payload shapes in [references/request-shapes.md](references/request-shapes.md).
5861

5962
## Memory Kinds
6063

‎skills/shellbrain-session-start/references/session-workflow.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ The point is case-based reasoning: query for similar prior problems, plans, cons
2424

2525
## Bootstrap
2626

27+
In Codex desktop and similar tool shells, first retry through a login shell that sources `~/.zprofile`:
28+
29+
```bash
30+
zsh -lc 'source ~/.zprofile >/dev/null 2>&1; command -v shellbrain && printf "%s\n" "$SHELLBRAIN_DB_DSN"'
31+
```
32+
2733
Use Shellbrain only after confirming:
2834

2935
- `shellbrain --help` works.
3036
- `SHELLBRAIN_DB_DSN` is set.
3137
- `shellbrain admin migrate` has been run against the target database.
3238

33-
Assume Shellbrain comes from a one-time global install. If the CLI is unavailable, stop and ask the operator to restore the machine-level install first. Do not create per-repo installs unless the operator explicitly wants that.
39+
Assume Shellbrain comes from a one-time global install. If direct calls fail in the current Codex session, keep using the `zsh -lc 'source ~/.zprofile ...'` wrapper for Shellbrain invocations before declaring Shellbrain blocked. Only if the wrapped check fails should you ask the operator to restore the machine-level install. Do not create per-repo installs unless the operator explicitly wants that.
3440

3541
## Repo Targeting
3642

@@ -181,10 +187,10 @@ Important modeling pattern for changed truth:
181187
## Recovery
182188

183189
- `shellbrain: command not found`
184-
Ask the operator to restore the one-time global Shellbrain install.
190+
Retry through `zsh -lc 'source ~/.zprofile >/dev/null 2>&1; shellbrain --help'` first. Only if that still fails should you ask the operator to restore the one-time global Shellbrain install.
185191

186192
- `SHELLBRAIN_DB_DSN is not set`
187-
Ask the operator to export the DB DSN from the shell profile, then rerun `shellbrain admin migrate` if the database is fresh.
193+
Retry through `zsh -lc 'source ~/.zprofile >/dev/null 2>&1; printf "%s\n" "$SHELLBRAIN_DB_DSN"'` first. If it is still unset, ask the operator to export the DB DSN from the shell profile, then rerun `shellbrain admin migrate` if the database is fresh.
188194

189195
- No active host session found
190196
Verify that the user is working in Codex or Claude Code, that transcript files exist, and that `repo_root` matches the repo used in that session.

‎tests/config/test_cli_surface.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_shellbrain_help_should_explain_the_workflow(capsys: pytest.CaptureFixtu
4848
assert "utility_vote" in output
4949
assert "shellbrain admin migrate" in output
5050
assert "--repo-root" in output
51+
assert "~/.zprofile" in output
5152
assert "--no-sync" not in output
5253
assert "create" in output
5354
assert "read" in output

‎tests/config/test_onboarding_assets.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_docs_and_skill_should_share_the_shellbrain_protocol() -> None:
3232
"session end",
3333
"utility_vote",
3434
"what should I know about this repo?",
35+
"~/.zprofile",
3536
]
3637

3738
for phrase in required_phrases:
@@ -51,6 +52,7 @@ def test_cli_help_should_share_the_short_protocol() -> None:
5152
"shellbrain admin migrate",
5253
"--repo-root",
5354
"At session end",
55+
"~/.zprofile",
5456
]
5557

5658
for phrase in required_phrases:

0 commit comments

Comments
 (0)