@hippo-digital/hippocampus 1.0.0-rc.4 → 1.0.0-rc.6
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 +69 -0
- package/lib/host-edit.js +31 -1
- package/package.json +2 -1
- package/scripts/eject.js +19 -4
- package/scripts/import-blueprint-spreadsheet.js +95 -32
- package/scripts/init.js +46 -3
- package/scripts/smoke-routes.js +31 -3
- package/scripts/validate-skills.js +17 -0
- package/skills/onboard-team-member.skill.md +1 -2
- package/views/hippocampus/index.html +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -30,12 +30,81 @@ journeys and screens they justify, rendered as a viewer inside your prototype.
|
|
|
30
30
|
- Commands that need a knowledge base refuse when none is found and say where
|
|
31
31
|
they looked, rather than exiting 0 having done nothing.
|
|
32
32
|
|
|
33
|
+
### A fresh install
|
|
34
|
+
|
|
35
|
+
- `init` writes the thirteen collection files as empty arrays. The loader
|
|
36
|
+
already treated a missing file as empty, so the viewer ran without them, but
|
|
37
|
+
every skill declares the files it reads and an absent file failed that check
|
|
38
|
+
in a project whose only fault was being new.
|
|
39
|
+
- The directories it scaffolds each carry a `.gitkeep`. Git does not track an
|
|
40
|
+
empty directory, so without one the scaffold vanished on the next clone and
|
|
41
|
+
the skills reading from it failed for reasons invisible in the working copy.
|
|
42
|
+
- Directories are scaffolded on every run, not only the first. A project
|
|
43
|
+
initialised before a directory existed never gained it otherwise.
|
|
44
|
+
|
|
45
|
+
### The stock Prototype Kit
|
|
46
|
+
|
|
47
|
+
Tested against a real kit cloned from `nhsuk/nhsuk-prototype-kit`, which found
|
|
48
|
+
three things the release gate's hand-written stand-in could not.
|
|
49
|
+
|
|
50
|
+
- `doctor`'s route check follows the URL the app announces. A stock kit takes
|
|
51
|
+
its port from `app/config.js` and ignores `PORT`, so the check timed out and
|
|
52
|
+
`doctor` reported a problem on a brand new install where nothing was wrong.
|
|
53
|
+
- `eject` removes the `viewsPath` entry from `app.js` itself, restoring both
|
|
54
|
+
host files to exactly what they were before `init`. It used to remove the
|
|
55
|
+
`routes.js` block, ask for the `app.js` entry by hand and exit non-zero -
|
|
56
|
+
an automatic edit that could only be undone manually.
|
|
57
|
+
- The gate's scratch project is now a faithful copy of a stock kit: two plain
|
|
58
|
+
string arrays in `app.js` rather than one, the port in `app/config.js`, a
|
|
59
|
+
`.github` holding only workflows. `skills install` creates its three
|
|
60
|
+
directories beside them without disturbing them.
|
|
61
|
+
|
|
62
|
+
The viewer's landing page no longer captions itself "Prototype Kit add-on
|
|
63
|
+
spike", which was a development-era label every install would have seen.
|
|
64
|
+
|
|
65
|
+
### The blueprint importer
|
|
66
|
+
|
|
67
|
+
Run against a real service blueprint it produced **88 unmapped rows and one
|
|
68
|
+
mapped**. Four faults, all silent:
|
|
69
|
+
|
|
70
|
+
- **It did not speak the schema's vocabulary.** A blueprint authored against the
|
|
71
|
+
data model uses `Frontstage`, `Backstage`, `Support processes`,
|
|
72
|
+
`Data dependencies`, `Security and governance`, `Exception handling` and
|
|
73
|
+
`Future state`. The triage table matched `Back office`, `Data`, `Processes`,
|
|
74
|
+
`Exception journeys` and `Future steps` - a different dialect. Both are now
|
|
75
|
+
covered, along with `Screen` and `User action`.
|
|
76
|
+
- **Two lanes were unreachable at any label.** `frontstage` and
|
|
77
|
+
`securityAndGovernance` appeared nowhere as a destination, so no spelling
|
|
78
|
+
could have imported them.
|
|
79
|
+
- **Step names came from the wrong row, and the first two lanes were dropped.**
|
|
80
|
+
The header was guessed as whichever of the first six rows had the most
|
|
81
|
+
populated cells, read the names from the row *after* it, and started lanes two
|
|
82
|
+
rows further down. Steps were named after the contents of the User action row,
|
|
83
|
+
and `Screen` and `User action` never appeared at all. The header is now the row
|
|
84
|
+
above the first labelled row, which is structural rather than a guess.
|
|
85
|
+
- **Ordinary tables were forced into blueprint shape.** An Evidence tab became 74
|
|
86
|
+
lanes named after repeated step names. A blueprint's step-header row has an
|
|
87
|
+
empty column 0 and its lane labels are distinct; a table has neither. A sheet
|
|
88
|
+
failing either test is read flat, which keeps every cell for review.
|
|
89
|
+
|
|
90
|
+
The same file now maps every lane, names its steps correctly and classifies all
|
|
91
|
+
four sheets, with nothing unmapped.
|
|
92
|
+
|
|
93
|
+
The grid logic is exported and covered by unit tests - `npm run test:unit`, also
|
|
94
|
+
run by the release gate. They are the package's first.
|
|
95
|
+
|
|
33
96
|
### Validation
|
|
34
97
|
|
|
35
98
|
- Three tiers: errors are broken references, warnings are gaps worth filling,
|
|
36
99
|
info is coverage. `--strict` promotes warnings to failures.
|
|
37
100
|
- `doctor` checks wiring, integrity and every route, and prints the resolved
|
|
38
101
|
root first.
|
|
102
|
+
- `skills validate` resolves the project to check against the same way every
|
|
103
|
+
other command does. It previously defaulted to a path relative to its own
|
|
104
|
+
location that only existed in this monorepo, so in an installed package it
|
|
105
|
+
pointed at `<host>/node_modules/apps/demo` and failed every check. The
|
|
106
|
+
release gate now runs shipped commands against a real install rather than
|
|
107
|
+
only checking that they load, which is what let this through.
|
|
39
108
|
|
|
40
109
|
### Data contract
|
|
41
110
|
|
package/lib/host-edit.js
CHANGED
|
@@ -128,6 +128,36 @@ function addToStringArray (source, { name, entry }) {
|
|
|
128
128
|
return { action: 'updated', source: source.replace(full, replacement) }
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* The inverse of addToStringArray, held to the same standard: act only on an
|
|
133
|
+
* unambiguous single match, otherwise say so and change nothing.
|
|
134
|
+
*
|
|
135
|
+
* Without this, `init` added the viewsPath entry automatically and `eject`
|
|
136
|
+
* asked for it back by hand and exited non-zero - so undoing an automatic edit
|
|
137
|
+
* was a manual step that looked like a failure. An edit this package made is an
|
|
138
|
+
* edit it should be able to take back.
|
|
139
|
+
*/
|
|
140
|
+
function removeFromStringArray (source, { name, entry }) {
|
|
141
|
+
if (!source.includes(entry)) return { action: 'unchanged', source }
|
|
142
|
+
|
|
143
|
+
const pattern = new RegExp(`(const\\s+${name}\\s*=\\s*\\[)([^\\]]*)\\]`, 'g')
|
|
144
|
+
const matches = [...source.matchAll(pattern)]
|
|
145
|
+
if (matches.length !== 1) {
|
|
146
|
+
return { action: 'no-anchor', reason: `Expected exactly one \`const ${name} = [...]\`, found ${matches.length}.` }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const [full, open, inner] = matches[0]
|
|
150
|
+
if (!inner.includes(entry)) {
|
|
151
|
+
return { action: 'no-anchor', reason: `The entry is in app.js but not inside \`${name}\`.` }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const indent = (inner.match(/\n(\s+)/) || [, ' '])[1]
|
|
155
|
+
const kept = inner.split(',').map((item) => item.trim()).filter(Boolean).filter((item) => item !== entry)
|
|
156
|
+
const body = kept.length ? `\n${indent}${kept.join(`,\n${indent}`)}\n` : '\n'
|
|
157
|
+
|
|
158
|
+
return { action: 'updated', source: source.replace(full, `${open}${body}]`) }
|
|
159
|
+
}
|
|
160
|
+
|
|
131
161
|
function backup (filePath) {
|
|
132
162
|
const backupPath = `${filePath}.hippocampus-backup`
|
|
133
163
|
if (!fs.existsSync(backupPath)) fs.copyFileSync(filePath, backupPath)
|
|
@@ -148,4 +178,4 @@ function diff (before, after, filePath) {
|
|
|
148
178
|
return out.join('\n')
|
|
149
179
|
}
|
|
150
180
|
|
|
151
|
-
module.exports = { upsertBlock, removeBlock, addToStringArray, findBlock, hashBody, backup, diff }
|
|
181
|
+
module.exports = { upsertBlock, removeBlock, addToStringArray, removeFromStringArray, findBlock, hashBody, backup, diff }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippo-digital/hippocampus",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.6",
|
|
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",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"views",
|
|
15
15
|
"assets",
|
|
16
16
|
"scripts",
|
|
17
|
+
"!scripts/__tests__",
|
|
17
18
|
"skills",
|
|
18
19
|
"agents",
|
|
19
20
|
"instructions",
|
package/scripts/eject.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
const fs = require('fs')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const { resolveRoot } = require('../lib/resolve-root')
|
|
5
|
-
const { removeBlock } = require('../lib/host-edit')
|
|
5
|
+
const { removeBlock, removeFromStringArray, backup } = require('../lib/host-edit')
|
|
6
6
|
|
|
7
7
|
// Removes the host edits and nothing else. All data stays: the knowledge base
|
|
8
8
|
// is the team's work, not this package's, and a command that deletes it because
|
|
9
9
|
// somebody wanted to stop using the viewer would be indefensible.
|
|
10
10
|
|
|
11
|
+
const APP_VIEWS_ENTRY = "require('@hippo-digital/hippocampus').createHippocampus().viewsPath"
|
|
12
|
+
|
|
11
13
|
const argv = process.argv.slice(2)
|
|
12
14
|
const dryRun = argv.includes('--dry-run')
|
|
13
15
|
|
|
@@ -31,9 +33,22 @@ function main () {
|
|
|
31
33
|
const appPath = path.join(root, 'app.js')
|
|
32
34
|
if (fs.existsSync(appPath)) {
|
|
33
35
|
const source = fs.readFileSync(appPath, 'utf8')
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const result = removeFromStringArray(source, { name: 'viewsPath', entry: APP_VIEWS_ENTRY })
|
|
37
|
+
|
|
38
|
+
if (result.action === 'updated') {
|
|
39
|
+
changed++
|
|
40
|
+
console.log(`${dryRun ? 'would remove' : 'removed'} the viewsPath entry from app.js`)
|
|
41
|
+
if (!dryRun) {
|
|
42
|
+
backup(appPath)
|
|
43
|
+
fs.writeFileSync(appPath, result.source)
|
|
44
|
+
}
|
|
45
|
+
} else if (result.action === 'no-anchor') {
|
|
46
|
+
console.log(`\napp.js could not be edited automatically: ${result.reason}`)
|
|
47
|
+
console.log('Remove this entry by hand:')
|
|
48
|
+
console.log(` ${APP_VIEWS_ENTRY}`)
|
|
49
|
+
} else if (source.includes('@hippo-digital/hippocampus')) {
|
|
50
|
+
console.log('\napp.js still references the package somewhere other than viewsPath.')
|
|
51
|
+
console.log('Check it by hand before uninstalling.')
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
|
|
@@ -2,7 +2,6 @@ const fs = require('fs')
|
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const { openWorkbook, readSheetGrid } = require('./lib/xlsx-grid')
|
|
4
4
|
const { createContextOrExit } = require('../lib/context')
|
|
5
|
-
const ctx = createContextOrExit()
|
|
6
5
|
|
|
7
6
|
// Generic triage mapping from common service-blueprint swimlane vocabulary to
|
|
8
7
|
// where it belongs in Hippocampus's knowledge model (see
|
|
@@ -10,6 +9,19 @@ const ctx = createContextOrExit()
|
|
|
10
9
|
// "unmapped" and is flagged for a manual decision - this list intentionally
|
|
11
10
|
// holds only generic blueprint/service-design terms, not any one project's
|
|
12
11
|
// specific persona or team names, so the same rules apply to any spreadsheet.
|
|
12
|
+
// Generic triage mapping from service-blueprint swimlane vocabulary to where it
|
|
13
|
+
// belongs in Hippocampus's knowledge model (see docs/source-model.md). Anything
|
|
14
|
+
// that doesn't match falls through as "unmapped" and is flagged for a manual
|
|
15
|
+
// decision. This list intentionally holds only generic blueprint/service-design
|
|
16
|
+
// terms, not any one project's persona or team names.
|
|
17
|
+
//
|
|
18
|
+
// It covers BOTH dialects, because the first version covered only one and not
|
|
19
|
+
// the important one. Every JourneyStep field name is a lane label somebody will
|
|
20
|
+
// write - a blueprint authored against the schema used `Frontstage`,
|
|
21
|
+
// `Backstage`, `Support processes`, `Data dependencies`,
|
|
22
|
+
// `Security and governance`, `Exception handling` and `Future state`, and the
|
|
23
|
+
// table matched none of them. `frontstage` and `securityAndGovernance` had no
|
|
24
|
+
// destination at all, so those lanes were unreachable under any label.
|
|
13
25
|
const SWIMLANE_TRIAGE = [
|
|
14
26
|
// Open questions and WIP markers are checked first so they take priority
|
|
15
27
|
// over the more generic keyword matches below (e.g. "Do we need a row for
|
|
@@ -17,18 +29,21 @@ const SWIMLANE_TRIAGE = [
|
|
|
17
29
|
{ match: /^do we need/i, destination: 'assumption', note: 'An open question row, not step content.' },
|
|
18
30
|
{ match: /unhappy path/i, destination: 'assumption', note: 'Likely deserves its own scenario/journey once detailed, rather than a lane on this one.' },
|
|
19
31
|
|
|
20
|
-
{ match: /^user groups
|
|
21
|
-
{ match: /^
|
|
22
|
-
{ match:
|
|
23
|
-
{ match: /^
|
|
24
|
-
{ match: /
|
|
32
|
+
{ match: /^user groups?$/i, destination: 'users', note: 'One User record per distinct persona named in this row.' },
|
|
33
|
+
{ match: /^screens?$/i, destination: 'journeyStep.screenIds', note: 'Match each route to an existing Screen record, or add one.' },
|
|
34
|
+
{ match: /^((external )?user steps|user actions?|what the user does)/i, destination: 'journeyStep.userAction', note: 'What the user actually does at this step.' },
|
|
35
|
+
{ match: /^front ?stage|^front.of.house/i, destination: 'journeyStep.frontstage', note: 'What the user can see at this step.' },
|
|
36
|
+
{ match: /^back ?stage|^back ?office/i, destination: 'journeyStep.backstage', note: '' },
|
|
37
|
+
{ match: /^(support )?processes/i, destination: 'journeyStep.supportProcesses', note: '' },
|
|
38
|
+
{ match: /^data( dependenc(y|ies))?$/i, destination: 'journeyStep.dataDependencies', note: '' },
|
|
39
|
+
{ match: /^(security|governance|security and governance|information governance)/i, destination: 'journeyStep.securityAndGovernance', note: '' },
|
|
25
40
|
{ match: /^pain points/i, destination: 'journeyStep.painPoints', note: '' },
|
|
26
|
-
{ match: /^
|
|
27
|
-
{ match: /^
|
|
28
|
-
{ match: /needs? linked to (jira|a ticket)/i, destination: 'needs', note: '
|
|
29
|
-
{ match: /^backlog status/i, destination: '
|
|
41
|
+
{ match: /^exception (handling|journeys)|^edge cases/i, destination: 'journeyStep.exceptionHandling', note: '' },
|
|
42
|
+
{ match: /^future (state|steps?)$/i, destination: 'journeyStep.futureState', note: 'Proposed/target-state, not current fact.' },
|
|
43
|
+
{ match: /needs? linked to (jira|a ticket)/i, destination: 'needs', note: 'Ticket references, not needs - link to the existing Need records instead.' },
|
|
44
|
+
{ match: /^backlog status/i, destination: 'unmapped', note: 'Delivery tracking, not design knowledge. Usually left out.' },
|
|
30
45
|
{ match: /^notes$/i, destination: 'projectContext.facts', note: '' },
|
|
31
|
-
{ match: /^opportunities/i, destination: 'assumption', note: '
|
|
46
|
+
{ match: /^opportunities/i, destination: 'assumption', note: 'Proposed, not observed - record as an assumption until evidenced.' },
|
|
32
47
|
{ match: /^systems/i, destination: 'projectContext.channels', note: '' },
|
|
33
48
|
{ match: /^sources$/i, destination: 'evidence', note: '' }
|
|
34
49
|
]
|
|
@@ -43,7 +58,7 @@ async function main () {
|
|
|
43
58
|
const workbook = openWorkbook(documentPath)
|
|
44
59
|
|
|
45
60
|
const draft = {
|
|
46
|
-
sourceDocument: path.relative(
|
|
61
|
+
sourceDocument: path.relative(createContextOrExit().root, documentPath),
|
|
47
62
|
importedAt: new Date().toISOString(),
|
|
48
63
|
note: 'Review artefact only - nothing here has been written to the project source yet. Decide, sheet by sheet and row by row, whether any identifying details should be genericized before promoting content into <project>/source/*.json.',
|
|
49
64
|
sheets: Object.fromEntries(
|
|
@@ -74,45 +89,86 @@ async function main () {
|
|
|
74
89
|
* silently dropping its content.
|
|
75
90
|
*/
|
|
76
91
|
function extractSheet (workbook, sheetName) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
return extractFromGrid(readSheetGrid(workbook, sheetName))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function extractFromGrid (grid) {
|
|
96
|
+
const { steps, laneStartRow, stepHeaderIsAboveLabels } = buildSteps(grid)
|
|
97
|
+
const swimlanes = groupIntoSwimlanes(grid, steps, laneStartRow)
|
|
80
98
|
|
|
81
99
|
// A handful of stray column-0 values isn't enough evidence that a sheet
|
|
82
100
|
// follows the swimlane convention - most of its actual content needs to
|
|
83
101
|
// have landed inside a swimlane, or this isn't really a step x lane
|
|
84
102
|
// blueprint and forcing that shape on it would silently drop everything
|
|
85
103
|
// that came before the first (possibly late, possibly sparse) label.
|
|
86
|
-
const contentCells = flattenCells(grid.slice(
|
|
104
|
+
const contentCells = flattenCells(grid.slice(laneStartRow)).length
|
|
87
105
|
const capturedCells = swimlanes.reduce(
|
|
88
106
|
(sum, swimlane) => sum + Object.values(swimlane.cellsByStep).reduce((n, v) => n + asList(v).length, 0),
|
|
89
107
|
0
|
|
90
108
|
)
|
|
91
109
|
|
|
92
|
-
|
|
110
|
+
// Two structural tests separate a blueprint from an ordinary table, because
|
|
111
|
+
// both have a populated column 0 and both passed the coverage test on their
|
|
112
|
+
// own - an Evidence tab came out as 74 lanes named after repeated step names,
|
|
113
|
+
// and a Sources tab as 8 lanes named after its ID column.
|
|
114
|
+
//
|
|
115
|
+
// 1. A blueprint's step-header row has an EMPTY column 0 - the corner above
|
|
116
|
+
// the lane labels. A table's header row names that column ("Source ID").
|
|
117
|
+
// 2. Each lane appears once. Duplicate labels mean column 0 holds data.
|
|
118
|
+
//
|
|
119
|
+
// A blueprint that does label its corner cell is read as flat, which keeps
|
|
120
|
+
// every cell for manual review. Wrongly flat loses nothing; wrongly blueprint
|
|
121
|
+
// invents a structure and buries the content.
|
|
122
|
+
const labels = swimlanes.map((swimlane) => swimlane.label)
|
|
123
|
+
const labelsAreUnique = new Set(labels).size === labels.length
|
|
124
|
+
|
|
125
|
+
if (stepHeaderIsAboveLabels && swimlanes.length && labelsAreUnique &&
|
|
126
|
+
contentCells > 0 && capturedCells / contentCells >= 0.5) {
|
|
93
127
|
return { shape: 'blueprint', steps: steps.map((step) => step.label), swimlanes }
|
|
94
128
|
}
|
|
95
129
|
|
|
96
130
|
return { shape: 'flat', cells: flattenCells(grid) }
|
|
97
131
|
}
|
|
98
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Finds the row of step names and the row the lanes start on.
|
|
135
|
+
*
|
|
136
|
+
* A blueprint's shape is: some number of title/phase rows, then a row of step
|
|
137
|
+
* names with an empty column 0, then one labelled row per lane. So the step
|
|
138
|
+
* header is the row immediately above the first labelled row - structural, and
|
|
139
|
+
* true whether there are zero title rows or three.
|
|
140
|
+
*
|
|
141
|
+
* The previous version guessed the header as whichever of the first six rows
|
|
142
|
+
* had the most populated cells, then read the step names from the row AFTER it
|
|
143
|
+
* and started lanes two rows later. On a real blueprint that named the steps
|
|
144
|
+
* after the contents of the User action row and silently dropped the first two
|
|
145
|
+
* lanes entirely.
|
|
146
|
+
*/
|
|
99
147
|
function buildSteps (grid) {
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
148
|
+
// A lane row has a label AND content beside it. A title row ("Patient search
|
|
149
|
+
// blueprint" in A1) has the label and nothing else, and taking it as the
|
|
150
|
+
// first lane puts the header above the top of the sheet and finds no steps
|
|
151
|
+
// at all. Requiring content beside the label tells them apart.
|
|
152
|
+
const firstLabelRow = grid.findIndex((row) => row && row[0] && row.slice(1).filter(Boolean).length > 0)
|
|
153
|
+
|
|
154
|
+
if (firstLabelRow === -1) return { steps: [], headerRowIndex: 0, laneStartRow: grid.length, stepHeaderIsAboveLabels: false }
|
|
155
|
+
|
|
156
|
+
// Usually the header sits above the first label. A sheet that puts a corner
|
|
157
|
+
// label in column 0 of its header row ("Step", "Stage") has no row above to
|
|
158
|
+
// take, so the header is that row itself and the lanes start below it.
|
|
159
|
+
const above = firstLabelRow > 0 ? (grid[firstLabelRow - 1] || []) : []
|
|
160
|
+
const aboveHasSteps = above.slice(1).filter(Boolean).length > 0
|
|
161
|
+
|
|
162
|
+
const headerRowIndex = aboveHasSteps ? firstLabelRow - 1 : firstLabelRow
|
|
163
|
+
const laneStartRow = aboveHasSteps ? firstLabelRow : firstLabelRow + 1
|
|
105
164
|
|
|
106
165
|
const headerRow = grid[headerRowIndex] || []
|
|
107
|
-
const nextRow = grid[headerRowIndex + 1] || []
|
|
108
166
|
const steps = []
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const label = nextRow[col] || headerRow[col]
|
|
112
|
-
if (label) steps.push({ column: col, label: String(label).trim() })
|
|
167
|
+
for (let col = 1; col < headerRow.length; col++) {
|
|
168
|
+
if (headerRow[col]) steps.push({ column: col, label: String(headerRow[col]).trim() })
|
|
113
169
|
}
|
|
114
170
|
|
|
115
|
-
return { steps, headerRowIndex }
|
|
171
|
+
return { steps, headerRowIndex, laneStartRow, stepHeaderIsAboveLabels: aboveHasSteps }
|
|
116
172
|
}
|
|
117
173
|
|
|
118
174
|
function groupIntoSwimlanes (grid, steps, startRow) {
|
|
@@ -236,7 +292,14 @@ function parseArgs (args) {
|
|
|
236
292
|
return parsed
|
|
237
293
|
}
|
|
238
294
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
295
|
+
// Exported so the grid logic can be tested without a workbook or a project:
|
|
296
|
+
// these are the parts that were silently wrong, and they are pure functions of
|
|
297
|
+
// a grid.
|
|
298
|
+
module.exports = { buildSteps, groupIntoSwimlanes, extractFromGrid, triageFor }
|
|
299
|
+
|
|
300
|
+
if (require.main === module) {
|
|
301
|
+
main().catch((error) => {
|
|
302
|
+
console.error(error.message)
|
|
303
|
+
process.exit(1)
|
|
304
|
+
})
|
|
305
|
+
}
|
package/scripts/init.js
CHANGED
|
@@ -37,6 +37,7 @@ function main () {
|
|
|
37
37
|
console.log(`Resolved from: ${source}\n`)
|
|
38
38
|
|
|
39
39
|
planConfig(root)
|
|
40
|
+
planKnowledgeDirs(root)
|
|
40
41
|
planKnowledgeBase(root)
|
|
41
42
|
planArtefacts(root, artefactsDir(root))
|
|
42
43
|
planArtefactGovernance(root)
|
|
@@ -125,6 +126,41 @@ function listTemplateFiles (dir, prefix = '') {
|
|
|
125
126
|
return found
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
// The directories the skills read from, scaffolded on every run rather than
|
|
130
|
+
// only on a first install. A project initialised before a directory existed
|
|
131
|
+
// never got it otherwise - which is how a knowledge base ends up missing
|
|
132
|
+
// `inbox/personas` and the persona skill fails its own `reads:` check.
|
|
133
|
+
//
|
|
134
|
+
// Each carries a .gitkeep. Git does not track an empty directory, so without
|
|
135
|
+
// one the scaffold is gone the moment somebody clones the repo, and the skills
|
|
136
|
+
// that read from it fail for reasons nobody can see in the working copy they
|
|
137
|
+
// are looking at.
|
|
138
|
+
const EMPTY_COLLECTIONS = [
|
|
139
|
+
'users', 'needs', 'scenarios', 'journeys', 'screens', 'evidence', 'decisions',
|
|
140
|
+
'assumptions', 'research-rounds', 'participants', 'insights', 'design-actions',
|
|
141
|
+
'relationships'
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
const KNOWLEDGE_DIRS = [
|
|
145
|
+
'source', 'inbox/personas', 'inbox/project', 'inbox/research',
|
|
146
|
+
'imports/project', 'imports/research', 'manifests'
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
function planKnowledgeDirs (root) {
|
|
150
|
+
const missing = KNOWLEDGE_DIRS.filter((dir) => !fs.existsSync(path.join(root, 'hippocampus', dir)))
|
|
151
|
+
if (!missing.length) return
|
|
152
|
+
|
|
153
|
+
plan(`hippocampus/: ${missing.length} ${missing.length === 1 ? 'directory' : 'directories'} (${missing.join(', ')})`, () => {
|
|
154
|
+
for (const dir of missing) {
|
|
155
|
+
const target = path.join(root, 'hippocampus', dir)
|
|
156
|
+
fs.mkdirSync(target, { recursive: true })
|
|
157
|
+
// `source` always receives project.json and _meta.json, so it is never
|
|
158
|
+
// the empty directory this guards against.
|
|
159
|
+
if (dir !== 'source') fs.writeFileSync(path.join(target, '.gitkeep'), '')
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
128
164
|
function planKnowledgeBase (root) {
|
|
129
165
|
const sourceDir = path.join(root, 'hippocampus/source')
|
|
130
166
|
const projectPath = path.join(sourceDir, 'project.json')
|
|
@@ -137,9 +173,7 @@ function planKnowledgeBase (root) {
|
|
|
137
173
|
const id = kebab(dirName) || 'prototype'
|
|
138
174
|
const name = dirName
|
|
139
175
|
plan('hippocampus/source/project.json and an empty knowledge base', () => {
|
|
140
|
-
|
|
141
|
-
fs.mkdirSync(path.join(root, 'hippocampus', dir), { recursive: true })
|
|
142
|
-
}
|
|
176
|
+
fs.mkdirSync(sourceDir, { recursive: true })
|
|
143
177
|
fs.writeFileSync(projectPath, JSON.stringify({
|
|
144
178
|
id: `${id}-knowledge`,
|
|
145
179
|
name,
|
|
@@ -153,6 +187,15 @@ function planKnowledgeBase (root) {
|
|
|
153
187
|
generator: 'hippocampus init',
|
|
154
188
|
updatedAt: new Date().toISOString()
|
|
155
189
|
}, null, 2) + '\n')
|
|
190
|
+
|
|
191
|
+
// The loader treats a missing collection as empty, so the viewer runs
|
|
192
|
+
// without these. The skills do not: every one declares the files it reads,
|
|
193
|
+
// and a file that is absent rather than empty fails that check in a project
|
|
194
|
+
// that is simply new. Writing them also shows someone opening the directory
|
|
195
|
+
// what the knowledge base is made of, which an empty folder does not.
|
|
196
|
+
for (const collection of EMPTY_COLLECTIONS) {
|
|
197
|
+
fs.writeFileSync(path.join(sourceDir, `${collection}.json`), '[]\n')
|
|
198
|
+
}
|
|
156
199
|
})
|
|
157
200
|
}
|
|
158
201
|
|
package/scripts/smoke-routes.js
CHANGED
|
@@ -4,7 +4,13 @@ const { listDocs } = require('../lib/docs')
|
|
|
4
4
|
const ctx = createContextOrExit()
|
|
5
5
|
|
|
6
6
|
const port = process.env.SMOKE_PORT || 4587
|
|
7
|
-
|
|
7
|
+
// Mutable, because the port we ask for is not always the port the app uses.
|
|
8
|
+
// The stock NHS Prototype Kit reads its port from `app/config.js`, where it is
|
|
9
|
+
// hardcoded to 3000, and ignores PORT entirely - so on a brand new kit this
|
|
10
|
+
// check failed and `doctor` reported a problem on an install where nothing was
|
|
11
|
+
// wrong. The app announces the URL it is actually on; believe that over the
|
|
12
|
+
// environment we set.
|
|
13
|
+
let baseUrl = `http://127.0.0.1:${port}`
|
|
8
14
|
// A cold Prototype Kit boot compiles sass before it listens, which on a fresh
|
|
9
15
|
// install is a good deal slower than the 15s this used to allow - and the
|
|
10
16
|
// failure looked like "your routes are broken" rather than "it had not finished
|
|
@@ -111,17 +117,39 @@ async function waitForServer (server, output) {
|
|
|
111
117
|
// Keep polling until the Prototype Kit has finished booting.
|
|
112
118
|
}
|
|
113
119
|
|
|
120
|
+
const announced = announcedPort(output())
|
|
121
|
+
if (announced && announced !== currentPort()) {
|
|
122
|
+
baseUrl = `http://127.0.0.1:${announced}`
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
await wait(250)
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
throw new Error(
|
|
118
129
|
`The prototype did not start listening on ${baseUrl} within ${timeoutMs}ms.\n` +
|
|
119
|
-
'This command starts your app with PORT set
|
|
120
|
-
'
|
|
130
|
+
'This command starts your app with PORT set and follows the URL the app\n' +
|
|
131
|
+
'announces, so a port set somewhere it never prints will be missed.\n' +
|
|
132
|
+
'Otherwise raise SMOKE_TIMEOUT_MS.\n' +
|
|
121
133
|
indent(output())
|
|
122
134
|
)
|
|
123
135
|
}
|
|
124
136
|
|
|
137
|
+
function currentPort () {
|
|
138
|
+
return baseUrl.slice(baseUrl.lastIndexOf(':') + 1)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// The kit prints its URLs through Browsersync once it is listening. Take the
|
|
142
|
+
// last one it mentions: an app that has moved port says so more than once, and
|
|
143
|
+
// the most recent is the one to trust.
|
|
144
|
+
function announcedPort (output) {
|
|
145
|
+
const matches = [...String(output).matchAll(/https?:\/\/(?:localhost|127\.0\.0\.1)(?::(\d{2,5}))?/gi)]
|
|
146
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
147
|
+
const found = matches[i][1]
|
|
148
|
+
if (found && found !== String(port)) return found
|
|
149
|
+
}
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
|
|
125
153
|
async function smokeRoutes (routes) {
|
|
126
154
|
const failures = []
|
|
127
155
|
|
|
@@ -3,6 +3,7 @@ const path = require('path')
|
|
|
3
3
|
const { z } = require('zod')
|
|
4
4
|
|
|
5
5
|
const packagePaths = require('../lib/package-paths')
|
|
6
|
+
const { resolveRoot } = require('../lib/resolve-root')
|
|
6
7
|
|
|
7
8
|
// Skills live in the package; the paths inside them (reads:, and the
|
|
8
9
|
// `.github/skills/<id>.skill.md` references in guidance) describe a HOST
|
|
@@ -13,9 +14,25 @@ const rootDir = packagePaths.packageRoot
|
|
|
13
14
|
const skillsDir = packagePaths.skillsDir
|
|
14
15
|
const catalogPath = path.join(skillsDir, 'skills.json')
|
|
15
16
|
|
|
17
|
+
// Two very different situations share this command.
|
|
18
|
+
//
|
|
19
|
+
// In this monorepo the package is not installed anywhere, so the consumer to
|
|
20
|
+
// validate against is the demo app. In a host, the package sits in
|
|
21
|
+
// node_modules and the consumer is the project around it - resolved the same
|
|
22
|
+
// way every other command resolves it.
|
|
23
|
+
//
|
|
24
|
+
// The old default was `<packageRoot>/../../apps/demo` unconditionally. From
|
|
25
|
+
// node_modules that is `<host>/node_modules/apps/demo`, a path that cannot
|
|
26
|
+
// exist, so every `reads:` check failed and the command was unusable in the
|
|
27
|
+
// place it matters most. It went unnoticed because nothing ran a shipped
|
|
28
|
+
// command against a real install - only checked that it loaded.
|
|
16
29
|
function readHostRoot () {
|
|
17
30
|
const flag = process.argv.indexOf('--host')
|
|
18
31
|
if (flag !== -1 && process.argv[flag + 1]) return path.resolve(process.argv[flag + 1])
|
|
32
|
+
|
|
33
|
+
const installed = rootDir.split(path.sep).includes('node_modules')
|
|
34
|
+
if (installed) return resolveRoot({ argv: process.argv.slice(2) }).root
|
|
35
|
+
|
|
19
36
|
return path.resolve(rootDir, '../../apps/demo')
|
|
20
37
|
}
|
|
21
38
|
|
|
@@ -10,7 +10,6 @@ composes:
|
|
|
10
10
|
- audit-knowledge-source
|
|
11
11
|
reads:
|
|
12
12
|
- hippocampus/source/project.json
|
|
13
|
-
- hippocampus/source/project-context.json
|
|
14
13
|
- hippocampus/source/users.json
|
|
15
14
|
- hippocampus/source/needs.json
|
|
16
15
|
- hippocampus/source/insights.json
|
|
@@ -53,7 +52,7 @@ Works in two modes. **Live** - answer their questions in conversation, grounded
|
|
|
53
52
|
|
|
54
53
|
### Read these first
|
|
55
54
|
|
|
56
|
-
1. `project.json` and `project-context.json` for what the project is. **`project-context.json` is the narrative half
|
|
55
|
+
1. `project.json` and, if it exists, `project-context.json` for what the project is. **`project-context.json` is the narrative half, and it is optional** - a project has one only once somebody has run `ingest-project-context`. If it is missing, or its `purpose`, `problemStatement` and `constraints` are empty, the project has never recorded why it exists - say that plainly and suggest `ingest-project-context`. Do not reconstruct a purpose from the graph.
|
|
57
56
|
2. The graph for the state. Everything below is counted, not remembered.
|
|
58
57
|
3. `npx hippocampus validate` for the coverage notes.
|
|
59
58
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{% block content %}
|
|
9
9
|
<div class="nhsuk-grid-row">
|
|
10
10
|
<div class="nhsuk-grid-column-two-thirds">
|
|
11
|
-
<span class="nhsuk-caption-l">
|
|
11
|
+
<span class="nhsuk-caption-l">Design knowledge base</span>
|
|
12
12
|
<h1>{{ knowledge.project.name }}</h1>
|
|
13
13
|
<p class="nhsuk-lede-text">{{ knowledge.project.description }}</p>
|
|
14
14
|
|