@hippo-digital/hippocampus 2.8.0 → 2.8.1

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.8.1
4
+
5
+ - **The viewer works with nhsuk-prototype-kit 8.5.2.** That kit renders through
6
+ a view class that puts `views/` in front of every template name, so every
7
+ viewer page was a 500 ("template not found: views/hippocampus/index...") and
8
+ `hippocampus doctor` reported that the prototype never started. The viewer
9
+ now asks the kit's view class how it names templates and passes names that
10
+ resolve either way. Nothing to change in a host.
11
+ - **`import design-actions` works again.** A message edit shipped in 1.0.0 put backticks
12
+ inside a template literal, so the script stopped parsing and every
13
+ `npx hippocampus import design-actions` failed with a SyntaxError. Once it
14
+ loaded, it also refused to write on a newly initialised project, because its
15
+ pre-write check read the source files directly instead of the way `validate`
16
+ does. Both are fixed, and a test now checks that every CLI script parses.
17
+ - **Skill descriptions say what each skill is not for.** `create-journey-from-scenario`
18
+ and `add-scenario` claimed "build, draft or map a user journey" and "write a
19
+ scenario", the same words a project's own journey and scenario skills use, so an
20
+ agent could pick either. Both now say they write knowledge-base records and name
21
+ what they are not for. `SKILL-FORMAT.md` asks for the same wherever two skills
22
+ could fire on the same words. Run `npx hippocampus skills install` after upgrading
23
+ to pick up the new descriptions.
24
+
3
25
  ## 2.8.0
4
26
 
5
27
  The knowledge model and the viewer follow the human-centred design cycle
@@ -46,9 +68,13 @@ so a 2.7 knowledge base loads unchanged. Old viewer URLs are unchanged.
46
68
  round's methods and a usability finding's polarity and rating, never rate a
47
69
  finding catastrophic, and record which requirements a test evaluated.
48
70
  `map-research-to-graph` no longer suggests the backwards `leads-to-action`.
49
- - **After upgrading, run `npx hippocampus init`.** It adds the four new
50
- collections as empty files to an existing knowledge base, because the skills
51
- check that the files they read exist. Existing files are not touched.
71
+ - **After upgrading, run `npx hippocampus init`, then
72
+ `npx hippocampus skills install` if your team uses an AI agent.** `init` adds
73
+ the four new collections as empty files to an existing knowledge base,
74
+ because the skills check that the files they read exist; existing files are
75
+ not touched. `skills install` brings in the two new skills and the updated
76
+ ones, leaving alone any your team has edited and naming them. Then
77
+ `npx hippocampus validate` confirms the knowledge base loads.
52
78
  - **The guide is grouped by activity**, with new pages on the cycle, quality
53
79
  objectives, the context of use, requirements, weighing options, principles and
54
80
  usability tests, and the existing recipes placed under the activity they serve.
@@ -191,6 +191,21 @@ prototype, where agents such as GitHub Copilot read them. Run it again after
191
191
  upgrading Hippocampus; it leaves alone any file your team has edited and tells
192
192
  you which.
193
193
 
194
+ ### Upgrade it
195
+
196
+ ```bash
197
+ npm install @hippo-digital/hippocampus@latest
198
+ npx hippocampus init
199
+ npx hippocampus skills install
200
+ npx hippocampus doctor
201
+ ```
202
+
203
+ `init` is safe to run again. It adds anything a newer version expects, such as
204
+ new empty collections in `hippocampus/source/`, and leaves your existing files
205
+ as they are. Skip `skills install` if your team doesn't use an AI agent. The
206
+ package's `CHANGELOG.md` says what changed in each release and whether there is
207
+ anything else to do.
208
+
194
209
  ## When anything leaves your machine
195
210
 
196
211
  - **The `hippocampus` commands send nothing anywhere.** Importing reads PDFs,
@@ -33,6 +33,22 @@ function createHippocampusRouter ({ basePath, knowledgeStore, paths }) {
33
33
  router.use('/assets', express.static(path.join(packagePaths.assetsDir, 'dist'), { fallthrough: true }))
34
34
  router.use('/assets', express.static(path.join(packagePaths.assetsDir, 'javascript'), { fallthrough: true }))
35
35
 
36
+ // nhsuk-prototype-kit 8.5.2 renders through a view class that joins
37
+ // "views/" onto every name and resolves it against the project root, so
38
+ // `hippocampus/index` became `views/hippocampus/index` and was looked for
39
+ // under the package's views directory as views/views/... - every viewer page
40
+ // was a 500 and `doctor` reported the prototype never started. Under that
41
+ // class the viewer passes `../hippocampus/...`, which the kit's join folds
42
+ // back to `hippocampus/...`. Kits that pass the name through unchanged get
43
+ // it unchanged.
44
+ router.use((req, res, next) => {
45
+ if (kitPrefixesViews(req.app)) {
46
+ const render = res.render.bind(res)
47
+ res.render = (name, ...rest) => render(typeof name === 'string' && name.startsWith('hippocampus/') ? `../${name}` : name, ...rest)
48
+ }
49
+ next()
50
+ })
51
+
36
52
  router.use((req, res, next) => {
37
53
  res.locals.basePath = basePath
38
54
  res.locals.hippocampusAssets = `${basePath}/assets`
@@ -546,4 +562,23 @@ function uniqueById (items) {
546
562
  return Object.values(Object.fromEntries(items.map((item) => [item.id, item])))
547
563
  }
548
564
 
565
+ // Asks the host's view class what it does with a name, once per app, rather
566
+ // than reading the kit's version: behaviour is what matters, and a kit that
567
+ // changes it back needs no release here.
568
+ const viewPrefixByApp = new WeakMap()
569
+ function kitPrefixesViews (app) {
570
+ if (!app || typeof app.get !== 'function') return false
571
+ if (viewPrefixByApp.has(app)) return viewPrefixByApp.get(app)
572
+ let prefixed = false
573
+ try {
574
+ const View = app.get('view')
575
+ const probe = new View('hippocampus-probe', { defaultEngine: 'html', engines: {}, root: app.get('views') })
576
+ prefixed = typeof probe.path === 'string' && /^views[\\/]hippocampus-probe/.test(probe.path)
577
+ } catch (error) {
578
+ prefixed = false
579
+ }
580
+ viewPrefixByApp.set(app, prefixed)
581
+ return prefixed
582
+ }
583
+
549
584
  module.exports = { createHippocampusRouter }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hippo-digital/hippocampus",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "A design-knowledge base for NHS Prototype Kit projects: research, insights, needs, journeys and screens, traceable end to end.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -21,6 +21,7 @@ const fs = require('fs')
21
21
  const path = require('path')
22
22
  const { openWorkbook, readSheetGrid } = require('./lib/xlsx-grid')
23
23
  const { KnowledgeSchema } = require('../lib/schema')
24
+ const { readMeta, migrateInMemory } = require('../lib/schema-version')
24
25
  const { createContextOrExit } = require('../lib/context')
25
26
  const ctx = createContextOrExit()
26
27
  const { knowledgeSourceDir } = ctx.paths
@@ -164,7 +165,15 @@ function main () {
164
165
  const preview = Object.fromEntries(fs.readdirSync(knowledgeSourceDir)
165
166
  .filter((f) => f.endsWith('.json') && !f.startsWith('_'))
166
167
  .map((f) => [key(f), proposed[f] || JSON.parse(fs.readFileSync(path.join(knowledgeSourceDir, f), 'utf8'))]))
167
- const result = KnowledgeSchema.safeParse(preview)
168
+ // Check it the way `hippocampus validate` reads it: a project that has never
169
+ // imported its context gets the same stub from project.json, and an older
170
+ // schema version is migrated in memory first. Without this, a freshly
171
+ // initialised project could not import design actions at all.
172
+ if (!preview.projectContext && preview.project) {
173
+ preview.projectContext = { id: `${preview.project.id}-context`, title: preview.project.name, summary: preview.project.description }
174
+ }
175
+ const { data: migrated } = migrateInMemory(preview, readMeta(knowledgeSourceDir))
176
+ const result = KnowledgeSchema.safeParse(migrated)
168
177
  if (!result.success) {
169
178
  console.error('\nThe import would make the knowledge base invalid:')
170
179
  for (const issue of result.error.issues.slice(0, 10)) console.error(`- ${issue.path.join('.')}: ${issue.message}`)
@@ -174,7 +183,7 @@ function main () {
174
183
  for (const [file, data] of Object.entries(proposed)) {
175
184
  fs.writeFileSync(path.join(knowledgeSourceDir, file), `${JSON.stringify(data, null, 2)}\n`)
176
185
  }
177
- console.log(`\nImported from ${path.relative(ctx.root, path.resolve(args.workbook))}. Run `npx hippocampus validate` to confirm.`)
186
+ console.log(`\nImported from ${path.relative(ctx.root, path.resolve(args.workbook))}. Run npx hippocampus validate to confirm.`)
178
187
  }
179
188
 
180
189
  function rows (workbook, sheetName) {
@@ -38,7 +38,7 @@ The catalog also includes:
38
38
  Use these keys on every `<name>/SKILL.md` file:
39
39
 
40
40
  - `name` - required by the spec; matches the directory name, lowercase kebab-case
41
- - `description` - required by the spec; what the skill does **and when to use it**, in words somebody would actually type. Max 1024 characters. This is the only thing an agent reads before choosing the skill, so a vague one means the skill never fires.
41
+ - `description` - required by the spec; what the skill does **and when to use it**, in words somebody would actually type. Max 1024 characters. This is the only thing an agent reads before choosing the skill, so a vague one means the skill never fires. Where another skill could fire on the same words, say what this one is not for and name the skill that is ("Not for building clickable screens (use add-prototype-screen)"); two skills whose descriptions both claim "build a journey" leave the agent guessing.
42
42
  - `id` - stable lowercase kebab-case skill ID; must equal `name`
43
43
  - `title` - short human-readable name
44
44
  - `purpose` - one-sentence statement of the task outcome
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: add-scenario
3
- description: "Adds a scenario record linking existing users and needs to a concrete trigger and context. Use when existing users and needs need a situation that can drive a journey, or when someone asks to add or write a scenario."
3
+ description: "Adds a scenario record to the knowledge base, linking existing users and needs to a concrete trigger and context. Use when existing users and needs need a situation that can drive a journey, or when someone asks to add a scenario to the knowledge base. Not for writing up a rough idea as a scenario document before any user or need records exist, which a project may have its own skill for."
4
4
  id: add-scenario
5
5
  title: Add scenario
6
6
  purpose: Add a concrete scenario that links existing users and needs to journey work.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: create-journey-from-scenario
3
- description: "Turns an existing scenario into a blueprint-ready journey with ordered steps and screens. Use when a scenario exists and needs a journey, or when someone asks to build, draft or map a user journey."
3
+ description: "Writes a journey record into the knowledge base from an existing scenario record: ordered steps with blueprint lanes, needs, screens and evidence. Use when a scenario in hippocampus/source/scenarios.json needs a journey, or when someone asks for a journey map or service blueprint. Not for building clickable screens (use add-prototype-screen) or for drafting journeys as standalone documents, which a project may have its own skill for."
4
4
  id: create-journey-from-scenario
5
5
  title: Create journey from scenario
6
6
  purpose: Turn an existing scenario into a blueprint-ready journey.