@concord-ai/concord-mcp 0.1.1 → 0.2.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 +10 -0
- 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/install.js +9 -1
- package/dist/cli/commands/install.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/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 +2 -0
- package/dist/db/rows.js +2 -0
- package/dist/db/rows.js.map +1 -1
- package/dist/db/schema.js +5 -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 +44 -0
- package/dist/domain/schemas.js +26 -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 +11 -4
- package/dist/install/instructions.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +10 -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-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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-hooks.js","sourceRoot":"","sources":["../../src/install/claude-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8DAA8D;AAC9D,MAAM,OAAO,GAAG,sBAAsB,CAAC;AACvC,qEAAqE;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAErE,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,KAAK,EAAE,CAAC;SACL,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;SACvD,WAAW,EAAE;SACb,QAAQ,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Q,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnF,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,aAAa,CAAC,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** The canonical instruction block written into each client's config. */
|
|
2
|
-
export declare const CONCORD_INSTRUCTIONS = "## Concord \u2014 shared work-state for coding agents\n\nThis project uses Concord MCP. Use its tools so your work is visible before PRs:\n\n- **Before editing code**, call `claim_work` with the task id, title, and the\n files/modules you expect to touch. Concord warns about overlaps with other\n active work.\n- **Before finishing or when blocked**, call `handoff` with what changed, tests\n run, assumptions, decisions, and guardrails you checked
|
|
2
|
+
export declare const CONCORD_INSTRUCTIONS = "## Concord \u2014 shared work-state for coding agents\n\nThis project uses Concord MCP. Use its tools so your work is visible before PRs:\n\n- **Keep each claim small.** Break work into the smallest independently\n handoff-able unit and `claim_work` each piece separately, rather than\n claiming one broad task. Concord flags claims that look too broad.\n- **Before editing code**, call `claim_work` with the task id, title, and the\n files/modules you expect to touch. Concord warns about overlaps with other\n active work.\n- **Before finishing or when blocked**, call `handoff` with what changed, tests\n run, assumptions, decisions, and guardrails you checked. **Before a PR**, set\n `ready_for_review` (with open questions and provenance) to also produce a\n review packet.\n\nConcord regenerates human-readable `HANDOFF.md` and `REVIEW_PACKET.md` in\n`.concord/` so humans can review your work.\n\nEnforcement note: on clients with hooks/command registration this can be\nenforced; elsewhere it is instruction-based and may be skipped. `concord doctor`\nshows per-task adoption either way. For edit-time enforcement, wire a PreToolUse\n(or git pre-commit) hook to `concord check <files> --task <your-task-id>`; it\nexits non-zero when your edits collide with another agent's active claim. On\nClaude Code, `concord install --claude-hooks` installs this automatically \u2014 set\n`CONCORD_TASK=<your task id>` so the hook excludes your own claim.";
|
|
3
3
|
/** MDC frontmatter used when creating a fresh Cursor rules file. */
|
|
4
4
|
export declare const CURSOR_MDC_HEADER = "---\ndescription: Concord shared work-state tools for coding agents\nalwaysApply: true\n---\n";
|
|
@@ -3,20 +3,27 @@ export const CONCORD_INSTRUCTIONS = `## Concord — shared work-state for coding
|
|
|
3
3
|
|
|
4
4
|
This project uses Concord MCP. Use its tools so your work is visible before PRs:
|
|
5
5
|
|
|
6
|
+
- **Keep each claim small.** Break work into the smallest independently
|
|
7
|
+
handoff-able unit and \`claim_work\` each piece separately, rather than
|
|
8
|
+
claiming one broad task. Concord flags claims that look too broad.
|
|
6
9
|
- **Before editing code**, call \`claim_work\` with the task id, title, and the
|
|
7
10
|
files/modules you expect to touch. Concord warns about overlaps with other
|
|
8
11
|
active work.
|
|
9
12
|
- **Before finishing or when blocked**, call \`handoff\` with what changed, tests
|
|
10
|
-
run, assumptions, decisions, and guardrails you checked.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
run, assumptions, decisions, and guardrails you checked. **Before a PR**, set
|
|
14
|
+
\`ready_for_review\` (with open questions and provenance) to also produce a
|
|
15
|
+
review packet.
|
|
13
16
|
|
|
14
17
|
Concord regenerates human-readable \`HANDOFF.md\` and \`REVIEW_PACKET.md\` in
|
|
15
18
|
\`.concord/\` so humans can review your work.
|
|
16
19
|
|
|
17
20
|
Enforcement note: on clients with hooks/command registration this can be
|
|
18
21
|
enforced; elsewhere it is instruction-based and may be skipped. \`concord doctor\`
|
|
19
|
-
shows per-task adoption either way
|
|
22
|
+
shows per-task adoption either way. For edit-time enforcement, wire a PreToolUse
|
|
23
|
+
(or git pre-commit) hook to \`concord check <files> --task <your-task-id>\`; it
|
|
24
|
+
exits non-zero when your edits collide with another agent's active claim. On
|
|
25
|
+
Claude Code, \`concord install --claude-hooks\` installs this automatically — set
|
|
26
|
+
\`CONCORD_TASK=<your task id>\` so the hook excludes your own claim.`;
|
|
20
27
|
/** MDC frontmatter used when creating a fresh Cursor rules file. */
|
|
21
28
|
export const CURSOR_MDC_HEADER = `---
|
|
22
29
|
description: Concord shared work-state tools for coding agents
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/install/instructions.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/install/instructions.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;qEAwBiC,CAAC;AAEtE,oEAAoE;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;CAIhC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { Repositories } from './db/index.js';
|
|
3
3
|
/** Concord's advertised MCP server version. */
|
|
4
|
-
export declare const SERVER_VERSION = "0.
|
|
4
|
+
export declare const SERVER_VERSION = "0.2.0";
|
|
5
5
|
export interface ServerOptions {
|
|
6
6
|
/** Called after any tool writes to the database (used to regenerate artifacts). */
|
|
7
7
|
onToolWrite?: () => void;
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { registerClaimWork } from './tools/claim-work.js';
|
|
3
|
+
import { registerWorkState } from './tools/get-work-state.js';
|
|
3
4
|
import { registerHandoff } from './tools/handoff.js';
|
|
4
|
-
import { registerReviewReady } from './tools/review-ready.js';
|
|
5
5
|
import { VERSION } from './version.js';
|
|
6
6
|
/** Concord's advertised MCP server version. */
|
|
7
7
|
export const SERVER_VERSION = VERSION;
|
|
@@ -11,9 +11,15 @@ export const SERVER_VERSION = VERSION;
|
|
|
11
11
|
*/
|
|
12
12
|
export function createServer(repos, options = {}) {
|
|
13
13
|
const server = new McpServer({ name: 'concord-mcp', version: SERVER_VERSION });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// Register the read surface first so we get the change-notifier, then run it
|
|
15
|
+
// (plus the caller's hook) after every write.
|
|
16
|
+
const notifyWorkStateChanged = registerWorkState(server, repos);
|
|
17
|
+
const onWrite = () => {
|
|
18
|
+
options.onToolWrite?.();
|
|
19
|
+
notifyWorkStateChanged();
|
|
20
|
+
};
|
|
21
|
+
registerClaimWork(server, repos, onWrite);
|
|
22
|
+
registerHandoff(server, repos, onWrite);
|
|
17
23
|
return server;
|
|
18
24
|
}
|
|
19
25
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAOtC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAmB,EAAE,UAAyB,EAAE;IAC3E,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAC/E,6EAA6E;IAC7E,8CAA8C;IAC9C,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QACxB,sBAAsB,EAAE,CAAC;IAC3B,CAAC,CAAC;IACF,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1C,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -6,11 +6,48 @@ export interface ClaimWorkResult {
|
|
|
6
6
|
task: TaskRecord;
|
|
7
7
|
alreadyClaimed: boolean;
|
|
8
8
|
overlaps: OverlapWarning[];
|
|
9
|
+
/**
|
|
10
|
+
* How many other active tasks the overlap check compared against. Overlap
|
|
11
|
+
* detection is point-in-time: an empty `overlaps` only means nothing conflicts
|
|
12
|
+
* *right now*. A later overlapping claim will not appear here — it surfaces on
|
|
13
|
+
* read (e.g. `concord status`), which recomputes overlaps live.
|
|
14
|
+
*/
|
|
15
|
+
checkedAgainst: number;
|
|
16
|
+
/**
|
|
17
|
+
* Advisory reasons the claim looks too broad (empty when appropriately
|
|
18
|
+
* scoped). A non-empty list is a suggestion to split the work into smaller,
|
|
19
|
+
* independently-handoffable tasks — never a rejection.
|
|
20
|
+
*/
|
|
21
|
+
breadthReasons: string[];
|
|
22
|
+
/**
|
|
23
|
+
* On a re-claim, the scope entries this call added to the existing claim
|
|
24
|
+
* (e.g. `module: api-client`, `file: lib/todo-api.ts`). Empty on a first
|
|
25
|
+
* claim or when nothing new was declared.
|
|
26
|
+
*/
|
|
27
|
+
scopeAdded: string[];
|
|
9
28
|
}
|
|
10
29
|
/**
|
|
11
|
-
* Record that an agent is working on a task and flag
|
|
12
|
-
*
|
|
30
|
+
* Record that an agent is working on a task and flag overlaps with other active
|
|
31
|
+
* tasks. Re-claiming an existing task is idempotent for its identity (title,
|
|
32
|
+
* owner, agent) but *extends* its declared scope: the new files/modules/domains/
|
|
33
|
+
* risk tags are merged in and persisted, overlaps are recomputed against the
|
|
34
|
+
* merged scope, and the additions are reported back.
|
|
13
35
|
*/
|
|
14
36
|
export declare function handleClaimWork(repos: Repositories, input: ClaimWorkInput): ClaimWorkResult;
|
|
15
37
|
export declare function formatClaimWorkText(result: ClaimWorkResult): string;
|
|
38
|
+
/** The `claim_work` MCP structured output. All keys are snake_case, including
|
|
39
|
+
* overlap entries, so the payload is internally consistent. */
|
|
40
|
+
export declare function toClaimWorkStructured(result: ClaimWorkResult): {
|
|
41
|
+
task_id: string;
|
|
42
|
+
parent_task_id: string | null;
|
|
43
|
+
already_claimed: boolean;
|
|
44
|
+
overlaps: {
|
|
45
|
+
task_id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
reasons: string[];
|
|
48
|
+
}[];
|
|
49
|
+
checked_against: number;
|
|
50
|
+
breadth_reasons: string[];
|
|
51
|
+
scope_added: string[];
|
|
52
|
+
};
|
|
16
53
|
export declare function registerClaimWork(server: McpServer, repos: Repositories, onWrite?: () => void): void;
|
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;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F,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,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,MAAM,CAAC,MAAM,cAAc,GAAG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AAE,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;IACpE,MAAM,QAAQ,GAAG,KA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;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
|