@hippo-digital/hippocampus 2.0.1 → 2.1.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.
- package/CHANGELOG.md +37 -0
- package/README.md +1 -0
- package/agents/knowledge-builder.md +1 -0
- package/agents/workflow-orchestrator.md +1 -0
- package/bin/hippocampus.js +1 -0
- package/lib/known.js +258 -0
- package/package.json +1 -1
- package/scripts/audit-provenance.js +1 -1
- package/scripts/known.js +118 -0
- package/skills/skills.json +26 -0
- package/skills/whats-known-about/SKILL.md +113 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
`hippocampus known <topic>` answers "what do we already know about this?" before
|
|
6
|
+
anyone finds it out a second time. A `whats-known-about` skill ships with it, and
|
|
7
|
+
`knowledge-builder` and `workflow-orchestrator` list it.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx hippocampus known "historic resident" "previous occupant"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Each argument is searched on its own, matching at the start of a word, so
|
|
14
|
+
`postcode` finds "postcodes" and `age` does not find "page". It reads the body of
|
|
15
|
+
every kind of record, not just the titles, because a topic is usually named in the
|
|
16
|
+
summary rather than the heading. The output keeps apart the things a summary tends
|
|
17
|
+
to merge:
|
|
18
|
+
|
|
19
|
+
- **Findings.** Insights and evidence, oldest round first. Each one keeps its own
|
|
20
|
+
round, date and confidence, because two rounds agreeing is a stronger result than
|
|
21
|
+
one sentence that hides both.
|
|
22
|
+
- **Assumptions.** These come from `assumptions.json`, plus any evidence whose
|
|
23
|
+
source type says it is an assertion. That test now lives in one place and
|
|
24
|
+
`source audit` uses it too, so the two commands cannot disagree about what counts.
|
|
25
|
+
- **Already built on these.** Screens, journeys, design actions and decisions,
|
|
26
|
+
found by following links forward up to three steps (`--hops`) and never back
|
|
27
|
+
through provenance. A need reaches a decision only through an insight and then a
|
|
28
|
+
design action. On NCRS, a single step from the need found the screens but none
|
|
29
|
+
of the five decisions, and naming what exists is what stops something being
|
|
30
|
+
built twice.
|
|
31
|
+
- **Coverage.** This covers rounds with a finding, rounds that name the topic
|
|
32
|
+
without one, rounds that produced no insights at all, and held files whose names
|
|
33
|
+
match but were never ingested. On NCRS, 7 of 14 rounds have no insights, so
|
|
34
|
+
finding nothing there means "not in the knowledge base", which is not the same as
|
|
35
|
+
"nobody asked". The output says which.
|
|
36
|
+
|
|
37
|
+
The command exits 0 when nothing matches, because finding nothing is an answer. It
|
|
38
|
+
supports `--json` for scripts and `--all` to lift the 25-item list limit.
|
|
39
|
+
|
|
3
40
|
## 2.0.1
|
|
4
41
|
|
|
5
42
|
`skills validate` says what it checked.
|
package/README.md
CHANGED
|
@@ -138,6 +138,7 @@ otherwise produce an empty knowledge base and no explanation.
|
|
|
138
138
|
npx hippocampus doctor # wiring, integrity and routes - start here
|
|
139
139
|
npx hippocampus validate # parse, check integrity, report coverage gaps
|
|
140
140
|
npx hippocampus validate --strict # and fail on warnings
|
|
141
|
+
npx hippocampus known "topic" # what is already known, what was built on it, what nobody asked
|
|
141
142
|
npx hippocampus research triage # rank a research folder before importing anything
|
|
142
143
|
npx hippocampus research sync # inbox artefacts to reviewable drafts
|
|
143
144
|
npx hippocampus source index # record what was ingested, before the copies go
|
|
@@ -18,6 +18,7 @@ Maintains the Hippocampus source model.
|
|
|
18
18
|
- `.github/skills/add-scenario/SKILL.md`
|
|
19
19
|
- `.github/skills/create-journey-from-scenario/SKILL.md`
|
|
20
20
|
- `.github/skills/audit-knowledge-source/SKILL.md`
|
|
21
|
+
- `.github/skills/whats-known-about/SKILL.md`
|
|
21
22
|
- `.github/skills/ingest-user-personas/SKILL.md`
|
|
22
23
|
- `.github/skills/record-design-decision/SKILL.md`
|
|
23
24
|
- `.github/skills/onboard-team-member/SKILL.md`
|
|
@@ -26,6 +26,7 @@ Coordinates larger Hippocampus delivery work.
|
|
|
26
26
|
- `.github/skills/review-research-import-draft/SKILL.md`
|
|
27
27
|
- `.github/skills/map-research-to-graph/SKILL.md`
|
|
28
28
|
- `.github/skills/audit-knowledge-source/SKILL.md`
|
|
29
|
+
- `.github/skills/whats-known-about/SKILL.md`
|
|
29
30
|
- `.github/skills/triage-research-corpus/SKILL.md`
|
|
30
31
|
- `.github/skills/onboard-team-member/SKILL.md`
|
|
31
32
|
|
package/bin/hippocampus.js
CHANGED
package/lib/known.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// "What do we already know about this?" answered from the knowledge base, so
|
|
2
|
+
// that nobody finds something out for a second time.
|
|
3
|
+
//
|
|
4
|
+
// Three things make an answer like this trustworthy, and each one is easy to
|
|
5
|
+
// lose in a summary:
|
|
6
|
+
//
|
|
7
|
+
// - Every claim keeps its own date, confidence and research round. Two rounds
|
|
8
|
+
// agreeing is a stronger finding than one sentence that hides both, and an
|
|
9
|
+
// old low-confidence insight is not the same fact as a recent strong one.
|
|
10
|
+
// - Assumptions are kept apart from findings. An assumption is a belief the
|
|
11
|
+
// design rests on; reporting one as research is the failure this knowledge
|
|
12
|
+
// base exists to stop.
|
|
13
|
+
// - Finding nothing is an answer. Which rounds exist, which of them produced
|
|
14
|
+
// nothing in the knowledge base, and which held files were never ingested
|
|
15
|
+
// all decide whether "nothing found" means "nobody asked".
|
|
16
|
+
|
|
17
|
+
// Evidence whose source type says it is an assertion rather than a finding.
|
|
18
|
+
// Shared with `source audit`, which classes unsourced evidence the same way.
|
|
19
|
+
const ASSERTION_TYPES = /assumption|principle|decision|local repo reference/i
|
|
20
|
+
|
|
21
|
+
// The fields a topic is usually named in. Titles alone miss most of it: the
|
|
22
|
+
// topic is normally in the body of a record, not its heading.
|
|
23
|
+
const SEARCH_FIELDS = {
|
|
24
|
+
evidence: ['title', 'summary', 'quotes'],
|
|
25
|
+
insights: ['title', 'summary'],
|
|
26
|
+
needs: ['statement'],
|
|
27
|
+
assumptions: ['statement'],
|
|
28
|
+
scenarios: ['title', 'trigger', 'context', 'happyPath', 'edgeCases'],
|
|
29
|
+
designActions: ['title', 'action', 'rationale'],
|
|
30
|
+
decisions: ['title', 'decision', 'consequence'],
|
|
31
|
+
screens: ['title', 'purpose'],
|
|
32
|
+
journeys: ['title', 'description']
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The kinds of record that are design work - things someone would build twice
|
|
36
|
+
// if they did not know they existed.
|
|
37
|
+
const BUILT_TYPES = new Set(['screens', 'journeys', 'designActions', 'decisions'])
|
|
38
|
+
const FINDING_TYPES = new Set(['insights', 'evidence'])
|
|
39
|
+
|
|
40
|
+
function escapeRegex (text) {
|
|
41
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Match at the start of a word, so "postcode" finds "postcodes" but "age" does
|
|
45
|
+
// not find "page".
|
|
46
|
+
function matcher (terms) {
|
|
47
|
+
const patterns = terms.map((term) => ({ term, re: new RegExp(`\\b${escapeRegex(term)}`, 'i') }))
|
|
48
|
+
return (text) => patterns.filter(({ re }) => re.test(text)).map(({ term }) => term)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function textOf (record, fields) {
|
|
52
|
+
return fields.map((field) => {
|
|
53
|
+
const value = record[field]
|
|
54
|
+
return Array.isArray(value) ? value.join(' ') : (value == null ? '' : String(value))
|
|
55
|
+
}).join(' ')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Edges pointing from a record to what was built on it. The schema's
|
|
59
|
+
// relationship rows point dependents at what they rely on for some types and
|
|
60
|
+
// the other way round for others, and some links live only in id-list fields,
|
|
61
|
+
// so this spells out each one rather than walking rows blindly. Provenance
|
|
62
|
+
// (who said it, which round) is deliberately absent: a round is not relevant
|
|
63
|
+
// because something drawn from it was.
|
|
64
|
+
function buildForwardEdges (knowledge) {
|
|
65
|
+
const forward = new Map()
|
|
66
|
+
const add = (from, to) => {
|
|
67
|
+
if (!from || !to || from === to) return
|
|
68
|
+
if (!forward.has(from)) forward.set(from, new Set())
|
|
69
|
+
forward.get(from).add(to)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const rel of knowledge.relationships || []) {
|
|
73
|
+
switch (rel.type) {
|
|
74
|
+
case 'supported-by': // need/insight supported by evidence
|
|
75
|
+
case 'uses-evidence':
|
|
76
|
+
case 'supports-insight':
|
|
77
|
+
case 'responds-to-insight': // design action responds to insight
|
|
78
|
+
case 'resolves-action': // decision resolves design action
|
|
79
|
+
case 'addresses-need': // screen addresses need
|
|
80
|
+
case 'renders-screen':
|
|
81
|
+
case 'records-decision':
|
|
82
|
+
add(rel.to, rel.from)
|
|
83
|
+
break
|
|
84
|
+
case 'tests-need': // insight or scenario tests a need
|
|
85
|
+
case 'leads-to-action':
|
|
86
|
+
case 'drives-journey':
|
|
87
|
+
add(rel.from, rel.to)
|
|
88
|
+
break
|
|
89
|
+
default:
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const need of knowledge.needs || []) for (const id of need.evidenceIds || []) add(id, need.id)
|
|
95
|
+
for (const insight of knowledge.insights || []) for (const id of insight.evidenceIds || []) add(id, insight.id)
|
|
96
|
+
for (const scenario of knowledge.scenarios || []) for (const id of scenario.needIds || []) add(scenario.id, id)
|
|
97
|
+
for (const screen of knowledge.screens || []) for (const id of screen.needIds || []) add(id, screen.id)
|
|
98
|
+
for (const action of knowledge.designActions || []) for (const id of action.insightIds || []) add(id, action.id)
|
|
99
|
+
for (const journey of knowledge.journeys || []) {
|
|
100
|
+
for (const step of journey.steps || []) {
|
|
101
|
+
for (const id of [...(step.needIds || []), ...(step.screenIds || []), ...(step.evidenceIds || []), ...(step.decisionIds || [])]) {
|
|
102
|
+
add(id, journey.id)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return forward
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function collectionIndex (knowledge) {
|
|
110
|
+
const where = new Map()
|
|
111
|
+
for (const collection of Object.keys(SEARCH_FIELDS).concat(['researchRounds', 'participants', 'users'])) {
|
|
112
|
+
for (const record of knowledge[collection] || []) where.set(record.id, { collection, record })
|
|
113
|
+
}
|
|
114
|
+
return where
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function roundOf (knowledge, roundId) {
|
|
118
|
+
const round = (knowledge.researchRounds || []).find((r) => r.id === roundId)
|
|
119
|
+
return round ? { id: round.id, title: round.title, date: round.date } : null
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function labelOf (collection, record) {
|
|
123
|
+
return record.title || record.statement || record.label || record.id
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {object} knowledge from store.getKnowledge()
|
|
128
|
+
* @param {string[]} terms words or phrases; a record matches on any of them
|
|
129
|
+
* @param {object} [options]
|
|
130
|
+
* @param {Array} [options.sourceArtefacts] entries from manifests/source-index.json
|
|
131
|
+
* @param {number} [options.hops=3] how far to follow what was built
|
|
132
|
+
*/
|
|
133
|
+
function whatsKnown (knowledge, terms, { sourceArtefacts = [], hops = 3 } = {}) {
|
|
134
|
+
const cleaned = terms.map((t) => t.trim()).filter(Boolean)
|
|
135
|
+
if (!cleaned.length) throw new Error('Give at least one word or phrase to look for.')
|
|
136
|
+
const match = matcher(cleaned)
|
|
137
|
+
const where = collectionIndex(knowledge)
|
|
138
|
+
|
|
139
|
+
const matched = new Map()
|
|
140
|
+
for (const [collection, fields] of Object.entries(SEARCH_FIELDS)) {
|
|
141
|
+
for (const record of knowledge[collection] || []) {
|
|
142
|
+
const hits = match(textOf(record, fields))
|
|
143
|
+
if (hits.length) matched.set(record.id, { collection, record, terms: hits })
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const findings = []
|
|
148
|
+
const assumptions = []
|
|
149
|
+
const needs = []
|
|
150
|
+
const scenarios = []
|
|
151
|
+
const design = []
|
|
152
|
+
|
|
153
|
+
for (const { collection, record, terms: hits } of matched.values()) {
|
|
154
|
+
const base = { id: record.id, label: labelOf(collection, record), terms: hits }
|
|
155
|
+
if (collection === 'insights') {
|
|
156
|
+
findings.push({
|
|
157
|
+
...base,
|
|
158
|
+
kind: 'insight',
|
|
159
|
+
confidence: record.confidence,
|
|
160
|
+
round: roundOf(knowledge, record.roundId),
|
|
161
|
+
participants: (record.participantIds || []).length
|
|
162
|
+
})
|
|
163
|
+
} else if (collection === 'evidence') {
|
|
164
|
+
const entry = { ...base, kind: 'evidence', sourceType: record.sourceType, confidence: record.confidence, sourcePath: record.sourcePath || null }
|
|
165
|
+
if (ASSERTION_TYPES.test(record.sourceType || '')) assumptions.push({ ...entry, kind: 'evidence recorded as an assertion' })
|
|
166
|
+
else findings.push(entry)
|
|
167
|
+
} else if (collection === 'assumptions') {
|
|
168
|
+
assumptions.push({ ...base, kind: 'assumption', risk: record.risk })
|
|
169
|
+
} else if (collection === 'needs') {
|
|
170
|
+
needs.push({ ...base, priority: record.priority })
|
|
171
|
+
} else if (collection === 'scenarios') {
|
|
172
|
+
scenarios.push({ ...base, riskLevel: record.riskLevel || null })
|
|
173
|
+
} else {
|
|
174
|
+
design.push({ ...base, kind: collection, status: record.status || null })
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Oldest round first, then by strength, so agreement across rounds reads as
|
|
179
|
+
// a sequence rather than being folded into one line.
|
|
180
|
+
const confidenceRank = { high: 0, medium: 1, low: 2 }
|
|
181
|
+
findings.sort((a, b) =>
|
|
182
|
+
`${a.round?.date || '9999'}`.localeCompare(`${b.round?.date || '9999'}`) ||
|
|
183
|
+
(confidenceRank[a.confidence] ?? 3) - (confidenceRank[b.confidence] ?? 3) ||
|
|
184
|
+
a.id.localeCompare(b.id))
|
|
185
|
+
|
|
186
|
+
// What already exists because of these records, found by following each
|
|
187
|
+
// one forward a bounded number of steps. Needs reached on the way are
|
|
188
|
+
// reported too: they are what the findings were turned into.
|
|
189
|
+
const forward = buildForwardEdges(knowledge)
|
|
190
|
+
const reached = new Map()
|
|
191
|
+
let frontier = [...matched.keys()]
|
|
192
|
+
const seen = new Set(frontier)
|
|
193
|
+
for (let step = 1; step <= hops && frontier.length; step++) {
|
|
194
|
+
const next = []
|
|
195
|
+
for (const from of frontier) {
|
|
196
|
+
for (const to of forward.get(from) || []) {
|
|
197
|
+
if (seen.has(to)) continue
|
|
198
|
+
seen.add(to)
|
|
199
|
+
next.push(to)
|
|
200
|
+
const found = where.get(to)
|
|
201
|
+
if (!found) continue
|
|
202
|
+
const origin = matched.has(from) ? from : reached.get(from)?.via
|
|
203
|
+
const originCollection = matched.has(from) ? matched.get(from).collection : reached.get(from)?.originCollection
|
|
204
|
+
reached.set(to, { ...found, via: origin, originCollection, step })
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
frontier = next
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const builtOn = []
|
|
211
|
+
const needsReached = []
|
|
212
|
+
for (const [id, { collection, record, via, originCollection, step }] of reached) {
|
|
213
|
+
const entry = { id, label: labelOf(collection, record), via, steps: step }
|
|
214
|
+
if (BUILT_TYPES.has(collection)) builtOn.push({ ...entry, kind: collection, status: record.status || null })
|
|
215
|
+
// Only needs a finding leads to. A scenario that names the topic usually
|
|
216
|
+
// tests a dozen needs about other things, and listing them all buries the
|
|
217
|
+
// few the research actually supports.
|
|
218
|
+
else if (collection === 'needs' && FINDING_TYPES.has(originCollection)) needsReached.push({ ...entry, priority: record.priority })
|
|
219
|
+
}
|
|
220
|
+
const byKind = (a, b) => `${a.kind || ''}:${a.id}`.localeCompare(`${b.kind || ''}:${b.id}`)
|
|
221
|
+
builtOn.sort(byKind)
|
|
222
|
+
needsReached.sort(byKind)
|
|
223
|
+
|
|
224
|
+
// Coverage: whether "nothing found" can be read as "nobody asked".
|
|
225
|
+
const insightCount = new Map()
|
|
226
|
+
for (const insight of knowledge.insights || []) insightCount.set(insight.roundId, (insightCount.get(insight.roundId) || 0) + 1)
|
|
227
|
+
const roundsWithFindings = new Set(findings.filter((f) => f.round).map((f) => f.round.id))
|
|
228
|
+
const rounds = (knowledge.researchRounds || []).map((round) => ({
|
|
229
|
+
id: round.id,
|
|
230
|
+
title: round.title,
|
|
231
|
+
date: round.date,
|
|
232
|
+
insights: insightCount.get(round.id) || 0,
|
|
233
|
+
matchedFindings: findings.filter((f) => f.round?.id === round.id).length,
|
|
234
|
+
namesTopic: match(textOf(round, ['title', 'summary', 'focus'])).length > 0
|
|
235
|
+
})).sort((a, b) => `${a.date}`.localeCompare(`${b.date}`))
|
|
236
|
+
|
|
237
|
+
const nearestRounds = rounds.filter((r) => r.namesTopic && !roundsWithFindings.has(r.id))
|
|
238
|
+
const emptyRounds = rounds.filter((r) => r.insights === 0)
|
|
239
|
+
const unIngested = sourceArtefacts
|
|
240
|
+
.filter((a) => !a.ingestedAs && !(a.citedBy || []).length)
|
|
241
|
+
.filter((a) => match(`${a.path || ''} ${a.fileName || ''}`.replace(/[-_./]/g, ' ')).length)
|
|
242
|
+
.map((a) => ({ path: a.path, roundId: a.roundId || null }))
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
terms: cleaned,
|
|
246
|
+
findings,
|
|
247
|
+
assumptions,
|
|
248
|
+
needs,
|
|
249
|
+
needsReached,
|
|
250
|
+
scenarios,
|
|
251
|
+
design,
|
|
252
|
+
builtOn,
|
|
253
|
+
coverage: { rounds, roundsWithFindings: [...roundsWithFindings], nearestRounds, emptyRounds, unIngested },
|
|
254
|
+
nothingFound: matched.size === 0
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
module.exports = { whatsKnown, ASSERTION_TYPES, SEARCH_FIELDS }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippo-digital/hippocampus",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
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",
|
|
@@ -22,7 +22,7 @@ const ctx = createContextOrExit({ argv })
|
|
|
22
22
|
// gestures at a folder. `Round 4 - ...` is the shape that fails: it looks like a
|
|
23
23
|
// citation and identifies nothing.
|
|
24
24
|
const VAGUE = [/\.\.\./, /^\s*$/, /\*/]
|
|
25
|
-
const ASSERTION_TYPES = /
|
|
25
|
+
const { ASSERTION_TYPES } = require('../lib/known')
|
|
26
26
|
|
|
27
27
|
function main () {
|
|
28
28
|
const project = ctx.requireProjects()[0]
|
package/scripts/known.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const { createContextOrExit } = require('../lib/context')
|
|
5
|
+
const { whatsKnown } = require('../lib/known')
|
|
6
|
+
|
|
7
|
+
// hippocampus known <word or phrase> [more...] [--json] [--all] [--hops N]
|
|
8
|
+
//
|
|
9
|
+
// What the knowledge base already holds on a topic: the findings with their
|
|
10
|
+
// round, date and confidence; the assumptions, kept apart; the needs and
|
|
11
|
+
// design work built on them; and whether "nothing found" can be read as
|
|
12
|
+
// "nobody asked". Always exits 0 when the knowledge base loads - finding
|
|
13
|
+
// nothing is an answer, not a failure.
|
|
14
|
+
|
|
15
|
+
const argv = process.argv.slice(2)
|
|
16
|
+
const ctx = createContextOrExit({ argv })
|
|
17
|
+
|
|
18
|
+
const flags = { json: false, all: false, hops: 3 }
|
|
19
|
+
const terms = []
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const arg = argv[i]
|
|
22
|
+
if (arg === '--root') { i++; continue }
|
|
23
|
+
if (arg.startsWith('--root=')) continue
|
|
24
|
+
if (arg === '--json') flags.json = true
|
|
25
|
+
else if (arg === '--all') flags.all = true
|
|
26
|
+
else if (arg === '--hops') flags.hops = Number(argv[++i])
|
|
27
|
+
else if (arg.startsWith('--')) { console.error(`Unknown option: ${arg}`); process.exit(1) }
|
|
28
|
+
else terms.push(arg)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!terms.length) {
|
|
32
|
+
console.error('Usage: hippocampus known <word or phrase> [more words...] [--json] [--all] [--hops N]')
|
|
33
|
+
console.error('Each argument is searched separately; quote a phrase to keep it together.')
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
if (!Number.isInteger(flags.hops) || flags.hops < 0) {
|
|
37
|
+
console.error('--hops needs a whole number, 0 or more.')
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readSourceArtefacts () {
|
|
42
|
+
const indexPath = path.join(ctx.paths.manifestsDir, 'source-index.json')
|
|
43
|
+
if (!fs.existsSync(indexPath)) return []
|
|
44
|
+
return JSON.parse(fs.readFileSync(indexPath, 'utf8')).artefacts || []
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const project = ctx.requireProjects()[0]
|
|
48
|
+
const knowledge = project.store.getKnowledge()
|
|
49
|
+
const result = whatsKnown(knowledge, terms, { sourceArtefacts: readSourceArtefacts(), hops: flags.hops })
|
|
50
|
+
|
|
51
|
+
if (flags.json) {
|
|
52
|
+
console.log(JSON.stringify(result, null, 2))
|
|
53
|
+
process.exit(0)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const LIMIT = flags.all ? Infinity : 25
|
|
57
|
+
const clip = (text, n = 110) => (text.length > n ? `${text.slice(0, n - 1)}…` : text)
|
|
58
|
+
const roundLabel = (round) => (round ? `${round.title}, ${round.date}` : 'no research round')
|
|
59
|
+
let clipped = false
|
|
60
|
+
|
|
61
|
+
function section (title, items, render, note) {
|
|
62
|
+
if (!items.length) return
|
|
63
|
+
console.log(`\n${title} (${items.length})${note ? ` - ${note}` : ''}`)
|
|
64
|
+
for (const item of items.slice(0, LIMIT)) console.log(render(item))
|
|
65
|
+
if (items.length > LIMIT) {
|
|
66
|
+
clipped = true
|
|
67
|
+
console.log(` ... and ${items.length - LIMIT} more`)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`What the knowledge base holds on: ${result.terms.join(', ')}`)
|
|
72
|
+
console.log(`(${ctx.root}, ${result.coverage.rounds.length} research rounds)`)
|
|
73
|
+
|
|
74
|
+
if (result.nothingFound) {
|
|
75
|
+
console.log('\nNo record names this.')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
section('Findings', result.findings, (f) => f.kind === 'insight'
|
|
79
|
+
? ` insight ${f.id} [${f.confidence}, ${f.participants} participants, ${roundLabel(f.round)}]\n ${clip(f.label)}`
|
|
80
|
+
: ` evidence ${f.id} [${f.confidence}, ${f.sourceType}]\n ${clip(f.label)}`,
|
|
81
|
+
'oldest round first; each is a separate claim')
|
|
82
|
+
|
|
83
|
+
section('Assumptions', result.assumptions, (a) => a.kind === 'assumption'
|
|
84
|
+
? ` assumption ${a.id} [${a.risk} risk]\n ${clip(a.label)}`
|
|
85
|
+
: ` evidence ${a.id} [${a.sourceType} - an assertion, not a finding]\n ${clip(a.label)}`,
|
|
86
|
+
'beliefs the design rests on, not research')
|
|
87
|
+
|
|
88
|
+
section('Needs that name it', result.needs, (n) => ` ${n.id} [${n.priority}]\n ${clip(n.label)}`)
|
|
89
|
+
section('Needs these findings support', result.needsReached, (n) => ` ${n.id} [${n.priority}, via ${n.via}]\n ${clip(n.label)}`)
|
|
90
|
+
section('Scenarios that name it', result.scenarios, (s) => ` ${s.id}${s.riskLevel ? ` [${s.riskLevel} risk]` : ''}\n ${clip(s.label)}`)
|
|
91
|
+
section('Design work that names it', result.design, (d) => ` ${d.kind.padEnd(13)} ${d.id}${d.status ? ` [${d.status}]` : ''}\n ${clip(d.label)}`)
|
|
92
|
+
section('Already built on these', result.builtOn, (d) => ` ${d.kind.padEnd(13)} ${d.id}${d.status ? ` [${d.status}]` : ''} via ${d.via}\n ${clip(d.label)}`,
|
|
93
|
+
'check these before building it again')
|
|
94
|
+
|
|
95
|
+
const { rounds, roundsWithFindings, nearestRounds, emptyRounds, unIngested } = result.coverage
|
|
96
|
+
console.log('\nCoverage')
|
|
97
|
+
const withFindings = rounds.filter((r) => roundsWithFindings.includes(r.id))
|
|
98
|
+
console.log(` Rounds with a finding on this: ${withFindings.length} of ${rounds.length}` +
|
|
99
|
+
(withFindings.length ? ` - ${withFindings.map((r) => `${r.title} (${r.date})`).join('; ')}` : ''))
|
|
100
|
+
if (nearestRounds.length) {
|
|
101
|
+
console.log(` Rounds whose title or summary names it, with no matching finding: ${nearestRounds.map((r) => `${r.title} (${r.date})`).join('; ')}`)
|
|
102
|
+
}
|
|
103
|
+
if (emptyRounds.length) {
|
|
104
|
+
console.log(` Rounds that produced no insights here (${emptyRounds.length}): ${emptyRounds.map((r) => `${r.title} (${r.date})`).join('; ')}`)
|
|
105
|
+
console.log(' The topic may be in their source material without having been ingested.')
|
|
106
|
+
}
|
|
107
|
+
if (unIngested.length) {
|
|
108
|
+
console.log(` Held files never ingested whose names match (${unIngested.length}):`)
|
|
109
|
+
for (const a of unIngested.slice(0, LIMIT)) console.log(` ${a.path}`)
|
|
110
|
+
}
|
|
111
|
+
if (!rounds.length) {
|
|
112
|
+
console.log(' This knowledge base has no research rounds yet, so nothing here can say whether anyone asked.')
|
|
113
|
+
} else if (result.nothingFound && !nearestRounds.length && !unIngested.length) {
|
|
114
|
+
console.log(emptyRounds.length
|
|
115
|
+
? ' No ingested record or round names this. Before calling it unresearched, check the rounds above that produced nothing here.'
|
|
116
|
+
: ' No round covered this. That is the finding.')
|
|
117
|
+
}
|
|
118
|
+
if (clipped) console.log('\nSome lists were cut at 25. Run with --all for everything, or --json for the full result.')
|
package/skills/skills.json
CHANGED
|
@@ -94,6 +94,32 @@
|
|
|
94
94
|
"The output stays review-first unless fixes are requested."
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
"id": "whats-known-about",
|
|
99
|
+
"title": "Report what is known about a topic",
|
|
100
|
+
"purpose": "Answer \"what do we already know about this\" from the knowledge base before anyone finds it out for a second time, and be explicit about what nobody has ever asked.",
|
|
101
|
+
"file": "whats-known-about/SKILL.md",
|
|
102
|
+
"owners": [
|
|
103
|
+
"knowledge-builder",
|
|
104
|
+
"workflow-orchestrator"
|
|
105
|
+
],
|
|
106
|
+
"runs": [
|
|
107
|
+
"npx hippocampus known \"<topic>\"",
|
|
108
|
+
"npx hippocampus validate"
|
|
109
|
+
],
|
|
110
|
+
"outputs": [
|
|
111
|
+
"What is known on the topic, each claim traced to its record and research round, with the round's date",
|
|
112
|
+
"What already exists because of it - the needs, screens and design actions downstream of those records",
|
|
113
|
+
"A plain statement of what nobody has asked, and the nearest round that came close",
|
|
114
|
+
"A dated answer under `artefacts/knowledge-answers/` when one is asked for, readable without an agent"
|
|
115
|
+
],
|
|
116
|
+
"acceptance": [
|
|
117
|
+
"Every claim in the answer names its record id and the research round behind it, with the round's date.",
|
|
118
|
+
"Assumptions are reported separately from evidence and are labelled as assumptions.",
|
|
119
|
+
"The answer states what nobody has asked, or says explicitly that coverage was not checked.",
|
|
120
|
+
"Nothing is asserted that cannot be pointed at in `hippocampus/source/`."
|
|
121
|
+
]
|
|
122
|
+
},
|
|
97
123
|
{
|
|
98
124
|
"id": "capture-route-review-pack",
|
|
99
125
|
"title": "Capture route review pack",
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: whats-known-about
|
|
3
|
+
description: "Answers what the knowledge base already holds on a topic, with the evidence and the date behind each claim, and names what nobody has asked. Use before researching, designing or specifying anything, and whenever someone asks whether this has been looked at before."
|
|
4
|
+
id: whats-known-about
|
|
5
|
+
title: Report what is known about a topic
|
|
6
|
+
purpose: Answer "what do we already know about this" from the knowledge base before anyone finds it out for a second time, and be explicit about what nobody has ever asked.
|
|
7
|
+
owners:
|
|
8
|
+
- knowledge-builder
|
|
9
|
+
- workflow-orchestrator
|
|
10
|
+
reads:
|
|
11
|
+
- hippocampus/source/evidence.json
|
|
12
|
+
- hippocampus/source/insights.json
|
|
13
|
+
- hippocampus/source/needs.json
|
|
14
|
+
- hippocampus/source/assumptions.json
|
|
15
|
+
- hippocampus/source/research-rounds.json
|
|
16
|
+
- hippocampus/source/relationships.json
|
|
17
|
+
- hippocampus/source/screens.json
|
|
18
|
+
- hippocampus/source/design-actions.json
|
|
19
|
+
edits:
|
|
20
|
+
- artefacts/knowledge-answers/
|
|
21
|
+
runs:
|
|
22
|
+
- npx hippocampus known "<topic>"
|
|
23
|
+
- npx hippocampus validate
|
|
24
|
+
outputs:
|
|
25
|
+
- What is known on the topic, each claim traced to its record and research round, with the round's date
|
|
26
|
+
- What already exists because of it - the needs, screens and design actions downstream of those records
|
|
27
|
+
- A plain statement of what nobody has asked, and the nearest round that came close
|
|
28
|
+
- A dated answer under `artefacts/knowledge-answers/` when one is asked for, readable without an agent
|
|
29
|
+
guardrails:
|
|
30
|
+
- Finding nothing is an answer, not a failure. Say that no round covered the topic, name the nearest one, and stop - an empty result reported as an error sends somebody off to research it again, which is the thing this skill exists to prevent.
|
|
31
|
+
- Never merge records from different rounds into one claim. Two rounds agreeing is a stronger finding than one sentence that conceals both.
|
|
32
|
+
- Carry confidence and the round date into every claim. A low-confidence insight from an old round is not the same fact as a recent high-confidence one, and a summary that flattens them is how a wrong thing gets rebuilt.
|
|
33
|
+
- An assumption is never reported as research. Check `assumptions.json`, and check `sourceType` on evidence - some projects record assumptions there instead. Either way it is a belief the team is relying on, and saying so is the point.
|
|
34
|
+
- Search summaries and statements, not just titles. The topic is usually named in the body of a record and not in its heading.
|
|
35
|
+
- Report what was already built on the records you found. "We know this" without "and here is the screen that already does it" still leaves somebody free to build it twice.
|
|
36
|
+
- Do not follow provenance backwards. A round is not relevant because something drawn from it was.
|
|
37
|
+
acceptance:
|
|
38
|
+
- Every claim in the answer names its record id and the research round behind it, with the round's date.
|
|
39
|
+
- Assumptions are reported separately from evidence and are labelled as assumptions.
|
|
40
|
+
- The answer states what nobody has asked, or says explicitly that coverage was not checked.
|
|
41
|
+
- Nothing is asserted that cannot be pointed at in `hippocampus/source/`.
|
|
42
|
+
---
|
|
43
|
+
# Report what is known about a topic
|
|
44
|
+
|
|
45
|
+
## Use when
|
|
46
|
+
|
|
47
|
+
Somebody is about to research, design or specify something and wants to know
|
|
48
|
+
whether it has been looked at before. Also when a question arrives that sounds
|
|
49
|
+
familiar, or when a team picks up an area an earlier one already worked in.
|
|
50
|
+
|
|
51
|
+
## Workflow
|
|
52
|
+
|
|
53
|
+
1. **Ask the knowledge base.**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx hippocampus known "the topic"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Run it once for the words the team would say and once for the words the
|
|
60
|
+
records use - a miss on one wording is not coverage. The command exits 0 even
|
|
61
|
+
when nothing matches, because nothing found is an answer.
|
|
62
|
+
|
|
63
|
+
2. **Read what it gives you, in its own shape.** Findings come oldest round
|
|
64
|
+
first, each a separate claim carrying its confidence and its round's date.
|
|
65
|
+
Assumptions are listed apart from findings. Then the needs that name the
|
|
66
|
+
topic, then `Already built on these`, then `Coverage`.
|
|
67
|
+
|
|
68
|
+
3. **Start the answer with the Coverage line, not the findings.** `0 of N` means
|
|
69
|
+
no ingested round has a finding on this, and that is the more useful half of
|
|
70
|
+
the answer. It is also the case that looks like a hit when records exist: a
|
|
71
|
+
topic can have needs and screens hanging off an assumption that no research
|
|
72
|
+
ever tested.
|
|
73
|
+
|
|
74
|
+
Before calling a topic unresearched, read the two lines under it. `Rounds
|
|
75
|
+
that produced no insights here` are rounds whose material may cover the topic
|
|
76
|
+
without any of it having been ingested, and `Held files never ingested` are
|
|
77
|
+
files whose names match. Either one means "not in the knowledge base", which
|
|
78
|
+
is not the same as "nobody asked". Say which it is.
|
|
79
|
+
|
|
80
|
+
4. **Take `Already built on these` seriously.** Those are the journeys and
|
|
81
|
+
screens that already serve the topic. Naming them is what stops the rebuild,
|
|
82
|
+
and it is the part a summary usually drops.
|
|
83
|
+
|
|
84
|
+
5. **If lists were cut at 25**, rerun with `--all`, or `--json` when you need to
|
|
85
|
+
work with the result rather than read it. Do not answer from a truncated list
|
|
86
|
+
without saying it was truncated.
|
|
87
|
+
|
|
88
|
+
6. **Run the linter** and report its `info` tier for the records you named:
|
|
89
|
+
insights with no need, rounds that produced nothing. An insight nobody turned
|
|
90
|
+
into a need is a discovery already half-lost.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx hippocampus validate
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Guardrails
|
|
97
|
+
|
|
98
|
+
- Nothing found is a result. Report it as one and name the nearest round.
|
|
99
|
+
- An assumption is never reported as research.
|
|
100
|
+
- Confidence and round date travel with the claim, or the claim does not go out.
|
|
101
|
+
- Records from different rounds stay as separate claims - do not paraphrase the
|
|
102
|
+
findings list into a single sentence.
|
|
103
|
+
- Every answer says what already exists downstream, not only what is known.
|
|
104
|
+
|
|
105
|
+
## Finish
|
|
106
|
+
|
|
107
|
+
When the answer is worth keeping, write it to `artefacts/knowledge-answers/` with
|
|
108
|
+
today's date, so the next person can read it without running an agent. An answer
|
|
109
|
+
that only ever existed in a chat window is the next repeated discovery.
|
|
110
|
+
|
|
111
|
+
End with the one question somebody would have to ask to close the gap, and who
|
|
112
|
+
would have to be asked. A topic nobody has researched is a piece of work, and
|
|
113
|
+
naming it here is what stops it being discovered from scratch a third time.
|