@ironbackend/prompts 1.0.0
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/LICENSE +21 -0
- package/dist/builders/context-builder.d.ts +44 -0
- package/dist/builders/context-builder.d.ts.map +1 -0
- package/dist/builders/context-builder.js +101 -0
- package/dist/builders/context-builder.js.map +1 -0
- package/dist/builders/index.d.ts +8 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +21 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/builders/prompt-builder.d.ts +38 -0
- package/dist/builders/prompt-builder.d.ts.map +1 -0
- package/dist/builders/prompt-builder.js +100 -0
- package/dist/builders/prompt-builder.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +22 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/rule-enforcement.d.ts +22 -0
- package/dist/templates/rule-enforcement.d.ts.map +1 -0
- package/dist/templates/rule-enforcement.js +120 -0
- package/dist/templates/rule-enforcement.js.map +1 -0
- package/dist/templates/stack-selection.d.ts +18 -0
- package/dist/templates/stack-selection.d.ts.map +1 -0
- package/dist/templates/stack-selection.js +143 -0
- package/dist/templates/stack-selection.js.map +1 -0
- package/dist/templates/style-selection.d.ts +14 -0
- package/dist/templates/style-selection.d.ts.map +1 -0
- package/dist/templates/style-selection.js +78 -0
- package/dist/templates/style-selection.js.map +1 -0
- package/dist/templates/system.d.ts +20 -0
- package/dist/templates/system.d.ts.map +1 -0
- package/dist/templates/system.js +121 -0
- package/dist/templates/system.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 IronBackend Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Builder
|
|
3
|
+
* Build context objects for prompt generation
|
|
4
|
+
*/
|
|
5
|
+
import type { ArchitectureStyle, TechStack, RuleCategory, IronBackendConfig } from '@ironbackend/core';
|
|
6
|
+
export interface PromptContext {
|
|
7
|
+
style: ArchitectureStyle | null;
|
|
8
|
+
stack: TechStack | null;
|
|
9
|
+
enabledRules: RuleCategory[];
|
|
10
|
+
securityEnabled: boolean;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build context from IronBackend config file
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildContextFromConfig(config: IronBackendConfig): PromptContext;
|
|
17
|
+
/**
|
|
18
|
+
* Build context interactively
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildContext(options: {
|
|
21
|
+
styleId?: string;
|
|
22
|
+
stackId?: string;
|
|
23
|
+
ruleCategories?: RuleCategory[];
|
|
24
|
+
}): PromptContext;
|
|
25
|
+
/**
|
|
26
|
+
* Validate context completeness
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateContext(context: PromptContext): {
|
|
29
|
+
valid: boolean;
|
|
30
|
+
errors: string[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Get context summary for display
|
|
34
|
+
*/
|
|
35
|
+
export declare function getContextSummary(context: PromptContext): string;
|
|
36
|
+
/**
|
|
37
|
+
* Serialize context for storage
|
|
38
|
+
*/
|
|
39
|
+
export declare function serializeContext(context: PromptContext): string;
|
|
40
|
+
/**
|
|
41
|
+
* Deserialize context from storage
|
|
42
|
+
*/
|
|
43
|
+
export declare function deserializeContext(json: string): PromptContext;
|
|
44
|
+
//# sourceMappingURL=context-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../src/builders/context-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGvG,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAQ/E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;CACnC,GAAG,aAAa,CAahB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmB5F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAehE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAQ/D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAU9D"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context Builder
|
|
4
|
+
* Build context objects for prompt generation
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.buildContextFromConfig = buildContextFromConfig;
|
|
8
|
+
exports.buildContext = buildContext;
|
|
9
|
+
exports.validateContext = validateContext;
|
|
10
|
+
exports.getContextSummary = getContextSummary;
|
|
11
|
+
exports.serializeContext = serializeContext;
|
|
12
|
+
exports.deserializeContext = deserializeContext;
|
|
13
|
+
const core_1 = require("@ironbackend/core");
|
|
14
|
+
/**
|
|
15
|
+
* Build context from IronBackend config file
|
|
16
|
+
*/
|
|
17
|
+
function buildContextFromConfig(config) {
|
|
18
|
+
return {
|
|
19
|
+
style: config.style ? (0, core_1.getStyle)(config.style) ?? null : null,
|
|
20
|
+
stack: config.stack ? (0, core_1.getStack)(config.stack) ?? null : null,
|
|
21
|
+
enabledRules: config.rules.enabled,
|
|
22
|
+
securityEnabled: true,
|
|
23
|
+
metadata: {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build context interactively
|
|
28
|
+
*/
|
|
29
|
+
function buildContext(options) {
|
|
30
|
+
const allCategories = [
|
|
31
|
+
'API', 'DOMAIN', 'ERROR_HANDLING', 'TRANSACTIONS',
|
|
32
|
+
'DATA_ACCESS', 'NAMING', 'VALIDATION', 'ASYNC'
|
|
33
|
+
];
|
|
34
|
+
return {
|
|
35
|
+
style: options.styleId ? (0, core_1.getStyle)(options.styleId) ?? null : null,
|
|
36
|
+
stack: options.stackId ? (0, core_1.getStack)(options.stackId) ?? null : null,
|
|
37
|
+
enabledRules: options.ruleCategories ?? allCategories,
|
|
38
|
+
securityEnabled: true,
|
|
39
|
+
metadata: {}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate context completeness
|
|
44
|
+
*/
|
|
45
|
+
function validateContext(context) {
|
|
46
|
+
const errors = [];
|
|
47
|
+
if (!context.style) {
|
|
48
|
+
errors.push('No architecture style selected');
|
|
49
|
+
}
|
|
50
|
+
if (!context.stack) {
|
|
51
|
+
errors.push('No tech stack selected');
|
|
52
|
+
}
|
|
53
|
+
if (context.enabledRules.length === 0) {
|
|
54
|
+
errors.push('No rule categories enabled');
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
valid: errors.length === 0,
|
|
58
|
+
errors
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get context summary for display
|
|
63
|
+
*/
|
|
64
|
+
function getContextSummary(context) {
|
|
65
|
+
const lines = [];
|
|
66
|
+
if (context.style) {
|
|
67
|
+
lines.push(`Style: ${context.style.name}`);
|
|
68
|
+
}
|
|
69
|
+
if (context.stack) {
|
|
70
|
+
lines.push(`Stack: ${context.stack.name}`);
|
|
71
|
+
}
|
|
72
|
+
lines.push(`Rules: ${context.enabledRules.length} categories enabled`);
|
|
73
|
+
lines.push(`Security: ${context.securityEnabled ? 'enabled' : 'disabled'}`);
|
|
74
|
+
return lines.join('\n');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Serialize context for storage
|
|
78
|
+
*/
|
|
79
|
+
function serializeContext(context) {
|
|
80
|
+
return JSON.stringify({
|
|
81
|
+
styleId: context.style?.id,
|
|
82
|
+
stackId: context.stack?.id,
|
|
83
|
+
enabledRules: context.enabledRules,
|
|
84
|
+
securityEnabled: context.securityEnabled,
|
|
85
|
+
metadata: context.metadata
|
|
86
|
+
}, null, 2);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Deserialize context from storage
|
|
90
|
+
*/
|
|
91
|
+
function deserializeContext(json) {
|
|
92
|
+
const data = JSON.parse(json);
|
|
93
|
+
return {
|
|
94
|
+
style: data.styleId ? (0, core_1.getStyle)(data.styleId) ?? null : null,
|
|
95
|
+
stack: data.stackId ? (0, core_1.getStack)(data.stackId) ?? null : null,
|
|
96
|
+
enabledRules: data.enabledRules ?? [],
|
|
97
|
+
securityEnabled: data.securityEnabled ?? true,
|
|
98
|
+
metadata: data.metadata ?? {}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=context-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-builder.js","sourceRoot":"","sources":["../../src/builders/context-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAgBH,wDAQC;AAKD,oCAiBC;AAKD,0CAmBC;AAKD,8CAeC;AAKD,4CAQC;AAKD,gDAUC;AAnHD,4CAAuD;AAUvD;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAAyB;IAC5D,OAAO;QACH,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI;QAC3D,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,MAAM,CAAC,KAAK,C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,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI;QAC3D,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI;QAC3D,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE;QACrC,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,IAAI;QAC7C,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;KAChC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builders Export
|
|
3
|
+
*/
|
|
4
|
+
export { formatFolderStructure, formatFolderTree, buildPrompt, buildPromptSections, estimateTokenCount, truncatePrompt } from './prompt-builder.js';
|
|
5
|
+
export type { PromptBuilderConfig } from './prompt-builder.js';
|
|
6
|
+
export { buildContextFromConfig, buildContext, validateContext, getContextSummary, serializeContext, deserializeContext } from './context-builder.js';
|
|
7
|
+
export type { PromptContext } from './context-builder.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACH,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Builders Export
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deserializeContext = exports.serializeContext = exports.getContextSummary = exports.validateContext = exports.buildContext = exports.buildContextFromConfig = exports.truncatePrompt = exports.estimateTokenCount = exports.buildPromptSections = exports.buildPrompt = exports.formatFolderTree = exports.formatFolderStructure = void 0;
|
|
7
|
+
var prompt_builder_js_1 = require("./prompt-builder.js");
|
|
8
|
+
Object.defineProperty(exports, "formatFolderStructure", { enumerable: true, get: function () { return prompt_builder_js_1.formatFolderStructure; } });
|
|
9
|
+
Object.defineProperty(exports, "formatFolderTree", { enumerable: true, get: function () { return prompt_builder_js_1.formatFolderTree; } });
|
|
10
|
+
Object.defineProperty(exports, "buildPrompt", { enumerable: true, get: function () { return prompt_builder_js_1.buildPrompt; } });
|
|
11
|
+
Object.defineProperty(exports, "buildPromptSections", { enumerable: true, get: function () { return prompt_builder_js_1.buildPromptSections; } });
|
|
12
|
+
Object.defineProperty(exports, "estimateTokenCount", { enumerable: true, get: function () { return prompt_builder_js_1.estimateTokenCount; } });
|
|
13
|
+
Object.defineProperty(exports, "truncatePrompt", { enumerable: true, get: function () { return prompt_builder_js_1.truncatePrompt; } });
|
|
14
|
+
var context_builder_js_1 = require("./context-builder.js");
|
|
15
|
+
Object.defineProperty(exports, "buildContextFromConfig", { enumerable: true, get: function () { return context_builder_js_1.buildContextFromConfig; } });
|
|
16
|
+
Object.defineProperty(exports, "buildContext", { enumerable: true, get: function () { return context_builder_js_1.buildContext; } });
|
|
17
|
+
Object.defineProperty(exports, "validateContext", { enumerable: true, get: function () { return context_builder_js_1.validateContext; } });
|
|
18
|
+
Object.defineProperty(exports, "getContextSummary", { enumerable: true, get: function () { return context_builder_js_1.getContextSummary; } });
|
|
19
|
+
Object.defineProperty(exports, "serializeContext", { enumerable: true, get: function () { return context_builder_js_1.serializeContext; } });
|
|
20
|
+
Object.defineProperty(exports, "deserializeContext", { enumerable: true, get: function () { return context_builder_js_1.deserializeContext; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAO6B;AANzB,0HAAA,qBAAqB,OAAA;AACrB,qHAAA,gBAAgB,OAAA;AAChB,gHAAA,WAAW,OAAA;AACX,wHAAA,mBAAmB,OAAA;AACnB,uHAAA,kBAAkB,OAAA;AAClB,mHAAA,cAAc,OAAA;AAIlB,2DAO8B;AAN1B,4HAAA,sBAAsB,OAAA;AACtB,kHAAA,YAAY,OAAA;AACZ,qHAAA,eAAe,OAAA;AACf,uHAAA,iBAAiB,OAAA;AACjB,sHAAA,gBAAgB,OAAA;AAChB,wHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Builder
|
|
3
|
+
* Utilities for building and composing prompts
|
|
4
|
+
*/
|
|
5
|
+
import type { FolderNode, RuleCategory } from '@ironbackend/core';
|
|
6
|
+
/**
|
|
7
|
+
* Format folder structure for display in prompts
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatFolderStructure(node: FolderNode, indent?: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Format folder structure as tree (without emojis)
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatFolderTree(node: FolderNode, indent?: number, isLast?: boolean): string;
|
|
14
|
+
export interface PromptBuilderConfig {
|
|
15
|
+
styleId: string;
|
|
16
|
+
stackId: string;
|
|
17
|
+
ruleCategories?: RuleCategory[];
|
|
18
|
+
includeRules?: boolean;
|
|
19
|
+
includeSecurity?: boolean;
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a complete prompt from configuration
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildPrompt(config: PromptBuilderConfig): string;
|
|
26
|
+
/**
|
|
27
|
+
* Build modular prompt sections (for composability)
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildPromptSections(config: PromptBuilderConfig): Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Count tokens (rough estimate)
|
|
32
|
+
*/
|
|
33
|
+
export declare function estimateTokenCount(text: string): number;
|
|
34
|
+
/**
|
|
35
|
+
* Truncate prompt to fit token limit
|
|
36
|
+
*/
|
|
37
|
+
export declare function truncatePrompt(prompt: string, maxTokens: number): string;
|
|
38
|
+
//# sourceMappingURL=prompt-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/builders/prompt-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIlE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAclF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,MAAU,EAAE,MAAM,GAAE,OAAc,GAAG,MAAM,CAerG;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAmB/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcvF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUxE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt Builder
|
|
4
|
+
* Utilities for building and composing prompts
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.formatFolderStructure = formatFolderStructure;
|
|
8
|
+
exports.formatFolderTree = formatFolderTree;
|
|
9
|
+
exports.buildPrompt = buildPrompt;
|
|
10
|
+
exports.buildPromptSections = buildPromptSections;
|
|
11
|
+
exports.estimateTokenCount = estimateTokenCount;
|
|
12
|
+
exports.truncatePrompt = truncatePrompt;
|
|
13
|
+
const core_1 = require("@ironbackend/core");
|
|
14
|
+
const index_js_1 = require("../templates/index.js");
|
|
15
|
+
/**
|
|
16
|
+
* Format folder structure for display in prompts
|
|
17
|
+
*/
|
|
18
|
+
function formatFolderStructure(node, indent = 0) {
|
|
19
|
+
const prefix = ' '.repeat(indent);
|
|
20
|
+
const icon = node.type === 'folder' ? '📁' : '📄';
|
|
21
|
+
const desc = node.description ? ` # ${node.description}` : '';
|
|
22
|
+
let result = `${prefix}${icon} ${node.name}${desc}`;
|
|
23
|
+
if (node.children) {
|
|
24
|
+
for (const child of node.children) {
|
|
25
|
+
result += '\n' + formatFolderStructure(child, indent + 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Format folder structure as tree (without emojis)
|
|
32
|
+
*/
|
|
33
|
+
function formatFolderTree(node, indent = 0, isLast = true) {
|
|
34
|
+
const prefix = indent === 0 ? '' : (isLast ? '└── ' : '├── ');
|
|
35
|
+
const linePrefix = indent === 0 ? '' : '│ '.repeat(indent - 1) + prefix;
|
|
36
|
+
let result = `${linePrefix}${node.name}/`;
|
|
37
|
+
if (node.children) {
|
|
38
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
39
|
+
const child = node.children[i];
|
|
40
|
+
const childIsLast = i === node.children.length - 1;
|
|
41
|
+
result += '\n' + formatFolderTree(child, indent + 1, childIsLast);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build a complete prompt from configuration
|
|
48
|
+
*/
|
|
49
|
+
function buildPrompt(config) {
|
|
50
|
+
const style = (0, core_1.getStyle)(config.styleId);
|
|
51
|
+
const stack = (0, core_1.getStack)(config.stackId);
|
|
52
|
+
if (!style || !stack) {
|
|
53
|
+
throw new Error(`Invalid style (${config.styleId}) or stack (${config.stackId})`);
|
|
54
|
+
}
|
|
55
|
+
const sections = [];
|
|
56
|
+
// System prompt
|
|
57
|
+
sections.push((0, index_js_1.generateSystemPrompt)({
|
|
58
|
+
style,
|
|
59
|
+
stack,
|
|
60
|
+
includeRules: config.includeRules ?? true,
|
|
61
|
+
includeSecurity: config.includeSecurity ?? true
|
|
62
|
+
}));
|
|
63
|
+
return sections.join('\n\n---\n\n');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build modular prompt sections (for composability)
|
|
67
|
+
*/
|
|
68
|
+
function buildPromptSections(config) {
|
|
69
|
+
const style = (0, core_1.getStyle)(config.styleId);
|
|
70
|
+
const stack = (0, core_1.getStack)(config.stackId);
|
|
71
|
+
if (!style || !stack) {
|
|
72
|
+
throw new Error(`Invalid style (${config.styleId}) or stack (${config.stackId})`);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
style: (0, index_js_1.generateStylePrompt)(style),
|
|
76
|
+
stack: (0, index_js_1.generateStackPrompt)(stack),
|
|
77
|
+
rules: (0, index_js_1.generateRuleEnforcementPrompt)(config.ruleCategories),
|
|
78
|
+
combined: buildPrompt(config)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Count tokens (rough estimate)
|
|
83
|
+
*/
|
|
84
|
+
function estimateTokenCount(text) {
|
|
85
|
+
// Rough estimate: 1 token ≈ 4 characters
|
|
86
|
+
return Math.ceil(text.length / 4);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Truncate prompt to fit token limit
|
|
90
|
+
*/
|
|
91
|
+
function truncatePrompt(prompt, maxTokens) {
|
|
92
|
+
const currentTokens = estimateTokenCount(prompt);
|
|
93
|
+
if (currentTokens <= maxTokens) {
|
|
94
|
+
return prompt;
|
|
95
|
+
}
|
|
96
|
+
// Calculate how many characters to keep
|
|
97
|
+
const targetChars = maxTokens * 4;
|
|
98
|
+
return prompt.slice(0, targetChars) + '\n\n[... truncated for token limit ...]';
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/builders/prompt-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AASH,sDAcC;AAKD,4CAeC;AAcD,kCAmBC;AAKD,kDAcC;AAKD,gDAGC;AAKD,wCAUC;AAnHD,4CAAuD;AACvD,oDAAsI;AAEtI;;GAEG;AACH,SAAgB,qBAAqB,CAAC,IAAgB,EAAE,SAAiB,CAAC;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9D,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;IA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;GAEG;AACH,SAAgB,kBAAkB,CAAC,IAAY;IAC3C,yCAAyC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,SAAiB;IAC5D,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,wCAAwC;IACxC,MAAM,WAAW,GAAG,SAAS,GAAG,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,yCAAyC,CAAC;AACpF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ironbackend/prompts
|
|
3
|
+
* AI Prompt Templates for IronBackend
|
|
4
|
+
*/
|
|
5
|
+
export { generateSystemPrompt, generateMinimalSystemPrompt, generateStylePrompt, generateStyleComparisonPrompt, generateStackPrompt, generateStackCodeStyle, generateStackComparisonPrompt, generateRuleEnforcementPrompt, generateCategoryEnforcementPrompt, generateCompactRulesPrompt, generateRuleExamplesPrompt } from './templates/index.js';
|
|
6
|
+
export type { SystemPromptContext } from './templates/index.js';
|
|
7
|
+
export { formatFolderStructure, formatFolderTree, buildPrompt, buildPromptSections, estimateTokenCount, truncatePrompt, buildContextFromConfig, buildContext, validateContext, getContextSummary, serializeContext, deserializeContext } from './builders/index.js';
|
|
8
|
+
export type { PromptBuilderConfig, PromptContext } from './builders/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Quick prompt generation
|
|
11
|
+
*/
|
|
12
|
+
export declare function quickPrompt(styleId: string, stackId: string): string;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,6BAA6B,EAC7B,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI9E;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @ironbackend/prompts
|
|
4
|
+
* AI Prompt Templates for IronBackend
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.deserializeContext = exports.serializeContext = exports.getContextSummary = exports.validateContext = exports.buildContext = exports.buildContextFromConfig = exports.truncatePrompt = exports.estimateTokenCount = exports.buildPromptSections = exports.buildPrompt = exports.formatFolderTree = exports.formatFolderStructure = exports.generateRuleExamplesPrompt = exports.generateCompactRulesPrompt = exports.generateCategoryEnforcementPrompt = exports.generateRuleEnforcementPrompt = exports.generateStackComparisonPrompt = exports.generateStackCodeStyle = exports.generateStackPrompt = exports.generateStyleComparisonPrompt = exports.generateStylePrompt = exports.generateMinimalSystemPrompt = exports.generateSystemPrompt = void 0;
|
|
8
|
+
exports.quickPrompt = quickPrompt;
|
|
9
|
+
// Templates
|
|
10
|
+
var index_js_1 = require("./templates/index.js");
|
|
11
|
+
Object.defineProperty(exports, "generateSystemPrompt", { enumerable: true, get: function () { return index_js_1.generateSystemPrompt; } });
|
|
12
|
+
Object.defineProperty(exports, "generateMinimalSystemPrompt", { enumerable: true, get: function () { return index_js_1.generateMinimalSystemPrompt; } });
|
|
13
|
+
Object.defineProperty(exports, "generateStylePrompt", { enumerable: true, get: function () { return index_js_1.generateStylePrompt; } });
|
|
14
|
+
Object.defineProperty(exports, "generateStyleComparisonPrompt", { enumerable: true, get: function () { return index_js_1.generateStyleComparisonPrompt; } });
|
|
15
|
+
Object.defineProperty(exports, "generateStackPrompt", { enumerable: true, get: function () { return index_js_1.generateStackPrompt; } });
|
|
16
|
+
Object.defineProperty(exports, "generateStackCodeStyle", { enumerable: true, get: function () { return index_js_1.generateStackCodeStyle; } });
|
|
17
|
+
Object.defineProperty(exports, "generateStackComparisonPrompt", { enumerable: true, get: function () { return index_js_1.generateStackComparisonPrompt; } });
|
|
18
|
+
Object.defineProperty(exports, "generateRuleEnforcementPrompt", { enumerable: true, get: function () { return index_js_1.generateRuleEnforcementPrompt; } });
|
|
19
|
+
Object.defineProperty(exports, "generateCategoryEnforcementPrompt", { enumerable: true, get: function () { return index_js_1.generateCategoryEnforcementPrompt; } });
|
|
20
|
+
Object.defineProperty(exports, "generateCompactRulesPrompt", { enumerable: true, get: function () { return index_js_1.generateCompactRulesPrompt; } });
|
|
21
|
+
Object.defineProperty(exports, "generateRuleExamplesPrompt", { enumerable: true, get: function () { return index_js_1.generateRuleExamplesPrompt; } });
|
|
22
|
+
// Builders
|
|
23
|
+
var index_js_2 = require("./builders/index.js");
|
|
24
|
+
Object.defineProperty(exports, "formatFolderStructure", { enumerable: true, get: function () { return index_js_2.formatFolderStructure; } });
|
|
25
|
+
Object.defineProperty(exports, "formatFolderTree", { enumerable: true, get: function () { return index_js_2.formatFolderTree; } });
|
|
26
|
+
Object.defineProperty(exports, "buildPrompt", { enumerable: true, get: function () { return index_js_2.buildPrompt; } });
|
|
27
|
+
Object.defineProperty(exports, "buildPromptSections", { enumerable: true, get: function () { return index_js_2.buildPromptSections; } });
|
|
28
|
+
Object.defineProperty(exports, "estimateTokenCount", { enumerable: true, get: function () { return index_js_2.estimateTokenCount; } });
|
|
29
|
+
Object.defineProperty(exports, "truncatePrompt", { enumerable: true, get: function () { return index_js_2.truncatePrompt; } });
|
|
30
|
+
Object.defineProperty(exports, "buildContextFromConfig", { enumerable: true, get: function () { return index_js_2.buildContextFromConfig; } });
|
|
31
|
+
Object.defineProperty(exports, "buildContext", { enumerable: true, get: function () { return index_js_2.buildContext; } });
|
|
32
|
+
Object.defineProperty(exports, "validateContext", { enumerable: true, get: function () { return index_js_2.validateContext; } });
|
|
33
|
+
Object.defineProperty(exports, "getContextSummary", { enumerable: true, get: function () { return index_js_2.getContextSummary; } });
|
|
34
|
+
Object.defineProperty(exports, "serializeContext", { enumerable: true, get: function () { return index_js_2.serializeContext; } });
|
|
35
|
+
Object.defineProperty(exports, "deserializeContext", { enumerable: true, get: function () { return index_js_2.deserializeContext; } });
|
|
36
|
+
const index_js_3 = require("./builders/index.js");
|
|
37
|
+
/**
|
|
38
|
+
* Quick prompt generation
|
|
39
|
+
*/
|
|
40
|
+
function quickPrompt(styleId, stackId) {
|
|
41
|
+
return (0, index_js_3.buildPrompt)({ styleId, stackId });
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwCH,kCAEC;AAxCD,YAAY;AACZ,iDAY8B;AAX1B,gHAAA,oBAAoB,OAAA;AACpB,uHAAA,2BAA2B,OAAA;AAC3B,+GAAA,mBAAmB,OAAA;AACnB,yHAAA,6BAA6B,OAAA;AAC7B,+GAAA,mBAAmB,OAAA;AACnB,kHAAA,sBAAsB,OAAA;AACtB,yHAAA,6BAA6B,OAAA;AAC7B,yHAAA,6BAA6B,OAAA;AAC7B,6HAAA,iCAAiC,OAAA;AACjC,sHAAA,0BAA0B,OAAA;AAC1B,sHAAA,0BAA0B,OAAA;AAI9B,WAAW;AACX,gDAa6B;AAZzB,iHAAA,qBAAqB,OAAA;AACrB,4GAAA,gBAAgB,OAAA;AAChB,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,kHAAA,sBAAsB,OAAA;AACtB,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,6GAAA,iBAAiB,OAAA;AACjB,4GAAA,gBAAgB,OAAA;AAChB,8GAAA,kBAAkB,OAAA;AAItB,kDAAkE;AAElE;;GAEG;AACH,SAAgB,WAAW,CAAC,OAAe,EAAE,OAAe;IACxD,OAAO,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Templates Export
|
|
3
|
+
*/
|
|
4
|
+
export { generateSystemPrompt, generateMinimalSystemPrompt } from './system.js';
|
|
5
|
+
export type { SystemPromptContext } from './system.js';
|
|
6
|
+
export { generateStylePrompt, generateStyleComparisonPrompt } from './style-selection.js';
|
|
7
|
+
export { generateStackPrompt, generateStackCodeStyle, generateStackComparisonPrompt } from './stack-selection.js';
|
|
8
|
+
export { generateRuleEnforcementPrompt, generateCategoryEnforcementPrompt, generateCompactRulesPrompt, generateRuleExamplesPrompt } from './rule-enforcement.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,EACH,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt Templates Export
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateRuleExamplesPrompt = exports.generateCompactRulesPrompt = exports.generateCategoryEnforcementPrompt = exports.generateRuleEnforcementPrompt = exports.generateStackComparisonPrompt = exports.generateStackCodeStyle = exports.generateStackPrompt = exports.generateStyleComparisonPrompt = exports.generateStylePrompt = exports.generateMinimalSystemPrompt = exports.generateSystemPrompt = void 0;
|
|
7
|
+
var system_js_1 = require("./system.js");
|
|
8
|
+
Object.defineProperty(exports, "generateSystemPrompt", { enumerable: true, get: function () { return system_js_1.generateSystemPrompt; } });
|
|
9
|
+
Object.defineProperty(exports, "generateMinimalSystemPrompt", { enumerable: true, get: function () { return system_js_1.generateMinimalSystemPrompt; } });
|
|
10
|
+
var style_selection_js_1 = require("./style-selection.js");
|
|
11
|
+
Object.defineProperty(exports, "generateStylePrompt", { enumerable: true, get: function () { return style_selection_js_1.generateStylePrompt; } });
|
|
12
|
+
Object.defineProperty(exports, "generateStyleComparisonPrompt", { enumerable: true, get: function () { return style_selection_js_1.generateStyleComparisonPrompt; } });
|
|
13
|
+
var stack_selection_js_1 = require("./stack-selection.js");
|
|
14
|
+
Object.defineProperty(exports, "generateStackPrompt", { enumerable: true, get: function () { return stack_selection_js_1.generateStackPrompt; } });
|
|
15
|
+
Object.defineProperty(exports, "generateStackCodeStyle", { enumerable: true, get: function () { return stack_selection_js_1.generateStackCodeStyle; } });
|
|
16
|
+
Object.defineProperty(exports, "generateStackComparisonPrompt", { enumerable: true, get: function () { return stack_selection_js_1.generateStackComparisonPrompt; } });
|
|
17
|
+
var rule_enforcement_js_1 = require("./rule-enforcement.js");
|
|
18
|
+
Object.defineProperty(exports, "generateRuleEnforcementPrompt", { enumerable: true, get: function () { return rule_enforcement_js_1.generateRuleEnforcementPrompt; } });
|
|
19
|
+
Object.defineProperty(exports, "generateCategoryEnforcementPrompt", { enumerable: true, get: function () { return rule_enforcement_js_1.generateCategoryEnforcementPrompt; } });
|
|
20
|
+
Object.defineProperty(exports, "generateCompactRulesPrompt", { enumerable: true, get: function () { return rule_enforcement_js_1.generateCompactRulesPrompt; } });
|
|
21
|
+
Object.defineProperty(exports, "generateRuleExamplesPrompt", { enumerable: true, get: function () { return rule_enforcement_js_1.generateRuleExamplesPrompt; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yCAAgF;AAAvE,iHAAA,oBAAoB,OAAA;AAAE,wHAAA,2BAA2B,OAAA;AAG1D,2DAA0F;AAAjF,yHAAA,mBAAmB,OAAA;AAAE,mIAAA,6BAA6B,OAAA;AAE3D,2DAAkH;AAAzG,yHAAA,mBAAmB,OAAA;AAAE,4HAAA,sBAAsB,OAAA;AAAE,mIAAA,6BAA6B,OAAA;AAEnF,6DAK+B;AAJ3B,oIAAA,6BAA6B,OAAA;AAC7B,wIAAA,iCAAiC,OAAA;AACjC,iIAAA,0BAA0B,OAAA;AAC1B,iIAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Enforcement Prompt Template
|
|
3
|
+
* Prompts for enforcing design rules
|
|
4
|
+
*/
|
|
5
|
+
import type { DesignRule, RuleCategory } from '@ironbackend/core';
|
|
6
|
+
/**
|
|
7
|
+
* Generate rule enforcement prompt
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateRuleEnforcementPrompt(categories?: RuleCategory[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a focused enforcement prompt for specific categories
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateCategoryEnforcementPrompt(category: RuleCategory): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a compact rules summary for limited context
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateCompactRulesPrompt(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate rule violation examples
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateRuleExamplesPrompt(rules: DesignRule[]): string;
|
|
22
|
+
//# sourceMappingURL=rule-enforcement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-enforcement.d.ts","sourceRoot":"","sources":["../../src/templates/rule-enforcement.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGlE;;GAEG;AACH,wBAAgB,6BAA6B,CACzC,UAAU,GAAE,YAAY,EAAuD,GAChF,MAAM,CAuCR;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAgBhF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAMnD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CA2BtE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rule Enforcement Prompt Template
|
|
4
|
+
* Prompts for enforcing design rules
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateRuleEnforcementPrompt = generateRuleEnforcementPrompt;
|
|
8
|
+
exports.generateCategoryEnforcementPrompt = generateCategoryEnforcementPrompt;
|
|
9
|
+
exports.generateCompactRulesPrompt = generateCompactRulesPrompt;
|
|
10
|
+
exports.generateRuleExamplesPrompt = generateRuleExamplesPrompt;
|
|
11
|
+
const core_1 = require("@ironbackend/core");
|
|
12
|
+
/**
|
|
13
|
+
* Generate rule enforcement prompt
|
|
14
|
+
*/
|
|
15
|
+
function generateRuleEnforcementPrompt(categories = ['API', 'DOMAIN', 'ERROR_HANDLING', 'DATA_ACCESS']) {
|
|
16
|
+
const sections = [];
|
|
17
|
+
sections.push(`# Design Rules Enforcement
|
|
18
|
+
|
|
19
|
+
## Severity Levels
|
|
20
|
+
|
|
21
|
+
- **ERROR**: MUST be followed. Reject code that violates these rules.
|
|
22
|
+
- **WARN**: SHOULD be followed. Recommend but allow exceptions with justification.
|
|
23
|
+
|
|
24
|
+
---`);
|
|
25
|
+
// Add rules by category
|
|
26
|
+
for (const category of categories) {
|
|
27
|
+
const rules = core_1.rulesByCategory[category];
|
|
28
|
+
if (rules && rules.length > 0) {
|
|
29
|
+
sections.push(`## ${formatCategoryName(category)} Rules
|
|
30
|
+
|
|
31
|
+
${(0, core_1.formatRulesForPrompt)(rules)}
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Add validation checklist
|
|
36
|
+
sections.push(`---
|
|
37
|
+
|
|
38
|
+
## Validation Checklist
|
|
39
|
+
|
|
40
|
+
Before completing any code generation, verify:
|
|
41
|
+
|
|
42
|
+
- [ ] All ERROR-severity rules are satisfied
|
|
43
|
+
- [ ] WARN-severity rules are considered (document exceptions)
|
|
44
|
+
- [ ] No anti-patterns present
|
|
45
|
+
- [ ] Proper error handling implemented
|
|
46
|
+
- [ ] Input validation at boundaries
|
|
47
|
+
- [ ] Logging included for observability
|
|
48
|
+
- [ ] Tests cover the new code`);
|
|
49
|
+
return sections.join('\n\n');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate a focused enforcement prompt for specific categories
|
|
53
|
+
*/
|
|
54
|
+
function generateCategoryEnforcementPrompt(category) {
|
|
55
|
+
const rules = core_1.rulesByCategory[category] || [];
|
|
56
|
+
const errorRules = rules.filter(r => r.severity === 'ERROR');
|
|
57
|
+
const warnRules = rules.filter(r => r.severity === 'WARN');
|
|
58
|
+
return `# ${formatCategoryName(category)} Rules
|
|
59
|
+
|
|
60
|
+
## MUST Follow (ERROR severity)
|
|
61
|
+
|
|
62
|
+
${errorRules.map(r => `### ${r.id}: ${r.rule}
|
|
63
|
+
${r.rationale ? `*Rationale: ${r.rationale}*` : ''}`).join('\n\n')}
|
|
64
|
+
|
|
65
|
+
## SHOULD Follow (WARN severity)
|
|
66
|
+
|
|
67
|
+
${warnRules.map(r => `### ${r.id}: ${r.rule}
|
|
68
|
+
${r.rationale ? `*Rationale: ${r.rationale}*` : ''}`).join('\n\n')}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generate a compact rules summary for limited context
|
|
72
|
+
*/
|
|
73
|
+
function generateCompactRulesPrompt() {
|
|
74
|
+
const errorRules = (0, core_1.getErrorRules)();
|
|
75
|
+
return `# Critical Design Rules (Must Follow)
|
|
76
|
+
|
|
77
|
+
${errorRules.map(r => `- ${r.id}: ${r.rule}`).join('\n')}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generate rule violation examples
|
|
81
|
+
*/
|
|
82
|
+
function generateRuleExamplesPrompt(rules) {
|
|
83
|
+
const sections = rules.map(rule => {
|
|
84
|
+
if (!rule.examples || rule.examples.length === 0) {
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
const bad = rule.examples.filter(e => e.type === 'bad');
|
|
88
|
+
const good = rule.examples.filter(e => e.type === 'good');
|
|
89
|
+
return `## ${rule.id}: ${rule.rule}
|
|
90
|
+
|
|
91
|
+
${bad.length > 0 ? `### ❌ Bad
|
|
92
|
+
\`\`\`
|
|
93
|
+
${bad[0].code}
|
|
94
|
+
\`\`\`
|
|
95
|
+
${bad[0].explanation ? `*${bad[0].explanation}*` : ''}
|
|
96
|
+
` : ''}
|
|
97
|
+
${good.length > 0 ? `### ✅ Good
|
|
98
|
+
\`\`\`
|
|
99
|
+
${good[0].code}
|
|
100
|
+
\`\`\`
|
|
101
|
+
${good[0].explanation ? `*${good[0].explanation}*` : ''}` : ''}`;
|
|
102
|
+
}).filter(s => s.length > 0);
|
|
103
|
+
return `# Rule Examples
|
|
104
|
+
|
|
105
|
+
${sections.join('\n\n')}`;
|
|
106
|
+
}
|
|
107
|
+
function formatCategoryName(category) {
|
|
108
|
+
const names = {
|
|
109
|
+
'API': 'API Design',
|
|
110
|
+
'DOMAIN': 'Domain Modeling',
|
|
111
|
+
'ERROR_HANDLING': 'Error Handling',
|
|
112
|
+
'TRANSACTIONS': 'Transaction',
|
|
113
|
+
'DATA_ACCESS': 'Data Access',
|
|
114
|
+
'NAMING': 'Naming Convention',
|
|
115
|
+
'VALIDATION': 'Validation',
|
|
116
|
+
'ASYNC': 'Async/Concurrency'
|
|
117
|
+
};
|
|
118
|
+
return names[category] || category;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=rule-enforcement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-enforcement.js","sourceRoot":"","sources":["../../src/templates/rule-enforcement.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAQH,sEAyCC;AAKD,8EAgBC;AAKD,gEAMC;AAKD,gEA2BC;AA9GD,4CAAyF;AAEzF;;GAEG;AACH,SAAgB,6BAA6B,CACzC,aAA6B,CAAC,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC;IAE/E,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,QAAQ,CAAC,IAAI,CAAC;;;;;;;I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C,EAAE;CACpD,CAAC,CAAC,CAAC,EAAE;EACJ,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;;EAElB,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;;EAEZ,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE7B,OAAO;;EAET,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAsB;IAC9C,MAAM,KAAK,GAAiC;QACxC,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,iBAAiB;QAC3B,gBAAgB,EAAE,gBAAgB;QAClC,cAAc,EAAE,aAAa;QAC7B,aAAa,EAAE,aAAa;QAC5B,QAAQ,EAAE,mBAAmB;QAC7B,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,mBAAmB;KAC/B,CAAC;IACF,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Selection Prompt Template
|
|
3
|
+
* Prompt for when a tech stack is selected
|
|
4
|
+
*/
|
|
5
|
+
import type { TechStack } from '@ironbackend/core';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a stack-specific prompt section
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateStackPrompt(stack: TechStack): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate stack-specific code style hints
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateStackCodeStyle(stack: TechStack): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate stack comparison for selection
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateStackComparisonPrompt(stacks: TechStack[]): string;
|
|
18
|
+
//# sourceMappingURL=stack-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-selection.d.ts","sourceRoot":"","sources":["../../src/templates/stack-selection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAmD5D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAiD/D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAezE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stack Selection Prompt Template
|
|
4
|
+
* Prompt for when a tech stack is selected
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateStackPrompt = generateStackPrompt;
|
|
8
|
+
exports.generateStackCodeStyle = generateStackCodeStyle;
|
|
9
|
+
exports.generateStackComparisonPrompt = generateStackComparisonPrompt;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a stack-specific prompt section
|
|
12
|
+
*/
|
|
13
|
+
function generateStackPrompt(stack) {
|
|
14
|
+
return `# Technology Stack: ${stack.name}
|
|
15
|
+
|
|
16
|
+
## Language & Framework
|
|
17
|
+
- **Language:** ${stack.language} ${stack.languageVersion}
|
|
18
|
+
- **Framework:** ${stack.framework} ${stack.frameworkVersion}
|
|
19
|
+
|
|
20
|
+
## Database
|
|
21
|
+
- **Type:** ${stack.database.type}
|
|
22
|
+
- **ORM:** ${stack.database.orm}
|
|
23
|
+
${stack.database.driver ? `- **Driver:** ${stack.database.driver}` : ''}
|
|
24
|
+
|
|
25
|
+
## Messaging & Async
|
|
26
|
+
- **Type:** ${stack.messaging.type}
|
|
27
|
+
- **Provider:** ${stack.messaging.provider}
|
|
28
|
+
|
|
29
|
+
## Authentication
|
|
30
|
+
${stack.authentication}
|
|
31
|
+
|
|
32
|
+
## Logging
|
|
33
|
+
${stack.logging}
|
|
34
|
+
|
|
35
|
+
## Testing Strategy
|
|
36
|
+
| Test Type | Tool | Target |
|
|
37
|
+
|-----------|------|--------|
|
|
38
|
+
| Unit | ${stack.testing.unit} | ${stack.testing.coverageTarget}% coverage |
|
|
39
|
+
| Integration | ${stack.testing.integration} | Key flows |
|
|
40
|
+
${stack.testing.e2e ? `| E2E | ${stack.testing.e2e} | Critical paths |` : ''}
|
|
41
|
+
|
|
42
|
+
## Deployment
|
|
43
|
+
${stack.deployment.map(d => `- ${d}`).join('\n')}
|
|
44
|
+
|
|
45
|
+
## Coding Conventions
|
|
46
|
+
|
|
47
|
+
When writing code for this stack, follow these conventions:
|
|
48
|
+
|
|
49
|
+
${stack.conventions.map((c, i) => `${i + 1}. ${c}`).join('\n')}
|
|
50
|
+
|
|
51
|
+
## Code Examples
|
|
52
|
+
|
|
53
|
+
### Entity/Model
|
|
54
|
+
Use ${stack.database.orm} patterns for data modeling.
|
|
55
|
+
|
|
56
|
+
### Repository
|
|
57
|
+
Implement repository interfaces using ${stack.database.orm}.
|
|
58
|
+
|
|
59
|
+
### Service
|
|
60
|
+
Services orchestrate domain logic, inject repositories.
|
|
61
|
+
|
|
62
|
+
### Controller/Handler
|
|
63
|
+
Handle HTTP concerns only, delegate to services.`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generate stack-specific code style hints
|
|
67
|
+
*/
|
|
68
|
+
function generateStackCodeStyle(stack) {
|
|
69
|
+
const codeStyles = {
|
|
70
|
+
'node-nestjs': `// NestJS Style
|
|
71
|
+
@Injectable()
|
|
72
|
+
export class UserService {
|
|
73
|
+
constructor(private readonly userRepository: UserRepository) {}
|
|
74
|
+
|
|
75
|
+
async findById(id: string): Promise<User> {
|
|
76
|
+
return this.userRepository.findById(id);
|
|
77
|
+
}
|
|
78
|
+
}`,
|
|
79
|
+
'java-spring': `// Spring Boot Style
|
|
80
|
+
@Service
|
|
81
|
+
public class UserService {
|
|
82
|
+
private final UserRepository userRepository;
|
|
83
|
+
|
|
84
|
+
public UserService(UserRepository userRepository) {
|
|
85
|
+
this.userRepository = userRepository;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public Optional<User> findById(UUID id) {
|
|
89
|
+
return userRepository.findById(id);
|
|
90
|
+
}
|
|
91
|
+
}`,
|
|
92
|
+
'dotnet-aspnetcore': `// ASP.NET Core Style
|
|
93
|
+
public class UserService : IUserService
|
|
94
|
+
{
|
|
95
|
+
private readonly IUserRepository _userRepository;
|
|
96
|
+
|
|
97
|
+
public UserService(IUserRepository userRepository)
|
|
98
|
+
{
|
|
99
|
+
_userRepository = userRepository;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public async Task<User?> FindByIdAsync(Guid id)
|
|
103
|
+
{
|
|
104
|
+
return await _userRepository.FindByIdAsync(id);
|
|
105
|
+
}
|
|
106
|
+
}`,
|
|
107
|
+
'python-fastapi': `# FastAPI Style
|
|
108
|
+
class UserService:
|
|
109
|
+
def __init__(self, user_repository: UserRepository):
|
|
110
|
+
self.user_repository = user_repository
|
|
111
|
+
|
|
112
|
+
async def find_by_id(self, id: UUID) -> User | None:
|
|
113
|
+
return await self.user_repository.find_by_id(id)`
|
|
114
|
+
};
|
|
115
|
+
return codeStyles[stack.id] || '// Follow stack conventions';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Generate stack comparison for selection
|
|
119
|
+
*/
|
|
120
|
+
function generateStackComparisonPrompt(stacks) {
|
|
121
|
+
const header = `# Technology Stack Selection Guide
|
|
122
|
+
|
|
123
|
+
Choose the right stack based on your requirements:
|
|
124
|
+
|
|
125
|
+
`;
|
|
126
|
+
const comparison = stacks.map(stack => `
|
|
127
|
+
## ${stack.name}
|
|
128
|
+
- **Language:** ${stack.language} ${stack.languageVersion}
|
|
129
|
+
- **Framework:** ${stack.framework}
|
|
130
|
+
- **Best for:** ${getStackStrengths(stack)}
|
|
131
|
+
`).join('\n');
|
|
132
|
+
return header + comparison;
|
|
133
|
+
}
|
|
134
|
+
function getStackStrengths(stack) {
|
|
135
|
+
const strengths = {
|
|
136
|
+
'node-nestjs': 'Fast development, TypeScript ecosystem, real-time apps',
|
|
137
|
+
'java-spring': 'Enterprise apps, strong typing, mature ecosystem',
|
|
138
|
+
'dotnet-aspnetcore': 'Microsoft stack, high performance, enterprise features',
|
|
139
|
+
'python-fastapi': 'Data science, ML integration, rapid prototyping'
|
|
140
|
+
};
|
|
141
|
+
return strengths[stack.id] || 'General purpose backend development';
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=stack-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-selection.js","sourceRoot":"","sources":["../../src/templates/stack-selection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,kDAmDC;AAKD,wDAiDC;AAKD,sEAeC;AAhID;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAAgB;IAChD,OAAO,uBAAuB,KAAK,CAAC,IAAI;;;kBAG1B,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,eAAe;mBACtC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,gBAAgB;;;cAG9C,KAAK,CAAC,QAAQ,CAAC,IAAI;aACpB,KAAK,CAAC,QAAQ,CAAC,GAAG;EAC7B,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;;;cAGzD,KAAK,CAAC,SAAS,CAAC,IAAI;kBAChB,KAAK,CAAC,SAAS,CAAC,QAAQ;;;EAGxC,KA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AAe;mBACtC,KAAK,CAAC,SAAS;kBAChB,iBAAiB,CAAC,KAAK,CAAC;CACzC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEV,OAAO,MAAM,GAAG,UAAU,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAgB;IACvC,MAAM,SAAS,GAA2B;QACtC,aAAa,EAAE,wDAAwD;QACvE,aAAa,EAAE,kDAAkD;QACjE,mBAAmB,EAAE,wDAAwD;QAC7E,gBAAgB,EAAE,iDAAiD;KACtE,CAAC;IACF,OAAO,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,qCAAqC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Selection Prompt Template
|
|
3
|
+
* Prompt for when an architecture style is selected
|
|
4
|
+
*/
|
|
5
|
+
import type { ArchitectureStyle } from '@ironbackend/core';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a style-specific prompt section
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateStylePrompt(style: ArchitectureStyle): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a comparison prompt for style selection
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateStyleComparisonPrompt(styles: ArchitectureStyle[]): string;
|
|
14
|
+
//# sourceMappingURL=style-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-selection.d.ts","sourceRoot":"","sources":["../../src/templates/style-selection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAsCpE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAejF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Style Selection Prompt Template
|
|
4
|
+
* Prompt for when an architecture style is selected
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateStylePrompt = generateStylePrompt;
|
|
8
|
+
exports.generateStyleComparisonPrompt = generateStyleComparisonPrompt;
|
|
9
|
+
const prompt_builder_js_1 = require("../builders/prompt-builder.js");
|
|
10
|
+
/**
|
|
11
|
+
* Generate a style-specific prompt section
|
|
12
|
+
*/
|
|
13
|
+
function generateStylePrompt(style) {
|
|
14
|
+
return `# Architecture Style: ${style.name}
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
${style.description}
|
|
18
|
+
|
|
19
|
+
## When to Use This Style
|
|
20
|
+
${style.whenToUse.map(w => `✅ ${w}`).join('\n')}
|
|
21
|
+
|
|
22
|
+
## When NOT to Use This Style
|
|
23
|
+
${style.whenNotToUse.map(w => `❌ ${w}`).join('\n')}
|
|
24
|
+
|
|
25
|
+
## Core Principles
|
|
26
|
+
${style.corePrinciples.map((p, i) => `${i + 1}. ${p}`).join('\n')}
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
Every file you create MUST follow this structure:
|
|
30
|
+
|
|
31
|
+
\`\`\`
|
|
32
|
+
${(0, prompt_builder_js_1.formatFolderStructure)(style.folderStructure)}
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
## AI Behavior Instructions
|
|
36
|
+
|
|
37
|
+
${style.aiInstructions}
|
|
38
|
+
|
|
39
|
+
## Violations to Flag
|
|
40
|
+
|
|
41
|
+
If you generate or see code with these patterns, flag them as violations:
|
|
42
|
+
${style.commonPitfalls.map(p => `⚠️ ${p}`).join('\n')}
|
|
43
|
+
|
|
44
|
+
## Decision Making
|
|
45
|
+
|
|
46
|
+
When asked where to put new code:
|
|
47
|
+
1. Identify the layer based on responsibilities
|
|
48
|
+
2. Check the folder structure above
|
|
49
|
+
3. Place code in the appropriate directory
|
|
50
|
+
4. Create new folders only if they fit the pattern`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generate a comparison prompt for style selection
|
|
54
|
+
*/
|
|
55
|
+
function generateStyleComparisonPrompt(styles) {
|
|
56
|
+
const header = `# Architecture Style Selection Guide
|
|
57
|
+
|
|
58
|
+
Choose the right style based on your project needs:
|
|
59
|
+
|
|
60
|
+
`;
|
|
61
|
+
const comparisons = styles.map(style => `
|
|
62
|
+
## ${style.name}
|
|
63
|
+
**Best for:** ${style.whenToUse.slice(0, 2).join(', ')}
|
|
64
|
+
**Avoid when:** ${style.whenNotToUse.slice(0, 2).join(', ')}
|
|
65
|
+
**Complexity:** ${getStyleComplexity(style)}
|
|
66
|
+
`).join('\n');
|
|
67
|
+
return header + comparisons;
|
|
68
|
+
}
|
|
69
|
+
function getStyleComplexity(style) {
|
|
70
|
+
const simpleStyles = ['clean-monolith', 'serverless', 'automation'];
|
|
71
|
+
const complexStyles = ['hexagonal', 'event-driven', 'cqrs', 'microservices-async'];
|
|
72
|
+
if (simpleStyles.includes(style.id))
|
|
73
|
+
return '🟢 Low';
|
|
74
|
+
if (complexStyles.includes(style.id))
|
|
75
|
+
return '🔴 High';
|
|
76
|
+
return '🟡 Medium';
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=style-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-selection.js","sourceRoot":"","sources":["../../src/templates/style-selection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAQH,kDAsCC;AAKD,sEAeC;AA/DD,qEAAsE;AAEtE;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAAwB;IACxD,OAAO,yBAAyB,KAAK,CAAC,IAAI;;;EAG5C,KAAK,CAAC,WAAW;;;EAGjB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,I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AAqB,CAAC,CAAC;IAEnF,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,QAAQ,CAAC;IACrD,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IACvD,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Prompt Template
|
|
3
|
+
* Main prompt that establishes the AI's role and context
|
|
4
|
+
*/
|
|
5
|
+
import type { ArchitectureStyle, TechStack } from '@ironbackend/core';
|
|
6
|
+
export interface SystemPromptContext {
|
|
7
|
+
style: ArchitectureStyle;
|
|
8
|
+
stack: TechStack;
|
|
9
|
+
includeRules?: boolean;
|
|
10
|
+
includeSecurity?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generate the main system prompt
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateSystemPrompt(context: SystemPromptContext): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a minimal system prompt (for limited context windows)
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateMinimalSystemPrompt(context: SystemPromptContext): string;
|
|
20
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/templates/system.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKtE,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA+FzE;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAgBhF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* System Prompt Template
|
|
4
|
+
* Main prompt that establishes the AI's role and context
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateSystemPrompt = generateSystemPrompt;
|
|
8
|
+
exports.generateMinimalSystemPrompt = generateMinimalSystemPrompt;
|
|
9
|
+
const core_1 = require("@ironbackend/core");
|
|
10
|
+
const core_2 = require("@ironbackend/core");
|
|
11
|
+
const prompt_builder_js_1 = require("../builders/prompt-builder.js");
|
|
12
|
+
/**
|
|
13
|
+
* Generate the main system prompt
|
|
14
|
+
*/
|
|
15
|
+
function generateSystemPrompt(context) {
|
|
16
|
+
const { style, stack, includeRules = true, includeSecurity = true } = context;
|
|
17
|
+
const sections = [];
|
|
18
|
+
// Header
|
|
19
|
+
sections.push(`# IronBackend System Prompt
|
|
20
|
+
|
|
21
|
+
You are a senior backend engineer with 10+ years of experience in ${style.name} architecture.
|
|
22
|
+
Your expertise includes ${stack.language} with ${stack.framework}, and you follow strict design principles.
|
|
23
|
+
|
|
24
|
+
---`);
|
|
25
|
+
// Architecture Context
|
|
26
|
+
sections.push(`## Architecture: ${style.name}
|
|
27
|
+
|
|
28
|
+
${style.description}
|
|
29
|
+
|
|
30
|
+
### Core Principles
|
|
31
|
+
${style.corePrinciples.map((p, i) => `${i + 1}. ${p}`).join('\n')}
|
|
32
|
+
|
|
33
|
+
### Project Structure
|
|
34
|
+
\`\`\`
|
|
35
|
+
${(0, prompt_builder_js_1.formatFolderStructure)(style.folderStructure)}
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
### Anti-Patterns to Avoid
|
|
39
|
+
${style.commonPitfalls.map(p => `- ❌ ${p}`).join('\n')}
|
|
40
|
+
|
|
41
|
+
---`);
|
|
42
|
+
// Tech Stack
|
|
43
|
+
sections.push(`## Technology Stack
|
|
44
|
+
|
|
45
|
+
| Component | Choice |
|
|
46
|
+
|-----------|--------|
|
|
47
|
+
| Language | ${stack.language} ${stack.languageVersion} |
|
|
48
|
+
| Framework | ${stack.framework} ${stack.frameworkVersion} |
|
|
49
|
+
| Database | ${stack.database.type} with ${stack.database.orm} |
|
|
50
|
+
| Messaging | ${stack.messaging.provider} |
|
|
51
|
+
| Auth | ${stack.authentication} |
|
|
52
|
+
| Logging | ${stack.logging} |
|
|
53
|
+
| Testing | ${stack.testing.unit} (unit), ${stack.testing.integration} (integration) |
|
|
54
|
+
|
|
55
|
+
### Conventions
|
|
56
|
+
${stack.conventions.map(c => `- ${c}`).join('\n')}
|
|
57
|
+
|
|
58
|
+
---`);
|
|
59
|
+
// AI Instructions
|
|
60
|
+
sections.push(`## AI Behavior Instructions
|
|
61
|
+
|
|
62
|
+
${style.aiInstructions}
|
|
63
|
+
|
|
64
|
+
---`);
|
|
65
|
+
// Rules
|
|
66
|
+
if (includeRules) {
|
|
67
|
+
const errorRules = (0, core_1.getErrorRules)();
|
|
68
|
+
sections.push(`## Enforced Design Rules (ERROR severity = must follow)
|
|
69
|
+
|
|
70
|
+
${(0, core_1.formatRulesForPrompt)(errorRules)}
|
|
71
|
+
|
|
72
|
+
---`);
|
|
73
|
+
}
|
|
74
|
+
// Security
|
|
75
|
+
if (includeSecurity) {
|
|
76
|
+
sections.push(`## Security Requirements
|
|
77
|
+
|
|
78
|
+
${(0, core_2.formatSecurityForPrompt)()}
|
|
79
|
+
|
|
80
|
+
---`);
|
|
81
|
+
}
|
|
82
|
+
// Code Generation Guidelines
|
|
83
|
+
sections.push(`## Code Generation Guidelines
|
|
84
|
+
|
|
85
|
+
When generating code, you MUST:
|
|
86
|
+
1. Follow the folder structure exactly as defined above
|
|
87
|
+
2. Apply all ERROR-severity rules without exception
|
|
88
|
+
3. Include proper error handling as per ERR-* rules
|
|
89
|
+
4. Add structured logging appropriate for the stack
|
|
90
|
+
5. Never skip input validation at API boundaries
|
|
91
|
+
6. Use the specified ORM and patterns for data access
|
|
92
|
+
7. Write tests for all public interfaces
|
|
93
|
+
|
|
94
|
+
When asked to create a new feature:
|
|
95
|
+
1. First, identify which layer(s) it belongs to
|
|
96
|
+
2. Create files in the correct locations
|
|
97
|
+
3. Define interfaces before implementations
|
|
98
|
+
4. Write unit tests alongside code
|
|
99
|
+
5. Add integration points last`);
|
|
100
|
+
return sections.join('\n\n');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Generate a minimal system prompt (for limited context windows)
|
|
104
|
+
*/
|
|
105
|
+
function generateMinimalSystemPrompt(context) {
|
|
106
|
+
const { style, stack } = context;
|
|
107
|
+
return `# IronBackend v1.0
|
|
108
|
+
|
|
109
|
+
You are a ${style.name} architecture expert using ${stack.language}/${stack.framework}.
|
|
110
|
+
|
|
111
|
+
## Key Rules
|
|
112
|
+
- ${style.corePrinciples.slice(0, 3).join('\n- ')}
|
|
113
|
+
|
|
114
|
+
## Anti-Patterns
|
|
115
|
+
- ${style.commonPitfalls.slice(0, 3).join('\n- ')}
|
|
116
|
+
|
|
117
|
+
## Stack: ${stack.database.type} + ${stack.database.orm}, ${stack.messaging.provider}
|
|
118
|
+
|
|
119
|
+
${style.aiInstructions.split('\n').slice(0, 10).join('\n')}`;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/templates/system.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,oDA+FC;AAKD,kEAgBC;AAlID,4CAAwE;AACxE,4CAA4D;AAC5D,qEAAsE;AAStE;;GAEG;AACH,SAAgB,oBAAoB,CAAC,OAA4B;IAC7D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,eAAe,GAAG,IAAI,EAAE,GAAG,OAAO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{
|
|
2
|
+
"name": "@ironbackend/prompts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI prompt templates for IronBackend",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"backend",
|
|
19
|
+
"architecture",
|
|
20
|
+
"ai",
|
|
21
|
+
"prompts",
|
|
22
|
+
"cursor",
|
|
23
|
+
"claude",
|
|
24
|
+
"copilot"
|
|
25
|
+
],
|
|
26
|
+
"author": "IronBackend Contributors",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/ironbackend/ironbackend.git",
|
|
31
|
+
"directory": "packages/prompts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@ironbackend/core": "1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.3.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"clean": "rm -rf dist"
|
|
43
|
+
}
|
|
44
|
+
}
|