@imenam/mcp-organizer 1.0.11 → 1.0.13

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.
Files changed (52) hide show
  1. package/README.md +728 -714
  2. package/dist/shared/schemas/agent-api.schema.d.ts +40 -2
  3. package/dist/shared/schemas/agent-api.schema.js +12 -3
  4. package/dist/shared/schemas/agent-tools.schema.d.ts +373 -6
  5. package/dist/shared/schemas/agent-tools.schema.js +54 -3
  6. package/dist/shared/schemas/api.schema.d.ts +26 -0
  7. package/dist/shared/schemas/api.schema.js +9 -0
  8. package/dist/shared/schemas/entities.schema.d.ts +32 -2
  9. package/dist/shared/schemas/entities.schema.js +27 -3
  10. package/dist/shared/schemas/enums.schema.d.ts +4 -2
  11. package/dist/shared/schemas/enums.schema.js +2 -1
  12. package/dist/shared/schemas/gui-api.schema.d.ts +6 -3
  13. package/dist/shared/schemas/gui-api.schema.js +6 -3
  14. package/dist/shared/schemas/notifications-api.schema.d.ts +29 -7
  15. package/dist/shared/schemas/notifications-api.schema.js +21 -5
  16. package/dist/shared/schemas/tasks-api.schema.d.ts +82 -0
  17. package/dist/shared/schemas/tasks-api.schema.js +35 -0
  18. package/dist/src/agent-api/requests.d.ts +1 -1
  19. package/dist/src/agent-api/requests.js +56 -4
  20. package/dist/src/agent-api/router.js +2 -1
  21. package/dist/src/agent-api/views.d.ts +2 -0
  22. package/dist/src/agent-api/views.js +203 -0
  23. package/dist/src/core/agent.d.ts +5 -1
  24. package/dist/src/core/agent.js +61 -2
  25. package/dist/src/core/board-views.d.ts +11 -1
  26. package/dist/src/core/board-views.js +28 -11
  27. package/dist/src/core/follow-ups.d.ts +7 -0
  28. package/dist/src/core/follow-ups.js +15 -0
  29. package/dist/src/core/history.d.ts +2 -1
  30. package/dist/src/core/history.js +62 -3
  31. package/dist/src/core/migrations.js +479 -424
  32. package/dist/src/core/notifications.js +36 -9
  33. package/dist/src/core/requests.d.ts +10 -1
  34. package/dist/src/core/requests.js +41 -3
  35. package/dist/src/core/snapshots.d.ts +4 -4
  36. package/dist/src/core/snapshots.js +6 -2
  37. package/dist/src/core/spaces.d.ts +2 -2
  38. package/dist/src/core/spaces.js +12 -6
  39. package/dist/src/core/store.d.ts +43 -6
  40. package/dist/src/core/store.js +202 -71
  41. package/dist/src/core/tasks.d.ts +21 -1
  42. package/dist/src/core/tasks.js +100 -10
  43. package/dist/src/gui-api.js +14 -7
  44. package/dist/src/mcp/start.d.ts +1 -1
  45. package/dist/src/mcp/start.js +4 -3
  46. package/dist/src/mcp/tools.js +86 -2
  47. package/dist/src/server/runner.js +4 -18
  48. package/gui/dist/assets/{index-BLhlceSY.css → index-CVwckTU6.css} +1 -1
  49. package/gui/dist/assets/index-CkZPrGSS.js +99 -0
  50. package/gui/dist/index.html +2 -2
  51. package/package.json +1 -1
  52. package/gui/dist/assets/index-Em4IQgbR.js +0 -98
@@ -31,20 +31,40 @@ function requireOwnView(store, viewId, userId) {
31
31
  /**
32
32
  * Regroupements permis par la disposition : un Kanban a un regroupement, une
33
33
  * matrice en croise deux, une liste en a zéro, un ou deux ; le second suit le
34
- * premier et en diffère.
34
+ * premier et en diffère. Renvoie le problème trouvé, ou null.
35
35
  */
36
- function requireGroupings(settings) {
36
+ export function groupingIssue(settings) {
37
37
  const { layout, groupBy, thenBy } = settings;
38
38
  if (layout === "kanban" && groupBy === "none")
39
- throw new OrganizerError("Un Kanban se regroupe par statut ou par priorité.");
39
+ return "kanban_ungrouped";
40
40
  if (layout === "kanban" && thenBy !== "none")
41
- throw new OrganizerError("Un Kanban n'a qu'un regroupement : choisissez la matrice pour en croiser deux.");
41
+ return "kanban_second";
42
42
  if (layout === "matrix" && (groupBy === "none" || thenBy === "none"))
43
- throw new OrganizerError("Une matrice croise deux regroupements : ses colonnes et ses lignes.");
43
+ return "matrix_incomplete";
44
44
  if (thenBy !== "none" && groupBy === "none")
45
- throw new OrganizerError("Le second regroupement suit un premier regroupement.");
45
+ return "second_without_first";
46
46
  if (thenBy !== "none" && thenBy === groupBy)
47
- throw new OrganizerError("Le second regroupement diffère du premier.");
47
+ return "second_same_as_first";
48
+ return null;
49
+ }
50
+ const GROUPING_MESSAGES = {
51
+ kanban_ungrouped: "Un Kanban se regroupe par statut ou par priorité.",
52
+ kanban_second: "Un Kanban n'a qu'un regroupement : choisissez la matrice pour en croiser deux.",
53
+ matrix_incomplete: "Une matrice croise deux regroupements : ses colonnes et ses lignes.",
54
+ second_without_first: "Le second regroupement suit un premier regroupement.",
55
+ second_same_as_first: "Le second regroupement diffère du premier.",
56
+ };
57
+ function requireGroupings(settings) {
58
+ const issue = groupingIssue(settings);
59
+ if (issue)
60
+ throw new OrganizerError(GROUPING_MESSAGES[issue]);
61
+ }
62
+ /** Crée les vues par défaut d'un membre qui n'en a aucune dans l'espace. */
63
+ export function ensureBoardViews(tx, spaceId, userId) {
64
+ if (tx.store.listBoardViews(spaceId, userId).length > 0)
65
+ return;
66
+ for (const settings of DEFAULT_BOARD_VIEWS)
67
+ tx.createBoardView(spaceId, userId, settings);
48
68
  }
49
69
  /** Vues de l'utilisateur dans un espace ; les vues par défaut sont créées s'il n'en a aucune. */
50
70
  export function listBoardViews(store, userId, spaceId) {
@@ -52,10 +72,7 @@ export function listBoardViews(store, userId, spaceId) {
52
72
  if (store.listBoardViews(spaceId, userId).length === 0) {
53
73
  store.mutate(asUser(userId), (tx) => {
54
74
  requireMember(tx.store, spaceId, userId);
55
- if (tx.store.listBoardViews(spaceId, userId).length > 0)
56
- return;
57
- for (const settings of DEFAULT_BOARD_VIEWS)
58
- tx.createBoardView(spaceId, userId, settings);
75
+ ensureBoardViews(tx, spaceId, userId);
59
76
  });
60
77
  }
61
78
  return { views: store.listBoardViews(spaceId, userId).map(viewOf) };
@@ -0,0 +1,7 @@
1
+ import type { Store } from "./store.js";
2
+ import type { FollowUp } from "../../shared/schemas/entities.schema.js";
3
+ import type { FollowUpView } from "../../shared/schemas/tasks-api.schema.js";
4
+ /** Points à régler d'une demande vus de la GUI : la page Agent et les commentaires d'une tâche. */
5
+ export declare function followUpView(store: Store, followUp: FollowUp): FollowUpView;
6
+ /** Points encore ouverts d'une demande. */
7
+ export declare function openFollowUps(store: Store, requestId: string): number;
@@ -0,0 +1,15 @@
1
+ /** Points à régler d'une demande vus de la GUI : la page Agent et les commentaires d'une tâche. */
2
+ export function followUpView(store, followUp) {
3
+ const doneBy = followUp.doneBy === null ? null : store.findUser(followUp.doneBy);
4
+ return {
5
+ id: followUp.id,
6
+ text: followUp.text,
7
+ doneAt: followUp.doneAt,
8
+ doneByName: doneBy ? (doneBy.displayName ?? doneBy.email) : null,
9
+ doneByRequestId: followUp.doneByRequestId,
10
+ };
11
+ }
12
+ /** Points encore ouverts d'une demande. */
13
+ export function openFollowUps(store, requestId) {
14
+ return store.listFollowUps(requestId).filter((followUp) => followUp.doneAt === null).length;
15
+ }
@@ -11,7 +11,8 @@ declare const TASK_FIELDS: readonly ["title", "description", "status", "priority
11
11
  * Annule une action de l'agent dans la mutation `tx` (acteur utilisateur).
12
12
  * L'état courant de l'entité doit être celui que l'action a laissé ; sinon le
13
13
  * refus nomme l'auteur de la modification. Une création est supprimée, une
14
- * suppression recréée, une modification ramenée à l'état d'avant.
14
+ * suppression recréée, une modification ramenée à l'état d'avant. Une action
15
+ * sur une vue du tableau de bord ne s'annule que par le membre à qui la vue appartient.
15
16
  */
16
17
  export declare function undoAgentAction(tx: Mutation, action: AgentAction): void;
17
18
  /** Libellés français des champs restaurables d'une tâche ; « position » est le rang dans une même colonne. */
@@ -1,6 +1,6 @@
1
- import { InvariantError, NotFoundError } from "./errors.js";
1
+ import { ForbiddenError, InvariantError, NotFoundError } from "./errors.js";
2
2
  import { CheckpointSnapshotSchema, isTracked, snapshotOf, taskIdOfAction } from "./snapshots.js";
3
- import { ChecklistItemSchema, CommentSchema, IdeaSchema, TaskSnapshotSchema, TestCheckpointSchema, } from "../../shared/schemas/entities.schema.js";
3
+ import { BoardViewSchema, ChecklistItemSchema, FollowUpSchema, CommentSchema, IdeaSchema, TaskSnapshotSchema, TestCheckpointSchema, } from "../../shared/schemas/entities.schema.js";
4
4
  /**
5
5
  * Retour à un état antérieur : annulation d'une action de l'agent, après
6
6
  * comparaison de l'état courant de l'entité avec celui que l'action a
@@ -27,8 +27,17 @@ function comparable(entityType, snapshot) {
27
27
  const idea = IdeaSchema.parse(snapshot);
28
28
  return [idea.text, idea.promotedTaskId, idea.archivedAt !== null];
29
29
  }
30
+ case "board_view":
31
+ return viewSettings(BoardViewSchema.parse(snapshot));
32
+ case "follow_up":
33
+ return [FollowUpSchema.parse(snapshot).doneAt !== null];
30
34
  }
31
35
  }
36
+ /** Réglages d'une vue, comparés et restaurés par l'annulation. */
37
+ function viewSettings(view) {
38
+ const { name, layout, groupBy, thenBy, showEmptyGroups, statuses, priorities, assigneeIds, unassigned } = view;
39
+ return { name, layout, groupBy, thenBy, showEmptyGroups, statuses, priorities, assigneeIds, unassigned };
40
+ }
32
41
  function sameState(entityType, a, b) {
33
42
  return JSON.stringify(comparable(entityType, a)) === JSON.stringify(comparable(entityType, b));
34
43
  }
@@ -48,6 +57,10 @@ function describe(store, entityType, snapshot) {
48
57
  return { label: "Le commentaire de l'agent", feminine: false };
49
58
  case "idea":
50
59
  return { label: `L'idée « ${excerpt(IdeaSchema.parse(snapshot).text)} »`, feminine: true };
60
+ case "board_view":
61
+ return { label: `La vue « ${BoardViewSchema.parse(snapshot).name} »`, feminine: true };
62
+ case "follow_up":
63
+ return { label: `Le point « ${excerpt(FollowUpSchema.parse(snapshot).text)} »`, feminine: false };
51
64
  }
52
65
  }
53
66
  function excerpt(text) {
@@ -68,7 +81,8 @@ function lastModifier(store, entityType, entityId, action) {
68
81
  * Annule une action de l'agent dans la mutation `tx` (acteur utilisateur).
69
82
  * L'état courant de l'entité doit être celui que l'action a laissé ; sinon le
70
83
  * refus nomme l'auteur de la modification. Une création est supprimée, une
71
- * suppression recréée, une modification ramenée à l'état d'avant.
84
+ * suppression recréée, une modification ramenée à l'état d'avant. Une action
85
+ * sur une vue du tableau de bord ne s'annule que par le membre à qui la vue appartient.
72
86
  */
73
87
  export function undoAgentAction(tx, action) {
74
88
  if (action.undoneAt !== null)
@@ -77,6 +91,8 @@ export function undoAgentAction(tx, action) {
77
91
  throw new InvariantError(`Une action sur ${action.entityType} ne s'annule pas.`);
78
92
  const entityType = action.entityType;
79
93
  const store = tx.store;
94
+ if (entityType === "board_view")
95
+ requireViewOwner(tx, BoardViewSchema.parse(action.after ?? action.before));
80
96
  const current = snapshotOf(store, entityType, action.entityId);
81
97
  if (action.after === null) {
82
98
  const { label } = describe(store, entityType, action.before);
@@ -100,6 +116,22 @@ export function undoAgentAction(tx, action) {
100
116
  }
101
117
  tx.markAgentActionUndone(action.id, taskIdOfAction(action));
102
118
  }
119
+ /** Seul le membre à qui appartient une vue annule les changements que l'agent y a faits. */
120
+ function requireViewOwner(tx, view) {
121
+ if (tx.actor.type === "user" && tx.actor.userId === view.userId)
122
+ return;
123
+ const owner = tx.store.findUser(view.userId);
124
+ throw new ForbiddenError(`La vue « ${view.name} » appartient à ${owner ? (owner.displayName ?? owner.email) : "un ancien membre"} : lui seul peut annuler ce changement.`);
125
+ }
126
+ /** Vérifie que les assignés filtrés par une vue sont encore membres de son espace. */
127
+ function requireViewAssignees(tx, view) {
128
+ for (const userId of view.assigneeIds) {
129
+ if (!tx.store.isMember(view.spaceId, userId)) {
130
+ const user = tx.store.findUser(userId);
131
+ throw new InvariantError(`${user ? (user.displayName ?? user.email) : "Un ancien assigné"} n'est plus membre de l'espace : restauration de la vue impossible.`);
132
+ }
133
+ }
134
+ }
103
135
  /** Supprime une entité créée par l'agent ; une tâche qui porte d'autres éléments est refusée. */
104
136
  function remove(tx, entityType, current, label) {
105
137
  const store = tx.store;
@@ -136,6 +168,14 @@ function remove(tx, entityType, current, label) {
136
168
  case "idea":
137
169
  tx.deleteIdea(IdeaSchema.parse(current).id);
138
170
  return;
171
+ case "board_view": {
172
+ const view = BoardViewSchema.parse(current);
173
+ if (store.listBoardViews(view.spaceId, view.userId).length === 1) {
174
+ throw new InvariantError(`${label} est la dernière vue de son propriétaire dans l'espace : créez-en une autre avant d'annuler.`);
175
+ }
176
+ tx.deleteBoardView(view.id);
177
+ return;
178
+ }
139
179
  }
140
180
  }
141
181
  /** Recrée une entité supprimée par l'agent. */
@@ -156,6 +196,14 @@ function recreate(tx, entityType, before) {
156
196
  tx.restoreCheckpoint(fields, results);
157
197
  return;
158
198
  }
199
+ case "board_view": {
200
+ const view = BoardViewSchema.parse(before);
201
+ if (!tx.store.isMember(view.spaceId, view.userId))
202
+ throw new InvariantError(`Le propriétaire de la vue « ${view.name} » n'est plus membre de l'espace : rien à recréer.`);
203
+ requireViewAssignees(tx, view);
204
+ tx.restoreBoardView(view);
205
+ return;
206
+ }
159
207
  default:
160
208
  throw new InvariantError(`La suppression d'un élément de type ${entityType} ne s'annule pas.`);
161
209
  }
@@ -184,6 +232,17 @@ function restore(tx, entityType, entityId, before) {
184
232
  }
185
233
  case "comment":
186
234
  throw new InvariantError("La modification d'un commentaire ne s'annule pas.");
235
+ case "board_view": {
236
+ const view = BoardViewSchema.parse(before);
237
+ requireViewAssignees(tx, view);
238
+ tx.updateBoardView(entityId, viewSettings(view));
239
+ return;
240
+ }
241
+ case "follow_up": {
242
+ const { doneAt, doneBy, doneByRequestId } = FollowUpSchema.parse(before);
243
+ tx.restoreFollowUpState(entityId, { doneAt, doneBy, doneByRequestId });
244
+ return;
245
+ }
187
246
  }
188
247
  }
189
248
  /** Libellés français des champs restaurables d'une tâche ; « position » est le rang dans une même colonne. */