Skip to content

Commit bccddf6

Browse files
committed
feat: update agent identifier
1 parent 25b205f commit bccddf6

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

packages/agent-manager/src/__tests__/AgentManager.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function createMockAgent(overrides: Partial<AgentInfo> = {}): AgentInfo {
4949
pid: 12345,
5050
projectPath: '/test/path',
5151
sessionId: 'test-session-id',
52-
slug: 'test-slug',
5352
lastActive: new Date(),
5453
...overrides,
5554
};

packages/agent-manager/src/__tests__/adapters/ClaudeCodeAdapter.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('ClaudeCodeAdapter', () => {
168168
// Create session file
169169
const sessionFile = path.join(projDir, 'session-1.jsonl');
170170
fs.writeFileSync(sessionFile, [
171-
JSON.stringify({ type: 'user', timestamp: '2026-03-18T23:18:44Z', cwd: '/Users/test/my-project', slug: 'merry-dog', message: { content: 'Investigate failing tests' } }),
171+
JSON.stringify({ type: 'user', timestamp: '2026-03-18T23:18:44Z', cwd: '/Users/test/my-project', message: { content: 'Investigate failing tests' } }),
172172
JSON.stringify({ type: 'assistant', timestamp: '2026-03-18T23:19:00Z' }),
173173
].join('\n'));
174174

@@ -203,7 +203,6 @@ describe('ClaudeCodeAdapter', () => {
203203
pid: 12345,
204204
projectPath: '/Users/test/my-project',
205205
sessionId: 'session-1',
206-
slug: 'merry-dog',
207206
});
208207
expect(agents[0].summary).toContain('Investigate failing tests');
209208

@@ -977,12 +976,12 @@ describe('ClaudeCodeAdapter', () => {
977976
});
978977

979978
describe('readSession', () => {
980-
it('should parse session file with timestamps, slug, cwd, and entry type', () => {
979+
it('should parse session file with timestamps, cwd, and entry type', () => {
981980
const readSession = (adapter as any).readSession.bind(adapter);
982981

983982
const filePath = path.join(tmpDir, 'test-session.jsonl');
984983
const lines = [
985-
JSON.stringify({ type: 'user', timestamp: '2026-03-10T10:00:00Z', cwd: '/my/project', slug: 'happy-dog' }),
984+
JSON.stringify({ type: 'user', timestamp: '2026-03-10T10:00:00Z', cwd: '/my/project' }),
986985
JSON.stringify({ type: 'assistant', timestamp: '2026-03-10T10:01:00Z' }),
987986
];
988987
fs.writeFileSync(filePath, lines.join('\n'));
@@ -991,7 +990,6 @@ describe('ClaudeCodeAdapter', () => {
991990
expect(session).toMatchObject({
992991
sessionId: 'test-session',
993992
projectPath: '/my/project',
994-
slug: 'happy-dog',
995993
lastCwd: '/my/project',
996994
lastEntryType: 'assistant',
997995
isInterrupted: false,
@@ -1029,7 +1027,6 @@ describe('ClaudeCodeAdapter', () => {
10291027
const session = readSession(filePath, '/test');
10301028
expect(session).not.toBeNull();
10311029
expect(session.lastEntryType).toBeUndefined();
1032-
expect(session.slug).toBeUndefined();
10331030
});
10341031

10351032
it('should return null for non-existent file', () => {

packages/agent-manager/src/__tests__/utils/matching.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,27 @@ describe('matchProcessesToSessions', () => {
173173
});
174174

175175
describe('generateAgentName', () => {
176-
it('should return folderName (pid)', () => {
177-
expect(generateAgentName('/projects/my-app', 12345)).toBe('my-app (12345)');
176+
it('should return lowercase kebab-case name with pid', () => {
177+
expect(generateAgentName('/projects/my-app', 12345)).toBe('my-app-12345');
178178
});
179179

180180
it('should handle root path', () => {
181-
expect(generateAgentName('/', 100)).toBe('unknown (100)');
181+
expect(generateAgentName('/', 100)).toBe('unknown-100');
182182
});
183183

184184
it('should handle empty cwd', () => {
185-
expect(generateAgentName('', 100)).toBe('unknown (100)');
185+
expect(generateAgentName('', 100)).toBe('unknown-100');
186186
});
187187

188188
it('should handle nested paths', () => {
189-
expect(generateAgentName('/home/user/projects/ai-devkit', 78070)).toBe('ai-devkit (78070)');
189+
expect(generateAgentName('/home/user/projects/ai-devkit', 78070)).toBe('ai-devkit-78070');
190+
});
191+
192+
it('should convert spaces and special chars to kebab-case', () => {
193+
expect(generateAgentName('/projects/AI DevKit', 123)).toBe('ai-devkit-123');
194+
});
195+
196+
it('should convert uppercase to lowercase', () => {
197+
expect(generateAgentName('/projects/MyProject', 456)).toBe('myproject-456');
190198
});
191199
});

packages/agent-manager/src/adapters/AgentAdapter.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export interface AgentInfo {
4545
/** Session UUID */
4646
sessionId: string;
4747

48-
/** Human-readable session name (e.g., "merry-wobbling-starlight"), may be undefined for new sessions */
49-
slug?: string;
50-
5148
/** Timestamp of last activity */
5249
lastActive: Date;
5350

packages/agent-manager/src/adapters/ClaudeCodeAdapter.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ interface ContentBlock {
2222
interface SessionEntry {
2323
type?: string;
2424
timestamp?: string;
25-
slug?: string;
2625
cwd?: string;
2726
message?: {
2827
content?: string | ContentBlock[];
@@ -56,7 +55,6 @@ interface ClaudeSession {
5655
sessionId: string;
5756
projectPath: string;
5857
lastCwd?: string;
59-
slug?: string;
6058
sessionStart: Date;
6159
lastActive: Date;
6260
lastEntryType?: string;
@@ -281,7 +279,6 @@ export class ClaudeCodeAdapter implements AgentAdapter {
281279
pid: processInfo.pid,
282280
projectPath: sessionFile.resolvedCwd || processInfo.cwd || '',
283281
sessionId: sessionFile.sessionId,
284-
slug: session.slug,
285282
lastActive: session.lastActive,
286283
sessionFilePath: sessionFile.filePath,
287284
};
@@ -340,7 +337,6 @@ export class ClaudeCodeAdapter implements AgentAdapter {
340337
}
341338

342339
// Parse all lines for session state (file already in memory)
343-
let slug: string | undefined;
344340
let lastEntryType: string | undefined;
345341
let lastActive: Date | undefined;
346342
let lastCwd: string | undefined;
@@ -358,10 +354,6 @@ export class ClaudeCodeAdapter implements AgentAdapter {
358354
}
359355
}
360356

361-
if (entry.slug && !slug) {
362-
slug = entry.slug;
363-
}
364-
365357
if (typeof entry.cwd === 'string' && entry.cwd.trim().length > 0) {
366358
lastCwd = entry.cwd;
367359
}
@@ -399,7 +391,6 @@ export class ClaudeCodeAdapter implements AgentAdapter {
399391
sessionId,
400392
projectPath: projectPath || lastCwd || '',
401393
lastCwd,
402-
slug,
403394
sessionStart: sessionStart || lastActive || new Date(),
404395
lastActive: lastActive || new Date(),
405396
lastEntryType,

packages/agent-manager/src/utils/matching.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,13 @@ export function matchProcessesToSessions(
8484
/**
8585
* Generate a deterministic agent name from CWD and PID.
8686
*
87-
* Format: "folderName (pid)"
87+
* Format: "folder-name-pid" (lowercase kebab-case)
8888
*/
8989
export function generateAgentName(cwd: string, pid: number): string {
9090
const folderName = path.basename(cwd) || 'unknown';
91-
return `${folderName} (${pid})`;
91+
const kebab = folderName
92+
.toLowerCase()
93+
.replace(/[^a-z0-9]+/g, '-')
94+
.replace(/^-+|-+$/g, '');
95+
return `${kebab || 'unknown'}-${pid}`;
9296
}

packages/cli/src/commands/agent.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function registerAgentCommand(program: Command): void {
216216
agentCommand
217217
.command('send <message>')
218218
.description('Send a message to a running agent')
219-
.requiredOption('--id <identifier>', 'Agent name, slug, or partial match')
219+
.requiredOption('--id <identifier>', 'Agent name or partial match')
220220
.action(async (message, options) => {
221221
try {
222222
const manager = new AgentManager();
@@ -346,7 +346,6 @@ export function registerAgentCommand(program: Command): void {
346346
status: agent.status,
347347
type: agent.type,
348348
name: agent.name,
349-
slug: agent.slug,
350349
lastActive: agent.lastActive,
351350
conversation: displayMessages,
352351
};
@@ -363,10 +362,6 @@ export function registerAgentCommand(program: Command): void {
363362
console.log(` ${chalk.bold('Last Active:')} ${formatRelativeTime(agent.lastActive)}`);
364363
console.log(` ${chalk.bold('Status:')} ${formatStatus(agent.status)}`);
365364
console.log(` ${chalk.bold('Type:')} ${formatType(agent.type)}`);
366-
if (agent.slug) {
367-
console.log(` ${chalk.bold('Slug:')} ${agent.slug}`);
368-
}
369-
370365
ui.breakline();
371366
const label = isTruncated
372367
? `Conversation (last ${displayMessages.length} of ${conversation.length} messages)`

0 commit comments

Comments
 (0)