convoke-agents 3.0.4 → 3.2.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/CHANGELOG.md +60 -0
- package/README.md +14 -13
- package/_bmad/bme/_artifacts/config.yaml +15 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/SKILL.md +6 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/steps/step-01-scope.md +138 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/steps/step-02-dryrun.md +199 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/steps/step-03-resolve.md +174 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/steps/step-04-execute.md +213 -0
- package/_bmad/bme/_artifacts/workflows/bmad-migrate-artifacts/workflow.md +85 -0
- package/_bmad/bme/_artifacts/workflows/bmad-portfolio-status/SKILL.md +6 -0
- package/_bmad/bme/_artifacts/workflows/bmad-portfolio-status/steps/step-01-scan.md +131 -0
- package/_bmad/bme/_artifacts/workflows/bmad-portfolio-status/steps/step-02-explore.md +131 -0
- package/_bmad/bme/_artifacts/workflows/bmad-portfolio-status/steps/step-03-recommend.md +149 -0
- package/_bmad/bme/_artifacts/workflows/bmad-portfolio-status/workflow.md +78 -0
- package/_bmad/bme/_gyre/guides/GYRE-TEAM-GUIDE.md +506 -0
- package/_bmad/bme/_portability/skills/bmad-export-skill/SKILL.md +6 -0
- package/_bmad/bme/_portability/skills/bmad-export-skill/workflow.md +74 -0
- package/_bmad/bme/_portability/skills/bmad-generate-catalog/SKILL.md +6 -0
- package/_bmad/bme/_portability/skills/bmad-generate-catalog/workflow.md +42 -0
- package/_bmad/bme/_portability/skills/bmad-seed-catalog/SKILL.md +6 -0
- package/_bmad/bme/_portability/skills/bmad-seed-catalog/workflow.md +61 -0
- package/_bmad/bme/_portability/skills/bmad-validate-exports/SKILL.md +6 -0
- package/_bmad/bme/_portability/skills/bmad-validate-exports/workflow.md +43 -0
- package/_bmad/bme/_team-factory/agents/team-factory.md +128 -0
- package/_bmad/bme/_team-factory/config.yaml +13 -0
- package/_bmad/bme/_team-factory/lib/cascade-logic.js +184 -0
- package/_bmad/bme/_team-factory/lib/collision-detector.js +228 -0
- package/_bmad/bme/_team-factory/lib/manifest-tracker.js +214 -0
- package/_bmad/bme/_team-factory/lib/spec-differ.js +176 -0
- package/_bmad/bme/_team-factory/lib/spec-parser.js +201 -0
- package/_bmad/bme/_team-factory/lib/spec-writer.js +128 -0
- package/_bmad/bme/_team-factory/lib/types/factory-types.js +193 -0
- package/_bmad/bme/_team-factory/lib/utils/csv-utils.js +62 -0
- package/_bmad/bme/_team-factory/lib/utils/naming-utils.js +45 -0
- package/_bmad/bme/_team-factory/lib/validators/end-to-end-validator.js +898 -0
- package/_bmad/bme/_team-factory/lib/writers/activation-validator.js +175 -0
- package/_bmad/bme/_team-factory/lib/writers/config-appender.js +192 -0
- package/_bmad/bme/_team-factory/lib/writers/config-creator.js +215 -0
- package/_bmad/bme/_team-factory/lib/writers/csv-appender.js +118 -0
- package/_bmad/bme/_team-factory/lib/writers/csv-creator.js +190 -0
- package/_bmad/bme/_team-factory/lib/writers/registry-appender.js +372 -0
- package/_bmad/bme/_team-factory/lib/writers/registry-writer.js +409 -0
- package/_bmad/bme/_team-factory/module-help.csv +3 -0
- package/_bmad/bme/_team-factory/schemas/schema-independent.json +147 -0
- package/_bmad/bme/_team-factory/schemas/schema-sequential.json +242 -0
- package/_bmad/bme/_team-factory/templates/team-spec-template.yaml +86 -0
- package/_bmad/bme/_team-factory/workflows/add-team/step-01-scope.md +105 -0
- package/_bmad/bme/_team-factory/workflows/add-team/step-02-connect.md +110 -0
- package/_bmad/bme/_team-factory/workflows/add-team/step-03-review.md +116 -0
- package/_bmad/bme/_team-factory/workflows/add-team/step-04-generate.md +160 -0
- package/_bmad/bme/_team-factory/workflows/add-team/step-05-validate.md +146 -0
- package/_bmad/bme/_team-factory/workflows/step-00-route.md +76 -0
- package/_bmad/bme/_vortex/config.yaml +4 -4
- package/_bmad/bme/_vortex/guides/VORTEX-TEAM-GUIDE.md +441 -0
- package/package.json +17 -8
- package/scripts/archive.js +26 -45
- package/scripts/convoke-check.js +88 -0
- package/scripts/convoke-doctor.js +303 -4
- package/scripts/install-gyre-agents.js +0 -0
- package/scripts/lib/artifact-utils.js +2182 -0
- package/scripts/lib/portfolio/formatters/markdown-formatter.js +40 -0
- package/scripts/lib/portfolio/formatters/terminal-formatter.js +56 -0
- package/scripts/lib/portfolio/portfolio-engine.js +572 -0
- package/scripts/lib/portfolio/rules/artifact-chain-rule.js +156 -0
- package/scripts/lib/portfolio/rules/conflict-resolver.js +99 -0
- package/scripts/lib/portfolio/rules/frontmatter-rule.js +42 -0
- package/scripts/lib/portfolio/rules/git-recency-rule.js +69 -0
- package/scripts/lib/types.js +122 -0
- package/scripts/migrate-artifacts.js +439 -0
- package/scripts/portability/catalog-generator.js +353 -0
- package/scripts/portability/classify-skills.js +646 -0
- package/scripts/portability/convoke-export.js +522 -0
- package/scripts/portability/export-engine.js +1133 -0
- package/scripts/portability/generate-adapters.js +79 -0
- package/scripts/portability/manifest-csv.js +147 -0
- package/scripts/portability/seed-catalog-repo.js +427 -0
- package/scripts/portability/templates/canonical-example.md +102 -0
- package/scripts/portability/templates/canonical-format.md +218 -0
- package/scripts/portability/templates/readme-template.md +72 -0
- package/scripts/portability/test-constants.js +42 -0
- package/scripts/portability/validate-classification.js +529 -0
- package/scripts/portability/validate-exports.js +348 -0
- package/scripts/update/lib/agent-registry.js +35 -0
- package/scripts/update/lib/config-merger.js +140 -10
- package/scripts/update/lib/migration-runner.js +1 -1
- package/scripts/update/lib/refresh-installation.js +293 -8
- package/scripts/update/lib/taxonomy-merger.js +138 -0
- package/scripts/update/lib/utils.js +27 -1
- package/scripts/update/lib/validator.js +114 -4
- package/scripts/update/migrations/2.0.x-to-3.1.0.js +50 -0
- package/scripts/update/migrations/3.0.x-to-3.1.0.js +41 -0
- package/scripts/update/migrations/registry.js +14 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const yaml = require('js-yaml');
|
|
6
|
+
|
|
7
|
+
/** @typedef {import('./types/factory-types').TeamSpec} TeamSpec */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Write a team spec to a YAML file with atomic write safety.
|
|
11
|
+
* Protocol: write to .tmp → validate parse → rename to target.
|
|
12
|
+
*
|
|
13
|
+
* @param {TeamSpec} spec - The team spec object to write
|
|
14
|
+
* @param {string} targetPath - Absolute path to the output YAML file
|
|
15
|
+
* @returns {Promise<{ success: boolean, errors: string[] }>}
|
|
16
|
+
*/
|
|
17
|
+
async function writeSpec(spec, targetPath) {
|
|
18
|
+
if (!spec || typeof spec !== 'object') {
|
|
19
|
+
return { success: false, errors: ['spec must be a non-null object'] };
|
|
20
|
+
}
|
|
21
|
+
if (!targetPath || !path.isAbsolute(targetPath)) {
|
|
22
|
+
return { success: false, errors: ['targetPath must be an absolute path'] };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Serialize to YAML
|
|
26
|
+
let yamlContent;
|
|
27
|
+
try {
|
|
28
|
+
yamlContent = yaml.dump(spec, {
|
|
29
|
+
indent: 2,
|
|
30
|
+
lineWidth: 120,
|
|
31
|
+
noRefs: true,
|
|
32
|
+
sortKeys: false,
|
|
33
|
+
quotingType: '"',
|
|
34
|
+
});
|
|
35
|
+
} catch (err) {
|
|
36
|
+
return { success: false, errors: [`YAML serialization failed: ${err.message}`] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Atomic write: .tmp → validate → rename
|
|
40
|
+
const tmpPath = targetPath + '.tmp';
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
await fs.ensureDir(path.dirname(targetPath));
|
|
44
|
+
await fs.writeFile(tmpPath, yamlContent, 'utf8');
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return { success: false, errors: [`Failed to write temp file: ${err.message}`] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Validate: re-read and parse to confirm round-trip integrity
|
|
50
|
+
try {
|
|
51
|
+
const reRead = await fs.readFile(tmpPath, 'utf8');
|
|
52
|
+
const parsed = yaml.load(reRead);
|
|
53
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
54
|
+
await fs.remove(tmpPath);
|
|
55
|
+
return { success: false, errors: ['Round-trip validation failed: parsed result is empty or not an object'] };
|
|
56
|
+
}
|
|
57
|
+
// Verify key fields survived serialization
|
|
58
|
+
const checks = [
|
|
59
|
+
['team_name_kebab', parsed.team_name_kebab, spec.team_name_kebab],
|
|
60
|
+
['composition_pattern', parsed.composition_pattern, spec.composition_pattern],
|
|
61
|
+
['agents.length', (parsed.agents || []).length, (spec.agents || []).length],
|
|
62
|
+
];
|
|
63
|
+
for (const [field, actual, expected] of checks) {
|
|
64
|
+
if (actual !== expected) {
|
|
65
|
+
await fs.remove(tmpPath);
|
|
66
|
+
return { success: false, errors: [`Round-trip validation failed: ${field} mismatch ("${actual}" vs "${expected}")`] };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
await fs.remove(tmpPath).catch(() => {});
|
|
71
|
+
return { success: false, errors: [`Round-trip validation failed: ${err.message}`] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Rename .tmp → target
|
|
75
|
+
try {
|
|
76
|
+
await fs.rename(tmpPath, targetPath);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
await fs.remove(tmpPath).catch(() => {});
|
|
79
|
+
return { success: false, errors: [`Failed to rename temp file to target: ${err.message}`] };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { success: true, errors: [] };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Update specific fields in an existing spec file.
|
|
87
|
+
* Loads current spec, merges updates, writes back atomically.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} specPath - Absolute path to existing spec file
|
|
90
|
+
* @param {Object} updates - Fields to update (shallow merge at top level, deep merge for nested objects)
|
|
91
|
+
* @returns {Promise<{ success: boolean, errors: string[] }>}
|
|
92
|
+
*/
|
|
93
|
+
async function updateSpec(specPath, updates) {
|
|
94
|
+
let raw;
|
|
95
|
+
try {
|
|
96
|
+
raw = await fs.readFile(specPath, 'utf8');
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return { success: false, errors: [`Cannot read spec file: ${err.message}`] };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let current;
|
|
102
|
+
try {
|
|
103
|
+
current = yaml.load(raw);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
return { success: false, errors: [`Invalid YAML in existing spec: ${err.message}`] };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Shallow merge with deep merge for known nested objects
|
|
109
|
+
const merged = { ...current };
|
|
110
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
111
|
+
if (key === 'progress' && typeof value === 'object' && typeof merged.progress === 'object') {
|
|
112
|
+
merged.progress = { ...merged.progress, ...value };
|
|
113
|
+
} else if (key === 'integration' && typeof value === 'object' && typeof merged.integration === 'object') {
|
|
114
|
+
merged.integration = { ...merged.integration, ...value };
|
|
115
|
+
} else if (key === 'metrics' && typeof value === 'object' && typeof merged.metrics === 'object') {
|
|
116
|
+
merged.metrics = { ...merged.metrics, ...value };
|
|
117
|
+
} else {
|
|
118
|
+
merged[key] = value;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return writeSpec(merged, specPath);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = {
|
|
126
|
+
writeSpec,
|
|
127
|
+
updateSpec,
|
|
128
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSDoc type definitions for Team Factory integration wiring modules.
|
|
5
|
+
* Canonical source for all factory shapes — no runtime code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parsed team spec file shape.
|
|
10
|
+
* @typedef {Object} TeamSpec
|
|
11
|
+
* @property {string} schema_version
|
|
12
|
+
* @property {string} team_name
|
|
13
|
+
* @property {string} team_name_kebab
|
|
14
|
+
* @property {string} [description] - Optional team description for config.yaml
|
|
15
|
+
* @property {string} composition_pattern - "Sequential" or "Independent"
|
|
16
|
+
* @property {string} created - ISO date string
|
|
17
|
+
* @property {string} factory_version
|
|
18
|
+
* @property {AgentSpec[]} agents
|
|
19
|
+
* @property {ContractSpec[]} contracts
|
|
20
|
+
* @property {ContractSpec[]} feedback_contracts
|
|
21
|
+
* @property {IntegrationSpec} integration
|
|
22
|
+
* @property {Object} progress
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Agent specification from spec file.
|
|
27
|
+
* @typedef {Object} AgentSpec
|
|
28
|
+
* @property {string} id
|
|
29
|
+
* @property {string} role
|
|
30
|
+
* @property {string[]} capabilities
|
|
31
|
+
* @property {number} [pipeline_position] - Sequential only
|
|
32
|
+
* @property {string[]} overlap_acknowledgments
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Contract specification from spec file.
|
|
37
|
+
* @typedef {Object} ContractSpec
|
|
38
|
+
* @property {string} id
|
|
39
|
+
* @property {string} source_agent
|
|
40
|
+
* @property {string[]} target_agents
|
|
41
|
+
* @property {string} artifact_title
|
|
42
|
+
* @property {string} artifact_description
|
|
43
|
+
* @property {string[]} key_sections
|
|
44
|
+
* @property {string} file_name
|
|
45
|
+
* @property {string[]} input_artifacts
|
|
46
|
+
* @property {boolean} optional
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Integration decisions from spec file.
|
|
51
|
+
* @typedef {Object} IntegrationSpec
|
|
52
|
+
* @property {string} output_directory
|
|
53
|
+
* @property {string} compass_routing - "optional", "per-agent", "required", or "shared-reference"
|
|
54
|
+
* @property {string} [contract_prefix]
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Config.yaml data shape (matches Gyre/Vortex schema).
|
|
59
|
+
* @typedef {Object} ConfigData
|
|
60
|
+
* @property {string} submodule_name
|
|
61
|
+
* @property {string} description
|
|
62
|
+
* @property {string} module
|
|
63
|
+
* @property {string} output_folder
|
|
64
|
+
* @property {string[]} agents
|
|
65
|
+
* @property {string[]} workflows
|
|
66
|
+
* @property {string} version
|
|
67
|
+
* @property {string} user_name
|
|
68
|
+
* @property {string} communication_language
|
|
69
|
+
* @property {boolean} party_mode_enabled
|
|
70
|
+
* @property {string} core_module
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Module-help.csv row shape.
|
|
75
|
+
* @typedef {Object} CsvRow
|
|
76
|
+
* @property {string} module
|
|
77
|
+
* @property {string} phase
|
|
78
|
+
* @property {string} name
|
|
79
|
+
* @property {string} code
|
|
80
|
+
* @property {number} sequence
|
|
81
|
+
* @property {string} workflow_file
|
|
82
|
+
* @property {string} command
|
|
83
|
+
* @property {string} required
|
|
84
|
+
* @property {string} agent
|
|
85
|
+
* @property {string} options
|
|
86
|
+
* @property {string} description
|
|
87
|
+
* @property {string} output_location
|
|
88
|
+
* @property {string} outputs
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Activation validation result per agent.
|
|
93
|
+
* @typedef {Object} ActivationResult
|
|
94
|
+
* @property {string} agentFile
|
|
95
|
+
* @property {ActivationCheck[]} checks
|
|
96
|
+
* @property {string[]} errors
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Individual activation check.
|
|
101
|
+
* @typedef {Object} ActivationCheck
|
|
102
|
+
* @property {string} check - Description of what was checked
|
|
103
|
+
* @property {boolean} passed
|
|
104
|
+
* @property {string} [detail] - Additional info if failed
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Collision detection result.
|
|
109
|
+
* @typedef {Object} Collision
|
|
110
|
+
* @property {string} field - "submodule_name", "agent", or "workflow"
|
|
111
|
+
* @property {string} value - The colliding value
|
|
112
|
+
* @property {string} existingModule - Module that already has this value
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Creator result shape (shared by config-creator and csv-creator).
|
|
117
|
+
* @typedef {Object} CreatorResult
|
|
118
|
+
* @property {boolean} success
|
|
119
|
+
* @property {string} [filePath]
|
|
120
|
+
* @property {string[]} errors
|
|
121
|
+
* @property {number} [rowCount] - csv-creator only
|
|
122
|
+
* @property {Collision[]} [collisions] - config-creator only
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Activation validator result shape.
|
|
127
|
+
* @typedef {Object} ValidationResult
|
|
128
|
+
* @property {boolean} valid
|
|
129
|
+
* @property {ActivationResult[]} results
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Registry writer result shape (Full Write Safety Protocol).
|
|
134
|
+
* Differs from CreatorResult intentionally — writers return written[]/skipped[] per architecture rule 2.
|
|
135
|
+
* @typedef {Object} RegistryResult
|
|
136
|
+
* @property {boolean} success
|
|
137
|
+
* @property {string[]} written - Const names added to module.exports
|
|
138
|
+
* @property {string[]} skipped - Reasons for skipping (e.g., 'block already exists')
|
|
139
|
+
* @property {string[]} errors
|
|
140
|
+
* @property {boolean} rollbackApplied - True if .bak was restored after verify failure
|
|
141
|
+
* @property {boolean} [dirty] - True if dirty-tree detection found uncommitted changes
|
|
142
|
+
* @property {string} [diff] - Git diff output when dirty
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Agent entry in agent-registry.js.
|
|
147
|
+
* @typedef {Object} RegistryAgentEntry
|
|
148
|
+
* @property {string} id
|
|
149
|
+
* @property {string} name - Display name (first name or derived)
|
|
150
|
+
* @property {string} icon - Unicode emoji character
|
|
151
|
+
* @property {string} title - Role-based title
|
|
152
|
+
* @property {string} stream - Team name kebab
|
|
153
|
+
* @property {RegistryPersona} persona
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Persona sub-object within a registry agent entry.
|
|
158
|
+
* @typedef {Object} RegistryPersona
|
|
159
|
+
* @property {string} role
|
|
160
|
+
* @property {string} identity
|
|
161
|
+
* @property {string} communication_style
|
|
162
|
+
* @property {string} expertise
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* File manifest entry tracking a created or modified file.
|
|
167
|
+
* @typedef {Object} ManifestEntry
|
|
168
|
+
* @property {string} path - File path (relative to project root)
|
|
169
|
+
* @property {'created' | 'modified'} operation - Whether the file was created or modified
|
|
170
|
+
* @property {string} module - Team name kebab identifying the owning module
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* End-to-end validation result.
|
|
175
|
+
* @typedef {Object} E2EValidationResult
|
|
176
|
+
* @property {boolean} valid - True if all checks passed
|
|
177
|
+
* @property {E2ECheck[]} checks - Individual check results
|
|
178
|
+
* @property {string[]} errors - Human-readable error messages for failed checks
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Individual end-to-end validation check.
|
|
183
|
+
* Name uses {PROP}-{SEMANTIC-NAME} format per architecture (line 590).
|
|
184
|
+
* @typedef {Object} E2ECheck
|
|
185
|
+
* @property {string} name - Check ID in {PROP}-{SEMANTIC-NAME} format (e.g., CONFIG-EXISTS)
|
|
186
|
+
* @property {string} stepName - Step that produced the check (e.g., 'structural', 'regression', 'wiring')
|
|
187
|
+
* @property {boolean} passed - Whether the check passed
|
|
188
|
+
* @property {string} [expected] - Expected value (included on failure per TF-NFR11)
|
|
189
|
+
* @property {string} [actual] - Actual value found (included on failure per TF-NFR11)
|
|
190
|
+
* @property {string} [detail] - Additional context (e.g., file path)
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
module.exports = {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RFC 4180-aware CSV row parser for team factory validation.
|
|
5
|
+
* Handles quoted fields containing commas and escaped quotes ("").
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parse a single CSV row into an array of field values.
|
|
10
|
+
* Handles double-quoted fields per RFC 4180:
|
|
11
|
+
* - Fields containing commas, quotes, or newlines are enclosed in double quotes
|
|
12
|
+
* - Double quotes inside quoted fields are escaped as ""
|
|
13
|
+
*
|
|
14
|
+
* @param {string} line - A single CSV row string
|
|
15
|
+
* @returns {string[]} Array of field values
|
|
16
|
+
*/
|
|
17
|
+
function parseCsvRow(line) {
|
|
18
|
+
const fields = [];
|
|
19
|
+
let current = '';
|
|
20
|
+
let inQuotes = false;
|
|
21
|
+
let i = 0;
|
|
22
|
+
|
|
23
|
+
while (i < line.length) {
|
|
24
|
+
const ch = line[i];
|
|
25
|
+
|
|
26
|
+
if (inQuotes) {
|
|
27
|
+
if (ch === '"') {
|
|
28
|
+
// Check for escaped quote ""
|
|
29
|
+
if (i + 1 < line.length && line[i + 1] === '"') {
|
|
30
|
+
current += '"';
|
|
31
|
+
i += 2;
|
|
32
|
+
} else {
|
|
33
|
+
// End of quoted field
|
|
34
|
+
inQuotes = false;
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
current += ch;
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (ch === '"') {
|
|
43
|
+
inQuotes = true;
|
|
44
|
+
i++;
|
|
45
|
+
} else if (ch === ',') {
|
|
46
|
+
fields.push(current);
|
|
47
|
+
current = '';
|
|
48
|
+
i++;
|
|
49
|
+
} else {
|
|
50
|
+
current += ch;
|
|
51
|
+
i++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Push the last field
|
|
57
|
+
fields.push(current);
|
|
58
|
+
|
|
59
|
+
return fields;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { parseCsvRow };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared naming utilities for team factory modules.
|
|
5
|
+
* Canonical source for toKebab() and deriveWorkflowName() — no duplication.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert a string to kebab-case.
|
|
10
|
+
* @param {string} str
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
function toKebab(str) {
|
|
14
|
+
if (!str) return '';
|
|
15
|
+
return str
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
18
|
+
.replace(/^-+|-+$/g, '');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Derive a workflow name for a single agent from spec data.
|
|
23
|
+
* Uses workflow_names map if present, otherwise derives from first capability.
|
|
24
|
+
* Falls back to role > agent.id when capabilities are absent.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} agent - Agent spec object with id, role, capabilities
|
|
27
|
+
* @param {Object} [specData] - Full spec data (checked for workflow_names map)
|
|
28
|
+
* @returns {string} kebab-case workflow name
|
|
29
|
+
*/
|
|
30
|
+
function deriveWorkflowName(agent, specData) {
|
|
31
|
+
if (specData && specData.workflow_names && specData.workflow_names[agent.id]) {
|
|
32
|
+
return specData.workflow_names[agent.id];
|
|
33
|
+
}
|
|
34
|
+
if (agent.capabilities && agent.capabilities.length > 0) {
|
|
35
|
+
const cap = agent.capabilities[0];
|
|
36
|
+
const wordCount = cap.trim().split(/\s+/).length;
|
|
37
|
+
if (wordCount > 4 && agent.role) {
|
|
38
|
+
return toKebab(agent.role);
|
|
39
|
+
}
|
|
40
|
+
return toKebab(cap);
|
|
41
|
+
}
|
|
42
|
+
return toKebab(agent.role || agent.id);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { toKebab, deriveWorkflowName };
|