@clawmasons/shared 0.1.0 → 0.1.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 +7 -0
- package/dist/mason/index.d.ts +3 -0
- package/dist/mason/index.d.ts.map +1 -0
- package/dist/mason/index.js +5 -0
- package/dist/mason/index.js.map +1 -0
- package/dist/mason/proposer.d.ts +36 -0
- package/dist/mason/proposer.d.ts.map +1 -0
- package/dist/mason/proposer.js +121 -0
- package/dist/mason/proposer.js.map +1 -0
- package/dist/mason/scanner.d.ts +64 -0
- package/dist/mason/scanner.d.ts.map +1 -0
- package/dist/mason/scanner.js +212 -0
- package/dist/mason/scanner.js.map +1 -0
- package/dist/role/adapter.d.ts +1 -1
- package/dist/role/adapter.js +2 -2
- package/dist/role/adapter.js.map +1 -1
- package/dist/role/dialect-registry.d.ts +49 -0
- package/dist/role/dialect-registry.d.ts.map +1 -0
- package/dist/role/dialect-registry.js +100 -0
- package/dist/role/dialect-registry.js.map +1 -0
- package/dist/role/index.d.ts +7 -0
- package/dist/schemas/app.d.ts +59 -0
- package/dist/schemas/app.d.ts.map +1 -0
- package/dist/schemas/app.js +42 -0
- package/dist/schemas/app.js.map +1 -0
- package/dist/schemas/chapter-field.d.ts +8 -0
- package/dist/schemas/chapter-field.d.ts.map +1 -0
- package/dist/schemas/chapter-field.js +60 -0
- package/dist/schemas/chapter-field.js.map +1 -0
- package/dist/schemas/role-types.d.ts +74 -74
- package/dist/schemas/role.d.ts +87 -0
- package/dist/schemas/role.d.ts.map +1 -0
- package/dist/schemas/role.js +29 -0
- package/dist/schemas/role.js.map +1 -0
- package/dist/schemas/skill.d.ts +16 -0
- package/dist/schemas/skill.d.ts.map +1 -0
- package/dist/schemas/skill.js +7 -0
- package/dist/schemas/skill.js.map +1 -0
- package/dist/schemas/task.d.ts +43 -0
- package/dist/schemas/task.d.ts.map +1 -0
- package/dist/schemas/task.js +16 -0
- package/dist/schemas/task.js.map +1 -0
- package/dist/toolfilter.d.ts +28 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @clawmasons/shared
|
|
2
|
+
|
|
3
|
+
Shared types, schemas, and utilities for the Mason CLI
|
|
4
|
+
|
|
5
|
+
## More Information
|
|
6
|
+
|
|
7
|
+
This package is part of the [Mason](https://github.com/clawmasons/mason) monorepo. See the [main README](https://github.com/clawmasons/mason/blob/main/README.md) for full documentation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mason/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,aAAa,EACb,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mason/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,EACL,WAAW,GAKZ,MAAM,cAAc,CAAC;AAEtB,WAAW;AACX,OAAO,EACL,aAAa,GAEd,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mason ROLE.md Proposer — generates draft ROLE.md from scanner results.
|
|
3
|
+
*
|
|
4
|
+
* Takes a ScanResult and produces a valid ROLE.md string with:
|
|
5
|
+
* - YAML frontmatter populated from discovered configuration
|
|
6
|
+
* - Least-privilege MCP server permissions (empty allow lists)
|
|
7
|
+
* - Credentials extracted from MCP server env keys
|
|
8
|
+
* - Default container ignore paths
|
|
9
|
+
* - System prompt as markdown body
|
|
10
|
+
*/
|
|
11
|
+
import type { ScanResult } from "./scanner.js";
|
|
12
|
+
export interface ProposeOptions {
|
|
13
|
+
/** Role name override (defaults to project directory name) */
|
|
14
|
+
roleName?: string;
|
|
15
|
+
/** Role description override (defaults to a placeholder) */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Target dialect for the ROLE.md (defaults to "claude-code-agent") */
|
|
18
|
+
targetDialect?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate a draft ROLE.md from scanner results.
|
|
22
|
+
*
|
|
23
|
+
* The generated ROLE.md:
|
|
24
|
+
* - Uses the Claude Code dialect by default
|
|
25
|
+
* - Maps discovered skills, commands, and MCP servers to frontmatter fields
|
|
26
|
+
* - Applies least-privilege permissions (empty tools.allow lists)
|
|
27
|
+
* - Extracts credentials from MCP server env keys with empty values
|
|
28
|
+
* - Includes default container ignore paths
|
|
29
|
+
* - Uses the discovered system prompt as the markdown body
|
|
30
|
+
*
|
|
31
|
+
* @param scanResult - Output from scanProject()
|
|
32
|
+
* @param options - Optional overrides for role name, description, dialect
|
|
33
|
+
* @returns Valid ROLE.md string
|
|
34
|
+
*/
|
|
35
|
+
export declare function proposeRoleMd(scanResult: ScanResult, options?: ProposeOptions): string;
|
|
36
|
+
//# sourceMappingURL=proposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposer.d.ts","sourceRoot":"","sources":["../../src/mason/proposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAuER"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mason ROLE.md Proposer — generates draft ROLE.md from scanner results.
|
|
3
|
+
*
|
|
4
|
+
* Takes a ScanResult and produces a valid ROLE.md string with:
|
|
5
|
+
* - YAML frontmatter populated from discovered configuration
|
|
6
|
+
* - Least-privilege MCP server permissions (empty allow lists)
|
|
7
|
+
* - Credentials extracted from MCP server env keys
|
|
8
|
+
* - Default container ignore paths
|
|
9
|
+
* - System prompt as markdown body
|
|
10
|
+
*/
|
|
11
|
+
import { dump as yamlDump } from "js-yaml";
|
|
12
|
+
import { basename } from "node:path";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Proposer
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Generate a draft ROLE.md from scanner results.
|
|
18
|
+
*
|
|
19
|
+
* The generated ROLE.md:
|
|
20
|
+
* - Uses the Claude Code dialect by default
|
|
21
|
+
* - Maps discovered skills, commands, and MCP servers to frontmatter fields
|
|
22
|
+
* - Applies least-privilege permissions (empty tools.allow lists)
|
|
23
|
+
* - Extracts credentials from MCP server env keys with empty values
|
|
24
|
+
* - Includes default container ignore paths
|
|
25
|
+
* - Uses the discovered system prompt as the markdown body
|
|
26
|
+
*
|
|
27
|
+
* @param scanResult - Output from scanProject()
|
|
28
|
+
* @param options - Optional overrides for role name, description, dialect
|
|
29
|
+
* @returns Valid ROLE.md string
|
|
30
|
+
*/
|
|
31
|
+
export function proposeRoleMd(scanResult, options) {
|
|
32
|
+
const roleName = options?.roleName ?? basename(scanResult.projectDir);
|
|
33
|
+
const description = options?.description ?? `Role for ${roleName} project`;
|
|
34
|
+
// Build frontmatter object
|
|
35
|
+
const frontmatter = {
|
|
36
|
+
name: roleName,
|
|
37
|
+
description,
|
|
38
|
+
};
|
|
39
|
+
// Commands (Claude dialect field name)
|
|
40
|
+
if (scanResult.commands.length > 0) {
|
|
41
|
+
frontmatter.commands = scanResult.commands.map((c) => c.name);
|
|
42
|
+
}
|
|
43
|
+
// Skills
|
|
44
|
+
if (scanResult.skills.length > 0) {
|
|
45
|
+
frontmatter.skills = scanResult.skills.map((s) => s.name);
|
|
46
|
+
}
|
|
47
|
+
// MCP Servers with least-privilege permissions
|
|
48
|
+
if (scanResult.mcpServers.length > 0) {
|
|
49
|
+
frontmatter.mcp_servers = scanResult.mcpServers.map((server) => {
|
|
50
|
+
const entry = {
|
|
51
|
+
name: server.name,
|
|
52
|
+
tools: {
|
|
53
|
+
allow: [], // Least-privilege: no tools granted by default
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
if (server.command) {
|
|
57
|
+
entry.command = server.command;
|
|
58
|
+
}
|
|
59
|
+
if (server.args && server.args.length > 0) {
|
|
60
|
+
entry.args = server.args;
|
|
61
|
+
}
|
|
62
|
+
if (server.url) {
|
|
63
|
+
entry.url = server.url;
|
|
64
|
+
}
|
|
65
|
+
return entry;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Container requirements with default ignore paths
|
|
69
|
+
frontmatter.container = {
|
|
70
|
+
ignore: {
|
|
71
|
+
paths: [".mason/", ".claude/", ".env"],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
// Governance — extract credentials from MCP server env
|
|
75
|
+
const credentials = extractCredentials(scanResult);
|
|
76
|
+
if (credentials.length > 0) {
|
|
77
|
+
frontmatter.credentials = credentials;
|
|
78
|
+
}
|
|
79
|
+
// Generate YAML frontmatter
|
|
80
|
+
const yamlStr = yamlDump(frontmatter, {
|
|
81
|
+
lineWidth: -1,
|
|
82
|
+
noRefs: true,
|
|
83
|
+
quotingType: "'",
|
|
84
|
+
forceQuotes: false,
|
|
85
|
+
}).trim();
|
|
86
|
+
// Build markdown body
|
|
87
|
+
const body = scanResult.systemPrompt ?? generatePlaceholderPrompt(roleName);
|
|
88
|
+
return `---\n${yamlStr}\n---\n\n${body}\n`;
|
|
89
|
+
}
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Helpers
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
/**
|
|
94
|
+
* Extract credential names from MCP server env configurations.
|
|
95
|
+
* Keys with empty string values are treated as credential references
|
|
96
|
+
* (the actual values are provided at runtime by the credential service).
|
|
97
|
+
*/
|
|
98
|
+
function extractCredentials(scanResult) {
|
|
99
|
+
const credentialSet = new Set();
|
|
100
|
+
for (const server of scanResult.mcpServers) {
|
|
101
|
+
if (!server.env)
|
|
102
|
+
continue;
|
|
103
|
+
for (const [key, value] of Object.entries(server.env)) {
|
|
104
|
+
// Empty string values indicate credential placeholders
|
|
105
|
+
if (value === "") {
|
|
106
|
+
credentialSet.add(key);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return [...credentialSet].sort();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Generate a minimal placeholder system prompt.
|
|
114
|
+
*/
|
|
115
|
+
function generatePlaceholderPrompt(roleName) {
|
|
116
|
+
return `You are an AI assistant operating in the ${roleName} role.
|
|
117
|
+
|
|
118
|
+
Review and customize this system prompt to describe the specific behavior,
|
|
119
|
+
constraints, and capabilities for this role.`;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=proposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposer.js","sourceRoot":"","sources":["../../src/mason/proposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAgBrC,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAsB,EACtB,OAAwB;IAExB,MAAM,QAAQ,GACZ,OAAO,EAAE,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,WAAW,GACf,OAAO,EAAE,WAAW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QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAC,QAAgB;IACjD,OAAO,4CAA4C,QAAQ;;;6CAGhB,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mason Project Scanner — discovers existing project configuration.
|
|
3
|
+
*
|
|
4
|
+
* Scans a project directory for:
|
|
5
|
+
* - Skills in `.<agent>/skills/` directories
|
|
6
|
+
* - Commands in `.<agent>/commands/` directories
|
|
7
|
+
* - MCP server configurations from agent settings files
|
|
8
|
+
* - System prompts from CLAUDE.md, AGENTS.md
|
|
9
|
+
*
|
|
10
|
+
* Uses the dialect registry to automatically scan all registered agent directories.
|
|
11
|
+
*/
|
|
12
|
+
export interface DiscoveredSkill {
|
|
13
|
+
/** Skill name (derived from directory name) */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Absolute path to the skill directory */
|
|
16
|
+
path: string;
|
|
17
|
+
/** Dialect that owns this skill (e.g., "claude-code-agent") */
|
|
18
|
+
dialect: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DiscoveredCommand {
|
|
21
|
+
/** Command name (derived from file name without extension, may include subdirectory) */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Absolute path to the command file */
|
|
24
|
+
path: string;
|
|
25
|
+
/** Dialect that owns this command */
|
|
26
|
+
dialect: string;
|
|
27
|
+
}
|
|
28
|
+
export interface DiscoveredMcpServer {
|
|
29
|
+
/** Server name (key from settings) */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Command to run the server */
|
|
32
|
+
command?: string;
|
|
33
|
+
/** Arguments for the command */
|
|
34
|
+
args?: string[];
|
|
35
|
+
/** URL for remote servers */
|
|
36
|
+
url?: string;
|
|
37
|
+
/** Environment variables */
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
/** Dialect that owns this configuration */
|
|
40
|
+
dialect: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ScanResult {
|
|
43
|
+
/** Absolute path to the scanned project directory */
|
|
44
|
+
projectDir: string;
|
|
45
|
+
/** Discovered skills across all dialect directories */
|
|
46
|
+
skills: DiscoveredSkill[];
|
|
47
|
+
/** Discovered commands/slash-commands */
|
|
48
|
+
commands: DiscoveredCommand[];
|
|
49
|
+
/** Discovered MCP server configurations */
|
|
50
|
+
mcpServers: DiscoveredMcpServer[];
|
|
51
|
+
/** System prompt content from CLAUDE.md or AGENTS.md */
|
|
52
|
+
systemPrompt: string | undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Scan a project directory for existing agent configuration.
|
|
56
|
+
*
|
|
57
|
+
* Iterates over all registered dialects, scanning each agent directory for
|
|
58
|
+
* skills, commands, and MCP server configurations.
|
|
59
|
+
*
|
|
60
|
+
* @param projectDir - Absolute path to the project root
|
|
61
|
+
* @returns Scan results with all discovered configuration
|
|
62
|
+
*/
|
|
63
|
+
export declare function scanProject(projectDir: string): Promise<ScanResult>;
|
|
64
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/mason/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,WAAW,eAAe;IAC9B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,2CAA2C;IAC3C,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,wDAAwD;IACxD,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAMD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAqCzE"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mason Project Scanner — discovers existing project configuration.
|
|
3
|
+
*
|
|
4
|
+
* Scans a project directory for:
|
|
5
|
+
* - Skills in `.<agent>/skills/` directories
|
|
6
|
+
* - Commands in `.<agent>/commands/` directories
|
|
7
|
+
* - MCP server configurations from agent settings files
|
|
8
|
+
* - System prompts from CLAUDE.md, AGENTS.md
|
|
9
|
+
*
|
|
10
|
+
* Uses the dialect registry to automatically scan all registered agent directories.
|
|
11
|
+
*/
|
|
12
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
13
|
+
import { join, relative } from "node:path";
|
|
14
|
+
import { getAllDialects } from "../role/dialect-registry.js";
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Main Scanner
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Scan a project directory for existing agent configuration.
|
|
20
|
+
*
|
|
21
|
+
* Iterates over all registered dialects, scanning each agent directory for
|
|
22
|
+
* skills, commands, and MCP server configurations.
|
|
23
|
+
*
|
|
24
|
+
* @param projectDir - Absolute path to the project root
|
|
25
|
+
* @returns Scan results with all discovered configuration
|
|
26
|
+
*/
|
|
27
|
+
export async function scanProject(projectDir) {
|
|
28
|
+
const dialects = getAllDialects();
|
|
29
|
+
const skills = [];
|
|
30
|
+
const commands = [];
|
|
31
|
+
const mcpServers = [];
|
|
32
|
+
for (const dialect of dialects) {
|
|
33
|
+
const agentDir = join(projectDir, `.${dialect.directory}`);
|
|
34
|
+
if (!(await dirExists(agentDir))) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// Scan skills
|
|
38
|
+
const discoveredSkills = await scanSkills(agentDir, dialect);
|
|
39
|
+
skills.push(...discoveredSkills);
|
|
40
|
+
// Scan commands
|
|
41
|
+
const discoveredCommands = await scanCommands(agentDir, dialect);
|
|
42
|
+
commands.push(...discoveredCommands);
|
|
43
|
+
// Scan MCP server configs
|
|
44
|
+
const discoveredServers = await scanMcpServers(agentDir, dialect);
|
|
45
|
+
mcpServers.push(...discoveredServers);
|
|
46
|
+
}
|
|
47
|
+
// Read system prompt
|
|
48
|
+
const systemPrompt = await readSystemPrompt(projectDir);
|
|
49
|
+
return {
|
|
50
|
+
projectDir,
|
|
51
|
+
skills,
|
|
52
|
+
commands,
|
|
53
|
+
mcpServers,
|
|
54
|
+
systemPrompt,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// Skills Scanner
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
async function scanSkills(agentDir, dialect) {
|
|
61
|
+
const skillsDir = join(agentDir, "skills");
|
|
62
|
+
if (!(await dirExists(skillsDir))) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const results = [];
|
|
66
|
+
const entries = await readdir(skillsDir, { withFileTypes: true });
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (!entry.isDirectory())
|
|
69
|
+
continue;
|
|
70
|
+
const skillDir = join(skillsDir, entry.name);
|
|
71
|
+
const skillMdPath = join(skillDir, "SKILL.md");
|
|
72
|
+
if (await fileExists(skillMdPath)) {
|
|
73
|
+
results.push({
|
|
74
|
+
name: entry.name,
|
|
75
|
+
path: skillDir,
|
|
76
|
+
dialect: dialect.name,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return results;
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Commands Scanner
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
async function scanCommands(agentDir, dialect) {
|
|
86
|
+
const commandsDir = join(agentDir, "commands");
|
|
87
|
+
if (!(await dirExists(commandsDir))) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
const results = [];
|
|
91
|
+
await walkCommands(commandsDir, commandsDir, dialect, results);
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
async function walkCommands(baseDir, currentDir, dialect, results) {
|
|
95
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
96
|
+
for (const entry of entries) {
|
|
97
|
+
const fullPath = join(currentDir, entry.name);
|
|
98
|
+
if (entry.isDirectory()) {
|
|
99
|
+
await walkCommands(baseDir, fullPath, dialect, results);
|
|
100
|
+
}
|
|
101
|
+
else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
102
|
+
const relPath = relative(baseDir, fullPath);
|
|
103
|
+
// Remove .md extension for command name
|
|
104
|
+
const name = relPath.replace(/\.md$/, "");
|
|
105
|
+
results.push({
|
|
106
|
+
name,
|
|
107
|
+
path: fullPath,
|
|
108
|
+
dialect: dialect.name,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// MCP Server Scanner
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
async function scanMcpServers(agentDir, dialect) {
|
|
117
|
+
// Read settings files (base + local)
|
|
118
|
+
const baseSettings = await readJsonFile(join(agentDir, "settings.json"));
|
|
119
|
+
const localSettings = await readJsonFile(join(agentDir, "settings.local.json"));
|
|
120
|
+
// Merge: local overrides base
|
|
121
|
+
const mergedServers = {};
|
|
122
|
+
if (baseSettings?.mcpServers && typeof baseSettings.mcpServers === "object") {
|
|
123
|
+
Object.assign(mergedServers, baseSettings.mcpServers);
|
|
124
|
+
}
|
|
125
|
+
if (localSettings?.mcpServers && typeof localSettings.mcpServers === "object") {
|
|
126
|
+
Object.assign(mergedServers, localSettings.mcpServers);
|
|
127
|
+
}
|
|
128
|
+
const results = [];
|
|
129
|
+
for (const [name, config] of Object.entries(mergedServers)) {
|
|
130
|
+
if (typeof config !== "object" || config === null)
|
|
131
|
+
continue;
|
|
132
|
+
const serverConfig = config;
|
|
133
|
+
const server = {
|
|
134
|
+
name,
|
|
135
|
+
dialect: dialect.name,
|
|
136
|
+
};
|
|
137
|
+
if (typeof serverConfig.command === "string") {
|
|
138
|
+
server.command = serverConfig.command;
|
|
139
|
+
}
|
|
140
|
+
if (Array.isArray(serverConfig.args)) {
|
|
141
|
+
server.args = serverConfig.args.map(String);
|
|
142
|
+
}
|
|
143
|
+
if (typeof serverConfig.url === "string") {
|
|
144
|
+
server.url = serverConfig.url;
|
|
145
|
+
}
|
|
146
|
+
if (typeof serverConfig.env === "object" &&
|
|
147
|
+
serverConfig.env !== null &&
|
|
148
|
+
!Array.isArray(serverConfig.env)) {
|
|
149
|
+
server.env = serverConfig.env;
|
|
150
|
+
}
|
|
151
|
+
results.push(server);
|
|
152
|
+
}
|
|
153
|
+
return results;
|
|
154
|
+
}
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// System Prompt Reader
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
async function readSystemPrompt(projectDir) {
|
|
159
|
+
// Check in priority order
|
|
160
|
+
const candidates = [
|
|
161
|
+
join(projectDir, "CLAUDE.md"),
|
|
162
|
+
join(projectDir, "AGENTS.md"),
|
|
163
|
+
join(projectDir, ".claude", "AGENTS.md"),
|
|
164
|
+
];
|
|
165
|
+
for (const candidate of candidates) {
|
|
166
|
+
if (await fileExists(candidate)) {
|
|
167
|
+
try {
|
|
168
|
+
const content = await readFile(candidate, "utf-8");
|
|
169
|
+
return content.trim();
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// Continue to next candidate
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
// Helpers
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
async function dirExists(path) {
|
|
182
|
+
try {
|
|
183
|
+
const s = await stat(path);
|
|
184
|
+
return s.isDirectory();
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function fileExists(path) {
|
|
191
|
+
try {
|
|
192
|
+
const s = await stat(path);
|
|
193
|
+
return s.isFile();
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function readJsonFile(path) {
|
|
200
|
+
try {
|
|
201
|
+
const content = await readFile(path, "utf-8");
|
|
202
|
+
const parsed = JSON.parse(content);
|
|
203
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
204
|
+
return parsed;
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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3B,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E,OAAO,MAAiC,CAAC;QAC3C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/role/adapter.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class AdapterError extends Error {
|
|
|
21
21
|
* Convert a Role into a ResolvedAgent that existing materializers accept.
|
|
22
22
|
*
|
|
23
23
|
* @param role - A validated Role from the ROLE_TYPES pipeline
|
|
24
|
-
* @param agentType - The target agent dialect name (e.g., "claude-code", "codex", "aider")
|
|
24
|
+
* @param agentType - The target agent dialect name (e.g., "claude-code-agent", "codex", "aider")
|
|
25
25
|
* @returns A ResolvedAgent suitable for passing to any RuntimeMaterializer
|
|
26
26
|
* @throws AdapterError if agentType does not match a registered dialect
|
|
27
27
|
*/
|
package/dist/role/adapter.js
CHANGED
|
@@ -23,7 +23,7 @@ export class AdapterError extends Error {
|
|
|
23
23
|
* Convert a Role into a ResolvedAgent that existing materializers accept.
|
|
24
24
|
*
|
|
25
25
|
* @param role - A validated Role from the ROLE_TYPES pipeline
|
|
26
|
-
* @param agentType - The target agent dialect name (e.g., "claude-code", "codex", "aider")
|
|
26
|
+
* @param agentType - The target agent dialect name (e.g., "claude-code-agent", "codex", "aider")
|
|
27
27
|
* @returns A ResolvedAgent suitable for passing to any RuntimeMaterializer
|
|
28
28
|
* @throws AdapterError if agentType does not match a registered dialect
|
|
29
29
|
*/
|
|
@@ -31,7 +31,7 @@ export function adaptRoleToResolvedAgent(role, agentType) {
|
|
|
31
31
|
// Validate agent type against dialect registry
|
|
32
32
|
const dialect = getDialect(agentType);
|
|
33
33
|
if (!dialect) {
|
|
34
|
-
throw new AdapterError(`Unknown agent type "${agentType}". Must be a registered dialect (e.g., "claude-code", "codex", "aider", "mcp-agent").`);
|
|
34
|
+
throw new AdapterError(`Unknown agent type "${agentType}". Must be a registered dialect (e.g., "claude-code-agent", "codex", "aider", "mcp-agent").`);
|
|
35
35
|
}
|
|
36
36
|
const name = role.metadata.name;
|
|
37
37
|
const version = role.metadata.version ?? "0.0.0";
|
package/dist/role/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/role/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAeH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAU,EACV,SAAiB;IAEjB,+CAA+C;IAC/C,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC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E;KACb,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,GAAc;IAC9B,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,OAAO;QACnC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS;QACzC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpC,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAe;IACjC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,KAAK,CAAC,IAAI;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialect Registry — maps agent directories to field name translations.
|
|
3
|
+
*
|
|
4
|
+
* Each supported agent runtime uses its own vocabulary in ROLE.md frontmatter.
|
|
5
|
+
* The registry normalizes these to generic ROLE_TYPES field names:
|
|
6
|
+
* - tasks (Claude: commands, Codex: instructions, Aider: conventions)
|
|
7
|
+
* - apps (all: mcp_servers)
|
|
8
|
+
* - skills (all: skills)
|
|
9
|
+
*
|
|
10
|
+
* New runtimes are registered by calling `registerDialect()`.
|
|
11
|
+
*/
|
|
12
|
+
export interface DialectFieldMapping {
|
|
13
|
+
/** Agent-specific field name for tasks (e.g., "commands") */
|
|
14
|
+
tasks: string;
|
|
15
|
+
/** Agent-specific field name for apps (e.g., "mcp_servers") */
|
|
16
|
+
apps: string;
|
|
17
|
+
/** Agent-specific field name for skills (e.g., "skills") */
|
|
18
|
+
skills: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DialectEntry {
|
|
21
|
+
/** Dialect identifier (e.g., "claude-code-agent") */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Agent directory name without dot (e.g., "claude") */
|
|
24
|
+
directory: string;
|
|
25
|
+
/** Mapping from generic field names to agent-specific field names */
|
|
26
|
+
fieldMapping: DialectFieldMapping;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a new dialect entry. Overwrites if the same name already exists.
|
|
30
|
+
*/
|
|
31
|
+
export declare function registerDialect(entry: DialectEntry): void;
|
|
32
|
+
/**
|
|
33
|
+
* Look up a dialect by its name (e.g., "claude-code-agent").
|
|
34
|
+
*/
|
|
35
|
+
export declare function getDialect(name: string): DialectEntry | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Look up a dialect by its directory name (e.g., "claude").
|
|
38
|
+
* The directory should not include the leading dot.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDialectByDirectory(directory: string): DialectEntry | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get all registered dialect entries.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAllDialects(): DialectEntry[];
|
|
45
|
+
/**
|
|
46
|
+
* Get all known agent directory names (without dot prefix).
|
|
47
|
+
*/
|
|
48
|
+
export declare function getKnownDirectories(): string[];
|
|
49
|
+
//# sourceMappingURL=dialect-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect-registry.d.ts","sourceRoot":"","sources":["../../src/role/dialect-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAOD;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAGzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEjE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAIjF;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,YAAY,EAAE,CAE/C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
|