hungry-ghost-hive 0.50.0 → 0.50.1
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/cli/commands/manager/auto-assignment.d.ts.map +1 -1
- package/dist/cli/commands/manager/auto-assignment.js +1 -2
- package/dist/cli/commands/manager/auto-assignment.js.map +1 -1
- package/dist/cli/commands/manager/auto-assignment.test.js +6 -8
- package/dist/cli/commands/manager/auto-assignment.test.js.map +1 -1
- package/dist/cli/commands/msg.d.ts.map +1 -1
- package/dist/cli/commands/msg.js +14 -19
- package/dist/cli/commands/msg.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/manager/auto-assignment.test.ts +6 -10
- package/src/cli/commands/manager/auto-assignment.ts +1 -3
- package/src/cli/commands/msg.ts +19 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-assignment.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manager/auto-assignment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-assignment.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manager/auto-assignment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgBtD,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCtF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { queryAll } from '../../../db/client.js';
|
|
4
3
|
function verboseLog(ctx, message) {
|
|
5
4
|
if (!ctx.verbose)
|
|
6
5
|
return;
|
|
@@ -8,7 +7,7 @@ function verboseLog(ctx, message) {
|
|
|
8
7
|
}
|
|
9
8
|
async function getAssignableUnassignedStoryCount(ctx) {
|
|
10
9
|
return ctx.withDb(async (db) => {
|
|
11
|
-
const rows = queryAll(
|
|
10
|
+
const rows = await db.provider.queryAll("SELECT COUNT(*) as count FROM stories WHERE status IN ('planned', 'qa_failed') AND assigned_agent_id IS NULL");
|
|
12
11
|
return rows[0]?.count || 0;
|
|
13
12
|
});
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-assignment.js","sourceRoot":"","sources":["../../../../src/cli/commands/manager/auto-assignment.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"auto-assignment.js","sourceRoot":"","sources":["../../../../src/cli/commands/manager/auto-assignment.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,SAAS,UAAU,CAAC,GAAyC,EAAE,OAAe;IAC5E,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO;IACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,OAAO,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,KAAK,UAAU,iCAAiC,CAAC,GAAwB;IACvE,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAC,EAAE,EAAC,EAAE;QAC3B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CACrC,8GAA8G,CAC/G,CAAC;QACF,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,GAAwB;IACrE,MAAM,oBAAoB,GAAG,MAAM,iCAAiC,CAAC,GAAG,CAAC,CAAC;IAC1E,UAAU,CAAC,GAAG,EAAE,kDAAkD,oBAAoB,EAAE,CAAC,CAAC;IAE1F,IAAI,oBAAoB,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;QAChE,MAAM,SAAS,CAAC,YAAY,EAAE,CAAC;QAC/B,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QAC/C,EAAE,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,UAAU,CACR,GAAG,EACH,sCAAsC,gBAAgB,CAAC,QAAQ,YAAY,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,CAC5G,CAAC;IACF,GAAG,CAAC,QAAQ,CAAC,mBAAmB,IAAI,gBAAgB,CAAC,QAAQ,CAAC;IAE9D,IAAI,gBAAgB,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,gBAAgB,CAAC,QAAQ,qBAAqB,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CAAC,iCAAiC,gBAAgB,CAAC,MAAM,CAAC,MAAM,WAAW,CAAC,CACzF,CAAC;QACF,KAAK,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;YAC1C,UAAU,CAAC,GAAG,EAAE,mCAAmC,GAAG,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
import { autoAssignPlannedStories } from './auto-assignment.js';
|
|
4
|
-
vi.mock('../../../db/client.js', () => ({
|
|
5
|
-
queryAll: vi.fn(),
|
|
6
|
-
}));
|
|
7
|
-
import { queryAll } from '../../../db/client.js';
|
|
8
4
|
describe('autoAssignPlannedStories', () => {
|
|
9
5
|
beforeEach(() => {
|
|
10
6
|
vi.clearAllMocks();
|
|
@@ -18,14 +14,15 @@ describe('autoAssignPlannedStories', () => {
|
|
|
18
14
|
preventedDuplicates: 0,
|
|
19
15
|
});
|
|
20
16
|
const save = vi.fn();
|
|
21
|
-
const
|
|
17
|
+
const mockProvider = {
|
|
18
|
+
queryAll: vi.fn().mockResolvedValue([{ count: options?.assignableUnassigned ?? 0 }]),
|
|
19
|
+
};
|
|
20
|
+
const mockDb = { db: {}, provider: mockProvider, save };
|
|
22
21
|
const scheduler = { checkScaling, checkMergeQueue, assignStories };
|
|
23
22
|
let callCount = 0;
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
24
|
const withDb = vi.fn(async (fn) => {
|
|
25
25
|
callCount += 1;
|
|
26
|
-
vi.mocked(queryAll).mockReturnValueOnce([
|
|
27
|
-
{ count: options?.assignableUnassigned ?? 0 },
|
|
28
|
-
]);
|
|
29
26
|
return fn(mockDb, scheduler);
|
|
30
27
|
});
|
|
31
28
|
const ctx = {
|
|
@@ -34,6 +31,7 @@ describe('autoAssignPlannedStories', () => {
|
|
|
34
31
|
counters: {
|
|
35
32
|
plannedAutoAssigned: 0,
|
|
36
33
|
},
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
35
|
};
|
|
38
36
|
return {
|
|
39
37
|
ctx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-assignment.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/manager/auto-assignment.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,wBAAwB,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,KAAK,IAAI,EAAE;QAC1F,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;YAC5E,oBAAoB,EAAE,CAAC;YACvB,QAAQ,EAAE,CAAC;SACZ,CAAC,CAAC;QAEH,MAAM,wBAAwB,CAAC,GAAG,CAAC,CAAC;QAEpC,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,eAAe,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msg.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/msg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"msg.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/msg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,eAAO,MAAM,UAAU,SAA0D,CAAC"}
|
package/dist/cli/commands/msg.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { nanoid } from 'nanoid';
|
|
5
|
-
import { queryAll, queryOne, run } from '../../db/client.js';
|
|
6
5
|
import { getTechLeadSessionName } from '../../utils/instance.js';
|
|
7
6
|
import { withHiveContext, withReadOnlyHiveContext } from '../../utils/with-hive-context.js';
|
|
8
7
|
export const msgCommand = new Command('msg').description('Inter-agent messaging');
|
|
@@ -15,10 +14,9 @@ msgCommand
|
|
|
15
14
|
await withHiveContext(async ({ db, paths }) => {
|
|
16
15
|
const id = `msg-${nanoid(8)}`;
|
|
17
16
|
const fromSession = options.from || getTechLeadSessionName(paths.hiveDir);
|
|
18
|
-
|
|
19
|
-
INSERT INTO messages (id, from_session, to_session, subject, body, status, created_at)
|
|
20
|
-
|
|
21
|
-
`, [id, fromSession, toSession, options.subject || null, message]);
|
|
17
|
+
const now = new Date().toISOString();
|
|
18
|
+
await db.provider.run(`INSERT INTO messages (id, from_session, to_session, subject, body, status, created_at)
|
|
19
|
+
VALUES (?, ?, ?, ?, ?, 'pending', ?)`, [id, fromSession, toSession, options.subject || null, message, now]);
|
|
22
20
|
db.save();
|
|
23
21
|
console.log(chalk.green(`Message sent: ${id}`));
|
|
24
22
|
console.log(chalk.gray(`To: ${toSession}`));
|
|
@@ -40,7 +38,7 @@ msgCommand
|
|
|
40
38
|
query += ` AND status = 'pending'`;
|
|
41
39
|
}
|
|
42
40
|
query += ` ORDER BY created_at DESC`;
|
|
43
|
-
const messages = queryAll(
|
|
41
|
+
const messages = await db.provider.queryAll(query, [targetSession]);
|
|
44
42
|
if (messages.length === 0) {
|
|
45
43
|
console.log(chalk.gray(`No ${options.all ? '' : 'pending '}messages for ${targetSession}`));
|
|
46
44
|
return;
|
|
@@ -68,14 +66,16 @@ msgCommand
|
|
|
68
66
|
.description('Read a specific message')
|
|
69
67
|
.action(async (msgId) => {
|
|
70
68
|
await withHiveContext(async ({ db }) => {
|
|
71
|
-
const msg = queryOne(
|
|
69
|
+
const msg = await db.provider.queryOne('SELECT * FROM messages WHERE id = ?', [
|
|
70
|
+
msgId,
|
|
71
|
+
]);
|
|
72
72
|
if (!msg) {
|
|
73
73
|
console.error(chalk.red(`Message not found: ${msgId}`));
|
|
74
74
|
process.exit(1);
|
|
75
75
|
}
|
|
76
76
|
// Mark as read
|
|
77
77
|
if (msg.status === 'pending') {
|
|
78
|
-
run(
|
|
78
|
+
await db.provider.run(`UPDATE messages SET status = 'read' WHERE id = ?`, [msgId]);
|
|
79
79
|
db.save();
|
|
80
80
|
}
|
|
81
81
|
console.log(chalk.bold(`\nMessage: ${msg.id}\n`));
|
|
@@ -99,16 +99,15 @@ msgCommand
|
|
|
99
99
|
.description('Reply to a message')
|
|
100
100
|
.action(async (msgId, response) => {
|
|
101
101
|
await withHiveContext(async ({ db }) => {
|
|
102
|
-
const msg = queryOne(
|
|
102
|
+
const msg = await db.provider.queryOne('SELECT * FROM messages WHERE id = ?', [
|
|
103
|
+
msgId,
|
|
104
|
+
]);
|
|
103
105
|
if (!msg) {
|
|
104
106
|
console.error(chalk.red(`Message not found: ${msgId}`));
|
|
105
107
|
process.exit(1);
|
|
106
108
|
}
|
|
107
|
-
|
|
108
|
-
UPDATE messages
|
|
109
|
-
SET reply = ?, status = 'replied', replied_at = datetime('now')
|
|
110
|
-
WHERE id = ?
|
|
111
|
-
`, [response, msgId]);
|
|
109
|
+
const now = new Date().toISOString();
|
|
110
|
+
await db.provider.run(`UPDATE messages SET reply = ?, status = 'replied', replied_at = ? WHERE id = ?`, [response, now, msgId]);
|
|
112
111
|
db.save();
|
|
113
112
|
console.log(chalk.green(`Reply sent to ${msg.from_session}`));
|
|
114
113
|
});
|
|
@@ -119,11 +118,7 @@ msgCommand
|
|
|
119
118
|
.action(async (session) => {
|
|
120
119
|
await withReadOnlyHiveContext(async ({ db, paths }) => {
|
|
121
120
|
const fromSession = session || getTechLeadSessionName(paths.hiveDir);
|
|
122
|
-
const messages = queryAll(
|
|
123
|
-
SELECT * FROM messages
|
|
124
|
-
WHERE from_session = ?
|
|
125
|
-
ORDER BY created_at DESC
|
|
126
|
-
`, [fromSession]);
|
|
121
|
+
const messages = await db.provider.queryAll(`SELECT * FROM messages WHERE from_session = ? ORDER BY created_at DESC`, [fromSession]);
|
|
127
122
|
if (messages.length === 0) {
|
|
128
123
|
console.log(chalk.gray(`No sent messages from ${fromSession}`));
|
|
129
124
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msg.js","sourceRoot":"","sources":["../../../src/cli/commands/msg.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"msg.js","sourceRoot":"","sources":["../../../src/cli/commands/msg.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAc5F,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;AAElF,UAAU;KACP,OAAO,CAAC,6BAA6B,CAAC;KACtC,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,yBAAyB,EAAE,iBAAiB,CAAC;KACpD,MAAM,CAAC,sBAAsB,EAAE,mDAAmD,CAAC;KACnF,MAAM,CACL,KAAK,EAAE,SAAiB,EAAE,OAAe,EAAE,OAA4C,EAAE,EAAE;IACzF,MAAM,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC5C,MAAM,EAAE,GAAG,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,IA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AAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import { autoAssignPlannedStories } from './auto-assignment.js';
|
|
5
5
|
|
|
6
|
-
vi.mock('../../../db/client.js', () => ({
|
|
7
|
-
queryAll: vi.fn(),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
import { queryAll } from '../../../db/client.js';
|
|
11
|
-
|
|
12
6
|
describe('autoAssignPlannedStories', () => {
|
|
13
7
|
beforeEach(() => {
|
|
14
8
|
vi.clearAllMocks();
|
|
@@ -28,15 +22,16 @@ describe('autoAssignPlannedStories', () => {
|
|
|
28
22
|
preventedDuplicates: 0,
|
|
29
23
|
});
|
|
30
24
|
const save = vi.fn();
|
|
31
|
-
const
|
|
25
|
+
const mockProvider = {
|
|
26
|
+
queryAll: vi.fn().mockResolvedValue([{ count: options?.assignableUnassigned ?? 0 }]),
|
|
27
|
+
};
|
|
28
|
+
const mockDb = { db: {} as never, provider: mockProvider, save };
|
|
32
29
|
const scheduler = { checkScaling, checkMergeQueue, assignStories } as never;
|
|
33
30
|
|
|
34
31
|
let callCount = 0;
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
33
|
const withDb = vi.fn(async (fn: (db: typeof mockDb, scheduler: any) => unknown) => {
|
|
36
34
|
callCount += 1;
|
|
37
|
-
vi.mocked(queryAll).mockReturnValueOnce([
|
|
38
|
-
{ count: options?.assignableUnassigned ?? 0 },
|
|
39
|
-
] as never);
|
|
40
35
|
return fn(mockDb, scheduler);
|
|
41
36
|
});
|
|
42
37
|
|
|
@@ -46,6 +41,7 @@ describe('autoAssignPlannedStories', () => {
|
|
|
46
41
|
counters: {
|
|
47
42
|
plannedAutoAssigned: 0,
|
|
48
43
|
},
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
45
|
} as any;
|
|
50
46
|
|
|
51
47
|
return {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import { queryAll } from '../../../db/client.js';
|
|
5
4
|
import type { ManagerCheckContext } from './types.js';
|
|
6
5
|
|
|
7
6
|
function verboseLog(ctx: Pick<ManagerCheckContext, 'verbose'>, message: string): void {
|
|
@@ -11,8 +10,7 @@ function verboseLog(ctx: Pick<ManagerCheckContext, 'verbose'>, message: string):
|
|
|
11
10
|
|
|
12
11
|
async function getAssignableUnassignedStoryCount(ctx: ManagerCheckContext): Promise<number> {
|
|
13
12
|
return ctx.withDb(async db => {
|
|
14
|
-
const rows = queryAll<{ count: number }>(
|
|
15
|
-
db.db,
|
|
13
|
+
const rows = await db.provider.queryAll<{ count: number }>(
|
|
16
14
|
"SELECT COUNT(*) as count FROM stories WHERE status IN ('planned', 'qa_failed') AND assigned_agent_id IS NULL"
|
|
17
15
|
);
|
|
18
16
|
return rows[0]?.count || 0;
|
package/src/cli/commands/msg.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { Command } from 'commander';
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
6
|
-
import { queryAll, queryOne, run } from '../../db/client.js';
|
|
7
6
|
import { getTechLeadSessionName } from '../../utils/instance.js';
|
|
8
7
|
import { withHiveContext, withReadOnlyHiveContext } from '../../utils/with-hive-context.js';
|
|
9
8
|
|
|
@@ -32,13 +31,11 @@ msgCommand
|
|
|
32
31
|
const id = `msg-${nanoid(8)}`;
|
|
33
32
|
const fromSession = options.from || getTechLeadSessionName(paths.hiveDir);
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`,
|
|
41
|
-
[id, fromSession, toSession, options.subject || null, message]
|
|
34
|
+
const now = new Date().toISOString();
|
|
35
|
+
await db.provider.run(
|
|
36
|
+
`INSERT INTO messages (id, from_session, to_session, subject, body, status, created_at)
|
|
37
|
+
VALUES (?, ?, ?, ?, ?, 'pending', ?)`,
|
|
38
|
+
[id, fromSession, toSession, options.subject || null, message, now]
|
|
42
39
|
);
|
|
43
40
|
db.save();
|
|
44
41
|
|
|
@@ -66,7 +63,7 @@ msgCommand
|
|
|
66
63
|
}
|
|
67
64
|
query += ` ORDER BY created_at DESC`;
|
|
68
65
|
|
|
69
|
-
const messages = queryAll<MessageRow>(
|
|
66
|
+
const messages = await db.provider.queryAll<MessageRow>(query, [targetSession]);
|
|
70
67
|
|
|
71
68
|
if (messages.length === 0) {
|
|
72
69
|
console.log(chalk.gray(`No ${options.all ? '' : 'pending '}messages for ${targetSession}`));
|
|
@@ -104,7 +101,9 @@ msgCommand
|
|
|
104
101
|
.description('Read a specific message')
|
|
105
102
|
.action(async (msgId: string) => {
|
|
106
103
|
await withHiveContext(async ({ db }) => {
|
|
107
|
-
const msg = queryOne<MessageRow>(
|
|
104
|
+
const msg = await db.provider.queryOne<MessageRow>('SELECT * FROM messages WHERE id = ?', [
|
|
105
|
+
msgId,
|
|
106
|
+
]);
|
|
108
107
|
|
|
109
108
|
if (!msg) {
|
|
110
109
|
console.error(chalk.red(`Message not found: ${msgId}`));
|
|
@@ -113,7 +112,7 @@ msgCommand
|
|
|
113
112
|
|
|
114
113
|
// Mark as read
|
|
115
114
|
if (msg.status === 'pending') {
|
|
116
|
-
run(
|
|
115
|
+
await db.provider.run(`UPDATE messages SET status = 'read' WHERE id = ?`, [msgId]);
|
|
117
116
|
db.save();
|
|
118
117
|
}
|
|
119
118
|
|
|
@@ -140,21 +139,19 @@ msgCommand
|
|
|
140
139
|
.description('Reply to a message')
|
|
141
140
|
.action(async (msgId: string, response: string) => {
|
|
142
141
|
await withHiveContext(async ({ db }) => {
|
|
143
|
-
const msg = queryOne<MessageRow>(
|
|
142
|
+
const msg = await db.provider.queryOne<MessageRow>('SELECT * FROM messages WHERE id = ?', [
|
|
143
|
+
msgId,
|
|
144
|
+
]);
|
|
144
145
|
|
|
145
146
|
if (!msg) {
|
|
146
147
|
console.error(chalk.red(`Message not found: ${msgId}`));
|
|
147
148
|
process.exit(1);
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
`
|
|
153
|
-
|
|
154
|
-
SET reply = ?, status = 'replied', replied_at = datetime('now')
|
|
155
|
-
WHERE id = ?
|
|
156
|
-
`,
|
|
157
|
-
[response, msgId]
|
|
151
|
+
const now = new Date().toISOString();
|
|
152
|
+
await db.provider.run(
|
|
153
|
+
`UPDATE messages SET reply = ?, status = 'replied', replied_at = ? WHERE id = ?`,
|
|
154
|
+
[response, now, msgId]
|
|
158
155
|
);
|
|
159
156
|
db.save();
|
|
160
157
|
|
|
@@ -169,13 +166,8 @@ msgCommand
|
|
|
169
166
|
await withReadOnlyHiveContext(async ({ db, paths }) => {
|
|
170
167
|
const fromSession = session || getTechLeadSessionName(paths.hiveDir);
|
|
171
168
|
|
|
172
|
-
const messages = queryAll<MessageRow>(
|
|
173
|
-
|
|
174
|
-
`
|
|
175
|
-
SELECT * FROM messages
|
|
176
|
-
WHERE from_session = ?
|
|
177
|
-
ORDER BY created_at DESC
|
|
178
|
-
`,
|
|
169
|
+
const messages = await db.provider.queryAll<MessageRow>(
|
|
170
|
+
`SELECT * FROM messages WHERE from_session = ? ORDER BY created_at DESC`,
|
|
179
171
|
[fromSession]
|
|
180
172
|
);
|
|
181
173
|
|