planko-mcp-server 0.5.0 → 0.5.2
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/index.js +91 -38
- package/package.json +1 -1
- package/src/projectLock.js +43 -0
package/index.js
CHANGED
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
sanitizeFilters,
|
|
27
27
|
ownerName,
|
|
28
28
|
assertProjectAllowed,
|
|
29
|
+
stripHallucinatedListFilters,
|
|
30
|
+
matchesAssignee,
|
|
31
|
+
hasOwnerInfo,
|
|
29
32
|
} from './src/projectLock.js';
|
|
30
33
|
import {
|
|
31
34
|
blockNoteToMarkdown,
|
|
@@ -922,15 +925,20 @@ function formatTags(tags) {
|
|
|
922
925
|
|
|
923
926
|
/** Build the API filter params from tool params, resolving projectName. */
|
|
924
927
|
async function buildListParams(type, params) {
|
|
925
|
-
|
|
928
|
+
// assigneeName is a client-side member filter (see applyAssigneeName); never
|
|
929
|
+
// forward it to the backend, which doesn't know that key.
|
|
930
|
+
const { projectName, assigneeName, ...rest } = params;
|
|
926
931
|
// Sanitize scalar filters (drops blank/placeholder values, incl. a blank
|
|
927
|
-
// assigneeId => "all members").
|
|
932
|
+
// assigneeId => "all members").
|
|
928
933
|
const out = { type, ...sanitizeFilters(rest) };
|
|
929
934
|
if (PROJECT_LOCK) {
|
|
935
|
+
// Drop the id/priority narrowers this class of agent fabricates with
|
|
936
|
+
// non-blank garbage (parentId=projectId, assigneeId from a chat id, guessed
|
|
937
|
+
// priority) that would silently zero the "list the whole team" result.
|
|
938
|
+
stripHallucinatedListFilters(out);
|
|
930
939
|
// Hard override: force the project regardless of caller input. Do NOT
|
|
931
940
|
// resolve projectName here — the override wins unconditionally, so an
|
|
932
|
-
// invalid projectName must not be able to fail an otherwise-locked list
|
|
933
|
-
// (keeps list consistent with create, which also ignores projectName).
|
|
941
|
+
// invalid projectName must not be able to fail an otherwise-locked list.
|
|
934
942
|
out.projectId = lockProjectId(PROJECT_LOCK, out.projectId);
|
|
935
943
|
} else if (!isBlankValue(projectName)) {
|
|
936
944
|
// Unlocked (default) path: unchanged behavior.
|
|
@@ -952,7 +960,7 @@ function summarizeItem(item, index) {
|
|
|
952
960
|
const owner = ownerName(item.userId);
|
|
953
961
|
if (owner) parts.push(`owner: ${owner}`);
|
|
954
962
|
return (
|
|
955
|
-
`${index}. ${item.name || '(untitled)'} [id: ${item._id}]\n` +
|
|
963
|
+
`${index}. ${item.name || '(untitled)'} [id: ${item._id ?? item.id}]\n` +
|
|
956
964
|
` ${parts.join(' | ')}`
|
|
957
965
|
);
|
|
958
966
|
}
|
|
@@ -977,7 +985,7 @@ function renderList(result, kindLabelPlural) {
|
|
|
977
985
|
function renderItem(item, kindLabel) {
|
|
978
986
|
const lines = [];
|
|
979
987
|
lines.push(`${item.name || '(untitled)'}`);
|
|
980
|
-
lines.push(`id: ${item._id}`);
|
|
988
|
+
lines.push(`id: ${item._id ?? item.id}`);
|
|
981
989
|
lines.push(`type: ${item.type === 2 ? 'note' : 'task'} (${kindLabel})`);
|
|
982
990
|
lines.push(`status: ${statusLabel(item.status)}`);
|
|
983
991
|
if (item.priority != null) lines.push(`priority: ${item.priority}`);
|
|
@@ -1032,35 +1040,88 @@ const listLimit = z
|
|
|
1032
1040
|
.optional()
|
|
1033
1041
|
.describe('Max items to return (default 50, max 200)');
|
|
1034
1042
|
const listPage = z.number().int().min(1).optional().describe('Page number (default 1)');
|
|
1043
|
+
const listPriority = z
|
|
1044
|
+
.union([z.literal(1), z.literal(2), z.literal(3)])
|
|
1045
|
+
.optional()
|
|
1046
|
+
.describe('Filter by priority: 1, 2, or 3');
|
|
1047
|
+
const listParentId = objectId.optional().describe('List subtasks of this parent task id');
|
|
1048
|
+
const listAssigneeName = z
|
|
1049
|
+
.string()
|
|
1050
|
+
.optional()
|
|
1051
|
+
.describe(
|
|
1052
|
+
'Narrow to ONE team member by their NAME or email (case-insensitive). ' +
|
|
1053
|
+
'Omit to list the WHOLE team (all members). Only set this when the user ' +
|
|
1054
|
+
'explicitly names a person; never guess.'
|
|
1055
|
+
);
|
|
1035
1056
|
|
|
1036
|
-
//
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
.optional()
|
|
1046
|
-
.describe('Filter by priority: 1, 2, or 3'),
|
|
1047
|
-
projectName: listProjectName,
|
|
1048
|
-
projectId: listProjectId,
|
|
1049
|
-
assigneeId: listAssigneeId,
|
|
1050
|
-
parentId: objectId.optional().describe('List subtasks of this parent task id'),
|
|
1057
|
+
// Build the list-filter schema. Under PROJECT_LOCK the project is forced and the
|
|
1058
|
+
// caller is a bespoke, project-scoped agent whose model fabricates id/priority
|
|
1059
|
+
// narrowers (parentId/assigneeId/priority) that silently zero the result — so
|
|
1060
|
+
// those fields are NOT offered; member narrowing is by NAME (assigneeName)
|
|
1061
|
+
// instead. Unlocked (default, e.g. clawis) keeps the full, unchanged surface.
|
|
1062
|
+
function listSchema(kind /* 'task' | 'note' */) {
|
|
1063
|
+
const base = { showCompleted: listShowCompleted };
|
|
1064
|
+
if (kind === 'task') base.status = listStatus;
|
|
1065
|
+
const tail = {
|
|
1051
1066
|
tags: listTags,
|
|
1052
1067
|
search: listSearch,
|
|
1053
|
-
|
|
1054
|
-
|
|
1068
|
+
...(kind === 'task'
|
|
1069
|
+
? {
|
|
1070
|
+
dueDateFrom: datePlain.optional().describe('Inclusive lower bound on due date (YYYY-MM-DD)'),
|
|
1071
|
+
dueDateTo: datePlain.optional().describe('Inclusive upper bound on due date (YYYY-MM-DD)'),
|
|
1072
|
+
}
|
|
1073
|
+
: {}),
|
|
1055
1074
|
sortBy: listSortBy,
|
|
1056
1075
|
limit: listLimit,
|
|
1057
1076
|
page: listPage,
|
|
1058
|
-
}
|
|
1077
|
+
};
|
|
1078
|
+
if (PROJECT_LOCK) {
|
|
1079
|
+
return { ...base, assigneeName: listAssigneeName, ...tail };
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
...base,
|
|
1083
|
+
priority: listPriority,
|
|
1084
|
+
projectName: listProjectName,
|
|
1085
|
+
projectId: listProjectId,
|
|
1086
|
+
assigneeId: listAssigneeId,
|
|
1087
|
+
...(kind === 'task' ? { parentId: listParentId } : {}),
|
|
1088
|
+
...tail,
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Client-side member narrowing by NAME (used under PROJECT_LOCK, where the
|
|
1094
|
+
* agent narrows by a person's name instead of a fabricated user id). Returns
|
|
1095
|
+
* { result, note }. When assigneeName is blank, the result is unchanged. When
|
|
1096
|
+
* items lack populated owner info (backend owner-populate not deployed yet),
|
|
1097
|
+
* the filter can't be applied — the full list is returned with an explanatory
|
|
1098
|
+
* note rather than a misleading empty result.
|
|
1099
|
+
*/
|
|
1100
|
+
function applyAssigneeName(result, assigneeName) {
|
|
1101
|
+
if (isBlankValue(assigneeName)) return { result, note: null };
|
|
1102
|
+
const tasks = Array.isArray(result?.tasks) ? result.tasks : [];
|
|
1103
|
+
if (!hasOwnerInfo(tasks)) {
|
|
1104
|
+
return {
|
|
1105
|
+
result,
|
|
1106
|
+
note: `Could not narrow to "${assigneeName}" — owner info is not available yet; showing all members.`,
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
const filtered = tasks.filter((t) => matchesAssignee(t.userId, assigneeName));
|
|
1110
|
+
return { result: { ...result, tasks: filtered, total: filtered.length }, note: null };
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// ---- planko_list_tasks ----
|
|
1114
|
+
server.tool(
|
|
1115
|
+
'planko_list_tasks',
|
|
1116
|
+
'List Planko tasks (type=1) via your API key, no folder setup required. All filters are optional; omit any the user did not explicitly ask for. Recurring tasks appear as separate dated occurrences. Returns a concise summary, not raw JSON.',
|
|
1117
|
+
listSchema('task'),
|
|
1059
1118
|
async (params) => {
|
|
1060
1119
|
try {
|
|
1061
1120
|
const apiParams = await buildListParams(1, params);
|
|
1062
1121
|
const result = await api.listTasks(apiParams);
|
|
1063
|
-
|
|
1122
|
+
const { result: filtered, note } = applyAssigneeName(result, params.assigneeName);
|
|
1123
|
+
const out = renderList(filtered, 'tasks');
|
|
1124
|
+
return toolOk(note ? `${out}\n\nNote: ${note}` : out);
|
|
1064
1125
|
} catch (err) {
|
|
1065
1126
|
return toolError(`List tasks failed: ${err.message}`);
|
|
1066
1127
|
}
|
|
@@ -1070,23 +1131,15 @@ server.tool(
|
|
|
1070
1131
|
// ---- planko_list_notes ----
|
|
1071
1132
|
server.tool(
|
|
1072
1133
|
'planko_list_notes',
|
|
1073
|
-
'List
|
|
1074
|
-
|
|
1075
|
-
showCompleted: listShowCompleted,
|
|
1076
|
-
projectName: listProjectName,
|
|
1077
|
-
projectId: listProjectId,
|
|
1078
|
-
assigneeId: listAssigneeId,
|
|
1079
|
-
tags: listTags,
|
|
1080
|
-
search: listSearch,
|
|
1081
|
-
sortBy: listSortBy,
|
|
1082
|
-
limit: listLimit,
|
|
1083
|
-
page: listPage,
|
|
1084
|
-
},
|
|
1134
|
+
'List Planko notes (type=2) via your API key, no folder setup required. All filters are optional; omit any the user did not explicitly ask for. Deleted and recurring-copy notes are excluded. Returns a concise summary, not raw JSON.',
|
|
1135
|
+
listSchema('note'),
|
|
1085
1136
|
async (params) => {
|
|
1086
1137
|
try {
|
|
1087
1138
|
const apiParams = await buildListParams(2, params);
|
|
1088
1139
|
const result = await api.listTasks(apiParams);
|
|
1089
|
-
|
|
1140
|
+
const { result: filtered, note } = applyAssigneeName(result, params.assigneeName);
|
|
1141
|
+
const out = renderList(filtered, 'notes');
|
|
1142
|
+
return toolOk(note ? `${out}\n\nNote: ${note}` : out);
|
|
1090
1143
|
} catch (err) {
|
|
1091
1144
|
return toolError(`List notes failed: ${err.message}`);
|
|
1092
1145
|
}
|
package/package.json
CHANGED
package/src/projectLock.js
CHANGED
|
@@ -79,3 +79,46 @@ export function assertProjectAllowed(lock, task) {
|
|
|
79
79
|
throw new Error('This agent is restricted to the "planko" project.');
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Under a project lock, LLM tool-callers (esp. GPT-class) reliably fabricate
|
|
85
|
+
* these narrowing filters with plausible-but-wrong NON-blank values that
|
|
86
|
+
* isBlankValue cannot catch: a 24-hex `parentId` copied from the project id, an
|
|
87
|
+
* `assigneeId` derived from a chat user id, a guessed `priority`. Any of these
|
|
88
|
+
* silently narrows a "list the whole team" query to zero. A locked agent's job
|
|
89
|
+
* is "list everyone unless a member is named", and it cannot supply these
|
|
90
|
+
* reliably, so they are dropped from both the tool schema and (defensively) the
|
|
91
|
+
* API params. Member narrowing is done by NAME client-side (see matchesAssignee).
|
|
92
|
+
*/
|
|
93
|
+
export const HALLUCINATED_LIST_FILTERS = ['parentId', 'assigneeId', 'priority'];
|
|
94
|
+
|
|
95
|
+
/** Delete the fabrication-prone narrowing filters from an API param bag. */
|
|
96
|
+
export function stripHallucinatedListFilters(params) {
|
|
97
|
+
for (const key of HALLUCINATED_LIST_FILTERS) delete params[key];
|
|
98
|
+
return params;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Client-side member filter by NAME (or email substring), case-insensitive.
|
|
103
|
+
* Returns true (keep) when `needle` is blank (no narrowing) so the default is
|
|
104
|
+
* "all members". Compares against the populated owner {name,email}; a bare-id
|
|
105
|
+
* userId has no name/email and won't match a non-blank needle.
|
|
106
|
+
*/
|
|
107
|
+
export function matchesAssignee(userId, needle) {
|
|
108
|
+
if (isBlankValue(needle)) return true;
|
|
109
|
+
const owner = ownerName(userId);
|
|
110
|
+
const email =
|
|
111
|
+
userId && typeof userId === 'object' && typeof userId.email === 'string'
|
|
112
|
+
? userId.email
|
|
113
|
+
: '';
|
|
114
|
+
const hay = `${owner || ''} ${email}`.toLowerCase();
|
|
115
|
+
return hay.includes(String(needle).trim().toLowerCase());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** True when at least one item carries populated owner info (name/email). */
|
|
119
|
+
export function hasOwnerInfo(items) {
|
|
120
|
+
return (
|
|
121
|
+
Array.isArray(items) &&
|
|
122
|
+
items.some((it) => it && ownerName(it.userId) !== null)
|
|
123
|
+
);
|
|
124
|
+
}
|