@scout9/app 1.0.0-alpha.0.5.3 → 1.0.0-alpha.0.5.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.
@@ -3,6 +3,7 @@ import colors from 'kleur';
3
3
  import { globSync } from 'glob';
4
4
  import { checkVariableType, requireProjectFile } from '../../utils/index.js';
5
5
  import { AgentsConfigurationSchema, AgentsSchema } from '../../runtime/index.js';
6
+ import { logUserValidationError } from '../../report.js';
6
7
 
7
8
  /**
8
9
  * @param {Array<Agent>} agents
@@ -29,7 +30,7 @@ export function validateAgentConfig(agents) {
29
30
  const result = AgentsSchema.safeParse(agents);
30
31
  if (!result.success) {
31
32
  result.error.source = `src/entities/agents.js|ts`;
32
- throw result.error;
33
+ throw logUserValidationError(result.error, `src/entities/agents.js|ts`)
33
34
  }
34
35
  return agents;
35
36
  }
@@ -7,6 +7,8 @@ import {
7
7
  EntityRootProjectConfigurationSchema
8
8
  } from '../../runtime/index.js';
9
9
  import { checkVariableType, requireOptionalProjectFile, requireProjectFile } from '../module.js';
10
+ import { logUserValidationError } from '../../report.js';
11
+ import { simplifyError } from '../error.js';
10
12
 
11
13
  async function loadEntityApiConfig(cwd, filePath) {
12
14
  const dir = path.dirname(filePath);
@@ -86,7 +88,7 @@ export default async function loadEntitiesConfig(
86
88
  const result = EntityConfigurationSchema.safeParse(entityConfig, {path: ['entities', config.length]});
87
89
  if (!result.success) {
88
90
  result.error.source = filePath;
89
- throw result.error;
91
+ throw logUserValidationError(result.error, filePath);
90
92
  }
91
93
  } else if (isSpecial && (fileName === 'index' || fileName === 'config')) {
92
94
  // If this is a special entity file, then ignore as we will capture it another method
@@ -100,7 +102,12 @@ export default async function loadEntitiesConfig(
100
102
  entities: parents.reverse(),
101
103
  api
102
104
  };
103
- EntityRootProjectConfigurationSchema.parse(entityProjectConfig);
105
+
106
+ try {
107
+ EntityRootProjectConfigurationSchema.parse(entityProjectConfig);
108
+ } catch (e) {
109
+ throw simplifyError(e);
110
+ }
104
111
  const existingIndex = config.findIndex(c => c.entity === entityProjectConfig.entity);
105
112
  if (existingIndex > -1) {
106
113
  if (config[existingIndex].entities.length !== entityProjectConfig.entities.length) {
@@ -138,8 +145,11 @@ export default async function loadEntitiesConfig(
138
145
  // }
139
146
 
140
147
  // Validate the config
141
- EntitiesRootProjectConfigurationSchema.parse(config);
148
+ try {
149
+ return EntitiesRootProjectConfigurationSchema.parse(config);
150
+ } catch (e) {
151
+ throw simplifyError(e);
152
+ }
142
153
 
143
- return config;
144
154
  }
145
155
 
@@ -1,47 +1,54 @@
1
1
  import { globSync } from 'glob';
2
2
  import { WorkflowConfigurationSchema, WorkflowsConfigurationSchema } from '../../runtime/index.js';
3
+ import { simplifyError } from '../error.js';
4
+ import { logUserValidationError } from '../../report.js';
3
5
 
4
6
 
5
7
  /**
6
- * @returns {Promise<WorkflowsBuildConfig>}
8
+ * @returns {Promise<WorkflowsConfigurationSchema>}
7
9
  */
8
10
  export default async function loadWorkflowsConfig(
9
- {
10
- cwd = process.cwd(),
11
- src = 'src',
12
- // cb = (message) => {}
13
- } = {}
11
+ {
12
+ cwd = process.cwd(),
13
+ src = 'src'
14
+ // cb = (message) => {}
15
+ } = {}
14
16
  ) {
15
- // const config = globSync(path.resolve(cwd, `${src}/workflows/**/workflow.{ts,js}`), {cwd, absolute: true})
16
- const config = globSync(`${src}/workflows/**/workflow.{ts,js}`, {cwd, absolute: true})
17
- .map((path) => {
18
- const segments = path.split('/');
19
- const srcIndex = segments.findIndex((segment, index) => segment === src && segments[index + 1] === 'workflows');
20
- const parents = segments.slice(srcIndex + 2, -1).reverse(); // +2 to skip "${src}" and "workflows"
21
- return {path, parents};
22
- })
23
- .filter(path => {
24
- if (path.parents.length > 0) {
25
- return true;
26
- } else {
27
- console.log(`WARNING: "${path}" Is not a valid entity path, must be contained in a named src under workflows/`);
28
- }
29
- })
30
- .map(({path, parents}) => {
17
+ // const config = globSync(path.resolve(cwd, `${src}/workflows/**/workflow.{ts,js}`), {cwd, absolute: true})
18
+ const config = globSync(`${src}/workflows/**/workflow.{ts,js}`, {cwd, absolute: true})
19
+ .map((path) => {
20
+ const segments = path.split('/');
21
+ const srcIndex = segments.findIndex((segment, index) => segment === src && segments[index + 1] === 'workflows');
22
+ const parents = segments.slice(srcIndex + 2, -1).reverse(); // +2 to skip "${src}" and "workflows"
23
+ return {path, parents};
24
+ })
25
+ .filter(path => {
26
+ if (path.parents.length > 0) {
27
+ return true;
28
+ } else {
29
+ console.log(`WARNING: "${path}" Is not a valid entity path, must be contained in a named src under workflows/`);
30
+ }
31
+ })
32
+ .map(({path, parents}) => {
31
33
 
32
- // Validate project configuration
33
- /** @type {WorkflowBuildConfig} */
34
- const workflowConfig = {
35
- entity: parents[0],
36
- entities: parents.reverse(),
37
- }
38
- WorkflowConfigurationSchema.parse(workflowConfig);
34
+ // Validate project configuration
35
+ /** @type {WorkflowConfigurationSchema} */
36
+ const workflowConfig = {
37
+ entity: parents[0],
38
+ entities: parents.reverse()
39
+ };
40
+ try {
41
+ return WorkflowConfigurationSchema.parse(workflowConfig);
42
+ } catch (e) {
43
+ throw logUserValidationError(e, path);
44
+ }
45
+ });
39
46
 
40
- return workflowConfig;
41
- });
47
+ // Validate the config
48
+ try {
49
+ return WorkflowsConfigurationSchema.parse(config);
50
+ } catch (e) {
51
+ throw simplifyError(e);
52
+ }
42
53
 
43
- // Validate the config
44
- WorkflowsConfigurationSchema.parse(config);
45
-
46
- return config;
47
54
  }
@@ -11,6 +11,7 @@ import loadWorkflowsConfig from './configs/workflow.js';
11
11
  import { Scout9ProjectBuildConfigSchema } from '../runtime/index.js';
12
12
  import { ProgressLogger } from './logger.js';
13
13
  import { formatGlobPattern, normalizeGlobPattern } from './glob.js';
14
+ import { logUserValidationError } from '../report.js';
14
15
 
15
16
  /**
16
17
  * Utility class to load and write project files in a targeted way
@@ -278,7 +279,8 @@ export default class ProjectFiles {
278
279
  ...(await this._loadEnv()),
279
280
  entities: [],
280
281
  agents: [],
281
- workflows: []
282
+ workflows: [],
283
+ commands: []
282
284
  };
283
285
 
284
286
  // Load entities, except for special entities such as ["agents"]
@@ -298,7 +300,7 @@ export default class ProjectFiles {
298
300
  const result = Scout9ProjectBuildConfigSchema.safeParse(projectConfig);
299
301
  if (!result.success) {
300
302
  result.error.source = `${this.src}/index.js`;
301
- throw result.error;
303
+ throw logUserValidationError(result.error, `${this.src}/index.js`);
302
304
  }
303
305
 
304
306
  // Log