baton-issue-tracker 1.10.0 → 1.11.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/package.json +1 -1
- package/source/cli.js +5 -0
- package/source/commands/agents.js +78 -0
- package/source/services/agentsService.js +10 -0
package/package.json
CHANGED
package/source/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ import { run as runDelete } from './commands/delete.js';
|
|
|
29
29
|
import { run as runPriority } from './commands/priority.js';
|
|
30
30
|
import { run as runLog } from './commands/log.js';
|
|
31
31
|
import { run as runRegister } from './commands/register.js';
|
|
32
|
+
import { run as runAgents } from './commands/agents.js';
|
|
32
33
|
import { run as runSubmit } from './commands/submit.js';
|
|
33
34
|
|
|
34
35
|
import { authenticateContext } from './services/authService.js';
|
|
@@ -41,6 +42,7 @@ Usage:
|
|
|
41
42
|
Commands:
|
|
42
43
|
init Initialize storage and seed issues from product specs
|
|
43
44
|
register Register a new AI agent or human user
|
|
45
|
+
agents List all registered agents and humans
|
|
44
46
|
next Work on the highest-priority open issue
|
|
45
47
|
loop Run the agent autonomously for multiple steps
|
|
46
48
|
status Show issue counts and overall progress
|
|
@@ -63,6 +65,7 @@ Options:
|
|
|
63
65
|
Default specs: docs/specs/project-requirements.md
|
|
64
66
|
register --name <name> Name of the agent or user
|
|
65
67
|
register --type <type> agent | human (default: agent)
|
|
68
|
+
agents [--json]
|
|
66
69
|
loop --steps <n> Number of autonomous steps (alias: -n)
|
|
67
70
|
loop -n <n>
|
|
68
71
|
loop --json Output as JSON (for AI agents)
|
|
@@ -99,6 +102,7 @@ Examples:
|
|
|
99
102
|
baton init ./my-specs.md
|
|
100
103
|
baton init --force
|
|
101
104
|
baton register --name claude-dev --type agent
|
|
105
|
+
baton agents
|
|
102
106
|
baton next
|
|
103
107
|
baton loop --steps 5
|
|
104
108
|
baton status
|
|
@@ -137,6 +141,7 @@ async function main() {
|
|
|
137
141
|
const handlers = {
|
|
138
142
|
init: () => runInit(args),
|
|
139
143
|
register: () => runRegister(args),
|
|
144
|
+
agents: () => runAgents(args),
|
|
140
145
|
next: () => runNext(args),
|
|
141
146
|
loop: () => runLoop(args),
|
|
142
147
|
status: () => runStatus(args),
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// agents.js
|
|
2
|
+
// Lists all registered agents and humans in the tracker.
|
|
3
|
+
// Usage: baton agents [--json]
|
|
4
|
+
//
|
|
5
|
+
// Options:
|
|
6
|
+
// --json Output as JSON (for AI agents)
|
|
7
|
+
// -h, --help Show this help
|
|
8
|
+
//
|
|
9
|
+
// Examples:
|
|
10
|
+
// baton agents
|
|
11
|
+
|
|
12
|
+
import { listAgents } from '../services/agentsService.js';
|
|
13
|
+
import { hasFlag, renderOutput } from '../util.js';
|
|
14
|
+
|
|
15
|
+
const VALID_FLAGS = ['--json'];
|
|
16
|
+
|
|
17
|
+
const COL = { id: 4, name: 14, type: 5 };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Agent} agent
|
|
21
|
+
* @returns {{ id: number, name: string, type: string }}
|
|
22
|
+
*/
|
|
23
|
+
function serializeAgent(agent) {
|
|
24
|
+
return {
|
|
25
|
+
id: agent.id,
|
|
26
|
+
name: agent.name,
|
|
27
|
+
type: agent.type,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {Agent[]} agents
|
|
33
|
+
*/
|
|
34
|
+
function printAgentsTable(agents) {
|
|
35
|
+
console.log(
|
|
36
|
+
`${'ID'.padEnd(COL.id)} | ${'Name'.padEnd(COL.name)} | Type`,
|
|
37
|
+
);
|
|
38
|
+
for (const agent of agents) {
|
|
39
|
+
console.log(
|
|
40
|
+
`${String(agent.id).padEnd(COL.id)} | ${agent.name.padEnd(COL.name)} | ${agent.type}`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Lists all registered agents and humans.
|
|
47
|
+
* @param {string[]} args - The command line arguments
|
|
48
|
+
* @returns {Promise<number>} The exit code: 0 is success, 1 is error
|
|
49
|
+
*/
|
|
50
|
+
export async function run(args = []) {
|
|
51
|
+
const isJson = hasFlag(args, '--json');
|
|
52
|
+
|
|
53
|
+
for (const arg of args) {
|
|
54
|
+
if (arg.startsWith('--') && !VALID_FLAGS.includes(arg)) {
|
|
55
|
+
throw new Error(`Unknown flag provided: ${arg}.\nFlags: --json`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const agents = listAgents();
|
|
61
|
+
const records = agents.map(serializeAgent);
|
|
62
|
+
const envelope = { status: 'success', count: records.length, agents: records };
|
|
63
|
+
|
|
64
|
+
renderOutput(isJson, envelope, (data) => {
|
|
65
|
+
if (data.count === 0) {
|
|
66
|
+
console.log('No registered agents or humans found.');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
printAgentsTable(agents);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return 0;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error: Failed to list agents.');
|
|
75
|
+
console.error(error.message);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -39,4 +39,14 @@ export function getAgentByName(name) {
|
|
|
39
39
|
} else {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Lists all registered agents and humans, ordered by id.
|
|
46
|
+
* @returns {Agent[]}
|
|
47
|
+
*/
|
|
48
|
+
export function listAgents() {
|
|
49
|
+
const db = getDB();
|
|
50
|
+
const rows = db.select().from(agentsTable).orderBy(agentsTable.id).all();
|
|
51
|
+
return rows.map((row) => new Agent(row));
|
|
42
52
|
}
|