@hippo-digital/hippocampus 2.3.0 → 2.5.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +19 -0
  3. package/assets/dist/hippocampus.css +1 -1
  4. package/assets/hippocampus.scss +34 -1
  5. package/docs/agent-roadmap.md +6 -1
  6. package/docs/agent-workflow.md +6 -1
  7. package/docs/ask-whats-already-known.md +159 -0
  8. package/docs/colour-pairings.md +6 -0
  9. package/docs/components.md +7 -1
  10. package/docs/custom-agents-usage.md +6 -1
  11. package/docs/design-actions-and-decisions.md +5 -0
  12. package/docs/diagrams/README.md +44 -0
  13. package/docs/diagrams/evidence-flow.mmd +56 -0
  14. package/docs/diagrams/mermaid.config.json +20 -0
  15. package/docs/hippocampus-for-designers-and-researchers.md +7 -1
  16. package/docs/hippocampus-technical.md +7 -1
  17. package/docs/images/evidence-flow.svg +1 -0
  18. package/docs/import-a-research-round.md +229 -0
  19. package/docs/prompt-architecture-guardrails.md +6 -1
  20. package/docs/repeatable-research-round-ingestion.md +6 -1
  21. package/docs/research-knowledge-graph.md +7 -1
  22. package/docs/research-source-file-conventions.md +7 -2
  23. package/docs/review-and-promote-a-draft.md +203 -0
  24. package/docs/source-model.md +28 -1
  25. package/docs/start-here.md +206 -0
  26. package/lib/create-router.js +41 -7
  27. package/lib/docs.js +288 -30
  28. package/lib/lint-knowledge.js +22 -1
  29. package/lib/schema.js +58 -12
  30. package/package.json +1 -1
  31. package/scripts/import-research-deck.js +31 -6
  32. package/scripts/known.js +2 -2
  33. package/scripts/promote-research-draft.js +76 -6
  34. package/scripts/smoke-routes.js +8 -1
  35. package/skills/ingest-user-personas/SKILL.md +1 -1
  36. package/views/hippocampus/doc.html +15 -0
  37. package/views/hippocampus/docs.html +42 -13
  38. package/views/hippocampus/evidence-impact.html +4 -0
  39. package/views/hippocampus/record.html +10 -2
  40. package/views/hippocampus/research.html +9 -4
@@ -1,4 +1,10 @@
1
- # Source Model
1
+ ---
2
+ section: reference
3
+ order: 10
4
+ audience: [cli]
5
+ summary: Every record type in hippocampus/source, what its fields mean, and the rules for editing them by hand.
6
+ ---
7
+ # Source model
2
8
 
3
9
  The knowledge base is driven by structured JSON in `hippocampus/source`.
4
10
 
@@ -85,6 +91,8 @@ Each user includes:
85
91
  - access needs
86
92
  - service context
87
93
 
94
+ Both `responsibilities` and `accessNeeds` need at least one entry. When nobody has researched one of them yet - common when a workbook names a user group before persona work reaches it - write exactly `Not yet researched` (exported as `UNRESEARCHED` from `lib/schema.js`). Do not invent an entry: a guessed access need reads as a finding. `npx hippocampus validate` counts users carrying the marker and reports them as coverage notes, so the gap stays visible.
95
+
88
96
  ### User needs
89
97
 
90
98
  File: `hippocampus/source/needs.json`
@@ -101,6 +109,19 @@ Needs should be specific enough to influence journeys and screens.
101
109
 
102
110
  A need may optionally carry a `reference` (e.g. an external ticket ID such as a Jira key) when it was imported from a source that already tracks it that way.
103
111
 
112
+ A need may carry the user story derived from it, as an optional `story`:
113
+
114
+ ```json
115
+ "story": {
116
+ "reference": "US-010",
117
+ "text": "As a hospital eye service triage clinician, I want referrals to include...",
118
+ "designQuestion": "What minimum referral data standard should be required before submission?",
119
+ "acceptanceCriteria": ["Differentiates mandatory from optional fields", "..."]
120
+ }
121
+ ```
122
+
123
+ Only `text` is required inside it. Stories are one per need in the workbooks teams keep, so a story lives on its need rather than as a record of its own; the need page shows it, with its design question and acceptance criteria.
124
+
104
125
  ### Scenarios
105
126
 
106
127
  File: `hippocampus/source/scenarios.json`
@@ -190,6 +211,8 @@ Each evidence item includes:
190
211
 
191
212
  Use `sourcePath` when the evidence comes from a copied artefact in the repo.
192
213
 
214
+ Evidence and insights may carry an optional `impact`: `critical`, `high`, `medium`, `low` or `unknown`. It answers how much the finding matters, which is a different question from `confidence` - how sure we are of it. Keep both: an item can be critical and only weakly evidenced, and recording confidence alone makes it read as middling.
215
+
193
216
  Do not invent evidence. If a claim is not evidenced, add an assumption instead.
194
217
 
195
218
  ### Decisions
@@ -217,6 +240,10 @@ Use assumptions when:
217
240
  - a service rule is plausible but unconfirmed
218
241
  - the spike makes a deliberate simplification
219
242
 
243
+ ### References
244
+
245
+ Every record type except relationships may carry an optional `reference`: the identifier it already has where it came from, such as a Jira key or a workbook row (`FB-013`, `US-010`). It keeps a decision traceable to the ticket a team works from, and gives an importer a stable key to find a record it wrote before and update it rather than add a second copy. It is not an `id`: ids stay kebab-case and never change; a reference is whatever the source system uses.
246
+
220
247
  ## Relationship Map
221
248
 
222
249
  ```text
@@ -0,0 +1,206 @@
1
+ ---
2
+ section: start
3
+ order: 10
4
+ audience: [viewer, cli]
5
+ summary: What Hippocampus is and is not, how research moves through it, and how to get it running in a prototype.
6
+ ---
7
+ # Start here
8
+
9
+ Hippocampus keeps a design team's knowledge in one connected place: the
10
+ research a team has done, what it learned, the needs that came out of it, and
11
+ the journeys and screens built to meet them. Every record is linked to the
12
+ records it relies on, so you can follow a screen back to the research that
13
+ shaped it.
14
+
15
+ This page covers what Hippocampus is, how research moves through it, and how
16
+ to set it up. If you only ever look at the pages in a prototype and never run
17
+ commands, read the first three sections and skip to
18
+ [If you only use the viewer](#if-you-only-use-the-viewer).
19
+
20
+ ## What Hippocampus is
21
+
22
+ - **A structured record.** Users, needs, research rounds, insights, evidence,
23
+ scenarios, journeys, screens and decisions, each stored as data in the same
24
+ repository as your NHS Prototype Kit prototype.
25
+ - **A set of links between them.** A need says which evidence supports it. A
26
+ screen says which needs it meets. A decision says what it changed. That is
27
+ what lets you ask "why is this screen like this?" and get an answer.
28
+ - **A viewer.** Pages inside your prototype, at `/hippocampus`, that show the
29
+ records and the links between them. Nobody has to read the data files.
30
+ - **A set of commands and skills.** Commands bring research in and check the
31
+ record holds together. Skills are written instructions an AI agent follows
32
+ to do the longer jobs, such as tidying a research draft or turning a
33
+ scenario into a journey.
34
+
35
+ ## What it is not
36
+
37
+ - **Not where your research files live.** Your shared drive, or wherever your
38
+ team keeps research, stays the home of the original files. Hippocampus holds
39
+ what was learned from them and where it came from.
40
+ - **Not an analysis tool.** It does not decide which findings matter. People
41
+ do, and the record shows who decided and on what evidence.
42
+ - **Not automatic.** Nothing becomes part of the record until a person
43
+ approves it.
44
+ - **Not a hosted service.** It runs inside your prototype, on your machine,
45
+ like the rest of the prototype does.
46
+
47
+ ## How research moves through it
48
+
49
+ ![How evidence moves through Hippocampus: seven steps from inbox to viewer, with a person approving each draft before it becomes part of the record](images/evidence-flow.svg)
50
+
51
+ The list below describes the same steps.
52
+ [Open the diagram on its own](images/evidence-flow.svg) to see it full size.
53
+
54
+ 1. **Inbox.** You put research files in `hippocampus/inbox/research/`. Decks,
55
+ PDFs, Word documents, spreadsheets and plain text notes all work.
56
+ 2. **Import.** `npx hippocampus research sync` reads each new file on your
57
+ machine and writes a draft. Nothing is sent anywhere.
58
+ 3. **Draft.** The draft goes into `hippocampus/imports/research/`. It is a
59
+ machine's reading of a messy file, so nothing treats it as true yet.
60
+
61
+ *Optional:* an AI agent can tidy the draft using the
62
+ `structure-research-draft` skill. Whatever the agent reads is sent to that
63
+ agent's service. See [When anything leaves your machine](#when-anything-leaves-your-machine).
64
+ 4. **Review.** A person reads the draft. If it is not right, it goes back to be
65
+ fixed. The `review-research-import-draft` skill can help someone check it,
66
+ but it does not decide.
67
+ 5. **Promote.** A person runs `npx hippocampus promote research` for the draft
68
+ they reviewed. This is the only step that writes to the record, and nothing
69
+ runs it on its own.
70
+
71
+ `research sync` asks whether to promote straight after importing. The
72
+ answer defaults to no. Say no until someone has read the draft, and do not
73
+ use `--yes`, which promotes without asking.
74
+ 6. **Source.** Promoted records live in `hippocampus/source/`. This is the
75
+ record everything else is built from.
76
+ 7. **Viewer.** The pages at `/hippocampus` are built from `source/` each time
77
+ you load one, so a promoted change shows up when you refresh.
78
+
79
+ Alongside the viewer, skills that review or hand over work write their output
80
+ to `artefacts/`: route review packs, accessibility reviews and delivery
81
+ summaries. Nothing reads them back, so `artefacts/` is safe to delete.
82
+
83
+ ## If you only use the viewer
84
+
85
+ You can follow the evidence behind a prototype without running anything. The
86
+ pages below are under `/hippocampus` by default; your team may have mounted
87
+ the viewer somewhere else.
88
+
89
+ | To find out | Open |
90
+ | --- | --- |
91
+ | Where the work stands: rounds not yet mined, insights with no need, needs with no screen | `/hippocampus` |
92
+ | Why a screen is designed the way it is | `/hippocampus/trace`, then choose the screen |
93
+ | What depends on a piece of research | any evidence link on a need or user page, which opens its impact page |
94
+ | Every need, and what supports it | `/hippocampus/user-needs` |
95
+ | The journey being prototyped, and what it is built on | `/hippocampus/handover` |
96
+ | How the records connect | `/hippocampus/graph` |
97
+ | This guide | `/hippocampus/docs` |
98
+
99
+ A link that is missing in the viewer is a link missing in the record. Ask the
100
+ team to add it rather than drawing it in by hand somewhere else.
101
+
102
+ ## Set it up
103
+
104
+ ### Before you start
105
+
106
+ You need:
107
+
108
+ - an NHS Prototype Kit project, using `nhsuk-prototype-kit` 8.3.0 or later
109
+ - Node.js 22.16.0 or later
110
+
111
+ ### Install it
112
+
113
+ In your prototype's folder:
114
+
115
+ ```bash
116
+ npm install @hippo-digital/hippocampus
117
+ ```
118
+
119
+ ### Set up the knowledge base
120
+
121
+ See what would change first:
122
+
123
+ ```bash
124
+ npx hippocampus init --dry-run
125
+ ```
126
+
127
+ Then run it for real:
128
+
129
+ ```bash
130
+ npx hippocampus init
131
+ ```
132
+
133
+ This writes:
134
+
135
+ - `hippocampus.config.json`, which tells every command where your knowledge
136
+ base is
137
+ - `hippocampus/`, with an empty knowledge base and its `inbox/`, `imports/`
138
+ and `source/` folders
139
+ - `artefacts/`, with a short README in each folder
140
+
141
+ It also adds two short blocks to your prototype, one in `app/routes.js` and
142
+ one in `app.js`, so the viewer appears inside it. Both are marked, and
143
+ `npx hippocampus eject` takes them back out without touching your knowledge
144
+ base.
145
+
146
+ ### Check it worked
147
+
148
+ ```bash
149
+ npx hippocampus doctor
150
+ ```
151
+
152
+ The first line is the project folder it found. If that is wrong, nothing
153
+ after it will be right: run the command from inside your prototype, or pass
154
+ `--root <folder>`.
155
+
156
+ After that, `doctor` checks the config, the knowledge base, the two blocks in
157
+ your prototype and whether the records link up. Then it starts the prototype
158
+ and opens every page to make sure each one loads. A failed check says what went
159
+ wrong, and usually what to run next.
160
+
161
+ Start your prototype as you normally would and go to `/hippocampus`. An empty
162
+ knowledge base still shows every page, and tells you what to add next.
163
+
164
+ ### If your team uses an AI agent
165
+
166
+ ```bash
167
+ npx hippocampus skills install
168
+ ```
169
+
170
+ This copies the skills, agent roles and instructions into `.github/` in your
171
+ prototype, where agents such as GitHub Copilot read them. Run it again after
172
+ upgrading Hippocampus; it leaves alone any file your team has edited and tells
173
+ you which.
174
+
175
+ ## When anything leaves your machine
176
+
177
+ - **The `hippocampus` commands send nothing anywhere.** Importing reads PDFs,
178
+ Word, PowerPoint and Excel files on your machine. Apart from the optional
179
+ Gemini tool below, the only network request any command makes is `doctor`
180
+ opening your own prototype's pages.
181
+ - **Skills are carried out by an AI agent, and what the agent reads goes to
182
+ its service.** If you point a skill at a research transcript, that
183
+ transcript is sent to whichever service runs the agent. Agree with your
184
+ information governance lead which agents may read which material before the
185
+ first research file goes into the inbox. The same applies to any agent
186
+ connected to `hippocampus mcp`, which hands it the knowledge base.
187
+ - **One optional tool calls Google Gemini.** `hippocampus mcp` serves the
188
+ knowledge base to agents. One of its tools, `design_brain_ask`, sends the
189
+ question and the parts of the knowledge base it looks up to Gemini. It is
190
+ off unless someone sets `GEMINI_API_KEY` and `DESIGN_BRAIN_MODEL` and
191
+ installs `@google/genai`. The rest of `hippocampus mcp` uses no model.
192
+
193
+ ## What to read next
194
+
195
+ - [Ask what's already known](ask-whats-already-known.md): check what the team
196
+ already knows before you research or design something
197
+ - [Import a research round](import-a-research-round.md) and
198
+ [Review a draft and promote it](review-and-promote-a-draft.md): bring a
199
+ round of research in, steps 1 to 6 above
200
+ - [Hippocampus for designers and researchers](hippocampus-for-designers-and-researchers.md):
201
+ the record types and viewer pages in more detail
202
+ - [Research source file conventions](research-source-file-conventions.md):
203
+ how to write research files so they import cleanly
204
+ - [Repeatable research round ingestion](repeatable-research-round-ingestion.md):
205
+ the full import and promotion procedure
206
+ - [Source model](source-model.md): every record type and its fields
@@ -1,7 +1,7 @@
1
1
  const express = require('express')
2
2
  const path = require('path')
3
3
  const packagePaths = require('./package-paths')
4
- const { listDocs, readDoc, packageVersion } = require('./docs')
4
+ const { listDocSections, readDoc, docImagePath, packageVersion } = require('./docs')
5
5
  const { listTemplates, allTemplates } = require('./templates')
6
6
  const { hrefFor, listHrefFor } = require('./record-links')
7
7
  const { matchesText, facet, matchesFacet, queryWithout } = require('./filter')
@@ -149,12 +149,23 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
149
149
  // connects to is resolved once by getRecordDetail and rendered the same way
150
150
  // on every page, so a reader learns one layout rather than three.
151
151
  const FACTS = {
152
- Need: (r) => [
153
- { key: 'Priority', value: r.priority },
154
- { key: 'Reference', value: r.reference }
155
- ],
152
+ Need: (r) => {
153
+ const story = r.story || {}
154
+ return [
155
+ { key: 'Priority', value: r.priority },
156
+ { key: 'Reference', value: r.reference },
157
+ // The story's design question is the reason to carry stories at all,
158
+ // so it sits next to the story rather than below the connections.
159
+ { key: 'User story', value: story.text },
160
+ { key: 'Story reference', value: story.reference },
161
+ { key: 'Design question', value: story.designQuestion },
162
+ { key: 'Acceptance criteria', list: story.acceptanceCriteria }
163
+ ]
164
+ },
156
165
  Insight: (r) => [
157
166
  { key: 'Confidence', value: r.confidence },
167
+ { key: 'Impact', value: r.impact },
168
+ { key: 'Reference', value: r.reference },
158
169
  { key: 'Summary', value: r.summary }
159
170
  ],
160
171
  Screen: (r) => [
@@ -366,7 +377,7 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
366
377
  // so what a team reads always matches the version they are running.
367
378
  router.get('/docs', (req, res) => {
368
379
  res.render('hippocampus/docs', {
369
- docs: listDocs(),
380
+ sections: listDocSections(),
370
381
  templates: listTemplates(paths),
371
382
  packageVersion: packageVersion()
372
383
  })
@@ -382,10 +393,33 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
382
393
  res.download(template.path, template.file)
383
394
  })
384
395
 
396
+ // Diagrams the guides embed, from the package like the guides themselves.
397
+ // docImagePath only answers for a plain name already in docs/images. The CSP
398
+ // is because an SVG opened on its own is a document that can run script:
399
+ // these are the package's own files, but the header costs nothing and means a
400
+ // diagram can only ever be a picture.
401
+ router.get('/docs/images/:file', (req, res) => {
402
+ const file = docImagePath(req.params.file)
403
+ if (!file) return res.status(404).render('hippocampus/not-found')
404
+ res.set('X-Content-Type-Options', 'nosniff')
405
+ res.set('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'")
406
+ res.sendFile(file)
407
+ })
408
+
409
+ // A guide sits under its section in the trail, so a reader who arrived from a
410
+ // link elsewhere can see which part of the guide they are in and get back to
411
+ // the rest of it. Not when the two share a name: "Start here > Start here"
412
+ // reads as a mistake, and the section adds nothing the page title does not.
385
413
  router.get('/docs/:slug', (req, res) => {
386
414
  const doc = readDoc(req.params.slug)
387
415
  if (!doc) return res.status(404).render('hippocampus/not-found')
388
- withLeaf(res, req, doc.title)
416
+ const section = { text: doc.sectionTitle, href: `${basePath}/docs#section-${doc.section}` }
417
+ res.locals.breadcrumbItems = buildTrail({
418
+ basePath,
419
+ path: req.path,
420
+ leaf: doc.title,
421
+ crumbs: doc.sectionTitle === doc.title ? [] : [section]
422
+ })
389
423
  res.render('hippocampus/doc', { doc, packageVersion: packageVersion() })
390
424
  })
391
425