dot-agents 0.1.5 → 0.3.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.
Files changed (40) hide show
  1. package/README.md +274 -7
  2. package/dist/cli/commands/check.d.ts +3 -0
  3. package/dist/cli/commands/check.d.ts.map +1 -0
  4. package/dist/cli/commands/check.js +152 -0
  5. package/dist/cli/commands/check.js.map +1 -0
  6. package/dist/cli/commands/index.d.ts +2 -0
  7. package/dist/cli/commands/index.d.ts.map +1 -1
  8. package/dist/cli/commands/index.js +2 -0
  9. package/dist/cli/commands/index.js.map +1 -1
  10. package/dist/cli/commands/init.d.ts +3 -0
  11. package/dist/cli/commands/init.d.ts.map +1 -0
  12. package/dist/cli/commands/init.js +248 -0
  13. package/dist/cli/commands/init.js.map +1 -0
  14. package/dist/cli/index.js +4 -2
  15. package/dist/cli/index.js.map +1 -1
  16. package/dist/lib/index.d.ts +1 -0
  17. package/dist/lib/index.d.ts.map +1 -1
  18. package/dist/lib/index.js +2 -0
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/validation/cron.d.ts +29 -0
  21. package/dist/lib/validation/cron.d.ts.map +1 -0
  22. package/dist/lib/validation/cron.js +159 -0
  23. package/dist/lib/validation/cron.js.map +1 -0
  24. package/dist/lib/validation/index.d.ts +18 -0
  25. package/dist/lib/validation/index.d.ts.map +1 -0
  26. package/dist/lib/validation/index.js +135 -0
  27. package/dist/lib/validation/index.js.map +1 -0
  28. package/dist/lib/validation/persona.d.ts +9 -0
  29. package/dist/lib/validation/persona.d.ts.map +1 -0
  30. package/dist/lib/validation/persona.js +143 -0
  31. package/dist/lib/validation/persona.js.map +1 -0
  32. package/dist/lib/validation/types.d.ts +64 -0
  33. package/dist/lib/validation/types.d.ts.map +1 -0
  34. package/dist/lib/validation/types.js +25 -0
  35. package/dist/lib/validation/types.js.map +1 -0
  36. package/dist/lib/validation/workflow.d.ts +10 -0
  37. package/dist/lib/validation/workflow.d.ts.map +1 -0
  38. package/dist/lib/validation/workflow.js +242 -0
  39. package/dist/lib/validation/workflow.js.map +1 -0
  40. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ import { readdir, stat } from "node:fs/promises";
2
+ import { join, relative } from "node:path";
3
+ import { createError, } from "./types.js";
4
+ import { validateWorkflow, getWorkflowPersonaRef } from "./workflow.js";
5
+ import { validatePersona } from "./persona.js";
6
+ export * from "./types.js";
7
+ export { validateWorkflow } from "./workflow.js";
8
+ export { validatePersona } from "./persona.js";
9
+ export { validateCron } from "./cron.js";
10
+ const PERSONA_FILENAME = "PERSONA.md";
11
+ const WORKFLOW_FILENAME = "WORKFLOW.md";
12
+ /**
13
+ * Check if a directory contains a specific file
14
+ */
15
+ async function hasFile(dirPath, filename) {
16
+ try {
17
+ const filePath = join(dirPath, filename);
18
+ const stats = await stat(filePath);
19
+ return stats.isFile();
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ }
25
+ /**
26
+ * Recursively find all directories containing a specific file
27
+ */
28
+ async function findDirectoriesWithFile(root, filename) {
29
+ const results = [];
30
+ async function scanDir(dir) {
31
+ try {
32
+ const entries = await readdir(dir, { withFileTypes: true });
33
+ for (const entry of entries) {
34
+ if (entry.isDirectory()) {
35
+ const subDir = join(dir, entry.name);
36
+ if (await hasFile(subDir, filename)) {
37
+ results.push(subDir);
38
+ }
39
+ await scanDir(subDir);
40
+ }
41
+ }
42
+ }
43
+ catch {
44
+ // Directory doesn't exist or not readable
45
+ }
46
+ }
47
+ await scanDir(root);
48
+ return results;
49
+ }
50
+ /**
51
+ * Check if a persona path exists
52
+ */
53
+ async function personaExists(personaRef, personasDir) {
54
+ const personaPath = join(personasDir, personaRef);
55
+ return hasFile(personaPath, PERSONA_FILENAME);
56
+ }
57
+ /**
58
+ * Determine if a persona is a root persona (no parent with PERSONA.md)
59
+ */
60
+ async function isRootPersona(personaPath, personasRoot) {
61
+ const relativePath = relative(personasRoot, personaPath);
62
+ const parts = relativePath.split("/").filter(Boolean);
63
+ // If it's directly under personasRoot, it's a root persona
64
+ if (parts.length <= 1) {
65
+ return true;
66
+ }
67
+ // Check if any parent directory has a PERSONA.md
68
+ let currentPath = personasRoot;
69
+ for (let i = 0; i < parts.length - 1; i++) {
70
+ currentPath = join(currentPath, parts[i]);
71
+ if (await hasFile(currentPath, PERSONA_FILENAME)) {
72
+ return false; // Has a parent persona
73
+ }
74
+ }
75
+ return true;
76
+ }
77
+ /**
78
+ * Validate all workflows in a directory
79
+ */
80
+ export async function validateAllWorkflows(workflowsDir, personasDir) {
81
+ const workflowPaths = await findDirectoriesWithFile(workflowsDir, WORKFLOW_FILENAME);
82
+ const results = [];
83
+ for (const workflowPath of workflowPaths) {
84
+ const result = await validateWorkflow(workflowPath);
85
+ // Cross-validate persona reference if personasDir provided
86
+ if (personasDir && result.valid) {
87
+ const personaRef = await getWorkflowPersonaRef(workflowPath);
88
+ if (personaRef && !(await personaExists(personaRef, personasDir))) {
89
+ result.issues.push(createError("reference_not_found", "persona", `Persona '${personaRef}' not found`, `Create persona at: ${join(personasDir, personaRef, PERSONA_FILENAME)}`));
90
+ result.valid = false;
91
+ }
92
+ }
93
+ results.push(result);
94
+ }
95
+ return results;
96
+ }
97
+ /**
98
+ * Validate all personas in a directory
99
+ */
100
+ export async function validateAllPersonas(personasDir) {
101
+ const personaPaths = await findDirectoriesWithFile(personasDir, PERSONA_FILENAME);
102
+ const results = [];
103
+ for (const personaPath of personaPaths) {
104
+ const isRoot = await isRootPersona(personaPath, personasDir);
105
+ const result = await validatePersona(personaPath, isRoot);
106
+ results.push(result);
107
+ }
108
+ return results;
109
+ }
110
+ /**
111
+ * Validate entire .agents directory
112
+ */
113
+ export async function validateAll(agentsDir) {
114
+ const personasDir = join(agentsDir, "personas");
115
+ const workflowsDir = join(agentsDir, "workflows");
116
+ const personaResults = await validateAllPersonas(personasDir);
117
+ const workflowResults = await validateAllWorkflows(workflowsDir, personasDir);
118
+ const validPersonas = personaResults.filter((r) => r.valid).length;
119
+ const validWorkflows = workflowResults.filter((r) => r.valid).length;
120
+ return {
121
+ personas: {
122
+ total: personaResults.length,
123
+ valid: validPersonas,
124
+ results: personaResults,
125
+ },
126
+ workflows: {
127
+ total: workflowResults.length,
128
+ valid: validWorkflows,
129
+ results: workflowResults,
130
+ },
131
+ valid: validPersonas === personaResults.length &&
132
+ validWorkflows === workflowResults.length,
133
+ };
134
+ }
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAGL,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC;;GAEG;AACH,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,QAAgB;IACtD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,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,aAAa;YACpB,OAAO,EAAE,cAAc;SACxB;QACD,SAAS,EAAE;YACT,KAAK,EAAE,eAAe,CAAC,MAAM;YAC7B,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE,eAAe;SACzB;QACD,KAAK,EACH,aAAa,KAAK,cAAc,CAAC,MAAM;YACvC,cAAc,KAAK,eAAe,CAAC,MAAM;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ValidationResult } from "./types.js";
2
+ /**
3
+ * Validate a persona file
4
+ *
5
+ * @param personaPath Path to the persona directory or PERSONA.md file
6
+ * @param isRootPersona Whether this is a root persona (requires cmd)
7
+ */
8
+ export declare function validatePersona(personaPath: string, isRootPersona?: boolean): Promise<ValidationResult>;
9
+ //# sourceMappingURL=persona.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/persona.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAIjB,MAAM,YAAY,CAAC;AA4CpB;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAyL3B"}
@@ -0,0 +1,143 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join, dirname } from "node:path";
3
+ import { parse as parseYaml } from "yaml";
4
+ import { createError, createWarning, } from "./types.js";
5
+ const PERSONA_FILENAME = "PERSONA.md";
6
+ /**
7
+ * Known persona frontmatter fields
8
+ */
9
+ const KNOWN_FIELDS = new Set(["name", "description", "cmd", "env", "skills"]);
10
+ /**
11
+ * Common legacy/misnamed fields and their correct names
12
+ */
13
+ const FIELD_SUGGESTIONS = {
14
+ command: "cmd",
15
+ commands: "cmd",
16
+ skill: "skills",
17
+ environment: "env",
18
+ variables: "env",
19
+ model: "env.CLAUDE_MODEL or similar",
20
+ };
21
+ /**
22
+ * Parse frontmatter from markdown content without full validation
23
+ */
24
+ function parseFrontmatter(content) {
25
+ const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
26
+ const match = content.match(frontmatterRegex);
27
+ if (!match) {
28
+ return null;
29
+ }
30
+ const [, yamlContent, body] = match;
31
+ try {
32
+ const frontmatter = parseYaml(yamlContent);
33
+ return { frontmatter, body: body.trim() };
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ /**
40
+ * Validate a persona file
41
+ *
42
+ * @param personaPath Path to the persona directory or PERSONA.md file
43
+ * @param isRootPersona Whether this is a root persona (requires cmd)
44
+ */
45
+ export async function validatePersona(personaPath, isRootPersona = true) {
46
+ const filePath = personaPath.endsWith(PERSONA_FILENAME)
47
+ ? personaPath
48
+ : join(personaPath, PERSONA_FILENAME);
49
+ const issues = [];
50
+ let name;
51
+ try {
52
+ const content = await readFile(filePath, "utf-8");
53
+ const parsed = parseFrontmatter(content);
54
+ if (!parsed) {
55
+ issues.push(createError("invalid_value", "frontmatter", "No valid YAML frontmatter found", "File must start with --- followed by YAML and another ---"));
56
+ return {
57
+ path: filePath,
58
+ valid: false,
59
+ issues,
60
+ };
61
+ }
62
+ const { frontmatter } = parsed;
63
+ name = frontmatter.name;
64
+ // Check required fields
65
+ if (!frontmatter.name) {
66
+ issues.push(createError("missing_field", "name", "Missing required 'name' field", "Add: name: my-persona"));
67
+ }
68
+ else if (typeof frontmatter.name !== "string") {
69
+ issues.push(createError("invalid_type", "name", "'name' must be a string"));
70
+ }
71
+ // cmd is required for root personas, optional for child personas (inherited)
72
+ if (isRootPersona && !frontmatter.cmd) {
73
+ issues.push(createError("missing_field", "cmd", "Missing required 'cmd' field for root persona", "Add: cmd: \"claude --print\" or cmd: [\"claude --print\", \"claude -p\"]"));
74
+ }
75
+ // Validate cmd type if present
76
+ if (frontmatter.cmd !== undefined) {
77
+ if (typeof frontmatter.cmd !== "string" &&
78
+ !Array.isArray(frontmatter.cmd)) {
79
+ issues.push(createError("invalid_type", "cmd", "'cmd' must be a string or array of strings", "Use: cmd: \"claude --print\" or cmd: [\"claude --print\"]"));
80
+ }
81
+ else if (Array.isArray(frontmatter.cmd)) {
82
+ frontmatter.cmd.forEach((c, index) => {
83
+ if (typeof c !== "string") {
84
+ issues.push(createError("invalid_type", `cmd[${index}]`, "Command must be a string"));
85
+ }
86
+ });
87
+ }
88
+ }
89
+ // Validate env if present
90
+ if (frontmatter.env !== undefined) {
91
+ if (typeof frontmatter.env !== "object" ||
92
+ Array.isArray(frontmatter.env) ||
93
+ frontmatter.env === null) {
94
+ issues.push(createError("invalid_type", "env", "'env' must be an object", "Use: env: { CLAUDE_MODEL: 'sonnet' }"));
95
+ }
96
+ else {
97
+ // Check that all env values are strings
98
+ const env = frontmatter.env;
99
+ for (const [key, value] of Object.entries(env)) {
100
+ if (typeof value !== "string") {
101
+ issues.push(createWarning("unknown_field", `env.${key}`, `Environment variable '${key}' should be a string, got ${typeof value}`, "Convert to string or use ${VAR} expansion"));
102
+ }
103
+ }
104
+ }
105
+ }
106
+ // Validate skills if present
107
+ if (frontmatter.skills !== undefined) {
108
+ if (!Array.isArray(frontmatter.skills)) {
109
+ issues.push(createError("invalid_type", "skills", "'skills' must be an array of glob patterns", "Use: skills: [\"productivity/**\", \"!experimental/*\"]"));
110
+ }
111
+ else {
112
+ frontmatter.skills.forEach((skill, index) => {
113
+ if (typeof skill !== "string") {
114
+ issues.push(createError("invalid_type", `skills[${index}]`, "Skill pattern must be a string"));
115
+ }
116
+ });
117
+ }
118
+ }
119
+ // Check for unknown/legacy fields
120
+ for (const key of Object.keys(frontmatter)) {
121
+ if (!KNOWN_FIELDS.has(key)) {
122
+ const suggestion = FIELD_SUGGESTIONS[key];
123
+ if (suggestion) {
124
+ issues.push(createWarning("unknown_field", key, `Unknown field '${key}'`, `Did you mean '${suggestion}'?`));
125
+ }
126
+ else {
127
+ issues.push(createWarning("unknown_field", key, `Unknown field '${key}'`));
128
+ }
129
+ }
130
+ }
131
+ }
132
+ catch (error) {
133
+ issues.push(createError("invalid_value", "file", `Failed to read persona: ${error.message}`));
134
+ }
135
+ const hasErrors = issues.some((i) => i.severity === "error");
136
+ return {
137
+ path: dirname(filePath),
138
+ name,
139
+ valid: !hasErrors,
140
+ issues,
141
+ };
142
+ }
143
+ //# sourceMappingURL=persona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona.js","sourceRoot":"","sources":["../../../src/lib/validation/persona.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAGL,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,iBAAiB,GAA2B;IAChD,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,KAAK;IAClB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAe;IAIvC,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;IACvE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAE9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,SAAS,CAA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G,CAAC,CAAC;gBAC1C,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CACT,aAAa,CACX,eAAe,EACf,GAAG,EACH,kBAAkB,GAAG,GAAG,EACxB,iBAAiB,UAAU,IAAI,CAChC,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CACT,aAAa,CAAC,eAAe,EAAE,GAAG,EAAE,kBAAkB,GAAG,GAAG,CAAC,CAC9D,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CACT,WAAW,CACT,eAAe,EACf,MAAM,EACN,2BAA4B,KAAe,CAAC,OAAO,EAAE,CACtD,CACF,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IAE7D,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;QACvB,IAAI;QACJ,KAAK,EAAE,CAAC,SAAS;QACjB,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Severity levels for validation issues
3
+ */
4
+ export type ValidationSeverity = "error" | "warning";
5
+ /**
6
+ * Types of validation errors
7
+ */
8
+ export type ValidationErrorType = "missing_field" | "invalid_type" | "invalid_value" | "reference_not_found";
9
+ /**
10
+ * Types of validation warnings
11
+ */
12
+ export type ValidationWarningType = "unknown_field" | "deprecated_field";
13
+ /**
14
+ * A validation issue (error or warning)
15
+ */
16
+ export interface ValidationIssue {
17
+ severity: ValidationSeverity;
18
+ type: ValidationErrorType | ValidationWarningType;
19
+ /** Path to the problematic field (e.g., "on.schedule[0].cron") */
20
+ path: string;
21
+ /** Human-readable error message */
22
+ message: string;
23
+ /** Suggestion for how to fix the issue */
24
+ suggestion?: string;
25
+ }
26
+ /**
27
+ * Result of validating a single resource
28
+ */
29
+ export interface ValidationResult {
30
+ /** Path to the resource */
31
+ path: string;
32
+ /** Resource name (if available) */
33
+ name?: string;
34
+ /** Whether the resource is valid (no errors, warnings are ok) */
35
+ valid: boolean;
36
+ /** All issues found */
37
+ issues: ValidationIssue[];
38
+ }
39
+ /**
40
+ * Summary of validation across multiple resources
41
+ */
42
+ export interface ValidationSummary {
43
+ workflows: {
44
+ total: number;
45
+ valid: number;
46
+ results: ValidationResult[];
47
+ };
48
+ personas: {
49
+ total: number;
50
+ valid: number;
51
+ results: ValidationResult[];
52
+ };
53
+ /** Overall validity (all resources valid) */
54
+ valid: boolean;
55
+ }
56
+ /**
57
+ * Helper to create an error issue
58
+ */
59
+ export declare function createError(type: ValidationErrorType, path: string, message: string, suggestion?: string): ValidationIssue;
60
+ /**
61
+ * Helper to create a warning issue
62
+ */
63
+ export declare function createWarning(type: ValidationWarningType, path: string, message: string, suggestion?: string): ValidationIssue;
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,cAAc,GACd,eAAe,GACf,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,mBAAmB,GAAG,qBAAqB,CAAC;IAClD,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,OAAO,CAAC;IACf,uBAAuB;IACvB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,gBAAgB,EAAE,CAAC;KAC7B,CAAC;IACF,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,gBAAgB,EAAE,CAAC;KAC7B,CAAC;IACF,6CAA6C;IAC7C,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,GAClB,eAAe,CAQjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,qBAAqB,EAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,GAClB,eAAe,CAQjB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Helper to create an error issue
3
+ */
4
+ export function createError(type, path, message, suggestion) {
5
+ return {
6
+ severity: "error",
7
+ type,
8
+ path,
9
+ message,
10
+ suggestion,
11
+ };
12
+ }
13
+ /**
14
+ * Helper to create a warning issue
15
+ */
16
+ export function createWarning(type, path, message, suggestion) {
17
+ return {
18
+ severity: "warning",
19
+ type,
20
+ path,
21
+ message,
22
+ suggestion,
23
+ };
24
+ }
25
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/validation/types.ts"],"names":[],"mappings":"AAiEA;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,IAAyB,EACzB,IAAY,EACZ,OAAe,EACf,UAAmB;IAEnB,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,IAA2B,EAC3B,IAAY,EACZ,OAAe,EACf,UAAmB;IAEnB,OAAO;QACL,QAAQ,EAAE,SAAS;QACnB,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ValidationResult } from "./types.js";
2
+ /**
3
+ * Validate a workflow file
4
+ */
5
+ export declare function validateWorkflow(workflowPath: string): Promise<ValidationResult>;
6
+ /**
7
+ * Get the persona referenced by a workflow (for cross-validation)
8
+ */
9
+ export declare function getWorkflowPersonaRef(workflowPath: string): Promise<string | null>;
10
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/workflow.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAIjB,MAAM,YAAY,CAAC;AAgMpB;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAyM3B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB"}
@@ -0,0 +1,242 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join, dirname } from "node:path";
3
+ import { parse as parseYaml } from "yaml";
4
+ import { createError, createWarning, } from "./types.js";
5
+ import { validateCron, suggestCronFromHint } from "./cron.js";
6
+ const WORKFLOW_FILENAME = "WORKFLOW.md";
7
+ /**
8
+ * Known workflow frontmatter fields
9
+ */
10
+ const KNOWN_FIELDS = new Set([
11
+ "name",
12
+ "description",
13
+ "persona",
14
+ "on",
15
+ "inputs",
16
+ "outputs",
17
+ "env",
18
+ "timeout",
19
+ "retry",
20
+ "working_dir",
21
+ ]);
22
+ /**
23
+ * Common legacy/misnamed fields and their correct names
24
+ */
25
+ const FIELD_SUGGESTIONS = {
26
+ goal: "description",
27
+ skills_used: "persona (skills belong in the persona definition)",
28
+ skills: "persona (skills belong in the persona definition)",
29
+ schedule: "on.schedule",
30
+ trigger: "on",
31
+ triggers: "on",
32
+ command: "persona (command belongs in the persona definition)",
33
+ cmd: "persona (command belongs in the persona definition)",
34
+ };
35
+ /**
36
+ * Parse frontmatter from markdown content without full validation
37
+ */
38
+ function parseFrontmatter(content) {
39
+ const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
40
+ const match = content.match(frontmatterRegex);
41
+ if (!match) {
42
+ return null;
43
+ }
44
+ const [, yamlContent, body] = match;
45
+ try {
46
+ const frontmatter = parseYaml(yamlContent);
47
+ return { frontmatter, body: body.trim() };
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ /**
54
+ * Validate the 'on' trigger configuration
55
+ */
56
+ function validateTriggers(on, issues) {
57
+ if (on === undefined || on === null) {
58
+ return; // 'on' is optional
59
+ }
60
+ if (typeof on !== "object" || Array.isArray(on)) {
61
+ issues.push(createError("invalid_type", "on", "'on' must be an object with trigger configurations", "Example: on: { manual: true, schedule: [{cron: '0 9 * * *'}] }"));
62
+ return;
63
+ }
64
+ const triggers = on;
65
+ // Validate schedule
66
+ if (triggers.schedule !== undefined) {
67
+ if (typeof triggers.schedule === "string") {
68
+ // Common mistake: using a string instead of array
69
+ const hint = suggestCronFromHint(triggers.schedule);
70
+ issues.push(createError("invalid_type", "on.schedule", "'schedule' must be an array of {cron: string} objects, got string", hint
71
+ ? `Use: schedule: [{ cron: "${hint}" }]`
72
+ : "Use: schedule: [{ cron: \"0 9 * * *\" }]"));
73
+ }
74
+ else if (!Array.isArray(triggers.schedule)) {
75
+ issues.push(createError("invalid_type", "on.schedule", "'schedule' must be an array", "Use: schedule: [{ cron: \"0 9 * * *\" }]"));
76
+ }
77
+ else {
78
+ // Validate each schedule entry
79
+ triggers.schedule.forEach((entry, index) => {
80
+ if (typeof entry !== "object" || entry === null) {
81
+ issues.push(createError("invalid_type", `on.schedule[${index}]`, "Schedule entry must be an object with 'cron' field", "Use: { cron: \"0 9 * * *\" }"));
82
+ return;
83
+ }
84
+ const scheduleEntry = entry;
85
+ if (typeof scheduleEntry.cron !== "string") {
86
+ issues.push(createError("missing_field", `on.schedule[${index}].cron`, "Schedule entry missing required 'cron' field", "Add: cron: \"0 9 * * *\""));
87
+ return;
88
+ }
89
+ // Validate cron expression
90
+ const cronResult = validateCron(scheduleEntry.cron);
91
+ if (!cronResult.valid) {
92
+ issues.push(createError("invalid_value", `on.schedule[${index}].cron`, `Invalid cron expression: ${cronResult.error}`, "Format: minute hour day-of-month month day-of-week (e.g., \"30 9 * * 1-5\")"));
93
+ }
94
+ });
95
+ }
96
+ }
97
+ // Validate manual trigger
98
+ if (triggers.manual !== undefined) {
99
+ if (typeof triggers.manual !== "boolean" &&
100
+ typeof triggers.manual !== "object") {
101
+ issues.push(createError("invalid_type", "on.manual", "'manual' must be true/false or an object with input overrides", "Use: manual: true"));
102
+ }
103
+ }
104
+ // Check for unknown trigger types
105
+ const knownTriggers = new Set([
106
+ "schedule",
107
+ "manual",
108
+ "file_change",
109
+ "webhook",
110
+ "workflow_complete",
111
+ "git",
112
+ "github",
113
+ ]);
114
+ for (const key of Object.keys(triggers)) {
115
+ if (!knownTriggers.has(key)) {
116
+ issues.push(createWarning("unknown_field", `on.${key}`, `Unknown trigger type '${key}'`, `Known triggers: ${Array.from(knownTriggers).join(", ")}`));
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * Validate a workflow file
122
+ */
123
+ export async function validateWorkflow(workflowPath) {
124
+ const filePath = workflowPath.endsWith(WORKFLOW_FILENAME)
125
+ ? workflowPath
126
+ : join(workflowPath, WORKFLOW_FILENAME);
127
+ const issues = [];
128
+ let name;
129
+ try {
130
+ const content = await readFile(filePath, "utf-8");
131
+ const parsed = parseFrontmatter(content);
132
+ if (!parsed) {
133
+ issues.push(createError("invalid_value", "frontmatter", "No valid YAML frontmatter found", "File must start with --- followed by YAML and another ---"));
134
+ return {
135
+ path: filePath,
136
+ valid: false,
137
+ issues,
138
+ };
139
+ }
140
+ const { frontmatter, body } = parsed;
141
+ name = frontmatter.name;
142
+ // Check required fields
143
+ if (!frontmatter.name) {
144
+ issues.push(createError("missing_field", "name", "Missing required 'name' field", "Add: name: my-workflow"));
145
+ }
146
+ else if (typeof frontmatter.name !== "string") {
147
+ issues.push(createError("invalid_type", "name", "'name' must be a string"));
148
+ }
149
+ if (!frontmatter.description) {
150
+ // Check if they used 'goal' instead
151
+ if (frontmatter.goal) {
152
+ issues.push(createError("missing_field", "description", "Missing required 'description' field", "Rename 'goal' to 'description'"));
153
+ }
154
+ else {
155
+ issues.push(createError("missing_field", "description", "Missing required 'description' field", "Add: description: What this workflow does"));
156
+ }
157
+ }
158
+ else if (typeof frontmatter.description !== "string") {
159
+ issues.push(createError("invalid_type", "description", "'description' must be a string"));
160
+ }
161
+ if (!frontmatter.persona) {
162
+ issues.push(createError("missing_field", "persona", "Missing required 'persona' field", "Add: persona: claude"));
163
+ }
164
+ else if (typeof frontmatter.persona !== "string") {
165
+ issues.push(createError("invalid_type", "persona", "'persona' must be a string"));
166
+ }
167
+ // Check for task body
168
+ if (!body) {
169
+ issues.push(createError("missing_field", "body", "Missing task body after frontmatter", "Add the task/prompt content after the --- delimiter"));
170
+ }
171
+ // Validate triggers
172
+ validateTriggers(frontmatter.on, issues);
173
+ // Check for unknown/legacy fields
174
+ for (const key of Object.keys(frontmatter)) {
175
+ if (!KNOWN_FIELDS.has(key)) {
176
+ const suggestion = FIELD_SUGGESTIONS[key];
177
+ if (suggestion) {
178
+ issues.push(createWarning("unknown_field", key, `Unknown field '${key}'`, `Did you mean '${suggestion}'?`));
179
+ }
180
+ else {
181
+ issues.push(createWarning("unknown_field", key, `Unknown field '${key}'`));
182
+ }
183
+ }
184
+ }
185
+ // Validate inputs if present
186
+ if (frontmatter.inputs !== undefined) {
187
+ if (!Array.isArray(frontmatter.inputs)) {
188
+ issues.push(createError("invalid_type", "inputs", "'inputs' must be an array", "Use: inputs: [{ name: 'myInput', type: 'string' }]"));
189
+ }
190
+ else {
191
+ frontmatter.inputs.forEach((input, index) => {
192
+ if (typeof input !== "object" || input === null) {
193
+ issues.push(createError("invalid_type", `inputs[${index}]`, "Input definition must be an object"));
194
+ return;
195
+ }
196
+ const inputDef = input;
197
+ if (!inputDef.name || typeof inputDef.name !== "string") {
198
+ issues.push(createError("missing_field", `inputs[${index}].name`, "Input definition missing required 'name' field"));
199
+ }
200
+ });
201
+ }
202
+ }
203
+ // Validate env if present
204
+ if (frontmatter.env !== undefined) {
205
+ if (typeof frontmatter.env !== "object" ||
206
+ Array.isArray(frontmatter.env) ||
207
+ frontmatter.env === null) {
208
+ issues.push(createError("invalid_type", "env", "'env' must be an object", "Use: env: { KEY: 'value' }"));
209
+ }
210
+ }
211
+ }
212
+ catch (error) {
213
+ issues.push(createError("invalid_value", "file", `Failed to read workflow: ${error.message}`));
214
+ }
215
+ const hasErrors = issues.some((i) => i.severity === "error");
216
+ return {
217
+ path: dirname(filePath),
218
+ name,
219
+ valid: !hasErrors,
220
+ issues,
221
+ };
222
+ }
223
+ /**
224
+ * Get the persona referenced by a workflow (for cross-validation)
225
+ */
226
+ export async function getWorkflowPersonaRef(workflowPath) {
227
+ const filePath = workflowPath.endsWith(WORKFLOW_FILENAME)
228
+ ? workflowPath
229
+ : join(workflowPath, WORKFLOW_FILENAME);
230
+ try {
231
+ const content = await readFile(filePath, "utf-8");
232
+ const parsed = parseFrontmatter(content);
233
+ if (parsed && typeof parsed.frontmatter.persona === "string") {
234
+ return parsed.frontmatter.persona;
235
+ }
236
+ }
237
+ catch {
238
+ // Ignore errors
239
+ }
240
+ return null;
241
+ }
242
+ //# sourceMappingURL=workflow.js.map