coaiajs 0.4.3 → 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/README.md +24 -5
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +13 -1
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/server.js +11 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/src/cli.js +62 -2
- 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/argument-hygiene.d.ts +46 -0
- package/dist/src/narrative/argument-hygiene.d.ts.map +1 -0
- package/dist/src/narrative/argument-hygiene.js +155 -0
- package/dist/src/narrative/argument-hygiene.js.map +1 -0
- package/dist/src/narrative/contract.d.ts +200 -0
- package/dist/src/narrative/contract.d.ts.map +1 -0
- package/dist/src/narrative/contract.js +274 -0
- package/dist/src/narrative/contract.js.map +1 -0
- package/dist/src/narrative/github-bridge.d.ts +23 -0
- package/dist/src/narrative/github-bridge.d.ts.map +1 -0
- package/dist/src/narrative/github-bridge.js +320 -0
- package/dist/src/narrative/github-bridge.js.map +1 -0
- package/dist/src/narrative/graph-manager.d.ts +83 -2
- package/dist/src/narrative/graph-manager.d.ts.map +1 -1
- package/dist/src/narrative/graph-manager.js +444 -54
- package/dist/src/narrative/graph-manager.js.map +1 -1
- package/dist/src/narrative/index.d.ts +24 -3
- package/dist/src/narrative/index.d.ts.map +1 -1
- package/dist/src/narrative/index.js +36 -15
- package/dist/src/narrative/index.js.map +1 -1
- package/dist/src/narrative/jsonl-preservation.d.ts +26 -0
- package/dist/src/narrative/jsonl-preservation.d.ts.map +1 -0
- package/dist/src/narrative/jsonl-preservation.js +293 -0
- package/dist/src/narrative/jsonl-preservation.js.map +1 -0
- package/dist/src/narrative/jsonl-records.d.ts +31 -0
- package/dist/src/narrative/jsonl-records.d.ts.map +1 -0
- package/dist/src/narrative/jsonl-records.js +69 -0
- package/dist/src/narrative/jsonl-records.js.map +1 -0
- package/dist/src/narrative/tool-definitions.d.ts +2 -1
- package/dist/src/narrative/tool-definitions.d.ts.map +1 -1
- package/dist/src/narrative/tool-definitions.js +134 -1
- package/dist/src/narrative/tool-definitions.js.map +1 -1
- package/dist/src/narrative/tool-handlers.d.ts.map +1 -1
- package/dist/src/narrative/tool-handlers.js +203 -20
- package/dist/src/narrative/tool-handlers.js.map +1 -1
- package/dist/src/narrative/types.d.ts +1 -1
- package/dist/src/narrative/types.d.ts.map +1 -1
- package/dist/src/narrative/validation.d.ts +13 -2
- package/dist/src/narrative/validation.d.ts.map +1 -1
- package/dist/src/narrative/validation.js +19 -4
- package/dist/src/narrative/validation.js.map +1 -1
- package/dist/src/skill.d.ts +78 -0
- package/dist/src/skill.d.ts.map +1 -0
- package/dist/src/skill.js +341 -0
- package/dist/src/skill.js.map +1 -0
- package/dist/src/types.d.ts +189 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- 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 +93 -8
- package/llms.txt +6 -3
- package/package.json +11 -1
- package/skills/coaiajs/SKILL.md +151 -0
- package/skills/coaiajs/references/beyond-narrative.md +82 -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,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* coaiajs — the packaged agent skill.
|
|
3
|
+
*
|
|
4
|
+
* WHY THE CONTENT IS NOT IN THIS FILE
|
|
5
|
+
*
|
|
6
|
+
* The lineage this is adapted from (coaia-narrative's `src/skill.ts`) embedded ~250
|
|
7
|
+
* lines of markdown as `['---', 'name: ...', ...].join('\n')`. That works, and it is
|
|
8
|
+
* unreadable: a documentation change shows up in review as a diff of quoted string
|
|
9
|
+
* fragments, no markdown tool can lint it, and the prose cannot be read in the form
|
|
10
|
+
* the reader will see.
|
|
11
|
+
*
|
|
12
|
+
* So the skill lives as real markdown under `skills/coaiajs/`, shipped by the `files`
|
|
13
|
+
* field, and is read from the package root at run time. `tests/skill.test.mjs` fails
|
|
14
|
+
* if a file listed here does not resolve, which is the failure mode this trades for.
|
|
15
|
+
*
|
|
16
|
+
* WHY THE TOOL MAP IS GENERATED
|
|
17
|
+
*
|
|
18
|
+
* A hand-written tool table drifts from the server the moment a tool is added, and a
|
|
19
|
+
* skill that advertises a tool the server does not serve teaches an agent to make a
|
|
20
|
+
* call that fails. `{{TOOL_MAP}}` is rendered from `ALL_TOOL_DEFINITIONS` — the same
|
|
21
|
+
* array the MCP server registers — so the two cannot disagree.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SKILL_NAME = "coaiajs";
|
|
24
|
+
/**
|
|
25
|
+
* Files that make up the skill, in the order a reader meets them.
|
|
26
|
+
*
|
|
27
|
+
* Listed explicitly rather than discovered by walking the directory: a stray file
|
|
28
|
+
* under `skills/` should not silently become part of what gets installed, and a
|
|
29
|
+
* missing one should be an error rather than a quietly shorter skill.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SKILL_FILES: readonly string[];
|
|
32
|
+
/** Directory inside the package holding the skill's markdown. */
|
|
33
|
+
export declare function getPackagedSkillDir(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Render the narrative tool surface as grouped markdown tables, from the definitions
|
|
36
|
+
* the MCP server actually registers. A tool that belongs to no group still appears,
|
|
37
|
+
* under "Other" — a tool silently absent from its own map is the drift this avoids.
|
|
38
|
+
*/
|
|
39
|
+
export declare function renderToolMap(): string;
|
|
40
|
+
/** Read one packaged skill file and fill its placeholders. */
|
|
41
|
+
export declare function renderSkillFile(relativeFilePath: string): string;
|
|
42
|
+
/** Every skill file, rendered, keyed by its path within the skill directory. */
|
|
43
|
+
export declare function renderSkill(): Map<string, string>;
|
|
44
|
+
export declare function getSkillInstallDir(globalInstall: boolean): string;
|
|
45
|
+
export declare function getClaudeSkillLinkPath(globalInstall: boolean): string;
|
|
46
|
+
/** Print the packaged SKILL.md, rendered. */
|
|
47
|
+
export declare function showSkill(): void;
|
|
48
|
+
export interface InstallSkillOptions {
|
|
49
|
+
global?: boolean;
|
|
50
|
+
force?: boolean;
|
|
51
|
+
yes?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function installSkill(options?: InstallSkillOptions): Promise<string>;
|
|
54
|
+
export interface SkillCheckResult {
|
|
55
|
+
status: 'current' | 'stale' | 'missing';
|
|
56
|
+
installDir: string;
|
|
57
|
+
packageVersion: string;
|
|
58
|
+
/** Version recorded in the installed SKILL.md frontmatter, when one is readable. */
|
|
59
|
+
installedVersion?: string;
|
|
60
|
+
/** Files whose installed content differs from what this package would write. */
|
|
61
|
+
differing: string[];
|
|
62
|
+
/** Files this package ships that the install does not have. */
|
|
63
|
+
absent: string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compare an installed skill against the packaged one.
|
|
67
|
+
*
|
|
68
|
+
* The failure this exists for is silent: a skill installed by an older `coaiajs`
|
|
69
|
+
* describes an older tool surface, sits there looking authoritative, and nothing in
|
|
70
|
+
* the normal flow ever says so. An agent then reads a tool map that no longer matches
|
|
71
|
+
* the server it is talking to.
|
|
72
|
+
*/
|
|
73
|
+
export declare function checkSkill(options?: {
|
|
74
|
+
global?: boolean;
|
|
75
|
+
}): SkillCheckResult;
|
|
76
|
+
/** Human-readable form of a check, for the CLI. */
|
|
77
|
+
export declare function formatSkillCheck(result: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C;IACpB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,gBAAgB,CA6B/E;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAqBjE"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* coaiajs — the packaged agent skill.
|
|
3
|
+
*
|
|
4
|
+
* WHY THE CONTENT IS NOT IN THIS FILE
|
|
5
|
+
*
|
|
6
|
+
* The lineage this is adapted from (coaia-narrative's `src/skill.ts`) embedded ~250
|
|
7
|
+
* lines of markdown as `['---', 'name: ...', ...].join('\n')`. That works, and it is
|
|
8
|
+
* unreadable: a documentation change shows up in review as a diff of quoted string
|
|
9
|
+
* fragments, no markdown tool can lint it, and the prose cannot be read in the form
|
|
10
|
+
* the reader will see.
|
|
11
|
+
*
|
|
12
|
+
* So the skill lives as real markdown under `skills/coaiajs/`, shipped by the `files`
|
|
13
|
+
* field, and is read from the package root at run time. `tests/skill.test.mjs` fails
|
|
14
|
+
* if a file listed here does not resolve, which is the failure mode this trades for.
|
|
15
|
+
*
|
|
16
|
+
* WHY THE TOOL MAP IS GENERATED
|
|
17
|
+
*
|
|
18
|
+
* A hand-written tool table drifts from the server the moment a tool is added, and a
|
|
19
|
+
* skill that advertises a tool the server does not serve teaches an agent to make a
|
|
20
|
+
* call that fails. `{{TOOL_MAP}}` is rendered from `ALL_TOOL_DEFINITIONS` — the same
|
|
21
|
+
* array the MCP server registers — so the two cannot disagree.
|
|
22
|
+
*/
|
|
23
|
+
import { lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, rmSync, symlinkSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
24
|
+
import { homedir } from 'node:os';
|
|
25
|
+
import { dirname, join, relative as relativePath, resolve } from 'node:path';
|
|
26
|
+
import { createInterface } from 'node:readline/promises';
|
|
27
|
+
import { getPackageRoot, getPackageVersion } from './version.js';
|
|
28
|
+
import { ALL_TOOL_DEFINITIONS, CORE_TOOLS, STC_TOOLS, NARRATIVE_TOOLS, WAMPUM_TOOLS, KG_TOOLS, } from './narrative/index.js';
|
|
29
|
+
export const SKILL_NAME = 'coaiajs';
|
|
30
|
+
/**
|
|
31
|
+
* Files that make up the skill, in the order a reader meets them.
|
|
32
|
+
*
|
|
33
|
+
* Listed explicitly rather than discovered by walking the directory: a stray file
|
|
34
|
+
* under `skills/` should not silently become part of what gets installed, and a
|
|
35
|
+
* missing one should be an error rather than a quietly shorter skill.
|
|
36
|
+
*/
|
|
37
|
+
export const SKILL_FILES = [
|
|
38
|
+
'SKILL.md',
|
|
39
|
+
'references/creative-orientation.md',
|
|
40
|
+
'references/structural-tension-charting.md',
|
|
41
|
+
'references/delayed-resolution.md',
|
|
42
|
+
'references/narrative-beats.md',
|
|
43
|
+
'references/wampum-belts.md',
|
|
44
|
+
'references/reading-the-store.md',
|
|
45
|
+
'references/beyond-narrative.md',
|
|
46
|
+
'references/mcp-tools.md',
|
|
47
|
+
'references/install-and-environment.md',
|
|
48
|
+
];
|
|
49
|
+
/** Directory inside the package holding the skill's markdown. */
|
|
50
|
+
export function getPackagedSkillDir() {
|
|
51
|
+
return join(getPackageRoot(), 'skills', SKILL_NAME);
|
|
52
|
+
}
|
|
53
|
+
// ─── Tool map generation ──────────────────────────────────────────────
|
|
54
|
+
/**
|
|
55
|
+
* Abbreviations whose trailing period does not end a sentence. Without these,
|
|
56
|
+
* `open_nodes` — whose description reads "…by exact name (e.g. 'chart_123_chart')" —
|
|
57
|
+
* rendered as "Open specific entity nodes by exact name (e.g." in the table, which
|
|
58
|
+
* reads as a truncation bug rather than as a description.
|
|
59
|
+
*/
|
|
60
|
+
const NON_TERMINAL_ABBREVIATIONS = ['e.g', 'i.e', 'etc', 'vs', 'cf', 'approx', 'no'];
|
|
61
|
+
/**
|
|
62
|
+
* One line of description, trimmed to something a table cell can hold.
|
|
63
|
+
*
|
|
64
|
+
* Leading emphasis markers ("🚨 NEW LLM?", "✨ RECOMMENDED:", "⚠️ DEPRECATED:") are kept
|
|
65
|
+
* deliberately — they carry the tool's own stance about itself, and a map that hides a
|
|
66
|
+
* deprecation is worse than one that shows it.
|
|
67
|
+
*/
|
|
68
|
+
function shortDescription(description) {
|
|
69
|
+
const collapsed = description.replace(/\s+/g, ' ').trim();
|
|
70
|
+
// Cut at the first period that actually ends a sentence: followed by whitespace and
|
|
71
|
+
// something that starts one, and not preceded by an abbreviation or a single letter.
|
|
72
|
+
let sentence = collapsed;
|
|
73
|
+
for (const match of collapsed.matchAll(/\.(?=\s+[A-Z0-9`'"(\u{1F300}-\u{1FAFF}])/gu)) {
|
|
74
|
+
const before = collapsed.slice(0, match.index);
|
|
75
|
+
const lastWord = (/([A-Za-z.]+)$/.exec(before)?.[1] ?? '').toLowerCase();
|
|
76
|
+
if (NON_TERMINAL_ABBREVIATIONS.includes(lastWord))
|
|
77
|
+
continue;
|
|
78
|
+
if (/^[a-z]$/.test(lastWord))
|
|
79
|
+
continue; // an initial, not a sentence end
|
|
80
|
+
sentence = collapsed.slice(0, match.index + 1);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const escaped = sentence.replace(/\|/g, '\\|');
|
|
84
|
+
return escaped.length > 180 ? `${escaped.slice(0, 177)}…` : escaped;
|
|
85
|
+
}
|
|
86
|
+
const TOOL_GROUP_ORDER = [
|
|
87
|
+
{ title: 'Start here', names: CORE_TOOLS },
|
|
88
|
+
{ title: 'Structural tension charts', names: STC_TOOLS },
|
|
89
|
+
{ title: 'Narrative beats', names: NARRATIVE_TOOLS },
|
|
90
|
+
{ title: 'Wampum belts', names: WAMPUM_TOOLS },
|
|
91
|
+
{ title: 'Knowledge graph', names: KG_TOOLS },
|
|
92
|
+
];
|
|
93
|
+
/**
|
|
94
|
+
* Render the narrative tool surface as grouped markdown tables, from the definitions
|
|
95
|
+
* the MCP server actually registers. A tool that belongs to no group still appears,
|
|
96
|
+
* under "Other" — a tool silently absent from its own map is the drift this avoids.
|
|
97
|
+
*/
|
|
98
|
+
export function renderToolMap() {
|
|
99
|
+
const byName = new Map(ALL_TOOL_DEFINITIONS.map(t => [t.name, t]));
|
|
100
|
+
const placed = new Set();
|
|
101
|
+
const sections = [];
|
|
102
|
+
for (const group of TOOL_GROUP_ORDER) {
|
|
103
|
+
const rows = [];
|
|
104
|
+
for (const name of group.names) {
|
|
105
|
+
const tool = byName.get(name);
|
|
106
|
+
if (!tool || placed.has(name))
|
|
107
|
+
continue;
|
|
108
|
+
placed.add(name);
|
|
109
|
+
rows.push(`| \`${name}\` | ${shortDescription(tool.description)} |`);
|
|
110
|
+
}
|
|
111
|
+
if (rows.length === 0)
|
|
112
|
+
continue;
|
|
113
|
+
sections.push(`### ${group.title}\n\n| Tool | Use |\n|---|---|\n${rows.join('\n')}`);
|
|
114
|
+
}
|
|
115
|
+
const leftover = ALL_TOOL_DEFINITIONS.filter(t => !placed.has(t.name));
|
|
116
|
+
if (leftover.length > 0) {
|
|
117
|
+
const rows = leftover.map(t => `| \`${t.name}\` | ${shortDescription(t.description)} |`);
|
|
118
|
+
sections.push(`### Other\n\n| Tool | Use |\n|---|---|\n${rows.join('\n')}`);
|
|
119
|
+
}
|
|
120
|
+
return sections.join('\n\n');
|
|
121
|
+
}
|
|
122
|
+
// ─── Rendering ────────────────────────────────────────────────────────
|
|
123
|
+
/** Placeholders a packaged skill file may carry. */
|
|
124
|
+
function substitutions() {
|
|
125
|
+
return {
|
|
126
|
+
VERSION: getPackageVersion(),
|
|
127
|
+
// The narrative/chart surface only. The server also serves Langfuse, PDE, and
|
|
128
|
+
// planning tools, and counting those here would mean importing the MCP feature
|
|
129
|
+
// config into the library — see references/beyond-narrative.md instead.
|
|
130
|
+
NARRATIVE_TOOL_COUNT: String(ALL_TOOL_DEFINITIONS.length),
|
|
131
|
+
TOOL_MAP: renderToolMap(),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function applySubstitutions(content, values) {
|
|
135
|
+
return content.replace(/\{\{([A-Z_]+)\}\}/g, (whole, key) => {
|
|
136
|
+
const value = values[key];
|
|
137
|
+
if (value === undefined) {
|
|
138
|
+
throw new Error(`Packaged skill carries an unknown placeholder {{${key}}}. ` +
|
|
139
|
+
`Add it to substitutions() in src/skill.ts or remove it from the markdown.`);
|
|
140
|
+
}
|
|
141
|
+
return value;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** Read one packaged skill file and fill its placeholders. */
|
|
145
|
+
export function renderSkillFile(relativeFilePath) {
|
|
146
|
+
const source = join(getPackagedSkillDir(), relativeFilePath);
|
|
147
|
+
let raw;
|
|
148
|
+
try {
|
|
149
|
+
raw = readFileSync(source, 'utf8');
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
throw new Error(`Packaged skill file missing: ${source}. ` +
|
|
153
|
+
`The published package must ship skills/ — check the "files" field in package.json.`);
|
|
154
|
+
}
|
|
155
|
+
return applySubstitutions(raw, substitutions());
|
|
156
|
+
}
|
|
157
|
+
/** Every skill file, rendered, keyed by its path within the skill directory. */
|
|
158
|
+
export function renderSkill() {
|
|
159
|
+
const values = substitutions();
|
|
160
|
+
const rendered = new Map();
|
|
161
|
+
for (const file of SKILL_FILES) {
|
|
162
|
+
const source = join(getPackagedSkillDir(), file);
|
|
163
|
+
let raw;
|
|
164
|
+
try {
|
|
165
|
+
raw = readFileSync(source, 'utf8');
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
throw new Error(`Packaged skill file missing: ${source}. ` +
|
|
169
|
+
`The published package must ship skills/ — check the "files" field in package.json.`);
|
|
170
|
+
}
|
|
171
|
+
rendered.set(file, applySubstitutions(raw, values));
|
|
172
|
+
}
|
|
173
|
+
return rendered;
|
|
174
|
+
}
|
|
175
|
+
// ─── Install locations ────────────────────────────────────────────────
|
|
176
|
+
export function getSkillInstallDir(globalInstall) {
|
|
177
|
+
return globalInstall
|
|
178
|
+
? resolve(homedir(), '.agents', 'skills', SKILL_NAME)
|
|
179
|
+
: resolve(process.cwd(), '.agents', 'skills', SKILL_NAME);
|
|
180
|
+
}
|
|
181
|
+
export function getClaudeSkillLinkPath(globalInstall) {
|
|
182
|
+
return globalInstall
|
|
183
|
+
? resolve(homedir(), '.claude', 'skills', SKILL_NAME)
|
|
184
|
+
: resolve(process.cwd(), '.claude', 'skills', SKILL_NAME);
|
|
185
|
+
}
|
|
186
|
+
function pathExists(pathName) {
|
|
187
|
+
try {
|
|
188
|
+
lstatSync(pathName);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function removePath(pathName) {
|
|
196
|
+
const stat = lstatSync(pathName);
|
|
197
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
198
|
+
rmSync(pathName, { recursive: true, force: true });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
unlinkSync(pathName);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function writeRenderedSkill(targetDir, force) {
|
|
205
|
+
// Render before touching anything on disk: a missing packaged file must not leave
|
|
206
|
+
// a half-written skill where a whole one used to be.
|
|
207
|
+
const rendered = renderSkill();
|
|
208
|
+
if (pathExists(targetDir)) {
|
|
209
|
+
if (!force) {
|
|
210
|
+
throw new Error(`Skill already exists: ${targetDir} (use --force to replace it)`);
|
|
211
|
+
}
|
|
212
|
+
removePath(targetDir);
|
|
213
|
+
}
|
|
214
|
+
mkdirSync(targetDir, { recursive: true });
|
|
215
|
+
for (const [file, content] of rendered) {
|
|
216
|
+
const destination = resolve(targetDir, file);
|
|
217
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
218
|
+
writeFileSync(destination, content, 'utf-8');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function ensureClaudeSymlink(linkPath, targetDir, force) {
|
|
222
|
+
const parentDir = dirname(linkPath);
|
|
223
|
+
if (pathExists(parentDir)) {
|
|
224
|
+
const resolvedTargetParent = realpathSync(dirname(targetDir));
|
|
225
|
+
const resolvedLinkParent = realpathSync(parentDir);
|
|
226
|
+
// Already the same directory — Claude sees the skill without a link.
|
|
227
|
+
if (resolvedTargetParent === resolvedLinkParent) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const linkTarget = relativePath(parentDir, targetDir) || '.';
|
|
232
|
+
mkdirSync(parentDir, { recursive: true });
|
|
233
|
+
if (pathExists(linkPath)) {
|
|
234
|
+
const stat = lstatSync(linkPath);
|
|
235
|
+
if (stat.isSymbolicLink() && readlinkSync(linkPath) === linkTarget) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
if (!force) {
|
|
239
|
+
throw new Error(`Claude skill path already exists: ${linkPath} (use --force to replace it)`);
|
|
240
|
+
}
|
|
241
|
+
removePath(linkPath);
|
|
242
|
+
}
|
|
243
|
+
symlinkSync(linkTarget, linkPath, 'dir');
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
async function shouldCreateClaudeSymlink(linkPath, autoYes) {
|
|
247
|
+
if (autoYes)
|
|
248
|
+
return true;
|
|
249
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
250
|
+
console.log(`Tip: create a Claude symlink manually at ${linkPath}`);
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
254
|
+
try {
|
|
255
|
+
const answer = await rl.question(`Create a symlink in ${linkPath}? [y/N] `);
|
|
256
|
+
const normalized = answer.trim().toLowerCase();
|
|
257
|
+
return normalized === 'y' || normalized === 'yes';
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
rl.close();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// ─── Commands ─────────────────────────────────────────────────────────
|
|
264
|
+
/** Print the packaged SKILL.md, rendered. */
|
|
265
|
+
export function showSkill() {
|
|
266
|
+
process.stdout.write(renderSkillFile('SKILL.md'));
|
|
267
|
+
}
|
|
268
|
+
export async function installSkill(options = {}) {
|
|
269
|
+
const globalInstall = options.global === true;
|
|
270
|
+
const installDir = getSkillInstallDir(globalInstall);
|
|
271
|
+
writeRenderedSkill(installDir, options.force === true);
|
|
272
|
+
console.log(`Installed the coaiajs skill (v${getPackageVersion()}) to ${installDir}`);
|
|
273
|
+
const claudeLinkPath = getClaudeSkillLinkPath(globalInstall);
|
|
274
|
+
if (await shouldCreateClaudeSymlink(claudeLinkPath, options.yes === true)) {
|
|
275
|
+
const linked = ensureClaudeSymlink(claudeLinkPath, installDir, options.force === true);
|
|
276
|
+
console.log(linked
|
|
277
|
+
? `Linked Claude skill at ${claudeLinkPath}`
|
|
278
|
+
: `Claude already sees the skill via ${dirname(claudeLinkPath)}`);
|
|
279
|
+
}
|
|
280
|
+
return installDir;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Compare an installed skill against the packaged one.
|
|
284
|
+
*
|
|
285
|
+
* The failure this exists for is silent: a skill installed by an older `coaiajs`
|
|
286
|
+
* describes an older tool surface, sits there looking authoritative, and nothing in
|
|
287
|
+
* the normal flow ever says so. An agent then reads a tool map that no longer matches
|
|
288
|
+
* the server it is talking to.
|
|
289
|
+
*/
|
|
290
|
+
export function checkSkill(options = {}) {
|
|
291
|
+
const installDir = getSkillInstallDir(options.global === true);
|
|
292
|
+
const packageVersion = getPackageVersion();
|
|
293
|
+
if (!pathExists(installDir)) {
|
|
294
|
+
return { status: 'missing', installDir, packageVersion, differing: [], absent: [...SKILL_FILES] };
|
|
295
|
+
}
|
|
296
|
+
const rendered = renderSkill();
|
|
297
|
+
const differing = [];
|
|
298
|
+
const absent = [];
|
|
299
|
+
let installedVersion;
|
|
300
|
+
for (const [file, expected] of rendered) {
|
|
301
|
+
let actual;
|
|
302
|
+
try {
|
|
303
|
+
actual = readFileSync(resolve(installDir, file), 'utf8');
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
absent.push(file);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (file === 'SKILL.md') {
|
|
310
|
+
installedVersion = /^\s*packageVersion:\s*"?([^"\n]+)"?\s*$/m.exec(actual)?.[1]?.trim();
|
|
311
|
+
}
|
|
312
|
+
if (actual !== expected)
|
|
313
|
+
differing.push(file);
|
|
314
|
+
}
|
|
315
|
+
const status = differing.length === 0 && absent.length === 0 ? 'current' : 'stale';
|
|
316
|
+
return { status, installDir, packageVersion, installedVersion, differing, absent };
|
|
317
|
+
}
|
|
318
|
+
/** Human-readable form of a check, for the CLI. */
|
|
319
|
+
export function formatSkillCheck(result) {
|
|
320
|
+
const lines = [];
|
|
321
|
+
switch (result.status) {
|
|
322
|
+
case 'missing':
|
|
323
|
+
lines.push(`No skill installed at ${result.installDir}`);
|
|
324
|
+
lines.push(`Install it with: coaia skill install`);
|
|
325
|
+
break;
|
|
326
|
+
case 'current':
|
|
327
|
+
lines.push(`Skill at ${result.installDir} is current (v${result.packageVersion})`);
|
|
328
|
+
break;
|
|
329
|
+
case 'stale':
|
|
330
|
+
lines.push(`Skill at ${result.installDir} is stale: installed from ` +
|
|
331
|
+
`v${result.installedVersion ?? 'unknown'}, package is v${result.packageVersion}`);
|
|
332
|
+
if (result.absent.length > 0)
|
|
333
|
+
lines.push(` absent: ${result.absent.join(', ')}`);
|
|
334
|
+
if (result.differing.length > 0)
|
|
335
|
+
lines.push(` differs: ${result.differing.join(', ')}`);
|
|
336
|
+
lines.push(`Refresh it with: coaia skill install --force`);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
return lines.join('\n');
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"AAAA;;;;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;YACzF,KAAK,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;YAC3D,MAAM;IACV,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,8 +1,169 @@
|
|
|
1
1
|
export interface Entity {
|
|
2
|
+
/** Present on records read straight from the JSONL store, where it carries the line's kind. */
|
|
3
|
+
type?: string;
|
|
2
4
|
name: string;
|
|
3
5
|
entityType: string;
|
|
4
6
|
observations: string[];
|
|
5
7
|
metadata?: EntityMetadata;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export type GithubSyncState = 'synced' | 'diverged' | 'conflict' | 'project-only' | 'chart-only';
|
|
11
|
+
export type GithubSyncAuthority = 'jsonl' | 'project';
|
|
12
|
+
export interface GithubIssueRef {
|
|
13
|
+
owner: string;
|
|
14
|
+
repo: string;
|
|
15
|
+
number: number;
|
|
16
|
+
nodeId?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GithubProjectItemRef {
|
|
20
|
+
projectNumber: number;
|
|
21
|
+
projectOwner: string;
|
|
22
|
+
projectTitle?: string;
|
|
23
|
+
itemId: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface GithubBridgeMetadata {
|
|
27
|
+
issue?: GithubIssueRef;
|
|
28
|
+
projectItem?: GithubProjectItemRef;
|
|
29
|
+
projectItems?: GithubProjectItemRef[];
|
|
30
|
+
syncState?: GithubSyncState;
|
|
31
|
+
lastSyncedAt?: string;
|
|
32
|
+
fieldHash?: string;
|
|
33
|
+
authoritativeOnLastSync?: GithubSyncAuthority;
|
|
34
|
+
}
|
|
35
|
+
export type GithubChartProvenance = GithubBridgeMetadata;
|
|
36
|
+
export type GithubActionStepProvenance = GithubBridgeMetadata;
|
|
37
|
+
export interface LegacyGithubSyncTarget {
|
|
38
|
+
owner?: string;
|
|
39
|
+
repo?: string;
|
|
40
|
+
issue_number?: number;
|
|
41
|
+
issueNumber?: number;
|
|
42
|
+
number?: number;
|
|
43
|
+
node_id?: string;
|
|
44
|
+
nodeId?: string;
|
|
45
|
+
issue_url?: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
project_id?: string;
|
|
48
|
+
projectId?: string;
|
|
49
|
+
project_number?: number;
|
|
50
|
+
projectNumber?: number;
|
|
51
|
+
project_owner?: string;
|
|
52
|
+
projectOwner?: string;
|
|
53
|
+
project_title?: string;
|
|
54
|
+
projectTitle?: string;
|
|
55
|
+
item_id?: string;
|
|
56
|
+
itemId?: string;
|
|
57
|
+
project_url?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface LegacyGithubRef {
|
|
60
|
+
owner?: string;
|
|
61
|
+
repo?: string;
|
|
62
|
+
issue_number?: number;
|
|
63
|
+
issueNumber?: number;
|
|
64
|
+
number?: number;
|
|
65
|
+
node_id?: string;
|
|
66
|
+
nodeId?: string;
|
|
67
|
+
issue_url?: string;
|
|
68
|
+
url?: string;
|
|
69
|
+
}
|
|
70
|
+
export type SourceSystem = 'coaia-narrative' | 'coaia-pde' | 'coaia-planning' | 'mcp-pde' | 'manual' | 'miadi' | 'coaia-github' | 'coaiajs' | (string & {});
|
|
71
|
+
export interface SourceProvenance {
|
|
72
|
+
system: SourceSystem;
|
|
73
|
+
version?: string;
|
|
74
|
+
toolName?: string;
|
|
75
|
+
sessionId?: string;
|
|
76
|
+
createdAt?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Deep Research Foundations metadata for tracking research packet context and evaluation status.
|
|
80
|
+
* Used by Atlas Chronicle and research delegation workflows.
|
|
81
|
+
*
|
|
82
|
+
* @see https://github.com/avadisabelle/coaia-narrative/issues/39
|
|
83
|
+
*/
|
|
84
|
+
export interface DeepResearchFoundationMetadata {
|
|
85
|
+
packetRoot?: string;
|
|
86
|
+
foundationType?: string;
|
|
87
|
+
parentIssue?: string;
|
|
88
|
+
baselineIssue?: string;
|
|
89
|
+
inquiryIssue?: string;
|
|
90
|
+
protocolIssue?: string;
|
|
91
|
+
schemaIssue?: string;
|
|
92
|
+
visualizerIssue?: string;
|
|
93
|
+
expectedArtifacts?: string[];
|
|
94
|
+
producedArtifacts?: string[];
|
|
95
|
+
evaluationStatus?: 'expected' | 'delegated' | 'produced' | 'evaluated';
|
|
96
|
+
privacyClass?: 'public-safe' | 'private' | 'mixed';
|
|
97
|
+
publicationStatus?: 'planned' | 'draft' | 'reviewed' | 'published';
|
|
98
|
+
commitHandles?: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Hermes session lineage metadata tracking conversation branching and handoff state.
|
|
102
|
+
* Used for reconstructing branch maps and session traceability.
|
|
103
|
+
*
|
|
104
|
+
* @see https://github.com/avadisabelle/coaia-narrative/issues/40
|
|
105
|
+
*/
|
|
106
|
+
export interface HermesSessionLineageMetadata {
|
|
107
|
+
platform?: string;
|
|
108
|
+
parentChartId?: string;
|
|
109
|
+
sourceBeat?: string;
|
|
110
|
+
originalSessionId?: string;
|
|
111
|
+
branchSessionId?: string;
|
|
112
|
+
branchIndex?: number;
|
|
113
|
+
copiedMessageCount?: number;
|
|
114
|
+
branchPurpose?: string;
|
|
115
|
+
relatedIssues?: string[];
|
|
116
|
+
handoffState?: 'requirements-created' | 'implementation-ready' | 'returned-to-parent';
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Beat-level lived session context metadata capturing the embodied condition of working sessions.
|
|
120
|
+
* Records land-based learning, voice/terminal mode, environmental constraints, and continuity context.
|
|
121
|
+
*
|
|
122
|
+
* @see https://github.com/avadisabelle/coaia-narrative/issues/42
|
|
123
|
+
*/
|
|
124
|
+
export interface SessionContextMetadata {
|
|
125
|
+
mode?: 'voice' | 'terminal' | 'mixed';
|
|
126
|
+
setting?: 'desk' | 'walking' | 'land-based' | 'transit' | 'unknown';
|
|
127
|
+
landBasedLearning?: boolean;
|
|
128
|
+
environmentNotes?: string[];
|
|
129
|
+
listeningContext?: string;
|
|
130
|
+
captureQuality?: 'clear' | 'windy' | 'partial';
|
|
131
|
+
continuationKind?: 'branch' | 'parent-return' | 'follow-up';
|
|
132
|
+
privateChroniclePath?: string;
|
|
133
|
+
publicSummaryAllowed?: boolean;
|
|
134
|
+
}
|
|
135
|
+
export interface WampumBeadPosition {
|
|
136
|
+
row: number;
|
|
137
|
+
col: number;
|
|
138
|
+
}
|
|
139
|
+
export interface WampumCeremonyLink {
|
|
140
|
+
ceremonyType: 'commitment' | 'accountability' | 'witness' | 'renewal';
|
|
141
|
+
chartId?: string;
|
|
142
|
+
beatName?: string;
|
|
143
|
+
witnessNames?: string[];
|
|
144
|
+
renewalDate?: string;
|
|
145
|
+
notes?: string;
|
|
146
|
+
}
|
|
147
|
+
export interface WampumBead {
|
|
148
|
+
id: string;
|
|
149
|
+
mnemonic: string;
|
|
150
|
+
color: 'white' | 'purple' | 'black' | 'mixed';
|
|
151
|
+
position: WampumBeadPosition;
|
|
152
|
+
reading: string;
|
|
153
|
+
relationalReadings?: Record<string, string>;
|
|
154
|
+
ceremonyLink?: WampumCeremonyLink;
|
|
155
|
+
observations: string[];
|
|
156
|
+
createdAt: string;
|
|
157
|
+
}
|
|
158
|
+
export interface WampumBeltMetadata {
|
|
159
|
+
beltId: string;
|
|
160
|
+
title: string;
|
|
161
|
+
purpose: string;
|
|
162
|
+
rows: number;
|
|
163
|
+
cols: number;
|
|
164
|
+
beads: WampumBead[];
|
|
165
|
+
createdAt: string;
|
|
166
|
+
updatedAt: string;
|
|
6
167
|
}
|
|
7
168
|
export interface EntityMetadata {
|
|
8
169
|
dueDate?: string;
|
|
@@ -49,23 +210,51 @@ export interface EntityMetadata {
|
|
|
49
210
|
lessons: string[];
|
|
50
211
|
};
|
|
51
212
|
order?: number;
|
|
213
|
+
github?: GithubBridgeMetadata;
|
|
214
|
+
source?: SourceProvenance;
|
|
215
|
+
/** Deep Research Foundations metadata for research packet tracking and evaluation. */
|
|
216
|
+
foundation?: DeepResearchFoundationMetadata;
|
|
217
|
+
/** Hermes session lineage metadata for conversation branching and handoff tracking. */
|
|
218
|
+
sessionLineage?: HermesSessionLineageMetadata;
|
|
219
|
+
/** Beat-level lived session context capturing embodied working conditions. */
|
|
220
|
+
sessionContext?: SessionContextMetadata;
|
|
221
|
+
/** Wampum Belt metadata for non-linear mnemonic sequencing with ceremony links. */
|
|
222
|
+
wampumBelt?: WampumBeltMetadata;
|
|
223
|
+
/** Belt identifier carried on the wampum_belt entity itself. */
|
|
224
|
+
beltId?: string;
|
|
225
|
+
/** @deprecated Use github.issue and github.projectItem instead. */
|
|
226
|
+
sync_target?: LegacyGithubSyncTarget;
|
|
227
|
+
/** @deprecated Use github.issue instead. */
|
|
228
|
+
github_ref?: LegacyGithubRef;
|
|
229
|
+
[key: string]: unknown;
|
|
52
230
|
}
|
|
53
231
|
export interface Relation {
|
|
232
|
+
/** Present on records read straight from the JSONL store, where it carries the line's kind. */
|
|
233
|
+
type?: string;
|
|
54
234
|
from: string;
|
|
55
235
|
to: string;
|
|
56
236
|
relationType: string;
|
|
57
237
|
metadata?: RelationMetadata;
|
|
238
|
+
[key: string]: unknown;
|
|
58
239
|
}
|
|
59
240
|
export interface RelationMetadata {
|
|
60
241
|
createdAt?: string;
|
|
61
242
|
strength?: number;
|
|
62
243
|
context?: string;
|
|
63
244
|
description?: string;
|
|
245
|
+
beltId?: string;
|
|
246
|
+
[key: string]: unknown;
|
|
64
247
|
}
|
|
65
248
|
export interface KnowledgeGraph {
|
|
66
249
|
entities: Entity[];
|
|
67
250
|
relations: Relation[];
|
|
251
|
+
/**
|
|
252
|
+
* The store's lines exactly as they were read, kept so a write can round-trip
|
|
253
|
+
* fields this package does not model. Absent on a graph built in memory.
|
|
254
|
+
*/
|
|
255
|
+
rawRecords?: JsonlRecord[];
|
|
68
256
|
}
|
|
257
|
+
export type JsonlRecord = Record<string, unknown>;
|
|
69
258
|
export interface McpToolResult {
|
|
70
259
|
content: Array<{
|
|
71
260
|
type: string;
|