@codemieai/code 0.0.32 → 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/codemie-code/ui/todoPanel.d.ts.map +1 -1
- package/dist/agents/codemie-code/ui/todoPanel.js +4 -0
- package/dist/agents/codemie-code/ui/todoPanel.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 +46 -2
- 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/SessionStore.d.ts +15 -0
- package/dist/agents/core/session/SessionStore.d.ts.map +1 -1
- package/dist/agents/core/session/SessionStore.js +46 -0
- package/dist/agents/core/session/SessionStore.js.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/session/types.d.ts +2 -0
- package/dist/agents/core/session/types.d.ts.map +1 -1
- 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/.claude-plugin/plugin.json +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/claude/plugin/hooks/hooks.json +11 -0
- package/dist/agents/plugins/gemini/extension/gemini-extension.json +1 -1
- package/dist/agents/plugins/gemini/extension/hooks/hooks.json +12 -0
- package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/gemini/gemini.plugin.js +2 -4
- 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/hook.d.ts.map +1 -1
- package/dist/cli/commands/hook.js +63 -6
- package/dist/cli/commands/hook.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/session/processors/metrics/metrics-api-client.d.ts +3 -2
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js +6 -2
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.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/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +11 -1
- package/dist/utils/exec.js.map +1 -1
- 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,120 @@
|
|
|
1
|
+
import { 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,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AI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;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"}
|
|
@@ -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;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AAa,EAAE,CAAC;IAE3B,SAAS;IACT,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,gBAAgB;IAChB,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"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { parse as parseYaml } from 'yaml';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when frontmatter parsing fails
|
|
4
|
+
*/
|
|
5
|
+
export class FrontmatterParseError extends Error {
|
|
6
|
+
filePath;
|
|
7
|
+
cause;
|
|
8
|
+
constructor(message, filePath, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.filePath = filePath;
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = 'FrontmatterParseError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse YAML frontmatter from a markdown file
|
|
17
|
+
*
|
|
18
|
+
* Expected format:
|
|
19
|
+
* ```
|
|
20
|
+
* ---
|
|
21
|
+
* key: value
|
|
22
|
+
* ---
|
|
23
|
+
* Content here
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param fileContent - Raw file content
|
|
27
|
+
* @param filePath - Optional file path (for error messages)
|
|
28
|
+
* @returns Parsed frontmatter metadata and markdown content
|
|
29
|
+
* @throws FrontmatterParseError if parsing fails
|
|
30
|
+
*/
|
|
31
|
+
export function parseFrontmatter(fileContent, filePath) {
|
|
32
|
+
// Trim leading/trailing whitespace
|
|
33
|
+
const trimmed = fileContent.trim();
|
|
34
|
+
// Check if file starts with frontmatter delimiter
|
|
35
|
+
if (!trimmed.startsWith('---')) {
|
|
36
|
+
throw new FrontmatterParseError('File must start with frontmatter delimiter (---)', filePath);
|
|
37
|
+
}
|
|
38
|
+
// Find the closing delimiter
|
|
39
|
+
const lines = trimmed.split('\n');
|
|
40
|
+
let closingDelimiterIndex = -1;
|
|
41
|
+
// Start from line 1 (skip opening ---)
|
|
42
|
+
for (let i = 1; i < lines.length; i++) {
|
|
43
|
+
if (lines[i].trim() === '---') {
|
|
44
|
+
closingDelimiterIndex = i;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (closingDelimiterIndex === -1) {
|
|
49
|
+
throw new FrontmatterParseError('Missing closing frontmatter delimiter (---)', filePath);
|
|
50
|
+
}
|
|
51
|
+
// Extract YAML content (between delimiters)
|
|
52
|
+
const yamlLines = lines.slice(1, closingDelimiterIndex);
|
|
53
|
+
const yamlContent = yamlLines.join('\n');
|
|
54
|
+
// Extract markdown content (after closing delimiter)
|
|
55
|
+
const contentLines = lines.slice(closingDelimiterIndex + 1);
|
|
56
|
+
const content = contentLines.join('\n').trim();
|
|
57
|
+
// Parse YAML
|
|
58
|
+
let metadata;
|
|
59
|
+
try {
|
|
60
|
+
const parsed = parseYaml(yamlContent);
|
|
61
|
+
// Ensure we got an object
|
|
62
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
63
|
+
throw new Error('Frontmatter must be a YAML object (key-value pairs)');
|
|
64
|
+
}
|
|
65
|
+
metadata = parsed;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw new FrontmatterParseError(`Failed to parse YAML frontmatter: ${error instanceof Error ? error.message : String(error)}`, filePath, error);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
metadata,
|
|
72
|
+
content,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if a file has valid frontmatter format (non-throwing)
|
|
77
|
+
*
|
|
78
|
+
* @param fileContent - Raw file content
|
|
79
|
+
* @returns true if file has valid frontmatter structure
|
|
80
|
+
*/
|
|
81
|
+
export function hasFrontmatter(fileContent) {
|
|
82
|
+
try {
|
|
83
|
+
parseFrontmatter(fileContent);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract just the metadata without validating content
|
|
92
|
+
*
|
|
93
|
+
* @param fileContent - Raw file content
|
|
94
|
+
* @param filePath - Optional file path (for error messages)
|
|
95
|
+
* @returns Parsed metadata
|
|
96
|
+
* @throws FrontmatterParseError if parsing fails
|
|
97
|
+
*/
|
|
98
|
+
export function extractMetadata(fileContent, filePath) {
|
|
99
|
+
const result = parseFrontmatter(fileContent, filePath);
|
|
100
|
+
return result.metadata;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extract just the content without validating metadata
|
|
104
|
+
*
|
|
105
|
+
* @param fileContent - Raw file content
|
|
106
|
+
* @param filePath - Optional file path (for error messages)
|
|
107
|
+
* @returns Markdown content
|
|
108
|
+
* @throws FrontmatterParseError if parsing fails
|
|
109
|
+
*/
|
|
110
|
+
export function extractContent(fileContent, filePath) {
|
|
111
|
+
const result = parseFrontmatter(fileContent, filePath);
|
|
112
|
+
return result.content;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../src/skills/utils/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAa1C;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAG5B;IACA;IAHlB,YACE,OAAe,EACC,QAAiB,EACjB,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,aAAQ,GAAR,QAAQ,CAAS;QACjB,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmB,EACnB,QAAiB;IAEjB,mCAAmC;IACnC,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;IAEnC,kDAAkD;IAClD,IAAI,CAAC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C3E,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,QAAQ,GAAG,MAAW,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,qBAAqB,CAC7B,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC7F,QAAQ,EACR,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO;QACL,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,IAAI,CAAC;QACH,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,WAAmB,EACnB,QAAiB;IAEjB,MAAM,MAAM,GAAG,gBAAgB,CAAI,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB,EAAE,QAAiB;IACnE,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern matcher for skill invocation detection
|
|
3
|
+
*
|
|
4
|
+
* Detects /skill-name patterns in user messages and extracts skill names.
|
|
5
|
+
* Excludes URLs and built-in CLI commands.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Skill pattern detected in a message
|
|
9
|
+
*/
|
|
10
|
+
export interface SkillPattern {
|
|
11
|
+
/** Skill name (e.g., 'mr', 'commit') */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Position in message where pattern starts */
|
|
14
|
+
position: number;
|
|
15
|
+
/** Optional arguments after skill name */
|
|
16
|
+
args?: string;
|
|
17
|
+
/** Full matched pattern (e.g., '/mr', '/commit -m "fix"') */
|
|
18
|
+
raw: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of pattern matching
|
|
22
|
+
*/
|
|
23
|
+
export interface PatternMatchResult {
|
|
24
|
+
/** Detected skill patterns */
|
|
25
|
+
patterns: SkillPattern[];
|
|
26
|
+
/** Original message */
|
|
27
|
+
originalMessage: string;
|
|
28
|
+
/** Whether any patterns were found */
|
|
29
|
+
hasPatterns: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extract skill patterns from a user message
|
|
33
|
+
*
|
|
34
|
+
* @param message - User message to scan
|
|
35
|
+
* @returns Pattern match result with detected skills
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const result = extractSkillPatterns('/mr');
|
|
40
|
+
* // result.patterns = [{ name: 'mr', position: 0, raw: '/mr' }]
|
|
41
|
+
*
|
|
42
|
+
* const result2 = extractSkillPatterns('ensure you can /commit this');
|
|
43
|
+
* // result2.patterns = [{ name: 'commit', position: 15, args: 'this', raw: '/commit this' }]
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractSkillPatterns(message: string): PatternMatchResult;
|
|
47
|
+
/**
|
|
48
|
+
* Validate a skill name
|
|
49
|
+
*
|
|
50
|
+
* @param name - Skill name to validate
|
|
51
|
+
* @returns True if valid, false otherwise
|
|
52
|
+
*
|
|
53
|
+
* Rules:
|
|
54
|
+
* - Lowercase letters only
|
|
55
|
+
* - Can include digits and hyphens
|
|
56
|
+
* - Must start with a letter
|
|
57
|
+
* - 1-50 characters
|
|
58
|
+
*/
|
|
59
|
+
export declare function isValidSkillName(name: string): boolean;
|
|
60
|
+
//# sourceMappingURL=pattern-matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-matcher.d.ts","sourceRoot":"","sources":["../../../src/skills/utils/pattern-matcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,WAAW,EAAE,OAAO,CAAC;CACtB;AAyBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CA8CxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|