@compilr-dev/sdk 0.9.15 → 0.9.16
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/capabilities/packs.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/system-prompt/modules.js +1 -1
- package/dist/team/skill-requirements.js +2 -2
- package/dist/team/tool-config.js +2 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/propose-alternatives-tool.d.ts +64 -0
- package/dist/tools/propose-alternatives-tool.js +128 -0
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ export const CAPABILITY_PACKS = {
|
|
|
53
53
|
interaction: {
|
|
54
54
|
id: 'interaction',
|
|
55
55
|
label: 'User Interaction',
|
|
56
|
-
tools: ['ask_user', 'ask_user_simple', 'suggest'],
|
|
56
|
+
tools: ['ask_user', 'ask_user_simple', 'propose_alternatives', 'suggest'],
|
|
57
57
|
readOnly: true,
|
|
58
58
|
promptModules: [],
|
|
59
59
|
estimatedPromptTokens: 0,
|
package/dist/index.d.ts
CHANGED
|
@@ -56,8 +56,8 @@ export type { SystemPromptContext, BuildResult, SystemPromptModule, ModuleCondit
|
|
|
56
56
|
export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, WorkItemComment, CreateCommentInput, UpdateCommentInput, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository, IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
|
|
57
57
|
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
|
|
58
58
|
export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './platform/index.js';
|
|
59
|
-
export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
|
|
60
|
-
export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './tools/index.js';
|
|
59
|
+
export { createAskUserTool, createAskUserSimpleTool, createProposeAlternativesTool } from './tools/index.js';
|
|
60
|
+
export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, Alternative, ProposeAlternativesInput, ProposeAlternativesResult, ProposeAlternativesHandler, } from './tools/index.js';
|
|
61
61
|
export { detectProject, suggestProjectType, detectCommon } from './detection/index.js';
|
|
62
62
|
export type { DetectProjectOptions, DetectionResult, ContentSummary } from './detection/index.js';
|
|
63
63
|
export { createGuideTool, SHARED_GUIDE_ENTRIES, searchGuideEntries, topicToGuideEntry, } from './guide/index.js';
|
package/dist/index.js
CHANGED
|
@@ -131,7 +131,7 @@ export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemReposi
|
|
|
131
131
|
// =============================================================================
|
|
132
132
|
// User Interaction Tools (ask_user, ask_user_simple)
|
|
133
133
|
// =============================================================================
|
|
134
|
-
export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
|
|
134
|
+
export { createAskUserTool, createAskUserSimpleTool, createProposeAlternativesTool } from './tools/index.js';
|
|
135
135
|
// =============================================================================
|
|
136
136
|
// Project Detection (universal project content detection)
|
|
137
137
|
// =============================================================================
|
|
@@ -140,7 +140,7 @@ IMPORTANT: Tool names are lowercase with underscores.
|
|
|
140
140
|
- **File operations**: read_file, write_file, edit, glob, grep
|
|
141
141
|
- **Shell**: bash (use run_in_background=true for long-running), bash_output, kill_shell
|
|
142
142
|
- **Task management**: todo_write, todo_read
|
|
143
|
-
- **User interaction**: ask_user, ask_user_simple
|
|
143
|
+
- **User interaction**: ask_user, ask_user_simple, propose_alternatives (present 2-3 options for comparison)
|
|
144
144
|
- **Sub-agents**: task (types: explore, code-review, plan, debug, test-runner, refactor, security-audit, general)`,
|
|
145
145
|
};
|
|
146
146
|
/**
|
|
@@ -51,7 +51,7 @@ export const SKILL_REQUIREMENTS = {
|
|
|
51
51
|
},
|
|
52
52
|
design: {
|
|
53
53
|
required: ['ask_user', 'workitem_add'],
|
|
54
|
-
optional: ['detect_project', 'document_save', 'edit'],
|
|
54
|
+
optional: ['propose_alternatives', 'detect_project', 'document_save', 'edit'],
|
|
55
55
|
reason: 'Needs to gather requirements and create backlog',
|
|
56
56
|
},
|
|
57
57
|
refine: {
|
|
@@ -72,7 +72,7 @@ export const SKILL_REQUIREMENTS = {
|
|
|
72
72
|
// Documentation skills
|
|
73
73
|
architecture: {
|
|
74
74
|
required: ['read_file', 'write_file', 'edit'],
|
|
75
|
-
optional: ['backlog_read', 'ask_user', 'glob'],
|
|
75
|
+
optional: ['backlog_read', 'ask_user', 'propose_alternatives', 'glob'],
|
|
76
76
|
reason: 'Creates architecture documents',
|
|
77
77
|
},
|
|
78
78
|
prd: {
|
package/dist/team/tool-config.js
CHANGED
|
@@ -21,6 +21,7 @@ const TOOL_NAMES = {
|
|
|
21
21
|
// User interaction
|
|
22
22
|
ASK_USER: 'ask_user',
|
|
23
23
|
ASK_USER_SIMPLE: 'ask_user_simple',
|
|
24
|
+
PROPOSE_ALTERNATIVES: 'propose_alternatives',
|
|
24
25
|
// Delegation
|
|
25
26
|
DELEGATE: 'delegate',
|
|
26
27
|
DELEGATE_BACKGROUND: 'delegate_background',
|
|
@@ -147,7 +148,7 @@ export const TOOL_GROUPS = {
|
|
|
147
148
|
},
|
|
148
149
|
interaction: {
|
|
149
150
|
label: 'User Interaction',
|
|
150
|
-
tools: [TOOL_NAMES.ASK_USER, TOOL_NAMES.ASK_USER_SIMPLE, TOOL_NAMES.SUGGEST],
|
|
151
|
+
tools: [TOOL_NAMES.ASK_USER, TOOL_NAMES.ASK_USER_SIMPLE, TOOL_NAMES.PROPOSE_ALTERNATIVES, TOOL_NAMES.SUGGEST],
|
|
151
152
|
readOnly: true,
|
|
152
153
|
tier: 'direct',
|
|
153
154
|
},
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@
|
|
|
5
5
|
* The SDK defines schemas and types; consumers provide the UI.
|
|
6
6
|
*/
|
|
7
7
|
export { createAskUserTool, createAskUserSimpleTool } from './ask-user-tools.js';
|
|
8
|
+
export { createProposeAlternativesTool } from './propose-alternatives-tool.js';
|
|
8
9
|
export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './ask-user-tools.js';
|
|
10
|
+
export type { Alternative, ProposeAlternativesInput, ProposeAlternativesResult, ProposeAlternativesHandler, } from './propose-alternatives-tool.js';
|
package/dist/tools/index.js
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propose Alternatives Tool — Present 2-3 options for the user to compare and choose.
|
|
3
|
+
*
|
|
4
|
+
* Unlike ask_user (open-ended questions), this tool presents concrete alternatives
|
|
5
|
+
* with rich previews (code, markdown, mermaid) for side-by-side comparison.
|
|
6
|
+
*
|
|
7
|
+
* Factory pattern: the consumer (CLI, desktop) provides a handler callback that
|
|
8
|
+
* implements the UI. The SDK defines the tool schema and types.
|
|
9
|
+
*/
|
|
10
|
+
import type { Tool } from '@compilr-dev/agents';
|
|
11
|
+
/** A single alternative to present */
|
|
12
|
+
export interface Alternative {
|
|
13
|
+
/** Short title: "Card Layout", "REST API" */
|
|
14
|
+
title: string;
|
|
15
|
+
/** 1-2 sentence explanation */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Optional rich content for preview */
|
|
18
|
+
content?: string;
|
|
19
|
+
/** Content format for rendering */
|
|
20
|
+
contentType?: 'markdown' | 'code' | 'mermaid';
|
|
21
|
+
/** Language hint for code syntax highlighting (e.g., 'typescript', 'html') */
|
|
22
|
+
language?: string;
|
|
23
|
+
/** Pros of this alternative */
|
|
24
|
+
pros?: string[];
|
|
25
|
+
/** Cons of this alternative */
|
|
26
|
+
cons?: string[];
|
|
27
|
+
}
|
|
28
|
+
/** Input parameters for propose_alternatives tool */
|
|
29
|
+
export interface ProposeAlternativesInput {
|
|
30
|
+
/** What decision is being made */
|
|
31
|
+
question: string;
|
|
32
|
+
/** Optional context paragraph */
|
|
33
|
+
context?: string;
|
|
34
|
+
/** 2-3 alternatives to present */
|
|
35
|
+
alternatives: Alternative[];
|
|
36
|
+
}
|
|
37
|
+
/** Result from propose_alternatives tool */
|
|
38
|
+
export interface ProposeAlternativesResult {
|
|
39
|
+
/** 0-based index of chosen alternative */
|
|
40
|
+
chosenIndex: number;
|
|
41
|
+
/** Title of chosen alternative */
|
|
42
|
+
chosenTitle: string;
|
|
43
|
+
/** Optional user notes */
|
|
44
|
+
notes?: string;
|
|
45
|
+
/** User rejected all alternatives */
|
|
46
|
+
rejected: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handler callback for propose_alternatives tool.
|
|
50
|
+
* The consumer provides the UI implementation.
|
|
51
|
+
*/
|
|
52
|
+
export type ProposeAlternativesHandler = (input: ProposeAlternativesInput) => Promise<ProposeAlternativesResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a propose_alternatives tool with a custom UI handler.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const tool = createProposeAlternativesTool(async (input) => {
|
|
59
|
+
* // Show side-by-side dialog, wait for user choice
|
|
60
|
+
* return { chosenIndex: 0, chosenTitle: input.alternatives[0].title, rejected: false };
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createProposeAlternativesTool(handler: ProposeAlternativesHandler): Tool<ProposeAlternativesInput>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propose Alternatives Tool — Present 2-3 options for the user to compare and choose.
|
|
3
|
+
*
|
|
4
|
+
* Unlike ask_user (open-ended questions), this tool presents concrete alternatives
|
|
5
|
+
* with rich previews (code, markdown, mermaid) for side-by-side comparison.
|
|
6
|
+
*
|
|
7
|
+
* Factory pattern: the consumer (CLI, desktop) provides a handler callback that
|
|
8
|
+
* implements the UI. The SDK defines the tool schema and types.
|
|
9
|
+
*/
|
|
10
|
+
import { defineTool } from '@compilr-dev/agents';
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Factory
|
|
13
|
+
// =============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Create a propose_alternatives tool with a custom UI handler.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const tool = createProposeAlternativesTool(async (input) => {
|
|
20
|
+
* // Show side-by-side dialog, wait for user choice
|
|
21
|
+
* return { chosenIndex: 0, chosenTitle: input.alternatives[0].title, rejected: false };
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function createProposeAlternativesTool(handler) {
|
|
26
|
+
return defineTool({
|
|
27
|
+
name: 'propose_alternatives',
|
|
28
|
+
description: 'Present 2-3 alternatives for the user to compare and choose from. ' +
|
|
29
|
+
'Use when there are multiple valid approaches and the user\'s preference matters. ' +
|
|
30
|
+
'Each alternative can include rich content (code, markdown, mermaid diagrams) for visual comparison. ' +
|
|
31
|
+
'Include pros and cons to help the user decide. The user picks one or provides feedback.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
question: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'What decision is being made (e.g., "Dashboard layout approach")',
|
|
38
|
+
},
|
|
39
|
+
context: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Optional background context for the decision',
|
|
42
|
+
},
|
|
43
|
+
alternatives: {
|
|
44
|
+
type: 'array',
|
|
45
|
+
description: '2-3 alternatives to present',
|
|
46
|
+
minItems: 2,
|
|
47
|
+
maxItems: 3,
|
|
48
|
+
items: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
title: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Short title (e.g., "Card Grid", "Data Table")',
|
|
54
|
+
},
|
|
55
|
+
description: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: '1-2 sentence explanation of this approach',
|
|
58
|
+
},
|
|
59
|
+
content: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Optional rich content for preview (code, markdown, or mermaid source)',
|
|
62
|
+
},
|
|
63
|
+
contentType: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
enum: ['markdown', 'code', 'mermaid'],
|
|
66
|
+
description: 'Content format for rendering',
|
|
67
|
+
},
|
|
68
|
+
language: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'Language hint for code syntax highlighting (e.g., "typescript", "html")',
|
|
71
|
+
},
|
|
72
|
+
pros: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
items: { type: 'string' },
|
|
75
|
+
description: 'Advantages of this alternative',
|
|
76
|
+
},
|
|
77
|
+
cons: {
|
|
78
|
+
type: 'array',
|
|
79
|
+
items: { type: 'string' },
|
|
80
|
+
description: 'Disadvantages of this alternative',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['title', 'description'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
required: ['question', 'alternatives'],
|
|
88
|
+
},
|
|
89
|
+
execute: async (input) => {
|
|
90
|
+
try {
|
|
91
|
+
if (input.alternatives.length < 2) {
|
|
92
|
+
return { success: false, error: 'At least 2 alternatives are required' };
|
|
93
|
+
}
|
|
94
|
+
if (input.alternatives.length > 3) {
|
|
95
|
+
return { success: false, error: 'Maximum 3 alternatives allowed' };
|
|
96
|
+
}
|
|
97
|
+
const result = await handler(input);
|
|
98
|
+
if (result.rejected) {
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
result: {
|
|
102
|
+
chosen: null,
|
|
103
|
+
rejected: true,
|
|
104
|
+
feedback: result.notes ?? 'User rejected all alternatives',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
result: {
|
|
111
|
+
chosen: result.chosenTitle,
|
|
112
|
+
chosenIndex: result.chosenIndex,
|
|
113
|
+
notes: result.notes,
|
|
114
|
+
rejected: false,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: `Failed to propose alternatives: ${err instanceof Error ? err.message : String(err)}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
// Not silent — show in tool call history (this is substantive, not meta)
|
|
126
|
+
silent: false,
|
|
127
|
+
});
|
|
128
|
+
}
|