loopctl-mcp-server 3.11.2 → 3.13.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 +1 -0
- package/index.js +48 -12
- package/lib/handoff.js +20 -14
- package/lib/project-update.js +50 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -207,6 +207,7 @@ tool parameter.
|
|
|
207
207
|
| `create_project` | Create a new **work** project (epics/stories/custody). Requires orchestrator+ **and** a `human_anchored` tenant; an agent-rooted tenant gets `403 custody_tier_required` and should use `create_kb_scope`. |
|
|
208
208
|
| `delete_project` | **Needs a user-role key:** `LOOPCTL_USER_KEY` verbatim when set, else the default key (orchestrator role is 403 `insufficient_role`). Archives the project (status `archived`); no rows are removed and its slug stays taken. |
|
|
209
209
|
| `restore_project` | Restore an archived `kind: work` project, the reverse of `delete_project`; audited as `unarchived`. Orchestrator role or higher on a human-anchored tenant. Rejected (422) at the tenant's `max_projects` cap and for a kb scope (use `restore_kb_scope`). The only way to change a project's status back: PATCH refuses `status` with 422. |
|
|
210
|
+
| `update_project` | PATCH a project's `name`, `repo_url`, `description`, `tech_stack`, `mission` or `metadata`; a field left out is left alone, and a call naming none is refused locally. Slug and status are never set here. Orchestrator role or higher on a human-anchored tenant, sent with `LOOPCTL_ORCH_KEY` verbatim (else `LOOPCTL_USER_KEY`). A `repo_url` must be on no other active project, or `resolve_project` 409s `ambiguous_resolution` for that repo. |
|
|
210
211
|
| `get_progress` | Get progress summary for a project, including story counts by status. Pass `include_cost=true` for cost data. |
|
|
211
212
|
| `import_stories` | Import stories into a project from a structured payload (Epic 12 import format). Pass `merge: true` to add stories to epics that already exist (otherwise duplicates return 409). For large payloads, use `payload_path` to read JSON from disk instead of passing it inline. With `merge: true`, `report_orphans: true` adds `stories_orphaned` (the project's stories the payload does not mention; nothing is detached) — a signal only on a FULL round-trip of an export; without it the key is absent (#880). |
|
|
212
213
|
|
package/index.js
CHANGED
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
githubCredential as githubCredentialRequest,
|
|
96
96
|
setGithubCredential as setGithubCredentialRequest,
|
|
97
97
|
} from "./lib/github-credential.js";
|
|
98
|
+
import { updateProject as updateProjectRequest } from "./lib/project-update.js";
|
|
98
99
|
import {
|
|
99
100
|
createEpic as createEpicRequest,
|
|
100
101
|
deleteEpic as deleteEpicRequest,
|
|
@@ -977,6 +978,10 @@ async function restoreProject({ project_id }) {
|
|
|
977
978
|
return toContent(result);
|
|
978
979
|
}
|
|
979
980
|
|
|
981
|
+
async function updateProject(args) {
|
|
982
|
+
return toContent(await updateProjectRequest(args, { apiCall: orchestratorPinnedApiCall }));
|
|
983
|
+
}
|
|
984
|
+
|
|
980
985
|
async function getProgress({ project_id, include_cost }) {
|
|
981
986
|
const params = new URLSearchParams();
|
|
982
987
|
if (include_cost) params.set("include_cost", "true");
|
|
@@ -3836,8 +3841,12 @@ const TOOLS = [
|
|
|
3836
3841
|
inputSchema: {
|
|
3837
3842
|
type: "object",
|
|
3838
3843
|
properties: {
|
|
3839
|
-
name: { type: "string", description: "Project name." },
|
|
3840
|
-
slug: {
|
|
3844
|
+
name: { type: "string", description: "Project name: the same string as slug." },
|
|
3845
|
+
slug: {
|
|
3846
|
+
type: "string",
|
|
3847
|
+
description:
|
|
3848
|
+
"The repo basename, lowercased, underscores kept (lowercase alphanumerics, hyphens, underscores; 2-63 chars).",
|
|
3849
|
+
},
|
|
3841
3850
|
repo_url: { type: "string", description: "GitHub repo URL." },
|
|
3842
3851
|
description: { type: "string", description: "Project description." },
|
|
3843
3852
|
tech_stack: { type: "string", description: "Tech stack summary." },
|
|
@@ -3857,8 +3866,15 @@ const TOOLS = [
|
|
|
3857
3866
|
inputSchema: {
|
|
3858
3867
|
type: "object",
|
|
3859
3868
|
properties: {
|
|
3860
|
-
name: {
|
|
3861
|
-
|
|
3869
|
+
name: {
|
|
3870
|
+
type: "string",
|
|
3871
|
+
description: "Scope name: the same string as slug (a different one is refused 422).",
|
|
3872
|
+
},
|
|
3873
|
+
slug: {
|
|
3874
|
+
type: "string",
|
|
3875
|
+
description:
|
|
3876
|
+
"The repo basename, lowercased, underscores kept (lowercase alphanumerics, hyphens, underscores; 2-63 chars).",
|
|
3877
|
+
},
|
|
3862
3878
|
repo_url: {
|
|
3863
3879
|
type: "string",
|
|
3864
3880
|
description: "Repo URL, so resolve_project can map a repo to this scope.",
|
|
@@ -3913,12 +3929,12 @@ const TOOLS = [
|
|
|
3913
3929
|
repo_url: {
|
|
3914
3930
|
type: "string",
|
|
3915
3931
|
description:
|
|
3916
|
-
"The repo's git remote (git@github.com:owner/repo.git, https://github.com/owner/repo, or bare owner/repo). The usual way to name the channel; also used to derive the kb-scope slug
|
|
3932
|
+
"The repo's git remote (git@github.com:owner/repo.git, https://github.com/owner/repo, or bare owner/repo). The usual way to name the channel; also used to derive the kb-scope slug if one must be created: the repo basename lowercased, underscores kept, and the name is the same string.",
|
|
3917
3933
|
},
|
|
3918
3934
|
slug: {
|
|
3919
3935
|
type: "string",
|
|
3920
3936
|
description:
|
|
3921
|
-
"Explicit project slug, if you know it or want to override the slug derived from repo_url (lowercase alphanumerics and
|
|
3937
|
+
"Explicit project slug, if you know it or want to override the slug derived from repo_url (lowercase alphanumerics, hyphens and underscores, 2-63 chars).",
|
|
3922
3938
|
},
|
|
3923
3939
|
project_id: {
|
|
3924
3940
|
type: "string",
|
|
@@ -3954,11 +3970,6 @@ const TOOLS = [
|
|
|
3954
3970
|
description:
|
|
3955
3971
|
"Default true: create a kind: kb scope when the repo has no project yet (this is what makes a handoff possible on a fresh repo; it consumes one max_projects slot, and the response reports channel.created). Pass false to fail with an actionable error instead of creating anything.",
|
|
3956
3972
|
},
|
|
3957
|
-
name: {
|
|
3958
|
-
type: "string",
|
|
3959
|
-
description:
|
|
3960
|
-
"Scope name, used ONLY if a channel must be created. Defaults to the repo basename.",
|
|
3961
|
-
},
|
|
3962
3973
|
description: {
|
|
3963
3974
|
type: "string",
|
|
3964
3975
|
description: "Scope description, used ONLY if a channel must be created.",
|
|
@@ -4292,7 +4303,7 @@ const TOOLS = [
|
|
|
4292
4303
|
{
|
|
4293
4304
|
name: "delete_project",
|
|
4294
4305
|
description:
|
|
4295
|
-
"ARCHIVE a project (DELETE /api/v1/projects/:id sets status to archived; it removes no rows). Its epics, stories and audit entries stay, and an already-archived project is a no-op. The SLUG stays taken: slugs are unique per tenant across archived projects too, resolve_project by that slug still returns the archived project, create_project with it is refused 422, and
|
|
4306
|
+
"ARCHIVE a project (DELETE /api/v1/projects/:id sets status to archived; it removes no rows). Its epics, stories and audit entries stay, and an already-archived project is a no-op. The SLUG stays taken: slugs are unique per tenant across archived projects too, resolve_project by that slug still returns the archived project, create_project with it is refused 422, and archiving never releases it, so a new project needs a different one. The one way a slug is freed: update_project renaming a kb scope (never a work project) releases the kb scope's old slug. The way back: restore_project for a work project, restore_kb_scope for a kb scope. Sent with LOOPCTL_USER_KEY verbatim when it is set (a global LOOPCTL_API_KEY does not displace it), else with the default key. Refusals: 403 insufficient_role below user role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant.",
|
|
4296
4307
|
inputSchema: {
|
|
4297
4308
|
type: "object",
|
|
4298
4309
|
properties: {
|
|
@@ -4319,6 +4330,29 @@ const TOOLS = [
|
|
|
4319
4330
|
required: ["project_id"],
|
|
4320
4331
|
},
|
|
4321
4332
|
},
|
|
4333
|
+
{
|
|
4334
|
+
name: "update_project",
|
|
4335
|
+
description:
|
|
4336
|
+
"UPDATE a project's fields (PATCH /api/v1/projects/:id): name, slug, repo_url, description, tech_stack, mission, metadata. Send only what changes; a field left out is left alone, and a call naming none is refused locally. Only a kind: kb scope's slug can change: its name follows the slug, a kb name different from its slug is 422, and a slug another project holds (archived included) is 422; a work project's slug change is 422. Status is not settable here (archive with delete_project, restore with restore_project). Setting repo_url makes resolve_project({repo_url}) and SessionStart find the project, so it must be the ONLY active project carrying that URL: a second one makes every lookup for the repo 409 ambiguous_resolution fleet-wide. Sent with LOOPCTL_ORCH_KEY verbatim, else LOOPCTL_USER_KEY, else the default key. Refusals: 403 insufficient_role below orchestrator role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant, 422 for an invalid field.",
|
|
4337
|
+
inputSchema: {
|
|
4338
|
+
type: "object",
|
|
4339
|
+
properties: {
|
|
4340
|
+
project_id: { type: "string", description: "The project's UUID." },
|
|
4341
|
+
name: { type: "string", description: "New name. For a kb scope it must equal the slug." },
|
|
4342
|
+
slug: {
|
|
4343
|
+
type: "string",
|
|
4344
|
+
description:
|
|
4345
|
+
"New slug, kb scopes only (lowercase alphanumerics, hyphens, underscores; 2-63 chars). For a repo channel, the repo basename verbatim, e.g. home_care_billing.",
|
|
4346
|
+
},
|
|
4347
|
+
repo_url: { type: "string", description: "Git remote URL, e.g. https://github.com/owner/repo." },
|
|
4348
|
+
description: { type: "string", description: "New description." },
|
|
4349
|
+
tech_stack: { type: "string", description: "New tech stack summary." },
|
|
4350
|
+
mission: { type: "string", description: "New mission; an empty string clears it." },
|
|
4351
|
+
metadata: { type: "object", description: "Replaces the metadata map whole." },
|
|
4352
|
+
},
|
|
4353
|
+
required: ["project_id"],
|
|
4354
|
+
},
|
|
4355
|
+
},
|
|
4322
4356
|
{
|
|
4323
4357
|
name: "get_progress",
|
|
4324
4358
|
description: "Get progress summary for a project, including story counts by status. Pass include_cost=true to include cost data when available.",
|
|
@@ -10259,6 +10293,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
10259
10293
|
case "delete_project":
|
|
10260
10294
|
return await deleteProject(args);
|
|
10261
10295
|
|
|
10296
|
+
case "update_project":
|
|
10297
|
+
return await updateProject(args);
|
|
10262
10298
|
case "restore_project":
|
|
10263
10299
|
return await restoreProject(args);
|
|
10264
10300
|
|
package/lib/handoff.js
CHANGED
|
@@ -41,7 +41,7 @@ export const HANDOFF_KEY_PREFIX = "handoff:";
|
|
|
41
41
|
export const KEY_MAX_BYTES = 200;
|
|
42
42
|
|
|
43
43
|
// Mirrors Loopctl.Projects.Project's slug rules (lib/loopctl/projects/project.ex:31,137):
|
|
44
|
-
// /^[a-z0-9][a-z0-
|
|
44
|
+
// /^[a-z0-9][a-z0-9_-]*[a-z0-9]$/, 2..63 chars. A derived slug that cannot satisfy these
|
|
45
45
|
// is reported as underivable rather than sent on to fail server-side.
|
|
46
46
|
export const SLUG_MIN_LENGTH = 2;
|
|
47
47
|
export const SLUG_MAX_LENGTH = 63;
|
|
@@ -124,7 +124,7 @@ export function handoffKey(anchor) {
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* The repo basename from a git remote URL or a bare owner/repo, with original casing
|
|
127
|
-
* preserved
|
|
127
|
+
* preserved; `deriveSlug` lowercases it.
|
|
128
128
|
*
|
|
129
129
|
* Handles: git@github.com:owner/repo.git, https://github.com/owner/repo(/),
|
|
130
130
|
* ssh://git@host/owner/repo.git, bare owner/repo, and trailing query/fragment.
|
|
@@ -150,8 +150,10 @@ export function repoBasename(repoUrl) {
|
|
|
150
150
|
*
|
|
151
151
|
* DETERMINISM IS THE POINT (#528 AC4): the created scope must be re-resolvable by the
|
|
152
152
|
* same derivation on a retry, or a repeated handoff would create a second scope and burn
|
|
153
|
-
* the tenant's max_projects budget.
|
|
154
|
-
*
|
|
153
|
+
* the tenant's max_projects budget. The slug is the repo basename lowercased with `_` KEPT
|
|
154
|
+
* (#1038: repo home_care_billing -> slug home_care_billing); only other non-alphanumeric
|
|
155
|
+
* runs become `-`. The server resolves a slug on its folded form too, so a channel still
|
|
156
|
+
* stored under the old hyphenated slug is found rather than duplicated.
|
|
155
157
|
*
|
|
156
158
|
* Returns null when nothing valid can be derived — the caller then asks for an explicit
|
|
157
159
|
* slug instead of sending a doomed create.
|
|
@@ -162,13 +164,13 @@ export function deriveSlug(repoUrl) {
|
|
|
162
164
|
|
|
163
165
|
const slug = basename
|
|
164
166
|
.toLowerCase()
|
|
165
|
-
.replace(/[^a-z0-
|
|
167
|
+
.replace(/[^a-z0-9_]+/g, "-")
|
|
166
168
|
.replace(/-+/g, "-")
|
|
167
|
-
.replace(
|
|
169
|
+
.replace(/^[-_]+|[-_]+$/g, "")
|
|
168
170
|
.slice(0, SLUG_MAX_LENGTH)
|
|
169
|
-
// A mid-string
|
|
171
|
+
// A mid-string separator can land last after truncation; the server's format regex
|
|
170
172
|
// requires an alphanumeric final character.
|
|
171
|
-
.replace(
|
|
173
|
+
.replace(/[-_]+$/, "");
|
|
172
174
|
|
|
173
175
|
return slug.length >= SLUG_MIN_LENGTH ? slug : null;
|
|
174
176
|
}
|
|
@@ -207,7 +209,10 @@ function postRemediation(status, channel) {
|
|
|
207
209
|
"member of it: channel writes on a work project require an agent assigned to a " +
|
|
208
210
|
"story there. The server's 'does not exist or does not belong to your tenant' " +
|
|
209
211
|
"wording is deliberately non-specific (it must not leak an existence oracle), so " +
|
|
210
|
-
"do NOT read it as the project being missing. "
|
|
212
|
+
"do NOT read it as the project being missing. Fix it with a membership story in " +
|
|
213
|
+
"THIS project, never a second channel: create_story, then contract_story, " +
|
|
214
|
+
"claim_story, start_story and request_review, and leave it there (verify, unclaim " +
|
|
215
|
+
"or release clears the assignee). Then call handoff again. "
|
|
211
216
|
: "";
|
|
212
217
|
|
|
213
218
|
return (
|
|
@@ -245,7 +250,7 @@ function createRemediation(status) {
|
|
|
245
250
|
* Returns a channel summary, or an `apiCall`-shaped failure.
|
|
246
251
|
*/
|
|
247
252
|
async function ensureChannel(
|
|
248
|
-
{ project_id, repo_url, slug,
|
|
253
|
+
{ project_id, repo_url, slug, description, tech_stack, create_channel },
|
|
249
254
|
{ resolveProject, createKbScope },
|
|
250
255
|
) {
|
|
251
256
|
// An explicit project_id is taken at face value — the caller already resolved it, and
|
|
@@ -302,12 +307,14 @@ async function ensureChannel(
|
|
|
302
307
|
0,
|
|
303
308
|
`Could not derive a valid project slug from repo_url ${JSON.stringify(repo_url)} ` +
|
|
304
309
|
`(needs ${SLUG_MIN_LENGTH}-${SLUG_MAX_LENGTH} chars of lowercase alphanumerics and ` +
|
|
305
|
-
`hyphens). Pass an explicit slug.`,
|
|
310
|
+
`hyphens or underscores). Pass an explicit slug.`,
|
|
306
311
|
);
|
|
307
312
|
}
|
|
308
313
|
|
|
309
314
|
const created = await createKbScope({
|
|
310
|
-
|
|
315
|
+
// A channel's name IS its slug (#1038): the server refuses a kb scope whose name
|
|
316
|
+
// differs, so the tool takes no `name` at all.
|
|
317
|
+
name: createSlug,
|
|
311
318
|
slug: createSlug,
|
|
312
319
|
repo_url,
|
|
313
320
|
description,
|
|
@@ -357,7 +364,6 @@ export async function createHandoff(args = {}, deps = {}) {
|
|
|
357
364
|
project_id,
|
|
358
365
|
repo_url,
|
|
359
366
|
slug,
|
|
360
|
-
name,
|
|
361
367
|
description,
|
|
362
368
|
tech_stack,
|
|
363
369
|
to_host,
|
|
@@ -380,7 +386,7 @@ export async function createHandoff(args = {}, deps = {}) {
|
|
|
380
386
|
}
|
|
381
387
|
|
|
382
388
|
const channel = await ensureChannel(
|
|
383
|
-
{ project_id, repo_url, slug,
|
|
389
|
+
{ project_id, repo_url, slug, description, tech_stack, create_channel },
|
|
384
390
|
deps,
|
|
385
391
|
);
|
|
386
392
|
if (channel?.error === true) return channel;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `update_project`: the MCP half of `PATCH /api/v1/projects/:id` (`ProjectController.update`,
|
|
3
|
+
* loopctl #1036). Without it no session could set a work project's `repo_url`, so SessionStart,
|
|
4
|
+
* which resolves channels by `repo_url`, found no channel for that repo.
|
|
5
|
+
*
|
|
6
|
+
* WHAT THE ENDPOINT ACCEPTS: `name`, `slug`, `repo_url`, `description`, `tech_stack`,
|
|
7
|
+
* `mission`, `metadata`. It drops every nil, so a request naming none is a 200 that changes
|
|
8
|
+
* nothing: refused here. Only a kind: kb scope's `slug` can change, and its name follows it
|
|
9
|
+
* (#1038); a work project's slug change is a 422. A body carrying `status` is a 422 (archive
|
|
10
|
+
* and restore have their own routes), so it is never sent. An empty `mission` clears it.
|
|
11
|
+
*
|
|
12
|
+
* KEY: orchestrator role on a human-anchored tenant; index.js injects the orchestrator-pinned
|
|
13
|
+
* `apiCall`, as it does for the epic writes.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { uuid as uuidRefusal } from "./delivery-loop.js";
|
|
17
|
+
|
|
18
|
+
export const PROJECT_UPDATABLE = [
|
|
19
|
+
"name",
|
|
20
|
+
"slug",
|
|
21
|
+
"repo_url",
|
|
22
|
+
"description",
|
|
23
|
+
"tech_stack",
|
|
24
|
+
"mission",
|
|
25
|
+
"metadata",
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export function projectPath(projectId) {
|
|
29
|
+
return `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function updateProject(args = {}, { apiCall } = {}) {
|
|
33
|
+
const refused = uuidRefusal(args.project_id, "project_id");
|
|
34
|
+
if (refused) return refused;
|
|
35
|
+
|
|
36
|
+
const body = {};
|
|
37
|
+
for (const key of PROJECT_UPDATABLE) {
|
|
38
|
+
if (args[key] != null) body[key] = args[key];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (Object.keys(body).length === 0) {
|
|
42
|
+
return {
|
|
43
|
+
error: true,
|
|
44
|
+
status: 0,
|
|
45
|
+
body: `update_project needs at least one of ${PROJECT_UPDATABLE.join(", ")}; nothing was sent.`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return apiCall("PATCH", projectPath(args.project_id), body);
|
|
50
|
+
}
|