@hyperwindmill/caretaker-cli 0.22.0 → 0.23.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/dist/cli/web/scheduler/locks.d.ts +3 -3
- package/dist/cli/web/scheduler/task_roles.js +1 -1
- package/dist/cli/web/scheduler/task_strategy.js +4 -4
- package/dist/cli/web/server.d.ts.map +1 -1
- package/dist/cli/web/server.js +61 -26
- package/dist/harness/tools/builtin/task_tools.js +37 -37
- package/dist/lib/docker.d.ts +1 -1
- package/dist/lib/docker.d.ts.map +1 -1
- package/dist/lib/docker.js +2 -2
- package/dist/lib/project_slug.d.ts +29 -0
- package/dist/lib/project_slug.d.ts.map +1 -0
- package/dist/lib/project_slug.js +41 -0
- package/dist/lib/task_git.d.ts +5 -5
- package/dist/lib/task_git.d.ts.map +1 -1
- package/dist/lib/task_git.js +8 -6
- package/dist/store/db.d.ts +12 -7
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +59 -15
- package/dist/store/json.d.ts +1 -0
- package/dist/store/json.d.ts.map +1 -1
- package/dist/store/json.js +6 -1
- package/dist/webview/standalone.js +45 -19
- package/dist/webview/standalone.js.map +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative validation for project ids (slugs).
|
|
3
|
+
*
|
|
4
|
+
* Same contract as validateRepositoryUrl (lib/repo_url.ts): the webview may
|
|
5
|
+
* keep a copy of the regex for form feedback, but every write path into
|
|
6
|
+
* caretaker.json — POST /api/projects, the web server's saveConfig websocket
|
|
7
|
+
* handler, and the VSCode sidebar's saveConfig handler — must call THIS one,
|
|
8
|
+
* because clients can send any payload.
|
|
9
|
+
*
|
|
10
|
+
* The slug is embedded verbatim in docker container/image names, git ref
|
|
11
|
+
* names, and filesystem paths under ~/.caretaker/ (a trust boundary: the
|
|
12
|
+
* charset is what makes `..` and `/` unrepresentable). It must start AND end
|
|
13
|
+
* alphanumeric — the docker image reference grammar
|
|
14
|
+
* `[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*` rejects a component ending in a hyphen,
|
|
15
|
+
* so `foo-` would make `caretaker-project-foo-:latest` an invalid reference.
|
|
16
|
+
*
|
|
17
|
+
* Slugs are immutable after creation by construction: the two forms never
|
|
18
|
+
* change the id of an existing project and POST /api/projects only creates.
|
|
19
|
+
* A changed id arriving via saveConfig is indistinguishable from a
|
|
20
|
+
* delete+create, so it cannot be rejected here; the web handler additionally
|
|
21
|
+
* refuses to drop a project that still has tasks (Task 4).
|
|
22
|
+
*/
|
|
23
|
+
export declare const PROJECT_SLUG_RE: RegExp;
|
|
24
|
+
export declare function validateProjectSlug(id: string): string | null;
|
|
25
|
+
export declare function validateProjectIds(incoming: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}>): string | null;
|
|
29
|
+
//# sourceMappingURL=project_slug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project_slug.d.ts","sourceRoot":"","sources":["../../src/lib/project_slug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,eAAe,QAA2C,CAAC;AAExE,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,GAAG,IAAI,CAS/F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoritative validation for project ids (slugs).
|
|
3
|
+
*
|
|
4
|
+
* Same contract as validateRepositoryUrl (lib/repo_url.ts): the webview may
|
|
5
|
+
* keep a copy of the regex for form feedback, but every write path into
|
|
6
|
+
* caretaker.json — POST /api/projects, the web server's saveConfig websocket
|
|
7
|
+
* handler, and the VSCode sidebar's saveConfig handler — must call THIS one,
|
|
8
|
+
* because clients can send any payload.
|
|
9
|
+
*
|
|
10
|
+
* The slug is embedded verbatim in docker container/image names, git ref
|
|
11
|
+
* names, and filesystem paths under ~/.caretaker/ (a trust boundary: the
|
|
12
|
+
* charset is what makes `..` and `/` unrepresentable). It must start AND end
|
|
13
|
+
* alphanumeric — the docker image reference grammar
|
|
14
|
+
* `[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*` rejects a component ending in a hyphen,
|
|
15
|
+
* so `foo-` would make `caretaker-project-foo-:latest` an invalid reference.
|
|
16
|
+
*
|
|
17
|
+
* Slugs are immutable after creation by construction: the two forms never
|
|
18
|
+
* change the id of an existing project and POST /api/projects only creates.
|
|
19
|
+
* A changed id arriving via saveConfig is indistinguishable from a
|
|
20
|
+
* delete+create, so it cannot be rejected here; the web handler additionally
|
|
21
|
+
* refuses to drop a project that still has tasks (Task 4).
|
|
22
|
+
*/
|
|
23
|
+
export const PROJECT_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
|
|
24
|
+
export function validateProjectSlug(id) {
|
|
25
|
+
if (!PROJECT_SLUG_RE.test(id)) {
|
|
26
|
+
return 'Project id must be 1-39 characters of a-z, 0-9 and hyphens, starting and ending with a letter or digit.';
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function validateProjectIds(incoming) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
for (const p of incoming) {
|
|
33
|
+
const err = validateProjectSlug(String(p.id));
|
|
34
|
+
if (err)
|
|
35
|
+
return `Project "${p.name}": ${err}`;
|
|
36
|
+
if (seen.has(p.id))
|
|
37
|
+
return `Duplicate project id "${p.id}".`;
|
|
38
|
+
seen.add(p.id);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
package/dist/lib/task_git.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function pushBranch(worktreePath: string, branch: string, repo: {
|
|
|
6
6
|
token?: string | null;
|
|
7
7
|
}): Promise<void>;
|
|
8
8
|
export declare function projectWorkingDir(project: {
|
|
9
|
-
id:
|
|
9
|
+
id: string;
|
|
10
10
|
workingDir?: string | null;
|
|
11
11
|
repositoryUrl?: string | null;
|
|
12
12
|
}): string;
|
|
@@ -17,7 +17,7 @@ export declare function projectWorkingDir(project: {
|
|
|
17
17
|
* anything null must never be touched.
|
|
18
18
|
*/
|
|
19
19
|
export declare function managedRepoDir(project: {
|
|
20
|
-
id:
|
|
20
|
+
id: string;
|
|
21
21
|
workingDir?: string | null;
|
|
22
22
|
repositoryUrl?: string | null;
|
|
23
23
|
}): string | null;
|
|
@@ -27,7 +27,7 @@ export type ProjectRepoStatus = {
|
|
|
27
27
|
commit?: string;
|
|
28
28
|
};
|
|
29
29
|
export declare function projectRepoStatus(project: {
|
|
30
|
-
id:
|
|
30
|
+
id: string;
|
|
31
31
|
workingDir?: string | null;
|
|
32
32
|
repositoryUrl?: string | null;
|
|
33
33
|
}): Promise<ProjectRepoStatus>;
|
|
@@ -42,7 +42,7 @@ export type SyncProgress = {
|
|
|
42
42
|
* callers turn that into a blocked task / in-band error line.
|
|
43
43
|
*/
|
|
44
44
|
export declare function syncProjectRepo(project: {
|
|
45
|
-
id:
|
|
45
|
+
id: string;
|
|
46
46
|
workingDir?: string | null;
|
|
47
47
|
repositoryUrl?: string | null;
|
|
48
48
|
repositoryToken?: string | null;
|
|
@@ -56,7 +56,7 @@ export declare function syncProjectRepo(project: {
|
|
|
56
56
|
*/
|
|
57
57
|
export declare function gitCommonDir(worktreePath: string): Promise<string | null>;
|
|
58
58
|
export declare function agentDirIn(worktreePath: string, projectWorkingDir: string): Promise<string>;
|
|
59
|
-
export declare function ensureWorktree(projectWorkingDir: string,
|
|
59
|
+
export declare function ensureWorktree(projectWorkingDir: string, taskId: string, title: string, existingBranch?: string | null): Promise<{
|
|
60
60
|
branch: string;
|
|
61
61
|
worktreePath: string;
|
|
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AC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC5D,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
package/dist/lib/task_git.js
CHANGED
|
@@ -98,7 +98,7 @@ export function projectWorkingDir(project) {
|
|
|
98
98
|
// Remote-backed with no explicit dir: managed clone under the data dir.
|
|
99
99
|
// Resolved at call time (dataDir() follows CARETAKER_HOME), never persisted.
|
|
100
100
|
if ((project.repositoryUrl || '').trim())
|
|
101
|
-
return join(dataDir(), 'repos',
|
|
101
|
+
return join(dataDir(), 'repos', project.id);
|
|
102
102
|
return '';
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
@@ -218,8 +218,8 @@ function slug(title) {
|
|
|
218
218
|
.replace(/^-+|-+$/g, '')
|
|
219
219
|
.slice(0, 40) || 'task');
|
|
220
220
|
}
|
|
221
|
-
function worktreePathFor(
|
|
222
|
-
return join(dataDir(), 'worktrees',
|
|
221
|
+
function worktreePathFor(taskId) {
|
|
222
|
+
return join(dataDir(), 'worktrees', taskId); // task id is already <projectId>-<seq>
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
225
|
* Absolute git common dir for a (linked) worktree — the main repo's shared
|
|
@@ -242,10 +242,12 @@ export async function agentDirIn(worktreePath, projectWorkingDir) {
|
|
|
242
242
|
const rel = relative(repoRoot, projectWorkingDir);
|
|
243
243
|
return rel ? join(worktreePath, rel) : worktreePath;
|
|
244
244
|
}
|
|
245
|
-
export async function ensureWorktree(projectWorkingDir,
|
|
245
|
+
export async function ensureWorktree(projectWorkingDir, taskId, title, existingBranch) {
|
|
246
246
|
const repoRoot = await git(projectWorkingDir, ['rev-parse', '--show-toplevel']);
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
// The persisted branch is authoritative: re-deriving under the new id scheme
|
|
248
|
+
// would produce a different name and orphan a lost-path task's commits.
|
|
249
|
+
const branch = existingBranch || `caretaker/task-${taskId}-${slug(title)}`;
|
|
250
|
+
const worktreePath = worktreePathFor(taskId);
|
|
249
251
|
try {
|
|
250
252
|
await git(repoRoot, ['worktree', 'add', '-b', branch, worktreePath, 'HEAD']);
|
|
251
253
|
}
|
package/dist/store/db.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface ChecklistItem {
|
|
|
6
6
|
order: number;
|
|
7
7
|
}
|
|
8
8
|
export interface Project {
|
|
9
|
-
id:
|
|
9
|
+
id: string;
|
|
10
10
|
name: string;
|
|
11
11
|
description: string;
|
|
12
12
|
workingDir: string;
|
|
@@ -19,8 +19,13 @@ export interface Project {
|
|
|
19
19
|
sddEnabled?: boolean | null;
|
|
20
20
|
}
|
|
21
21
|
export interface Task {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** `<projectId>-<seq>`. OPAQUE — never parse it; projectId and seq below
|
|
23
|
+
* are the source of truth. Embedded verbatim in the worktree dir name
|
|
24
|
+
* (~/.caretaker/worktrees/<id>) and container name (caretaker-task-<id>). */
|
|
25
|
+
id: string;
|
|
26
|
+
projectId: string;
|
|
27
|
+
/** Per-project sequence number; stored, never derived from id. */
|
|
28
|
+
seq: number;
|
|
24
29
|
title: string;
|
|
25
30
|
objective: string;
|
|
26
31
|
checklist: ChecklistItem[];
|
|
@@ -48,7 +53,7 @@ export interface Task {
|
|
|
48
53
|
}
|
|
49
54
|
export interface TaskMessage {
|
|
50
55
|
id: number;
|
|
51
|
-
taskId:
|
|
56
|
+
taskId: string;
|
|
52
57
|
role: 'user' | 'assistant' | 'tool';
|
|
53
58
|
messageType: 'chat' | 'heartbeat' | 'heartbeat_live' | 'system' | 'block' | 'tool_call' | 'yield' | 'review' | 'plan';
|
|
54
59
|
content: string;
|
|
@@ -64,10 +69,10 @@ export declare function dbStoreDir(): string;
|
|
|
64
69
|
export declare function getDb(): Store;
|
|
65
70
|
export declare function tryNormalizeChecklistStatus(status: any): 'pending' | 'in_progress' | 'done' | 'skipped' | null;
|
|
66
71
|
export declare function runQuery(sql: string): Promise<any>;
|
|
67
|
-
export declare function getTaskById(id:
|
|
72
|
+
export declare function getTaskById(id: string): Promise<Task | null>;
|
|
68
73
|
export declare function saveTask(task: Task): Promise<void>;
|
|
69
|
-
export declare function createTask(task: Omit<Task, 'id' | 'createdAt' | 'updatedAt'>): Promise<Task>;
|
|
74
|
+
export declare function createTask(task: Omit<Task, 'id' | 'seq' | 'createdAt' | 'updatedAt'>): Promise<Task>;
|
|
70
75
|
export declare function addTaskMessage(msg: Omit<TaskMessage, 'id' | 'createdAt'>): Promise<TaskMessage>;
|
|
71
76
|
export declare function updateTaskMessageContent(id: number, content: string, type?: TaskMessage['messageType']): Promise<void>;
|
|
72
|
-
export declare function deleteTask(taskId:
|
|
77
|
+
export declare function deleteTask(taskId: string): Promise<void>;
|
|
73
78
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/store/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIvC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CA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AAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAgBrG;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAUf;AAID,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9D"}
|
package/dist/store/db.js
CHANGED
|
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
|
|
|
3
3
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
4
4
|
import { Store } from '@morphql/store';
|
|
5
5
|
import { FolderAdapter } from '@morphql/store/node';
|
|
6
|
+
import { loadConfig, saveConfig } from './json.js';
|
|
6
7
|
export function dataDir() {
|
|
7
8
|
return process.env.CARETAKER_HOME ?? join(homedir(), '.caretaker');
|
|
8
9
|
}
|
|
@@ -21,6 +22,25 @@ export function getDb() {
|
|
|
21
22
|
return dbInstance;
|
|
22
23
|
}
|
|
23
24
|
let queryQueue = Promise.resolve();
|
|
25
|
+
let migrationPromise = null;
|
|
26
|
+
/** One-time, idempotent rewrite of numeric ids to their string composites:
|
|
27
|
+
* project 3 → "3", task 17 in project 3 → "3-17". Chosen so every derived
|
|
28
|
+
* artifact name (worktrees/3-17, caretaker-task-3-17, repos/3) is
|
|
29
|
+
* byte-identical to what is already on disk — nothing moves. Runs as the
|
|
30
|
+
* first operation on the query queue, so every surface waits for it. */
|
|
31
|
+
async function migrateNumericIds() {
|
|
32
|
+
const store = getDb();
|
|
33
|
+
const tasks = (await store.query('SELECT * FROM tasks'));
|
|
34
|
+
const legacy = tasks.filter((t) => typeof t.id === 'number');
|
|
35
|
+
for (const t of legacy) {
|
|
36
|
+
const oldId = t.id;
|
|
37
|
+
const projectId = String(t.projectId);
|
|
38
|
+
const newId = `${projectId}-${oldId}`;
|
|
39
|
+
await store.query(`DELETE FROM tasks WHERE id = ${oldId}`);
|
|
40
|
+
await store.query(`INSERT INTO tasks ${JSON.stringify({ ...t, id: newId, projectId, seq: oldId })}`);
|
|
41
|
+
await store.query(`UPDATE task_messages SET taskId = '${newId}' WHERE taskId = ${oldId}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
export function tryNormalizeChecklistStatus(status) {
|
|
25
45
|
const s = String(status || '').trim().toLowerCase();
|
|
26
46
|
if (s === 'completed' || s === 'complete' || s === 'done') {
|
|
@@ -37,15 +57,27 @@ export function tryNormalizeChecklistStatus(status) {
|
|
|
37
57
|
}
|
|
38
58
|
return null;
|
|
39
59
|
}
|
|
60
|
+
/** Ids are validated slugs/composites; anything else never matches a record.
|
|
61
|
+
* Also keeps quotes/backslashes out of interpolated queries. */
|
|
62
|
+
function safeId(id) {
|
|
63
|
+
return /^[a-z0-9][a-z0-9-]*$/.test(id);
|
|
64
|
+
}
|
|
40
65
|
export async function runQuery(sql) {
|
|
41
|
-
|
|
66
|
+
if (!migrationPromise)
|
|
67
|
+
migrationPromise = migrateNumericIds();
|
|
68
|
+
const op = async () => {
|
|
69
|
+
await migrationPromise;
|
|
70
|
+
return getDb().query(sql);
|
|
71
|
+
};
|
|
42
72
|
const resultPromise = queryQueue.then(op);
|
|
43
73
|
queryQueue = resultPromise.catch(() => { });
|
|
44
74
|
return resultPromise;
|
|
45
75
|
}
|
|
46
76
|
export async function getTaskById(id) {
|
|
77
|
+
if (!safeId(id))
|
|
78
|
+
return null;
|
|
47
79
|
try {
|
|
48
|
-
const taskRows = (await runQuery(`SELECT * FROM tasks WHERE id = ${id}`));
|
|
80
|
+
const taskRows = (await runQuery(`SELECT * FROM tasks WHERE id = '${id}'`));
|
|
49
81
|
return taskRows[0] || null;
|
|
50
82
|
}
|
|
51
83
|
catch (err) {
|
|
@@ -53,26 +85,36 @@ export async function getTaskById(id) {
|
|
|
53
85
|
}
|
|
54
86
|
}
|
|
55
87
|
export async function saveTask(task) {
|
|
56
|
-
await runQuery(`DELETE FROM tasks WHERE id = ${task.id}`);
|
|
88
|
+
await runQuery(`DELETE FROM tasks WHERE id = '${task.id}'`);
|
|
57
89
|
await runQuery(`INSERT INTO tasks ${JSON.stringify(task)}`);
|
|
58
90
|
}
|
|
59
91
|
export async function createTask(task) {
|
|
60
|
-
|
|
92
|
+
if (!safeId(task.projectId))
|
|
93
|
+
throw new Error(`Invalid project id: ${task.projectId}`);
|
|
94
|
+
const config = await loadConfig();
|
|
95
|
+
const project = (config.projects || []).find((p) => p.id === task.projectId);
|
|
96
|
+
const existing = (await runQuery(`SELECT * FROM tasks WHERE projectId = '${task.projectId}'`));
|
|
97
|
+
const seq = Math.max(project?.nextTaskSeq ?? 0, 0, ...existing.map((t) => t.seq ?? 0)) + 1;
|
|
98
|
+
const record = {
|
|
61
99
|
...task,
|
|
62
|
-
id:
|
|
100
|
+
id: `${task.projectId}-${seq}`,
|
|
101
|
+
seq,
|
|
63
102
|
createdAt: new Date().toISOString(),
|
|
64
103
|
updatedAt: new Date().toISOString(),
|
|
65
104
|
};
|
|
66
|
-
await runQuery(`INSERT INTO tasks ${JSON.stringify(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
105
|
+
await runQuery(`INSERT INTO tasks ${JSON.stringify(record)}`);
|
|
106
|
+
if (project) {
|
|
107
|
+
// ponytail: unlocked read-modify-write on nextTaskSeq; the max() over
|
|
108
|
+
// existing seqs above heals races and stale-config rollbacks. Move the
|
|
109
|
+
// counter into the folder DB behind runQuery's queue if it ever matters.
|
|
110
|
+
project.nextTaskSeq = seq;
|
|
111
|
+
await saveConfig(config);
|
|
72
112
|
}
|
|
73
|
-
return
|
|
113
|
+
return record;
|
|
74
114
|
}
|
|
75
115
|
export async function addTaskMessage(msg) {
|
|
116
|
+
if (!safeId(msg.taskId))
|
|
117
|
+
throw new Error(`Invalid task id: ${msg.taskId}`);
|
|
76
118
|
const payload = {
|
|
77
119
|
...msg,
|
|
78
120
|
id: '$auto',
|
|
@@ -80,7 +122,7 @@ export async function addTaskMessage(msg) {
|
|
|
80
122
|
};
|
|
81
123
|
await runQuery(`INSERT INTO task_messages ${JSON.stringify(payload)}`);
|
|
82
124
|
// Find the inserted message to get its auto-increment ID
|
|
83
|
-
const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = ${msg.taskId}`));
|
|
125
|
+
const messages = (await runQuery(`SELECT * FROM task_messages WHERE taskId = '${msg.taskId}'`));
|
|
84
126
|
const created = messages[messages.length - 1];
|
|
85
127
|
if (!created) {
|
|
86
128
|
throw new Error('Failed to retrieve newly created task message');
|
|
@@ -102,6 +144,8 @@ export async function updateTaskMessageContent(id, content, type) {
|
|
|
102
144
|
// Permanently delete a task and all of its messages. Used by the delete
|
|
103
145
|
// action (real deletion from the store); archiving is a soft flag, not this.
|
|
104
146
|
export async function deleteTask(taskId) {
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
if (!safeId(taskId))
|
|
148
|
+
return;
|
|
149
|
+
await runQuery(`DELETE FROM task_messages WHERE taskId = '${taskId}'`);
|
|
150
|
+
await runQuery(`DELETE FROM tasks WHERE id = '${taskId}'`);
|
|
107
151
|
}
|
package/dist/store/json.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentConfig, CaretakerConfig, McpServersFile, PluginsFile } from '../types.js';
|
|
2
2
|
export { validateRepositoryUrl } from '../lib/repo_url.js';
|
|
3
|
+
export { validateProjectSlug, validateProjectIds, PROJECT_SLUG_RE } from '../lib/project_slug.js';
|
|
3
4
|
export declare function dataDir(): string;
|
|
4
5
|
export declare function configPath(): string;
|
|
5
6
|
export declare function agentsPath(): string;
|
package/dist/store/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/store/json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE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,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO5E"}
|
package/dist/store/json.js
CHANGED
|
@@ -7,6 +7,7 @@ import { encrypt, isEncrypted } from '../lib/encryption.js';
|
|
|
7
7
|
// persists config (web server, VSCode extension) enforces the same rule on
|
|
8
8
|
// `projects[].repositoryUrl` before calling saveConfig.
|
|
9
9
|
export { validateRepositoryUrl } from '../lib/repo_url.js';
|
|
10
|
+
export { validateProjectSlug, validateProjectIds, PROJECT_SLUG_RE } from '../lib/project_slug.js';
|
|
10
11
|
// Path accessors are resolved at call time, not import time, so test runs
|
|
11
12
|
// that share a process can switch CARETAKER_HOME between suites.
|
|
12
13
|
export function dataDir() {
|
|
@@ -80,7 +81,11 @@ async function writeJson(path, data) {
|
|
|
80
81
|
throw lastErr;
|
|
81
82
|
}
|
|
82
83
|
export async function loadConfig() {
|
|
83
|
-
|
|
84
|
+
const cfg = await readJsonOrDefault(configPath(), defaultConfig);
|
|
85
|
+
// Numeric project ids from older versions become their string slugs ("3").
|
|
86
|
+
for (const p of cfg.projects || [])
|
|
87
|
+
p.id = String(p.id);
|
|
88
|
+
return cfg;
|
|
84
89
|
}
|
|
85
90
|
export async function saveConfig(c) {
|
|
86
91
|
if (c.scheduler?.tasks) {
|
|
@@ -16455,9 +16455,11 @@ ${text}</tr>
|
|
|
16455
16455
|
|
|
16456
16456
|
// src/ProjectsTabSettings.tsx
|
|
16457
16457
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
16458
|
+
var SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
|
|
16458
16459
|
function ProjectsTabSettings({ config, agents, postMessage }) {
|
|
16459
16460
|
const [editingProject, setEditingProject] = (0, import_react9.useState)(null);
|
|
16460
16461
|
const [isCreating, setIsCreating] = (0, import_react9.useState)(false);
|
|
16462
|
+
const [slugText, setSlugText] = (0, import_react9.useState)("");
|
|
16461
16463
|
const [name, setName] = (0, import_react9.useState)("");
|
|
16462
16464
|
const [description, setDescription] = (0, import_react9.useState)("");
|
|
16463
16465
|
const [workingDir, setWorkingDir] = (0, import_react9.useState)("");
|
|
@@ -16477,6 +16479,7 @@ ${text}</tr>
|
|
|
16477
16479
|
const startEdit = (proj) => {
|
|
16478
16480
|
setEditingProject(proj);
|
|
16479
16481
|
setIsCreating(false);
|
|
16482
|
+
setSlugText(proj.id);
|
|
16480
16483
|
setName(proj.name);
|
|
16481
16484
|
setDescription(proj.description || "");
|
|
16482
16485
|
setWorkingDir(proj.workingDir);
|
|
@@ -16496,6 +16499,7 @@ ${text}</tr>
|
|
|
16496
16499
|
const startCreate = () => {
|
|
16497
16500
|
setIsCreating(true);
|
|
16498
16501
|
setEditingProject(null);
|
|
16502
|
+
setSlugText("");
|
|
16499
16503
|
setName("");
|
|
16500
16504
|
setDescription("");
|
|
16501
16505
|
setWorkingDir("");
|
|
@@ -16545,9 +16549,13 @@ ${text}</tr>
|
|
|
16545
16549
|
const trimmedDocker = dockerImage.trim();
|
|
16546
16550
|
const updatedProjects = [...projects];
|
|
16547
16551
|
if (isCreating) {
|
|
16548
|
-
const
|
|
16552
|
+
const slug = slugText.trim();
|
|
16553
|
+
if (!SLUG_RE.test(slug) || projects.some((p) => p.id === slug)) {
|
|
16554
|
+
setErrorMsg("Project id must be 1-39 chars of a-z, 0-9 and hyphens (start/end alphanumeric) and unique.");
|
|
16555
|
+
return;
|
|
16556
|
+
}
|
|
16549
16557
|
const newProj = {
|
|
16550
|
-
id:
|
|
16558
|
+
id: slug,
|
|
16551
16559
|
name: trimmedName,
|
|
16552
16560
|
description: trimmedDesc,
|
|
16553
16561
|
workingDir: trimmedDir,
|
|
@@ -16598,19 +16606,14 @@ ${text}</tr>
|
|
|
16598
16606
|
setEditingProject(null);
|
|
16599
16607
|
setErrorMsg(null);
|
|
16600
16608
|
};
|
|
16601
|
-
const deleteProject = (id) => {
|
|
16609
|
+
const deleteProject = async (id) => {
|
|
16602
16610
|
if (!confirm("Are you sure you want to delete this project? All associated tasks will be permanently removed from disk.")) return;
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
}
|
|
16610
|
-
});
|
|
16611
|
-
fetch(`/api/projects/${id}`, { method: "DELETE" }).catch((err) => {
|
|
16612
|
-
console.error("Failed to trigger database tasks cleanup on project deletion:", err);
|
|
16613
|
-
});
|
|
16611
|
+
try {
|
|
16612
|
+
await fetch(`/api/projects/${id}`, { method: "DELETE" });
|
|
16613
|
+
} catch (err) {
|
|
16614
|
+
console.error("Failed to delete project:", err);
|
|
16615
|
+
}
|
|
16616
|
+
postMessage({ type: "getSettingsData" });
|
|
16614
16617
|
};
|
|
16615
16618
|
const showForm = isCreating || editingProject !== null;
|
|
16616
16619
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "tab-pane projects-tab-settings", children: [
|
|
@@ -16626,6 +16629,31 @@ ${text}</tr>
|
|
|
16626
16629
|
showForm ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "glass-form", children: [
|
|
16627
16630
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h4", { children: isCreating ? "Register New Project" : `Edit Project: ${editingProject?.name}` }),
|
|
16628
16631
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "glass-form__body", children: [
|
|
16632
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "form-group", children: [
|
|
16633
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { htmlFor: "project-id", children: [
|
|
16634
|
+
"Project ID ",
|
|
16635
|
+
isCreating && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: { opacity: 0.6 }, children: "(slug: a-z, 0-9, hyphens)" })
|
|
16636
|
+
] }),
|
|
16637
|
+
isCreating ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
16638
|
+
"input",
|
|
16639
|
+
{
|
|
16640
|
+
id: "project-id",
|
|
16641
|
+
type: "text",
|
|
16642
|
+
placeholder: "e.g. backend-service",
|
|
16643
|
+
value: slugText,
|
|
16644
|
+
onChange: (e) => setSlugText(e.target.value.toLowerCase())
|
|
16645
|
+
}
|
|
16646
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
16647
|
+
"input",
|
|
16648
|
+
{
|
|
16649
|
+
id: "project-id",
|
|
16650
|
+
type: "text",
|
|
16651
|
+
value: editingProject?.id || "",
|
|
16652
|
+
disabled: true,
|
|
16653
|
+
style: { opacity: 0.7, cursor: "not-allowed" }
|
|
16654
|
+
}
|
|
16655
|
+
)
|
|
16656
|
+
] }),
|
|
16629
16657
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "form-group", children: [
|
|
16630
16658
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: "project-name", children: "Project Name" }),
|
|
16631
16659
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -19928,9 +19956,7 @@ ${text}</tr>
|
|
|
19928
19956
|
function loadSavedProjectId() {
|
|
19929
19957
|
try {
|
|
19930
19958
|
const raw = localStorage.getItem(LS_PROJECT_KEY);
|
|
19931
|
-
|
|
19932
|
-
const n = Number(raw);
|
|
19933
|
-
return Number.isFinite(n) ? n : null;
|
|
19959
|
+
return raw && raw.trim() ? raw.trim() : null;
|
|
19934
19960
|
} catch {
|
|
19935
19961
|
return null;
|
|
19936
19962
|
}
|
|
@@ -19938,7 +19964,7 @@ ${text}</tr>
|
|
|
19938
19964
|
function saveProjectId(id) {
|
|
19939
19965
|
try {
|
|
19940
19966
|
if (id === null) localStorage.removeItem(LS_PROJECT_KEY);
|
|
19941
|
-
else localStorage.setItem(LS_PROJECT_KEY,
|
|
19967
|
+
else localStorage.setItem(LS_PROJECT_KEY, id);
|
|
19942
19968
|
} catch {
|
|
19943
19969
|
}
|
|
19944
19970
|
}
|
|
@@ -20743,7 +20769,7 @@ ${msg.content}`, streaming: false, label: msg.agentLabel || labels?.reviewer });
|
|
|
20743
20769
|
{
|
|
20744
20770
|
className: "task-view__project-filter",
|
|
20745
20771
|
value: selectedProjectId ?? void 0,
|
|
20746
|
-
onChange: (e) => onProjectChange(
|
|
20772
|
+
onChange: (e) => onProjectChange(e.target.value),
|
|
20747
20773
|
style: {
|
|
20748
20774
|
background: "var(--vscode-input-background, #252526)",
|
|
20749
20775
|
color: "var(--vscode-input-foreground)",
|