coaiajs 0.5.0 → 0.5.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/llms-full.txt CHANGED
@@ -110,9 +110,10 @@ EnvironmentManager, createEnvironment, findEnvironment
110
110
 
111
111
  ```
112
112
  getPackageVersion
113
+ getPackageRoot
113
114
  ```
114
115
 
115
- Returns the resolved version of the installed package, read from `package.json` at runtime.
116
+ `getPackageVersion` returns the resolved version of the installed package, read from `package.json` at runtime. `getPackageRoot` returns the directory holding that `package.json` — the way anything shipped beside `dist/` (the packaged skill under `skills/`, the Custom GPT specs) is located. Do not use `process.cwd()` for that; it is the caller's directory and says nothing about where the package was installed.
116
117
 
117
118
  ### `coaiajs/narrative`
118
119
 
@@ -174,6 +175,26 @@ const store = parseStore(await readFile('./memory.jsonl', 'utf8'));
174
175
  const work = getWork(store, 'chart_1757200000000');
175
176
  ```
176
177
 
178
+ ### `coaiajs/skill`
179
+
180
+ The agent skill this package ships, describing its own surface.
181
+
182
+ ```
183
+ SKILL_NAME, SKILL_FILES, getPackagedSkillDir,
184
+ renderSkill, renderSkillFile, renderToolMap,
185
+ showSkill, installSkill, checkSkill, formatSkillCheck,
186
+ getSkillInstallDir, getClaudeSkillLinkPath
187
+ ```
188
+
189
+ ```bash
190
+ coaia skill show # print the packaged SKILL.md, rendered
191
+ coaia skill install --yes # ./.agents/skills/coaiajs + the .claude/skills symlink
192
+ coaia skill install --global # ~/.agents/skills/coaiajs
193
+ coaia skill check # current / stale / missing; exits non-zero unless current
194
+ ```
195
+
196
+ The content lives as real markdown under `skills/coaiajs/` rather than as strings in the TypeScript, so a documentation change reads as a documentation diff. The `{{TOOL_MAP}}` placeholder inside `SKILL.md` is rendered from `ALL_TOOL_DEFINITIONS` — the same array the MCP server registers — so an installed skill cannot advertise a tool the server does not serve. The version it was rendered from is recorded in the installed frontmatter as `packageVersion`, which is what `checkSkill` reads.
197
+
177
198
  ### `coaiajs/pde`
178
199
 
179
200
  ```
@@ -367,6 +388,7 @@ Global options: `--env <path>` · `-M, --memory-path <path>` · `--json` · `--n
367
388
  | `p <tag> [text]` | | Process text with a custom tag |
368
389
  | `init` | | Create a sample `coaia.json` |
369
390
  | `fuse` | | Langfuse operations |
391
+ | `skill` | | The packaged agent skill: show, install, check |
370
392
  | `narrative` | `n` | Structural tension chart operations |
371
393
  | `pde` | | Prompt Decomposition Engine |
372
394
  | `plan` | | Structural tension plan operations |
@@ -377,7 +399,8 @@ Global options: `--env <path>` · `-M, --memory-path <path>` · `--json` · `--n
377
399
  Subcommands:
378
400
 
379
401
  - **`fuse`** — `traces`, `prompts`, `datasets`, `sessions`, `scores` (`sc`), `score-configs` (`scc`), `comments`, `media`, `dataset-items`, `projects`
380
- - **`narrative`** — `list` (`ls`), `view` (`v`), `current` (`cur`), `update` (`up`), `add-action` (`aa`), `add-obs` (`ao`), `complete` (`done`), `export` (`exp`), `export-all`, `stats` (`st`), `progress` (`pg`), `mmot`, `set-date` (`sd`)
402
+ - **`skill`** — `show`, `install` (`--global`, `--yes`, `--force`), `check` (`--global`)
403
+ - **`narrative`** — `list` (`ls`), `view` (`v`), `current` (`cur`), `update` (`up`), `add-action` (`aa`), `add-obs` (`ao`), `complete` (`done`), `export` (`exp`), `export-all`, `stats` (`st`), `progress` (`pg`), `mmot`, `set-date` (`sd`, `--redistribute`), `link-issue`
381
404
  - **`pde`** — `import <pdeId>`, `list`, `sessions`, `show <sessionId>`
382
405
  - **`plan`** — `parse <planPath>`, `convert <planPath>`, `sync-to-chart <planPath> <chartsPath>`, `sync-to-plan <chartsPath> <planPath>`
383
406
  - **`pipeline`** — `list`, `show <name>`, `create <name>`, `init <name>`
@@ -428,3 +451,7 @@ npm run dev # tsc --watch
428
451
  Conventions: ESM only, relative imports end in `.js` · `strict: true`, no unjustified `any` · shared types live in `src/types.ts` · clients lazy, each module exports `resetClient()` · no side effects at import time.
429
452
 
430
453
  Per-module RISE specifications live in `rispecs/`, one file per module.
454
+
455
+ ### Carrying corrections forward from coaia-narrative
456
+
457
+ `src/narrative/` began as a snapshot of `avadisabelle/coaia-narrative` and still takes corrections from it — one way. `docs/LINEAGE-COAIA-NARRATIVE.md` records where the last port stopped (upstream `68f6e2f`, v0.16.2), how to compute the next diff, what was adapted rather than copied and why, and what is deliberately not ported. Read it before porting anything from that repository. The two trees are not diff-compatible; port semantically and carry the reasoning, not just the code.
package/llms.txt CHANGED
@@ -17,6 +17,7 @@ Key facts an agent usually needs first:
17
17
  - [llms-full.txt](./llms-full.txt): complete API surface — every export, every MCP tool, every CLI command, in one file
18
18
  - [CLAUDE.md](./CLAUDE.md): repository conventions for agents working *on* this codebase
19
19
  - [KINSHIP.md](./KINSHIP.md): lineage and type provenance from the four origin projects
20
+ - [docs/LINEAGE-COAIA-NARRATIVE.md](./docs/LINEAGE-COAIA-NARRATIVE.md): how corrections are carried forward from `avadisabelle/coaia-narrative` — where the last port stopped, how to find the next one, and what is deliberately not copied
20
21
 
21
22
  ## Entry points
22
23
 
@@ -32,6 +33,7 @@ Key facts an agent usually needs first:
32
33
  - `coaiajs/media-upload-proxy`: deployable `openaiFileIdRefs` to Langfuse media upload bridge (`coaiajs-media-proxy` binary)
33
34
  - `coaiajs/narrative`: `KnowledgeGraphManager`, structural tension charts, markdown export, Wampum Belt sequencing, GitHub issue linkage, loss-free JSONL round-tripping
34
35
  - `coaiajs/narrative/contract`: the store read contract for renderers — zero I/O, tolerant of a bad line
36
+ - `coaiajs/skill`: the packaged agent skill — render, install, and check it (`coaia skill show|install|check`)
35
37
  - `coaiajs/pde`: Prompt Decomposition Engine — sessions, STC mapping
36
38
  - `coaiajs/planning`: `parsePlan`, `planToSTC`, `syncToChart`, `syncToPlan`
37
39
  - `coaiajs/pipeline`: pipeline template engine
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coaiajs",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "CoAIA unified TypeScript monorepo — CLI, MCP server, and library consolidating coaia-narrative, coaia-pde, coaia-planning, and coaiapy patterns into one package.",
6
6
  "main": "./dist/src/index.js",
@@ -54,6 +54,10 @@
54
54
  "types": "./dist/src/narrative/contract.d.ts",
55
55
  "import": "./dist/src/narrative/contract.js"
56
56
  },
57
+ "./skill": {
58
+ "types": "./dist/src/skill.d.ts",
59
+ "import": "./dist/src/skill.js"
60
+ },
57
61
  "./pde": {
58
62
  "types": "./dist/src/pde/index.d.ts",
59
63
  "import": "./dist/src/pde/index.js"
@@ -70,6 +74,8 @@
70
74
  },
71
75
  "files": [
72
76
  "dist",
77
+ "skills",
78
+ "docs",
73
79
  "agents/custom_gpt",
74
80
  "rispecs",
75
81
  "README.md",
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: coaiajs
3
+ description: Use coaiajs to create and manage Structural Tension Charts, narrative beats, Wampum Belts, MMOT evaluations, PDE decompositions, action plans, and Langfuse-traced pipelines over a JSONL knowledge graph.
4
+ license: MIT
5
+ compatibility: Requires the coaiajs package. CLI: coaia. MCP server: coaiajs-mcp.
6
+ metadata:
7
+ author: Guillaume D. Isabelle
8
+ package: coaiajs
9
+ packageVersion: "{{VERSION}}"
10
+ allowed-tools: Bash(coaia:*), Bash(coaiajs-mcp:*)
11
+ ---
12
+
13
+ # coaiajs
14
+
15
+ `coaiajs` is the structural tension surface of the COAIA family, consolidated into one
16
+ installable unit: a library, a CLI (`coaia`), and an MCP server (`coaiajs-mcp`). Use it when
17
+ an assistant should help create outcomes, hold current reality clearly, track strategic
18
+ secondary choices, archive significant learning, and keep that work traced.
19
+
20
+ The chart and knowledge-graph surface below is {{NARRATIVE_TOOL_COUNT}} tools. The same
21
+ server also serves Langfuse, PDE, and planning tools — see `references/beyond-narrative.md`.
22
+
23
+ Its core data model is the structural tension chart — desired outcome, current reality,
24
+ telescoping action steps — backed by a JSONL knowledge graph.
25
+
26
+ ## Status
27
+
28
+ !`coaia --version 2>/dev/null || echo "Not installed: npm install -g coaiajs"`
29
+
30
+ ## First Principles
31
+
32
+ - Work from creative orientation: ask what result the user wants to create, not what
33
+ problem should disappear.
34
+ - Hold desired outcome and current reality at the same time. Do not collapse the tension
35
+ with "ready to begin" defaults.
36
+ - Treat action steps as strategic secondary choices. They are not a to-do list.
37
+ - Every action step is also a telescoped chart with its own desired outcome and current
38
+ reality.
39
+ - Use narrative beats for significant learning moments, not routine task tracking.
40
+ - Use a Wampum Belt when the sequence is not linear and position carries meaning.
41
+
42
+ ## MCP Setup
43
+
44
+ Use the MCP server when the assistant needs write access to chart memory:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "coaiajs": {
50
+ "command": "npx",
51
+ "args": ["-y", "coaiajs", "coaiajs-mcp", "--memory-path", "/absolute/path/to/memory.jsonl"],
52
+ "env": {
53
+ "COAIAJS_FEATURES": "STANDARD"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ `--memory-path` must be a real, expanded path. A path still carrying `${VAR}` is refused
61
+ at startup rather than opened — see `references/install-and-environment.md` for why that
62
+ refusal is the kind answer.
63
+
64
+ When a new session connects, call `init_llm_guidance` first: `format: "full"` for first
65
+ use, `format: "quick"` for a refresh.
66
+
67
+ ## CLI Inspection Flow
68
+
69
+ The CLI is for quick inspection, exports, and local chart context:
70
+
71
+ ```bash
72
+ coaia narrative list -M ./memory.jsonl
73
+ coaia narrative view <chartId> -M ./memory.jsonl
74
+ coaia narrative stats -M ./memory.jsonl
75
+ coaia narrative export <chartId> --output chart.md -M ./memory.jsonl
76
+ coaia narrative link-issue <chartId> owner/repo#123 -M ./memory.jsonl
77
+ ```
78
+
79
+ ## Core Workflow
80
+
81
+ 1. Read chart state before writing anything:
82
+
83
+ ```text
84
+ list_active_charts
85
+ ```
86
+
87
+ 2. Create a chart only when there is a new primary desired outcome:
88
+
89
+ ```json
90
+ {
91
+ "tool": "create_structural_tension_chart",
92
+ "arguments": {
93
+ "desiredOutcome": "A release process that runs the same way every time",
94
+ "currentReality": "Build and publish steps are manual and easy to miss",
95
+ "dueDate": "2027-06-01T00:00:00.000Z",
96
+ "actionSteps": ["Document release checks", "Verify npm package contents"],
97
+ "githubIssue": "jgwill/coaiajs#13"
98
+ }
99
+ }
100
+ ```
101
+
102
+ `githubIssue` is optional and takes the FULL `owner/repo#number` path. A bare `#number`
103
+ is refused: charts travel between repositories, and a bare number cites the wrong project
104
+ as soon as the chart is read somewhere else.
105
+
106
+ 3. Add or expand action steps with `manage_action_step`:
107
+
108
+ ```json
109
+ {
110
+ "tool": "manage_action_step",
111
+ "arguments": {
112
+ "parentReference": "chart_123",
113
+ "actionDescription": "Verify npm package contents",
114
+ "currentReality": "No package dry-run has been inspected for this release"
115
+ }
116
+ }
117
+ ```
118
+
119
+ 4. Track advancement without pretending completion:
120
+
121
+ ```text
122
+ update_action_progress
123
+ update_current_reality
124
+ mark_action_complete
125
+ ```
126
+
127
+ 5. Move a date with `update_chart_due_date` rather than editing the JSONL by hand. Several
128
+ MCP instances can point at one store with no lock, which is how a hand-edit becomes a
129
+ lost write.
130
+
131
+ 6. Use `perform_mmot_evaluation` when output and expected performance diverge, or when a
132
+ chart needs a truth-based review.
133
+
134
+ 7. Create a narrative beat when the work produced a significant learning moment across
135
+ engineer-world, ceremony-world, and story-engine-world.
136
+
137
+ ## Tool Map
138
+
139
+ {{TOOL_MAP}}
140
+
141
+ ## References
142
+
143
+ - `references/creative-orientation.md` — the creation-vs-problem-solving distinction
144
+ - `references/structural-tension-charting.md` — chart and action-step rules
145
+ - `references/delayed-resolution.md` — current reality discipline
146
+ - `references/narrative-beats.md` — story archive usage
147
+ - `references/wampum-belts.md` — non-linear mnemonic sequencing
148
+ - `references/reading-the-store.md` — reading a chart store without re-deriving its shape
149
+ - `references/beyond-narrative.md` — PDE, planning, Langfuse, pipeline
150
+ - `references/mcp-tools.md` — feature levels and environment variables
151
+ - `references/install-and-environment.md` — install, run, and the refusals worth knowing
@@ -0,0 +1,82 @@
1
+ # Beyond Narrative
2
+
3
+ `coaiajs` consolidates four CoAIA sub-projects. The chart engine is the centre, but three
4
+ other surfaces feed it and one observes it.
5
+
6
+ ## PDE — Prompt Decomposition Engine
7
+
8
+ Decomposes a complex prompt into an intent map — primary intent, secondary intents,
9
+ context requirements, expected outputs, and the four directions — then turns that map into
10
+ a chart.
11
+
12
+ | Tool | Use |
13
+ |---|---|
14
+ | `import_pde_decomposition` | Bring a decomposition JSON into the session store |
15
+ | `create_stc_from_pde` | Turn a decomposition into a structural tension chart |
16
+ | `list_pde_decompositions` | See what has been imported |
17
+ | `get_session`, `list_sessions`, `complete_session` | Session lifecycle |
18
+ | `pde_update_action_progress`, `pde_mark_action_complete`, `pde_add_action_step`, `pde_update_current_reality` | The chart verbs, targeting the PDE session |
19
+
20
+ The last four carry a `pde_` prefix because their unprefixed names belong to the narrative
21
+ group. Calling `add_action_step` targets the narrative chart; `pde_add_action_step`
22
+ targets the PDE session. Getting this wrong writes to the wrong store and reports success.
23
+
24
+ ```bash
25
+ coaia pde --help
26
+ ```
27
+
28
+ ## Planning
29
+
30
+ Parses a structured plan file into structural tension form and keeps it in sync with a
31
+ chart store, in both directions.
32
+
33
+ | Tool | Use |
34
+ |---|---|
35
+ | `parse_plan_structural` | Read a plan file into chart shape |
36
+ | `plan_to_stc` | Create charts from a plan |
37
+ | `sync_plan_to_chart` | Plan is authoritative |
38
+ | `sync_chart_to_plan` | Chart is authoritative |
39
+ | `create_plan_trace` | Emit a Langfuse trace for the plan |
40
+ | `pde_to_plan` | Turn a decomposition into a plan |
41
+
42
+ Choose the sync direction deliberately. Both write.
43
+
44
+ ```bash
45
+ coaia plan --help
46
+ ```
47
+
48
+ ## Langfuse
49
+
50
+ Traces, observations, scores, prompts, datasets, comments, and media, over the Langfuse
51
+ REST API. Use it to make the chart work observable rather than to store it — the JSONL
52
+ store remains the record.
53
+
54
+ ```bash
55
+ coaia fuse traces list
56
+ coaia fuse trace view <traceId>
57
+ coaia fuse prompts get <name>
58
+ ```
59
+
60
+ The `coaia_fuse_*` MCP tools mirror these. Media tools are `FULL`-level only.
61
+
62
+ ## Pipeline
63
+
64
+ A Jinja2-style template engine for prompt pipelines, exposed as the `coaia://templates/`
65
+ MCP resources and the `coaia pipeline` commands.
66
+
67
+ ```bash
68
+ coaia pipeline list
69
+ coaia pipeline run <name>
70
+ ```
71
+
72
+ ## Redis shorthand
73
+
74
+ `tash` / `fetch` are the COAIA SET/GET shorthand, used for stashing plan perspectives and
75
+ intermediate content:
76
+
77
+ ```bash
78
+ coaia tash mykey "value"
79
+ coaia fetch mykey
80
+ ```
81
+
82
+ Prefer the CLI over the MCP tool for these — it is the more reliable path.
@@ -0,0 +1,42 @@
1
+ # Creative Orientation
2
+
3
+ Creative orientation focuses on bringing desired results into being. Reactive orientation
4
+ focuses on removing unwanted conditions. `coaiajs` biases toward creation.
5
+
6
+ Ask: "What do you want to create?" Then define current reality in relation to that
7
+ desired outcome.
8
+
9
+ Structural tension is not a gap to bridge. It is the active disequilibrium created by
10
+ holding desired outcome and current reality clearly at the same time.
11
+
12
+ Use this language:
13
+
14
+ | Avoid | Prefer |
15
+ |---|---|
16
+ | bridge the gap | resolve the tension |
17
+ | close the gap | advance toward the desired outcome |
18
+ | tasks to fix the problem | strategic secondary choices |
19
+ | ready to begin | factual current reality |
20
+
21
+ A useful chart advances toward a created result. It does not merely remove a discomfort.
22
+
23
+ ## The guard, and what it does not do
24
+
25
+ `create_structural_tension_chart` refuses a desired outcome containing `fix`, `solve`,
26
+ `eliminate`, `prevent`, `stop`, `avoid`, `reduce`, or `remove`, and answers with the
27
+ teaching above.
28
+
29
+ It matches on **word boundaries**, not substrings. This matters: an earlier version used
30
+ `.includes()` and so read the letters of those words inside longer ones. Two measured
31
+ refusals, on outcomes already written in creative orientation:
32
+
33
+ - "a fixed ladder of named rungs" — refused for `fix`
34
+ - "carry one to completion or resolve it" — refused for `solve`
35
+
36
+ Both authors rephrased around the error without asking why, which is the quiet cost: a
37
+ guard that fires on innocent text teaches the caller to edit for the checker rather than
38
+ for the reader. Sharper still, the second example is the phrasing the COAIA guidance
39
+ itself prescribes.
40
+
41
+ The word list is unchanged. An outcome that genuinely says "eliminate" or "reduce" should
42
+ still be met with the teaching. Only the matching was corrected.
@@ -0,0 +1,48 @@
1
+ # Delayed Resolution
2
+
3
+ Tolerate discrepancy and delayed resolution. Do not smooth over the contradiction between
4
+ desired outcome and current reality.
5
+
6
+ When information is missing, ask for current reality or name the missing reality
7
+ explicitly. Do not invent readiness.
8
+
9
+ `create_structural_tension_chart` refuses a current reality containing "ready to",
10
+ "prepared to", "all set", "ready for", or "set to", and answers with the principle. That
11
+ refusal exists because a readiness assumption prematurely resolves the tension the chart
12
+ was created to hold.
13
+
14
+ ## MMOT — the Managerial Moment of Truth
15
+
16
+ Run `perform_mmot_evaluation` when output and expected performance diverge. Four phases,
17
+ in order:
18
+
19
+ 1. **Acknowledge** the difference between expected and delivered.
20
+ 2. **Analyze** how it came to pass.
21
+ 3. **Update** the chart and current reality.
22
+ 4. **Recommit** or redirect based on what is now true.
23
+
24
+ Call with `phase` set to one of those, or omit it for `full`.
25
+
26
+ ## What `updateReality` governs
27
+
28
+ `updateReality` controls **one** record: the append into current reality. The chart's own
29
+ `metadata.mmotEvaluations[]` trail is a separate record and is written whenever an
30
+ assessment was made.
31
+
32
+ An earlier version gated both on that one flag, so a caller who only asked to leave
33
+ current reality alone lost the evaluation entirely — while still being handed a full
34
+ phase response that read like a success. The response line now names which records were
35
+ actually written:
36
+
37
+ - `✅ Evaluation stored: chart MMOT trail + current reality.`
38
+ - `✅ Evaluation stored: chart MMOT trail (current reality left untouched, as requested).`
39
+
40
+ Read that line. A success line that names the wrong record is the same failure class as a
41
+ success line over zero bytes.
42
+
43
+ ## Elements of Performance
44
+
45
+ Pass `elementsOfPerformance` when creating a chart to define what the MMOT will evaluate
46
+ against. Each is `{ description, type }` where `type` is `DESIGN` (structural intent,
47
+ architecture) or `EXECUTION` (delivery, implementation quality). Without them, MMOT still
48
+ runs, but it has nothing concrete to compare the work to.
@@ -0,0 +1,85 @@
1
+ # Install And Environment
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g coaiajs
7
+ coaia --version
8
+ ```
9
+
10
+ ## The skill
11
+
12
+ ```bash
13
+ coaia skill show # print the packaged SKILL.md
14
+ coaia skill install # write ./.agents/skills/coaiajs
15
+ coaia skill install --global # write ~/.agents/skills/coaiajs
16
+ coaia skill install --yes # also create the .claude/skills/coaiajs symlink
17
+ coaia skill install --force # replace an existing install
18
+ coaia skill check # is the installed skill current?
19
+ ```
20
+
21
+ `coaia skill check` compares an installed skill against the packaged one and reports
22
+ `current`, `stale`, or `missing`. Run it after upgrading `coaiajs`: a skill installed by an
23
+ older version describes an older tool surface, and nothing else will tell you.
24
+
25
+ The tool map inside `SKILL.md` is generated from the server's own tool definitions at
26
+ install time, so an installed skill cannot advertise a tool this package does not serve.
27
+ The version it was generated from is recorded in the frontmatter as `packageVersion`.
28
+
29
+ ## Run the MCP server
30
+
31
+ ```bash
32
+ coaiajs-mcp --memory-path ./memory.jsonl
33
+ COAIAJS_FEATURES=FULL coaiajs-mcp --memory-path ./memory.jsonl
34
+ ```
35
+
36
+ ## Inspect from the CLI
37
+
38
+ ```bash
39
+ coaia narrative list -M ./memory.jsonl
40
+ coaia narrative view <chartId> -M ./memory.jsonl
41
+ coaia narrative stats -M ./memory.jsonl
42
+ coaia narrative progress <chartId> -M ./memory.jsonl
43
+ coaia narrative export <chartId> --output chart.md -M ./memory.jsonl
44
+ coaia narrative set-date <chartId> 2027-06-01T00:00:00Z --redistribute -M ./memory.jsonl
45
+ coaia narrative link-issue <chartId> owner/repo#123 -M ./memory.jsonl
46
+ ```
47
+
48
+ ## Refusals worth knowing about
49
+
50
+ ### A memory path carrying an unexpanded shell variable
51
+
52
+ ```
53
+ Refusing to open memory store: the path contains an unexpanded shell variable.
54
+ got: ${MIADI_CHART_MEMORY_PATH}
55
+ ```
56
+
57
+ A seat once booted with that variable unset, so its `.mcp.json` handed the process the
58
+ placeholder verbatim. The server started happily and wrote live charts into a file
59
+ literally named `${MIADI_CHART_MEMORY_PATH}`. Nothing failed — the charts were simply
60
+ somewhere nobody would look, and another seat auditing the boot found them.
61
+
62
+ The sibling failure is worse and is why this is fatal rather than a warning: had the
63
+ variable been set to a path that does not exist, the server would have started **clean and
64
+ empty**, and the seat would have reported its whole store lost. A store is the one input
65
+ where "start anyway" is never the kind answer.
66
+
67
+ `$` is legal in a filename, so a path containing `$` alone is fine. Only `${` is refused —
68
+ a caller writing that is quoting a shell it expected to have run.
69
+
70
+ ### A bare GitHub issue number
71
+
72
+ `githubIssue` and `link_chart_to_github_issue` require the full `owner/repo#number` path.
73
+ A bare `#42` resolves against whichever repository the reader happens to be in, which is
74
+ how an issue from one project ends up cited as another project's.
75
+
76
+ ### A malformed tool call
77
+
78
+ See `mcp-tools.md`. Nothing is written and the offending fragment is quoted back.
79
+
80
+ ## What this package does not lock
81
+
82
+ Writes are atomic — temp file, then rename — so a reader never sees a torn store. That
83
+ removes torn **reads**; it does not provide compare-and-swap. Two processes that both
84
+ load, then both write, still lose the earlier update, and both report success. If several
85
+ MCP instances point at one store, keep their write windows apart.
@@ -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`.