@loicngr/kobo 1.6.2 → 1.6.3
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/mcp-server/kobo-tasks-handlers.js +145 -0
- package/dist/mcp-server/kobo-tasks-server.js +144 -54
- package/dist/server/services/agent/engines/claude-code/args-builder.js +21 -0
- package/package.json +1 -1
- package/src/client/dist/spa/assets/ActivityFeed-BCPHgr3p.css +1 -0
- package/src/client/dist/spa/assets/ActivityFeed-DPg8lZZP.js +7 -0
- package/src/client/dist/spa/assets/{CreatePage-sGrkfyOm.js → CreatePage-C2mUAcwE.js} +1 -1
- package/src/client/dist/spa/assets/{DiffViewer-BwSRtVRI.js → DiffViewer-DdLwXeB3.js} +2 -2
- package/src/client/dist/spa/assets/{HealthPage-BO-bMpEu.js → HealthPage-CJDF2_4D.js} +1 -1
- package/src/client/dist/spa/assets/{MainLayout-BpqOChIX.js → MainLayout-K2u9uIOb.js} +2 -2
- package/src/client/dist/spa/assets/{SearchPage-BrUbbtgI.js → SearchPage-Drjd-r_Y.js} +1 -1
- package/src/client/dist/spa/assets/{SettingsPage-B3elO1PX.js → SettingsPage-DvqT-ViK.js} +1 -1
- package/src/client/dist/spa/assets/{WorkspacePage-BHl17_tY.js → WorkspacePage-Bk_SslTv.js} +3 -3
- package/src/client/dist/spa/assets/{build-path-tree-Bgl2q74t.js → build-path-tree-BE2FoPWg.js} +1 -1
- package/src/client/dist/spa/assets/{cssMode-B1wQ-79R.js → cssMode-0GRgcPCL.js} +1 -1
- package/src/client/dist/spa/assets/{documents-CHc8t22V.js → documents-BJW_8dHZ.js} +1 -1
- package/src/client/dist/spa/assets/{editor.api-CRb_5Zw6.js → editor.api-C1-xuJKd.js} +1 -1
- package/src/client/dist/spa/assets/{editor.main-C5sdCvGW.js → editor.main-C2QDgca3.js} +3 -3
- package/src/client/dist/spa/assets/{freemarker2-CVSnsZk-.js → freemarker2-Dgc_0Q23.js} +1 -1
- package/src/client/dist/spa/assets/{handlebars-uL_pucGI.js → handlebars-DkfsYZsi.js} +1 -1
- package/src/client/dist/spa/assets/{html-CatZVwWp.js → html-CbSyHFvE.js} +1 -1
- package/src/client/dist/spa/assets/{htmlMode-DTDzEngo.js → htmlMode-BKR6h-2d.js} +1 -1
- package/src/client/dist/spa/assets/i18n-C03q300x.js +1 -0
- package/src/client/dist/spa/assets/{index-CUI-zN26.js → index-9vZWx9Bu.js} +2 -2
- package/src/client/dist/spa/assets/{javascript-DeHBpolA.js → javascript-QJqA2E1u.js} +1 -1
- package/src/client/dist/spa/assets/{jsonMode-Bma_YGGm.js → jsonMode-D8CXYQiy.js} +1 -1
- package/src/client/dist/spa/assets/{liquid-CW7xQEG_.js → liquid-DLssQpNB.js} +1 -1
- package/src/client/dist/spa/assets/{mdx-BsYUhMzF.js → mdx-4u6l2_x4.js} +1 -1
- package/src/client/dist/spa/assets/{models-BbSRHL9b.js → models-BtywKe_m.js} +1 -1
- package/src/client/dist/spa/assets/{monaco.contribution-Du0atePv.js → monaco.contribution-DFCuvXsm.js} +2 -2
- package/src/client/dist/spa/assets/{python-D7DQWXZm.js → python-BFIl5AC4.js} +1 -1
- package/src/client/dist/spa/assets/{razor-B2ZxF301.js → razor-BrKtxN6e.js} +1 -1
- package/src/client/dist/spa/assets/{tsMode-B4Xul5xA.js → tsMode-B7FS-eG8.js} +1 -1
- package/src/client/dist/spa/assets/{typescript-CdsKQuLT.js → typescript-CpUDqcsF.js} +1 -1
- package/src/client/dist/spa/assets/{xml-Wap00dMv.js → xml-_L0I3U6m.js} +1 -1
- package/src/client/dist/spa/assets/{yaml-BxRDHC24.js → yaml-CY3U_Y-0.js} +1 -1
- package/src/client/dist/spa/index.html +1 -1
- package/src/mcp-server/kobo-tasks-handlers.ts +191 -0
- package/src/mcp-server/kobo-tasks-server.ts +158 -53
- package/src/client/dist/spa/assets/ActivityFeed-CFuT6H5u.js +0 -7
- package/src/client/dist/spa/assets/ActivityFeed-DXYafbn4.css +0 -1
- package/src/client/dist/spa/assets/i18n-D-VdPLEh.js +0 -1
|
@@ -183,3 +183,148 @@ export function listWorkspaceImagesHandler(worktreePath) {
|
|
|
183
183
|
};
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
+
// ── Documents ────────────────────────────────────────────────────────────────
|
|
187
|
+
/** Directories (relative to the worktree root) scanned for AI-generated docs. */
|
|
188
|
+
export const DOCUMENT_DIRS = ['docs/plans', 'docs/superpowers', '.ai/thoughts'];
|
|
189
|
+
/** Depth cap to keep recursion bounded even on pathological symlink loops. */
|
|
190
|
+
const DOC_MAX_DEPTH = 8;
|
|
191
|
+
function walkMarkdownFiles(rootAbs, rootRel, out, depth = 0) {
|
|
192
|
+
if (depth > DOC_MAX_DEPTH)
|
|
193
|
+
return;
|
|
194
|
+
let entries;
|
|
195
|
+
try {
|
|
196
|
+
entries = fs.readdirSync(rootAbs);
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
for (const entry of entries) {
|
|
202
|
+
if (entry.startsWith('.') && entry !== '.ai')
|
|
203
|
+
continue;
|
|
204
|
+
const absEntry = path.join(rootAbs, entry);
|
|
205
|
+
const relEntry = `${rootRel}/${entry}`;
|
|
206
|
+
let stat;
|
|
207
|
+
try {
|
|
208
|
+
stat = fs.statSync(absEntry);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (stat.isDirectory()) {
|
|
214
|
+
walkMarkdownFiles(absEntry, relEntry, out, depth + 1);
|
|
215
|
+
}
|
|
216
|
+
else if (stat.isFile() && entry.endsWith('.md')) {
|
|
217
|
+
out.push({ path: relEntry, name: entry, modifiedAt: stat.mtime.toISOString() });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Recursively list every `.md` file under `docs/plans/`, `docs/superpowers/`,
|
|
223
|
+
* and `.ai/thoughts/` inside the given worktree. Sorted by modifiedAt desc.
|
|
224
|
+
*/
|
|
225
|
+
export function listDocumentsHandler(worktreePath) {
|
|
226
|
+
const documents = [];
|
|
227
|
+
for (const dir of DOCUMENT_DIRS) {
|
|
228
|
+
const absDir = path.join(worktreePath, dir);
|
|
229
|
+
if (!fs.existsSync(absDir))
|
|
230
|
+
continue;
|
|
231
|
+
walkMarkdownFiles(absDir, dir, documents);
|
|
232
|
+
}
|
|
233
|
+
documents.sort((a, b) => new Date(b.modifiedAt).getTime() - new Date(a.modifiedAt).getTime());
|
|
234
|
+
return documents;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Read a single document. The caller-supplied path must be relative to the
|
|
238
|
+
* worktree root and live under one of the allowed DOCUMENT_DIRS; `.md` only;
|
|
239
|
+
* traversal (`..`) is rejected.
|
|
240
|
+
*/
|
|
241
|
+
export function readDocumentHandler(worktreePath, relPath) {
|
|
242
|
+
if (!relPath)
|
|
243
|
+
throw new Error('path is required');
|
|
244
|
+
const normalized = path.normalize(relPath);
|
|
245
|
+
if (normalized.includes('..') ||
|
|
246
|
+
!DOCUMENT_DIRS.some((dir) => normalized.startsWith(`${dir}/`) || normalized === dir)) {
|
|
247
|
+
throw new Error(`Invalid path: must be under ${DOCUMENT_DIRS.map((d) => `${d}/`).join(', ')}`);
|
|
248
|
+
}
|
|
249
|
+
if (!normalized.endsWith('.md')) {
|
|
250
|
+
throw new Error('Only .md files can be read');
|
|
251
|
+
}
|
|
252
|
+
const abs = path.join(worktreePath, normalized);
|
|
253
|
+
if (!fs.existsSync(abs)) {
|
|
254
|
+
throw new Error(`Document not found: ${normalized}`);
|
|
255
|
+
}
|
|
256
|
+
return { path: normalized, content: fs.readFileSync(abs, 'utf-8') };
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Append a thought / decision / note to `.ai/thoughts/<YYYY-MM-DD>-<slug>.md`.
|
|
260
|
+
* Creates the directory if missing. Returns the path (worktree-relative) of
|
|
261
|
+
* the file actually written — useful for the agent to reference it in chat.
|
|
262
|
+
*/
|
|
263
|
+
export function logThoughtHandler(worktreePath, data) {
|
|
264
|
+
const title = data.title?.trim();
|
|
265
|
+
if (!title)
|
|
266
|
+
throw new Error('title is required');
|
|
267
|
+
const content = data.content?.trim();
|
|
268
|
+
if (!content)
|
|
269
|
+
throw new Error('content is required');
|
|
270
|
+
const thoughtsDir = path.join(worktreePath, '.ai', 'thoughts');
|
|
271
|
+
fs.mkdirSync(thoughtsDir, { recursive: true });
|
|
272
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
273
|
+
const slug = title
|
|
274
|
+
.toLowerCase()
|
|
275
|
+
.normalize('NFKD')
|
|
276
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
277
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
278
|
+
.replace(/^-+|-+$/g, '')
|
|
279
|
+
.slice(0, 60) || 'note';
|
|
280
|
+
const tagSuffix = data.tag ? `-${data.tag.replace(/[^a-z0-9]+/gi, '-').toLowerCase()}` : '';
|
|
281
|
+
const filename = `${date}-${slug}${tagSuffix}.md`;
|
|
282
|
+
const abs = path.join(thoughtsDir, filename);
|
|
283
|
+
const relPath = `.ai/thoughts/${filename}`;
|
|
284
|
+
const header = `# ${title}\n\n_${new Date().toISOString()}_${data.tag ? ` · tag: \`${data.tag}\`` : ''}\n\n`;
|
|
285
|
+
fs.writeFileSync(abs, header + content + (content.endsWith('\n') ? '' : '\n'), 'utf-8');
|
|
286
|
+
return { path: relPath };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Aggregate `usage` events from `ws_events` to report how many tokens and
|
|
290
|
+
* dollars the workspace has consumed — both in total and for the currently
|
|
291
|
+
* running agent_session (if any). Silently skips rows whose payload is not
|
|
292
|
+
* valid JSON or not a usage event.
|
|
293
|
+
*/
|
|
294
|
+
export function getSessionUsageHandler(db, workspaceId) {
|
|
295
|
+
const runningSession = db
|
|
296
|
+
.prepare("SELECT id FROM agent_sessions WHERE workspace_id = ? AND status = 'running' ORDER BY started_at DESC LIMIT 1")
|
|
297
|
+
.get(workspaceId);
|
|
298
|
+
const currentSessionId = runningSession?.id ?? null;
|
|
299
|
+
const rows = db
|
|
300
|
+
.prepare("SELECT payload, session_id FROM ws_events WHERE workspace_id = ? AND type = 'agent:event'")
|
|
301
|
+
.all(workspaceId);
|
|
302
|
+
const totals = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
|
|
303
|
+
const current = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
|
|
304
|
+
for (const row of rows) {
|
|
305
|
+
let parsed;
|
|
306
|
+
try {
|
|
307
|
+
parsed = JSON.parse(row.payload);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (parsed.kind !== 'usage')
|
|
313
|
+
continue;
|
|
314
|
+
const input = typeof parsed.inputTokens === 'number' ? parsed.inputTokens : 0;
|
|
315
|
+
const output = typeof parsed.outputTokens === 'number' ? parsed.outputTokens : 0;
|
|
316
|
+
const cost = typeof parsed.costUsd === 'number' ? parsed.costUsd : 0;
|
|
317
|
+
totals.inputTokens += input;
|
|
318
|
+
totals.outputTokens += output;
|
|
319
|
+
totals.costUsd += cost;
|
|
320
|
+
if (currentSessionId && row.session_id === currentSessionId) {
|
|
321
|
+
current.inputTokens += input;
|
|
322
|
+
current.outputTokens += output;
|
|
323
|
+
current.costUsd += cost;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
workspaceTotals: totals,
|
|
328
|
+
currentSession: { sessionId: currentSessionId, ...current },
|
|
329
|
+
};
|
|
330
|
+
}
|
|
@@ -5,7 +5,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
5
5
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
6
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import Database from 'better-sqlite3';
|
|
8
|
-
import { createTaskHandler, deleteTaskHandler, getDevServerStatusHandler, getSettingsHandler, getWorkspaceInfoHandler, listTasksHandler, listWorkspaceImagesHandler, markTaskDoneHandler, updateTaskHandler, } from './kobo-tasks-handlers.js';
|
|
8
|
+
import { createTaskHandler, deleteTaskHandler, getDevServerStatusHandler, getSessionUsageHandler, getSettingsHandler, getWorkspaceInfoHandler, listDocumentsHandler, listTasksHandler, listWorkspaceImagesHandler, logThoughtHandler, markTaskDoneHandler, readDocumentHandler, updateTaskHandler, } from './kobo-tasks-handlers.js';
|
|
9
9
|
const workspaceId = process.env.KOBO_WORKSPACE_ID;
|
|
10
10
|
const dbPath = process.env.KOBO_DB_PATH;
|
|
11
11
|
const settingsPath = process.env.KOBO_SETTINGS_PATH;
|
|
@@ -73,37 +73,30 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
73
73
|
tools: [
|
|
74
74
|
{
|
|
75
75
|
name: 'list_tasks',
|
|
76
|
-
description: '
|
|
77
|
-
inputSchema: {
|
|
78
|
-
type: 'object',
|
|
79
|
-
properties: {},
|
|
80
|
-
required: [],
|
|
81
|
-
},
|
|
76
|
+
description: 'CALL FIRST on any non-trivial turn to know what the user wants done and what is already completed. Returns every task and acceptance criterion for the current workspace with its id and status. Re-call periodically (before marking something done, or after the user asks for a status) to stay in sync with user-added or external updates.',
|
|
77
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
82
78
|
},
|
|
83
79
|
{
|
|
84
80
|
name: 'mark_task_done',
|
|
85
|
-
description: '
|
|
81
|
+
description: 'CALL AS SOON AS a task or acceptance criterion is finished AND verified (tests pass, feature works, diff committed). Do not wait for the end of the turn — the user watches progress live and marking each item as it completes is the primary signal Kōbō uses to track you.',
|
|
86
82
|
inputSchema: {
|
|
87
83
|
type: 'object',
|
|
88
84
|
properties: {
|
|
89
|
-
task_id: {
|
|
90
|
-
type: 'string',
|
|
91
|
-
description: 'The ID of the task to mark as done (obtained from list_tasks)',
|
|
92
|
-
},
|
|
85
|
+
task_id: { type: 'string', description: 'Task id from list_tasks.' },
|
|
93
86
|
},
|
|
94
87
|
required: ['task_id'],
|
|
95
88
|
},
|
|
96
89
|
},
|
|
97
90
|
{
|
|
98
91
|
name: 'create_task',
|
|
99
|
-
description: '
|
|
92
|
+
description: 'CALL WHEN you discover follow-up work that was not in the original list and needs to stick around (e.g. "refactor this helper later", "add a test for edge case"). Appends at the end of the list. Do not use it for ephemeral internal notes — prefer log_thought for those.',
|
|
100
93
|
inputSchema: {
|
|
101
94
|
type: 'object',
|
|
102
95
|
properties: {
|
|
103
|
-
title: { type: 'string', description: '
|
|
96
|
+
title: { type: 'string', description: 'Short, imperative title (e.g. "Add retry to fetchUser").' },
|
|
104
97
|
is_acceptance_criterion: {
|
|
105
98
|
type: 'boolean',
|
|
106
|
-
description: '
|
|
99
|
+
description: 'Mark as acceptance criterion rather than a task (default: false).',
|
|
107
100
|
},
|
|
108
101
|
},
|
|
109
102
|
required: ['title'],
|
|
@@ -111,20 +104,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
111
104
|
},
|
|
112
105
|
{
|
|
113
106
|
name: 'update_task',
|
|
114
|
-
description: '
|
|
107
|
+
description: 'CALL WHEN you need to refine a task — rewording for clarity, flipping status to `in_progress` as you start it, or promoting a task to acceptance criterion. At least one mutable field is required.',
|
|
115
108
|
inputSchema: {
|
|
116
109
|
type: 'object',
|
|
117
110
|
properties: {
|
|
118
|
-
task_id: { type: 'string', description: '
|
|
119
|
-
title: { type: 'string', description: 'New title (optional)' },
|
|
111
|
+
task_id: { type: 'string', description: 'Task id from list_tasks.' },
|
|
112
|
+
title: { type: 'string', description: 'New title (optional).' },
|
|
120
113
|
status: {
|
|
121
114
|
type: 'string',
|
|
122
115
|
enum: ['pending', 'in_progress', 'done'],
|
|
123
|
-
description: 'New status (optional)',
|
|
116
|
+
description: 'New status (optional).',
|
|
124
117
|
},
|
|
125
118
|
is_acceptance_criterion: {
|
|
126
119
|
type: 'boolean',
|
|
127
|
-
description: 'Toggle acceptance criterion flag (optional)',
|
|
120
|
+
description: 'Toggle acceptance criterion flag (optional).',
|
|
128
121
|
},
|
|
129
122
|
},
|
|
130
123
|
required: ['task_id'],
|
|
@@ -132,95 +125,150 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
132
125
|
},
|
|
133
126
|
{
|
|
134
127
|
name: 'delete_task',
|
|
135
|
-
description: '
|
|
128
|
+
description: 'CALL ONLY when a task was created in error or became truly irrelevant (scope change validated by user). Prefer marking done or in_progress over deleting.',
|
|
136
129
|
inputSchema: {
|
|
137
130
|
type: 'object',
|
|
138
131
|
properties: {
|
|
139
|
-
task_id: { type: 'string', description: '
|
|
132
|
+
task_id: { type: 'string', description: 'Task id from list_tasks.' },
|
|
140
133
|
},
|
|
141
134
|
required: ['task_id'],
|
|
142
135
|
},
|
|
143
136
|
},
|
|
144
137
|
{
|
|
145
|
-
name: '
|
|
146
|
-
description: '
|
|
138
|
+
name: 'get_workspace_info',
|
|
139
|
+
description: 'CALL EARLY in a session to confirm project path, working/source branch, worktree path, model, and notion link. Cheap read — useful when the user refers to "this workspace" or when you need the worktree path to locate files.',
|
|
140
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'get_git_info',
|
|
144
|
+
description: 'CALL BEFORE creating a PR, committing in batches, or reporting progress to the user. Returns commit count ahead of source, files changed, insertions/deletions, and existing PR URL if any.',
|
|
145
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'set_workspace_status',
|
|
149
|
+
description: 'CALL WHEN you believe the mission is done (`completed`), blocked beyond recovery (`error`), or explicitly idle awaiting user input (`idle`). Transitions are validated by the backend — invalid ones are rejected.',
|
|
147
150
|
inputSchema: {
|
|
148
151
|
type: 'object',
|
|
149
152
|
properties: {
|
|
150
|
-
|
|
153
|
+
status: {
|
|
151
154
|
type: 'string',
|
|
152
|
-
|
|
155
|
+
enum: ['idle', 'completed', 'error'],
|
|
156
|
+
description: 'Target status.',
|
|
153
157
|
},
|
|
154
158
|
},
|
|
155
|
-
required: [],
|
|
159
|
+
required: ['status'],
|
|
156
160
|
},
|
|
157
161
|
},
|
|
158
162
|
{
|
|
159
|
-
name: '
|
|
160
|
-
description: '
|
|
161
|
-
inputSchema: {
|
|
162
|
-
type: 'object',
|
|
163
|
-
properties: {},
|
|
164
|
-
required: [],
|
|
165
|
-
},
|
|
163
|
+
name: 'get_notion_ticket',
|
|
164
|
+
description: 'CALL when the user references "the ticket", "the Notion page", or when you need the source-of-truth text for the mission. Returns the Notion URL + locally-extracted ticket content from .ai/thoughts/.',
|
|
165
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
|
-
name: '
|
|
169
|
-
description: '
|
|
168
|
+
name: 'get_dev_server_status',
|
|
169
|
+
description: 'CALL BEFORE asking the user whether the app is running, or when your change is dev-server-sensitive. Returns running/stopped/starting/error + URL, port, container names.',
|
|
170
170
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
name: 'start_dev_server',
|
|
174
|
-
description: '
|
|
174
|
+
description: 'CALL WHEN the user asks you to test the running app and the dev server is stopped.',
|
|
175
175
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
name: 'stop_dev_server',
|
|
179
|
-
description: '
|
|
179
|
+
description: 'CALL WHEN the user explicitly asks to stop the dev server, or before destructive operations that require a clean boot.',
|
|
180
180
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
name: 'get_dev_server_logs',
|
|
184
|
-
description: '
|
|
184
|
+
description: 'CALL WHEN debugging a runtime issue the user describes as happening in the running app. Returns the last N lines of logs (default 200). Cheaper than asking the user to paste them.',
|
|
185
185
|
inputSchema: {
|
|
186
186
|
type: 'object',
|
|
187
187
|
properties: {
|
|
188
|
-
tail: {
|
|
189
|
-
type: 'number',
|
|
190
|
-
description: 'Number of lines to fetch from the end (default: 200)',
|
|
191
|
-
},
|
|
188
|
+
tail: { type: 'number', description: 'Number of lines from the end (default: 200).' },
|
|
192
189
|
},
|
|
193
190
|
required: [],
|
|
194
191
|
},
|
|
195
192
|
},
|
|
196
193
|
{
|
|
197
194
|
name: 'list_workspace_images',
|
|
198
|
-
description: '
|
|
195
|
+
description: 'CALL WHEN the user mentions "the screenshot", "the attached image", or when you need to reference a previously-uploaded image. Returns uid, originalName, relativePath, createdAt for every image in .ai/images/.',
|
|
199
196
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
200
197
|
},
|
|
201
198
|
{
|
|
202
|
-
name: '
|
|
203
|
-
description: '
|
|
199
|
+
name: 'get_settings',
|
|
200
|
+
description: 'CALL WHEN you need to confirm configured models, PR prompt templates, git conventions, or dev-server commands before acting on them. Pass project_path to merge global + project-specific entries.',
|
|
201
|
+
inputSchema: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
project_path: {
|
|
205
|
+
type: 'string',
|
|
206
|
+
description: 'Project path to resolve a specific project entry (optional).',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
required: [],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
// ── Knowledge / context tools ─────────────────────────────────────────────
|
|
213
|
+
{
|
|
214
|
+
name: 'list_documents',
|
|
215
|
+
description: 'CALL EARLY on a new session to discover plans, specs, and thoughts previously written for this workspace. Recursively lists every .md under docs/plans/, docs/superpowers/, and .ai/thoughts/. Before writing a new plan, check if one already exists.',
|
|
204
216
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
205
217
|
},
|
|
206
218
|
{
|
|
207
|
-
name: '
|
|
208
|
-
description: '
|
|
219
|
+
name: 'read_document',
|
|
220
|
+
description: 'CALL AFTER list_documents when a file title looks relevant to the current task. Returns the full markdown content. Scoped to docs/plans/, docs/superpowers/, .ai/thoughts/ — reject anything else.',
|
|
209
221
|
inputSchema: {
|
|
210
222
|
type: 'object',
|
|
211
223
|
properties: {
|
|
212
|
-
|
|
224
|
+
path: {
|
|
213
225
|
type: 'string',
|
|
214
|
-
|
|
215
|
-
description: 'New status (e.g. idle, completed)',
|
|
226
|
+
description: 'Worktree-relative path from list_documents (e.g. "docs/superpowers/plans/2026-04-17-foo.md").',
|
|
216
227
|
},
|
|
217
228
|
},
|
|
218
|
-
required: ['
|
|
229
|
+
required: ['path'],
|
|
219
230
|
},
|
|
220
231
|
},
|
|
221
232
|
{
|
|
222
|
-
name: '
|
|
223
|
-
description: '
|
|
233
|
+
name: 'log_thought',
|
|
234
|
+
description: 'CALL WHEN you make a decision worth remembering — architecture choice, trade-off taken, dead-end avoided, pattern discovered. Appends a dated markdown file to .ai/thoughts/. Keep entries short and focused; one decision per call. Use create_task for actionable follow-ups instead.',
|
|
235
|
+
inputSchema: {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
title: { type: 'string', description: 'Short, descriptive title (becomes the filename slug and the # H1).' },
|
|
239
|
+
content: { type: 'string', description: 'Markdown body explaining the decision and its reasoning.' },
|
|
240
|
+
tag: {
|
|
241
|
+
type: 'string',
|
|
242
|
+
description: 'Optional short tag appended to filename (e.g. "arch", "bug", "perf").',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
required: ['title', 'content'],
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'search_codebase',
|
|
250
|
+
description: 'CALL WHEN you need to recall prior chat history across workspaces — past decisions, prior user requests, an agent message you remember but can’t locate. Full-text search over user messages + agent outputs persisted in Kōbō. Use the local Grep tool for searching source code; this tool searches CONVERSATIONS.',
|
|
251
|
+
inputSchema: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
query: { type: 'string', description: 'Search phrase. Plain text; no regex.' },
|
|
255
|
+
include_archived: {
|
|
256
|
+
type: 'boolean',
|
|
257
|
+
description: 'Include archived workspaces in the search (default: false).',
|
|
258
|
+
},
|
|
259
|
+
scope: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
enum: ['workspace', 'all'],
|
|
262
|
+
description: 'Restrict to this workspace only (default) or search across every workspace.',
|
|
263
|
+
},
|
|
264
|
+
limit: { type: 'number', description: 'Max results to return (default 30, max 100).' },
|
|
265
|
+
},
|
|
266
|
+
required: ['query'],
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: 'get_session_usage',
|
|
271
|
+
description: 'CALL when you need to self-regulate on long missions — returns token/cost totals for the workspace lifetime and for the currently running agent_session. Useful before spawning heavy subagents or deep reasoning on already-expensive sessions.',
|
|
224
272
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
225
273
|
},
|
|
226
274
|
],
|
|
@@ -339,6 +387,48 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
339
387
|
const result = await backendRequest('PATCH', `/api/workspaces/${workspaceId}`, { status });
|
|
340
388
|
return ok(result);
|
|
341
389
|
}
|
|
390
|
+
if (name === 'list_documents') {
|
|
391
|
+
const info = getWorkspaceInfoHandler(db, workspaceId);
|
|
392
|
+
return ok(listDocumentsHandler(info.worktreePath));
|
|
393
|
+
}
|
|
394
|
+
if (name === 'read_document') {
|
|
395
|
+
const docPath = a.path;
|
|
396
|
+
if (!docPath)
|
|
397
|
+
return fail('path parameter is required');
|
|
398
|
+
const info = getWorkspaceInfoHandler(db, workspaceId);
|
|
399
|
+
return ok(readDocumentHandler(info.worktreePath, docPath));
|
|
400
|
+
}
|
|
401
|
+
if (name === 'log_thought') {
|
|
402
|
+
const title = a.title;
|
|
403
|
+
const content = a.content;
|
|
404
|
+
if (!title)
|
|
405
|
+
return fail('title parameter is required');
|
|
406
|
+
if (!content)
|
|
407
|
+
return fail('content parameter is required');
|
|
408
|
+
const info = getWorkspaceInfoHandler(db, workspaceId);
|
|
409
|
+
return ok(logThoughtHandler(info.worktreePath, {
|
|
410
|
+
title,
|
|
411
|
+
content,
|
|
412
|
+
tag: a.tag,
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
if (name === 'get_session_usage') {
|
|
416
|
+
return ok(getSessionUsageHandler(db, workspaceId));
|
|
417
|
+
}
|
|
418
|
+
if (name === 'search_codebase') {
|
|
419
|
+
const query = a.query;
|
|
420
|
+
if (!query)
|
|
421
|
+
return fail('query parameter is required');
|
|
422
|
+
const scope = a.scope ?? 'workspace';
|
|
423
|
+
const includeArchived = a.include_archived === true;
|
|
424
|
+
const limit = Math.min(Math.max(1, a.limit ?? 30), 100);
|
|
425
|
+
const qs = new URLSearchParams({ q: query, limit: String(limit) });
|
|
426
|
+
if (includeArchived)
|
|
427
|
+
qs.set('includeArchived', 'true');
|
|
428
|
+
const raw = (await backendRequest('GET', `/api/search?${qs.toString()}`));
|
|
429
|
+
const results = scope === 'all' ? raw : raw.filter((r) => r.workspaceId === workspaceId);
|
|
430
|
+
return ok({ query, scope, total: results.length, results });
|
|
431
|
+
}
|
|
342
432
|
return fail(`Unknown tool: ${name}`);
|
|
343
433
|
}
|
|
344
434
|
catch (err) {
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short brief injected at the top of the first prompt of a *new* session so
|
|
3
|
+
* the agent discovers the Kōbō MCP toolbox without having to be asked.
|
|
4
|
+
* Skipped on `--resume` because the brief is already in conversation history.
|
|
5
|
+
*/
|
|
6
|
+
const KOBO_MCP_BRIEF = [
|
|
7
|
+
'[Kōbō MCP] This workspace exposes a dedicated MCP server with tools prefixed `kobo__`.',
|
|
8
|
+
'Conventions — read these BEFORE starting work, not as a fallback:',
|
|
9
|
+
'• `kobo__list_tasks` first on any non-trivial turn, then `kobo__mark_task_done` as each item completes.',
|
|
10
|
+
'• `kobo__list_documents` / `kobo__read_document` to discover existing plans and specs under docs/ and .ai/thoughts/ before writing new ones.',
|
|
11
|
+
'• `kobo__log_thought` to persist notable decisions to `.ai/thoughts/<date>-<slug>.md`.',
|
|
12
|
+
'• `kobo__search_codebase` to recall prior chat history (conversations, not source — use Grep for source).',
|
|
13
|
+
'• `kobo__get_workspace_info` / `kobo__get_git_info` / `kobo__get_notion_ticket` for context.',
|
|
14
|
+
'• `kobo__set_workspace_status` when the mission is done / blocked / idle.',
|
|
15
|
+
'Each tool carries its own "WHEN to use" guidance in its description — follow it.',
|
|
16
|
+
].join('\n');
|
|
1
17
|
export function buildClaudeArgs(input) {
|
|
2
18
|
const args = ['--output-format', 'stream-json', '--verbose'];
|
|
3
19
|
if (input.skipPermissions)
|
|
4
20
|
args.push('--dangerously-skip-permissions');
|
|
5
21
|
let prompt = input.prompt;
|
|
22
|
+
// Only prepend the MCP brief on a fresh session — on --resume, the previous
|
|
23
|
+
// turn's context already contains it, and re-prepending would spam.
|
|
24
|
+
if (!input.resumeFromEngineSessionId) {
|
|
25
|
+
prompt = `${KOBO_MCP_BRIEF}\n\n${prompt}`;
|
|
26
|
+
}
|
|
6
27
|
if (input.permissionMode === 'plan') {
|
|
7
28
|
prompt = `[PLAN MODE] You are in PLAN/READ-ONLY mode. You MUST NOT create, edit, write, or delete any files. Only use read-only tools (Read, Grep, Glob, LS, Bash for read-only commands). Analyze the codebase, plan your approach, and present your findings — but do NOT execute any changes.\n\n${prompt}`;
|
|
8
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loicngr/kobo",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Kōbō — multi-workspace agent manager for Claude Code. Orchestrates isolated git worktrees with dev servers, Notion integration, and MCP tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.markdown-message[data-v-0ac5a3e4]{color:#e0e0e0;word-break:break-word;overflow-wrap:anywhere;min-width:0;max-width:100%;font-size:13px;line-height:1.55}.markdown-message[data-v-0ac5a3e4] *{max-width:100%}.markdown-message[data-v-0ac5a3e4] p{margin:0 0 .5em}.markdown-message[data-v-0ac5a3e4] p:last-child{margin-bottom:0}.markdown-message[data-v-0ac5a3e4] pre{background:#00000059;border-radius:4px;margin:.5em 0;padding:.5em .75em;overflow-x:auto}.markdown-message[data-v-0ac5a3e4] code{word-break:break-all;background:#0000004d;border-radius:3px;padding:.1em .3em;font-size:.9em}.markdown-message[data-v-0ac5a3e4] pre code{background:0 0;padding:0}.markdown-message[data-v-0ac5a3e4] ul,.markdown-message[data-v-0ac5a3e4] ol{margin:.25em 0 .5em;padding-left:1.5em}.markdown-message[data-v-0ac5a3e4] li{margin:.15em 0}.markdown-message[data-v-0ac5a3e4] a{color:#7986cb;text-decoration:underline}.markdown-message[data-v-0ac5a3e4] .document-link{color:#9fa8da;cursor:pointer;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.markdown-message[data-v-0ac5a3e4] .document-link:hover{color:#c5cae9;-webkit-text-decoration:underline;text-decoration:underline}.markdown-message[data-v-0ac5a3e4] h1,.markdown-message[data-v-0ac5a3e4] h2,.markdown-message[data-v-0ac5a3e4] h3,.markdown-message[data-v-0ac5a3e4] h4,.markdown-message[data-v-0ac5a3e4] h5,.markdown-message[data-v-0ac5a3e4] h6{margin:.5em 0 .3em;font-weight:600;line-height:1.3}.markdown-message[data-v-0ac5a3e4] h1{font-size:1.25em}.markdown-message[data-v-0ac5a3e4] h2{font-size:1.15em}.markdown-message[data-v-0ac5a3e4] h3{font-size:1.08em}.markdown-message[data-v-0ac5a3e4] h4,.markdown-message[data-v-0ac5a3e4] h5,.markdown-message[data-v-0ac5a3e4] h6{font-size:1em}.markdown-message[data-v-0ac5a3e4] blockquote{color:#ffffffb3;border-left:3px solid #fff3;margin:.5em 0;padding-left:.75em}.markdown-message[data-v-0ac5a3e4] table{border-collapse:collapse;margin:.5em 0}.markdown-message[data-v-0ac5a3e4] th,.markdown-message[data-v-0ac5a3e4] td{border:1px solid #ffffff26;padding:.25em .5em}.markdown-thinking[data-v-e9fb9f90] p{margin:0 0 .4em}.markdown-thinking[data-v-e9fb9f90] p:last-child{margin-bottom:0}.markdown-thinking[data-v-e9fb9f90] code{background:#ffffff14;border-radius:3px;padding:.1em .3em}.tool-row[data-v-b1ed78cb]{border-radius:4px;margin:0;font-size:12px}.tool-header[data-v-b1ed78cb]{color:#bbb;cursor:default;align-items:center;gap:10px;min-width:0;padding:5px 10px;display:flex}.tool-row:not(.tool-row-generic) .tool-header[data-v-b1ed78cb],.tool-row--toggleable .tool-header[data-v-b1ed78cb]{cursor:pointer}.tool-row:has(.tool-diff) .tool-header[data-v-b1ed78cb]{cursor:pointer}.tool-row:not(.tool-row-generic) .tool-header[data-v-b1ed78cb]:hover,.tool-row--toggleable .tool-header[data-v-b1ed78cb]:hover{background:#ffffff08}.tool-icon[data-v-b1ed78cb]{color:#9fbce0;flex-shrink:0}.tool-name[data-v-b1ed78cb]{color:#d0d0d0;flex-shrink:0;font-weight:600}.tool-arg[data-v-b1ed78cb],.tool-path[data-v-b1ed78cb]{color:#999;text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:100%;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11.5px;overflow:hidden}.tool-path[data-v-b1ed78cb],.tool-arg[data-v-b1ed78cb]{flex:1}.tool-stat-add[data-v-b1ed78cb]{color:#66bb6a;flex-shrink:0;font-size:11px;font-weight:600}.tool-stat-del[data-v-b1ed78cb]{color:#ef5350;flex-shrink:0;font-size:11px;font-weight:600}.tool-diff[data-v-b1ed78cb]{background:#0003;border-radius:4px;max-height:400px;margin-top:4px;padding:8px 0;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.5;overflow:auto}.diff-line[data-v-b1ed78cb]{white-space:pre;color:#bbb;padding:0 12px}.diff-sign[data-v-b1ed78cb]{color:#555;-webkit-user-select:none;user-select:none;width:14px;display:inline-block}.diff-add[data-v-b1ed78cb]{color:#c8e6c9;background:#66bb6a1a}.diff-add .diff-sign[data-v-b1ed78cb]{color:#66bb6a}.diff-del[data-v-b1ed78cb]{color:#ffcdd2;background:#ef53501a}.diff-del .diff-sign[data-v-b1ed78cb]{color:#ef5350}.tool-output[data-v-b1ed78cb]{color:#aaa;white-space:pre-wrap;background:#00000026;border-radius:4px;max-height:8em;margin-top:4px;padding:6px 10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:auto}.markdown-message[data-v-cb8cec0f]{color:#e0e0e0;word-break:break-word;overflow-wrap:anywhere;min-width:0;max-width:100%;font-size:13px;line-height:1.55}.markdown-message[data-v-cb8cec0f] *{max-width:100%}.markdown-message[data-v-cb8cec0f] code{word-break:break-all}.markdown-message[data-v-cb8cec0f] p{margin:0 0 .4em}.markdown-message[data-v-cb8cec0f] p:last-child{margin-bottom:0}.markdown-message[data-v-cb8cec0f] code{background:#00000040;border-radius:3px;padding:.1em .3em}.markdown-message[data-v-cb8cec0f] h1,.markdown-message[data-v-cb8cec0f] h2,.markdown-message[data-v-cb8cec0f] h3,.markdown-message[data-v-cb8cec0f] h4,.markdown-message[data-v-cb8cec0f] h5,.markdown-message[data-v-cb8cec0f] h6{margin:.4em 0 .25em;font-weight:600;line-height:1.3}.markdown-message[data-v-cb8cec0f] h1{font-size:1.25em}.markdown-message[data-v-cb8cec0f] h2{font-size:1.15em}.markdown-message[data-v-cb8cec0f] h3{font-size:1.08em}.markdown-message[data-v-cb8cec0f] h4,.markdown-message[data-v-cb8cec0f] h5,.markdown-message[data-v-cb8cec0f] h6{font-size:1em}.markdown-user-prompt[data-v-cb8cec0f]{color:#aaa;font-size:12px;font-style:italic}.markdown-user-prompt[data-v-cb8cec0f] p{margin:0 0 .4em}.markdown-user-prompt[data-v-cb8cec0f] code{background:#ffffff14;border-radius:3px;padding:.1em .3em;font-style:normal}.turn-card[data-v-8a9ce6dd]{border:1px solid #ffffff14;border-left:3px solid var(--turn-accent);background:#ffffff05;border-radius:6px;min-width:0;max-width:100%;margin:14px 0;overflow:hidden}.turn-header[data-v-8a9ce6dd]{color:#888;background:#ffffff08;border-bottom:1px solid #ffffff0d;align-items:center;gap:8px;padding:8px 14px;font-size:11px;display:flex}.turn-badge[data-v-8a9ce6dd]{letter-spacing:.3px;border-radius:3px;padding:2px 8px;font-size:11px;font-weight:700}.turn-badge-user[data-v-8a9ce6dd]{color:#ce93d8;background:#ce93d826}.turn-badge-agent[data-v-8a9ce6dd]{color:#7986cb;background:#7986cb26}.turn-badge-system[data-v-8a9ce6dd]{color:#bdbdbd;background:#75757533;font-style:italic}.turn-badge-session[data-v-8a9ce6dd]{color:#9e9e9e;background:#61616133}.turn-time[data-v-8a9ce6dd]{color:#666;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px}.turn-actions[data-v-8a9ce6dd]{color:#777;font-size:11px}.turn-body[data-v-8a9ce6dd]{flex-direction:column;gap:12px;min-width:0;padding:14px 18px;display:flex}.turn-body[data-v-8a9ce6dd]>*{min-width:0;max-width:100%}.turn-body[data-v-8a9ce6dd] .tool-row+.tool-row{margin-top:-8px}.activity-feed-wrap[data-v-51e2c6eb]{width:100%;height:100%;position:relative}.activity-feed-scroll[data-v-51e2c6eb]{width:100%;height:100%}.activity-feed-prev-btn[data-v-51e2c6eb]{z-index:2;opacity:.8;transition:opacity .12s;position:absolute;bottom:14px;right:14px}.activity-feed-prev-btn[data-v-51e2c6eb]:hover{opacity:1}.content-origin-marker[data-v-51e2c6eb]{pointer-events:none;width:0;height:0;margin:0;padding:0}.activity-feed-scroll[data-v-51e2c6eb] .q-scrollarea__content{max-width:100%;overflow-x:hidden}.activity-feed-switching[data-v-51e2c6eb]{justify-content:center;align-items:center;width:100%;height:100%;display:flex}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{E as e,F as t,H as n,L as r,M as i,Q as a,U as o,_t as s,bt as c,d as l,f as u,g as d,h as f,l as p,p as m,r as h,rt as g,u as _,v,yt as y}from"./runtime-core.esm-bundler-C3IgBgY5.js";import{L as b,l as x,t as S}from"./QIcon-B0-pH3Qs.js";import{t as C}from"./QBtn-CyzfM9-_.js";import{n as w}from"./vue-i18n-CeG0hR0Z.js";import{S as T,v as E,x as D}from"./index-9vZWx9Bu.js";import{t as O}from"./QSpinnerDots-DEiRooBD.js";import{t as k}from"./QExpansionItem-DCRks-Ra.js";import{t as A}from"./QScrollArea-e5qTqwcb.js";import{n as j,r as M,t as N}from"./documents-BJW_8dHZ.js";import{t as P}from"./_plugin-vue_export-helper-r4mAJOHR.js";function ee(e,t,n=!0){let r=[],i=new Map,a=new Map;for(let n=0;n<e.length;n++){let o=e[n],s=t?.[n];switch(o.kind){case`message:text`:{let e=i.get(o.messageId);if(e)e.text+=o.text,e.streaming=o.streaming;else{let e={type:`text`,messageId:o.messageId,text:o.text,streaming:o.streaming,ts:s};i.set(o.messageId,e),r.push(e)}break}case`message:end`:{let e=i.get(o.messageId);e&&(e.streaming=!1);break}case`message:thinking`:r.push({type:`thinking`,messageId:o.messageId,text:o.text,ts:s});break;case`tool:call`:{let e={type:`tool`,toolCallId:o.toolCallId,name:o.name,input:o.input,ts:s};a.set(o.toolCallId,e),r.push(e);break}case`tool:result`:{let e=a.get(o.toolCallId);e&&(e.result={output:o.output,isError:o.isError});break}case`session:started`:r.push({type:`session`,kind:`started`,detail:{engineSessionId:o.engineSessionId,model:o.model},ts:s});break;case`session:ended`:r.push({type:`session`,kind:`ended`,detail:{reason:o.reason,exitCode:o.exitCode},ts:s});break;case`session:compacted`:r.push({type:`session`,kind:`compacted`,ts:s});break;case`session:brainstorm-complete`:case`message:raw`:case`skills:discovered`:case`usage`:case`rate_limit`:case`subagent:progress`:case`error`:break;default:}}let o=null;for(let e of r)e.type===`text`&&e.streaming&&(o&&(o.streaming=!1),o=e);return o&&!n&&(o.streaming=!1),r}function te(e,t){if(t.length===0)return e;let n=t.map(e=>({type:`user`,content:e.content,sender:e.sender,ts:e.ts})),r=[...e,...n];r.sort((e,t)=>{let n=e.ts??``,r=t.ts??``;return n===r?0:n?r?n<r?-1:1:-1:1});let i;for(let e of r)e.type===`user`&&e.sender!==`system-prompt`&&e.ts&&(!i||e.ts>i)&&(i=e.ts);if(i)for(let e of r)e.type===`text`&&e.streaming&&(!e.ts||e.ts<i)&&(e.streaming=!1);return r}function F(e){switch(e.type){case`user`:return e.sender===`system-prompt`?`system-prompt`:`user`;case`session`:return`session`;default:return`agent`}}function ne(e){let t=[],n=null;for(let r of e){let e=F(r),i=e===`session`||e===`system-prompt`;!n||n.speaker!==e||i?(n={speaker:e,ts:r.ts,items:[r]},t.push(n),i&&(n=null)):n.items.push(r)}return t}var I={class:`text-caption text-grey-6`},L=v({__name:`SessionEventItem`,props:{item:{}},setup(e){let n=e,r=p(()=>{switch(n.item.kind){case`started`:return`session.started`;case`ended`:return`session.ended`;case`compacted`:return`session.compacted`;default:return`session.started`}});return(e,n)=>(t(),m(`span`,I,c(e.$t(r.value)),1))}});function R(e,t){if(t.length===0||e.length===0)return e;let n=[...t].sort((e,t)=>t.length-e.length),r=new DOMParser().parseFromString(`<div>${e}</div>`,`text/html`),i=r.body.firstChild;if(!i)return e;function a(e){if(e.nodeType===Node.TEXT_NODE){z(e,n,r);return}if(e.nodeName===`A`)return;let t=Array.from(e.childNodes);for(let e of t)a(e)}return a(i),i.innerHTML}function z(e,t,n){let r=e.textContent??``;if(!t.some(e=>r.includes(e)))return;let i=n.createDocumentFragment(),a=0;for(;a<r.length;){let e=B(r,a,t);if(!e){i.appendChild(n.createTextNode(r.slice(a)));break}e.index>a&&i.appendChild(n.createTextNode(r.slice(a,e.index)));let o=n.createElement(`a`);o.className=`document-link`,o.setAttribute(`data-document-path`,e.path),o.setAttribute(`href`,`#`),o.textContent=e.path,i.appendChild(o),a=e.index+e.path.length}e.parentNode?.replaceChild(i,e)}function B(e,t,n){let r=null;for(let i of n){let n=e.indexOf(i,t);n<0||(!r||n<r.index||n===r.index&&i.length>r.path.length)&&(r={index:n,path:i})}return r}var V=[`innerHTML`],H=P(v({__name:`TextMessageItem`,props:{item:{}},setup(e){let n=e,r=N(),i=E(),a=p(()=>{let e=i.selectedWorkspaceId;return e?r.documentsFor(e).map(e=>e.path):[]}),o=p(()=>{let e=R(j.parse(n.item.text,{async:!1,breaks:!0,gfm:!0}),a.value);return M.sanitize(e,{ADD_ATTR:[`data-document-path`]})});function s(e){let t=e.target?.closest(`.document-link`);if(!t)return;e.preventDefault();let n=t.getAttribute(`data-document-path`),a=i.selectedWorkspaceId;!n||!a||r.openDocumentByPath(a,n)}return(n,r)=>(t(),m(`div`,{class:`markdown-message`,onClick:s},[_(`div`,{innerHTML:o.value},null,8,V),e.item.streaming?(t(),l(x,{key:0,size:`xs`,class:`q-ml-xs`})):u(``,!0)]))}}),[[`__scopeId`,`data-v-0ac5a3e4`]]),U={key:0,class:`text-caption text-grey-5`,style:{"font-style":`italic`}},W=[`innerHTML`],G={key:1,style:{"white-space":`pre-wrap`}},K=P(v({__name:`ThinkingItem`,props:{item:{}},setup(e){let n=e,r=p(()=>n.item.text.trim().slice(0,100)),i=p(()=>n.item.text.trim().length>0),a=p(()=>n.item.text.trim().length>100),s=p(()=>{let e=j.parse(n.item.text,{async:!1,breaks:!0,gfm:!0});return M.sanitize(e)});return(n,d)=>i.value?(t(),m(`div`,U,[a.value?(t(),l(k,{key:0,dense:``,"dense-toggle":``,label:r.value,"header-class":`text-grey-5 text-caption`,style:{"font-style":`italic`}},{default:o(()=>[_(`div`,{class:`q-py-xs markdown-thinking`,innerHTML:s.value},null,8,W)]),_:1},8,[`label`])):(t(),m(`span`,G,c(e.item.text),1))])):u(``,!0)}}),[[`__scopeId`,`data-v-e9fb9f90`]]);function q(e,t){let n=e.split(`
|
|
2
|
+
`),r=t.split(`
|
|
3
|
+
`),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)n[e]===r[t]?o[e][t]=o[e+1][t+1]+1:o[e][t]=Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push({type:`context`,content:n[c]}),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push({type:`del`,content:n[c]}),c++):(s.push({type:`add`,content:r[l]}),l++);for(;c<i;)s.push({type:`del`,content:n[c++]});for(;l<a;)s.push({type:`add`,content:r[l++]});return s}function J(e,t){if(!t||typeof t!=`object`)return null;let n=t;if(e===`Edit`){let e=n.file_path;if(!e)return null;let t=n.old_string??``,r=n.new_string??``;return{toolName:`Edit`,filePath:e,oldString:t,newString:r,replaceAll:n.replace_all??!1,additions:r?r.split(`
|
|
4
|
+
`).length:0,deletions:t?t.split(`
|
|
5
|
+
`).length:0}}if(e===`Write`){let e=n.file_path;if(!e)return null;let t=n.content??``;return{toolName:`Write`,filePath:e,content:t,additions:t?t.split(`
|
|
6
|
+
`).length:0,deletions:0}}if(e===`Bash`){let e=(n.command??``).match(/^\s*rm\s+(?:-[a-zA-Z]*\s+)*(.+)/);if(e)return{toolName:`Bash:rm`,filePath:e[1].trim().replace(/["']/g,``),additions:0,deletions:1}}return null}function Y(e,t){if(!e||!t?.projectPath)return e;let n=X(e,`${t.projectPath}/.worktrees/${t.workingBranch}`);return n===e&&(n=X(e,t.projectPath)),n}function X(e,t){if(!t)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(RegExp(`${n}/`,`g`),``).replace(RegExp(`${n}(?=\\s|$|["'\`])`,`g`),`.`)}var re={class:`tool-name`},ie=[`title`],ae={key:0,class:`tool-stat-add`},oe={key:1,class:`tool-stat-del`},se={class:`diff-sign`},ce={class:`tool-name`},le=[`title`],ue=P(v({__name:`ToolCallItem`,props:{item:{}},setup(e){let i=e,o=a(!1),g=E(),v=p(()=>J(i.item.name,i.item.input)),y=p(()=>v.value?Y(v.value.filePath,g.selectedWorkspace):``),x={Bash:`terminal`,Read:`description`,Edit:`edit`,Write:`edit_note`,MultiEdit:`edit`,Glob:`folder_open`,Grep:`manage_search`,LS:`list`,Skill:`auto_awesome`,Task:`hub`,Agent:`hub`,TodoWrite:`checklist`,TodoRead:`checklist`,ToolSearch:`search`,WebFetch:`public`,WebSearch:`travel_explore`,NotebookRead:`book`,NotebookEdit:`edit_note`,SendMessage:`send`,ExitPlanMode:`check_circle_outline`,KillShell:`stop_circle`,BashOutput:`terminal`},C=p(()=>x[i.item.name]??`build`),w=p(()=>{if(v.value)return``;let e=i.item.input,t=T(e);return t?Y(t,g.selectedWorkspace):``});function T(e){if(!e||typeof e!=`object`)return typeof e==`string`?e:``;let t=e;for(let e of[`file_path`,`path`,`command`,`pattern`,`query`,`url`,`skill`,`description`,`subject`,`prompt`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return e;return``}let D=p(()=>{let e=v.value;return e?e.toolName===`Edit`&&e.oldString!==void 0&&e.newString!==void 0?q(e.oldString,e.newString):e.toolName===`Write`&&e.content!==void 0?e.content.split(`
|
|
7
|
+
`).map(e=>({type:`add`,content:e})):e.toolName===`Bash:rm`?[{type:`del`,content:`File deleted`}]:null:null}),O=p(()=>{let e=i.item.result;if(!e)return``;if(typeof e.output==`string`)return e.output;try{return JSON.stringify(e.output)}catch{return String(e.output)}}),k=new Set([`Read`]),A=p(()=>!!(i.item.result&&O.value)&&(!k.has(i.item.name)||i.item.result?.isError===!0));function j(){o.value=!o.value}return n(()=>i.item.result?.isError===!0,e=>{e&&(o.value=!0)},{immediate:!0}),(n,i)=>v.value?(t(),m(`div`,{key:0,class:s([`tool-row`,{"tool-row-expanded":o.value}])},[_(`div`,{class:`tool-header`,onClick:j},[d(S,{name:C.value,size:`14px`,class:`tool-icon`},null,8,[`name`]),_(`span`,re,c(v.value.toolName===`Bash:rm`?`Bash`:v.value.toolName),1),_(`span`,{class:`tool-path`,title:v.value.filePath},c(y.value),9,ie),v.value.additions>0?(t(),m(`span`,ae,`+`+c(v.value.additions),1)):u(``,!0),v.value.deletions>0?(t(),m(`span`,oe,`-`+c(v.value.deletions),1)):u(``,!0),e.item.result?.isError?(t(),l(S,{key:2,name:`error_outline`,color:`negative`,size:`xs`,class:`q-ml-xs`})):e.item.result?(t(),l(S,{key:3,name:`check`,color:`positive`,size:`xs`,class:`q-ml-xs`})):u(``,!0),d(S,{name:o.value?`expand_less`:`expand_more`,size:`xs`,class:`q-ml-auto text-grey-6`},null,8,[`name`])]),o.value&&D.value?(t(),m(`div`,{key:0,class:`tool-diff`,onClick:i[0]||=b(()=>{},[`stop`])},[(t(!0),m(h,null,r(D.value,(e,n)=>(t(),m(`div`,{key:n,class:s([`diff-line`,{"diff-del":e.type===`del`,"diff-add":e.type===`add`,"diff-context":e.type===`context`}])},[_(`span`,se,c(e.type===`del`?`-`:e.type===`add`?`+`:` `),1),f(c(e.content),1)],2))),128))])):u(``,!0)],2)):(t(),m(`div`,{key:1,class:s([`tool-row tool-row-generic`,{"tool-row-expanded":o.value,"tool-row--toggleable":A.value}])},[_(`div`,{class:`tool-header`,onClick:i[1]||=e=>A.value&&j()},[d(S,{name:C.value,size:`14px`,class:`tool-icon`},null,8,[`name`]),_(`span`,ce,c(e.item.name),1),w.value?(t(),m(`span`,{key:0,class:`tool-arg`,title:T(e.item.input)||w.value},c(w.value),9,le)):u(``,!0),e.item.result?.isError?(t(),l(S,{key:1,name:`error_outline`,color:`negative`,size:`xs`,class:`q-ml-auto`})):e.item.result?(t(),l(S,{key:2,name:`check`,color:`positive`,size:`xs`,class:`q-ml-auto`})):u(``,!0),A.value?(t(),l(S,{key:3,name:o.value?`expand_less`:`expand_more`,size:`xs`,class:`q-ml-xs text-grey-6`},null,8,[`name`])):u(``,!0)]),o.value&&A.value?(t(),m(`div`,{key:0,class:`tool-output`,onClick:i[2]||=b(()=>{},[`stop`])},c(O.value),1)):u(``,!0)],2))}}),[[`__scopeId`,`data-v-b1ed78cb`]]),de=[`innerHTML`],fe={key:1,class:`markdown-message`},pe=[`innerHTML`],me=P(v({__name:`UserMessageItem`,props:{item:{}},setup(e){let n=e,r=p(()=>n.item.sender===`system-prompt`),i=p(()=>{let e=j.parse(n.item.content,{async:!1,breaks:!0,gfm:!0});return M.sanitize(e)});return(e,n)=>r.value?(t(),l(k,{key:0,dense:``,"dense-toggle":``,label:e.$t(`chat.systemPrompt`),"header-class":`text-grey-5 text-caption`},{default:o(()=>[_(`div`,{class:`q-py-xs markdown-user-prompt`,innerHTML:i.value},null,8,de)]),_:1},8,[`label`])):(t(),m(`div`,fe,[_(`div`,{innerHTML:i.value},null,8,pe)]))}}),[[`__scopeId`,`data-v-cb8cec0f`]]),he={class:`turn-header`},ge={key:0,class:`turn-time`},_e={key:1,class:`turn-actions`},ve={class:`turn-body`},ye=P(v({__name:`TurnCard`,props:{turn:{}},setup(e){let n=e,{t:i}=w(),a=p(()=>{switch(n.turn.speaker){case`user`:return{label:i(`chat.you`),accent:`#ce93d8`,badgeClass:`turn-badge-user`};case`agent`:return{label:i(`chat.agent`),accent:`#7986cb`,badgeClass:`turn-badge-agent`};case`system-prompt`:return{label:i(`chat.systemPrompt`),accent:`#757575`,badgeClass:`turn-badge-system`};case`session`:return{label:i(`chat.session`),accent:`#616161`,badgeClass:`turn-badge-session`}}}),o=p(()=>{if(!n.turn.ts)return``;let e=new Date(n.turn.ts);return Number.isNaN(e.getTime())?``:e.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}),d=p(()=>n.turn.items.filter(e=>e.type===`tool`).length);return(n,f)=>(t(),m(`div`,{class:s([`turn-card`,{"turn-card--user":e.turn.speaker===`user`}]),style:y({"--turn-accent":a.value.accent})},[_(`div`,he,[_(`span`,{class:s([`turn-badge`,a.value.badgeClass])},c(a.value.label),3),o.value?(t(),m(`span`,ge,c(o.value),1)):u(``,!0),d.value>0?(t(),m(`span`,_e,` · `+c(g(i)(`chat.nActions`,{n:d.value})),1)):u(``,!0)]),_(`div`,ve,[(t(!0),m(h,null,r(e.turn.items,(e,n)=>(t(),m(h,{key:n},[e.type===`text`?(t(),l(H,{key:0,item:e},null,8,[`item`])):e.type===`thinking`?(t(),l(K,{key:1,item:e},null,8,[`item`])):e.type===`tool`?(t(),l(ue,{key:2,item:e},null,8,[`item`])):e.type===`user`?(t(),l(me,{key:3,item:e},null,8,[`item`])):e.type===`session`?(t(),l(L,{key:4,item:e},null,8,[`item`])):u(``,!0)],64))),128))])],6))}}),[[`__scopeId`,`data-v-8a9ce6dd`]]),be={key:0,class:`activity-feed-switching`},Z={key:1,class:`activity-feed-wrap`},xe={key:0,class:`text-center q-py-sm text-caption text-grey-6`},Se={class:`q-pa-md`},Ce={key:1,class:`q-px-md q-pb-md`},we=60,Q=200,$=200,Te=400,Ee=200,De=P(v({__name:`ActivityFeed`,props:{workspaceId:{}},setup(s){let g=s,v=T(),y=D(),b=E(),S=p(()=>(b.activityFeeds[g.workspaceId]??[]).filter(e=>e.type===`text`&&typeof e.content==`string`).map(e=>({content:e.content,sender:e.meta?.sender??`user`,ts:e.timestamp,sessionId:e.sessionId}))),w=p(()=>{let e=b.workspaces.find(e=>e.id===g.workspaceId);return e?e.status===`extracting`||e.status===`brainstorming`||e.status===`executing`:!1}),j=p(()=>{let e=te(ee(v.eventsFor(g.workspaceId),v.timestampsFor(g.workspaceId),w.value),S.value);return ne(y.showVerboseSystemMessages?e:e.filter(e=>e.type!==`session`))}),M=p(()=>y.showVerboseSystemMessages?v.eventsFor(g.workspaceId).filter(e=>e.kind===`message:raw`).map(e=>e.content):[]),N=a(null),P=!0,F=a(!1),I=!1,L=a(!0);function R(e){P=e.verticalSize-e.verticalPosition-e.verticalContainerSize<=we,I&&e.verticalPosition<=Q&&!F.value&&v.hasMoreOlderFor(g.workspaceId)&&z()}async function z(){let t=g.workspaceId,n=v.oldestIdFor(t);if(!n)return;F.value=!0;let r=Date.now();try{let r=N.value,i=r?.getScroll().verticalSize??0,a=r?.getScroll().verticalPosition??0,o=fetch(`/api/workspaces/${t}/events?before=${encodeURIComponent(n)}&limit=200`),s=new Promise(e=>setTimeout(e,$)),[c]=await Promise.all([o,s]);if(!c.ok){v.prepend(t,[],[],{oldestId:n,hasMoreOlder:!1});return}let l=await c.json(),u=l.events??[],d=u.filter(e=>e.type===`agent:event`&&e.workspaceId===t),f=u.filter(e=>e.type===`user:message`&&e.workspaceId===t),p=d.map(e=>e.payload),m=d.map(e=>e.createdAt),h=d.map(e=>e.sessionId??null),g=u.length>0?u[0].id:n;v.prepend(t,p,m,{oldestId:g,hasMoreOlder:l.hasMore,sessionIds:h});for(let e of f){let n=e.payload;typeof n.content==`string`&&b.addActivityItem(t,{id:e.id,type:`text`,content:n.content,timestamp:e.createdAt,sessionId:e.sessionId??void 0,meta:{sender:n.sender??`user`}})}if(await e(),r){let e=r.getScroll().verticalSize-i,t=Math.max(a+e,Q+50);r.setScrollPosition(`vertical`,t,0)}}catch(e){console.error(`[ActivityFeed] failed to load older events:`,e)}finally{let e=Date.now()-r,t=Math.max(0,$-e);await new Promise(e=>setTimeout(e,t+Te)),F.value=!1}}async function B(t=0){await e();let n=N.value;if(!n)return;let r=n.getScroll();n.setScrollPosition(`vertical`,r.verticalSize,t)}let V=a([]),H=a(null);function U(){let e=j.value,t=V.value,n=[];if(t.length===e.length){for(let r=0;r<e.length;r++){if(e[r].speaker!==`user`)continue;let i=t[r]?.$el;i&&n.push(i)}if(n.length>0)return n}let r=H.value?.parentElement;if(r){let e=r.querySelectorAll(`.turn-card--user`);for(let t of e)n.push(t)}return n}function W(){let e=N.value;if(!e)return null;let t=H.value;if(!t)return null;let n=e.getScroll().verticalPosition,r=t.getBoundingClientRect().top,i=null;for(let e of U()){let t=e.getBoundingClientRect().top-r;if(t<n-40)i=t;else break}return i}async function G(){let t=N.value;if(!t)return;let n=W();if(n===null)for(let t=0;t<15&&v.hasMoreOlderFor(g.workspaceId);t++){for(;F.value;)await new Promise(e=>setTimeout(e,50));if(await z(),await e(),n=W(),n!==null)break}n!==null&&t.setScrollPosition(`vertical`,Math.max(0,n-12),250)}async function K(){I=!1,await e(),await B(0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{I=!0})})}let q=p(()=>v.eventsFor(g.workspaceId).length);async function J(){L.value=!0;let e=Date.now();await new Promise(e=>setTimeout(e,Ee));let t=e+5e3;for(;q.value===0&&Date.now()<t;)await new Promise(e=>setTimeout(e,50));L.value=!1}n(L,async e=>{!e&&q.value>0&&await K()}),i(()=>{J(),q.value>0&&K()});let Y=!1;return n(q,async(e,t)=>{if(!Y&&e>0){Y=!0,await K();return}e>t&&P&&!F.value&&await B(180)}),n(()=>g.workspaceId,()=>{P=!0,Y=!1,I=!1,J(),q.value>0&&K()}),n(()=>b.selectedSessionId,async()=>{P=!0,I=!1,await K()}),n(p(()=>S.value.filter(e=>e.sender!==`system-prompt`).length),async(e,t)=>{e>t&&(P=!0,await B(180))}),(e,n)=>L.value?(t(),m(`div`,be,[d(O,{size:`40px`,color:`indigo-4`})])):(t(),m(`div`,Z,[d(A,{ref_key:`scrollRef`,ref:N,class:`activity-feed-scroll`,onScroll:R},{default:o(()=>[_(`div`,{ref_key:`contentOriginRef`,ref:H,class:`content-origin-marker`},null,512),F.value?(t(),m(`div`,xe,[d(x,{size:`sm`}),f(` `+c(e.$t(`activity.loading_older`)),1)])):u(``,!0),_(`div`,Se,[(t(!0),m(h,null,r(j.value,(e,n)=>(t(),l(ye,{key:n,ref_for:!0,ref_key:`turnRefs`,ref:V,turn:e},null,8,[`turn`]))),128))]),M.value.length?(t(),m(`div`,Ce,[d(k,{label:e.$t(`activity.raw_lines`,{n:M.value.length}),dense:``},{default:o(()=>[(t(!0),m(h,null,r(M.value,(e,n)=>(t(),m(`div`,{key:n,class:`text-caption text-grey q-pa-xs`},c(e),1))),128))]),_:1},8,[`label`])])):u(``,!0)]),_:1},512),d(C,{round:``,dense:``,unelevated:``,color:`grey-9`,"text-color":`grey-3`,icon:`arrow_upward`,size:`sm`,class:`activity-feed-prev-btn`,title:e.$t(`activity.prev_user_message`),onClick:G},null,8,[`title`])]))}}),[[`__scopeId`,`data-v-51e2c6eb`]]);export{De as default};
|