stashes 0.1.39 → 0.1.41

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/dist/cli.js CHANGED
@@ -102,18 +102,35 @@ app.get("/chats", (c) => {
102
102
  app.post("/chats", async (c) => {
103
103
  const persistence = getPersistence();
104
104
  const project = ensureProject(persistence);
105
- const { title } = await c.req.json();
105
+ const { title, referencedStashIds } = await c.req.json();
106
106
  const chatCount = persistence.listChats(project.id).length;
107
107
  const chat = {
108
108
  id: `chat_${crypto.randomUUID().substring(0, 8)}`,
109
109
  projectId: project.id,
110
110
  title: title?.trim() || `Chat ${chatCount + 1}`,
111
+ referencedStashIds: referencedStashIds ?? [],
111
112
  createdAt: new Date().toISOString(),
112
113
  updatedAt: new Date().toISOString()
113
114
  };
114
115
  persistence.saveChat(chat);
115
116
  return c.json({ data: chat }, 201);
116
117
  });
118
+ app.patch("/chats/:chatId", async (c) => {
119
+ const persistence = getPersistence();
120
+ const project = ensureProject(persistence);
121
+ const chatId = c.req.param("chatId");
122
+ const chat = persistence.getChat(project.id, chatId);
123
+ if (!chat)
124
+ return c.json({ error: "Chat not found" }, 404);
125
+ const body = await c.req.json();
126
+ const updated = {
127
+ ...chat,
128
+ ...body.referencedStashIds !== undefined ? { referencedStashIds: body.referencedStashIds } : {},
129
+ updatedAt: new Date().toISOString()
130
+ };
131
+ persistence.saveChat(updated);
132
+ return c.json({ data: updated });
133
+ });
117
134
  app.get("/chats/:chatId", (c) => {
118
135
  const persistence = getPersistence();
119
136
  const project = ensureProject(persistence);
@@ -122,7 +139,8 @@ app.get("/chats/:chatId", (c) => {
122
139
  if (!chat)
123
140
  return c.json({ error: "Chat not found" }, 404);
124
141
  const messages = persistence.getChatMessages(project.id, chatId);
125
- const stashes = persistence.listStashes(project.id).filter((s) => s.originChatId === chatId);
142
+ const refIds = new Set(chat.referencedStashIds ?? []);
143
+ const stashes = persistence.listStashes(project.id).filter((s) => s.originChatId === chatId || refIds.has(s.id));
126
144
  return c.json({ data: { ...chat, messages, stashes } });
127
145
  });
128
146
  app.delete("/chats/:chatId", (c) => {
package/dist/mcp.js CHANGED
@@ -1498,18 +1498,35 @@ app.get("/chats", (c) => {
1498
1498
  app.post("/chats", async (c) => {
1499
1499
  const persistence = getPersistence();
1500
1500
  const project = ensureProject(persistence);
1501
- const { title } = await c.req.json();
1501
+ const { title, referencedStashIds } = await c.req.json();
1502
1502
  const chatCount = persistence.listChats(project.id).length;
1503
1503
  const chat = {
1504
1504
  id: `chat_${crypto.randomUUID().substring(0, 8)}`,
1505
1505
  projectId: project.id,
1506
1506
  title: title?.trim() || `Chat ${chatCount + 1}`,
1507
+ referencedStashIds: referencedStashIds ?? [],
1507
1508
  createdAt: new Date().toISOString(),
1508
1509
  updatedAt: new Date().toISOString()
1509
1510
  };
1510
1511
  persistence.saveChat(chat);
1511
1512
  return c.json({ data: chat }, 201);
1512
1513
  });
1514
+ app.patch("/chats/:chatId", async (c) => {
1515
+ const persistence = getPersistence();
1516
+ const project = ensureProject(persistence);
1517
+ const chatId = c.req.param("chatId");
1518
+ const chat = persistence.getChat(project.id, chatId);
1519
+ if (!chat)
1520
+ return c.json({ error: "Chat not found" }, 404);
1521
+ const body = await c.req.json();
1522
+ const updated = {
1523
+ ...chat,
1524
+ ...body.referencedStashIds !== undefined ? { referencedStashIds: body.referencedStashIds } : {},
1525
+ updatedAt: new Date().toISOString()
1526
+ };
1527
+ persistence.saveChat(updated);
1528
+ return c.json({ data: updated });
1529
+ });
1513
1530
  app.get("/chats/:chatId", (c) => {
1514
1531
  const persistence = getPersistence();
1515
1532
  const project = ensureProject(persistence);
@@ -1518,7 +1535,8 @@ app.get("/chats/:chatId", (c) => {
1518
1535
  if (!chat)
1519
1536
  return c.json({ error: "Chat not found" }, 404);
1520
1537
  const messages = persistence.getChatMessages(project.id, chatId);
1521
- const stashes = persistence.listStashes(project.id).filter((s) => s.originChatId === chatId);
1538
+ const refIds = new Set(chat.referencedStashIds ?? []);
1539
+ const stashes = persistence.listStashes(project.id).filter((s) => s.originChatId === chatId || refIds.has(s.id));
1522
1540
  return c.json({ data: { ...chat, messages, stashes } });
1523
1541
  });
1524
1542
  app.delete("/chats/:chatId", (c) => {