@compilr-dev/sdk 0.10.25 → 0.10.27
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/presets/coding.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { readFileTool, writeFileTool, editTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, createTodoTools, getDefaultTodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
|
|
5
5
|
import { allCodingTools, unifiedTools, ts, python, go } from '@compilr-dev/agents-coding';
|
|
6
|
-
import { createLenientTodoWriteTool } from './lenient-todo.js';
|
|
6
|
+
import { createLenientTodoWriteTool, createLenientTodoClaimTool, createLenientTodoHandoffTool, } from './lenient-todo.js';
|
|
7
7
|
const CODING_SYSTEM_PROMPT = `You are a skilled software engineer. You help users with coding tasks including:
|
|
8
8
|
- Writing, reviewing, and debugging code
|
|
9
9
|
- Understanding codebases and architecture
|
|
@@ -43,16 +43,19 @@ export const webTools = [webFetchTool];
|
|
|
43
43
|
* key aliases (title/description/task → content) so todos don't silently
|
|
44
44
|
* drop when the LLM picks the wrong key.
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const todoStore = getDefaultTodoStore();
|
|
47
|
+
const todoTools = createTodoTools(todoStore);
|
|
48
|
+
const lenientTodoWrite = createLenientTodoWriteTool(todoTools.todoWrite, todoStore);
|
|
49
|
+
const lenientTodoClaim = createLenientTodoClaimTool(todoTools.todoClaim, todoStore);
|
|
50
|
+
const lenientTodoHandoff = createLenientTodoHandoffTool(todoTools.todoHandoff, todoStore);
|
|
48
51
|
/**
|
|
49
52
|
* Utility tools (always included in coding preset)
|
|
50
53
|
*/
|
|
51
54
|
const utilityTools = [
|
|
52
55
|
lenientTodoWrite,
|
|
53
56
|
todoTools.todoRead,
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
lenientTodoClaim,
|
|
58
|
+
lenientTodoHandoff,
|
|
56
59
|
suggestTool,
|
|
57
60
|
];
|
|
58
61
|
/**
|
package/dist/presets/general.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* in the ProjectTypeConfig, not from the preset.
|
|
7
7
|
*/
|
|
8
8
|
import { readFileTool, writeFileTool, editTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, createTodoTools, getDefaultTodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
|
|
9
|
-
import { createLenientTodoWriteTool } from './lenient-todo.js';
|
|
9
|
+
import { createLenientTodoWriteTool, createLenientTodoClaimTool, createLenientTodoHandoffTool, } from './lenient-todo.js';
|
|
10
10
|
const GENERAL_SYSTEM_PROMPT = `You are a versatile AI assistant. You adapt your approach to the user's needs and project context.
|
|
11
11
|
|
|
12
12
|
You help users with a wide range of tasks including research, writing, analysis, planning, and problem solving.
|
|
@@ -22,8 +22,11 @@ Guidelines:
|
|
|
22
22
|
// to TODO-9 — see audit doc. The lenient wrapper normalises agent-input
|
|
23
23
|
// key aliases (title/description/task → content) so todos don't silently
|
|
24
24
|
// drop when the LLM picks the wrong key.
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const todoStore = getDefaultTodoStore();
|
|
26
|
+
const todoTools = createTodoTools(todoStore);
|
|
27
|
+
const lenientTodoWrite = createLenientTodoWriteTool(todoTools.todoWrite, todoStore);
|
|
28
|
+
const lenientTodoClaim = createLenientTodoClaimTool(todoTools.todoClaim, todoStore);
|
|
29
|
+
const lenientTodoHandoff = createLenientTodoHandoffTool(todoTools.todoHandoff, todoStore);
|
|
27
30
|
export const generalPreset = {
|
|
28
31
|
name: 'general',
|
|
29
32
|
systemPrompt: GENERAL_SYSTEM_PROMPT,
|
|
@@ -38,8 +41,8 @@ export const generalPreset = {
|
|
|
38
41
|
globTool,
|
|
39
42
|
lenientTodoWrite,
|
|
40
43
|
todoTools.todoRead,
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
lenientTodoClaim,
|
|
45
|
+
lenientTodoHandoff,
|
|
43
46
|
webFetchTool,
|
|
44
47
|
suggestTool,
|
|
45
48
|
],
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Spec ref: project-docs/00-requirements/compilr-dev-sdk/architecture-audit-cli-vs-desktop.md
|
|
19
19
|
* TODO-9.
|
|
20
20
|
*/
|
|
21
|
-
import { type Tool } from '@compilr-dev/agents';
|
|
21
|
+
import { type Tool, type TodoStore } from '@compilr-dev/agents';
|
|
22
22
|
interface LenientTodoInput {
|
|
23
23
|
todos: Array<{
|
|
24
24
|
content?: string;
|
|
@@ -44,12 +44,49 @@ interface StrictTodoInput {
|
|
|
44
44
|
}>;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Wrap a strict `todo_write` tool with input-key normalisation
|
|
47
|
+
* Wrap a strict `todo_write` tool with input-key normalisation AND
|
|
48
|
+
* response enrichment.
|
|
48
49
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* Two improvements over the strict tool:
|
|
51
|
+
*
|
|
52
|
+
* 1. **Input normalisation**: accepts alternative property aliases LLMs
|
|
53
|
+
* commonly emit (`title`, `description`, `task`, `text` → `content`).
|
|
54
|
+
* Prevents silent todo drops when the LLM picks the wrong key.
|
|
55
|
+
*
|
|
56
|
+
* 2. **Response enrichment**: after writing, returns the full todo list
|
|
57
|
+
* *with ids* so subsequent `todo_claim` / `todo_handoff` calls have
|
|
58
|
+
* the right `todoId` without needing an extra `todo_read` round trip.
|
|
59
|
+
* Per agent feedback: "if todo_write returned the ids, that would
|
|
60
|
+
* streamline the process."
|
|
61
|
+
*
|
|
62
|
+
* Pass the `todoWrite` from `createTodoTools(store)` and the same store
|
|
63
|
+
* instance — the wrapper reads the store after writing to surface ids.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createLenientTodoWriteTool(strictTool: Tool<StrictTodoInput>, store: TodoStore): Tool<LenientTodoInput>;
|
|
66
|
+
interface LenientTodoClaimInput {
|
|
67
|
+
todoId: string | number;
|
|
68
|
+
agentId: string;
|
|
69
|
+
}
|
|
70
|
+
interface StrictTodoClaimInput {
|
|
71
|
+
todoId: string;
|
|
72
|
+
agentId: string;
|
|
73
|
+
}
|
|
74
|
+
interface LenientTodoHandoffInput {
|
|
75
|
+
todoId: string | number;
|
|
76
|
+
toAgentId: string;
|
|
77
|
+
notes?: string;
|
|
78
|
+
}
|
|
79
|
+
interface StrictTodoHandoffInput {
|
|
80
|
+
todoId: string;
|
|
81
|
+
toAgentId: string;
|
|
82
|
+
notes?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Wrap a strict `todo_claim` tool with todoId normalisation.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createLenientTodoClaimTool(strictTool: Tool<StrictTodoClaimInput>, store: TodoStore): Tool<LenientTodoClaimInput>;
|
|
88
|
+
/**
|
|
89
|
+
* Wrap a strict `todo_handoff` tool with todoId normalisation.
|
|
53
90
|
*/
|
|
54
|
-
export declare function
|
|
91
|
+
export declare function createLenientTodoHandoffTool(strictTool: Tool<StrictTodoHandoffInput>, store: TodoStore): Tool<LenientTodoHandoffInput>;
|
|
55
92
|
export {};
|
|
@@ -18,19 +18,31 @@
|
|
|
18
18
|
* Spec ref: project-docs/00-requirements/compilr-dev-sdk/architecture-audit-cli-vs-desktop.md
|
|
19
19
|
* TODO-9.
|
|
20
20
|
*/
|
|
21
|
-
import { defineTool } from '@compilr-dev/agents';
|
|
21
|
+
import { defineTool, } from '@compilr-dev/agents';
|
|
22
22
|
/**
|
|
23
|
-
* Wrap a strict `todo_write` tool with input-key normalisation
|
|
23
|
+
* Wrap a strict `todo_write` tool with input-key normalisation AND
|
|
24
|
+
* response enrichment.
|
|
24
25
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Two improvements over the strict tool:
|
|
27
|
+
*
|
|
28
|
+
* 1. **Input normalisation**: accepts alternative property aliases LLMs
|
|
29
|
+
* commonly emit (`title`, `description`, `task`, `text` → `content`).
|
|
30
|
+
* Prevents silent todo drops when the LLM picks the wrong key.
|
|
31
|
+
*
|
|
32
|
+
* 2. **Response enrichment**: after writing, returns the full todo list
|
|
33
|
+
* *with ids* so subsequent `todo_claim` / `todo_handoff` calls have
|
|
34
|
+
* the right `todoId` without needing an extra `todo_read` round trip.
|
|
35
|
+
* Per agent feedback: "if todo_write returned the ids, that would
|
|
36
|
+
* streamline the process."
|
|
37
|
+
*
|
|
38
|
+
* Pass the `todoWrite` from `createTodoTools(store)` and the same store
|
|
39
|
+
* instance — the wrapper reads the store after writing to surface ids.
|
|
29
40
|
*/
|
|
30
|
-
export function createLenientTodoWriteTool(strictTool) {
|
|
41
|
+
export function createLenientTodoWriteTool(strictTool, store) {
|
|
31
42
|
return defineTool({
|
|
32
43
|
name: 'todo_write',
|
|
33
|
-
description: strictTool.definition.description
|
|
44
|
+
description: `${strictTool.definition.description} ` +
|
|
45
|
+
'Returns the resulting todo list with ids — use those ids for any subsequent todo_claim / todo_handoff calls.',
|
|
34
46
|
inputSchema: strictTool.definition.inputSchema,
|
|
35
47
|
execute: async (input) => {
|
|
36
48
|
// Normalise — accept alternative property names that LLMs commonly emit.
|
|
@@ -53,7 +65,112 @@ export function createLenientTodoWriteTool(strictTool) {
|
|
|
53
65
|
...todo,
|
|
54
66
|
content: todo.content || 'Untitled task',
|
|
55
67
|
}));
|
|
56
|
-
|
|
68
|
+
const result = await strictTool.execute({ todos: valid });
|
|
69
|
+
// Enrich the success result with the actual stored todos (incl. ids)
|
|
70
|
+
// so the LLM has them in context immediately — no todo_read needed.
|
|
71
|
+
if (result.success) {
|
|
72
|
+
const todos = store.getAll().map((t) => ({
|
|
73
|
+
id: t.id,
|
|
74
|
+
content: t.content,
|
|
75
|
+
status: t.status,
|
|
76
|
+
owner: t.owner,
|
|
77
|
+
activeForm: t.activeForm,
|
|
78
|
+
priority: t.priority,
|
|
79
|
+
}));
|
|
80
|
+
const inner = result.result && typeof result.result === 'object'
|
|
81
|
+
? result.result
|
|
82
|
+
: {};
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
result: { ...inner, todos },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolve a lenient todoId reference to a concrete store key.
|
|
94
|
+
* Returns null if no plausible match exists.
|
|
95
|
+
*
|
|
96
|
+
* Strategy intentionally narrow — only unambiguous one-to-one mappings.
|
|
97
|
+
* No content/prefix/substring matching: fuzzy resolution risks silent
|
|
98
|
+
* wrong matches in edge cases (e.g. "Fix login" matching the wrong of
|
|
99
|
+
* two similar todos). The agent should either pass the full id from a
|
|
100
|
+
* prior `todo_write` / `todo_read` response, or use the numeric position
|
|
101
|
+
* shown in the footer. Anything else gets a clear error listing the
|
|
102
|
+
* available ids, which the agent can recover from in one extra call.
|
|
103
|
+
*/
|
|
104
|
+
function resolveTodoId(rawId, store) {
|
|
105
|
+
const ids = store.getAll().map((t) => t.id);
|
|
106
|
+
const id = String(rawId).trim();
|
|
107
|
+
// Direct match — handles "todo-1" as-is.
|
|
108
|
+
if (ids.includes(id))
|
|
109
|
+
return id;
|
|
110
|
+
// Bare positional reference: "1" or 1 → "todo-1". Matches the footer's
|
|
111
|
+
// "#1 ☐ task" rendering.
|
|
112
|
+
if (/^\d+$/.test(id)) {
|
|
113
|
+
const candidate = `todo-${id}`;
|
|
114
|
+
if (ids.includes(candidate))
|
|
115
|
+
return candidate;
|
|
116
|
+
}
|
|
117
|
+
// "todo_1" variant — LLMs sometimes use underscores.
|
|
118
|
+
const underscoreToHyphen = id.replace(/^todo_/, 'todo-');
|
|
119
|
+
if (ids.includes(underscoreToHyphen))
|
|
120
|
+
return underscoreToHyphen;
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Wrap a strict `todo_claim` tool with todoId normalisation.
|
|
125
|
+
*/
|
|
126
|
+
export function createLenientTodoClaimTool(strictTool, store) {
|
|
127
|
+
return defineTool({
|
|
128
|
+
name: 'todo_claim',
|
|
129
|
+
description: `${strictTool.definition.description} ` +
|
|
130
|
+
'The todoId can be the full id ("todo-1"), a positional number ("1"), or a content prefix.',
|
|
131
|
+
inputSchema: strictTool.definition.inputSchema,
|
|
132
|
+
execute: async (input) => {
|
|
133
|
+
const resolved = resolveTodoId(input.todoId, store);
|
|
134
|
+
if (!resolved) {
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
error: `Todo "${String(input.todoId)}" not found. ` +
|
|
138
|
+
`Available ids: ${store
|
|
139
|
+
.getAll()
|
|
140
|
+
.map((t) => t.id)
|
|
141
|
+
.join(', ') || '(none)'}.`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return strictTool.execute({ todoId: resolved, agentId: input.agentId });
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Wrap a strict `todo_handoff` tool with todoId normalisation.
|
|
150
|
+
*/
|
|
151
|
+
export function createLenientTodoHandoffTool(strictTool, store) {
|
|
152
|
+
return defineTool({
|
|
153
|
+
name: 'todo_handoff',
|
|
154
|
+
description: `${strictTool.definition.description} ` +
|
|
155
|
+
'The todoId can be the full id ("todo-1"), a positional number ("1"), or a content prefix.',
|
|
156
|
+
inputSchema: strictTool.definition.inputSchema,
|
|
157
|
+
execute: async (input) => {
|
|
158
|
+
const resolved = resolveTodoId(input.todoId, store);
|
|
159
|
+
if (!resolved) {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: `Todo "${String(input.todoId)}" not found. ` +
|
|
163
|
+
`Available ids: ${store
|
|
164
|
+
.getAll()
|
|
165
|
+
.map((t) => t.id)
|
|
166
|
+
.join(', ') || '(none)'}.`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return strictTool.execute({
|
|
170
|
+
todoId: resolved,
|
|
171
|
+
toAgentId: input.toAgentId,
|
|
172
|
+
notes: input.notes,
|
|
173
|
+
});
|
|
57
174
|
},
|
|
58
175
|
});
|
|
59
176
|
}
|