@ai-primitives-hub/app 0.0.1-alpha.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 +26 -0
- package/dist/collection/generate-skill.d.ts +43 -0
- package/dist/collection/generate-skill.d.ts.map +1 -0
- package/dist/collection/generate-skill.js +244 -0
- package/dist/collection/generate-skill.js.map +1 -0
- package/dist/collection/index.d.ts +8 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +23 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/read-collection.d.ts +60 -0
- package/dist/collection/read-collection.d.ts.map +1 -0
- package/dist/collection/read-collection.js +291 -0
- package/dist/collection/read-collection.js.map +1 -0
- package/dist/context-detection/detector.d.ts +126 -0
- package/dist/context-detection/detector.d.ts.map +1 -0
- package/dist/context-detection/detector.js +408 -0
- package/dist/context-detection/detector.js.map +1 -0
- package/dist/context-detection/index.d.ts +11 -0
- package/dist/context-detection/index.d.ts.map +1 -0
- package/dist/context-detection/index.js +14 -0
- package/dist/context-detection/index.js.map +1 -0
- package/dist/context-detection/types.d.ts +74 -0
- package/dist/context-detection/types.d.ts.map +1 -0
- package/dist/context-detection/types.js +13 -0
- package/dist/context-detection/types.js.map +1 -0
- package/dist/discovery/index.d.ts +7 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +23 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/profile-generator.d.ts +31 -0
- package/dist/discovery/profile-generator.d.ts.map +1 -0
- package/dist/discovery/profile-generator.js +55 -0
- package/dist/discovery/profile-generator.js.map +1 -0
- package/dist/discovery/recommendation-engine.d.ts +76 -0
- package/dist/discovery/recommendation-engine.d.ts.map +1 -0
- package/dist/discovery/recommendation-engine.js +210 -0
- package/dist/discovery/recommendation-engine.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/install/index.d.ts +14 -0
- package/dist/install/index.d.ts.map +1 -0
- package/dist/install/index.js +20 -0
- package/dist/install/index.js.map +1 -0
- package/dist/install/install-bundle.d.ts +31 -0
- package/dist/install/install-bundle.d.ts.map +1 -0
- package/dist/install/install-bundle.js +23 -0
- package/dist/install/install-bundle.js.map +1 -0
- package/dist/install/layout-resolver.d.ts +31 -0
- package/dist/install/layout-resolver.d.ts.map +1 -0
- package/dist/install/layout-resolver.js +70 -0
- package/dist/install/layout-resolver.js.map +1 -0
- package/dist/install/pipeline.d.ts +111 -0
- package/dist/install/pipeline.d.ts.map +1 -0
- package/dist/install/pipeline.js +138 -0
- package/dist/install/pipeline.js.map +1 -0
- package/dist/install/uninstall-bundle.d.ts +36 -0
- package/dist/install/uninstall-bundle.d.ts.map +1 -0
- package/dist/install/uninstall-bundle.js +37 -0
- package/dist/install/uninstall-bundle.js.map +1 -0
- package/dist/install/uninstall-pipeline.d.ts +119 -0
- package/dist/install/uninstall-pipeline.d.ts.map +1 -0
- package/dist/install/uninstall-pipeline.js +187 -0
- package/dist/install/uninstall-pipeline.js.map +1 -0
- package/dist/registry/activate-registry-profile.d.ts +67 -0
- package/dist/registry/activate-registry-profile.d.ts.map +1 -0
- package/dist/registry/activate-registry-profile.js +150 -0
- package/dist/registry/activate-registry-profile.js.map +1 -0
- package/dist/registry/create-source-adapter.d.ts +43 -0
- package/dist/registry/create-source-adapter.d.ts.map +1 -0
- package/dist/registry/create-source-adapter.js +53 -0
- package/dist/registry/create-source-adapter.js.map +1 -0
- package/dist/registry/deactivate-registry-profile.d.ts +38 -0
- package/dist/registry/deactivate-registry-profile.d.ts.map +1 -0
- package/dist/registry/deactivate-registry-profile.js +45 -0
- package/dist/registry/deactivate-registry-profile.js.map +1 -0
- package/dist/registry/detect-updates.d.ts +12 -0
- package/dist/registry/detect-updates.d.ts.map +1 -0
- package/dist/registry/detect-updates.js +76 -0
- package/dist/registry/detect-updates.js.map +1 -0
- package/dist/registry/hub-manager.d.ts +229 -0
- package/dist/registry/hub-manager.d.ts.map +1 -0
- package/dist/registry/hub-manager.js +473 -0
- package/dist/registry/hub-manager.js.map +1 -0
- package/dist/registry/index.d.ts +23 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +39 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/install-registry-bundle.d.ts +56 -0
- package/dist/registry/install-registry-bundle.d.ts.map +1 -0
- package/dist/registry/install-registry-bundle.js +150 -0
- package/dist/registry/install-registry-bundle.js.map +1 -0
- package/dist/registry/list-all-profiles.d.ts +27 -0
- package/dist/registry/list-all-profiles.d.ts.map +1 -0
- package/dist/registry/list-all-profiles.js +52 -0
- package/dist/registry/list-all-profiles.js.map +1 -0
- package/dist/registry/list-installed-bundles.d.ts +37 -0
- package/dist/registry/list-installed-bundles.d.ts.map +1 -0
- package/dist/registry/list-installed-bundles.js +27 -0
- package/dist/registry/list-installed-bundles.js.map +1 -0
- package/dist/registry/load-hub-sources.d.ts +56 -0
- package/dist/registry/load-hub-sources.d.ts.map +1 -0
- package/dist/registry/load-hub-sources.js +123 -0
- package/dist/registry/load-hub-sources.js.map +1 -0
- package/dist/registry/local-profile-crud.d.ts +58 -0
- package/dist/registry/local-profile-crud.d.ts.map +1 -0
- package/dist/registry/local-profile-crud.js +85 -0
- package/dist/registry/local-profile-crud.js.map +1 -0
- package/dist/registry/profile-lifecycle.d.ts +190 -0
- package/dist/registry/profile-lifecycle.d.ts.map +1 -0
- package/dist/registry/profile-lifecycle.js +400 -0
- package/dist/registry/profile-lifecycle.js.map +1 -0
- package/dist/registry/registry-settings.d.ts +32 -0
- package/dist/registry/registry-settings.d.ts.map +1 -0
- package/dist/registry/registry-settings.js +145 -0
- package/dist/registry/registry-settings.js.map +1 -0
- package/dist/registry/resolve-installation-bundle.d.ts +46 -0
- package/dist/registry/resolve-installation-bundle.d.ts.map +1 -0
- package/dist/registry/resolve-installation-bundle.js +98 -0
- package/dist/registry/resolve-installation-bundle.js.map +1 -0
- package/dist/registry/search-registry-bundles.d.ts +47 -0
- package/dist/registry/search-registry-bundles.d.ts.map +1 -0
- package/dist/registry/search-registry-bundles.js +129 -0
- package/dist/registry/search-registry-bundles.js.map +1 -0
- package/dist/registry/uninstall-installed-bundle.d.ts +48 -0
- package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -0
- package/dist/registry/uninstall-installed-bundle.js +45 -0
- package/dist/registry/uninstall-installed-bundle.js.map +1 -0
- package/dist/registry/update-registry-bundle.d.ts +36 -0
- package/dist/registry/update-registry-bundle.d.ts.map +1 -0
- package/dist/registry/update-registry-bundle.js +113 -0
- package/dist/registry/update-registry-bundle.js.map +1 -0
- package/dist/registry/user-config-paths.d.ts +24 -0
- package/dist/registry/user-config-paths.d.ts.map +1 -0
- package/dist/registry/user-config-paths.js +82 -0
- package/dist/registry/user-config-paths.js.map +1 -0
- package/dist/registry/version-consolidator.d.ts +123 -0
- package/dist/registry/version-consolidator.d.ts.map +1 -0
- package/dist/registry/version-consolidator.js +231 -0
- package/dist/registry/version-consolidator.js.map +1 -0
- package/dist/search/export-profile.d.ts +63 -0
- package/dist/search/export-profile.d.ts.map +1 -0
- package/dist/search/export-profile.js +138 -0
- package/dist/search/export-profile.js.map +1 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +22 -0
- package/dist/search/index.js.map +1 -0
- package/dist/stores/index.d.ts +8 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +24 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/stores/json-lockfile-store.d.ts +203 -0
- package/dist/stores/json-lockfile-store.d.ts.map +1 -0
- package/dist/stores/json-lockfile-store.js +277 -0
- package/dist/stores/json-lockfile-store.js.map +1 -0
- package/dist/transform/index.d.ts +10 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +26 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/transformer-registry.d.ts +52 -0
- package/dist/transform/transformer-registry.d.ts.map +1 -0
- package/dist/transform/transformer-registry.js +53 -0
- package/dist/transform/transformer-registry.js.map +1 -0
- package/dist/transform/transformers/claude-code-transformer.d.ts +67 -0
- package/dist/transform/transformers/claude-code-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/claude-code-transformer.js +140 -0
- package/dist/transform/transformers/claude-code-transformer.js.map +1 -0
- package/dist/transform/transformers/kiro-transformer.d.ts +51 -0
- package/dist/transform/transformers/kiro-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/kiro-transformer.js +128 -0
- package/dist/transform/transformers/kiro-transformer.js.map +1 -0
- package/dist/transform/transformers/noop-transformer.d.ts +25 -0
- package/dist/transform/transformers/noop-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/noop-transformer.js +20 -0
- package/dist/transform/transformers/noop-transformer.js.map +1 -0
- package/dist/transform/transformers/windsurf-transformer.d.ts +63 -0
- package/dist/transform/transformers/windsurf-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/windsurf-transformer.js +125 -0
- package/dist/transform/transformers/windsurf-transformer.js.map +1 -0
- package/dist/update/auto-update.d.ts +84 -0
- package/dist/update/auto-update.d.ts.map +1 -0
- package/dist/update/auto-update.js +217 -0
- package/dist/update/auto-update.js.map +1 -0
- package/dist/update/check-updates.d.ts +51 -0
- package/dist/update/check-updates.d.ts.map +1 -0
- package/dist/update/check-updates.js +168 -0
- package/dist/update/check-updates.js.map +1 -0
- package/dist/update/index.d.ts +8 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +24 -0
- package/dist/update/index.js.map +1 -0
- package/dist/update/log-event.d.ts +15 -0
- package/dist/update/log-event.d.ts.map +1 -0
- package/dist/update/log-event.js +11 -0
- package/dist/update/log-event.js.map +1 -0
- package/dist/writers/file-tree-writer.d.ts +136 -0
- package/dist/writers/file-tree-writer.d.ts.map +1 -0
- package/dist/writers/file-tree-writer.js +337 -0
- package/dist/writers/file-tree-writer.js.map +1 -0
- package/dist/writers/index.d.ts +7 -0
- package/dist/writers/index.d.ts.map +1 -0
- package/dist/writers/index.js +23 -0
- package/dist/writers/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClaudeCodeTransformer — transforms content for the Claude Code target runtime.
|
|
3
|
+
*
|
|
4
|
+
* Claude Code subagents (`.claude/agents/*.md`) require both `name` and
|
|
5
|
+
* `description` in their YAML frontmatter — the only two mandatory
|
|
6
|
+
* fields of the subagent spec:
|
|
7
|
+
* @see https://code.claude.com/docs/en/sub-agents
|
|
8
|
+
*
|
|
9
|
+
* This transformer ensures agent files have both fields, deriving
|
|
10
|
+
* whichever is missing:
|
|
11
|
+
* - `name`: from an existing `title` field, or the filename — same
|
|
12
|
+
* derivation as `KiroTransformer`.
|
|
13
|
+
* - `description`: from the first non-empty, non-heading line of the
|
|
14
|
+
* file body — matching Claude Code's own documented fallback for a
|
|
15
|
+
* missing slash-command `description` ("defaults to the first line
|
|
16
|
+
* of the command prompt"), reused here since agents live in the same
|
|
17
|
+
* spec family. Falls back to a generic `"<name> agent"` description
|
|
18
|
+
* if the body has no usable line either, so the field is never left
|
|
19
|
+
* absent.
|
|
20
|
+
*
|
|
21
|
+
* Idempotent: fields that are already present are left untouched;
|
|
22
|
+
* unlike `KiroTransformer` (which only ever manages one field), this
|
|
23
|
+
* checks `name` and `description` independently, only filling in
|
|
24
|
+
* whichever is missing.
|
|
25
|
+
* Fail-safe: on parsing errors, returns the original content.
|
|
26
|
+
* @module transform/transformers/claude-code-transformer
|
|
27
|
+
*/
|
|
28
|
+
import type { ResourceTransformer, TransformContext, TransformResult } from '@ai-primitives-hub/core';
|
|
29
|
+
/**
|
|
30
|
+
* Transformer for Claude Code-specific requirements.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ClaudeCodeTransformer implements ResourceTransformer {
|
|
33
|
+
/**
|
|
34
|
+
* Derive a human-readable name from a bundle-relative file path.
|
|
35
|
+
* @param filePath - Bundle-relative file path.
|
|
36
|
+
* @returns Derived name.
|
|
37
|
+
*/
|
|
38
|
+
private extractNameFromPath;
|
|
39
|
+
/**
|
|
40
|
+
* Derive a fallback description from the first non-empty, non-heading
|
|
41
|
+
* line of the file body (the part after the closing frontmatter marker).
|
|
42
|
+
* @param originalContent - Original file content.
|
|
43
|
+
* @returns Derived description, or undefined if the body has no usable line.
|
|
44
|
+
*/
|
|
45
|
+
private extractDescriptionFromBody;
|
|
46
|
+
/**
|
|
47
|
+
* Serialize frontmatter back to the file content.
|
|
48
|
+
* @param frontmatter - Frontmatter object.
|
|
49
|
+
* @param originalContent - Original file content.
|
|
50
|
+
* @returns Updated content with new frontmatter.
|
|
51
|
+
*/
|
|
52
|
+
private serializeFrontmatter;
|
|
53
|
+
/**
|
|
54
|
+
* Convert an object to YAML string. Simple implementation for common cases.
|
|
55
|
+
* @param obj - Object to convert.
|
|
56
|
+
* @returns YAML string.
|
|
57
|
+
*/
|
|
58
|
+
private objectToYaml;
|
|
59
|
+
/**
|
|
60
|
+
* Transform file content for the Claude Code runtime.
|
|
61
|
+
* Only transforms agent files (agents/*.md).
|
|
62
|
+
* @param context - Transformation context.
|
|
63
|
+
* @returns TransformResult.
|
|
64
|
+
*/
|
|
65
|
+
transform(context: TransformContext): TransformResult;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=claude-code-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-transformer.d.ts","sourceRoot":"","sources":["../../../src/transform/transformers/claude-code-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAOjC;;GAEG;AACH,qBAAa,qBAAsB,YAAW,mBAAmB;IAC/D;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IA0BpB;;;;;OAKG;IACI,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe;CA4C7D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudeCodeTransformer = void 0;
|
|
4
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
5
|
+
/**
|
|
6
|
+
* Transformer for Claude Code-specific requirements.
|
|
7
|
+
*/
|
|
8
|
+
class ClaudeCodeTransformer {
|
|
9
|
+
/**
|
|
10
|
+
* Derive a human-readable name from a bundle-relative file path.
|
|
11
|
+
* @param filePath - Bundle-relative file path.
|
|
12
|
+
* @returns Derived name.
|
|
13
|
+
*/
|
|
14
|
+
extractNameFromPath(filePath) {
|
|
15
|
+
const baseName = filePath.replace(/^agents\//, '').replace(/\.md$/, '');
|
|
16
|
+
return baseName
|
|
17
|
+
.split(/[-_]/)
|
|
18
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
19
|
+
.join(' ');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Derive a fallback description from the first non-empty, non-heading
|
|
23
|
+
* line of the file body (the part after the closing frontmatter marker).
|
|
24
|
+
* @param originalContent - Original file content.
|
|
25
|
+
* @returns Derived description, or undefined if the body has no usable line.
|
|
26
|
+
*/
|
|
27
|
+
extractDescriptionFromBody(originalContent) {
|
|
28
|
+
const lines = originalContent.split('\n');
|
|
29
|
+
const frontmatterEndIndex = lines.indexOf('---');
|
|
30
|
+
const secondSeparatorIndex = lines.findIndex((line, idx) => idx > frontmatterEndIndex && line === '---');
|
|
31
|
+
const bodyLines = secondSeparatorIndex === -1 ? [] : lines.slice(secondSeparatorIndex + 1);
|
|
32
|
+
for (const line of bodyLines) {
|
|
33
|
+
const trimmed = line.trim();
|
|
34
|
+
if (trimmed.length > 0 && !trimmed.startsWith('#')) {
|
|
35
|
+
return trimmed;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serialize frontmatter back to the file content.
|
|
42
|
+
* @param frontmatter - Frontmatter object.
|
|
43
|
+
* @param originalContent - Original file content.
|
|
44
|
+
* @returns Updated content with new frontmatter.
|
|
45
|
+
*/
|
|
46
|
+
serializeFrontmatter(frontmatter, originalContent) {
|
|
47
|
+
const lines = originalContent.split('\n');
|
|
48
|
+
const frontmatterEndIndex = lines.indexOf('---');
|
|
49
|
+
if (frontmatterEndIndex === -1) {
|
|
50
|
+
const newYaml = this.objectToYaml(frontmatter);
|
|
51
|
+
return `---\n${newYaml}---\n${originalContent}`;
|
|
52
|
+
}
|
|
53
|
+
const secondSeparatorIndex = lines.findIndex((line, idx) => idx > frontmatterEndIndex && line === '---');
|
|
54
|
+
if (secondSeparatorIndex === -1) {
|
|
55
|
+
// Malformed frontmatter, return original
|
|
56
|
+
return originalContent;
|
|
57
|
+
}
|
|
58
|
+
const yamlContent = this.objectToYaml(frontmatter);
|
|
59
|
+
const beforeFrontmatter = lines.slice(0, frontmatterEndIndex + 1);
|
|
60
|
+
const afterFrontmatter = lines.slice(secondSeparatorIndex);
|
|
61
|
+
return [...beforeFrontmatter, yamlContent, ...afterFrontmatter].join('\n');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert an object to YAML string. Simple implementation for common cases.
|
|
65
|
+
* @param obj - Object to convert.
|
|
66
|
+
* @returns YAML string.
|
|
67
|
+
*/
|
|
68
|
+
objectToYaml(obj) {
|
|
69
|
+
const lines = [];
|
|
70
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
71
|
+
if (value === undefined) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (typeof value === 'string') {
|
|
75
|
+
lines.push(`${key}: "${value}"`);
|
|
76
|
+
}
|
|
77
|
+
else if (typeof value === 'boolean' || value === null) {
|
|
78
|
+
lines.push(`${key}: ${value}`);
|
|
79
|
+
}
|
|
80
|
+
else if (Array.isArray(value)) {
|
|
81
|
+
lines.push(`${key}:`);
|
|
82
|
+
for (const item of value) {
|
|
83
|
+
if (typeof item === 'string') {
|
|
84
|
+
lines.push(` - "${item}"`);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
lines.push(` - ${String(item)}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
lines.push(`${key}: ${JSON.stringify(value)}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return lines.join('\n');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Transform file content for the Claude Code runtime.
|
|
99
|
+
* Only transforms agent files (agents/*.md).
|
|
100
|
+
* @param context - Transformation context.
|
|
101
|
+
* @returns TransformResult.
|
|
102
|
+
*/
|
|
103
|
+
transform(context) {
|
|
104
|
+
if (!context.filePath.startsWith('agents/')) {
|
|
105
|
+
return (0, core_1.noChange)(context.content);
|
|
106
|
+
}
|
|
107
|
+
if (!context.filePath.endsWith('.md')) {
|
|
108
|
+
return (0, core_1.noChange)(context.content);
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const frontmatter = (0, core_1.parseFrontmatter)(context.content);
|
|
112
|
+
const hasFrontmatterMarkers = context.content.startsWith('---')
|
|
113
|
+
&& context.content.includes('---', 3);
|
|
114
|
+
if (!hasFrontmatterMarkers) {
|
|
115
|
+
return (0, core_1.noChange)(context.content);
|
|
116
|
+
}
|
|
117
|
+
const needsName = frontmatter === null || frontmatter.name === undefined;
|
|
118
|
+
const needsDescription = frontmatter === null || frontmatter.description === undefined;
|
|
119
|
+
if (!needsName && !needsDescription) {
|
|
120
|
+
return (0, core_1.noChange)(context.content);
|
|
121
|
+
}
|
|
122
|
+
const updatedFrontmatter = frontmatter === null ? {} : { ...frontmatter };
|
|
123
|
+
if (needsName) {
|
|
124
|
+
updatedFrontmatter.name = (frontmatter?.title) ?? this.extractNameFromPath(context.filePath);
|
|
125
|
+
}
|
|
126
|
+
if (needsDescription) {
|
|
127
|
+
updatedFrontmatter.description = this.extractDescriptionFromBody(context.content)
|
|
128
|
+
?? `${String(updatedFrontmatter.name)} agent`;
|
|
129
|
+
}
|
|
130
|
+
const updatedContent = this.serializeFrontmatter(updatedFrontmatter, context.content);
|
|
131
|
+
return (0, core_1.changed)(updatedContent);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Fail-safe: on parsing error, return original content
|
|
135
|
+
return (0, core_1.noChange)(context.content);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.ClaudeCodeTransformer = ClaudeCodeTransformer;
|
|
140
|
+
//# sourceMappingURL=claude-code-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-transformer.js","sourceRoot":"","sources":["../../../src/transform/transformers/claude-code-transformer.ts"],"names":[],"mappings":";;;AAgCA,kDAIiC;AAEjC;;GAEG;AACH,MAAa,qBAAqB;IAChC;;;;OAIG;IACK,mBAAmB,CAAC,QAAgB;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACxE,OAAO,QAAQ;aACZ,KAAK,CAAC,MAAM,CAAC;aACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aACzE,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,0BAA0B,CAAC,eAAuB;QACxD,MAAM,KAAK,GAAG,e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C,WAAW,KAAK,SAAS,CAAC;YAEvF,IAAI,CAAC,SAAS,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACpC,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,kBAAkB,GAA4B,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;YAEnG,IAAI,SAAS,EAAE,CAAC;gBACd,kBAAkB,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/F,CAAC;YACD,IAAI,gBAAgB,EAAE,CAAC;gBACrB,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC;uBAC5E,GAAG,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;YAClD,CAAC;YAED,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAEtF,OAAO,IAAA,cAAO,EAAC,cAAc,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;YACvD,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAjJD,sDAiJC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KiroTransformer — transforms content for Kiro target runtime.
|
|
3
|
+
*
|
|
4
|
+
* Kiro requires the agent name in frontmatter to be mandatory:
|
|
5
|
+
* https://kiro.dev/docs/chat/subagents/
|
|
6
|
+
*
|
|
7
|
+
* This transformer ensures that agent files have a 'name' field in their
|
|
8
|
+
* frontmatter. If missing, it derives the name from the title field or
|
|
9
|
+
* the filename.
|
|
10
|
+
*
|
|
11
|
+
* Idempotent: If the name field already exists, the content is unchanged.
|
|
12
|
+
* Fail-safe: On parsing errors, returns the original content.
|
|
13
|
+
*
|
|
14
|
+
* Ported unchanged from the reference branch's
|
|
15
|
+
* `app/src/transform/transformers/kiro-transformer.ts`.
|
|
16
|
+
* @module transform/transformers/kiro-transformer
|
|
17
|
+
*/
|
|
18
|
+
import type { ResourceTransformer, TransformContext, TransformResult } from '@ai-primitives-hub/core';
|
|
19
|
+
/**
|
|
20
|
+
* Transformer for Kiro-specific requirements.
|
|
21
|
+
*/
|
|
22
|
+
export declare class KiroTransformer implements ResourceTransformer {
|
|
23
|
+
/**
|
|
24
|
+
* Extract a name from a file path.
|
|
25
|
+
* @param filePath - Bundle-relative file path.
|
|
26
|
+
* @returns Derived name.
|
|
27
|
+
*/
|
|
28
|
+
private extractNameFromPath;
|
|
29
|
+
/**
|
|
30
|
+
* Serialize frontmatter back to the file content.
|
|
31
|
+
* @param frontmatter - Frontmatter object.
|
|
32
|
+
* @param originalContent - Original file content.
|
|
33
|
+
* @returns Updated content with new frontmatter.
|
|
34
|
+
*/
|
|
35
|
+
private serializeFrontmatter;
|
|
36
|
+
/**
|
|
37
|
+
* Convert an object to YAML string.
|
|
38
|
+
* Simple implementation for common cases.
|
|
39
|
+
* @param obj - Object to convert.
|
|
40
|
+
* @returns YAML string.
|
|
41
|
+
*/
|
|
42
|
+
private objectToYaml;
|
|
43
|
+
/**
|
|
44
|
+
* Transform file content for Kiro runtime.
|
|
45
|
+
* Only transforms agent files (agents/*.md).
|
|
46
|
+
* @param context - Transformation context.
|
|
47
|
+
* @returns TransformResult.
|
|
48
|
+
*/
|
|
49
|
+
transform(context: TransformContext): TransformResult;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=kiro-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiro-transformer.d.ts","sourceRoot":"","sources":["../../../src/transform/transformers/kiro-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAOjC;;GAEG;AACH,qBAAa,eAAgB,YAAW,mBAAmB;IACzD;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAyB5B;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IA0BpB;;;;;OAKG;IACI,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe;CA4C7D"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KiroTransformer = void 0;
|
|
4
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
5
|
+
/**
|
|
6
|
+
* Transformer for Kiro-specific requirements.
|
|
7
|
+
*/
|
|
8
|
+
class KiroTransformer {
|
|
9
|
+
/**
|
|
10
|
+
* Extract a name from a file path.
|
|
11
|
+
* @param filePath - Bundle-relative file path.
|
|
12
|
+
* @returns Derived name.
|
|
13
|
+
*/
|
|
14
|
+
extractNameFromPath(filePath) {
|
|
15
|
+
// Remove 'agents/' prefix and '.md' extension
|
|
16
|
+
const baseName = filePath.replace(/^agents\//, '').replace(/\.md$/, '');
|
|
17
|
+
// Convert kebab-case to title case
|
|
18
|
+
return baseName
|
|
19
|
+
.split(/[-_]/)
|
|
20
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
21
|
+
.join(' ');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serialize frontmatter back to the file content.
|
|
25
|
+
* @param frontmatter - Frontmatter object.
|
|
26
|
+
* @param originalContent - Original file content.
|
|
27
|
+
* @returns Updated content with new frontmatter.
|
|
28
|
+
*/
|
|
29
|
+
serializeFrontmatter(frontmatter, originalContent) {
|
|
30
|
+
const lines = originalContent.split('\n');
|
|
31
|
+
const frontmatterEndIndex = lines.indexOf('---');
|
|
32
|
+
if (frontmatterEndIndex === -1) {
|
|
33
|
+
// No frontmatter found, prepend it
|
|
34
|
+
const newYaml = this.objectToYaml(frontmatter);
|
|
35
|
+
return `---\n${newYaml}---\n${originalContent}`;
|
|
36
|
+
}
|
|
37
|
+
const secondSeparatorIndex = lines.findIndex((line, idx) => idx > frontmatterEndIndex && line === '---');
|
|
38
|
+
if (secondSeparatorIndex === -1) {
|
|
39
|
+
// Malformed frontmatter, return original
|
|
40
|
+
return originalContent;
|
|
41
|
+
}
|
|
42
|
+
// Replace existing frontmatter
|
|
43
|
+
const yamlContent = this.objectToYaml(frontmatter);
|
|
44
|
+
const beforeFrontmatter = lines.slice(0, frontmatterEndIndex + 1);
|
|
45
|
+
const afterFrontmatter = lines.slice(secondSeparatorIndex);
|
|
46
|
+
return [...beforeFrontmatter, yamlContent, ...afterFrontmatter].join('\n');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert an object to YAML string.
|
|
50
|
+
* Simple implementation for common cases.
|
|
51
|
+
* @param obj - Object to convert.
|
|
52
|
+
* @returns YAML string.
|
|
53
|
+
*/
|
|
54
|
+
objectToYaml(obj) {
|
|
55
|
+
const lines = [];
|
|
56
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
57
|
+
if (value === undefined) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'string') {
|
|
61
|
+
lines.push(`${key}: "${value}"`);
|
|
62
|
+
}
|
|
63
|
+
else if (typeof value === 'boolean' || value === null) {
|
|
64
|
+
lines.push(`${key}: ${value}`);
|
|
65
|
+
}
|
|
66
|
+
else if (Array.isArray(value)) {
|
|
67
|
+
lines.push(`${key}:`);
|
|
68
|
+
for (const item of value) {
|
|
69
|
+
if (typeof item === 'string') {
|
|
70
|
+
lines.push(` - "${item}"`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
lines.push(` - ${String(item)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
lines.push(`${key}: ${JSON.stringify(value)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return lines.join('\n');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Transform file content for Kiro runtime.
|
|
85
|
+
* Only transforms agent files (agents/*.md).
|
|
86
|
+
* @param context - Transformation context.
|
|
87
|
+
* @returns TransformResult.
|
|
88
|
+
*/
|
|
89
|
+
transform(context) {
|
|
90
|
+
// Only transform agent files
|
|
91
|
+
if (!context.filePath.startsWith('agents/')) {
|
|
92
|
+
return (0, core_1.noChange)(context.content);
|
|
93
|
+
}
|
|
94
|
+
// Skip non-markdown files
|
|
95
|
+
if (!context.filePath.endsWith('.md')) {
|
|
96
|
+
return (0, core_1.noChange)(context.content);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const frontmatter = (0, core_1.parseFrontmatter)(context.content);
|
|
100
|
+
// Check if frontmatter markers exist in content
|
|
101
|
+
const hasFrontmatterMarkers = context.content.startsWith('---')
|
|
102
|
+
&& context.content.includes('---', 3);
|
|
103
|
+
// If no frontmatter markers exist, return original content (fail-safe)
|
|
104
|
+
if (!hasFrontmatterMarkers) {
|
|
105
|
+
return (0, core_1.noChange)(context.content);
|
|
106
|
+
}
|
|
107
|
+
// If name field already exists, no transformation needed
|
|
108
|
+
if (frontmatter !== null && frontmatter.name !== undefined) {
|
|
109
|
+
return (0, core_1.noChange)(context.content);
|
|
110
|
+
}
|
|
111
|
+
// Derive name from title or filename
|
|
112
|
+
const derivedName = (frontmatter?.title) ?? this.extractNameFromPath(context.filePath);
|
|
113
|
+
// Update frontmatter with name field (create new if null)
|
|
114
|
+
const updatedFrontmatter = frontmatter === null
|
|
115
|
+
? { name: derivedName }
|
|
116
|
+
: { ...frontmatter, name: derivedName };
|
|
117
|
+
const updatedContent = this.serializeFrontmatter(updatedFrontmatter, context.content);
|
|
118
|
+
return (0, core_1.changed)(updatedContent);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// Fail-safe: on parsing error, return original content
|
|
122
|
+
// In production, this would log a warning
|
|
123
|
+
return (0, core_1.noChange)(context.content);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.KiroTransformer = KiroTransformer;
|
|
128
|
+
//# sourceMappingURL=kiro-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiro-transformer.js","sourceRoot":"","sources":["../../../src/transform/transformers/kiro-transformer.ts"],"names":[],"mappings":";;;AAsBA,kDAIiC;AAEjC;;GAEG;AACH,MAAa,eAAe;IAC1B;;;;OAIG;IACK,mBAAmB,CAAC,QAAgB;QAC1C,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACxE,mCAAmC;QACnC,OAAO,QAAQ;aACZ,KAAK,CAAC,MAAM,CAAC;aACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aACzE,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,oBAAoB,CAAC,WAAoC,EAAE,eAAuB;QACxF,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,mBAAmB,KAAK,CAAC,CAAC,EAAE,CAAC;YAC/B,mCAAmC;YACnC,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC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AC,KAAK,EAAE,CAAC,CAAC,CAAC;YAExC,uEAAuE;YACvE,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC3B,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC;YAED,yDAAyD;YACzD,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC3D,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC;YAED,qCAAqC;YACrC,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEvF,0DAA0D;YAC1D,MAAM,kBAAkB,GAAG,WAAW,KAAK,IAAI;gBAC7C,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE;gBACvB,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAEtF,OAAO,IAAA,cAAO,EAAC,cAAc,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;YACvD,0CAA0C;YAC1C,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAjID,0CAiIC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NoOpTransformer — pass-through transformer that performs no transformations.
|
|
3
|
+
*
|
|
4
|
+
* Used as the default/fallback for target types that don't have
|
|
5
|
+
* specific transformation requirements. Returns the original content
|
|
6
|
+
* unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Ported unchanged from the reference branch's
|
|
9
|
+
* `app/src/transform/transformers/noop-transformer.ts`.
|
|
10
|
+
* @module transform/transformers/noop-transformer
|
|
11
|
+
*/
|
|
12
|
+
import type { ResourceTransformer, TransformContext, TransformResult } from '@ai-primitives-hub/core';
|
|
13
|
+
/**
|
|
14
|
+
* Transformer that performs no transformations.
|
|
15
|
+
* Returns the original content unchanged with modified=false.
|
|
16
|
+
*/
|
|
17
|
+
export declare class NoOpTransformer implements ResourceTransformer {
|
|
18
|
+
/**
|
|
19
|
+
* Return the original content unchanged.
|
|
20
|
+
* @param context - Transformation context (ignored).
|
|
21
|
+
* @returns TransformResult with original content and modified=false.
|
|
22
|
+
*/
|
|
23
|
+
transform(context: TransformContext): TransformResult;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=noop-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop-transformer.d.ts","sourceRoot":"","sources":["../../../src/transform/transformers/noop-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAKjC;;;GAGG;AACH,qBAAa,eAAgB,YAAW,mBAAmB;IACzD;;;;OAIG;IACI,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe;CAG7D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoOpTransformer = void 0;
|
|
4
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
5
|
+
/**
|
|
6
|
+
* Transformer that performs no transformations.
|
|
7
|
+
* Returns the original content unchanged with modified=false.
|
|
8
|
+
*/
|
|
9
|
+
class NoOpTransformer {
|
|
10
|
+
/**
|
|
11
|
+
* Return the original content unchanged.
|
|
12
|
+
* @param context - Transformation context (ignored).
|
|
13
|
+
* @returns TransformResult with original content and modified=false.
|
|
14
|
+
*/
|
|
15
|
+
transform(context) {
|
|
16
|
+
return (0, core_1.noChange)(context.content);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.NoOpTransformer = NoOpTransformer;
|
|
20
|
+
//# sourceMappingURL=noop-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop-transformer.js","sourceRoot":"","sources":["../../../src/transform/transformers/noop-transformer.ts"],"names":[],"mappings":";;;AAgBA,kDAEiC;AAEjC;;;GAGG;AACH,MAAa,eAAe;IAC1B;;;;OAIG;IACI,SAAS,CAAC,OAAyB;QACxC,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACF;AATD,0CASC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WindsurfTransformer — transforms content for the Windsurf target runtime.
|
|
3
|
+
*
|
|
4
|
+
* Windsurf's modern rules system (`.windsurf/rules/*.md`, replacing the
|
|
5
|
+
* legacy single-file `.windsurfrules`) requires each rule file to declare
|
|
6
|
+
* an activation `trigger` in its YAML frontmatter — one of `always_on`,
|
|
7
|
+
* `model_decision`, `glob`, or `manual` — with `globs` required when
|
|
8
|
+
* `trigger` is `glob`:
|
|
9
|
+
* @see https://docs.windsurf.com/windsurf/cascade/memories#rules
|
|
10
|
+
*
|
|
11
|
+
* `infra`'s `writers/default-layouts.json` routes both `prompts/` and
|
|
12
|
+
* `instructions/` into Windsurf's single `rules/` directory, so both are
|
|
13
|
+
* in scope here (unlike Kiro's transformer, which only touches
|
|
14
|
+
* `agents/`).
|
|
15
|
+
*
|
|
16
|
+
* This transformer:
|
|
17
|
+
* - Maps an existing `applyTo` glob (the VS Code Copilot
|
|
18
|
+
* `*.instructions.md` convention this project's harvester already
|
|
19
|
+
* reads, see `infra/harvest/extractor.ts`) onto `trigger: glob` +
|
|
20
|
+
* `globs: [<applyTo>]`, preserving the original `applyTo` field.
|
|
21
|
+
* - Otherwise defaults to `trigger: model_decision`, deriving a
|
|
22
|
+
* `description` (required for the model to judge relevance) from an
|
|
23
|
+
* existing `title`/`description` field or the filename, same
|
|
24
|
+
* derivation as `KiroTransformer`'s `name`.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent: if `trigger` is already present, the content is
|
|
27
|
+
* unchanged — an explicit existing trigger is never second-guessed.
|
|
28
|
+
* Fail-safe: on parsing errors, returns the original content.
|
|
29
|
+
* @module transform/transformers/windsurf-transformer
|
|
30
|
+
*/
|
|
31
|
+
import type { ResourceTransformer, TransformContext, TransformResult } from '@ai-primitives-hub/core';
|
|
32
|
+
/**
|
|
33
|
+
* Transformer for Windsurf-specific requirements.
|
|
34
|
+
*/
|
|
35
|
+
export declare class WindsurfTransformer implements ResourceTransformer {
|
|
36
|
+
/**
|
|
37
|
+
* Derive a human-readable name from a bundle-relative file path.
|
|
38
|
+
* @param filePath - Bundle-relative file path.
|
|
39
|
+
* @returns Derived name.
|
|
40
|
+
*/
|
|
41
|
+
private extractNameFromPath;
|
|
42
|
+
/**
|
|
43
|
+
* Serialize frontmatter back to the file content.
|
|
44
|
+
* @param frontmatter - Frontmatter object.
|
|
45
|
+
* @param originalContent - Original file content.
|
|
46
|
+
* @returns Updated content with new frontmatter.
|
|
47
|
+
*/
|
|
48
|
+
private serializeFrontmatter;
|
|
49
|
+
/**
|
|
50
|
+
* Convert an object to YAML string. Simple implementation for common cases.
|
|
51
|
+
* @param obj - Object to convert.
|
|
52
|
+
* @returns YAML string.
|
|
53
|
+
*/
|
|
54
|
+
private objectToYaml;
|
|
55
|
+
/**
|
|
56
|
+
* Transform file content for the Windsurf runtime.
|
|
57
|
+
* Only transforms rule-routed files (prompts/*.md, instructions/*.md).
|
|
58
|
+
* @param context - Transformation context.
|
|
59
|
+
* @returns TransformResult.
|
|
60
|
+
*/
|
|
61
|
+
transform(context: TransformContext): TransformResult;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=windsurf-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windsurf-transformer.d.ts","sourceRoot":"","sources":["../../../src/transform/transformers/windsurf-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAOjC;;GAEG;AACH,qBAAa,mBAAoB,YAAW,mBAAmB;IAC7D;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IA0BpB;;;;;OAKG;IACI,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe;CA8C7D"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WindsurfTransformer = void 0;
|
|
4
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
5
|
+
/**
|
|
6
|
+
* Transformer for Windsurf-specific requirements.
|
|
7
|
+
*/
|
|
8
|
+
class WindsurfTransformer {
|
|
9
|
+
/**
|
|
10
|
+
* Derive a human-readable name from a bundle-relative file path.
|
|
11
|
+
* @param filePath - Bundle-relative file path.
|
|
12
|
+
* @returns Derived name.
|
|
13
|
+
*/
|
|
14
|
+
extractNameFromPath(filePath) {
|
|
15
|
+
const baseName = filePath.replace(/^(prompts|instructions)\//, '').replace(/\.md$/, '');
|
|
16
|
+
return baseName
|
|
17
|
+
.split(/[-_]/)
|
|
18
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
19
|
+
.join(' ');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Serialize frontmatter back to the file content.
|
|
23
|
+
* @param frontmatter - Frontmatter object.
|
|
24
|
+
* @param originalContent - Original file content.
|
|
25
|
+
* @returns Updated content with new frontmatter.
|
|
26
|
+
*/
|
|
27
|
+
serializeFrontmatter(frontmatter, originalContent) {
|
|
28
|
+
const lines = originalContent.split('\n');
|
|
29
|
+
const frontmatterEndIndex = lines.indexOf('---');
|
|
30
|
+
if (frontmatterEndIndex === -1) {
|
|
31
|
+
const newYaml = this.objectToYaml(frontmatter);
|
|
32
|
+
return `---\n${newYaml}---\n${originalContent}`;
|
|
33
|
+
}
|
|
34
|
+
const secondSeparatorIndex = lines.findIndex((line, idx) => idx > frontmatterEndIndex && line === '---');
|
|
35
|
+
if (secondSeparatorIndex === -1) {
|
|
36
|
+
// Malformed frontmatter, return original
|
|
37
|
+
return originalContent;
|
|
38
|
+
}
|
|
39
|
+
const yamlContent = this.objectToYaml(frontmatter);
|
|
40
|
+
const beforeFrontmatter = lines.slice(0, frontmatterEndIndex + 1);
|
|
41
|
+
const afterFrontmatter = lines.slice(secondSeparatorIndex);
|
|
42
|
+
return [...beforeFrontmatter, yamlContent, ...afterFrontmatter].join('\n');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert an object to YAML string. Simple implementation for common cases.
|
|
46
|
+
* @param obj - Object to convert.
|
|
47
|
+
* @returns YAML string.
|
|
48
|
+
*/
|
|
49
|
+
objectToYaml(obj) {
|
|
50
|
+
const lines = [];
|
|
51
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
52
|
+
if (value === undefined) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
lines.push(`${key}: "${value}"`);
|
|
57
|
+
}
|
|
58
|
+
else if (typeof value === 'boolean' || value === null) {
|
|
59
|
+
lines.push(`${key}: ${value}`);
|
|
60
|
+
}
|
|
61
|
+
else if (Array.isArray(value)) {
|
|
62
|
+
lines.push(`${key}:`);
|
|
63
|
+
for (const item of value) {
|
|
64
|
+
if (typeof item === 'string') {
|
|
65
|
+
lines.push(` - "${item}"`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
lines.push(` - ${String(item)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
lines.push(`${key}: ${JSON.stringify(value)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return lines.join('\n');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Transform file content for the Windsurf runtime.
|
|
80
|
+
* Only transforms rule-routed files (prompts/*.md, instructions/*.md).
|
|
81
|
+
* @param context - Transformation context.
|
|
82
|
+
* @returns TransformResult.
|
|
83
|
+
*/
|
|
84
|
+
transform(context) {
|
|
85
|
+
if (!context.filePath.startsWith('prompts/') && !context.filePath.startsWith('instructions/')) {
|
|
86
|
+
return (0, core_1.noChange)(context.content);
|
|
87
|
+
}
|
|
88
|
+
if (!context.filePath.endsWith('.md')) {
|
|
89
|
+
return (0, core_1.noChange)(context.content);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const frontmatter = (0, core_1.parseFrontmatter)(context.content);
|
|
93
|
+
const hasFrontmatterMarkers = context.content.startsWith('---')
|
|
94
|
+
&& context.content.includes('---', 3);
|
|
95
|
+
if (!hasFrontmatterMarkers) {
|
|
96
|
+
return (0, core_1.noChange)(context.content);
|
|
97
|
+
}
|
|
98
|
+
// If a trigger is already declared, respect it as-is.
|
|
99
|
+
if (frontmatter !== null && frontmatter.trigger !== undefined) {
|
|
100
|
+
return (0, core_1.noChange)(context.content);
|
|
101
|
+
}
|
|
102
|
+
const applyTo = frontmatter?.applyTo;
|
|
103
|
+
const updatedFrontmatter = frontmatter === null ? {} : { ...frontmatter };
|
|
104
|
+
if (typeof applyTo === 'string' && applyTo.length > 0) {
|
|
105
|
+
// A VS Code Copilot-style applyTo glob maps directly onto Windsurf's glob trigger.
|
|
106
|
+
updatedFrontmatter.trigger = 'glob';
|
|
107
|
+
updatedFrontmatter.globs = [applyTo];
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
updatedFrontmatter.trigger = 'model_decision';
|
|
111
|
+
if (updatedFrontmatter.description === undefined) {
|
|
112
|
+
updatedFrontmatter.description = (frontmatter?.title) ?? this.extractNameFromPath(context.filePath);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const updatedContent = this.serializeFrontmatter(updatedFrontmatter, context.content);
|
|
116
|
+
return (0, core_1.changed)(updatedContent);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Fail-safe: on parsing error, return original content
|
|
120
|
+
return (0, core_1.noChange)(context.content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.WindsurfTransformer = WindsurfTransformer;
|
|
125
|
+
//# sourceMappingURL=windsurf-transformer.js.map
|