oneie 1.2.1 → 1.2.3
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/bin/agent-integration.js +499 -0
- package/bin/cli-animations.js +420 -0
- package/bin/mission-system.js +612 -0
- package/bin/one-installer.js +776 -0
- package/bin/story-system.js +478 -0
- package/bin/task-system.js +717 -0
- package/bin/template-generator.js +661 -0
- package/one/tools/agent-installer.js +575 -0
- package/one/tools/lib/dependency-resolver.js +179 -0
- package/one/tools/lib/template-processor.js +748 -0
- package/one/tools/lib/yaml-utils.js +29 -0
- package/package.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import yaml from 'js-yaml';
|
|
4
|
+
import { extractYamlFromAgent } from './yaml-utils.js';
|
|
5
|
+
|
|
6
|
+
class DependencyResolver {
|
|
7
|
+
constructor(rootDir) {
|
|
8
|
+
this.rootDir = rootDir;
|
|
9
|
+
this.oneCore = path.join(rootDir, 'one'); // Changed from '.one' to 'one' for working directory
|
|
10
|
+
this.common = path.join(rootDir, 'common');
|
|
11
|
+
this.cache = new Map();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async resolveAgentDependencies(agentId) {
|
|
15
|
+
const agentPath = path.join(this.oneCore, 'agents', `${agentId}.md`);
|
|
16
|
+
const agentContent = await fs.readFile(agentPath, 'utf8');
|
|
17
|
+
|
|
18
|
+
// Extract YAML from markdown content with command cleaning
|
|
19
|
+
const yamlContent = extractYamlFromAgent(agentContent, true);
|
|
20
|
+
if (!yamlContent) {
|
|
21
|
+
throw new Error(`No YAML configuration found in agent ${agentId}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const agentConfig = yaml.load(yamlContent);
|
|
25
|
+
|
|
26
|
+
const dependencies = {
|
|
27
|
+
agent: {
|
|
28
|
+
id: agentId,
|
|
29
|
+
path: agentPath,
|
|
30
|
+
content: agentContent,
|
|
31
|
+
config: agentConfig
|
|
32
|
+
},
|
|
33
|
+
resources: []
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Personas are now embedded in agent configs, no need to resolve separately
|
|
37
|
+
|
|
38
|
+
// Resolve other dependencies
|
|
39
|
+
const depTypes = ['tasks', 'templates', 'checklists', 'data', 'utils'];
|
|
40
|
+
for (const depType of depTypes) {
|
|
41
|
+
const deps = agentConfig.dependencies?.[depType] || [];
|
|
42
|
+
for (const depId of deps) {
|
|
43
|
+
const resource = await this.loadResource(depType, depId);
|
|
44
|
+
if (resource) dependencies.resources.push(resource);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return dependencies;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async resolveTeamDependencies(teamId) {
|
|
52
|
+
const teamPath = path.join(this.oneCore, 'agent-teams', `${teamId}.yaml`);
|
|
53
|
+
const teamContent = await fs.readFile(teamPath, 'utf8');
|
|
54
|
+
const teamConfig = yaml.load(teamContent);
|
|
55
|
+
|
|
56
|
+
const dependencies = {
|
|
57
|
+
team: {
|
|
58
|
+
id: teamId,
|
|
59
|
+
path: teamPath,
|
|
60
|
+
content: teamContent,
|
|
61
|
+
config: teamConfig
|
|
62
|
+
},
|
|
63
|
+
agents: [],
|
|
64
|
+
resources: new Map() // Use Map to deduplicate resources
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Always add one-orchestrator agent first if it's a team
|
|
68
|
+
const oneAgent = await this.resolveAgentDependencies('one-orchestrator');
|
|
69
|
+
dependencies.agents.push(oneAgent.agent);
|
|
70
|
+
oneAgent.resources.forEach(res => {
|
|
71
|
+
dependencies.resources.set(res.path, res);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Resolve all agents in the team
|
|
75
|
+
let agentsToResolve = teamConfig.agents || [];
|
|
76
|
+
|
|
77
|
+
// Handle wildcard "*" - include all agents except one-master
|
|
78
|
+
if (agentsToResolve.includes('*')) {
|
|
79
|
+
const allAgents = await this.listAgents();
|
|
80
|
+
// Remove wildcard and add all agents except those already in the list and one-master
|
|
81
|
+
agentsToResolve = agentsToResolve.filter(a => a !== '*');
|
|
82
|
+
for (const agent of allAgents) {
|
|
83
|
+
if (!agentsToResolve.includes(agent) && agent !== 'one-master') {
|
|
84
|
+
agentsToResolve.push(agent);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (const agentId of agentsToResolve) {
|
|
90
|
+
if (agentId === 'one-orchestrator' || agentId === 'one-master') continue; // Already added or excluded
|
|
91
|
+
const agentDeps = await this.resolveAgentDependencies(agentId);
|
|
92
|
+
dependencies.agents.push(agentDeps.agent);
|
|
93
|
+
|
|
94
|
+
// Add resources with deduplication
|
|
95
|
+
agentDeps.resources.forEach(res => {
|
|
96
|
+
dependencies.resources.set(res.path, res);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Resolve workflows
|
|
101
|
+
for (const workflowId of teamConfig.workflows || []) {
|
|
102
|
+
const resource = await this.loadResource('workflows', workflowId);
|
|
103
|
+
if (resource) dependencies.resources.set(resource.path, resource);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Convert Map back to array
|
|
107
|
+
dependencies.resources = Array.from(dependencies.resources.values());
|
|
108
|
+
|
|
109
|
+
return dependencies;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async loadResource(type, id) {
|
|
113
|
+
const cacheKey = `${type}#${id}`;
|
|
114
|
+
if (this.cache.has(cacheKey)) {
|
|
115
|
+
return this.cache.get(cacheKey);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
let content = null;
|
|
120
|
+
let filePath = null;
|
|
121
|
+
|
|
122
|
+
// First try one
|
|
123
|
+
try {
|
|
124
|
+
filePath = path.join(this.oneCore, type, id);
|
|
125
|
+
content = await fs.readFile(filePath, 'utf8');
|
|
126
|
+
} catch (e) {
|
|
127
|
+
// If not found in one, try common folder
|
|
128
|
+
try {
|
|
129
|
+
filePath = path.join(this.common, type, id);
|
|
130
|
+
content = await fs.readFile(filePath, 'utf8');
|
|
131
|
+
} catch (e2) {
|
|
132
|
+
// File not found in either location
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!content) {
|
|
137
|
+
console.warn(`Resource not found: ${type}/${id}`);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const resource = {
|
|
142
|
+
type,
|
|
143
|
+
id,
|
|
144
|
+
path: filePath,
|
|
145
|
+
content
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
this.cache.set(cacheKey, resource);
|
|
149
|
+
return resource;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error(`Error loading resource ${type}/${id}:`, error.message);
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async listAgents() {
|
|
157
|
+
try {
|
|
158
|
+
const files = await fs.readdir(path.join(this.oneCore, 'agents'));
|
|
159
|
+
return files
|
|
160
|
+
.filter(f => f.endsWith('.md'))
|
|
161
|
+
.map(f => f.replace('.md', ''));
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async listTeams() {
|
|
168
|
+
try {
|
|
169
|
+
const files = await fs.readdir(path.join(this.oneCore, 'agent-teams'));
|
|
170
|
+
return files
|
|
171
|
+
.filter(f => f.endsWith('.yaml'))
|
|
172
|
+
.map(f => f.replace('.yaml', ''));
|
|
173
|
+
} catch (error) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default DependencyResolver;
|