@tstdl/base 0.93.76 → 0.93.77
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.
|
@@ -1,25 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the visual formatting style for a list of instructions.
|
|
3
|
+
* - `sections`: Renders keys as Markdown headers (e.g., `# Header`).
|
|
4
|
+
* - `ordered`: Renders items as a numbered list (e.g., `1. Item`).
|
|
5
|
+
* - `unordered`: Renders items as a bulleted list (e.g., `- Item`).
|
|
6
|
+
*/
|
|
1
7
|
export type ListStyle = 'sections' | 'ordered' | 'unordered';
|
|
2
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The content of an instructions list, which can be either:
|
|
10
|
+
* - An array of strings (simple list items).
|
|
11
|
+
* - A nested `Instructions` object (key-value pairs or further lists).
|
|
12
|
+
*/
|
|
13
|
+
export type InstructionsListContent = string[] | Instructions;
|
|
14
|
+
/**
|
|
15
|
+
* A container representing a specific grouping of instructions with a defined style.
|
|
16
|
+
* This is usually created via factory functions like `sections()`, `orderedList()`, or `unorderedList()`.
|
|
17
|
+
*/
|
|
3
18
|
export type InstructionsList = {
|
|
19
|
+
/** The rendering style to apply to this group. */
|
|
4
20
|
style: ListStyle;
|
|
21
|
+
/** An optional high-level instruction or description associated with this group. */
|
|
5
22
|
instruction?: string;
|
|
23
|
+
/** The content of the list, either an array of strings or a nested key-value map. */
|
|
6
24
|
items: InstructionsListContent;
|
|
7
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* A recursive dictionary structure for defining structured instructions.
|
|
28
|
+
* Keys typically represent labels or headers, while values represent the content.
|
|
29
|
+
*/
|
|
8
30
|
export type Instructions = {
|
|
9
31
|
[key: string]: string | string[] | InstructionsList | Instructions;
|
|
10
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates a container where content is rendered as Markdown sections.
|
|
35
|
+
* Keys in the object map become headers (e.g., `# Key`), and nested items reset indentation.
|
|
36
|
+
*
|
|
37
|
+
* @param items - The content of the section.
|
|
38
|
+
*/
|
|
11
39
|
export declare function sections(items: InstructionsListContent): InstructionsList;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a container where content is rendered as Markdown sections with a preamble.
|
|
42
|
+
*
|
|
43
|
+
* @param instruction - A general instruction describing this section.
|
|
44
|
+
* @param items - The content of the section.
|
|
45
|
+
*/
|
|
12
46
|
export declare function sections(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a container rendered as a numbered list.
|
|
49
|
+
*
|
|
50
|
+
* @param items - The list items or map.
|
|
51
|
+
*/
|
|
13
52
|
export declare function orderedList(items: InstructionsListContent): InstructionsList;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a container rendered as a numbered list with a preamble.
|
|
55
|
+
*
|
|
56
|
+
* @param instruction - An instruction describing the list.
|
|
57
|
+
* @param items - The list items or map.
|
|
58
|
+
*/
|
|
14
59
|
export declare function orderedList(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a container rendered as a bulleted list.
|
|
62
|
+
*
|
|
63
|
+
* @param items - The list items or map.
|
|
64
|
+
*/
|
|
15
65
|
export declare function unorderedList(items: InstructionsListContent): InstructionsList;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a container rendered as a bulleted list with a preamble.
|
|
68
|
+
*
|
|
69
|
+
* @param instruction - An instruction describing the list.
|
|
70
|
+
* @param items - The list items or map.
|
|
71
|
+
*/
|
|
16
72
|
export declare function unorderedList(instruction: string, items: InstructionsListContent): InstructionsList;
|
|
17
73
|
/**
|
|
18
|
-
* Formats instructions into a string representation suitable for AI prompts.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
74
|
+
* Formats a structured instructions object into a string representation suitable for AI prompts (Markdown).
|
|
75
|
+
*
|
|
76
|
+
* It recursively handles:
|
|
77
|
+
* - `sections`: Creates headers (H1, H2...).
|
|
78
|
+
* - `ordered` / `unordered`: Creates indented lists.
|
|
79
|
+
* - `Instructions`: Objects are formatted as key-value pairs (e.g., `- **Key:** Value`).
|
|
80
|
+
*
|
|
81
|
+
* @param node - The root instructions object, array, or instructions list wrapper.
|
|
82
|
+
* @param options - Formatting options.
|
|
83
|
+
* @param options.initialDepth - The starting indentation level (default: 0).
|
|
84
|
+
* @returns A formatted string.
|
|
21
85
|
*/
|
|
22
86
|
export declare function formatInstructions(node: Instructions | InstructionsList | string[], options?: {
|
|
23
87
|
initialDepth?: number;
|
|
24
88
|
}): string;
|
|
25
|
-
export {};
|
|
@@ -146,9 +146,17 @@ function processNode(node, context) {
|
|
|
146
146
|
}).join(separator);
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Formats instructions into a string representation suitable for AI prompts.
|
|
150
|
-
*
|
|
151
|
-
*
|
|
149
|
+
* Formats a structured instructions object into a string representation suitable for AI prompts (Markdown).
|
|
150
|
+
*
|
|
151
|
+
* It recursively handles:
|
|
152
|
+
* - `sections`: Creates headers (H1, H2...).
|
|
153
|
+
* - `ordered` / `unordered`: Creates indented lists.
|
|
154
|
+
* - `Instructions`: Objects are formatted as key-value pairs (e.g., `- **Key:** Value`).
|
|
155
|
+
*
|
|
156
|
+
* @param node - The root instructions object, array, or instructions list wrapper.
|
|
157
|
+
* @param options - Formatting options.
|
|
158
|
+
* @param options.initialDepth - The starting indentation level (default: 0).
|
|
159
|
+
* @returns A formatted string.
|
|
152
160
|
*/
|
|
153
161
|
export function formatInstructions(node, options = {}) {
|
|
154
162
|
// Heuristic: If passing a raw object, assume it's a Root Section unless specified otherwise.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.77",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"@zxcvbn-ts/language-de": "^3.0",
|
|
151
151
|
"@zxcvbn-ts/language-en": "^3.0",
|
|
152
152
|
"drizzle-orm": "^0.45",
|
|
153
|
-
"file-type": "^21.
|
|
153
|
+
"file-type": "^21.3",
|
|
154
154
|
"genkit": "^1.27",
|
|
155
155
|
"handlebars": "^4.7",
|
|
156
156
|
"minio": "^8.0",
|
|
@@ -181,13 +181,13 @@
|
|
|
181
181
|
"concurrently": "9.2",
|
|
182
182
|
"drizzle-kit": "0.31",
|
|
183
183
|
"eslint": "9.39",
|
|
184
|
-
"globals": "
|
|
184
|
+
"globals": "17.0",
|
|
185
185
|
"tsc-alias": "1.8",
|
|
186
186
|
"typedoc-github-wiki-theme": "2.1",
|
|
187
187
|
"typedoc-plugin-markdown": "4.9",
|
|
188
188
|
"typedoc-plugin-missing-exports": "4.1",
|
|
189
189
|
"typescript": "5.9",
|
|
190
|
-
"typescript-eslint": "8.
|
|
190
|
+
"typescript-eslint": "8.51"
|
|
191
191
|
},
|
|
192
192
|
"overrides": {
|
|
193
193
|
"drizzle-kit": {
|