@compilr-dev/sdk 0.1.9 → 0.1.11
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/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/platform/context.d.ts +4 -0
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/services.d.ts +82 -0
- package/dist/platform/services.js +7 -0
- package/dist/platform/tools/anchor-tools.d.ts +18 -0
- package/dist/platform/tools/anchor-tools.js +172 -0
- package/dist/platform/tools/artifact-tools.d.ts +20 -0
- package/dist/platform/tools/artifact-tools.js +254 -0
- package/dist/platform/tools/document-tools.js +13 -13
- package/dist/platform/tools/episode-tools.d.ts +15 -0
- package/dist/platform/tools/episode-tools.js +92 -0
- package/dist/platform/tools/index.d.ts +13 -123
- package/dist/platform/tools/index.js +27 -5
- package/dist/platform/tools/plan-tools.js +6 -6
- package/dist/platform/tools/project-tools.js +1 -1
- package/dist/platform/tools/workitem-tools.js +18 -18
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -47,8 +47,8 @@ export { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX, }
|
|
|
47
47
|
export type { MetaToolStats, MetaTools } from './meta-tools/index.js';
|
|
48
48
|
export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './system-prompt/index.js';
|
|
49
49
|
export type { SystemPromptContext, BuildResult, SystemPromptModule, ModuleConditions, } from './system-prompt/index.js';
|
|
50
|
-
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, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
|
|
51
|
-
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, } from './platform/index.js';
|
|
50
|
+
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, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
|
|
51
|
+
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './platform/index.js';
|
|
52
52
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
|
|
53
53
|
export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, } from './skills/index.js';
|
|
54
54
|
export { defineTool, createSuccessResult, createErrorResult, mergeHooks, createLoggingHooks, createClaudeProvider, createOpenAIProvider, createGeminiNativeProvider, createOllamaProvider, createTogetherProvider, createGroqProvider, createFireworksProvider, createPerplexityProvider, createOpenRouterProvider, createMockProvider, MockProvider, Agent, ContextManager, DEFAULT_CONTEXT_CONFIG, createTaskTool, createSuggestTool, defaultAgentTypes, TOOL_SETS, BUILTIN_GUARDRAILS, TOOL_NAMES, getDefaultShellManager, builtinSkills, AnchorManager, MCPManager, AgentError, ProviderError, ToolError, ToolTimeoutError, MaxIterationsError, AbortError, } from '@compilr-dev/agents';
|
package/dist/index.js
CHANGED
|
@@ -77,7 +77,7 @@ shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, }
|
|
|
77
77
|
// =============================================================================
|
|
78
78
|
// Platform Tools (runtime — createPlatformTools factory + individual factories)
|
|
79
79
|
// =============================================================================
|
|
80
|
-
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, } from './platform/index.js';
|
|
80
|
+
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './platform/index.js';
|
|
81
81
|
// =============================================================================
|
|
82
82
|
// Platform Workflow (pure step-criteria logic)
|
|
83
83
|
// =============================================================================
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* underlying storage backend (SQLite in CLI, PostgreSQL in web/API).
|
|
6
6
|
*/
|
|
7
7
|
import type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository } from './repositories.js';
|
|
8
|
+
import type { IAnchorService, IArtifactService, IEpisodeService } from './services.js';
|
|
8
9
|
export interface PlatformContext {
|
|
9
10
|
readonly projects: IProjectRepository;
|
|
10
11
|
readonly workItems: IWorkItemRepository;
|
|
11
12
|
readonly documents: IDocumentRepository;
|
|
12
13
|
readonly plans: IPlanRepository;
|
|
13
14
|
currentProjectId?: number;
|
|
15
|
+
readonly anchors?: IAnchorService;
|
|
16
|
+
readonly artifacts?: IArtifactService;
|
|
17
|
+
readonly episodes?: IEpisodeService;
|
|
14
18
|
}
|
|
15
19
|
export interface PlatformHooks {
|
|
16
20
|
/** Called when a project is resolved/selected as the current project */
|
package/dist/platform/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
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, } from './types.js';
|
|
5
5
|
export type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, } from './repositories.js';
|
|
6
|
+
export type { IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, } from './services.js';
|
|
6
7
|
export type { PlatformContext, PlatformToolsConfig, PlatformHooks } from './context.js';
|
|
7
|
-
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, } from './tools/index.js';
|
|
8
|
+
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
|
|
8
9
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './workflow.js';
|
|
9
10
|
export type { StepCriteria } from './workflow.js';
|
package/dist/platform/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Platform — Repository interfaces, data models, tools, and workflow.
|
|
3
3
|
*/
|
|
4
4
|
// Platform tools (runtime)
|
|
5
|
-
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, } from './tools/index.js';
|
|
5
|
+
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
|
|
6
6
|
// Workflow (pure step-criteria logic)
|
|
7
7
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './workflow.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Service Interfaces — Non-DB services for anchors, artifacts, and episodes.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces abstract CLI-specific implementations (AnchorManager, ArtifactStore,
|
|
5
|
+
* FileEpisodeStore) so tool definitions can live in the SDK.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnchorPriority, WorkEpisode, ProjectWorkSummary } from '@compilr-dev/agents';
|
|
8
|
+
export interface AnchorData {
|
|
9
|
+
id: string;
|
|
10
|
+
content: string;
|
|
11
|
+
priority: string;
|
|
12
|
+
scope: 'global' | 'project';
|
|
13
|
+
tags?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface IAnchorService {
|
|
16
|
+
add(input: {
|
|
17
|
+
content: string;
|
|
18
|
+
priority?: AnchorPriority;
|
|
19
|
+
scope?: 'global' | 'project';
|
|
20
|
+
tags?: string[];
|
|
21
|
+
}): Promise<AnchorData>;
|
|
22
|
+
remove(id: string): Promise<{
|
|
23
|
+
removed: boolean;
|
|
24
|
+
scope?: string;
|
|
25
|
+
}>;
|
|
26
|
+
list(options?: {
|
|
27
|
+
scope?: 'global' | 'project' | 'all';
|
|
28
|
+
priority?: AnchorPriority;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
count: number;
|
|
31
|
+
activeProjectName: string | null;
|
|
32
|
+
anchors: AnchorData[];
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export type ArtifactType = 'design' | 'plan' | 'review' | 'decision' | 'note';
|
|
36
|
+
export interface ArtifactData {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
agent: string;
|
|
40
|
+
type: ArtifactType;
|
|
41
|
+
content: string;
|
|
42
|
+
summary: string;
|
|
43
|
+
version: number;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
}
|
|
47
|
+
export interface ArtifactSummaryData {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
agent: string;
|
|
51
|
+
type: ArtifactType;
|
|
52
|
+
summary: string;
|
|
53
|
+
version: number;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
}
|
|
56
|
+
export interface IArtifactService {
|
|
57
|
+
save(input: {
|
|
58
|
+
name: string;
|
|
59
|
+
type: ArtifactType;
|
|
60
|
+
content: string;
|
|
61
|
+
summary?: string;
|
|
62
|
+
agent?: string;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
artifact: ArtifactData;
|
|
65
|
+
isUpdate: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
getByName(name: string): Promise<ArtifactData | null>;
|
|
68
|
+
list(options?: {
|
|
69
|
+
type?: ArtifactType;
|
|
70
|
+
agent?: string;
|
|
71
|
+
search?: string;
|
|
72
|
+
}): Promise<ArtifactSummaryData[]>;
|
|
73
|
+
delete(name: string): Promise<ArtifactData | null>;
|
|
74
|
+
}
|
|
75
|
+
export type { WorkEpisode, ProjectWorkSummary } from '@compilr-dev/agents';
|
|
76
|
+
export interface IEpisodeService {
|
|
77
|
+
getByFiles(files: string[]): Promise<WorkEpisode[]>;
|
|
78
|
+
getByAgent(agentId: string): Promise<WorkEpisode[]>;
|
|
79
|
+
getBySession(sessionId: string): Promise<WorkEpisode[]>;
|
|
80
|
+
getRecent(count: number): Promise<WorkEpisode[]>;
|
|
81
|
+
getWorkSummary(): Promise<ProjectWorkSummary>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor Tools — Agent tools for managing persistent context anchors.
|
|
3
|
+
*
|
|
4
|
+
* 3 tools: anchor_add, anchor_remove, anchor_list
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/anchor-tools.ts. Key adaptation:
|
|
7
|
+
* - getGlobalAnchorManager()/getAnchorManager()/getActiveProject() → anchors.*
|
|
8
|
+
*/
|
|
9
|
+
import type { AnchorPriority } from '@compilr-dev/agents';
|
|
10
|
+
import type { PlatformToolsConfig } from '../context.js';
|
|
11
|
+
export declare function createAnchorTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
|
|
12
|
+
content: string;
|
|
13
|
+
priority?: AnchorPriority;
|
|
14
|
+
scope?: "global" | "project";
|
|
15
|
+
tags?: string[];
|
|
16
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>)[];
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor Tools — Agent tools for managing persistent context anchors.
|
|
3
|
+
*
|
|
4
|
+
* 3 tools: anchor_add, anchor_remove, anchor_list
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/anchor-tools.ts. Key adaptation:
|
|
7
|
+
* - getGlobalAnchorManager()/getAnchorManager()/getActiveProject() → anchors.*
|
|
8
|
+
*/
|
|
9
|
+
import { defineTool } from '@compilr-dev/agents';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
+
export function createAnchorTools(config) {
|
|
12
|
+
// Safe: callers guard with `if (config.context.anchors)` before calling
|
|
13
|
+
const anchors = config.context.anchors;
|
|
14
|
+
if (!anchors)
|
|
15
|
+
throw new Error('anchors service required');
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// anchor_add
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
const anchorAddTool = defineTool({
|
|
20
|
+
name: 'anchor_add',
|
|
21
|
+
description: 'Add critical information that must survive context compaction. ' +
|
|
22
|
+
'Use this for: project context, important decisions, user preferences, ' +
|
|
23
|
+
'architectural constraints, or any information that should persist across the entire conversation. ' +
|
|
24
|
+
'Anchors are always included at the top of the context window.',
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
content: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'The critical information to preserve. Keep it concise but complete.',
|
|
31
|
+
},
|
|
32
|
+
priority: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
enum: ['critical', 'safety', 'info'],
|
|
35
|
+
description: 'Priority level. "critical" for must-never-forget info (user preferences, key constraints), ' +
|
|
36
|
+
'"safety" for safety-related context, "info" for general helpful context.',
|
|
37
|
+
},
|
|
38
|
+
scope: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: ['global', 'project'],
|
|
41
|
+
description: 'Scope for the anchor. "global" persists across all projects, ' +
|
|
42
|
+
'"project" is specific to the current project (requires active project).',
|
|
43
|
+
},
|
|
44
|
+
tags: {
|
|
45
|
+
type: 'array',
|
|
46
|
+
items: { type: 'string' },
|
|
47
|
+
description: 'Optional tags for categorization (e.g., ["architecture", "decision"])',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ['content'],
|
|
51
|
+
},
|
|
52
|
+
execute: async (input) => {
|
|
53
|
+
try {
|
|
54
|
+
if (!input.content || input.content.trim().length === 0) {
|
|
55
|
+
return { success: false, error: 'Anchor content is required and cannot be empty' };
|
|
56
|
+
}
|
|
57
|
+
const result = await anchors.add({
|
|
58
|
+
content: input.content.trim(),
|
|
59
|
+
priority: input.priority,
|
|
60
|
+
scope: input.scope,
|
|
61
|
+
tags: input.tags,
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
result: {
|
|
66
|
+
id: result.id,
|
|
67
|
+
content: result.content,
|
|
68
|
+
priority: result.priority,
|
|
69
|
+
scope: result.scope,
|
|
70
|
+
tags: result.tags,
|
|
71
|
+
message: `Anchor added successfully (${result.scope} scope, ${result.priority} priority)`,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
error: `Failed to add anchor: ${err instanceof Error ? err.message : String(err)}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// anchor_remove
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
const anchorRemoveTool = defineTool({
|
|
87
|
+
name: 'anchor_remove',
|
|
88
|
+
description: 'Remove an anchor by its ID. Use this to clean up outdated or no longer relevant anchors. ' +
|
|
89
|
+
'Use anchor_list first to see available anchors and their IDs.',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
id: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'The ID of the anchor to remove',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
required: ['id'],
|
|
99
|
+
},
|
|
100
|
+
execute: async (input) => {
|
|
101
|
+
try {
|
|
102
|
+
if (!input.id || input.id.trim().length === 0) {
|
|
103
|
+
return { success: false, error: 'Anchor ID is required' };
|
|
104
|
+
}
|
|
105
|
+
const result = await anchors.remove(input.id.trim());
|
|
106
|
+
if (!result.removed) {
|
|
107
|
+
return { success: false, error: `Anchor with ID "${input.id.trim()}" not found` };
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
result: {
|
|
112
|
+
id: input.id.trim(),
|
|
113
|
+
scope: result.scope,
|
|
114
|
+
message: `Anchor removed successfully (was ${result.scope ?? 'unknown'} scope)`,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: `Failed to remove anchor: ${err instanceof Error ? err.message : String(err)}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// anchor_list
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
const anchorListTool = defineTool({
|
|
130
|
+
name: 'anchor_list',
|
|
131
|
+
description: 'List all anchors. Returns anchor IDs, content, priority, and scope. ' +
|
|
132
|
+
'Use this to see what persistent context is available before adding or removing anchors.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
scope: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
enum: ['global', 'project', 'all'],
|
|
139
|
+
description: 'Filter by scope: "global", "project", or "all" (default: "all")',
|
|
140
|
+
},
|
|
141
|
+
priority: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
enum: ['critical', 'safety', 'info'],
|
|
144
|
+
description: 'Filter by priority level',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
execute: async (input) => {
|
|
149
|
+
try {
|
|
150
|
+
const result = await anchors.list({
|
|
151
|
+
scope: input.scope,
|
|
152
|
+
priority: input.priority,
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
success: true,
|
|
156
|
+
result: {
|
|
157
|
+
count: result.count,
|
|
158
|
+
activeProject: result.activeProjectName,
|
|
159
|
+
anchors: result.anchors,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: `Failed to list anchors: ${err instanceof Error ? err.message : String(err)}`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
return [anchorAddTool, anchorRemoveTool, anchorListTool];
|
|
172
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Tools — Team artifact management.
|
|
3
|
+
*
|
|
4
|
+
* 4 tools: artifact_save, artifact_get, artifact_list, artifact_delete
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/artifact-tools.ts. Key adaptation:
|
|
7
|
+
* - getTeamCheckpointer()/recordTeamActivity()/getCurrentProject() → artifacts.*
|
|
8
|
+
*/
|
|
9
|
+
import type { PlatformToolsConfig } from '../context.js';
|
|
10
|
+
export declare function createArtifactTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
content: string;
|
|
14
|
+
summary?: string;
|
|
15
|
+
agent?: string;
|
|
16
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
17
|
+
type?: string;
|
|
18
|
+
agent?: string;
|
|
19
|
+
search?: string;
|
|
20
|
+
}>)[];
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Tools — Team artifact management.
|
|
3
|
+
*
|
|
4
|
+
* 4 tools: artifact_save, artifact_get, artifact_list, artifact_delete
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/artifact-tools.ts. Key adaptation:
|
|
7
|
+
* - getTeamCheckpointer()/recordTeamActivity()/getCurrentProject() → artifacts.*
|
|
8
|
+
*/
|
|
9
|
+
import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/agents';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
+
export function createArtifactTools(config) {
|
|
12
|
+
// Safe: callers guard with `if (config.context.artifacts)` before calling
|
|
13
|
+
const artifacts = config.context.artifacts;
|
|
14
|
+
if (!artifacts)
|
|
15
|
+
throw new Error('artifacts service required');
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// artifact_save
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
const artifactSaveTool = defineTool({
|
|
20
|
+
name: 'artifact_save',
|
|
21
|
+
description: 'Save a new artifact or update an existing one. Artifacts are named pieces of work that can be referenced by other agents. ' +
|
|
22
|
+
'Types: design (architecture/API specs), plan (task breakdowns), review (code reviews), decision (architectural decisions), note (general notes).',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
name: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'Artifact name (human-readable, unique within team). Example: "API Design v2", "Sprint 5 Plan", "Auth Module Review"',
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['design', 'plan', 'review', 'decision', 'note'],
|
|
33
|
+
description: 'Artifact type: design (architecture), plan (task breakdown), review (feedback), decision (trade-off analysis), note (general)',
|
|
34
|
+
},
|
|
35
|
+
content: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Full artifact content in markdown format. Should be complete and self-contained.',
|
|
38
|
+
},
|
|
39
|
+
summary: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Optional one-line summary (auto-generated if not provided). Max 200 characters.',
|
|
42
|
+
},
|
|
43
|
+
agent: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Optional agent ID who created this artifact. Defaults to current agent.',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['name', 'type', 'content'],
|
|
49
|
+
},
|
|
50
|
+
execute: async (input) => {
|
|
51
|
+
try {
|
|
52
|
+
const result = await artifacts.save({
|
|
53
|
+
name: input.name,
|
|
54
|
+
type: input.type,
|
|
55
|
+
content: input.content,
|
|
56
|
+
summary: input.summary,
|
|
57
|
+
agent: input.agent,
|
|
58
|
+
});
|
|
59
|
+
const { artifact, isUpdate } = result;
|
|
60
|
+
if (isUpdate) {
|
|
61
|
+
const output = [
|
|
62
|
+
`Updated artifact "${artifact.name}" (v${String(artifact.version)})`,
|
|
63
|
+
``,
|
|
64
|
+
`Type: ${artifact.type}`,
|
|
65
|
+
`Agent: ${artifact.agent}`,
|
|
66
|
+
`Summary: ${artifact.summary}`,
|
|
67
|
+
`Updated: ${artifact.updatedAt.toISOString()}`,
|
|
68
|
+
].join('\n');
|
|
69
|
+
return createSuccessResult(output);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const output = [
|
|
73
|
+
`Created artifact "${artifact.name}"`,
|
|
74
|
+
``,
|
|
75
|
+
`Type: ${artifact.type}`,
|
|
76
|
+
`Agent: ${artifact.agent}`,
|
|
77
|
+
`Summary: ${artifact.summary}`,
|
|
78
|
+
`Created: ${artifact.createdAt.toISOString()}`,
|
|
79
|
+
].join('\n');
|
|
80
|
+
return createSuccessResult(output);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return createErrorResult(`Failed to save artifact: ${error instanceof Error ? error.message : String(error)}`);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// artifact_get
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
const artifactGetTool = defineTool({
|
|
92
|
+
name: 'artifact_get',
|
|
93
|
+
description: 'Retrieve an artifact by name. Returns the full content and metadata. ' +
|
|
94
|
+
'Use artifact_list first to see available artifacts.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
name: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Name of the artifact to retrieve (case-insensitive)',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: ['name'],
|
|
104
|
+
},
|
|
105
|
+
execute: async (input) => {
|
|
106
|
+
try {
|
|
107
|
+
const artifact = await artifacts.getByName(input.name);
|
|
108
|
+
if (!artifact) {
|
|
109
|
+
// List available artifacts for suggestions
|
|
110
|
+
const all = await artifacts.list();
|
|
111
|
+
const searchLower = input.name.toLowerCase();
|
|
112
|
+
const suggestions = all
|
|
113
|
+
.filter((a) => a.name.toLowerCase().includes(searchLower) ||
|
|
114
|
+
searchLower.includes(a.name.toLowerCase()))
|
|
115
|
+
.slice(0, 3)
|
|
116
|
+
.map((a) => `"${a.name}"`);
|
|
117
|
+
let message = `Artifact "${input.name}" not found.`;
|
|
118
|
+
if (suggestions.length > 0) {
|
|
119
|
+
message += ` Did you mean: ${suggestions.join(', ')}?`;
|
|
120
|
+
}
|
|
121
|
+
else if (all.length > 0) {
|
|
122
|
+
message += ` Available artifacts: ${all
|
|
123
|
+
.slice(0, 5)
|
|
124
|
+
.map((a) => `"${a.name}"`)
|
|
125
|
+
.join(', ')}`;
|
|
126
|
+
if (all.length > 5) {
|
|
127
|
+
message += ` (+${String(all.length - 5)} more)`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
message += ' No artifacts exist yet. Use artifact_save to create one.';
|
|
132
|
+
}
|
|
133
|
+
return createErrorResult(message);
|
|
134
|
+
}
|
|
135
|
+
const output = [
|
|
136
|
+
`Artifact: ${artifact.name}`,
|
|
137
|
+
``,
|
|
138
|
+
`Type: ${artifact.type}`,
|
|
139
|
+
`Agent: ${artifact.agent}`,
|
|
140
|
+
`Version: ${String(artifact.version)}`,
|
|
141
|
+
`Summary: ${artifact.summary}`,
|
|
142
|
+
`Created: ${artifact.createdAt.toISOString()}`,
|
|
143
|
+
`Updated: ${artifact.updatedAt.toISOString()}`,
|
|
144
|
+
``,
|
|
145
|
+
`--- Content ---`,
|
|
146
|
+
artifact.content,
|
|
147
|
+
].join('\n');
|
|
148
|
+
return createSuccessResult(output);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
return createErrorResult(`Failed to get artifact: ${error instanceof Error ? error.message : String(error)}`);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// artifact_list
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
const artifactListTool = defineTool({
|
|
159
|
+
name: 'artifact_list',
|
|
160
|
+
description: 'List all artifacts in the team. Can filter by type or agent. ' +
|
|
161
|
+
'Returns summaries only - use artifact_get for full content.',
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
type: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
enum: ['design', 'plan', 'review', 'decision', 'note'],
|
|
168
|
+
description: 'Optional: filter by artifact type',
|
|
169
|
+
},
|
|
170
|
+
agent: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
description: 'Optional: filter by agent ID',
|
|
173
|
+
},
|
|
174
|
+
search: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
description: 'Optional: search by name or content',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: [],
|
|
180
|
+
},
|
|
181
|
+
execute: async (input) => {
|
|
182
|
+
try {
|
|
183
|
+
const items = await artifacts.list({
|
|
184
|
+
type: input.type,
|
|
185
|
+
agent: input.agent,
|
|
186
|
+
search: input.search,
|
|
187
|
+
});
|
|
188
|
+
// Sort by most recently updated
|
|
189
|
+
items.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
190
|
+
if (items.length === 0) {
|
|
191
|
+
let message = 'No artifacts found';
|
|
192
|
+
if (input.type || input.agent || input.search) {
|
|
193
|
+
message += ' matching the filter criteria';
|
|
194
|
+
}
|
|
195
|
+
message += '. Use artifact_save to create one.';
|
|
196
|
+
return createSuccessResult(message);
|
|
197
|
+
}
|
|
198
|
+
const lines = [
|
|
199
|
+
`Found ${String(items.length)} artifact${items.length === 1 ? '' : 's'}:`,
|
|
200
|
+
``,
|
|
201
|
+
];
|
|
202
|
+
for (const a of items) {
|
|
203
|
+
lines.push(`* ${a.name} [${a.type}]`);
|
|
204
|
+
lines.push(` Agent: ${a.agent} | v${String(a.version)} | Updated: ${a.updatedAt.toISOString().split('T')[0]}`);
|
|
205
|
+
if (a.summary) {
|
|
206
|
+
lines.push(` ${a.summary}`);
|
|
207
|
+
}
|
|
208
|
+
lines.push(``);
|
|
209
|
+
}
|
|
210
|
+
lines.push(`Use artifact_get(name) to view full content.`);
|
|
211
|
+
return createSuccessResult(lines.join('\n'));
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
return createErrorResult(`Failed to list artifacts: ${error instanceof Error ? error.message : String(error)}`);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
// artifact_delete
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
const artifactDeleteTool = defineTool({
|
|
222
|
+
name: 'artifact_delete',
|
|
223
|
+
description: 'Delete an artifact by name. This action cannot be undone.',
|
|
224
|
+
inputSchema: {
|
|
225
|
+
type: 'object',
|
|
226
|
+
properties: {
|
|
227
|
+
name: {
|
|
228
|
+
type: 'string',
|
|
229
|
+
description: 'Name of the artifact to delete (case-insensitive)',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
required: ['name'],
|
|
233
|
+
},
|
|
234
|
+
execute: async (input) => {
|
|
235
|
+
try {
|
|
236
|
+
const deleted = await artifacts.delete(input.name);
|
|
237
|
+
if (!deleted) {
|
|
238
|
+
return createErrorResult(`Artifact "${input.name}" not found.`);
|
|
239
|
+
}
|
|
240
|
+
const output = [
|
|
241
|
+
`Deleted artifact "${deleted.name}"`,
|
|
242
|
+
``,
|
|
243
|
+
`Type: ${deleted.type}`,
|
|
244
|
+
`Agent: ${deleted.agent}`,
|
|
245
|
+
].join('\n');
|
|
246
|
+
return createSuccessResult(output);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
return createErrorResult(`Failed to delete artifact: ${error instanceof Error ? error.message : String(error)}`);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
return [artifactSaveTool, artifactGetTool, artifactListTool, artifactDeleteTool];
|
|
254
|
+
}
|
|
@@ -19,10 +19,6 @@ export function createDocumentTools(config) {
|
|
|
19
19
|
inputSchema: {
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
22
|
-
project_id: {
|
|
23
|
-
type: 'number',
|
|
24
|
-
description: 'Project ID (uses active project if not provided)',
|
|
25
|
-
},
|
|
26
22
|
doc_type: {
|
|
27
23
|
type: 'string',
|
|
28
24
|
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
@@ -36,6 +32,10 @@ export function createDocumentTools(config) {
|
|
|
36
32
|
type: 'string',
|
|
37
33
|
description: 'Document content (markdown)',
|
|
38
34
|
},
|
|
35
|
+
project_id: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
38
|
+
},
|
|
39
39
|
},
|
|
40
40
|
required: ['doc_type', 'title', 'content'],
|
|
41
41
|
},
|
|
@@ -78,15 +78,15 @@ export function createDocumentTools(config) {
|
|
|
78
78
|
inputSchema: {
|
|
79
79
|
type: 'object',
|
|
80
80
|
properties: {
|
|
81
|
-
project_id: {
|
|
82
|
-
type: 'number',
|
|
83
|
-
description: 'Project ID (uses active project if not provided)',
|
|
84
|
-
},
|
|
85
81
|
doc_type: {
|
|
86
82
|
type: 'string',
|
|
87
83
|
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
88
84
|
description: 'Document type to retrieve',
|
|
89
85
|
},
|
|
86
|
+
project_id: {
|
|
87
|
+
type: 'number',
|
|
88
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
89
|
+
},
|
|
90
90
|
},
|
|
91
91
|
required: ['doc_type'],
|
|
92
92
|
},
|
|
@@ -132,7 +132,7 @@ export function createDocumentTools(config) {
|
|
|
132
132
|
properties: {
|
|
133
133
|
project_id: {
|
|
134
134
|
type: 'number',
|
|
135
|
-
description: '
|
|
135
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
138
|
required: [],
|
|
@@ -172,15 +172,15 @@ export function createDocumentTools(config) {
|
|
|
172
172
|
inputSchema: {
|
|
173
173
|
type: 'object',
|
|
174
174
|
properties: {
|
|
175
|
-
project_id: {
|
|
176
|
-
type: 'number',
|
|
177
|
-
description: 'Project ID (uses active project if not provided)',
|
|
178
|
-
},
|
|
179
175
|
doc_type: {
|
|
180
176
|
type: 'string',
|
|
181
177
|
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
182
178
|
description: 'Document type to delete',
|
|
183
179
|
},
|
|
180
|
+
project_id: {
|
|
181
|
+
type: 'number',
|
|
182
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
183
|
+
},
|
|
184
184
|
},
|
|
185
185
|
required: ['doc_type'],
|
|
186
186
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Episode Tools — Query work history.
|
|
3
|
+
*
|
|
4
|
+
* 1 tool: recall_work
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/recall-work-tool.ts. Key adaptation:
|
|
7
|
+
* - getGlobalEpisodeStore() → episodes.*
|
|
8
|
+
*/
|
|
9
|
+
import type { PlatformToolsConfig } from '../context.js';
|
|
10
|
+
export declare function createEpisodeTools(config: PlatformToolsConfig): import("@compilr-dev/agents").Tool<{
|
|
11
|
+
files?: string[];
|
|
12
|
+
agentId?: string;
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
recent?: number;
|
|
15
|
+
}>[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Episode Tools — Query work history.
|
|
3
|
+
*
|
|
4
|
+
* 1 tool: recall_work
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/recall-work-tool.ts. Key adaptation:
|
|
7
|
+
* - getGlobalEpisodeStore() → episodes.*
|
|
8
|
+
*/
|
|
9
|
+
import { defineTool } from '@compilr-dev/agents';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
+
export function createEpisodeTools(config) {
|
|
12
|
+
// Safe: callers guard with `if (config.context.episodes)` before calling
|
|
13
|
+
const episodes = config.context.episodes;
|
|
14
|
+
if (!episodes)
|
|
15
|
+
throw new Error('episodes service required');
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// recall_work
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
const recallWorkTool = defineTool({
|
|
20
|
+
name: 'recall_work',
|
|
21
|
+
description: 'Query work history — episodes of what agents have done in this project. ' +
|
|
22
|
+
'Returns episodes with agent attribution, effort level, and affected files. ' +
|
|
23
|
+
'Use before destructive operations to check what work would be affected. ' +
|
|
24
|
+
'Use to understand what has been done in this session or by other agents.',
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
files: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
items: { type: 'string' },
|
|
31
|
+
description: 'Filter by file paths — returns episodes touching any of these files',
|
|
32
|
+
},
|
|
33
|
+
agentId: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'Filter by agent ID (e.g., "default", "backend")',
|
|
36
|
+
},
|
|
37
|
+
sessionId: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'Filter by session ID',
|
|
40
|
+
},
|
|
41
|
+
recent: {
|
|
42
|
+
type: 'number',
|
|
43
|
+
description: 'Return N most recent episodes (default: 20)',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
execute: async (input) => {
|
|
48
|
+
try {
|
|
49
|
+
let results;
|
|
50
|
+
if (input.files && input.files.length > 0) {
|
|
51
|
+
results = await episodes.getByFiles(input.files);
|
|
52
|
+
}
|
|
53
|
+
else if (input.agentId) {
|
|
54
|
+
results = await episodes.getByAgent(input.agentId);
|
|
55
|
+
}
|
|
56
|
+
else if (input.sessionId) {
|
|
57
|
+
results = await episodes.getBySession(input.sessionId);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
results = await episodes.getRecent(input.recent ?? 20);
|
|
61
|
+
}
|
|
62
|
+
const summary = await episodes.getWorkSummary();
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
result: {
|
|
66
|
+
episodes: results.map((ep) => ({
|
|
67
|
+
id: ep.id,
|
|
68
|
+
agentId: ep.agentId,
|
|
69
|
+
terminalPrefix: ep.terminalPrefix,
|
|
70
|
+
action: ep.action,
|
|
71
|
+
summary: ep.summary,
|
|
72
|
+
files: ep.files,
|
|
73
|
+
effort: ep.effort,
|
|
74
|
+
timestamp: ep.timestamp,
|
|
75
|
+
toolCalls: ep.toolCalls,
|
|
76
|
+
})),
|
|
77
|
+
totalEpisodes: summary.episodeCount,
|
|
78
|
+
totalEffort: summary.totalEffort,
|
|
79
|
+
uncommittedCount: summary.uncommittedWork.length,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: `Failed to recall work: ${err instanceof Error ? err.message : String(err)}`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return [recallWorkTool];
|
|
92
|
+
}
|
|
@@ -1,135 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Tools — Factory function for all platform tools.
|
|
3
3
|
*
|
|
4
|
-
* Returns
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Returns up to 32 tool definitions operating against async PlatformContext.
|
|
5
|
+
* - 24 DB tools (always): project, workitem, document, plan, backlog
|
|
6
|
+
* - 3 anchor tools (if ctx.anchors provided)
|
|
7
|
+
* - 4 artifact tools (if ctx.artifacts provided)
|
|
8
|
+
* - 1 episode tool (if ctx.episodes provided)
|
|
7
9
|
*/
|
|
10
|
+
import type { Tool } from '@compilr-dev/agents';
|
|
8
11
|
import type { PlatformToolsConfig } from '../context.js';
|
|
9
12
|
/**
|
|
10
|
-
* Create all
|
|
13
|
+
* Create all platform tools operating against the given context.
|
|
14
|
+
* Returns 24 DB tools unconditionally, plus up to 8 service-based tools
|
|
15
|
+
* if the optional anchors/artifacts/episodes services are provided.
|
|
11
16
|
*/
|
|
12
|
-
export declare function createPlatformTools(config: PlatformToolsConfig):
|
|
13
|
-
project_id?: number;
|
|
14
|
-
name?: string;
|
|
15
|
-
path?: string;
|
|
16
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
17
|
-
name: string;
|
|
18
|
-
display_name: string;
|
|
19
|
-
description?: string;
|
|
20
|
-
path?: string;
|
|
21
|
-
type?: string;
|
|
22
|
-
workflow_mode?: string;
|
|
23
|
-
language?: string;
|
|
24
|
-
framework?: string;
|
|
25
|
-
package_manager?: string;
|
|
26
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
27
|
-
project_id?: number;
|
|
28
|
-
status?: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
workflow_mode?: string;
|
|
31
|
-
lifecycle_state?: string;
|
|
32
|
-
current_item_id?: string;
|
|
33
|
-
git_remote?: string;
|
|
34
|
-
git_branch?: string;
|
|
35
|
-
last_context?: Record<string, unknown>;
|
|
36
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
37
|
-
project_id?: number;
|
|
38
|
-
status?: string;
|
|
39
|
-
type?: string;
|
|
40
|
-
priority?: string;
|
|
41
|
-
owner?: string;
|
|
42
|
-
search?: string;
|
|
43
|
-
limit?: number;
|
|
44
|
-
offset?: number;
|
|
45
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
46
|
-
project_id?: number;
|
|
47
|
-
type: string;
|
|
48
|
-
title: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
priority?: string;
|
|
51
|
-
estimated_effort?: string;
|
|
52
|
-
owner?: string;
|
|
53
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
54
|
-
item_id: string;
|
|
55
|
-
project_id?: number;
|
|
56
|
-
status?: string;
|
|
57
|
-
priority?: string;
|
|
58
|
-
owner?: string;
|
|
59
|
-
guided_step?: string;
|
|
60
|
-
title?: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
commit_hash?: string;
|
|
63
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
64
|
-
item_id: string;
|
|
65
|
-
reason: string;
|
|
66
|
-
force?: boolean;
|
|
67
|
-
project_id?: number;
|
|
68
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
69
|
-
item_id: string;
|
|
70
|
-
agent_id: string;
|
|
71
|
-
project_id?: number;
|
|
72
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
73
|
-
item_id: string;
|
|
74
|
-
to_agent_id: string;
|
|
75
|
-
notes?: string;
|
|
76
|
-
project_id?: number;
|
|
77
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
78
|
-
project_id?: number;
|
|
79
|
-
doc_type: string;
|
|
80
|
-
title: string;
|
|
81
|
-
content: string;
|
|
82
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
83
|
-
name: string;
|
|
84
|
-
content: string;
|
|
85
|
-
work_item_id?: number;
|
|
86
|
-
project_id?: number;
|
|
87
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
88
|
-
plan_id: number;
|
|
89
|
-
content?: string;
|
|
90
|
-
status?: string;
|
|
91
|
-
work_item_id?: number | null;
|
|
92
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
93
|
-
plan_id?: number;
|
|
94
|
-
name?: string;
|
|
95
|
-
project_id?: number;
|
|
96
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
97
|
-
project_id?: number;
|
|
98
|
-
status?: string;
|
|
99
|
-
work_item_id?: number;
|
|
100
|
-
limit?: number;
|
|
101
|
-
order_by?: string;
|
|
102
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
103
|
-
id?: string;
|
|
104
|
-
status?: string;
|
|
105
|
-
type?: string;
|
|
106
|
-
search?: string;
|
|
107
|
-
priority?: string;
|
|
108
|
-
limit?: number;
|
|
109
|
-
}> | import("@compilr-dev/agents").Tool<{
|
|
110
|
-
action: string;
|
|
111
|
-
item?: {
|
|
112
|
-
id?: string;
|
|
113
|
-
type?: string;
|
|
114
|
-
title?: string;
|
|
115
|
-
description?: string;
|
|
116
|
-
status?: string;
|
|
117
|
-
priority?: string;
|
|
118
|
-
owner?: string;
|
|
119
|
-
commit_hash?: string;
|
|
120
|
-
};
|
|
121
|
-
deleteId?: string;
|
|
122
|
-
items?: Array<{
|
|
123
|
-
id?: string;
|
|
124
|
-
type: string;
|
|
125
|
-
title: string;
|
|
126
|
-
description?: string;
|
|
127
|
-
status?: string;
|
|
128
|
-
priority?: string;
|
|
129
|
-
}>;
|
|
130
|
-
}>)[];
|
|
17
|
+
export declare function createPlatformTools(config: PlatformToolsConfig): Tool<never>[];
|
|
131
18
|
export { createProjectTools } from './project-tools.js';
|
|
132
19
|
export { createWorkItemTools } from './workitem-tools.js';
|
|
133
20
|
export { createDocumentTools } from './document-tools.js';
|
|
134
21
|
export { createPlanTools } from './plan-tools.js';
|
|
135
22
|
export { createBacklogTools } from './backlog-tools.js';
|
|
23
|
+
export { createAnchorTools } from './anchor-tools.js';
|
|
24
|
+
export { createArtifactTools } from './artifact-tools.js';
|
|
25
|
+
export { createEpisodeTools } from './episode-tools.js';
|
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Tools — Factory function for all platform tools.
|
|
3
3
|
*
|
|
4
|
-
* Returns
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Returns up to 32 tool definitions operating against async PlatformContext.
|
|
5
|
+
* - 24 DB tools (always): project, workitem, document, plan, backlog
|
|
6
|
+
* - 3 anchor tools (if ctx.anchors provided)
|
|
7
|
+
* - 4 artifact tools (if ctx.artifacts provided)
|
|
8
|
+
* - 1 episode tool (if ctx.episodes provided)
|
|
7
9
|
*/
|
|
8
10
|
import { createProjectTools } from './project-tools.js';
|
|
9
11
|
import { createWorkItemTools } from './workitem-tools.js';
|
|
10
12
|
import { createDocumentTools } from './document-tools.js';
|
|
11
13
|
import { createPlanTools } from './plan-tools.js';
|
|
12
14
|
import { createBacklogTools } from './backlog-tools.js';
|
|
15
|
+
import { createAnchorTools } from './anchor-tools.js';
|
|
16
|
+
import { createArtifactTools } from './artifact-tools.js';
|
|
17
|
+
import { createEpisodeTools } from './episode-tools.js';
|
|
13
18
|
/**
|
|
14
|
-
* Create all
|
|
19
|
+
* Create all platform tools operating against the given context.
|
|
20
|
+
* Returns 24 DB tools unconditionally, plus up to 8 service-based tools
|
|
21
|
+
* if the optional anchors/artifacts/episodes services are provided.
|
|
15
22
|
*/
|
|
16
23
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
17
24
|
export function createPlatformTools(config) {
|
|
18
|
-
|
|
25
|
+
// Use Tool<never>[] to accept any Tool<T> — the generic parameter is only
|
|
26
|
+
// relevant to execute() callers, not to the registry that stores them.
|
|
27
|
+
const tools = [
|
|
19
28
|
...createProjectTools(config),
|
|
20
29
|
...createWorkItemTools(config),
|
|
21
30
|
...createDocumentTools(config),
|
|
22
31
|
...createPlanTools(config),
|
|
23
32
|
...createBacklogTools(config),
|
|
24
33
|
];
|
|
34
|
+
if (config.context.anchors) {
|
|
35
|
+
tools.push(...createAnchorTools(config));
|
|
36
|
+
}
|
|
37
|
+
if (config.context.artifacts) {
|
|
38
|
+
tools.push(...createArtifactTools(config));
|
|
39
|
+
}
|
|
40
|
+
if (config.context.episodes) {
|
|
41
|
+
tools.push(...createEpisodeTools(config));
|
|
42
|
+
}
|
|
43
|
+
return tools;
|
|
25
44
|
}
|
|
26
45
|
// Re-export individual factory functions for selective use
|
|
27
46
|
export { createProjectTools } from './project-tools.js';
|
|
@@ -29,3 +48,6 @@ export { createWorkItemTools } from './workitem-tools.js';
|
|
|
29
48
|
export { createDocumentTools } from './document-tools.js';
|
|
30
49
|
export { createPlanTools } from './plan-tools.js';
|
|
31
50
|
export { createBacklogTools } from './backlog-tools.js';
|
|
51
|
+
export { createAnchorTools } from './anchor-tools.js';
|
|
52
|
+
export { createArtifactTools } from './artifact-tools.js';
|
|
53
|
+
export { createEpisodeTools } from './episode-tools.js';
|
|
@@ -32,7 +32,7 @@ export function createPlanTools(config) {
|
|
|
32
32
|
},
|
|
33
33
|
project_id: {
|
|
34
34
|
type: 'number',
|
|
35
|
-
description: '
|
|
35
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
required: ['name', 'content'],
|
|
@@ -154,7 +154,7 @@ export function createPlanTools(config) {
|
|
|
154
154
|
},
|
|
155
155
|
project_id: {
|
|
156
156
|
type: 'number',
|
|
157
|
-
description: '
|
|
157
|
+
description: 'Required when using name lookup. Defaults to active project.',
|
|
158
158
|
},
|
|
159
159
|
},
|
|
160
160
|
required: [],
|
|
@@ -220,10 +220,6 @@ export function createPlanTools(config) {
|
|
|
220
220
|
inputSchema: {
|
|
221
221
|
type: 'object',
|
|
222
222
|
properties: {
|
|
223
|
-
project_id: {
|
|
224
|
-
type: 'number',
|
|
225
|
-
description: 'Project ID (uses active project if not provided)',
|
|
226
|
-
},
|
|
227
223
|
status: {
|
|
228
224
|
type: 'string',
|
|
229
225
|
enum: ['draft', 'approved', 'in_progress', 'completed', 'abandoned', 'all'],
|
|
@@ -242,6 +238,10 @@ export function createPlanTools(config) {
|
|
|
242
238
|
enum: ['updated_desc', 'updated_asc', 'created_desc', 'name_asc'],
|
|
243
239
|
description: 'Sort order (default: updated_desc)',
|
|
244
240
|
},
|
|
241
|
+
project_id: {
|
|
242
|
+
type: 'number',
|
|
243
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
244
|
+
},
|
|
245
245
|
},
|
|
246
246
|
required: [],
|
|
247
247
|
},
|
|
@@ -225,7 +225,7 @@ export function createProjectTools(config) {
|
|
|
225
225
|
properties: {
|
|
226
226
|
project_id: {
|
|
227
227
|
type: 'number',
|
|
228
|
-
description: '
|
|
228
|
+
description: 'Optional. Defaults to active project. Only needed to update a different project.',
|
|
229
229
|
},
|
|
230
230
|
status: {
|
|
231
231
|
type: 'string',
|
|
@@ -27,10 +27,6 @@ export function createWorkItemTools(config) {
|
|
|
27
27
|
inputSchema: {
|
|
28
28
|
type: 'object',
|
|
29
29
|
properties: {
|
|
30
|
-
project_id: {
|
|
31
|
-
type: 'number',
|
|
32
|
-
description: 'Project ID (uses active project if not provided)',
|
|
33
|
-
},
|
|
34
30
|
status: {
|
|
35
31
|
type: 'string',
|
|
36
32
|
enum: ['backlog', 'in_progress', 'completed', 'skipped', 'all'],
|
|
@@ -62,6 +58,10 @@ export function createWorkItemTools(config) {
|
|
|
62
58
|
type: 'number',
|
|
63
59
|
description: 'Offset for pagination (default: 0)',
|
|
64
60
|
},
|
|
61
|
+
project_id: {
|
|
62
|
+
type: 'number',
|
|
63
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
64
|
+
},
|
|
65
65
|
},
|
|
66
66
|
required: [],
|
|
67
67
|
},
|
|
@@ -125,10 +125,6 @@ export function createWorkItemTools(config) {
|
|
|
125
125
|
inputSchema: {
|
|
126
126
|
type: 'object',
|
|
127
127
|
properties: {
|
|
128
|
-
project_id: {
|
|
129
|
-
type: 'number',
|
|
130
|
-
description: 'Project ID (uses active project if not provided)',
|
|
131
|
-
},
|
|
132
128
|
type: {
|
|
133
129
|
type: 'string',
|
|
134
130
|
enum: ['feature', 'bug', 'tech-debt', 'chore'],
|
|
@@ -156,6 +152,10 @@ export function createWorkItemTools(config) {
|
|
|
156
152
|
type: 'string',
|
|
157
153
|
description: 'Owner agent ID. Omit for unassigned.',
|
|
158
154
|
},
|
|
155
|
+
project_id: {
|
|
156
|
+
type: 'number',
|
|
157
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
158
|
+
},
|
|
159
159
|
},
|
|
160
160
|
required: ['type', 'title'],
|
|
161
161
|
},
|
|
@@ -210,7 +210,7 @@ export function createWorkItemTools(config) {
|
|
|
210
210
|
},
|
|
211
211
|
project_id: {
|
|
212
212
|
type: 'number',
|
|
213
|
-
description: '
|
|
213
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
214
214
|
},
|
|
215
215
|
status: {
|
|
216
216
|
type: 'string',
|
|
@@ -315,15 +315,15 @@ export function createWorkItemTools(config) {
|
|
|
315
315
|
inputSchema: {
|
|
316
316
|
type: 'object',
|
|
317
317
|
properties: {
|
|
318
|
-
project_id: {
|
|
319
|
-
type: 'number',
|
|
320
|
-
description: 'Project ID (uses active project if not provided)',
|
|
321
|
-
},
|
|
322
318
|
type: {
|
|
323
319
|
type: 'string',
|
|
324
320
|
enum: ['feature', 'bug', 'tech-debt', 'chore'],
|
|
325
321
|
description: 'Filter by type (optional)',
|
|
326
322
|
},
|
|
323
|
+
project_id: {
|
|
324
|
+
type: 'number',
|
|
325
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
326
|
+
},
|
|
327
327
|
},
|
|
328
328
|
required: [],
|
|
329
329
|
},
|
|
@@ -376,7 +376,7 @@ export function createWorkItemTools(config) {
|
|
|
376
376
|
},
|
|
377
377
|
project_id: {
|
|
378
378
|
type: 'number',
|
|
379
|
-
description: '
|
|
379
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
380
380
|
},
|
|
381
381
|
},
|
|
382
382
|
required: ['item_id'],
|
|
@@ -416,7 +416,7 @@ export function createWorkItemTools(config) {
|
|
|
416
416
|
properties: {
|
|
417
417
|
project_id: {
|
|
418
418
|
type: 'number',
|
|
419
|
-
description: '
|
|
419
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
420
420
|
},
|
|
421
421
|
},
|
|
422
422
|
required: [],
|
|
@@ -469,7 +469,7 @@ export function createWorkItemTools(config) {
|
|
|
469
469
|
},
|
|
470
470
|
project_id: {
|
|
471
471
|
type: 'number',
|
|
472
|
-
description: '
|
|
472
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
473
473
|
},
|
|
474
474
|
},
|
|
475
475
|
required: ['item_id', 'reason'],
|
|
@@ -591,7 +591,7 @@ export function createWorkItemTools(config) {
|
|
|
591
591
|
},
|
|
592
592
|
project_id: {
|
|
593
593
|
type: 'number',
|
|
594
|
-
description: '
|
|
594
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
595
595
|
},
|
|
596
596
|
},
|
|
597
597
|
required: ['item_id', 'agent_id'],
|
|
@@ -658,7 +658,7 @@ export function createWorkItemTools(config) {
|
|
|
658
658
|
},
|
|
659
659
|
project_id: {
|
|
660
660
|
type: 'number',
|
|
661
|
-
description: '
|
|
661
|
+
description: 'Optional. Defaults to active project. Only needed to target a different project.',
|
|
662
662
|
},
|
|
663
663
|
},
|
|
664
664
|
required: ['item_id', 'to_agent_id'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilr-dev/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Universal agent runtime for building AI-powered applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -56,14 +56,15 @@
|
|
|
56
56
|
"ajv": "^6.14.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@compilr-dev/agents": "^0.3.
|
|
59
|
+
"@compilr-dev/agents": "^0.3.16",
|
|
60
60
|
"@compilr-dev/agents-coding": "^1.0.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
64
|
-
"@compilr-dev/agents": "^0.3.
|
|
64
|
+
"@compilr-dev/agents": "^0.3.16",
|
|
65
65
|
"@compilr-dev/agents-coding": "^1.0.2",
|
|
66
66
|
"@eslint/js": "^9.39.1",
|
|
67
|
+
"@opentelemetry/api": "^1.9.0",
|
|
67
68
|
"@types/node": "^25.2.3",
|
|
68
69
|
"@vitest/coverage-v8": "^4.0.18",
|
|
69
70
|
"eslint": "^9.39.1",
|