dot-agents 0.4.1 → 0.6.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/README.md +239 -122
- package/dist/cli/commands/channel.d.ts +19 -0
- package/dist/cli/commands/channel.d.ts.map +1 -1
- package/dist/cli/commands/channel.js +152 -13
- package/dist/cli/commands/channel.js.map +1 -1
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +61 -1
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +2 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/personas.d.ts +3 -0
- package/dist/cli/commands/personas.d.ts.map +1 -0
- package/dist/cli/commands/personas.js +402 -0
- package/dist/cli/commands/personas.js.map +1 -0
- package/dist/cli/commands/projects.d.ts +3 -0
- package/dist/cli/commands/projects.d.ts.map +1 -0
- package/dist/cli/commands/projects.js +138 -0
- package/dist/cli/commands/projects.js.map +1 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +4 -5
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/index.js +5 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lib/runner.d.ts +2 -0
- package/dist/cli/lib/runner.d.ts.map +1 -1
- package/dist/cli/lib/runner.js +102 -25
- package/dist/cli/lib/runner.js.map +1 -1
- package/dist/daemon/api/server.d.ts.map +1 -1
- package/dist/daemon/api/server.js +4 -2
- package/dist/daemon/api/server.js.map +1 -1
- package/dist/daemon/daemon.d.ts +12 -3
- package/dist/daemon/daemon.d.ts.map +1 -1
- package/dist/daemon/daemon.js +138 -35
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/lib/executor.d.ts +12 -2
- package/dist/daemon/lib/executor.d.ts.map +1 -1
- package/dist/daemon/lib/executor.js +52 -34
- package/dist/daemon/lib/executor.js.map +1 -1
- package/dist/daemon/lib/watcher.d.ts +14 -2
- package/dist/daemon/lib/watcher.d.ts.map +1 -1
- package/dist/daemon/lib/watcher.js +43 -3
- package/dist/daemon/lib/watcher.js.map +1 -1
- package/dist/lib/channel.d.ts +53 -1
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/lib/channel.js +221 -30
- package/dist/lib/channel.js.map +1 -1
- package/dist/lib/channel.test.d.ts +2 -0
- package/dist/lib/channel.test.d.ts.map +1 -0
- package/dist/lib/channel.test.js +33 -0
- package/dist/lib/channel.test.js.map +1 -0
- package/dist/lib/daemon-status.d.ts +26 -0
- package/dist/lib/daemon-status.d.ts.map +1 -0
- package/dist/lib/daemon-status.js +64 -0
- package/dist/lib/daemon-status.js.map +1 -0
- package/dist/lib/environment.d.ts +87 -0
- package/dist/lib/environment.d.ts.map +1 -0
- package/dist/lib/environment.js +224 -0
- package/dist/lib/environment.js.map +1 -0
- package/dist/lib/frontmatter.d.ts +8 -0
- package/dist/lib/frontmatter.d.ts.map +1 -1
- package/dist/lib/frontmatter.js +16 -3
- package/dist/lib/frontmatter.js.map +1 -1
- package/dist/lib/frontmatter.test.d.ts +2 -0
- package/dist/lib/frontmatter.test.d.ts.map +1 -0
- package/dist/lib/frontmatter.test.js +60 -0
- package/dist/lib/frontmatter.test.js.map +1 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/integration.test.d.ts +2 -0
- package/dist/lib/integration.test.d.ts.map +1 -0
- package/dist/lib/integration.test.js +445 -0
- package/dist/lib/integration.test.js.map +1 -0
- package/dist/lib/invoke.d.ts +23 -0
- package/dist/lib/invoke.d.ts.map +1 -0
- package/dist/lib/invoke.js +158 -0
- package/dist/lib/invoke.js.map +1 -0
- package/dist/lib/invoke.test.d.ts +2 -0
- package/dist/lib/invoke.test.d.ts.map +1 -0
- package/dist/lib/invoke.test.js +82 -0
- package/dist/lib/invoke.test.js.map +1 -0
- package/dist/lib/persona.d.ts +41 -0
- package/dist/lib/persona.d.ts.map +1 -1
- package/dist/lib/persona.js +233 -31
- package/dist/lib/persona.js.map +1 -1
- package/dist/lib/persona.test.d.ts +2 -0
- package/dist/lib/persona.test.d.ts.map +1 -0
- package/dist/lib/persona.test.js +324 -0
- package/dist/lib/persona.test.js.map +1 -0
- package/dist/lib/processor.d.ts +50 -0
- package/dist/lib/processor.d.ts.map +1 -0
- package/dist/lib/processor.js +135 -0
- package/dist/lib/processor.js.map +1 -0
- package/dist/lib/processor.test.d.ts +2 -0
- package/dist/lib/processor.test.d.ts.map +1 -0
- package/dist/lib/processor.test.js +134 -0
- package/dist/lib/processor.test.js.map +1 -0
- package/dist/lib/registry.d.ts +109 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +192 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/registry.test.d.ts +2 -0
- package/dist/lib/registry.test.d.ts.map +1 -0
- package/dist/lib/registry.test.js +236 -0
- package/dist/lib/registry.test.js.map +1 -0
- package/dist/lib/session-thread.d.ts +75 -0
- package/dist/lib/session-thread.d.ts.map +1 -0
- package/dist/lib/session-thread.js +132 -0
- package/dist/lib/session-thread.js.map +1 -0
- package/dist/lib/session-thread.test.d.ts +2 -0
- package/dist/lib/session-thread.test.d.ts.map +1 -0
- package/dist/lib/session-thread.test.js +235 -0
- package/dist/lib/session-thread.test.js.map +1 -0
- package/dist/lib/session.d.ts +150 -0
- package/dist/lib/session.d.ts.map +1 -0
- package/dist/lib/session.js +183 -0
- package/dist/lib/session.js.map +1 -0
- package/dist/lib/session.test.d.ts +2 -0
- package/dist/lib/session.test.d.ts.map +1 -0
- package/dist/lib/session.test.js +336 -0
- package/dist/lib/session.test.js.map +1 -0
- package/dist/lib/types/channel.d.ts +4 -0
- package/dist/lib/types/channel.d.ts.map +1 -1
- package/dist/lib/types/persona.d.ts +51 -0
- package/dist/lib/types/persona.d.ts.map +1 -1
- package/dist/lib/types/triggers.d.ts +11 -0
- package/dist/lib/types/triggers.d.ts.map +1 -1
- package/dist/lib/version.d.ts +26 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +61 -0
- package/dist/lib/version.js.map +1 -0
- package/internal/personas/_base/PERSONA.md +251 -0
- package/internal/skills/channels/list/SKILL.md +76 -0
- package/internal/skills/channels/publish/SKILL.md +129 -0
- package/internal/skills/channels/read/SKILL.md +124 -0
- package/internal/skills/channels/reply/SKILL.md +138 -0
- package/package.json +7 -2
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { describe, it, before, after } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { mkdir, writeFile, rm, stat } from "node:fs/promises";
|
|
6
|
+
/**
|
|
7
|
+
* Integration tests for the cross-project channel flow:
|
|
8
|
+
* channels publish @project → message lands in @root → channels process @root → invokes root persona
|
|
9
|
+
*
|
|
10
|
+
* These tests validate that the pieces connect end-to-end, catching gaps like:
|
|
11
|
+
* - Root persona not being recognized at .agents/PERSONA.md
|
|
12
|
+
* - personaExists() not finding root persona
|
|
13
|
+
* - invokePersona path resolution failures
|
|
14
|
+
*/
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
const PROJECT_ROOT = join(__dirname, "..", "..");
|
|
18
|
+
// Import pure functions for testing (inline where needed to avoid module issues)
|
|
19
|
+
const PERSONA_FILENAME = "PERSONA.md";
|
|
20
|
+
async function hasPersonaFile(dirPath) {
|
|
21
|
+
try {
|
|
22
|
+
const filePath = join(dirPath, PERSONA_FILENAME);
|
|
23
|
+
const stats = await stat(filePath);
|
|
24
|
+
return stats.isFile();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Inline persona path resolution (mirrors invoke.ts:51-53)
|
|
31
|
+
function resolvePersonaPath(personaName, agentsDir, personasDir) {
|
|
32
|
+
if (personaName === "root") {
|
|
33
|
+
return agentsDir;
|
|
34
|
+
}
|
|
35
|
+
return join(personasDir, personaName);
|
|
36
|
+
}
|
|
37
|
+
// Inline personaExists (mirrors processor.ts:93-116)
|
|
38
|
+
async function personaExists(config, channelName, listPersonasFn) {
|
|
39
|
+
const personaName = channelName.slice(1);
|
|
40
|
+
if (personaName === "root") {
|
|
41
|
+
return await hasPersonaFile(config.agentsDir);
|
|
42
|
+
}
|
|
43
|
+
const personaPaths = await listPersonasFn();
|
|
44
|
+
for (const path of personaPaths) {
|
|
45
|
+
const parts = path.split("/");
|
|
46
|
+
const name = parts[parts.length - 1];
|
|
47
|
+
if (name === personaName) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
function parseChannelAddress(address) {
|
|
54
|
+
if (!address.startsWith("#") && !address.startsWith("@")) {
|
|
55
|
+
throw new Error(`Invalid channel address: ${address}. Must start with # or @`);
|
|
56
|
+
}
|
|
57
|
+
const type = address[0];
|
|
58
|
+
const rest = address.slice(1);
|
|
59
|
+
const slashIndex = rest.indexOf("/");
|
|
60
|
+
if (slashIndex > 0) {
|
|
61
|
+
const project = rest.slice(0, slashIndex);
|
|
62
|
+
const name = rest.slice(slashIndex + 1);
|
|
63
|
+
if (!name) {
|
|
64
|
+
throw new Error(`Invalid channel address: ${address}. Missing channel/persona name after project.`);
|
|
65
|
+
}
|
|
66
|
+
return { project, type, name, original: address };
|
|
67
|
+
}
|
|
68
|
+
return { project: null, type, name: rest, original: address };
|
|
69
|
+
}
|
|
70
|
+
function resolveChannelAddress(address, localChannelsDir, projectRegistry) {
|
|
71
|
+
const parsed = parseChannelAddress(address);
|
|
72
|
+
if (parsed.project === null && parsed.type === "@") {
|
|
73
|
+
const projectPath = projectRegistry[parsed.name];
|
|
74
|
+
if (projectPath) {
|
|
75
|
+
return {
|
|
76
|
+
channelsDir: `${projectPath}/channels`,
|
|
77
|
+
localChannelName: "@root",
|
|
78
|
+
isProjectEntryPoint: true,
|
|
79
|
+
projectName: parsed.name,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (parsed.project === null) {
|
|
84
|
+
return {
|
|
85
|
+
channelsDir: localChannelsDir,
|
|
86
|
+
localChannelName: address,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const projectPath = projectRegistry[parsed.project];
|
|
90
|
+
if (!projectPath) {
|
|
91
|
+
throw new Error(`Unknown project: ${parsed.project}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
channelsDir: `${projectPath}/channels`,
|
|
95
|
+
localChannelName: `${parsed.type}${parsed.name}`,
|
|
96
|
+
projectName: parsed.project,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
describe("Integration: Cross-project channel flow", () => {
|
|
100
|
+
/**
|
|
101
|
+
* This test suite validates the complete flow:
|
|
102
|
+
* 1. @project address resolution routes to @root
|
|
103
|
+
* 2. @root channel maps to root persona
|
|
104
|
+
* 3. Root persona exists at .agents/PERSONA.md
|
|
105
|
+
* 4. Persona path resolution returns agentsDir for root
|
|
106
|
+
*
|
|
107
|
+
* This is the exact flow that was broken before the root persona fix.
|
|
108
|
+
*/
|
|
109
|
+
const projectRegistry = {
|
|
110
|
+
"dot-agents": join(PROJECT_ROOT, ".agents"),
|
|
111
|
+
"remote-project": "/path/to/remote/.agents",
|
|
112
|
+
};
|
|
113
|
+
describe("Step 1: @project routes to @root", () => {
|
|
114
|
+
it("@dot-agents routes to dot-agents project's @root channel", () => {
|
|
115
|
+
const result = resolveChannelAddress("@dot-agents", "/local/.agents/channels", projectRegistry);
|
|
116
|
+
assert.strictEqual(result.localChannelName, "@root", "@project should route to @root");
|
|
117
|
+
assert.strictEqual(result.isProjectEntryPoint, true);
|
|
118
|
+
assert.strictEqual(result.projectName, "dot-agents");
|
|
119
|
+
});
|
|
120
|
+
it("preserves @root when already specified", () => {
|
|
121
|
+
// If someone explicitly uses @project/root, it should still work
|
|
122
|
+
const result = resolveChannelAddress("@dot-agents/root", "/local/.agents/channels", projectRegistry);
|
|
123
|
+
assert.strictEqual(result.localChannelName, "@root");
|
|
124
|
+
assert.strictEqual(result.projectName, "dot-agents");
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
describe("Step 2: @root channel maps to root persona", () => {
|
|
128
|
+
it("@root extracts 'root' as persona name", () => {
|
|
129
|
+
const channel = "@root";
|
|
130
|
+
const personaName = channel.slice(1);
|
|
131
|
+
assert.strictEqual(personaName, "root");
|
|
132
|
+
});
|
|
133
|
+
it("personaExists finds root at .agents/PERSONA.md", async () => {
|
|
134
|
+
const config = {
|
|
135
|
+
agentsDir: join(PROJECT_ROOT, ".agents"),
|
|
136
|
+
personasDir: join(PROJECT_ROOT, ".agents", "personas"),
|
|
137
|
+
};
|
|
138
|
+
const exists = await personaExists(config, "@root", async () => []);
|
|
139
|
+
assert.strictEqual(exists, true, "Root persona should exist at .agents/PERSONA.md");
|
|
140
|
+
});
|
|
141
|
+
it("personaExists does NOT look in personasDir for root", async () => {
|
|
142
|
+
// This is the bug we fixed: root was looked up in personas/ directory
|
|
143
|
+
const config = {
|
|
144
|
+
agentsDir: "/nonexistent-agents", // No PERSONA.md here
|
|
145
|
+
personasDir: "/path/to/personas", // Would have root/ here
|
|
146
|
+
};
|
|
147
|
+
// Even if listPersonas would return a "root" persona, @root should check agentsDir
|
|
148
|
+
const mockListPersonas = async () => ["/path/to/personas/root"];
|
|
149
|
+
const exists = await personaExists(config, "@root", mockListPersonas);
|
|
150
|
+
assert.strictEqual(exists, false, "Should check agentsDir, not personas list");
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
describe("Step 3: Root persona path resolution", () => {
|
|
154
|
+
it("'root' persona resolves to agentsDir", () => {
|
|
155
|
+
const agentsDir = "/project/.agents";
|
|
156
|
+
const personasDir = "/project/.agents/personas";
|
|
157
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
158
|
+
assert.strictEqual(path, agentsDir, "Root should resolve to agentsDir");
|
|
159
|
+
});
|
|
160
|
+
it("'root' does NOT resolve to personasDir/root", () => {
|
|
161
|
+
const agentsDir = "/project/.agents";
|
|
162
|
+
const personasDir = "/project/.agents/personas";
|
|
163
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
164
|
+
assert.notStrictEqual(path, join(personasDir, "root"), "Root should NOT be in personas dir");
|
|
165
|
+
});
|
|
166
|
+
it("other personas still resolve to personasDir/<name>", () => {
|
|
167
|
+
const agentsDir = "/project/.agents";
|
|
168
|
+
const personasDir = "/project/.agents/personas";
|
|
169
|
+
const path = resolvePersonaPath("developer", agentsDir, personasDir);
|
|
170
|
+
assert.strictEqual(path, join(personasDir, "developer"));
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
describe("Step 4: End-to-end path validation", () => {
|
|
174
|
+
it("complete flow: @project → @root → root persona → agentsDir", () => {
|
|
175
|
+
// Simulate the complete flow
|
|
176
|
+
const localChannelsDir = "/caller/.agents/channels";
|
|
177
|
+
// Step 1: Resolve @dot-agents to @root
|
|
178
|
+
const resolved = resolveChannelAddress("@dot-agents", localChannelsDir, projectRegistry);
|
|
179
|
+
assert.strictEqual(resolved.localChannelName, "@root");
|
|
180
|
+
// Step 2: Extract persona name
|
|
181
|
+
const personaName = resolved.localChannelName.slice(1);
|
|
182
|
+
assert.strictEqual(personaName, "root");
|
|
183
|
+
// Step 3: Resolve persona path
|
|
184
|
+
const agentsDir = projectRegistry["dot-agents"];
|
|
185
|
+
const personasDir = join(agentsDir, "personas");
|
|
186
|
+
const personaPath = resolvePersonaPath(personaName, agentsDir, personasDir);
|
|
187
|
+
assert.strictEqual(personaPath, agentsDir, "Complete flow should end at agentsDir");
|
|
188
|
+
});
|
|
189
|
+
it("actual project has PERSONA.md at expected location", async () => {
|
|
190
|
+
// Verify the actual dot-agents project structure
|
|
191
|
+
const agentsDir = join(PROJECT_ROOT, ".agents");
|
|
192
|
+
const exists = await hasPersonaFile(agentsDir);
|
|
193
|
+
assert.strictEqual(exists, true, "dot-agents should have .agents/PERSONA.md");
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
describe("Integration: Cross-project delegation with isolated fixture", () => {
|
|
198
|
+
/**
|
|
199
|
+
* Test with isolated fixtures to avoid depending on actual project structure.
|
|
200
|
+
* Creates temporary project structures to validate the integration.
|
|
201
|
+
*/
|
|
202
|
+
const testRoot = join(PROJECT_ROOT, ".test-fixtures", `integration-${Date.now()}`);
|
|
203
|
+
const projectA = join(testRoot, "project-a");
|
|
204
|
+
const projectB = join(testRoot, "project-b");
|
|
205
|
+
before(async () => {
|
|
206
|
+
// Create project A with root persona
|
|
207
|
+
await mkdir(join(projectA, ".agents", "channels", "@root"), { recursive: true });
|
|
208
|
+
await writeFile(join(projectA, ".agents", "PERSONA.md"), `---
|
|
209
|
+
name: root
|
|
210
|
+
cmd: "echo"
|
|
211
|
+
---
|
|
212
|
+
I am project A's entry point.
|
|
213
|
+
`);
|
|
214
|
+
// Create project B with root persona
|
|
215
|
+
await mkdir(join(projectB, ".agents", "channels", "@root"), { recursive: true });
|
|
216
|
+
await writeFile(join(projectB, ".agents", "PERSONA.md"), `---
|
|
217
|
+
name: root
|
|
218
|
+
cmd: "echo"
|
|
219
|
+
---
|
|
220
|
+
I am project B's entry point.
|
|
221
|
+
`);
|
|
222
|
+
// Create project A with a named persona (developer)
|
|
223
|
+
await mkdir(join(projectA, ".agents", "personas", "developer"), { recursive: true });
|
|
224
|
+
await writeFile(join(projectA, ".agents", "personas", "developer", "PERSONA.md"), `---
|
|
225
|
+
name: developer
|
|
226
|
+
cmd: "echo"
|
|
227
|
+
---
|
|
228
|
+
I am project A's developer persona.
|
|
229
|
+
`);
|
|
230
|
+
});
|
|
231
|
+
after(async () => {
|
|
232
|
+
try {
|
|
233
|
+
await rm(testRoot, { recursive: true, force: true });
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// Ignore cleanup errors
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
describe("cross-project routing to entry points", () => {
|
|
240
|
+
it("@project-a routes to project A's @root", () => {
|
|
241
|
+
const registry = {
|
|
242
|
+
"project-a": join(projectA, ".agents"),
|
|
243
|
+
"project-b": join(projectB, ".agents"),
|
|
244
|
+
};
|
|
245
|
+
const result = resolveChannelAddress("@project-a", "/caller/.agents/channels", registry);
|
|
246
|
+
assert.strictEqual(result.channelsDir, join(projectA, ".agents", "channels"));
|
|
247
|
+
assert.strictEqual(result.localChannelName, "@root");
|
|
248
|
+
assert.strictEqual(result.isProjectEntryPoint, true);
|
|
249
|
+
});
|
|
250
|
+
it("@project-a/developer routes to project A's @developer", () => {
|
|
251
|
+
const registry = {
|
|
252
|
+
"project-a": join(projectA, ".agents"),
|
|
253
|
+
};
|
|
254
|
+
const result = resolveChannelAddress("@project-a/developer", "/caller/.agents/channels", registry);
|
|
255
|
+
assert.strictEqual(result.channelsDir, join(projectA, ".agents", "channels"));
|
|
256
|
+
assert.strictEqual(result.localChannelName, "@developer");
|
|
257
|
+
assert.strictEqual(result.isProjectEntryPoint, undefined);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
describe("persona existence checks with fixtures", () => {
|
|
261
|
+
it("finds root persona in project A", async () => {
|
|
262
|
+
const config = {
|
|
263
|
+
agentsDir: join(projectA, ".agents"),
|
|
264
|
+
personasDir: join(projectA, ".agents", "personas"),
|
|
265
|
+
};
|
|
266
|
+
const exists = await personaExists(config, "@root", async () => []);
|
|
267
|
+
assert.strictEqual(exists, true);
|
|
268
|
+
});
|
|
269
|
+
it("finds developer persona in project A", async () => {
|
|
270
|
+
const config = {
|
|
271
|
+
agentsDir: join(projectA, ".agents"),
|
|
272
|
+
personasDir: join(projectA, ".agents", "personas"),
|
|
273
|
+
};
|
|
274
|
+
const mockListPersonas = async () => [
|
|
275
|
+
join(projectA, ".agents", "personas", "developer"),
|
|
276
|
+
];
|
|
277
|
+
const exists = await personaExists(config, "@developer", mockListPersonas);
|
|
278
|
+
assert.strictEqual(exists, true);
|
|
279
|
+
});
|
|
280
|
+
it("does not find nonexistent persona", async () => {
|
|
281
|
+
const config = {
|
|
282
|
+
agentsDir: join(projectA, ".agents"),
|
|
283
|
+
personasDir: join(projectA, ".agents", "personas"),
|
|
284
|
+
};
|
|
285
|
+
const mockListPersonas = async () => [
|
|
286
|
+
join(projectA, ".agents", "personas", "developer"),
|
|
287
|
+
];
|
|
288
|
+
const exists = await personaExists(config, "@nonexistent", mockListPersonas);
|
|
289
|
+
assert.strictEqual(exists, false);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
describe("path resolution with fixtures", () => {
|
|
293
|
+
it("root resolves to project A agentsDir", () => {
|
|
294
|
+
const agentsDir = join(projectA, ".agents");
|
|
295
|
+
const personasDir = join(projectA, ".agents", "personas");
|
|
296
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
297
|
+
assert.strictEqual(path, agentsDir);
|
|
298
|
+
});
|
|
299
|
+
it("developer resolves to project A personasDir/developer", () => {
|
|
300
|
+
const agentsDir = join(projectA, ".agents");
|
|
301
|
+
const personasDir = join(projectA, ".agents", "personas");
|
|
302
|
+
const path = resolvePersonaPath("developer", agentsDir, personasDir);
|
|
303
|
+
assert.strictEqual(path, join(personasDir, "developer"));
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
describe("Contract: Root persona must be first-class citizen", () => {
|
|
308
|
+
/**
|
|
309
|
+
* Contract tests that explicitly document and test root persona behavior.
|
|
310
|
+
* These tests serve as the contract for how root persona should work.
|
|
311
|
+
*
|
|
312
|
+
* Any function that resolves personas MUST handle root specially:
|
|
313
|
+
* 1. personaExists(@root) checks agentsDir, not personasDir
|
|
314
|
+
* 2. resolvePersonaPath("root") returns agentsDir, not personasDir/root
|
|
315
|
+
* 3. @project routes to @root (project entry point)
|
|
316
|
+
*/
|
|
317
|
+
const agentsDir = "/project/.agents";
|
|
318
|
+
const personasDir = "/project/.agents/personas";
|
|
319
|
+
describe("personaExists contract", () => {
|
|
320
|
+
it("CONTRACT: @root checks agentsDir for PERSONA.md", async () => {
|
|
321
|
+
// This is the correct behavior
|
|
322
|
+
const config = {
|
|
323
|
+
agentsDir: join(PROJECT_ROOT, ".agents"), // Has PERSONA.md
|
|
324
|
+
personasDir: join(PROJECT_ROOT, ".agents", "personas"),
|
|
325
|
+
};
|
|
326
|
+
const exists = await personaExists(config, "@root", async () => []);
|
|
327
|
+
assert.strictEqual(exists, true, "VIOLATED: personaExists must check agentsDir for @root");
|
|
328
|
+
});
|
|
329
|
+
it("CONTRACT: @root does NOT use listPersonas", async () => {
|
|
330
|
+
// Even if there's a "root" in the personas list, @root should check agentsDir
|
|
331
|
+
const config = {
|
|
332
|
+
agentsDir: "/nonexistent",
|
|
333
|
+
personasDir: "/also-nonexistent",
|
|
334
|
+
};
|
|
335
|
+
// This mock would return true if the function wrongly used the list
|
|
336
|
+
const mockListPersonas = async () => ["/some/path/root"];
|
|
337
|
+
const exists = await personaExists(config, "@root", mockListPersonas);
|
|
338
|
+
assert.strictEqual(exists, false, "VIOLATED: @root must not use personas list");
|
|
339
|
+
});
|
|
340
|
+
it("CONTRACT: @other uses listPersonas", async () => {
|
|
341
|
+
const config = {
|
|
342
|
+
agentsDir: "/project/.agents",
|
|
343
|
+
personasDir: "/project/.agents/personas",
|
|
344
|
+
};
|
|
345
|
+
const mockListPersonas = async () => ["/project/.agents/personas/developer"];
|
|
346
|
+
const exists = await personaExists(config, "@developer", mockListPersonas);
|
|
347
|
+
assert.strictEqual(exists, true, "Named personas should use list lookup");
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
describe("resolvePersonaPath contract", () => {
|
|
351
|
+
it("CONTRACT: 'root' returns agentsDir", () => {
|
|
352
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
353
|
+
assert.strictEqual(path, agentsDir, "VIOLATED: root must resolve to agentsDir");
|
|
354
|
+
});
|
|
355
|
+
it("CONTRACT: 'root' does NOT return personasDir/root", () => {
|
|
356
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
357
|
+
assert.notStrictEqual(path, join(personasDir, "root"), "VIOLATED: root must not be in personasDir");
|
|
358
|
+
});
|
|
359
|
+
it("CONTRACT: other personas return personasDir/<name>", () => {
|
|
360
|
+
const path = resolvePersonaPath("developer", agentsDir, personasDir);
|
|
361
|
+
assert.strictEqual(path, join(personasDir, "developer"));
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
describe("channel address resolution contract", () => {
|
|
365
|
+
it("CONTRACT: @project routes to @root", () => {
|
|
366
|
+
const registry = { myproject: "/path/to/myproject/.agents" };
|
|
367
|
+
const result = resolveChannelAddress("@myproject", "/local/channels", registry);
|
|
368
|
+
assert.strictEqual(result.localChannelName, "@root", "VIOLATED: @project must route to @root");
|
|
369
|
+
assert.strictEqual(result.isProjectEntryPoint, true);
|
|
370
|
+
});
|
|
371
|
+
it("CONTRACT: @project/persona routes to @persona", () => {
|
|
372
|
+
const registry = { myproject: "/path/to/myproject/.agents" };
|
|
373
|
+
const result = resolveChannelAddress("@myproject/developer", "/local/channels", registry);
|
|
374
|
+
assert.strictEqual(result.localChannelName, "@developer");
|
|
375
|
+
assert.strictEqual(result.isProjectEntryPoint, undefined);
|
|
376
|
+
});
|
|
377
|
+
it("CONTRACT: @local-persona stays local when not a project", () => {
|
|
378
|
+
const registry = { myproject: "/path/to/myproject/.agents" };
|
|
379
|
+
const result = resolveChannelAddress("@developer", "/local/channels", registry);
|
|
380
|
+
assert.strictEqual(result.channelsDir, "/local/channels");
|
|
381
|
+
assert.strictEqual(result.localChannelName, "@developer");
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
describe("Regression: Previous root persona bugs", () => {
|
|
386
|
+
/**
|
|
387
|
+
* Regression tests for specific bugs we've encountered.
|
|
388
|
+
* Each test documents a bug and ensures it stays fixed.
|
|
389
|
+
*/
|
|
390
|
+
describe("Bug: personaExists only checked personasDir for root", () => {
|
|
391
|
+
/**
|
|
392
|
+
* Before fix: personaExists used listPersonas which only scanned personasDir.
|
|
393
|
+
* This meant @root would fail because there was no personas/root directory.
|
|
394
|
+
*
|
|
395
|
+
* After fix: personaExists checks hasPersonaFile(agentsDir) for @root.
|
|
396
|
+
*/
|
|
397
|
+
it("REGRESSION: @root works even without personas/root directory", async () => {
|
|
398
|
+
const config = {
|
|
399
|
+
agentsDir: join(PROJECT_ROOT, ".agents"),
|
|
400
|
+
personasDir: join(PROJECT_ROOT, ".agents", "personas"),
|
|
401
|
+
};
|
|
402
|
+
// The mock returns empty list (no personas/root)
|
|
403
|
+
const mockListPersonas = async () => [];
|
|
404
|
+
const exists = await personaExists(config, "@root", mockListPersonas);
|
|
405
|
+
assert.strictEqual(exists, true, "Root persona should exist via agentsDir check");
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
describe("Bug: invokePersona resolved root to personasDir/root", () => {
|
|
409
|
+
/**
|
|
410
|
+
* Before fix: invokePersona used join(personasDir, personaName) for all personas.
|
|
411
|
+
* This meant "root" resolved to .agents/personas/root instead of .agents.
|
|
412
|
+
*
|
|
413
|
+
* After fix: invokePersona checks personaName === "root" and uses agentsDir.
|
|
414
|
+
*/
|
|
415
|
+
it("REGRESSION: 'root' resolves to agentsDir, not personasDir/root", () => {
|
|
416
|
+
const agentsDir = "/project/.agents";
|
|
417
|
+
const personasDir = "/project/.agents/personas";
|
|
418
|
+
const path = resolvePersonaPath("root", agentsDir, personasDir);
|
|
419
|
+
// The bug would have produced this wrong path
|
|
420
|
+
const wrongPath = join(personasDir, "root");
|
|
421
|
+
assert.notStrictEqual(path, wrongPath, "Must not resolve to personasDir/root");
|
|
422
|
+
// Correct path
|
|
423
|
+
assert.strictEqual(path, agentsDir, "Must resolve to agentsDir");
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
describe("Bug: `personas run root` failed", () => {
|
|
427
|
+
/**
|
|
428
|
+
* Before fix: CLI command "personas run root" used the same broken path resolution.
|
|
429
|
+
*
|
|
430
|
+
* After fix: All code paths use the same pattern: root → agentsDir.
|
|
431
|
+
*/
|
|
432
|
+
it("REGRESSION: CLI path resolution follows same pattern", () => {
|
|
433
|
+
// The CLI uses the same resolvePersonaPath logic
|
|
434
|
+
// This test ensures consistency across all entry points
|
|
435
|
+
const agentsDir = "/project/.agents";
|
|
436
|
+
const personasDir = "/project/.agents/personas";
|
|
437
|
+
// Both invokePersona and CLI should resolve identically
|
|
438
|
+
const invokePath = resolvePersonaPath("root", agentsDir, personasDir);
|
|
439
|
+
const cliPath = resolvePersonaPath("root", agentsDir, personasDir);
|
|
440
|
+
assert.strictEqual(invokePath, cliPath);
|
|
441
|
+
assert.strictEqual(invokePath, agentsDir);
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
//# sourceMappingURL=integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.test.js","sourceRoot":"","sources":["../../src/lib/integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;;;;GAQG;AAEH,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;A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C;YACrC,MAAM,WAAW,GAAG,2BAA2B,CAAC;YAEhD,wDAAwD;YACxD,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YACtE,MAAM,OAAO,GAAG,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YAEnE,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DotAgentsConfig, type ExecutionResult } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for invoking a persona directly
|
|
4
|
+
*/
|
|
5
|
+
export interface InvokePersonaOptions {
|
|
6
|
+
/** Extra context variables to include */
|
|
7
|
+
context?: Record<string, string>;
|
|
8
|
+
/** Source of the invocation (e.g., DM channel name) */
|
|
9
|
+
source?: string;
|
|
10
|
+
/** Goal description for the session */
|
|
11
|
+
goal?: string;
|
|
12
|
+
/** Timeout in milliseconds (default: 10 minutes) */
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Invoke a persona directly with a message (no workflow required)
|
|
17
|
+
*
|
|
18
|
+
* This is the shared implementation used by:
|
|
19
|
+
* - daemon/lib/executor.ts for DM-triggered invocations
|
|
20
|
+
* - lib/processor.ts for one-shot channel processing
|
|
21
|
+
*/
|
|
22
|
+
export declare function invokePersona(config: DotAgentsConfig, personaName: string, message: string, options?: InvokePersonaOptions): Promise<ExecutionResult>;
|
|
23
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/lib/invoke.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EAOrB,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,eAAe,CAAC,CAkL1B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { hostname } from "node:os";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { resolvePersona, createExecutionContext, processTemplate, expandVariables, createSession, finalizeSession, } from "./index.js";
|
|
5
|
+
import { getEnvironmentContextMarkdown } from "./environment.js";
|
|
6
|
+
/**
|
|
7
|
+
* Invoke a persona directly with a message (no workflow required)
|
|
8
|
+
*
|
|
9
|
+
* This is the shared implementation used by:
|
|
10
|
+
* - daemon/lib/executor.ts for DM-triggered invocations
|
|
11
|
+
* - lib/processor.ts for one-shot channel processing
|
|
12
|
+
*/
|
|
13
|
+
export async function invokePersona(config, personaName, message, options = {}) {
|
|
14
|
+
const startedAt = new Date();
|
|
15
|
+
const { context: extraContext = {}, source = "dm", goal = `DM invocation: ${personaName}`, timeoutMs = 10 * 60 * 1000, } = options;
|
|
16
|
+
// Resolve persona path - handle root persona specially
|
|
17
|
+
const personaPath = personaName === "root"
|
|
18
|
+
? config.agentsDir
|
|
19
|
+
: join(config.personasDir, personaName);
|
|
20
|
+
const persona = await resolvePersona(personaPath, config.personasDir);
|
|
21
|
+
// Create session for DM invocation
|
|
22
|
+
const session = await createSession({
|
|
23
|
+
sessionsDir: config.sessionsDir,
|
|
24
|
+
runtime: {
|
|
25
|
+
hostname: hostname(),
|
|
26
|
+
executionMode: "headless",
|
|
27
|
+
triggerType: "dm",
|
|
28
|
+
workingDir: config.agentsDir,
|
|
29
|
+
},
|
|
30
|
+
goal,
|
|
31
|
+
persona: {
|
|
32
|
+
name: persona.name,
|
|
33
|
+
inheritanceChain: persona.inheritanceChain,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const context = createExecutionContext({
|
|
37
|
+
PERSONA_NAME: persona.name,
|
|
38
|
+
PERSONA_DIR: persona.path,
|
|
39
|
+
AGENTS_DIR: config.agentsDir,
|
|
40
|
+
SESSION_DIR: session.path,
|
|
41
|
+
INVOCATION_SOURCE: source,
|
|
42
|
+
...extraContext,
|
|
43
|
+
});
|
|
44
|
+
// Merge environment
|
|
45
|
+
// Include FROM_ADDRESS, FROM_CHANNEL, FROM_THREAD from context if provided
|
|
46
|
+
const env = {
|
|
47
|
+
...process.env,
|
|
48
|
+
...persona.env,
|
|
49
|
+
DOT_AGENTS_PERSONA: persona.name,
|
|
50
|
+
DOT_AGENTS_INVOCATION: "dm",
|
|
51
|
+
// Pass session env vars from legacy session
|
|
52
|
+
SESSION_DIR: session.path,
|
|
53
|
+
// Pass callback routing from context (for cross-project delegation)
|
|
54
|
+
...(extraContext.FROM_ADDRESS && { FROM_ADDRESS: extraContext.FROM_ADDRESS }),
|
|
55
|
+
...(extraContext.FROM_CHANNEL && { FROM_CHANNEL: extraContext.FROM_CHANNEL }),
|
|
56
|
+
...(extraContext.FROM_THREAD && { FROM_THREAD: extraContext.FROM_THREAD }),
|
|
57
|
+
};
|
|
58
|
+
for (const [key, value] of Object.entries(env)) {
|
|
59
|
+
if (value) {
|
|
60
|
+
env[key] = expandVariables(value, context, env);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Build prompt: persona prompt + environment context + message
|
|
64
|
+
const parts = [];
|
|
65
|
+
if (persona.prompt) {
|
|
66
|
+
const expandedPrompt = processTemplate(persona.prompt, context, persona.env);
|
|
67
|
+
parts.push(expandedPrompt);
|
|
68
|
+
parts.push("\n---\n");
|
|
69
|
+
}
|
|
70
|
+
// Inject environment discovery context
|
|
71
|
+
const environmentContext = await getEnvironmentContextMarkdown(config);
|
|
72
|
+
parts.push(environmentContext);
|
|
73
|
+
parts.push("\n---\n");
|
|
74
|
+
parts.push(`You received a direct message:\n\n${message}`);
|
|
75
|
+
const prompt = parts.join("\n");
|
|
76
|
+
// Use headless commands for DM-triggered invocations
|
|
77
|
+
const cmds = persona.commands.headless;
|
|
78
|
+
if (!cmds) {
|
|
79
|
+
const endedAt = new Date();
|
|
80
|
+
const result = {
|
|
81
|
+
success: false,
|
|
82
|
+
exitCode: 1,
|
|
83
|
+
stdout: "",
|
|
84
|
+
stderr: `Persona '${persona.name}' does not support headless mode`,
|
|
85
|
+
duration: endedAt.getTime() - startedAt.getTime(),
|
|
86
|
+
runId: context.RUN_ID,
|
|
87
|
+
startedAt,
|
|
88
|
+
endedAt,
|
|
89
|
+
error: "Persona does not support headless mode",
|
|
90
|
+
};
|
|
91
|
+
await finalizeSession(session, {
|
|
92
|
+
success: result.success,
|
|
93
|
+
exitCode: result.exitCode,
|
|
94
|
+
duration: result.duration,
|
|
95
|
+
error: result.error,
|
|
96
|
+
stderr: result.stderr,
|
|
97
|
+
});
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
// Try each command
|
|
101
|
+
let lastError = null;
|
|
102
|
+
let result = null;
|
|
103
|
+
for (const cmd of cmds) {
|
|
104
|
+
try {
|
|
105
|
+
const expandedCmd = expandVariables(cmd, context, env);
|
|
106
|
+
const [command, ...args] = expandedCmd.split(/\s+/);
|
|
107
|
+
const execResult = await execa(command, args, {
|
|
108
|
+
input: prompt,
|
|
109
|
+
cwd: config.agentsDir,
|
|
110
|
+
env,
|
|
111
|
+
timeout: timeoutMs,
|
|
112
|
+
reject: false,
|
|
113
|
+
});
|
|
114
|
+
const endedAt = new Date();
|
|
115
|
+
result = {
|
|
116
|
+
success: execResult.exitCode === 0,
|
|
117
|
+
exitCode: execResult.exitCode ?? 1,
|
|
118
|
+
stdout: execResult.stdout,
|
|
119
|
+
stderr: execResult.stderr,
|
|
120
|
+
duration: endedAt.getTime() - startedAt.getTime(),
|
|
121
|
+
runId: context.RUN_ID,
|
|
122
|
+
startedAt,
|
|
123
|
+
endedAt,
|
|
124
|
+
};
|
|
125
|
+
if (result.success)
|
|
126
|
+
break;
|
|
127
|
+
lastError = new Error(`Command failed with exit code ${result.exitCode}: ${execResult.stderr}`);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
lastError = error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!result) {
|
|
134
|
+
const endedAt = new Date();
|
|
135
|
+
result = {
|
|
136
|
+
success: false,
|
|
137
|
+
exitCode: 1,
|
|
138
|
+
stdout: "",
|
|
139
|
+
stderr: lastError?.message ?? "All commands failed",
|
|
140
|
+
duration: endedAt.getTime() - startedAt.getTime(),
|
|
141
|
+
runId: context.RUN_ID,
|
|
142
|
+
startedAt,
|
|
143
|
+
endedAt,
|
|
144
|
+
error: lastError?.message,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Finalize session
|
|
148
|
+
await finalizeSession(session, {
|
|
149
|
+
success: result.success,
|
|
150
|
+
exitCode: result.exitCode,
|
|
151
|
+
duration: result.duration,
|
|
152
|
+
error: result.error,
|
|
153
|
+
stdout: result.stdout,
|
|
154
|
+
stderr: result.stderr,
|
|
155
|
+
});
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=invoke.js.map
|