@tagma/sdk 0.3.9 → 0.4.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/package.json +1 -1
- package/src/schema.ts +6 -4
- package/src/validate-raw.ts +17 -6
package/package.json
CHANGED
package/src/schema.ts
CHANGED
|
@@ -41,14 +41,16 @@ function validateRawTask(task: RawTaskConfig, trackId: string): void {
|
|
|
41
41
|
if (!task.id) throw new Error(`track "${trackId}": task.id is required`);
|
|
42
42
|
if (task.use) return; // template usage, validated later
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
44
|
+
const hasPromptKey = typeof task.prompt === 'string';
|
|
45
|
+
const hasCommandKey = typeof task.command === 'string';
|
|
46
|
+
if (!hasPromptKey && !hasCommandKey) {
|
|
47
47
|
throw new Error(`task "${task.id}": must have either "prompt" or "command"`);
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (hasPromptKey && hasCommandKey) {
|
|
50
50
|
throw new Error(`task "${task.id}": cannot have both "prompt" and "command"`);
|
|
51
51
|
}
|
|
52
|
+
// Empty-content tasks (e.g. `prompt: ''`) are allowed at parse time and
|
|
53
|
+
// flagged as non-fatal validation errors by validate-raw.ts.
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
// ═══ Template Expansion ═══
|
package/src/validate-raw.ts
CHANGED
|
@@ -111,19 +111,30 @@ export function validateRaw(config: RawPipelineConfig): ValidationError[] {
|
|
|
111
111
|
// Template-based tasks: skip prompt/command checks (params validated at runtime)
|
|
112
112
|
if (task.use) continue;
|
|
113
113
|
|
|
114
|
-
const
|
|
115
|
-
const
|
|
114
|
+
const hasPromptKey = typeof task.prompt === 'string';
|
|
115
|
+
const hasCommandKey = typeof task.command === 'string';
|
|
116
|
+
const promptEmpty = hasPromptKey && task.prompt!.trim().length === 0;
|
|
117
|
+
const commandEmpty = hasCommandKey && task.command!.trim().length === 0;
|
|
116
118
|
|
|
117
|
-
if (
|
|
119
|
+
if (hasPromptKey && hasCommandKey) {
|
|
120
|
+
errors.push({
|
|
121
|
+
path: taskPath,
|
|
122
|
+
message: `Task "${task.id}": cannot have both "prompt" and "command"`,
|
|
123
|
+
});
|
|
124
|
+
} else if (!hasPromptKey && !hasCommandKey) {
|
|
118
125
|
errors.push({
|
|
119
126
|
path: taskPath,
|
|
120
127
|
message: `Task "${task.id}": must have "prompt" or "command"`,
|
|
121
128
|
});
|
|
122
|
-
}
|
|
123
|
-
if (hasPrompt && hasCommand) {
|
|
129
|
+
} else if (promptEmpty) {
|
|
124
130
|
errors.push({
|
|
125
131
|
path: taskPath,
|
|
126
|
-
message: `Task "${task.id}":
|
|
132
|
+
message: `Task "${task.id}": prompt content cannot be empty`,
|
|
133
|
+
});
|
|
134
|
+
} else if (commandEmpty) {
|
|
135
|
+
errors.push({
|
|
136
|
+
path: taskPath,
|
|
137
|
+
message: `Task "${task.id}": command content cannot be empty`,
|
|
127
138
|
});
|
|
128
139
|
}
|
|
129
140
|
|