@proletariat/cli 0.3.65 → 0.3.66
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/dist/commands/agents/index.d.ts +11 -0
- package/dist/commands/agents/index.js +105 -0
- package/dist/commands/agents/index.js.map +1 -0
- package/dist/commands/pr/checks.d.ts +20 -0
- package/dist/commands/pr/checks.js +154 -0
- package/dist/commands/pr/checks.js.map +1 -0
- package/dist/commands/pr/index.js +10 -2
- package/dist/commands/pr/index.js.map +1 -1
- package/dist/commands/pr/merge.d.ts +22 -0
- package/dist/commands/pr/merge.js +145 -0
- package/dist/commands/pr/merge.js.map +1 -0
- package/dist/commands/version/bump.d.ts +13 -0
- package/dist/commands/version/bump.js +125 -0
- package/dist/commands/version/bump.js.map +1 -0
- package/dist/commands/work/start.js +25 -0
- package/dist/commands/work/start.js.map +1 -1
- package/dist/lib/execution/runners.js +14 -6
- package/dist/lib/execution/runners.js.map +1 -1
- package/dist/lib/pr/index.d.ts +28 -0
- package/dist/lib/pr/index.js +53 -1
- package/dist/lib/pr/index.js.map +1 -1
- package/dist/lib/registry/index.d.ts +52 -0
- package/dist/lib/registry/index.js +169 -0
- package/dist/lib/registry/index.js.map +1 -0
- package/oclif.manifest.json +3391 -3150
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-level Agent Registry
|
|
3
|
+
*
|
|
4
|
+
* Tracks all agents across all projects in a single SQLite database
|
|
5
|
+
* at ~/.prlt/agents.db. This provides a global view of agent activity
|
|
6
|
+
* regardless of which workspace they belong to.
|
|
7
|
+
*/
|
|
8
|
+
import Database from 'better-sqlite3';
|
|
9
|
+
export type MachineAgentStatus = 'running' | 'idle' | 'completed';
|
|
10
|
+
export interface MachineAgent {
|
|
11
|
+
agentName: string;
|
|
12
|
+
projectPath: string;
|
|
13
|
+
sessionId: string | null;
|
|
14
|
+
ticketId: string | null;
|
|
15
|
+
status: MachineAgentStatus;
|
|
16
|
+
spawnedAt: string;
|
|
17
|
+
lastSeenAt: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Open (or create) the machine-level agent registry at ~/.prlt/agents.db.
|
|
21
|
+
* Ensures the ~/.prlt directory and schema exist.
|
|
22
|
+
*/
|
|
23
|
+
export declare function openMachineRegistry(): Database.Database;
|
|
24
|
+
/**
|
|
25
|
+
* Register an agent spawn in the machine registry.
|
|
26
|
+
* Uses INSERT OR REPLACE so re-spawning the same agent updates the record.
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerAgent(params: {
|
|
29
|
+
agentName: string;
|
|
30
|
+
projectPath: string;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
ticketId?: string;
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* Update the status of an agent in the machine registry.
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateAgentStatus(agentName: string, projectPath: string, status: MachineAgentStatus): void;
|
|
38
|
+
/**
|
|
39
|
+
* Touch the last_seen_at timestamp for a running agent.
|
|
40
|
+
*/
|
|
41
|
+
export declare function touchAgentLastSeen(agentName: string, projectPath: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get all agents in the machine registry, optionally filtered.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getMachineAgents(filters?: {
|
|
46
|
+
status?: MachineAgentStatus;
|
|
47
|
+
projectPath?: string;
|
|
48
|
+
}): MachineAgent[];
|
|
49
|
+
/**
|
|
50
|
+
* Get a single agent by name and project path.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getMachineAgent(agentName: string, projectPath: string): MachineAgent | undefined;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-level Agent Registry
|
|
3
|
+
*
|
|
4
|
+
* Tracks all agents across all projects in a single SQLite database
|
|
5
|
+
* at ~/.prlt/agents.db. This provides a global view of agent activity
|
|
6
|
+
* regardless of which workspace they belong to.
|
|
7
|
+
*/
|
|
8
|
+
import Database from 'better-sqlite3';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import * as os from 'node:os';
|
|
12
|
+
import { throwIfNativeBindingError } from '../database/native-validation.js';
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// Schema
|
|
15
|
+
// =============================================================================
|
|
16
|
+
const REGISTRY_SCHEMA = `
|
|
17
|
+
CREATE TABLE IF NOT EXISTS agents (
|
|
18
|
+
agent_name TEXT NOT NULL,
|
|
19
|
+
project_path TEXT NOT NULL,
|
|
20
|
+
session_id TEXT,
|
|
21
|
+
ticket_id TEXT,
|
|
22
|
+
status TEXT NOT NULL DEFAULT 'running' CHECK (status IN ('running', 'idle', 'completed')),
|
|
23
|
+
spawned_at TEXT NOT NULL,
|
|
24
|
+
last_seen_at TEXT NOT NULL,
|
|
25
|
+
PRIMARY KEY (agent_name, project_path)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX IF NOT EXISTS idx_registry_status ON agents(status);
|
|
29
|
+
CREATE INDEX IF NOT EXISTS idx_registry_project ON agents(project_path);
|
|
30
|
+
`;
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Helpers
|
|
33
|
+
// =============================================================================
|
|
34
|
+
function rowToMachineAgent(row) {
|
|
35
|
+
return {
|
|
36
|
+
agentName: row.agent_name,
|
|
37
|
+
projectPath: row.project_path,
|
|
38
|
+
sessionId: row.session_id,
|
|
39
|
+
ticketId: row.ticket_id,
|
|
40
|
+
status: row.status,
|
|
41
|
+
spawnedAt: row.spawned_at,
|
|
42
|
+
lastSeenAt: row.last_seen_at,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getMachineRegistryPath() {
|
|
46
|
+
return path.join(os.homedir(), '.prlt', 'agents.db');
|
|
47
|
+
}
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// Database Access
|
|
50
|
+
// =============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Open (or create) the machine-level agent registry at ~/.prlt/agents.db.
|
|
53
|
+
* Ensures the ~/.prlt directory and schema exist.
|
|
54
|
+
*/
|
|
55
|
+
export function openMachineRegistry() {
|
|
56
|
+
const dbPath = getMachineRegistryPath();
|
|
57
|
+
const dir = path.dirname(dbPath);
|
|
58
|
+
if (!fs.existsSync(dir)) {
|
|
59
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const db = new Database(dbPath);
|
|
63
|
+
db.pragma('journal_mode = WAL');
|
|
64
|
+
db.pragma('busy_timeout = 3000');
|
|
65
|
+
db.exec(REGISTRY_SCHEMA);
|
|
66
|
+
return db;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throwIfNativeBindingError(error, 'machine agent registry');
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// =============================================================================
|
|
74
|
+
// Write Operations
|
|
75
|
+
// =============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Register an agent spawn in the machine registry.
|
|
78
|
+
* Uses INSERT OR REPLACE so re-spawning the same agent updates the record.
|
|
79
|
+
*/
|
|
80
|
+
export function registerAgent(params) {
|
|
81
|
+
const db = openMachineRegistry();
|
|
82
|
+
try {
|
|
83
|
+
const now = new Date().toISOString();
|
|
84
|
+
db.prepare(`
|
|
85
|
+
INSERT OR REPLACE INTO agents (agent_name, project_path, session_id, ticket_id, status, spawned_at, last_seen_at)
|
|
86
|
+
VALUES (?, ?, ?, ?, 'running', ?, ?)
|
|
87
|
+
`).run(params.agentName, params.projectPath, params.sessionId ?? null, params.ticketId ?? null, now, now);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
db.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update the status of an agent in the machine registry.
|
|
95
|
+
*/
|
|
96
|
+
export function updateAgentStatus(agentName, projectPath, status) {
|
|
97
|
+
const db = openMachineRegistry();
|
|
98
|
+
try {
|
|
99
|
+
const now = new Date().toISOString();
|
|
100
|
+
db.prepare(`
|
|
101
|
+
UPDATE agents SET status = ?, last_seen_at = ?
|
|
102
|
+
WHERE agent_name = ? AND project_path = ?
|
|
103
|
+
`).run(status, now, agentName, projectPath);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
db.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Touch the last_seen_at timestamp for a running agent.
|
|
111
|
+
*/
|
|
112
|
+
export function touchAgentLastSeen(agentName, projectPath) {
|
|
113
|
+
const db = openMachineRegistry();
|
|
114
|
+
try {
|
|
115
|
+
const now = new Date().toISOString();
|
|
116
|
+
db.prepare(`
|
|
117
|
+
UPDATE agents SET last_seen_at = ?
|
|
118
|
+
WHERE agent_name = ? AND project_path = ?
|
|
119
|
+
`).run(now, agentName, projectPath);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
db.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// =============================================================================
|
|
126
|
+
// Read Operations
|
|
127
|
+
// =============================================================================
|
|
128
|
+
/**
|
|
129
|
+
* Get all agents in the machine registry, optionally filtered.
|
|
130
|
+
*/
|
|
131
|
+
export function getMachineAgents(filters) {
|
|
132
|
+
const db = openMachineRegistry();
|
|
133
|
+
try {
|
|
134
|
+
let sql = 'SELECT * FROM agents';
|
|
135
|
+
const conditions = [];
|
|
136
|
+
const params = [];
|
|
137
|
+
if (filters?.status) {
|
|
138
|
+
conditions.push('status = ?');
|
|
139
|
+
params.push(filters.status);
|
|
140
|
+
}
|
|
141
|
+
if (filters?.projectPath) {
|
|
142
|
+
conditions.push('project_path = ?');
|
|
143
|
+
params.push(filters.projectPath);
|
|
144
|
+
}
|
|
145
|
+
if (conditions.length > 0) {
|
|
146
|
+
sql += ' WHERE ' + conditions.join(' AND ');
|
|
147
|
+
}
|
|
148
|
+
sql += ' ORDER BY last_seen_at DESC';
|
|
149
|
+
const rows = db.prepare(sql).all(...params);
|
|
150
|
+
return rows.map(rowToMachineAgent);
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
db.close();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get a single agent by name and project path.
|
|
158
|
+
*/
|
|
159
|
+
export function getMachineAgent(agentName, projectPath) {
|
|
160
|
+
const db = openMachineRegistry();
|
|
161
|
+
try {
|
|
162
|
+
const row = db.prepare('SELECT * FROM agents WHERE agent_name = ? AND project_path = ?').get(agentName, projectPath);
|
|
163
|
+
return row ? rowToMachineAgent(row) : undefined;
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
db.close();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AA4B5E,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,MAAM,eAAe,GAAG;;;;;;;;;;;;;;CAcvB,CAAA;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,SAAS,iBAAiB,CAAC,GAAoB;IAC7C,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,MAAM,EAAE,GAAG,CAAC,MAA4B;QACxC,SAAS,EAAE,GAAG,CA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