@quanvo99/ai-rules 0.1.4 → 0.1.5
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/dist/cli/commands/generate-questions.d.ts +7 -0
- package/dist/cli/commands/generate-questions.d.ts.map +1 -0
- package/dist/cli/commands/generate-questions.js +120 -0
- package/dist/cli/commands/generate-questions.js.map +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +45 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/lib/files.d.ts +8 -0
- package/dist/cli/lib/files.d.ts.map +1 -1
- package/dist/cli/lib/files.js +19 -0
- package/dist/cli/lib/files.js.map +1 -1
- package/dist/cli/lib/github.d.ts +9 -0
- package/dist/cli/lib/github.d.ts.map +1 -1
- package/dist/cli/lib/github.js +20 -0
- package/dist/cli/lib/github.js.map +1 -1
- package/dist/cli/lib/ollama-client.d.ts +66 -0
- package/dist/cli/lib/ollama-client.d.ts.map +1 -0
- package/dist/cli/lib/ollama-client.js +198 -0
- package/dist/cli/lib/ollama-client.js.map +1 -0
- package/dist/cli/lib/question-prompt.d.ts +37 -0
- package/dist/cli/lib/question-prompt.d.ts.map +1 -0
- package/dist/cli/lib/question-prompt.js +204 -0
- package/dist/cli/lib/question-prompt.js.map +1 -0
- package/dist/cli/lib/question-schema.d.ts +84 -0
- package/dist/cli/lib/question-schema.d.ts.map +1 -0
- package/dist/cli/lib/question-schema.js +135 -0
- package/dist/cli/lib/question-schema.js.map +1 -0
- package/dist/cli/lib/question-types.d.ts +72 -0
- package/dist/cli/lib/question-types.d.ts.map +1 -0
- package/dist/cli/lib/question-types.js +28 -0
- package/dist/cli/lib/question-types.js.map +1 -0
- package/dist/cli/lib/types.d.ts +2 -1
- package/dist/cli/lib/types.d.ts.map +1 -1
- package/dist/cli/lib/types.js +1 -0
- package/dist/cli/lib/types.js.map +1 -1
- package/dist/lib/question-types.d.ts +69 -0
- package/dist/lib/question-types.d.ts.map +1 -0
- package/dist/lib/question-types.js +3 -0
- package/dist/lib/question-types.js.map +1 -0
- package/dist/server/types.d.ts +47 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js +2 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama-client.js","sourceRoot":"","sources":["../../../../src/cli/lib/ollama-client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkEH,8CAkBC;AASD,gCAsDC;AAsBD,0DAmDC;AAQD,kEAsBC;AA5OD;;GAEG;AACH,MAAM,cAAc,GAAiB;IACpC,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,UAAU;IACpD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,QAAQ,EAAE,EAAE,CAAC,EAAE,0CAA0C;CACzG,CAAC;AA2BF;;GAEG;AACH,MAAa,WAAY,SAAQ,KAAK;IACrC,YACC,OAAe,EACR,UAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC3B,CAAC;CACD;AARD,kCAQC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CAAC,SAAuB,cAAc;IAC5E,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAEvE,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,WAAW,EAAE;YAC1D,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,UAAU,CAAC,MAAM;SACzB,CAAC,CAAC;QACH,YAAY,CAAC,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IAC5C,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CACpB,4EAA4E;YAC3E,uDAAuD,CACxD,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAI,WAAW,CACpB,6CAA6C;YAC5C,sBAAsB;YACtB,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;YAC1B,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CACrC,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt builder for question generation
|
|
3
|
+
* Reads rule content and builds structured prompts for LLM
|
|
4
|
+
*/
|
|
5
|
+
import type { Manifest } from "../../server/types";
|
|
6
|
+
/**
|
|
7
|
+
* Rule content structure for prompt building
|
|
8
|
+
*/
|
|
9
|
+
interface RuleContent {
|
|
10
|
+
/** Rule manifest metadata */
|
|
11
|
+
manifest: Manifest;
|
|
12
|
+
/** Content of all rule files */
|
|
13
|
+
files: Array<{
|
|
14
|
+
path: string;
|
|
15
|
+
content: string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads rule content from the repository
|
|
20
|
+
* @param rulePath - The path to the rule directory (e.g., 'rules/cursor/brainstorming')
|
|
21
|
+
* @returns Rule content with manifest and files
|
|
22
|
+
*/
|
|
23
|
+
export declare function readRuleContent(rulePath: string): RuleContent;
|
|
24
|
+
/**
|
|
25
|
+
* Builds context string from rule metadata and content
|
|
26
|
+
* @param ruleContent - Rule content structure
|
|
27
|
+
* @returns Formatted context string for LLM
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildRuleContext(ruleContent: RuleContent): string;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the complete prompt for LLM question generation
|
|
32
|
+
* @param rulePath - The path to the rule directory
|
|
33
|
+
* @returns Complete prompt string
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildQuestionPrompt(rulePath: string): string;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=question-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-prompt.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/question-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,UAAU,WAAW;IACpB,6BAA6B;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,gCAAgC;IAChC,KAAK,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CA+B7D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAcjE;AAmID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU5D"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt builder for question generation
|
|
4
|
+
* Reads rule content and builds structured prompts for LLM
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.readRuleContent = readRuleContent;
|
|
8
|
+
exports.buildRuleContext = buildRuleContext;
|
|
9
|
+
exports.buildQuestionPrompt = buildQuestionPrompt;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
/**
|
|
13
|
+
* Reads rule content from the repository
|
|
14
|
+
* @param rulePath - The path to the rule directory (e.g., 'rules/cursor/brainstorming')
|
|
15
|
+
* @returns Rule content with manifest and files
|
|
16
|
+
*/
|
|
17
|
+
function readRuleContent(rulePath) {
|
|
18
|
+
// Resolve the rule directory path
|
|
19
|
+
const ruleDir = rulePath.startsWith("/") ? rulePath : (0, node_path_1.join)(process.cwd(), rulePath);
|
|
20
|
+
if (!(0, node_fs_1.existsSync)(ruleDir)) {
|
|
21
|
+
throw new Error(`Rule directory not found: ${ruleDir}`);
|
|
22
|
+
}
|
|
23
|
+
// Read manifest
|
|
24
|
+
const manifestPath = (0, node_path_1.join)(ruleDir, "manifest.json");
|
|
25
|
+
if (!(0, node_fs_1.existsSync)(manifestPath)) {
|
|
26
|
+
throw new Error(`Manifest not found: ${manifestPath}`);
|
|
27
|
+
}
|
|
28
|
+
const manifest = JSON.parse((0, node_fs_1.readFileSync)(manifestPath, "utf-8"));
|
|
29
|
+
// Read all rule files
|
|
30
|
+
const files = manifest.files.map((file) => {
|
|
31
|
+
const filePath = (0, node_path_1.join)(ruleDir, file.path);
|
|
32
|
+
if (!(0, node_fs_1.existsSync)(filePath)) {
|
|
33
|
+
throw new Error(`Rule file not found: ${filePath}`);
|
|
34
|
+
}
|
|
35
|
+
const content = (0, node_fs_1.readFileSync)(filePath, "utf-8");
|
|
36
|
+
return {
|
|
37
|
+
path: file.path,
|
|
38
|
+
content,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
return { manifest, files };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds context string from rule metadata and content
|
|
45
|
+
* @param ruleContent - Rule content structure
|
|
46
|
+
* @returns Formatted context string for LLM
|
|
47
|
+
*/
|
|
48
|
+
function buildRuleContext(ruleContent) {
|
|
49
|
+
const { manifest, files } = ruleContent;
|
|
50
|
+
const context = `
|
|
51
|
+
Rule ID: ${manifest.id}
|
|
52
|
+
Category: ${manifest.category}
|
|
53
|
+
Tags: ${manifest.tags.join(", ")}
|
|
54
|
+
Description: ${manifest.description}
|
|
55
|
+
|
|
56
|
+
Rule Content:
|
|
57
|
+
${files.map((file) => `--- ${file.path} ---\n${file.content}`).join("\n\n")}
|
|
58
|
+
`;
|
|
59
|
+
return context.trim();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* System prompt for question generation
|
|
63
|
+
* Includes instructions, schema, and examples
|
|
64
|
+
*/
|
|
65
|
+
const SYSTEM_PROMPT = `You are a question generation assistant for an AI rules library.
|
|
66
|
+
|
|
67
|
+
Your task: Generate 3-5 questions that identify if developers want/need help from this rule.
|
|
68
|
+
|
|
69
|
+
Context: Questions build context for fuzzy search rule discovery. User describes project → answers questions → keywords added to context → context searches rules.
|
|
70
|
+
|
|
71
|
+
Question Types:
|
|
72
|
+
1. yes-no: Binary questions. Must include "keywords" array (added to search context if user answers yes)
|
|
73
|
+
2. choice: Multiple choice. Must include "options" array with text and keywords for each
|
|
74
|
+
3. open-ended: Free text. Full answer added to search context.
|
|
75
|
+
|
|
76
|
+
All questions MUST include:
|
|
77
|
+
- "id": Unique identifier in kebab-case
|
|
78
|
+
- "text": Clear, concise question text
|
|
79
|
+
- "type": One of: yes-no, choice, open-ended
|
|
80
|
+
- "tags": Array of relevant search tags (technology names, concepts, patterns)
|
|
81
|
+
|
|
82
|
+
Requirements:
|
|
83
|
+
- ALWAYS lead with 1-2 high-level need/intent questions
|
|
84
|
+
- High-level questions should directly ask about wanting/needing help (e.g., "Do you want rules to help with X?")
|
|
85
|
+
- Then follow with specific usage or technical questions
|
|
86
|
+
- Questions can ask about current usage OR needs - both add keywords to context
|
|
87
|
+
- For core technologies (e.g., TypeScript, React, Next.js, Node.js), the FIRST question MUST be a usage-detection yes/no (e.g., "Are you using TypeScript?") when the rule clearly targets that technology
|
|
88
|
+
- Focus on what will help identify if this rule solves their problems
|
|
89
|
+
- Tags should match common terms developers use
|
|
90
|
+
- Keywords should include aliases and variations
|
|
91
|
+
- Keep questions clear and unambiguous
|
|
92
|
+
|
|
93
|
+
Return valid JSON matching this schema:
|
|
94
|
+
{
|
|
95
|
+
"questions": [
|
|
96
|
+
{
|
|
97
|
+
"id": "string (kebab-case, unique)",
|
|
98
|
+
"text": "string (the question)",
|
|
99
|
+
"type": "yes-no | choice | open-ended",
|
|
100
|
+
"tags": ["string", "..."],
|
|
101
|
+
"keywords": ["string", "..."], // for yes-no only
|
|
102
|
+
"options": [ // for choice only
|
|
103
|
+
{ "text": "string", "keywords": ["string", "..."] }
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Examples:
|
|
110
|
+
|
|
111
|
+
Example for a TypeScript rule (usage detection MUST be first):
|
|
112
|
+
{
|
|
113
|
+
"id": "uses-typescript",
|
|
114
|
+
"text": "Are you using TypeScript?",
|
|
115
|
+
"type": "yes-no",
|
|
116
|
+
"tags": ["typescript", "language", "type-system"],
|
|
117
|
+
"keywords": ["typescript", "ts"]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Example for a React hooks rule (usage detection):
|
|
121
|
+
{
|
|
122
|
+
"id": "uses-react-hooks",
|
|
123
|
+
"text": "Are you using React hooks in your project?",
|
|
124
|
+
"type": "yes-no",
|
|
125
|
+
"tags": ["react", "hooks", "frontend"],
|
|
126
|
+
"keywords": ["react", "hooks", "useState", "useEffect"]
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Example for a CSS framework choice:
|
|
130
|
+
{
|
|
131
|
+
"id": "css-framework",
|
|
132
|
+
"text": "What CSS framework are you using?",
|
|
133
|
+
"type": "choice",
|
|
134
|
+
"tags": ["css", "styling", "framework"],
|
|
135
|
+
"options": [
|
|
136
|
+
{ "text": "Tailwind CSS", "keywords": ["tailwind", "tailwindcss"] },
|
|
137
|
+
{ "text": "styled-components", "keywords": ["styled-components"] },
|
|
138
|
+
{ "text": "CSS Modules", "keywords": ["css-modules"] }
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Example for a brainstorming rule (high-level need):
|
|
143
|
+
{
|
|
144
|
+
"id": "wants-brainstorming-help",
|
|
145
|
+
"text": "Do you want rules to help you brainstorm and document ideas methodically?",
|
|
146
|
+
"type": "yes-no",
|
|
147
|
+
"tags": ["brainstorming", "problem-solving", "documentation"],
|
|
148
|
+
"keywords": ["brainstorming", "structured-thinking", "documentation", "problem-definition"]
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
Example for open-ended (exploration):
|
|
152
|
+
{
|
|
153
|
+
"id": "project-challenges",
|
|
154
|
+
"text": "What are the main challenges you face in your development process?",
|
|
155
|
+
"type": "open-ended",
|
|
156
|
+
"tags": ["challenges", "problems", "workflow"]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
Example for a React Server Components rule (usage detection):
|
|
160
|
+
{
|
|
161
|
+
"id": "uses-nextjs-app-router",
|
|
162
|
+
"text": "Are you using Next.js App Router?",
|
|
163
|
+
"type": "yes-no",
|
|
164
|
+
"tags": ["nextjs", "react", "app-router", "server-components"],
|
|
165
|
+
"keywords": ["nextjs", "app-router", "server-components", "next.js"]
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Example for a React Server Components rule (architecture choice):
|
|
169
|
+
{
|
|
170
|
+
"id": "component-architecture",
|
|
171
|
+
"text": "What component architecture are you using?",
|
|
172
|
+
"type": "choice",
|
|
173
|
+
"tags": ["react", "architecture", "components"],
|
|
174
|
+
"options": [
|
|
175
|
+
{ "text": "Server Components with App Router", "keywords": ["server-components", "app-router", "rsc"] },
|
|
176
|
+
{ "text": "Client Components only", "keywords": ["client-components", "spa"] },
|
|
177
|
+
{ "text": "Pages Router", "keywords": ["pages-router", "getServerSideProps"] }
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
Example for a Server Components rule (need for guidance):
|
|
182
|
+
{
|
|
183
|
+
"id": "needs-server-component-patterns",
|
|
184
|
+
"text": "Do you need help with Server Component patterns and best practices?",
|
|
185
|
+
"type": "yes-no",
|
|
186
|
+
"tags": ["react", "server-components", "patterns", "best-practices"],
|
|
187
|
+
"keywords": ["server-components", "client-server-separation", "data-fetching", "composition"]
|
|
188
|
+
}`;
|
|
189
|
+
/**
|
|
190
|
+
* Builds the complete prompt for LLM question generation
|
|
191
|
+
* @param rulePath - The path to the rule directory
|
|
192
|
+
* @returns Complete prompt string
|
|
193
|
+
*/
|
|
194
|
+
function buildQuestionPrompt(rulePath) {
|
|
195
|
+
const ruleContent = readRuleContent(rulePath);
|
|
196
|
+
const context = buildRuleContext(ruleContent);
|
|
197
|
+
return `${SYSTEM_PROMPT}
|
|
198
|
+
|
|
199
|
+
Rule to analyze:
|
|
200
|
+
${context}
|
|
201
|
+
|
|
202
|
+
Generate 3-5 relevant questions for this rule. Return only valid JSON.`;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=question-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-prompt.js","sourceRoot":"","sources":["../../../../src/cli/lib/question-prompt.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAwBH,0CA+BC;AAOD,4CAcC;AAwID,kDAUC;AA5ND,qCAAmD;AACnD,yCAAiC;AAgBjC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,QAAgB;IAC/C,kCAAkC;IAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAEpF,IAAI,CAAC,IAAA,oBAAU,EAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAg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AI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;CAC1E,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2HpB,CAAC;AAEH;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,QAAgB;IACnD,MAAM,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9C,OAAO,GAAG,aAAa;;;EAGtB,OAAO;;uEAE8D,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for validating question generation responses
|
|
3
|
+
* Provides type-safe validation with detailed error messages
|
|
4
|
+
*/
|
|
5
|
+
import type { Question, QuestionResponse } from "src/lib/question-types";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Discriminated union schema for all question types
|
|
9
|
+
* Automatically validates based on the 'type' field
|
|
10
|
+
*/
|
|
11
|
+
export declare const QuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
text: z.ZodString;
|
|
14
|
+
tags: z.ZodArray<z.ZodString>;
|
|
15
|
+
type: z.ZodLiteral<"yes-no">;
|
|
16
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
text: z.ZodString;
|
|
20
|
+
tags: z.ZodArray<z.ZodString>;
|
|
21
|
+
type: z.ZodLiteral<"choice">;
|
|
22
|
+
options: z.ZodArray<z.ZodObject<{
|
|
23
|
+
text: z.ZodString;
|
|
24
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
text: z.ZodString;
|
|
29
|
+
tags: z.ZodArray<z.ZodString>;
|
|
30
|
+
type: z.ZodLiteral<"open-ended">;
|
|
31
|
+
}, z.core.$strip>], "type">;
|
|
32
|
+
/**
|
|
33
|
+
* Schema for the complete response containing questions array
|
|
34
|
+
*/
|
|
35
|
+
export declare const QuestionResponseSchema: z.ZodObject<{
|
|
36
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
text: z.ZodString;
|
|
39
|
+
tags: z.ZodArray<z.ZodString>;
|
|
40
|
+
type: z.ZodLiteral<"yes-no">;
|
|
41
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
text: z.ZodString;
|
|
45
|
+
tags: z.ZodArray<z.ZodString>;
|
|
46
|
+
type: z.ZodLiteral<"choice">;
|
|
47
|
+
options: z.ZodArray<z.ZodObject<{
|
|
48
|
+
text: z.ZodString;
|
|
49
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
text: z.ZodString;
|
|
54
|
+
tags: z.ZodArray<z.ZodString>;
|
|
55
|
+
type: z.ZodLiteral<"open-ended">;
|
|
56
|
+
}, z.core.$strip>], "type">>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Validates a question response and returns typed result
|
|
60
|
+
* @param data - Raw data to validate
|
|
61
|
+
* @returns Success result with typed data or error details
|
|
62
|
+
*/
|
|
63
|
+
export declare function validateQuestionResponse(data: unknown): {
|
|
64
|
+
success: true;
|
|
65
|
+
data: QuestionResponse;
|
|
66
|
+
} | {
|
|
67
|
+
success: false;
|
|
68
|
+
error: string;
|
|
69
|
+
details?: z.ZodError;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Validates a single question
|
|
73
|
+
* @param data - Raw data to validate
|
|
74
|
+
* @returns Success result with typed question or error details
|
|
75
|
+
*/
|
|
76
|
+
export declare function validateQuestion(data: unknown): {
|
|
77
|
+
success: true;
|
|
78
|
+
data: Question;
|
|
79
|
+
} | {
|
|
80
|
+
success: false;
|
|
81
|
+
error: string;
|
|
82
|
+
details?: z.ZodError;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=question-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-schema.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/question-schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsDxB;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;2BAIzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;iBAKjC,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GACnD;IACA,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,gBAAgB,CAAC;CACtB,GACD;IACA,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;CACpB,CAyBH;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAC3C;IACA,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CACd,GACD;IACA,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;CACpB,CAyBH"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schemas for validating question generation responses
|
|
4
|
+
* Provides type-safe validation with detailed error messages
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.QuestionResponseSchema = exports.QuestionSchema = void 0;
|
|
8
|
+
exports.validateQuestionResponse = validateQuestionResponse;
|
|
9
|
+
exports.validateQuestion = validateQuestion;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
/**
|
|
12
|
+
* Base schema with common fields for all question types
|
|
13
|
+
*/
|
|
14
|
+
const BaseQuestionSchema = zod_1.z.object({
|
|
15
|
+
id: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.regex(/^[a-z0-9-]+$/, "ID must be in kebab-case (lowercase letters, numbers, and hyphens only)")
|
|
18
|
+
.min(1, "ID cannot be empty"),
|
|
19
|
+
text: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.min(10, "Question text must be at least 10 characters")
|
|
22
|
+
.max(200, "Question text must be at most 200 characters"),
|
|
23
|
+
tags: zod_1.z.array(zod_1.z.string().min(1, "Tags cannot be empty")).min(1, "At least one tag is required"),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Yes/No question schema
|
|
27
|
+
* Requires keywords array for context building
|
|
28
|
+
*/
|
|
29
|
+
const YesNoQuestionSchema = BaseQuestionSchema.extend({
|
|
30
|
+
type: zod_1.z.literal("yes-no"),
|
|
31
|
+
keywords: zod_1.z
|
|
32
|
+
.array(zod_1.z.string().min(1, "Keywords cannot be empty"))
|
|
33
|
+
.min(1, "At least one keyword is required for yes-no questions"),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Choice question schema
|
|
37
|
+
* Requires options array with at least 2 choices
|
|
38
|
+
*/
|
|
39
|
+
const ChoiceQuestionSchema = BaseQuestionSchema.extend({
|
|
40
|
+
type: zod_1.z.literal("choice"),
|
|
41
|
+
options: zod_1.z
|
|
42
|
+
.array(zod_1.z.object({
|
|
43
|
+
text: zod_1.z.string().min(1, "Option text cannot be empty"),
|
|
44
|
+
keywords: zod_1.z
|
|
45
|
+
.array(zod_1.z.string().min(1, "Keywords cannot be empty"))
|
|
46
|
+
.min(1, "At least one keyword is required per option"),
|
|
47
|
+
}))
|
|
48
|
+
.min(2, "Choice questions must have at least 2 options"),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Open-ended question schema
|
|
52
|
+
* No additional fields required
|
|
53
|
+
*/
|
|
54
|
+
const OpenEndedQuestionSchema = BaseQuestionSchema.extend({
|
|
55
|
+
type: zod_1.z.literal("open-ended"),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Discriminated union schema for all question types
|
|
59
|
+
* Automatically validates based on the 'type' field
|
|
60
|
+
*/
|
|
61
|
+
exports.QuestionSchema = zod_1.z.discriminatedUnion("type", [
|
|
62
|
+
YesNoQuestionSchema,
|
|
63
|
+
ChoiceQuestionSchema,
|
|
64
|
+
OpenEndedQuestionSchema,
|
|
65
|
+
]);
|
|
66
|
+
/**
|
|
67
|
+
* Schema for the complete response containing questions array
|
|
68
|
+
*/
|
|
69
|
+
exports.QuestionResponseSchema = zod_1.z.object({
|
|
70
|
+
questions: zod_1.z
|
|
71
|
+
.array(exports.QuestionSchema)
|
|
72
|
+
.min(1, "At least one question is required")
|
|
73
|
+
.max(10, "Maximum 10 questions allowed per rule"),
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Validates a question response and returns typed result
|
|
77
|
+
* @param data - Raw data to validate
|
|
78
|
+
* @returns Success result with typed data or error details
|
|
79
|
+
*/
|
|
80
|
+
function validateQuestionResponse(data) {
|
|
81
|
+
try {
|
|
82
|
+
const result = exports.QuestionResponseSchema.parse(data);
|
|
83
|
+
return { success: true, data: result };
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
87
|
+
const errorMessages = error.issues
|
|
88
|
+
.map((err) => {
|
|
89
|
+
const path = err.path.length > 0 ? `${err.path.join(".")}: ` : "";
|
|
90
|
+
return `${path}${err.message}`;
|
|
91
|
+
})
|
|
92
|
+
.join("\n");
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
error: `Validation failed:\n${errorMessages}`,
|
|
96
|
+
details: error,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
error: `Unknown validation error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Validates a single question
|
|
107
|
+
* @param data - Raw data to validate
|
|
108
|
+
* @returns Success result with typed question or error details
|
|
109
|
+
*/
|
|
110
|
+
function validateQuestion(data) {
|
|
111
|
+
try {
|
|
112
|
+
const result = exports.QuestionSchema.parse(data);
|
|
113
|
+
return { success: true, data: result };
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
117
|
+
const errorMessages = error.issues
|
|
118
|
+
.map((err) => {
|
|
119
|
+
const path = err.path.length > 0 ? `${err.path.join(".")}: ` : "";
|
|
120
|
+
return `${path}${err.message}`;
|
|
121
|
+
})
|
|
122
|
+
.join("\n");
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
error: `Question validation failed:\n${errorMessages}`,
|
|
126
|
+
details: error,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
success: false,
|
|
131
|
+
error: `Unknown validation error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=question-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-schema.js","sourceRoot":"","sources":["../../../../src/cli/lib/question-schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkFH,4DAkCC;AAOD,4CAkCC;AA1JD,6BAAwB;AAExB;;GAEG;AACH,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,OAAC;SACH,MAAM,EAAE;SACR,KAAK,CAAC,cAAc,EAAE,yEAAyE,CAAC;SAChG,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC;IAC9B,IAAI,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,EAAE,EAAE,8CAA8C,CAAC;SACvD,GAAG,CAAC,GAAG,EAAE,8CAA8C,CAAC;IAC1D,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC;CAC/F,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IACrD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,QAAQ,EAAE,OAAC;SACT,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC;SACpD,GAAG,CAAC,CAAC,EAAE,uDAAuD,CAAC;CACjE,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IACtD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,OAAO,EAAE,OAAC;SACR,KAAK,CACL,OAAC,C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CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEb,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,gCAAgC,aAAa,EAAE;gBACtD,OAAO,EAAE,KAAK;aACd,CAAC;QACH,CAAC;QAED,OAAO;YACN,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;SAC9F,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for question generation system
|
|
3
|
+
* Based on the brainstorming documentation requirements
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base fields common to all question types
|
|
7
|
+
*/
|
|
8
|
+
interface BaseQuestion {
|
|
9
|
+
/** Unique identifier in kebab-case */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The question text to display to users */
|
|
12
|
+
text: string;
|
|
13
|
+
/** Tags for fuzzy search matching */
|
|
14
|
+
tags: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Yes/No question type
|
|
18
|
+
* Must include keywords array that gets added to context if user answers yes
|
|
19
|
+
*/
|
|
20
|
+
export interface YesNoQuestion extends BaseQuestion {
|
|
21
|
+
type: "yes-no";
|
|
22
|
+
/** Keywords added to search context if user answers yes */
|
|
23
|
+
keywords: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Choice question type
|
|
27
|
+
* Must include options array with text and keywords for each option
|
|
28
|
+
*/
|
|
29
|
+
export interface ChoiceQuestion extends BaseQuestion {
|
|
30
|
+
type: "choice";
|
|
31
|
+
/** Available choices with their associated keywords */
|
|
32
|
+
options: Array<{
|
|
33
|
+
/** Display text for the choice */
|
|
34
|
+
text: string;
|
|
35
|
+
/** Keywords added to search context if this option is selected */
|
|
36
|
+
keywords: string[];
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Open-ended question type
|
|
41
|
+
* Full user answer text is added to search context
|
|
42
|
+
*/
|
|
43
|
+
export interface OpenEndedQuestion extends BaseQuestion {
|
|
44
|
+
type: "open-ended";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Union type for all question types
|
|
48
|
+
* Uses discriminated union based on the 'type' field
|
|
49
|
+
*/
|
|
50
|
+
export type Question = YesNoQuestion | ChoiceQuestion | OpenEndedQuestion;
|
|
51
|
+
/**
|
|
52
|
+
* Response format containing array of questions
|
|
53
|
+
* This is what gets written to suggested_questions/<rule-id>.json
|
|
54
|
+
*/
|
|
55
|
+
export interface QuestionResponse {
|
|
56
|
+
/** Array of generated questions for this rule */
|
|
57
|
+
questions: Question[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Type guard to check if a question is a Yes/No question
|
|
61
|
+
*/
|
|
62
|
+
export declare function isYesNoQuestion(question: Question): question is YesNoQuestion;
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if a question is a Choice question
|
|
65
|
+
*/
|
|
66
|
+
export declare function isChoiceQuestion(question: Question): question is ChoiceQuestion;
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if a question is an Open-ended question
|
|
69
|
+
*/
|
|
70
|
+
export declare function isOpenEndedQuestion(question: Question): question is OpenEndedQuestion;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=question-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-types.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/question-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,UAAU,YAAY;IACrB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,YAAY;IAClD,IAAI,EAAE,QAAQ,CAAC;IACf,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,YAAY;IACnD,IAAI,EAAE,QAAQ,CAAC;IACf,uDAAuD;IACvD,OAAO,EAAE,KAAK,CAAC;QACd,kCAAkC;QAClC,IAAI,EAAE,MAAM,CAAC;QACb,kEAAkE;QAClE,QAAQ,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACtD,IAAI,EAAE,YAAY,CAAC;CAEnB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,iDAAiD;IACjD,SAAS,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,aAAa,CAE7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,cAAc,CAE/E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,iBAAiB,CAErF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript types for question generation system
|
|
4
|
+
* Based on the brainstorming documentation requirements
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isYesNoQuestion = isYesNoQuestion;
|
|
8
|
+
exports.isChoiceQuestion = isChoiceQuestion;
|
|
9
|
+
exports.isOpenEndedQuestion = isOpenEndedQuestion;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if a question is a Yes/No question
|
|
12
|
+
*/
|
|
13
|
+
function isYesNoQuestion(question) {
|
|
14
|
+
return question.type === "yes-no";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if a question is a Choice question
|
|
18
|
+
*/
|
|
19
|
+
function isChoiceQuestion(question) {
|
|
20
|
+
return question.type === "choice";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a question is an Open-ended question
|
|
24
|
+
*/
|
|
25
|
+
function isOpenEndedQuestion(question) {
|
|
26
|
+
return question.type === "open-ended";
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=question-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-types.js","sourceRoot":"","sources":["../../../../src/cli/lib/question-types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAkEH,0CAEC;AAKD,4CAEC;AAKD,kDAEC;AAnBD;;GAEG;AACH,SAAgB,eAAe,CAAC,QAAkB;IACjD,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,QAAkB;IAClD,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,QAAkB;IACrD,OAAO,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC;AACvC,CAAC"}
|
package/dist/cli/lib/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,IAAI,EAAE,MAAM,EAAE,C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AM,CAAC,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACtC"}
|
package/dist/cli/lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/cli/lib/types.ts"],"names":[],"mappings":";;;AAoDA;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/cli/lib/types.ts"],"names":[],"mappings":";;;AAoDA;;GAEG;AACH,IAAY,OAOX;AAPD,WAAY,OAAO;IAClB,4BAAiB,CAAA;IACjB,gCAAqB,CAAA;IACrB,0BAAe,CAAA;IACf,gCAAqB,CAAA;IACrB,wBAAa,CAAA;IACb,sCAA2B,CAAA;AAC5B,CAAC,EAPW,OAAO,uBAAP,OAAO,QAOlB"}
|