@codemieai/code 0.0.33 → 0.0.34
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 +73 -7
- package/bin/codemie-opencode.js +11 -0
- package/dist/agents/codemie-code/agent.d.ts +17 -1
- package/dist/agents/codemie-code/agent.d.ts.map +1 -1
- package/dist/agents/codemie-code/agent.js +62 -3
- package/dist/agents/codemie-code/agent.js.map +1 -1
- package/dist/agents/codemie-code/index.d.ts +1 -0
- package/dist/agents/codemie-code/index.d.ts.map +1 -1
- package/dist/agents/codemie-code/index.js +28 -2
- package/dist/agents/codemie-code/index.js.map +1 -1
- package/dist/agents/codemie-code/prompts.d.ts +12 -3
- package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
- package/dist/agents/codemie-code/prompts.js +25 -5
- package/dist/agents/codemie-code/prompts.js.map +1 -1
- package/dist/agents/codemie-code/types.d.ts +3 -0
- package/dist/agents/codemie-code/types.d.ts.map +1 -1
- package/dist/agents/codemie-code/types.js.map +1 -1
- package/dist/agents/core/AgentCLI.d.ts.map +1 -1
- package/dist/agents/core/AgentCLI.js +3 -1
- package/dist/agents/core/AgentCLI.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +33 -0
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/session/BaseSessionAdapter.d.ts +25 -0
- package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
- package/dist/agents/core/session/discovery-types.d.ts +53 -0
- package/dist/agents/core/session/discovery-types.d.ts.map +1 -0
- package/dist/agents/core/session/discovery-types.js +8 -0
- package/dist/agents/core/session/discovery-types.js.map +1 -0
- package/dist/agents/core/types.d.ts +45 -0
- package/dist/agents/core/types.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts +44 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.js +214 -0
- package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
- package/dist/agents/plugins/claude/plugin/README.md +40 -2
- package/dist/agents/plugins/claude/plugin/claude-templates/README.md +5 -5
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/CLAUDE.md.template +177 -436
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/code-review-agent-template.md.template +49 -82
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/refactor-cleaner-agent.md.template +337 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/solution-architect-agent.md.template +129 -419
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/unit-tester-agent.md.template +146 -693
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/api/api-patterns.md.template +110 -138
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/architecture.md.template +197 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/data/database-patterns.md.template +171 -91
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/development/development-practices.md.template +219 -131
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/security/security-practices.md.template +223 -98
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/standards/code-quality.md.template +131 -95
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/testing/testing-patterns.md.template +247 -75
- package/dist/agents/plugins/claude/plugin/commands/README.md +133 -0
- package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +336 -544
- package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +232 -503
- package/dist/agents/plugins/claude/plugin/commands/memory-add.md +311 -30
- package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +218 -39
- package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/gemini/gemini.plugin.js +0 -3
- package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
- package/dist/agents/plugins/opencode/index.d.ts +8 -0
- package/dist/agents/plugins/opencode/index.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/index.js +12 -0
- package/dist/agents/plugins/opencode/index.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts +207 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js +59 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +65 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js +184 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts +62 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.js +148 -0
- package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts +35 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js +338 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts +77 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.js +424 -0
- package/dist/agents/plugins/opencode/opencode.session.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts +25 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js +96 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts +30 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js +116 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +102 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +584 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -0
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +2 -0
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts +5 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.js +29 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +86 -7
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/opencode-metrics.d.ts +13 -0
- package/dist/cli/commands/opencode-metrics.d.ts.map +1 -0
- package/dist/cli/commands/opencode-metrics.js +200 -0
- package/dist/cli/commands/opencode-metrics.js.map +1 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +113 -0
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/skill.d.ts +6 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +196 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +34 -6
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/migrations/003-remove-hooks-node.migration.d.ts +22 -0
- package/dist/migrations/003-remove-hooks-node.migration.d.ts.map +1 -0
- package/dist/migrations/003-remove-hooks-node.migration.js +103 -0
- package/dist/migrations/003-remove-hooks-node.migration.js.map +1 -0
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/providers/plugins/sso/sso.http-client.js +2 -2
- package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.js +14 -10
- package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
- package/dist/skills/core/SkillDiscovery.d.ts +83 -0
- package/dist/skills/core/SkillDiscovery.d.ts.map +1 -0
- package/dist/skills/core/SkillDiscovery.js +237 -0
- package/dist/skills/core/SkillDiscovery.js.map +1 -0
- package/dist/skills/core/SkillManager.d.ts +86 -0
- package/dist/skills/core/SkillManager.d.ts.map +1 -0
- package/dist/skills/core/SkillManager.js +155 -0
- package/dist/skills/core/SkillManager.js.map +1 -0
- package/dist/skills/core/types.d.ts +120 -0
- package/dist/skills/core/types.d.ts.map +1 -0
- package/dist/skills/core/types.js +20 -0
- package/dist/skills/core/types.js.map +1 -0
- package/dist/skills/index.d.ts +12 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +12 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/utils/content-loader.d.ts +25 -0
- package/dist/skills/utils/content-loader.d.ts.map +1 -0
- package/dist/skills/utils/content-loader.js +161 -0
- package/dist/skills/utils/content-loader.js.map +1 -0
- package/dist/skills/utils/frontmatter.d.ts +60 -0
- package/dist/skills/utils/frontmatter.d.ts.map +1 -0
- package/dist/skills/utils/frontmatter.js +114 -0
- package/dist/skills/utils/frontmatter.js.map +1 -0
- package/dist/skills/utils/pattern-matcher.d.ts +60 -0
- package/dist/skills/utils/pattern-matcher.d.ts.map +1 -0
- package/dist/skills/utils/pattern-matcher.js +97 -0
- package/dist/skills/utils/pattern-matcher.js.map +1 -0
- package/dist/utils/installation-detector.d.ts +22 -0
- package/dist/utils/installation-detector.d.ts.map +1 -0
- package/dist/utils/installation-detector.js +49 -0
- package/dist/utils/installation-detector.js.map +1 -0
- package/dist/utils/native-installer.d.ts +49 -0
- package/dist/utils/native-installer.d.ts.map +1 -0
- package/dist/utils/native-installer.js +194 -0
- package/dist/utils/native-installer.js.map +1 -0
- package/dist/utils/version-utils.d.ts +50 -0
- package/dist/utils/version-utils.d.ts.map +1 -0
- package/dist/utils/version-utils.js +92 -0
- package/dist/utils/version-utils.js.map +1 -0
- package/package.json +5 -2
- package/scripts/copy-mr-skill-to-global.ts +252 -0
- package/scripts/demo-hooks.sh +125 -0
- package/scripts/test-hooks.sh +196 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/INDEX.md +0 -205
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/TEMPLATE_SIZES.md +0 -74
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/layered-architecture.md.template +0 -143
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/project-structure.md.template +0 -127
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { SkillDiscovery } from './SkillDiscovery.js';
|
|
2
|
+
import { loadSkillWithInventory } from '../utils/content-loader.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Skill manager singleton
|
|
6
|
+
*
|
|
7
|
+
* Provides high-level API for skill management:
|
|
8
|
+
* - Discovery and caching
|
|
9
|
+
* - Agent-aware filtering
|
|
10
|
+
* - Validation
|
|
11
|
+
* - Cache management
|
|
12
|
+
*/
|
|
13
|
+
export class SkillManager {
|
|
14
|
+
static instance;
|
|
15
|
+
discovery;
|
|
16
|
+
/**
|
|
17
|
+
* Private constructor (singleton pattern)
|
|
18
|
+
*/
|
|
19
|
+
constructor() {
|
|
20
|
+
this.discovery = new SkillDiscovery();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get singleton instance
|
|
24
|
+
*/
|
|
25
|
+
static getInstance() {
|
|
26
|
+
if (!SkillManager.instance) {
|
|
27
|
+
SkillManager.instance = new SkillManager();
|
|
28
|
+
}
|
|
29
|
+
return SkillManager.instance;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get skills for a specific agent
|
|
33
|
+
*
|
|
34
|
+
* @param agentName - Name of the agent (e.g., 'codemie-code')
|
|
35
|
+
* @param options - Additional discovery options
|
|
36
|
+
* @returns Array of skills compatible with the agent
|
|
37
|
+
*/
|
|
38
|
+
async getSkillsForAgent(agentName, options = {}) {
|
|
39
|
+
return this.discovery.discoverSkills({
|
|
40
|
+
...options,
|
|
41
|
+
agentName,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get a specific skill by name
|
|
46
|
+
*
|
|
47
|
+
* @param name - Skill name
|
|
48
|
+
* @param options - Discovery options
|
|
49
|
+
* @returns Skill if found, undefined otherwise
|
|
50
|
+
*/
|
|
51
|
+
async getSkillByName(name, options = {}) {
|
|
52
|
+
const skills = await this.discovery.discoverSkills(options);
|
|
53
|
+
return skills.find((skill) => skill.metadata.name === name);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* List all discovered skills
|
|
57
|
+
*
|
|
58
|
+
* @param options - Discovery options
|
|
59
|
+
* @returns Array of all skills
|
|
60
|
+
*/
|
|
61
|
+
async listSkills(options = {}) {
|
|
62
|
+
return this.discovery.discoverSkills(options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get multiple skills by names with file inventory
|
|
66
|
+
*
|
|
67
|
+
* Used for pattern-based invocation when /skill-name patterns are detected.
|
|
68
|
+
* Loads skill content and builds file inventory for each requested skill.
|
|
69
|
+
*
|
|
70
|
+
* @param names - Array of skill names to load
|
|
71
|
+
* @param options - Discovery options
|
|
72
|
+
* @returns Array of skills with inventory (only found skills)
|
|
73
|
+
*/
|
|
74
|
+
async getSkillsByNames(names, options = {}) {
|
|
75
|
+
const results = [];
|
|
76
|
+
// Discover all skills (uses cache)
|
|
77
|
+
const allSkills = await this.discovery.discoverSkills(options);
|
|
78
|
+
// Find and load each requested skill
|
|
79
|
+
for (const name of names) {
|
|
80
|
+
const skill = allSkills.find((s) => s.metadata.name === name);
|
|
81
|
+
if (skill) {
|
|
82
|
+
try {
|
|
83
|
+
const withInventory = await loadSkillWithInventory(skill);
|
|
84
|
+
results.push(withInventory);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
logger.warn(`Failed to load inventory for skill '${name}':`, error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
logger.debug(`Skill '${name}' not found during pattern invocation`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Reload skills (clear cache and force re-discovery)
|
|
98
|
+
*
|
|
99
|
+
* Call this after adding/removing/modifying skill files
|
|
100
|
+
*/
|
|
101
|
+
reload() {
|
|
102
|
+
this.discovery.clearCache();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Validate all skill files
|
|
106
|
+
*
|
|
107
|
+
* Attempts to discover and parse all skills, returning validation results
|
|
108
|
+
*
|
|
109
|
+
* @param options - Discovery options
|
|
110
|
+
* @returns Validation results for all skills
|
|
111
|
+
*/
|
|
112
|
+
async validateAll(options = {}) {
|
|
113
|
+
try {
|
|
114
|
+
// Force reload to ensure fresh validation
|
|
115
|
+
const skills = await this.discovery.discoverSkills({
|
|
116
|
+
...options,
|
|
117
|
+
forceReload: true,
|
|
118
|
+
});
|
|
119
|
+
// All discovered skills are valid (parsing errors are filtered out in discovery)
|
|
120
|
+
const valid = skills;
|
|
121
|
+
// For now, we don't track invalid skills (they're silently filtered)
|
|
122
|
+
// Future enhancement: return parse errors from discovery
|
|
123
|
+
const invalid = [];
|
|
124
|
+
return { valid, invalid };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
// Discovery failed entirely
|
|
128
|
+
return {
|
|
129
|
+
valid: [],
|
|
130
|
+
invalid: [
|
|
131
|
+
{
|
|
132
|
+
valid: false,
|
|
133
|
+
filePath: 'unknown',
|
|
134
|
+
errors: [
|
|
135
|
+
error instanceof Error ? error.message : String(error),
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get cache statistics (for debugging)
|
|
144
|
+
*/
|
|
145
|
+
getCacheStats() {
|
|
146
|
+
return this.discovery.getCacheStats();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Reset singleton instance (for testing)
|
|
150
|
+
*/
|
|
151
|
+
static resetInstance() {
|
|
152
|
+
SkillManager.instance = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=SkillManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillManager.js","sourceRoot":"","sources":["../../../src/skills/core/SkillManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,CAAe;IAC9B,SAAS,CAAiB;IAElC;;OAEG;IACH;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,iBAAi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z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for skill metadata (frontmatter)
|
|
4
|
+
*/
|
|
5
|
+
export declare const SkillMetadataSchema: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
description: z.ZodString;
|
|
8
|
+
version: z.ZodOptional<z.ZodString>;
|
|
9
|
+
author: z.ZodOptional<z.ZodString>;
|
|
10
|
+
license: z.ZodOptional<z.ZodString>;
|
|
11
|
+
modes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
compatibility: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
minVersion: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
priority: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* TypeScript interface for skill metadata
|
|
20
|
+
*/
|
|
21
|
+
export type SkillMetadata = z.infer<typeof SkillMetadataSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Source type for a skill
|
|
24
|
+
*/
|
|
25
|
+
export type SkillSource = 'global' | 'project' | 'mode-specific';
|
|
26
|
+
/**
|
|
27
|
+
* Complete skill with metadata, content, and location info
|
|
28
|
+
*/
|
|
29
|
+
export interface Skill {
|
|
30
|
+
/** Parsed and validated metadata from YAML frontmatter */
|
|
31
|
+
metadata: SkillMetadata;
|
|
32
|
+
/** Markdown content (body after frontmatter) */
|
|
33
|
+
content: string;
|
|
34
|
+
/** Absolute path to the SKILL.md file */
|
|
35
|
+
filePath: string;
|
|
36
|
+
/** Where this skill was discovered from */
|
|
37
|
+
source: SkillSource;
|
|
38
|
+
/** Computed priority (source-based + metadata priority) */
|
|
39
|
+
computedPriority: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of parsing a skill file
|
|
43
|
+
*/
|
|
44
|
+
export interface SkillParseResult {
|
|
45
|
+
skill?: Skill;
|
|
46
|
+
error?: {
|
|
47
|
+
filePath: string;
|
|
48
|
+
message: string;
|
|
49
|
+
cause?: unknown;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for skill discovery
|
|
54
|
+
*/
|
|
55
|
+
export interface SkillDiscoveryOptions {
|
|
56
|
+
/** Working directory (for project-level skills) */
|
|
57
|
+
cwd?: string;
|
|
58
|
+
/** Filter by mode (e.g., 'code', 'architect') */
|
|
59
|
+
mode?: string;
|
|
60
|
+
/** Filter by agent name */
|
|
61
|
+
agentName?: string;
|
|
62
|
+
/** Force cache reload */
|
|
63
|
+
forceReload?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validation result for a skill
|
|
67
|
+
*/
|
|
68
|
+
export interface SkillValidationResult {
|
|
69
|
+
valid: boolean;
|
|
70
|
+
filePath: string;
|
|
71
|
+
skillName?: string;
|
|
72
|
+
errors: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for skills in agent config
|
|
76
|
+
*/
|
|
77
|
+
export interface SkillsConfig {
|
|
78
|
+
/** Enable/disable skill loading */
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
/** Mode for mode-specific skills */
|
|
81
|
+
mode?: string;
|
|
82
|
+
/** Auto-reload on file changes (future feature) */
|
|
83
|
+
autoReload?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Skill pattern detected in a message
|
|
87
|
+
*/
|
|
88
|
+
export interface SkillPattern {
|
|
89
|
+
/** Skill name (e.g., 'mr', 'commit') */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Position in message where pattern starts */
|
|
92
|
+
position: number;
|
|
93
|
+
/** Optional arguments after skill name */
|
|
94
|
+
args?: string;
|
|
95
|
+
/** Full matched pattern (e.g., '/mr', '/commit -m "fix"') */
|
|
96
|
+
raw: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Result of pattern matching
|
|
100
|
+
*/
|
|
101
|
+
export interface PatternMatchResult {
|
|
102
|
+
/** Detected skill patterns */
|
|
103
|
+
patterns: SkillPattern[];
|
|
104
|
+
/** Original message */
|
|
105
|
+
originalMessage: string;
|
|
106
|
+
/** Whether any patterns were found */
|
|
107
|
+
hasPatterns: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Skill with file inventory
|
|
111
|
+
*/
|
|
112
|
+
export interface SkillWithInventory {
|
|
113
|
+
/** Base skill metadata and content */
|
|
114
|
+
skill: Skill;
|
|
115
|
+
/** Relative file paths (excluding SKILL.md) */
|
|
116
|
+
files: string[];
|
|
117
|
+
/** Formatted content ready for prompt injection */
|
|
118
|
+
formattedContent: string;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/skills/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBAc9B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,0DAA0D;IAC1D,QAAQ,EAAE,aAAa,CAAC;IAExB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAEhB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,MAAM,EAAE,WAAW,CAAC;IAEpB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,K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IACjC,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAC;IACb,+CAA+C;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for skill metadata (frontmatter)
|
|
4
|
+
*/
|
|
5
|
+
export const SkillMetadataSchema = z.object({
|
|
6
|
+
name: z.string().min(1, 'Skill name is required'),
|
|
7
|
+
description: z.string().min(1, 'Skill description is required'),
|
|
8
|
+
version: z.string().optional(),
|
|
9
|
+
author: z.string().optional(),
|
|
10
|
+
license: z.string().optional(),
|
|
11
|
+
modes: z.array(z.string()).optional(),
|
|
12
|
+
compatibility: z
|
|
13
|
+
.object({
|
|
14
|
+
agents: z.array(z.string()).optional(),
|
|
15
|
+
minVersion: z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
priority: z.number().default(0),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/skills/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;IACjD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,+BAA+B,CAAC;IAC/D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,aAAa,EAAE,CAAC;SACb,MAAM,CAAC;QACN,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAClC,CAAC;SACD,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills System - Public API
|
|
3
|
+
*
|
|
4
|
+
* Provides skill discovery, loading, and management for CodeMie agents.
|
|
5
|
+
*/
|
|
6
|
+
export { SkillManager } from './core/SkillManager.js';
|
|
7
|
+
export { SkillDiscovery } from './core/SkillDiscovery.js';
|
|
8
|
+
export type { Skill, SkillMetadata, SkillSource, SkillParseResult, SkillDiscoveryOptions, SkillValidationResult, SkillsConfig, } from './core/types.js';
|
|
9
|
+
export { SkillMetadataSchema } from './core/types.js';
|
|
10
|
+
export { parseFrontmatter, hasFrontmatter, extractMetadata, extractContent, FrontmatterParseError, } from './utils/frontmatter.js';
|
|
11
|
+
export type { FrontmatterResult } from './utils/frontmatter.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,YAAY,EACV,KAAK,EACL,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills System - Public API
|
|
3
|
+
*
|
|
4
|
+
* Provides skill discovery, loading, and management for CodeMie agents.
|
|
5
|
+
*/
|
|
6
|
+
// Core exports
|
|
7
|
+
export { SkillManager } from './core/SkillManager.js';
|
|
8
|
+
export { SkillDiscovery } from './core/SkillDiscovery.js';
|
|
9
|
+
export { SkillMetadataSchema } from './core/types.js';
|
|
10
|
+
// Utility exports
|
|
11
|
+
export { parseFrontmatter, hasFrontmatter, extractMetadata, extractContent, FrontmatterParseError, } from './utils/frontmatter.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAe;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAY1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,kBAAkB;AAClB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content loader for skill files and inventory
|
|
3
|
+
*
|
|
4
|
+
* Loads skill content and builds file inventories for pattern-based invocation.
|
|
5
|
+
*/
|
|
6
|
+
import type { Skill } from '../core/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Skill with file inventory
|
|
9
|
+
*/
|
|
10
|
+
export interface SkillWithInventory {
|
|
11
|
+
/** Base skill metadata and content */
|
|
12
|
+
skill: Skill;
|
|
13
|
+
/** Relative file paths (excluding SKILL.md) */
|
|
14
|
+
files: string[];
|
|
15
|
+
/** Formatted content ready for prompt injection */
|
|
16
|
+
formattedContent: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Load a skill with its file inventory
|
|
20
|
+
*
|
|
21
|
+
* @param skill - Skill to load inventory for
|
|
22
|
+
* @returns Skill with file inventory and formatted content
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadSkillWithInventory(skill: Skill): Promise<SkillWithInventory>;
|
|
25
|
+
//# sourceMappingURL=content-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/utils/content-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAC;IACb,+CAA+C;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AA4BD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,kBAAkB,CAAC,CAe7B"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content loader for skill files and inventory
|
|
3
|
+
*
|
|
4
|
+
* Loads skill content and builds file inventories for pattern-based invocation.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { logger } from '../../utils/logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* File extensions to include in inventory
|
|
11
|
+
*/
|
|
12
|
+
const INCLUDED_EXTENSIONS = new Set([
|
|
13
|
+
'.md',
|
|
14
|
+
'.sh',
|
|
15
|
+
'.js',
|
|
16
|
+
'.ts',
|
|
17
|
+
'.py',
|
|
18
|
+
'.json',
|
|
19
|
+
'.yaml',
|
|
20
|
+
'.yml',
|
|
21
|
+
'.toml',
|
|
22
|
+
'.txt',
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Directories to exclude from inventory
|
|
26
|
+
*/
|
|
27
|
+
const EXCLUDED_DIRS = new Set(['node_modules', '.git', 'dist', 'build']);
|
|
28
|
+
/**
|
|
29
|
+
* Maximum depth for file scanning (prevent infinite loops)
|
|
30
|
+
*/
|
|
31
|
+
const MAX_DEPTH = 5;
|
|
32
|
+
/**
|
|
33
|
+
* Load a skill with its file inventory
|
|
34
|
+
*
|
|
35
|
+
* @param skill - Skill to load inventory for
|
|
36
|
+
* @returns Skill with file inventory and formatted content
|
|
37
|
+
*/
|
|
38
|
+
export async function loadSkillWithInventory(skill) {
|
|
39
|
+
// Get skill directory from SKILL.md path
|
|
40
|
+
const skillDirectory = path.dirname(skill.filePath);
|
|
41
|
+
// Build file inventory
|
|
42
|
+
const files = await buildFileInventory(skillDirectory);
|
|
43
|
+
// Format content for injection
|
|
44
|
+
const formattedContent = formatSkillContent(skill, files);
|
|
45
|
+
return {
|
|
46
|
+
skill,
|
|
47
|
+
files,
|
|
48
|
+
formattedContent,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build file inventory for a skill directory
|
|
53
|
+
*
|
|
54
|
+
* @param skillDirectoryPath - Absolute path to skill directory
|
|
55
|
+
* @returns Array of relative file paths (sorted alphabetically)
|
|
56
|
+
*/
|
|
57
|
+
async function buildFileInventory(skillDirectoryPath) {
|
|
58
|
+
const files = [];
|
|
59
|
+
try {
|
|
60
|
+
// Check if directory exists
|
|
61
|
+
if (!fs.existsSync(skillDirectoryPath)) {
|
|
62
|
+
logger.warn(`Skill directory not found: ${skillDirectoryPath}`);
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
// Scan directory recursively
|
|
66
|
+
await scanDirectory(skillDirectoryPath, skillDirectoryPath, files, 0);
|
|
67
|
+
// Sort alphabetically for consistent output
|
|
68
|
+
files.sort();
|
|
69
|
+
return files;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.warn(`Failed to build file inventory for ${skillDirectoryPath}:`, error);
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Recursively scan a directory for files
|
|
78
|
+
*
|
|
79
|
+
* @param basePath - Base skill directory path
|
|
80
|
+
* @param currentPath - Current directory being scanned
|
|
81
|
+
* @param files - Accumulator for discovered files
|
|
82
|
+
* @param depth - Current recursion depth
|
|
83
|
+
*/
|
|
84
|
+
async function scanDirectory(basePath, currentPath, files, depth) {
|
|
85
|
+
// Prevent infinite loops
|
|
86
|
+
if (depth >= MAX_DEPTH) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const entries = await fs.promises.readdir(currentPath, {
|
|
91
|
+
withFileTypes: true,
|
|
92
|
+
});
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
const fullPath = path.join(currentPath, entry.name);
|
|
95
|
+
// Skip hidden files/directories
|
|
96
|
+
if (entry.name.startsWith('.')) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (entry.isDirectory()) {
|
|
100
|
+
// Skip excluded directories
|
|
101
|
+
if (EXCLUDED_DIRS.has(entry.name)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// Recurse into subdirectory
|
|
105
|
+
await scanDirectory(basePath, fullPath, files, depth + 1);
|
|
106
|
+
}
|
|
107
|
+
else if (entry.isFile()) {
|
|
108
|
+
// Skip SKILL.md (already loaded)
|
|
109
|
+
if (entry.name === 'SKILL.md') {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
// Check file extension
|
|
113
|
+
const ext = path.extname(entry.name);
|
|
114
|
+
if (INCLUDED_EXTENSIONS.has(ext)) {
|
|
115
|
+
// Store relative path
|
|
116
|
+
const relativePath = path.relative(basePath, fullPath);
|
|
117
|
+
files.push(relativePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Skip symbolic links (avoid loops)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// Permission errors or other issues - log and continue
|
|
125
|
+
logger.debug(`Failed to scan directory ${currentPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Format skill content for prompt injection
|
|
130
|
+
*
|
|
131
|
+
* @param skill - Skill to format
|
|
132
|
+
* @param files - File inventory
|
|
133
|
+
* @returns Formatted markdown content
|
|
134
|
+
*/
|
|
135
|
+
function formatSkillContent(skill, files) {
|
|
136
|
+
const parts = [];
|
|
137
|
+
// Header
|
|
138
|
+
parts.push(`## Skill: ${skill.metadata.name}`);
|
|
139
|
+
parts.push('');
|
|
140
|
+
parts.push(skill.metadata.description);
|
|
141
|
+
parts.push('');
|
|
142
|
+
// Skill content
|
|
143
|
+
parts.push('### SKILL.md Content');
|
|
144
|
+
parts.push('');
|
|
145
|
+
parts.push(skill.content);
|
|
146
|
+
parts.push('');
|
|
147
|
+
// File inventory (if any)
|
|
148
|
+
if (files.length > 0) {
|
|
149
|
+
parts.push('### Available Files');
|
|
150
|
+
parts.push('');
|
|
151
|
+
parts.push('The following files are available in this skill directory.');
|
|
152
|
+
parts.push('Use the Read tool to access their content when needed:');
|
|
153
|
+
parts.push('');
|
|
154
|
+
for (const file of files) {
|
|
155
|
+
parts.push(`- ${file}`);
|
|
156
|
+
}
|
|
157
|
+
parts.push('');
|
|
158
|
+
}
|
|
159
|
+
return parts.join('\n');
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=content-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-loader.js","sourceRoot":"","sources":["../../../src/skills/utils/content-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAc/C;;GAEG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAY;IAEZ,yCAAyC;IACzC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEpD,uBAAuB;IACvB,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAEvD,+BAA+B;IAC/B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAE1D,OAAO;QACL,KAAK;QACL,KAAK;QACL,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,kBAAkB,CAC/B,kBAA0B;IAE1B,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,CAAC;QACH,4BAA4B;QAC5B,IAAI,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AChB,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,0BAA0B;IAC1B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,4DAA4D,CAC7D,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;QACrE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAC1B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of parsing frontmatter from a markdown file
|
|
3
|
+
*/
|
|
4
|
+
export interface FrontmatterResult<T = Record<string, unknown>> {
|
|
5
|
+
/** Parsed metadata from YAML frontmatter */
|
|
6
|
+
metadata: T;
|
|
7
|
+
/** Markdown content (body after frontmatter) */
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when frontmatter parsing fails
|
|
12
|
+
*/
|
|
13
|
+
export declare class FrontmatterParseError extends Error {
|
|
14
|
+
readonly filePath?: string | undefined;
|
|
15
|
+
readonly cause?: unknown | undefined;
|
|
16
|
+
constructor(message: string, filePath?: string | undefined, cause?: unknown | undefined);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse YAML frontmatter from a markdown file
|
|
20
|
+
*
|
|
21
|
+
* Expected format:
|
|
22
|
+
* ```
|
|
23
|
+
* ---
|
|
24
|
+
* key: value
|
|
25
|
+
* ---
|
|
26
|
+
* Content here
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param fileContent - Raw file content
|
|
30
|
+
* @param filePath - Optional file path (for error messages)
|
|
31
|
+
* @returns Parsed frontmatter metadata and markdown content
|
|
32
|
+
* @throws FrontmatterParseError if parsing fails
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseFrontmatter<T = Record<string, unknown>>(fileContent: string, filePath?: string): FrontmatterResult<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a file has valid frontmatter format (non-throwing)
|
|
37
|
+
*
|
|
38
|
+
* @param fileContent - Raw file content
|
|
39
|
+
* @returns true if file has valid frontmatter structure
|
|
40
|
+
*/
|
|
41
|
+
export declare function hasFrontmatter(fileContent: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Extract just the metadata without validating content
|
|
44
|
+
*
|
|
45
|
+
* @param fileContent - Raw file content
|
|
46
|
+
* @param filePath - Optional file path (for error messages)
|
|
47
|
+
* @returns Parsed metadata
|
|
48
|
+
* @throws FrontmatterParseError if parsing fails
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractMetadata<T = Record<string, unknown>>(fileContent: string, filePath?: string): T;
|
|
51
|
+
/**
|
|
52
|
+
* Extract just the content without validating metadata
|
|
53
|
+
*
|
|
54
|
+
* @param fileContent - Raw file content
|
|
55
|
+
* @param filePath - Optional file path (for error messages)
|
|
56
|
+
* @returns Markdown content
|
|
57
|
+
* @throws FrontmatterParseError if parsing fails
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractContent(fileContent: string, filePath?: string): string;
|
|
60
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/skills/utils/frontmatter.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,CAAC;IAEZ,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aAG5B,QAAQ,CAAC,EAAE,MAAM;aACjB,KAAK,CAAC,EAAE,OAAO;gBAF/B,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,KAAK,CAAC,EAAE,OAAO,YAAA;CAKlC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,iBAAiB,CAAC,CAAC,CAAC,CA8DtB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO3D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,CAAC,CAGH;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7E"}
|