coaiajs 0.5.0 → 0.5.2
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/README.md +22 -3
- package/dist/src/cli.d.ts +9 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +79 -7
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/narrative/tool-definitions.d.ts +9 -1
- package/dist/src/narrative/tool-definitions.d.ts.map +1 -1
- package/dist/src/narrative/tool-definitions.js +10 -1
- package/dist/src/narrative/tool-definitions.js.map +1 -1
- package/dist/src/skill.d.ts +98 -0
- package/dist/src/skill.d.ts.map +1 -0
- package/dist/src/skill.js +396 -0
- package/dist/src/skill.js.map +1 -0
- package/dist/src/version.d.ts +9 -0
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +30 -14
- package/dist/src/version.js.map +1 -1
- package/docs/LINEAGE-COAIA-NARRATIVE.md +150 -0
- package/llms-full.txt +29 -2
- package/llms.txt +2 -0
- package/package.json +7 -1
- package/skills/coaiajs/SKILL.md +165 -0
- package/skills/coaiajs/references/beyond-narrative.md +71 -0
- package/skills/coaiajs/references/creative-orientation.md +42 -0
- package/skills/coaiajs/references/delayed-resolution.md +48 -0
- package/skills/coaiajs/references/install-and-environment.md +85 -0
- package/skills/coaiajs/references/mcp-tools.md +83 -0
- package/skills/coaiajs/references/narrative-beats.md +44 -0
- package/skills/coaiajs/references/reading-the-store.md +66 -0
- package/skills/coaiajs/references/structural-tension-charting.md +71 -0
- package/skills/coaiajs/references/wampum-belts.md +72 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# MCP Tools And Environment
|
|
2
|
+
|
|
3
|
+
The MCP server is `coaiajs-mcp`. It speaks stdio and serves tools, prompts, and resources.
|
|
4
|
+
|
|
5
|
+
## Feature levels
|
|
6
|
+
|
|
7
|
+
`COAIAJS_FEATURES` selects the tool set. Default is `STANDARD`.
|
|
8
|
+
|
|
9
|
+
| Level | Serves |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `MINIMAL` | Redis shorthand and the core Langfuse read/write tools |
|
|
12
|
+
| `STANDARD` | Default — everything except the media tools |
|
|
13
|
+
| `OBSERVABILITY` | Langfuse-focused |
|
|
14
|
+
| `FULL` | Everything, including media upload/get |
|
|
15
|
+
|
|
16
|
+
Pass `--features <LEVEL>` on the command line to override the environment.
|
|
17
|
+
|
|
18
|
+
## Tool groups (library-side)
|
|
19
|
+
|
|
20
|
+
`coaiajs/narrative` exports these name lists so a caller can gate its own surface:
|
|
21
|
+
|
|
22
|
+
| Group | Contents |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `CORE_TOOLS` | The minimal list / create / add / complete workflow |
|
|
25
|
+
| `STC_TOOLS` | Chart creation, action steps, progress, reality, outcome, due date, GitHub link, MMOT |
|
|
26
|
+
| `NARRATIVE_TOOLS` | Narrative beat creation, telescoping, listing |
|
|
27
|
+
| `WAMPUM_TOOLS` | Belt creation, bead placement, belt reading |
|
|
28
|
+
| `KG_TOOLS` | Lower-level knowledge graph entities and relations |
|
|
29
|
+
|
|
30
|
+
Prefer STC tools for chart work. Use KG tools only when deliberately managing generic
|
|
31
|
+
entities and relations — they bypass the chart-shaped validation.
|
|
32
|
+
|
|
33
|
+
## Environment variables
|
|
34
|
+
|
|
35
|
+
| Variable | Purpose |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `COAIAJS_FEATURES` | Feature level: `MINIMAL` / `STANDARD` / `OBSERVABILITY` / `FULL` |
|
|
38
|
+
| `COAIAJS_MEMORY_PATH` | Default JSONL store path for CLI and MCP server |
|
|
39
|
+
| `COAIA_CURRENT_CHART_ID` | Chart the CLI treats as current (`coaia narrative current`) |
|
|
40
|
+
| `REDIS_URL` / `REDIS_HOST` etc. | Redis endpoint for `tash` / `fetch` |
|
|
41
|
+
| `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, `LANGFUSE_HOST` | Langfuse credentials |
|
|
42
|
+
| `OPENAI_API_KEY` | LLM and transcription calls |
|
|
43
|
+
|
|
44
|
+
Config resolution order is: environment variables, then `.env`, then `coaia.json`.
|
|
45
|
+
|
|
46
|
+
## Arguments this server will tell you about
|
|
47
|
+
|
|
48
|
+
Two behaviours worth relying on:
|
|
49
|
+
|
|
50
|
+
**Unknown arguments are named, not swallowed.** A tool call carrying a key the schema does
|
|
51
|
+
not know still succeeds, but the result appends:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
⚠️ Ignored unrecognised argument(s): dueDte. They were NOT applied — check the tool's inputSchema for the accepted names.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A dropped argument is otherwise invisible from the caller's side — the call succeeds, the
|
|
58
|
+
record is written, and the ignored part looks exactly like an honoured one.
|
|
59
|
+
|
|
60
|
+
**Every validation problem is reported at once.** Two missing required fields come back in
|
|
61
|
+
one message rather than costing a round trip each.
|
|
62
|
+
|
|
63
|
+
**`telescope_action_step` accepts `actionSteps`** as an alias for `initialActionSteps`,
|
|
64
|
+
because its sibling `create_structural_tension_chart` names the same concept `actionSteps`
|
|
65
|
+
and callers reach for that name.
|
|
66
|
+
|
|
67
|
+
## Refusals
|
|
68
|
+
|
|
69
|
+
A call whose argument tags did not parse arrives with its own raw text inside a value.
|
|
70
|
+
That is refused at the write boundary, with the fragment quoted and nothing written:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Malformed call refused — nothing was written.
|
|
74
|
+
|
|
75
|
+
`currentReality` carries unparsed call syntax, not prose:
|
|
76
|
+
</currentReality>
|
|
77
|
+
That is a closing tag for the 'currentReality' argument.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The refusal exists because that text used to persist verbatim: a live store was found
|
|
81
|
+
carrying seven observations ending in `</currentReality>` followed by a parameter block,
|
|
82
|
+
rendered as prose by every consumer since. A read-side filter arrives too late — anything
|
|
83
|
+
that reaches the JSONL is already in every reader's render.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Narrative Beats
|
|
2
|
+
|
|
3
|
+
Narrative beats document significant learning moments. They are not replacements for
|
|
4
|
+
charts or action steps, and they are not routine task tracking.
|
|
5
|
+
|
|
6
|
+
Create a beat when a moment matters across multiple perspectives:
|
|
7
|
+
|
|
8
|
+
- **engineer-world** — technical structure and consequences
|
|
9
|
+
- **ceremony-world** — relational protocol and accountability
|
|
10
|
+
- **story-engine-world** — narrative progression and meaning
|
|
11
|
+
|
|
12
|
+
A useful beat carries title, act, dramatic type, universes, description, prose, and
|
|
13
|
+
lessons. Use beats after a real transition, discovery, crisis, MMOT, or integration
|
|
14
|
+
moment.
|
|
15
|
+
|
|
16
|
+
## Tools
|
|
17
|
+
|
|
18
|
+
| Tool | Use |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `create_narrative_beat` | Archive a significant multi-universe learning moment |
|
|
21
|
+
| `telescope_narrative_beat` | Break a beat into sub-beats with their own current reality |
|
|
22
|
+
| `list_narrative_beats` | Review the archive, optionally filtered by parent chart |
|
|
23
|
+
|
|
24
|
+
## Beat-level session context
|
|
25
|
+
|
|
26
|
+
`metadata.sessionContext` records the embodied condition of the session a beat came from:
|
|
27
|
+
`mode` (voice / terminal / mixed), `setting` (desk / walking / land-based / transit),
|
|
28
|
+
`landBasedLearning`, `environmentNotes`, `captureQuality`, and whether a public summary is
|
|
29
|
+
allowed. Use it when the conditions of the work are part of what the beat means.
|
|
30
|
+
|
|
31
|
+
`metadata.sessionLineage` records conversation branching — parent chart, source beat,
|
|
32
|
+
original and branch session ids, branch purpose, and handoff state — so a branch map can
|
|
33
|
+
be reconstructed later.
|
|
34
|
+
|
|
35
|
+
## The legacy on-disk dialect
|
|
36
|
+
|
|
37
|
+
Some live stores hold beats written with a top-level `type: "narrative_beat"` rather than
|
|
38
|
+
`type: "entity"` with `entityType: "narrative_beat"`. Both are read, both round-trip as
|
|
39
|
+
themselves, and a writer never flattens one into the other.
|
|
40
|
+
|
|
41
|
+
This matters to anyone reading the store directly: a reader that does not know the legacy
|
|
42
|
+
dialect renders **fewer beats than exist** and may report the difference as corruption.
|
|
43
|
+
Use `coaiajs/narrative/contract` rather than classifying records by hand — see
|
|
44
|
+
`reading-the-store.md`.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Reading the Store
|
|
2
|
+
|
|
3
|
+
`coaiajs` owns the writes. Anything that renders a chart store — a dashboard, a report, a
|
|
4
|
+
Twine promotion, another agent — needs the store's shape, and re-deriving that shape by
|
|
5
|
+
hand is where readers quietly go wrong.
|
|
6
|
+
|
|
7
|
+
It is not a style problem. When a hand-rolled reader drifts from the writer, it does not
|
|
8
|
+
break: it renders **less**. A chart holding real work looks identical to an empty one.
|
|
9
|
+
|
|
10
|
+
## Use the contract
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { parseStore, getWork, getChartEntity } from 'coaiajs/narrative/contract';
|
|
14
|
+
import { readFile } from 'node:fs/promises';
|
|
15
|
+
|
|
16
|
+
const store = parseStore(await readFile('./memory.jsonl', 'utf8'));
|
|
17
|
+
const chart = getChartEntity(store, 'chart_1757200000000');
|
|
18
|
+
const work = getWork(store, 'chart_1757200000000');
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The contract keeps three rules:
|
|
22
|
+
|
|
23
|
+
1. **Zero I/O.** No `fs`, no `process`, no network. The caller owns reading; this owns
|
|
24
|
+
shape.
|
|
25
|
+
2. **Never imports the server.** The package root is safe to import, but the contract
|
|
26
|
+
lives behind its own subpath so a renderer pulls nothing it does not need.
|
|
27
|
+
3. **Tolerant by construction, honest about what it skipped.** One unparseable line is
|
|
28
|
+
skipped and counted in `skipped`, where `parseJsonlMemory` — correctly, for a writer —
|
|
29
|
+
throws.
|
|
30
|
+
|
|
31
|
+
Classification is **not** defined in the contract. `jsonl-records.ts` holds the single
|
|
32
|
+
definition, and both the writer and the contract import it. The first draft of the
|
|
33
|
+
contract re-implemented classification by hand and a review measured it returning 73
|
|
34
|
+
entities where the writer returned 76: it dropped the legacy `type:"narrative_beat"`
|
|
35
|
+
dialect and reported the losses as corruption. Duplication relocated rather than removed.
|
|
36
|
+
|
|
37
|
+
## What it gives you
|
|
38
|
+
|
|
39
|
+
| Export | Use |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `parseStore(raw)` | `{ entities: Map, relations: [], skipped: number }` |
|
|
42
|
+
| `ENTITY_TYPES` | Every entity kind the writer writes |
|
|
43
|
+
| `MMOT_PHASES`, `CREATING_PHASES` | The vocabularies, including `full` |
|
|
44
|
+
| `chartEntityName`, `desiredOutcomeName`, `currentRealityName` | The naming scheme, once |
|
|
45
|
+
| `getChartEntity`, `getDesiredOutcome`, `getCurrentReality` | Chart parts by id |
|
|
46
|
+
| `getFlatActionSteps`, `getChildCharts`, `getWork` | The two shapes work takes, counted once |
|
|
47
|
+
| `getMmotBeats`, `getMmotEvaluations` | The MMOT trail |
|
|
48
|
+
| `storeRevision`, `revisionOf` | Cheap change detection between reads |
|
|
49
|
+
|
|
50
|
+
## What `skipped` cannot tell you
|
|
51
|
+
|
|
52
|
+
Writes are temp-file-plus-rename, so a reader should never see a torn file and
|
|
53
|
+
`skipped > 0` genuinely suggests a foreign or damaged line.
|
|
54
|
+
|
|
55
|
+
But a store truncated by something *other* than this package can still be a syntactically
|
|
56
|
+
perfect prefix: every whole line parses, and the result is simply a smaller store with
|
|
57
|
+
`skipped === 0`. No reader can detect that from content alone. If it matters, compare
|
|
58
|
+
entity counts across reads.
|
|
59
|
+
|
|
60
|
+
## Writing from outside
|
|
61
|
+
|
|
62
|
+
If you must write, go through `KnowledgeGraphManager` or
|
|
63
|
+
`readJsonlMemoryFile` / `writeJsonlMemoryFile`. They preserve fields this package does not
|
|
64
|
+
model — another consumer's metadata survives — and they write atomically. A bare
|
|
65
|
+
`writeFile` over the store truncates first, and a reader landing in that window gets a
|
|
66
|
+
valid partial store.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Structural Tension Charting
|
|
2
|
+
|
|
3
|
+
A chart has three core parts:
|
|
4
|
+
|
|
5
|
+
1. **Desired Outcome** — what the user wants to create.
|
|
6
|
+
2. **Current Reality** — the honest present state in relation to that outcome.
|
|
7
|
+
3. **Action Steps** — strategic secondary choices that support the primary choice.
|
|
8
|
+
|
|
9
|
+
Action steps are not independent checklist items. They must make sense together as an
|
|
10
|
+
overview strategy. Test them with: "If these steps were taken, would the desired outcome
|
|
11
|
+
likely be created?"
|
|
12
|
+
|
|
13
|
+
Each action step is a telescoped chart. Its title becomes the desired outcome of the child
|
|
14
|
+
chart, and it needs its own current reality. Never use "ready to begin" as that reality.
|
|
15
|
+
|
|
16
|
+
Good current reality examples:
|
|
17
|
+
|
|
18
|
+
- "No Django experience."
|
|
19
|
+
- "Package builds locally, publish dry-run not inspected."
|
|
20
|
+
- "Budget: $5000."
|
|
21
|
+
- "Completed models section, struggling with views."
|
|
22
|
+
|
|
23
|
+
Poor current reality examples:
|
|
24
|
+
|
|
25
|
+
- "Ready to begin."
|
|
26
|
+
- "Need to retrieve the notes."
|
|
27
|
+
- "Excited to start."
|
|
28
|
+
- "Prepared to tackle the action step."
|
|
29
|
+
|
|
30
|
+
## How a chart is laid out in the store
|
|
31
|
+
|
|
32
|
+
For a chart with id `chart_1757200000000`:
|
|
33
|
+
|
|
34
|
+
| Entity | `entityType` |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `chart_1757200000000_chart` | `structural_tension_chart` |
|
|
37
|
+
| `chart_1757200000000_desired_outcome` | `desired_outcome` |
|
|
38
|
+
| `chart_1757200000000_current_reality` | `current_reality` |
|
|
39
|
+
| `chart_1757200000000_action_1` … `_action_N` | `action_step` |
|
|
40
|
+
|
|
41
|
+
A telescoped child chart is a full chart of its own, carrying `metadata.parentChart` and,
|
|
42
|
+
when it grew out of a specific step, `metadata.parentActionStep`.
|
|
43
|
+
|
|
44
|
+
## The two shapes work takes
|
|
45
|
+
|
|
46
|
+
This is the single most common source of a wrong reading. A chart holds its work in **two**
|
|
47
|
+
shapes:
|
|
48
|
+
|
|
49
|
+
1. `action_step` entities that live on the chart itself.
|
|
50
|
+
2. Telescoped child charts, which is what `add_action_step` produces.
|
|
51
|
+
|
|
52
|
+
Counting or rendering only one of them under-reports. A chart built entirely with
|
|
53
|
+
`add_action_step` used to report `0/0` progress while holding real work, and a chart
|
|
54
|
+
holding eight of its own steps used to render as "(No action steps yet)".
|
|
55
|
+
|
|
56
|
+
A child telescoped out of one of the chart's own steps is that same result seen closer up.
|
|
57
|
+
It counts **once**, through the step — not twice.
|
|
58
|
+
|
|
59
|
+
`getChartProgress`, `listActiveCharts`, `updateChartDueDate`, and
|
|
60
|
+
`coaiajs/narrative/contract`'s `getWork()` all apply that rule. Prefer them over walking
|
|
61
|
+
the graph by hand.
|
|
62
|
+
|
|
63
|
+
## Moving a date
|
|
64
|
+
|
|
65
|
+
Use `update_chart_due_date`. It moves the chart and its desired outcome together, records
|
|
66
|
+
the move as an observation on the chart, and reports how many open steps still fall after
|
|
67
|
+
the new date. Pass `redistributeActionSteps: true` to spread those open steps evenly
|
|
68
|
+
between now and the new date.
|
|
69
|
+
|
|
70
|
+
Do not hand-edit the JSONL to change a date. Several MCP instances can point at one store
|
|
71
|
+
with no lock; a hand-edit races every one of them.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Wampum Belts
|
|
2
|
+
|
|
3
|
+
A Wampum Belt is a non-linear mnemonic grid that runs in **parallel** with the linear
|
|
4
|
+
narrative beats. Beats are a sequence; a belt is a surface where position itself carries
|
|
5
|
+
meaning.
|
|
6
|
+
|
|
7
|
+
Reach for a belt when the order of things is not a line: when a reading depends on where
|
|
8
|
+
it sits relative to its neighbours, when several perspectives on one bead are all true,
|
|
9
|
+
or when a commitment needs a witness rather than a timestamp.
|
|
10
|
+
|
|
11
|
+
## Shape
|
|
12
|
+
|
|
13
|
+
A belt has `rows` × `cols` positions. Each position holds at most one bead, written once.
|
|
14
|
+
|
|
15
|
+
A bead carries:
|
|
16
|
+
|
|
17
|
+
| Field | Meaning |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `mnemonic` | Short anchor phrase |
|
|
20
|
+
| `color` | `white`, `purple`, `black`, or `mixed` |
|
|
21
|
+
| `position` | `{ row, col }`, zero-indexed, inside the grid |
|
|
22
|
+
| `reading` | The canonical meaning |
|
|
23
|
+
| `relationalReadings` | Optional per-perspective readings, keyed `left` / `center` / `right` / `row:N` / `col:N` |
|
|
24
|
+
| `ceremonyLink` | Optional tie to a chart or a beat |
|
|
25
|
+
| `observations` | Free notes |
|
|
26
|
+
|
|
27
|
+
`read_wampum_belt` with a `position` resolves the reading for that position: it prefers
|
|
28
|
+
`col:N`, then `row:N`, then the positional label (`left` / `center` / `right`), and falls
|
|
29
|
+
back to the canonical `reading`.
|
|
30
|
+
|
|
31
|
+
## Ceremony links
|
|
32
|
+
|
|
33
|
+
`ceremonyLink.ceremonyType` is one of `commitment`, `accountability`, `witness`, or
|
|
34
|
+
`renewal`. With `chartId` it writes a `wampum_holds_accountable` edge to that chart; with
|
|
35
|
+
`beatName` it writes a `wampum_witnesses` edge to that beat.
|
|
36
|
+
|
|
37
|
+
**The edge is subject to the bead, not the belt.** A relation's identity in the store is
|
|
38
|
+
`(from, to, relationType)`. With the belt as subject, a second bead linking the same chart
|
|
39
|
+
under a different `ceremonyType` collided on that triple: the existence check matched, the
|
|
40
|
+
edge was skipped, and the bead kept a ceremony type the graph had no edge for. Silent
|
|
41
|
+
discard, with the bead's own record disagreeing with the graph and nothing saying so.
|
|
42
|
+
|
|
43
|
+
A bead id is `bead_<beltId>_<row>_<col>` and a position is written once, so
|
|
44
|
+
`(bead, target, relationType)` is unique by construction and every ceremony link survives
|
|
45
|
+
carrying its own type.
|
|
46
|
+
|
|
47
|
+
## Tools
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{ "tool": "create_wampum_belt",
|
|
51
|
+
"arguments": { "title": "Release ceremony", "purpose": "Hold what each step promised", "rows": 2, "cols": 3 } }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{ "tool": "add_wampum_bead",
|
|
56
|
+
"arguments": {
|
|
57
|
+
"beltId": "belt_1757200000000",
|
|
58
|
+
"mnemonic": "witnessed",
|
|
59
|
+
"color": "purple",
|
|
60
|
+
"position": { "row": 0, "col": 1 },
|
|
61
|
+
"reading": "The publish was seen by someone other than its author",
|
|
62
|
+
"relationalReadings": { "center": "seen from the middle of the belt" },
|
|
63
|
+
"ceremonyLink": { "ceremonyType": "witness", "chartId": "chart_1757200000000" }
|
|
64
|
+
} }
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{ "tool": "read_wampum_belt", "arguments": { "beltId": "belt_1757200000000" } }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Out-of-bounds positions, occupied positions, and non-integer grids are refused with the
|
|
72
|
+
reason named.
|