@concord-ai/concord-mcp 0.1.1 → 0.3.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 +34 -17
- package/dist/artifacts/work-state-json.js +1 -0
- package/dist/artifacts/work-state-json.js.map +1 -1
- package/dist/artifacts/work-state-view.d.ts +36 -0
- package/dist/artifacts/work-state-view.js +99 -0
- package/dist/artifacts/work-state-view.js.map +1 -0
- package/dist/cli/commands/check.d.ts +20 -0
- package/dist/cli/commands/check.js +66 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/doctor.js +2 -1
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/hook.d.ts +19 -0
- package/dist/cli/commands/hook.js +82 -0
- package/dist/cli/commands/hook.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +15 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.js +9 -1
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/review-packet.js +1 -1
- package/dist/cli/commands/review-packet.js.map +1 -1
- package/dist/cli/commands/status.d.ts +0 -31
- package/dist/cli/commands/status.js +1 -95
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +5 -0
- package/dist/cli/commands/watch.js +35 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/db/index.d.ts +4 -1
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/repositories/task-updates.d.ts +13 -0
- package/dist/db/repositories/task-updates.js +32 -0
- package/dist/db/repositories/task-updates.js.map +1 -0
- package/dist/db/repositories/tasks.d.ts +10 -0
- package/dist/db/repositories/tasks.js +17 -2
- package/dist/db/repositories/tasks.js.map +1 -1
- package/dist/db/rows.d.ts +14 -1
- package/dist/db/rows.js +34 -1
- package/dist/db/rows.js.map +1 -1
- package/dist/db/schema.js +18 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/domain/decomposition.d.ts +25 -0
- package/dist/domain/decomposition.js +32 -0
- package/dist/domain/decomposition.js.map +1 -0
- package/dist/domain/overlap.d.ts +11 -2
- package/dist/domain/overlap.js +51 -9
- package/dist/domain/overlap.js.map +1 -1
- package/dist/domain/schemas.d.ts +78 -0
- package/dist/domain/schemas.js +48 -2
- package/dist/domain/schemas.js.map +1 -1
- package/dist/install/claude-hooks.d.ts +13 -0
- package/dist/install/claude-hooks.js +48 -0
- package/dist/install/claude-hooks.js.map +1 -0
- package/dist/install/instructions.d.ts +1 -1
- package/dist/install/instructions.js +14 -4
- package/dist/install/instructions.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +14 -4
- package/dist/server.js.map +1 -1
- package/dist/tools/claim-work.d.ts +39 -2
- package/dist/tools/claim-work.js +99 -28
- package/dist/tools/claim-work.js.map +1 -1
- package/dist/tools/get-task-context.d.ts +13 -0
- package/dist/tools/get-task-context.js +77 -0
- package/dist/tools/get-task-context.js.map +1 -0
- package/dist/tools/get-work-state.d.ts +22 -0
- package/dist/tools/get-work-state.js +72 -0
- package/dist/tools/get-work-state.js.map +1 -0
- package/dist/tools/handoff.d.ts +2 -0
- package/dist/tools/handoff.js +28 -3
- package/dist/tools/handoff.js.map +1 -1
- package/dist/tools/review-ready.d.ts +3 -4
- package/dist/tools/review-ready.js +5 -23
- package/dist/tools/review-ready.js.map +1 -1
- package/dist/tools/update-task.d.ts +10 -0
- package/dist/tools/update-task.js +48 -0
- package/dist/tools/update-task.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/dist/tools/claim-work.js
CHANGED
|
@@ -1,72 +1,143 @@
|
|
|
1
|
+
import { assessClaimBreadth } from '../domain/decomposition.js';
|
|
1
2
|
import { detectOverlaps } from '../domain/overlap.js';
|
|
2
3
|
import { claimWorkInputShape } from '../domain/schemas.js';
|
|
4
|
+
/** Union of two label lists, de-duplicated, existing entries first. */
|
|
5
|
+
function mergeUnique(existing, incoming) {
|
|
6
|
+
return [...new Set([...existing, ...incoming])];
|
|
7
|
+
}
|
|
8
|
+
/** Entries in `incoming` not already present in `existing`. */
|
|
9
|
+
function addedEntries(existing, incoming) {
|
|
10
|
+
const have = new Set(existing);
|
|
11
|
+
return [...new Set(incoming.filter((value) => !have.has(value)))];
|
|
12
|
+
}
|
|
3
13
|
/**
|
|
4
|
-
* Record that an agent is working on a task and flag
|
|
5
|
-
*
|
|
14
|
+
* Record that an agent is working on a task and flag overlaps with other active
|
|
15
|
+
* tasks. Re-claiming an existing task is idempotent for its identity (title,
|
|
16
|
+
* owner, agent) but *extends* its declared scope: the new files/modules/domains/
|
|
17
|
+
* risk tags are merged in and persisted, overlaps are recomputed against the
|
|
18
|
+
* merged scope, and the additions are reported back.
|
|
6
19
|
*/
|
|
7
20
|
export function handleClaimWork(repos, input) {
|
|
21
|
+
const inputFiles = input.expected_files ?? [];
|
|
22
|
+
const inputModules = input.modules ?? [];
|
|
23
|
+
const inputDomains = input.domains ?? [];
|
|
24
|
+
const inputRiskTags = input.risk_tags ?? [];
|
|
25
|
+
const existing = repos.tasks.get(input.task_id);
|
|
26
|
+
// Parent is set at first claim and preserved thereafter (identity is idempotent).
|
|
27
|
+
const parentTaskId = existing ? existing.parentTaskId : (input.parent_task_id ?? null);
|
|
28
|
+
// Effective scope: the merged surface for an existing claim, else the input.
|
|
29
|
+
const scope = {
|
|
30
|
+
expectedFiles: existing ? mergeUnique(existing.expectedFiles, inputFiles) : inputFiles,
|
|
31
|
+
modules: existing ? mergeUnique(existing.modules, inputModules) : inputModules,
|
|
32
|
+
domains: existing ? mergeUnique(existing.domains, inputDomains) : inputDomains,
|
|
33
|
+
riskTags: existing ? mergeUnique(existing.riskTags, inputRiskTags) : inputRiskTags,
|
|
34
|
+
};
|
|
8
35
|
const activeOthers = repos.tasks
|
|
9
36
|
.list()
|
|
10
37
|
.filter((task) => task.taskId !== input.task_id && task.status === 'active');
|
|
11
|
-
const overlaps = detectOverlaps({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
38
|
+
const overlaps = detectOverlaps({ taskId: input.task_id, parentTaskId, ...scope }, activeOthers);
|
|
39
|
+
const scopeAdded = existing
|
|
40
|
+
? [
|
|
41
|
+
...addedEntries(existing.expectedFiles, inputFiles).map((value) => `file: ${value}`),
|
|
42
|
+
...addedEntries(existing.modules, inputModules).map((value) => `module: ${value}`),
|
|
43
|
+
...addedEntries(existing.domains, inputDomains).map((value) => `domain: ${value}`),
|
|
44
|
+
...addedEntries(existing.riskTags, inputRiskTags).map((value) => `risk tag: ${value}`),
|
|
45
|
+
]
|
|
46
|
+
: [];
|
|
47
|
+
let task;
|
|
48
|
+
if (existing === undefined) {
|
|
49
|
+
task = repos.tasks.create({
|
|
21
50
|
taskId: input.task_id,
|
|
22
51
|
title: input.title,
|
|
23
52
|
owner: input.owner ?? null,
|
|
24
53
|
agent: input.agent ?? null,
|
|
25
54
|
branch: input.branch ?? null,
|
|
26
55
|
worktree: input.worktree ?? null,
|
|
27
|
-
|
|
28
|
-
modules: input.modules ?? [],
|
|
29
|
-
domains: input.domains ?? [],
|
|
30
|
-
riskTags: input.risk_tags ?? [],
|
|
56
|
+
...scope,
|
|
31
57
|
notes: input.notes ?? null,
|
|
58
|
+
parentTaskId,
|
|
32
59
|
});
|
|
60
|
+
}
|
|
61
|
+
else if (scopeAdded.length > 0) {
|
|
62
|
+
task = repos.tasks.updateScope(input.task_id, scope) ?? existing;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
task = existing;
|
|
66
|
+
}
|
|
33
67
|
repos.events.record({
|
|
34
68
|
taskId: input.task_id,
|
|
35
69
|
tool: 'claim_work',
|
|
36
70
|
status: 'success',
|
|
37
71
|
detail: overlaps.length > 0 ? `${String(overlaps.length)} overlap(s)` : null,
|
|
38
72
|
});
|
|
39
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
task,
|
|
75
|
+
alreadyClaimed: existing !== undefined,
|
|
76
|
+
overlaps,
|
|
77
|
+
checkedAgainst: activeOthers.length,
|
|
78
|
+
breadthReasons: assessClaimBreadth(scope),
|
|
79
|
+
scopeAdded,
|
|
80
|
+
};
|
|
40
81
|
}
|
|
41
82
|
export function formatClaimWorkText(result) {
|
|
42
83
|
const verb = result.alreadyClaimed ? 'Already claimed' : 'Claimed';
|
|
43
84
|
const lines = [`${verb} ${result.task.taskId} (${result.task.title}).`];
|
|
85
|
+
if (result.alreadyClaimed && result.scopeAdded.length > 0) {
|
|
86
|
+
lines.push(`Extended claim scope (added ${result.scopeAdded.join(', ')}).`);
|
|
87
|
+
}
|
|
44
88
|
if (result.overlaps.length === 0) {
|
|
45
|
-
|
|
46
|
-
|
|
89
|
+
if (result.checkedAgainst === 0) {
|
|
90
|
+
lines.push('No other active claims to check against yet. Overlaps are only checked at ' +
|
|
91
|
+
'claim time, so a later overlapping claim will not appear here — run ' +
|
|
92
|
+
'`concord status` to re-check as others claim work.');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
lines.push(`No overlaps with the ${String(result.checkedAgainst)} other active task(s) at claim time. ` +
|
|
96
|
+
'This is a point-in-time check — run `concord status` to re-check as new work is claimed.');
|
|
97
|
+
}
|
|
47
98
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
99
|
+
else {
|
|
100
|
+
lines.push(`Potential overlaps (${String(result.overlaps.length)} of ${String(result.checkedAgainst)} active task(s)):`);
|
|
101
|
+
for (const overlap of result.overlaps) {
|
|
102
|
+
lines.push(` - ${overlap.taskId} (${overlap.title}): ${overlap.reasons.join('; ')}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (result.breadthReasons.length > 0) {
|
|
106
|
+
lines.push(`Heads-up: this claim looks broad (${result.breadthReasons.join('; ')}). ` +
|
|
107
|
+
'Consider splitting it into smaller, independently-handoffable tasks and claiming each separately.');
|
|
51
108
|
}
|
|
52
109
|
return lines.join('\n');
|
|
53
110
|
}
|
|
111
|
+
/** The `claim_work` MCP structured output. All keys are snake_case, including
|
|
112
|
+
* overlap entries, so the payload is internally consistent. */
|
|
113
|
+
export function toClaimWorkStructured(result) {
|
|
114
|
+
return {
|
|
115
|
+
task_id: result.task.taskId,
|
|
116
|
+
parent_task_id: result.task.parentTaskId,
|
|
117
|
+
already_claimed: result.alreadyClaimed,
|
|
118
|
+
overlaps: result.overlaps.map((overlap) => ({
|
|
119
|
+
task_id: overlap.taskId,
|
|
120
|
+
title: overlap.title,
|
|
121
|
+
reasons: overlap.reasons,
|
|
122
|
+
})),
|
|
123
|
+
checked_against: result.checkedAgainst,
|
|
124
|
+
breadth_reasons: result.breadthReasons,
|
|
125
|
+
scope_added: result.scopeAdded,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
54
128
|
export function registerClaimWork(server, repos, onWrite) {
|
|
55
129
|
server.registerTool('claim_work', {
|
|
56
130
|
title: 'Claim work',
|
|
57
131
|
description: 'Record that an agent is starting a task and flag overlaps with other active tasks. ' +
|
|
58
|
-
'Call this before editing code.'
|
|
132
|
+
'Call this before editing code. Overlap detection is point-in-time (only against tasks ' +
|
|
133
|
+
'already active at claim time); run `concord status` to re-check as others claim.',
|
|
59
134
|
inputSchema: claimWorkInputShape,
|
|
60
135
|
}, (args) => {
|
|
61
136
|
const result = handleClaimWork(repos, args);
|
|
62
137
|
onWrite?.();
|
|
63
138
|
return {
|
|
64
139
|
content: [{ type: 'text', text: formatClaimWorkText(result) }],
|
|
65
|
-
structuredContent:
|
|
66
|
-
task_id: result.task.taskId,
|
|
67
|
-
already_claimed: result.alreadyClaimed,
|
|
68
|
-
overlaps: result.overlaps,
|
|
69
|
-
},
|
|
140
|
+
structuredContent: toClaimWorkStructured(result),
|
|
70
141
|
};
|
|
71
142
|
});
|
|
72
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim-work.js","sourceRoot":"","sources":["../../src/tools/claim-work.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"claim-work.js","sourceRoot":"","sources":["../../src/tools/claim-work.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sBAAsB,CAAC;AA2BhF,uEAAuE;AACvE,SAAS,WAAW,CAAC,QAA2B,EAAE,QAA2B;IAC3E,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,+DAA+D;AAC/D,SAAS,YAAY,CAAC,QAA2B,EAAE,QAA2B;IAC5E,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAmB,EAAE,KAAqB;IACxE,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC;IAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;IAE5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,CAAC,UAAU;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAiB,EACjB,KAAmB,EACnB,OAAoB;IAEpB,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,KAAK,EAAE,YAAY;QACnB,WAAW,EACT,qFAAqF;YACrF,wFAAwF;YACxF,kFAAkF;QACpF,WAAW,EAAE,mBAAmB;KACjC,EACD,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC5C,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9D,iBAAiB,EAAE,qBAAqB,CAAC,MAAM,CAAC;SACjD,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { HandoffRecord, Repositories, ReviewRecord, TaskRecord, TaskUpdateRecord } from '../db/index.js';
|
|
3
|
+
import { type OverlapWarning } from '../domain/overlap.js';
|
|
4
|
+
import { type GetTaskContextInput } from '../domain/schemas.js';
|
|
5
|
+
export interface TaskContextResult {
|
|
6
|
+
task: TaskRecord;
|
|
7
|
+
updates: TaskUpdateRecord[];
|
|
8
|
+
latestHandoff: HandoffRecord | undefined;
|
|
9
|
+
latestReview: ReviewRecord | undefined;
|
|
10
|
+
overlaps: OverlapWarning[];
|
|
11
|
+
}
|
|
12
|
+
export declare function handleGetTaskContext(repos: Repositories, input: GetTaskContextInput): TaskContextResult;
|
|
13
|
+
export declare function registerGetTaskContext(server: McpServer, repos: Repositories): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { detectOverlaps } from '../domain/overlap.js';
|
|
2
|
+
import { getTaskContextInputShape } from '../domain/schemas.js';
|
|
3
|
+
export function handleGetTaskContext(repos, input) {
|
|
4
|
+
const task = repos.tasks.get(input.task_id);
|
|
5
|
+
if (!task) {
|
|
6
|
+
throw new Error(`Task "${input.task_id}" is not claimed. Call claim_work first.`);
|
|
7
|
+
}
|
|
8
|
+
const overlaps = task.status === 'active'
|
|
9
|
+
? detectOverlaps({
|
|
10
|
+
taskId: task.taskId,
|
|
11
|
+
parentTaskId: task.parentTaskId,
|
|
12
|
+
expectedFiles: task.expectedFiles,
|
|
13
|
+
modules: task.modules,
|
|
14
|
+
domains: task.domains,
|
|
15
|
+
riskTags: task.riskTags,
|
|
16
|
+
}, repos.tasks
|
|
17
|
+
.list()
|
|
18
|
+
.filter((candidate) => candidate.taskId !== task.taskId && candidate.status === 'active'))
|
|
19
|
+
: [];
|
|
20
|
+
return {
|
|
21
|
+
task,
|
|
22
|
+
updates: repos.taskUpdates.listByTask(task.taskId),
|
|
23
|
+
latestHandoff: repos.handoffs.latestForTask(task.taskId),
|
|
24
|
+
latestReview: repos.reviews.latestForTask(task.taskId),
|
|
25
|
+
overlaps,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function formatContext(result) {
|
|
29
|
+
const updates = result.updates.length === 0
|
|
30
|
+
? ' None'
|
|
31
|
+
: result.updates
|
|
32
|
+
.map((update) => ` [${update.kind}] ${update.content} — ${update.agent ?? 'unknown agent'}`)
|
|
33
|
+
.join('\n');
|
|
34
|
+
const overlaps = result.overlaps.length === 0
|
|
35
|
+
? ' None'
|
|
36
|
+
: result.overlaps
|
|
37
|
+
.map((overlap) => ` ${overlap.taskId}: ${overlap.reasons.join('; ')}`)
|
|
38
|
+
.join('\n');
|
|
39
|
+
return [
|
|
40
|
+
`${result.task.taskId} — ${result.task.title}`,
|
|
41
|
+
`Status: ${result.task.status}`,
|
|
42
|
+
`Agent: ${result.task.agent ?? 'unassigned'}`,
|
|
43
|
+
`Notes: ${result.task.notes ?? 'not recorded'}`,
|
|
44
|
+
'Updates:',
|
|
45
|
+
updates,
|
|
46
|
+
'Live overlaps:',
|
|
47
|
+
overlaps,
|
|
48
|
+
`Latest handoff: ${result.latestHandoff?.whatChanged ?? 'none'}`,
|
|
49
|
+
`Review plan: ${result.latestReview?.planSummary ?? 'not submitted'}`,
|
|
50
|
+
].join('\n');
|
|
51
|
+
}
|
|
52
|
+
export function registerGetTaskContext(server, repos) {
|
|
53
|
+
server.registerTool('get_task_context', {
|
|
54
|
+
title: 'Get task context',
|
|
55
|
+
description: "Read a claimed task's scope, ordered updates, latest handoff and review, and current overlaps.",
|
|
56
|
+
inputSchema: getTaskContextInputShape,
|
|
57
|
+
annotations: {
|
|
58
|
+
readOnlyHint: true,
|
|
59
|
+
destructiveHint: false,
|
|
60
|
+
idempotentHint: true,
|
|
61
|
+
openWorldHint: false,
|
|
62
|
+
},
|
|
63
|
+
}, (input) => {
|
|
64
|
+
const result = handleGetTaskContext(repos, input);
|
|
65
|
+
return {
|
|
66
|
+
content: [{ type: 'text', text: formatContext(result) }],
|
|
67
|
+
structuredContent: {
|
|
68
|
+
task: result.task,
|
|
69
|
+
updates: result.updates,
|
|
70
|
+
latest_handoff: result.latestHandoff ?? null,
|
|
71
|
+
latest_review: result.latestReview ?? null,
|
|
72
|
+
overlaps: result.overlaps,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=get-task-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-task-context.js","sourceRoot":"","sources":["../../src/tools/get-task-context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAA4B,MAAM,sBAAsB,CAAC;AAU1F,MAAM,UAAU,oBAAoB,CAClC,KAAmB,EACnB,KAA0B;IAE1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,C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E,KAAK,CAAC,CAAC;QAClD,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,cAAc,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;gBAC5C,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,IAAI;gBAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type StatusView } from '../artifacts/work-state-view.js';
|
|
3
|
+
import type { Repositories } from '../db/index.js';
|
|
4
|
+
/** Stable URI for the read-only work-state resource. */
|
|
5
|
+
export declare const WORK_STATE_URI = "concord://work-state";
|
|
6
|
+
/**
|
|
7
|
+
* Read the current shared work-state. Pure read: no writes, no artifact
|
|
8
|
+
* regeneration. Overlaps are recomputed live across all active tasks, so this
|
|
9
|
+
* reflects claims made after any single agent's own `claim_work` returned.
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleGetWorkState(repos: Repositories): StatusView;
|
|
12
|
+
/**
|
|
13
|
+
* Register the read surface for shared work-state: the `get_work_state` tool
|
|
14
|
+
* (which agents can call directly) and the `concord://work-state` resource (the
|
|
15
|
+
* MCP-native read). Both return the same snapshot. This is read-only and does
|
|
16
|
+
* not change the three-tool *write* surface.
|
|
17
|
+
*
|
|
18
|
+
* Returns a `notifyChanged` callback: call it after any write so subscribed
|
|
19
|
+
* clients are pushed a `resources/updated` for `concord://work-state`. MCP
|
|
20
|
+
* cannot wake an idle client — this is push while a session is connected.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerWorkState(server: McpServer, repos: Repositories): () => void;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SubscribeRequestSchema, UnsubscribeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { buildStatus, renderStatusText } from '../artifacts/work-state-view.js';
|
|
3
|
+
/** Stable URI for the read-only work-state resource. */
|
|
4
|
+
export const WORK_STATE_URI = 'concord://work-state';
|
|
5
|
+
/**
|
|
6
|
+
* Read the current shared work-state. Pure read: no writes, no artifact
|
|
7
|
+
* regeneration. Overlaps are recomputed live across all active tasks, so this
|
|
8
|
+
* reflects claims made after any single agent's own `claim_work` returned.
|
|
9
|
+
*/
|
|
10
|
+
export function handleGetWorkState(repos) {
|
|
11
|
+
return buildStatus(repos);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register the read surface for shared work-state: the `get_work_state` tool
|
|
15
|
+
* (which agents can call directly) and the `concord://work-state` resource (the
|
|
16
|
+
* MCP-native read). Both return the same snapshot. This is read-only and does
|
|
17
|
+
* not change the three-tool *write* surface.
|
|
18
|
+
*
|
|
19
|
+
* Returns a `notifyChanged` callback: call it after any write so subscribed
|
|
20
|
+
* clients are pushed a `resources/updated` for `concord://work-state`. MCP
|
|
21
|
+
* cannot wake an idle client — this is push while a session is connected.
|
|
22
|
+
*/
|
|
23
|
+
export function registerWorkState(server, repos) {
|
|
24
|
+
server.registerTool('get_work_state', {
|
|
25
|
+
title: 'Get work state',
|
|
26
|
+
description: 'Read the current shared work-state: active claims, overlaps (recomputed live across ' +
|
|
27
|
+
'all active tasks), and review-ready tasks. Read-only — call this before claiming to ' +
|
|
28
|
+
'see what other agents are already working on.',
|
|
29
|
+
}, () => {
|
|
30
|
+
const view = handleGetWorkState(repos);
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: 'text', text: renderStatusText(view) }],
|
|
33
|
+
structuredContent: {
|
|
34
|
+
active: view.active,
|
|
35
|
+
overlaps: view.overlaps,
|
|
36
|
+
review_ready: view.reviewReady,
|
|
37
|
+
open_questions: view.openQuestions,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
server.registerResource('work-state', WORK_STATE_URI, {
|
|
42
|
+
title: 'Concord work state',
|
|
43
|
+
description: 'Active claims, live overlaps, and review-ready tasks as JSON.',
|
|
44
|
+
mimeType: 'application/json',
|
|
45
|
+
}, (uri) => ({
|
|
46
|
+
contents: [
|
|
47
|
+
{
|
|
48
|
+
uri: uri.href,
|
|
49
|
+
mimeType: 'application/json',
|
|
50
|
+
text: `${JSON.stringify(handleGetWorkState(repos), null, 2)}\n`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}));
|
|
54
|
+
// Advertise resource subscriptions and track which URIs clients care about,
|
|
55
|
+
// so writes push a targeted `resources/updated` rather than a broadcast.
|
|
56
|
+
server.server.registerCapabilities({ resources: { subscribe: true } });
|
|
57
|
+
const subscribers = new Set();
|
|
58
|
+
server.server.setRequestHandler(SubscribeRequestSchema, (request) => {
|
|
59
|
+
subscribers.add(request.params.uri);
|
|
60
|
+
return {};
|
|
61
|
+
});
|
|
62
|
+
server.server.setRequestHandler(UnsubscribeRequestSchema, (request) => {
|
|
63
|
+
subscribers.delete(request.params.uri);
|
|
64
|
+
return {};
|
|
65
|
+
});
|
|
66
|
+
return () => {
|
|
67
|
+
if (subscribers.has(WORK_STATE_URI)) {
|
|
68
|
+
void server.server.sendResourceUpdated({ uri: WORK_STATE_URI });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=get-work-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-work-state.js","sourceRoot":"","sources":["../../src/tools/get-work-state.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAmB,MAAM,iCAAiC,CAAC;AAGjG,wDAAwD;AACxD,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,oBAAoB,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE;QAClE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;QACpE,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,IAAI,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/tools/handoff.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { type HandoffInput } from '../domain/schemas.js';
|
|
|
4
4
|
export interface HandoffResult {
|
|
5
5
|
handoff: HandoffRecord;
|
|
6
6
|
taskAutoCreated: boolean;
|
|
7
|
+
/** True when `ready_for_review` was set, so a review packet was also produced. */
|
|
8
|
+
reviewReady: boolean;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Record a handoff for a task and mark the task handed off. If the task was
|
package/dist/tools/handoff.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { handoffInputShape } from '../domain/schemas.js';
|
|
2
|
+
import { handleReviewReady } from './review-ready.js';
|
|
2
3
|
/**
|
|
3
4
|
* Record a handoff for a task and mark the task handed off. If the task was
|
|
4
5
|
* never claimed, a minimal stub task is created so the handoff is never lost
|
|
@@ -20,6 +21,7 @@ export function handleHandoff(repos, input) {
|
|
|
20
21
|
domains: [],
|
|
21
22
|
riskTags: [],
|
|
22
23
|
notes: null,
|
|
24
|
+
parentTaskId: null,
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
const handoff = repos.handoffs.create({
|
|
@@ -35,14 +37,32 @@ export function handleHandoff(repos, input) {
|
|
|
35
37
|
needsReviewFrom: input.needs_review_from ?? [],
|
|
36
38
|
nextSteps: input.next_steps ?? [],
|
|
37
39
|
});
|
|
38
|
-
repos.tasks.updateStatus(input.task_id, 'handed_off');
|
|
39
40
|
repos.events.record({
|
|
40
41
|
taskId: input.task_id,
|
|
41
42
|
tool: 'handoff',
|
|
42
43
|
status: 'success',
|
|
43
44
|
detail: input.status,
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
+
// Folding review_ready into handoff: when flagged, produce the review packet
|
|
47
|
+
// (and set status review_ready) via the shared review handler. Otherwise the
|
|
48
|
+
// task is simply handed off.
|
|
49
|
+
const reviewReady = input.ready_for_review === true;
|
|
50
|
+
if (reviewReady) {
|
|
51
|
+
handleReviewReady(repos, {
|
|
52
|
+
task_id: input.task_id,
|
|
53
|
+
plan_summary: input.what_changed,
|
|
54
|
+
tests_run: input.tests_run,
|
|
55
|
+
diff_size: input.diff_size,
|
|
56
|
+
guardrails_checked: input.guardrails_checked,
|
|
57
|
+
assumptions: input.assumptions,
|
|
58
|
+
open_questions: input.open_questions,
|
|
59
|
+
provenance: input.provenance,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
repos.tasks.updateStatus(input.task_id, 'handed_off');
|
|
64
|
+
}
|
|
65
|
+
return { handoff, taskAutoCreated, reviewReady };
|
|
46
66
|
}
|
|
47
67
|
export function formatHandoffText(result) {
|
|
48
68
|
const { handoff } = result;
|
|
@@ -54,13 +74,17 @@ export function formatHandoffText(result) {
|
|
|
54
74
|
if (handoff.needsReviewFrom.length > 0) {
|
|
55
75
|
lines.push(`Needs review from: ${handoff.needsReviewFrom.join(', ')}`);
|
|
56
76
|
}
|
|
77
|
+
if (result.reviewReady) {
|
|
78
|
+
lines.push('Marked review-ready; REVIEW_PACKET.md regenerated.');
|
|
79
|
+
}
|
|
57
80
|
return lines.join('\n');
|
|
58
81
|
}
|
|
59
82
|
export function registerHandoff(server, repos, onWrite) {
|
|
60
83
|
server.registerTool('handoff', {
|
|
61
84
|
title: 'Hand off work',
|
|
62
85
|
description: 'Record a concise handoff when an agent finishes or is blocked: what changed, ' +
|
|
63
|
-
'tests run, assumptions, decisions, and guardrails checked. Call this before finishing.'
|
|
86
|
+
'tests run, assumptions, decisions, and guardrails checked. Call this before finishing. ' +
|
|
87
|
+
'Set ready_for_review before a PR to also produce a review packet.',
|
|
64
88
|
inputSchema: handoffInputShape,
|
|
65
89
|
}, (args) => {
|
|
66
90
|
const result = handleHandoff(repos, args);
|
|
@@ -71,6 +95,7 @@ export function registerHandoff(server, repos, onWrite) {
|
|
|
71
95
|
task_id: result.handoff.taskId,
|
|
72
96
|
handoff_id: result.handoff.id,
|
|
73
97
|
task_auto_created: result.taskAutoCreated,
|
|
98
|
+
review_ready: result.reviewReady,
|
|
74
99
|
},
|
|
75
100
|
};
|
|
76
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/tools/handoff.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/tools/handoff.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAStD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAmB,EAAE,KAAmB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MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,sBAAsB,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAAiB,EACjB,KAAmB,EACnB,OAAoB;IAEpB,MAAM,CAAC,YAAY,CACjB,SAAS,EACT;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EACT,+EAA+E;YAC/E,yFAAyF;YACzF,mEAAmE;QACrE,WAAW,EAAE,iBAAiB;KAC/B,EACD,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5D,iBAAiB,EAAE;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;gBAC9B,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE;gBAC7B,iBAAiB,EAAE,MAAM,CAAC,eAAe;gBACzC,YAAY,EAAE,MAAM,CAAC,WAAW;aACjC;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { Repositories, ReviewRecord } from '../db/index.js';
|
|
3
2
|
import { type ReviewReadyInput } from '../domain/schemas.js';
|
|
4
3
|
export interface ReviewReadyResult {
|
|
@@ -6,9 +5,9 @@ export interface ReviewReadyResult {
|
|
|
6
5
|
taskAutoCreated: boolean;
|
|
7
6
|
}
|
|
8
7
|
/**
|
|
9
|
-
* Record a review packet for a task and mark the task review-ready.
|
|
10
|
-
* handoff
|
|
8
|
+
* Record a review packet for a task and mark the task review-ready. Invoked by
|
|
9
|
+
* `handoff` when `ready_for_review` is set (review_ready is no longer a separate
|
|
10
|
+
* tool). Auto-creates a stub task if the work was never claimed.
|
|
11
11
|
*/
|
|
12
12
|
export declare function handleReviewReady(repos: Repositories, input: ReviewReadyInput): ReviewReadyResult;
|
|
13
13
|
export declare function formatReviewReadyText(result: ReviewReadyResult): string;
|
|
14
|
-
export declare function registerReviewReady(server: McpServer, repos: Repositories, onWrite?: () => void): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from '../domain/schemas.js';
|
|
2
2
|
function toProvenance(entries) {
|
|
3
3
|
return (entries ?? []).map((entry) => ({ field: entry.field, source: entry.source }));
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Record a review packet for a task and mark the task review-ready.
|
|
7
|
-
* handoff
|
|
6
|
+
* Record a review packet for a task and mark the task review-ready. Invoked by
|
|
7
|
+
* `handoff` when `ready_for_review` is set (review_ready is no longer a separate
|
|
8
|
+
* tool). Auto-creates a stub task if the work was never claimed.
|
|
8
9
|
*/
|
|
9
10
|
export function handleReviewReady(repos, input) {
|
|
10
11
|
const existing = repos.tasks.get(input.task_id);
|
|
@@ -22,6 +23,7 @@ export function handleReviewReady(repos, input) {
|
|
|
22
23
|
domains: [],
|
|
23
24
|
riskTags: [],
|
|
24
25
|
notes: null,
|
|
26
|
+
parentTaskId: null,
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
const review = repos.reviews.create({
|
|
@@ -54,24 +56,4 @@ export function formatReviewReadyText(result) {
|
|
|
54
56
|
lines.push(`Open questions: ${String(review.openQuestions.length)}`);
|
|
55
57
|
return lines.join('\n');
|
|
56
58
|
}
|
|
57
|
-
export function registerReviewReady(server, repos, onWrite) {
|
|
58
|
-
server.registerTool('review_ready', {
|
|
59
|
-
title: 'Mark review-ready',
|
|
60
|
-
description: 'Record review evidence before a PR: plan summary, tests run, diff size, guardrails ' +
|
|
61
|
-
'checked, assumptions, open questions, and provenance. Call this before opening a PR.',
|
|
62
|
-
inputSchema: reviewReadyInputShape,
|
|
63
|
-
}, (args) => {
|
|
64
|
-
const result = handleReviewReady(repos, args);
|
|
65
|
-
onWrite?.();
|
|
66
|
-
return {
|
|
67
|
-
content: [{ type: 'text', text: formatReviewReadyText(result) }],
|
|
68
|
-
structuredContent: {
|
|
69
|
-
task_id: result.review.taskId,
|
|
70
|
-
review_id: result.review.id,
|
|
71
|
-
open_questions: result.review.openQuestions.length,
|
|
72
|
-
task_auto_created: result.taskAutoCreated,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
59
|
//# sourceMappingURL=review-ready.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-ready.js","sourceRoot":"","sources":["../../src/tools/review-ready.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"review-ready.js","sourceRoot":"","sources":["../../src/tools/review-ready.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,MAAM,sBAAsB,CAAC;AAO7D,SAAS,YAAY,CAAC,OAAuC;IAC3D,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB,EAAE,KAAuB;IAC5E,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CA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AC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAyB;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,mBAAmB,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,cAAc,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3D,KAAK,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,KAAK,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Repositories, TaskUpdateRecord } from '../db/index.js';
|
|
3
|
+
import { type UpdateTaskInput } from '../domain/schemas.js';
|
|
4
|
+
export interface UpdateTaskResult {
|
|
5
|
+
update: TaskUpdateRecord;
|
|
6
|
+
}
|
|
7
|
+
/** Append one durable, task-scoped memory entry for other agents and sessions. */
|
|
8
|
+
export declare function handleUpdateTask(repos: Repositories, input: UpdateTaskInput): UpdateTaskResult;
|
|
9
|
+
export declare function formatUpdateTaskText(result: UpdateTaskResult): string;
|
|
10
|
+
export declare function registerUpdateTask(server: McpServer, repos: Repositories, onWrite?: () => void): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { updateTaskInputShape } from '../domain/schemas.js';
|
|
2
|
+
/** Append one durable, task-scoped memory entry for other agents and sessions. */
|
|
3
|
+
export function handleUpdateTask(repos, input) {
|
|
4
|
+
const task = repos.tasks.get(input.task_id);
|
|
5
|
+
if (task === undefined) {
|
|
6
|
+
throw new Error(`Task ${input.task_id} is not claimed. Call claim_work first.`);
|
|
7
|
+
}
|
|
8
|
+
const update = repos.taskUpdates.create({
|
|
9
|
+
taskId: input.task_id,
|
|
10
|
+
kind: input.kind,
|
|
11
|
+
content: input.content,
|
|
12
|
+
agent: input.agent ?? task.agent,
|
|
13
|
+
});
|
|
14
|
+
repos.events.record({
|
|
15
|
+
taskId: input.task_id,
|
|
16
|
+
tool: 'update_task',
|
|
17
|
+
status: 'success',
|
|
18
|
+
detail: input.kind,
|
|
19
|
+
});
|
|
20
|
+
return { update };
|
|
21
|
+
}
|
|
22
|
+
export function formatUpdateTaskText(result) {
|
|
23
|
+
const author = result.update.agent === null ? '' : ` by ${result.update.agent}`;
|
|
24
|
+
return `Recorded ${result.update.kind} for ${result.update.taskId}${author}: ${result.update.content}`;
|
|
25
|
+
}
|
|
26
|
+
export function registerUpdateTask(server, repos, onWrite) {
|
|
27
|
+
server.registerTool('update_task', {
|
|
28
|
+
title: 'Update task',
|
|
29
|
+
description: 'Append durable task-scoped context such as an intent, decision, assumption, question, ' +
|
|
30
|
+
'answer, blocker, finding, or progress update. The task must be claimed first.',
|
|
31
|
+
inputSchema: updateTaskInputShape,
|
|
32
|
+
}, (args) => {
|
|
33
|
+
const result = handleUpdateTask(repos, args);
|
|
34
|
+
onWrite?.();
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: formatUpdateTaskText(result) }],
|
|
37
|
+
structuredContent: {
|
|
38
|
+
update_id: result.update.id,
|
|
39
|
+
task_id: result.update.taskId,
|
|
40
|
+
kind: result.update.kind,
|
|
41
|
+
content: result.update.content,
|
|
42
|
+
agent: result.update.agent,
|
|
43
|
+
created_at: result.update.createdAt,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=update-task.js.map
|