@compilr-dev/sdk 0.9.6 → 0.9.8

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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Guide Tool Factory — creates an environment-aware compilr_guide tool.
3
+ *
4
+ * The tool definition lives in the SDK. Each host app (CLI, Desktop)
5
+ * registers environment-specific content via additionalEntries.
6
+ */
7
+ import type { GuideToolConfig } from './types.js';
8
+ interface GuideInput {
9
+ query?: string;
10
+ list_topics?: boolean;
11
+ }
12
+ /**
13
+ * Create the compilr_guide tool for the given environment.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // In CLI
18
+ * const guideTool = createGuideTool({
19
+ * environment: 'cli',
20
+ * additionalEntries: CLI_GUIDE_ENTRIES,
21
+ * });
22
+ *
23
+ * // In Desktop
24
+ * const guideTool = createGuideTool({
25
+ * environment: 'desktop',
26
+ * additionalEntries: DESKTOP_GUIDE_ENTRIES,
27
+ * });
28
+ * ```
29
+ */
30
+ export declare function createGuideTool(config: GuideToolConfig): import("@compilr-dev/agents").Tool<GuideInput>;
31
+ export {};
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Guide Tool Factory — creates an environment-aware compilr_guide tool.
3
+ *
4
+ * The tool definition lives in the SDK. Each host app (CLI, Desktop)
5
+ * registers environment-specific content via additionalEntries.
6
+ */
7
+ import { defineTool } from '@compilr-dev/agents';
8
+ import { SHARED_GUIDE_ENTRIES } from './shared-content.js';
9
+ import { searchGuideEntries } from './search.js';
10
+ /**
11
+ * Create the compilr_guide tool for the given environment.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // In CLI
16
+ * const guideTool = createGuideTool({
17
+ * environment: 'cli',
18
+ * additionalEntries: CLI_GUIDE_ENTRIES,
19
+ * });
20
+ *
21
+ * // In Desktop
22
+ * const guideTool = createGuideTool({
23
+ * environment: 'desktop',
24
+ * additionalEntries: DESKTOP_GUIDE_ENTRIES,
25
+ * });
26
+ * ```
27
+ */
28
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
29
+ export function createGuideTool(config) {
30
+ // Merge shared + environment-specific content
31
+ const allEntries = [...SHARED_GUIDE_ENTRIES, ...(config.additionalEntries ?? [])];
32
+ const envLabel = config.environment === 'desktop' ? 'Desktop' : 'CLI';
33
+ return defineTool({
34
+ name: 'compilr_guide',
35
+ description: `Get documentation about Compilr Dev ${envLabel} features and capabilities. ` +
36
+ `Use this to answer user questions about how to use the ${envLabel.toLowerCase()}. ` +
37
+ 'Query by topic (e.g., "creating-project", "team-agents", "image-support") or ' +
38
+ 'set list_topics=true to see all available topics.',
39
+ inputSchema: {
40
+ type: 'object',
41
+ properties: {
42
+ query: {
43
+ type: 'string',
44
+ description: 'Topic or keyword to look up. Examples: "creating-project", "team-agents", "permissions", "image-support"',
45
+ },
46
+ list_topics: {
47
+ type: 'boolean',
48
+ description: 'Set to true to list all available guide topics',
49
+ },
50
+ },
51
+ },
52
+ execute: (input) => {
53
+ if (input.list_topics) {
54
+ const topics = allEntries.map((e) => `- ${e.id} — ${e.title}`).join('\n');
55
+ return Promise.resolve({
56
+ success: true,
57
+ result: {
58
+ output: `Available guide topics (${envLabel}):\n\n${topics}`,
59
+ },
60
+ });
61
+ }
62
+ if (!input.query) {
63
+ return Promise.resolve({
64
+ success: true,
65
+ result: {
66
+ output: 'Provide a query (topic or keyword) or set list_topics=true to see all topics.',
67
+ },
68
+ });
69
+ }
70
+ const results = searchGuideEntries(allEntries, input.query);
71
+ if (results.length === 0) {
72
+ const topics = allEntries.map((e) => e.id).join(', ');
73
+ return Promise.resolve({
74
+ success: true,
75
+ result: {
76
+ output: `No guide found for "${input.query}".\n\nAvailable topics: ${topics}`,
77
+ },
78
+ });
79
+ }
80
+ const formatted = results
81
+ .map((entry) => `## ${entry.title}\n\n${entry.content}`)
82
+ .join('\n\n---\n\n');
83
+ return Promise.resolve({
84
+ success: true,
85
+ result: { output: formatted },
86
+ });
87
+ },
88
+ silent: true,
89
+ });
90
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Guide module — environment-aware documentation tool.
3
+ */
4
+ export { createGuideTool } from './guide-tool.js';
5
+ export { SHARED_GUIDE_ENTRIES } from './shared-content.js';
6
+ export { searchGuideEntries, topicToGuideEntry } from './search.js';
7
+ export type { GuideEntry, ContentTopic, ContentSection, GuideToolConfig } from './types.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Guide module — environment-aware documentation tool.
3
+ */
4
+ export { createGuideTool } from './guide-tool.js';
5
+ export { SHARED_GUIDE_ENTRIES } from './shared-content.js';
6
+ export { searchGuideEntries, topicToGuideEntry } from './search.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Guide search — finds relevant entries by query.
3
+ */
4
+ import type { GuideEntry } from './types.js';
5
+ /**
6
+ * Search guide entries by keyword, topic ID, or free text.
7
+ * Returns up to maxResults matches, ranked by relevance.
8
+ */
9
+ export declare function searchGuideEntries(entries: GuideEntry[], query: string, maxResults?: number): GuideEntry[];
10
+ /**
11
+ * Convert a ContentTopic to a GuideEntry (plain text).
12
+ */
13
+ export declare function topicToGuideEntry(topic: {
14
+ id: string;
15
+ title: string;
16
+ keywords: string[];
17
+ sections: Array<{
18
+ title?: string;
19
+ items: string[];
20
+ }>;
21
+ }): GuideEntry;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Guide search — finds relevant entries by query.
3
+ */
4
+ /**
5
+ * Search guide entries by keyword, topic ID, or free text.
6
+ * Returns up to maxResults matches, ranked by relevance.
7
+ */
8
+ export function searchGuideEntries(entries, query, maxResults = 3) {
9
+ const q = query.toLowerCase().trim();
10
+ if (!q)
11
+ return [];
12
+ // 1. Exact ID match
13
+ const exactMatch = entries.find((e) => e.id === q);
14
+ if (exactMatch)
15
+ return [exactMatch];
16
+ // 2. Command match (e.g., "/design" → "skill-design", or "design")
17
+ const cmdQuery = q.startsWith('/') ? q : `/${q}`;
18
+ const cmdMatch = entries.find((e) => e.keywords.includes(cmdQuery) || e.keywords.includes(q));
19
+ if (cmdMatch)
20
+ return [cmdMatch];
21
+ // 3. Keyword + title + content search with scoring
22
+ const scored = entries
23
+ .map((e) => {
24
+ let score = 0;
25
+ // Keyword match (strongest signal)
26
+ if (e.keywords.some((k) => k === q))
27
+ score += 10;
28
+ if (e.keywords.some((k) => k.includes(q)))
29
+ score += 5;
30
+ if (e.keywords.some((k) => q.includes(k) && k.length > 2))
31
+ score += 3;
32
+ // Title match
33
+ if (e.title.toLowerCase().includes(q))
34
+ score += 4;
35
+ // Content match (weakest signal)
36
+ if (e.content.toLowerCase().includes(q))
37
+ score += 1;
38
+ return { entry: e, score };
39
+ })
40
+ .filter((s) => s.score > 0)
41
+ .sort((a, b) => b.score - a.score);
42
+ return scored.slice(0, maxResults).map((s) => s.entry);
43
+ }
44
+ /**
45
+ * Convert a ContentTopic to a GuideEntry (plain text).
46
+ */
47
+ export function topicToGuideEntry(topic) {
48
+ const parts = [];
49
+ for (const section of topic.sections) {
50
+ if (section.title)
51
+ parts.push(section.title);
52
+ for (const item of section.items) {
53
+ parts.push(` ${item}`);
54
+ }
55
+ }
56
+ return {
57
+ id: topic.id,
58
+ title: topic.title,
59
+ keywords: topic.keywords,
60
+ content: parts.join('\n'),
61
+ };
62
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared Guide Content — environment-agnostic topics.
3
+ *
4
+ * These apply to both CLI and Desktop. Each entry describes a feature
5
+ * that works the same way regardless of the host application.
6
+ */
7
+ import type { GuideEntry } from './types.js';
8
+ export declare const SHARED_GUIDE_ENTRIES: GuideEntry[];
@@ -0,0 +1,267 @@
1
+ /**
2
+ * Shared Guide Content — environment-agnostic topics.
3
+ *
4
+ * These apply to both CLI and Desktop. Each entry describes a feature
5
+ * that works the same way regardless of the host application.
6
+ */
7
+ export const SHARED_GUIDE_ENTRIES = [
8
+ // ── Projects ────────────────────────────────────────────────────────────
9
+ {
10
+ id: 'creating-project',
11
+ title: 'Creating a New Project',
12
+ keywords: ['create', 'new', 'project', 'start'],
13
+ content: `To create a new project, use the project creation flow.
14
+
15
+ You'll specify:
16
+ - Project name and display name
17
+ - Project type (software, research, book, business-plan, etc.)
18
+ - Project path (where files live on disk)
19
+
20
+ After creation, the project is set as active and agents can start working in it.
21
+
22
+ 7 project types are available:
23
+ - software — Full-stack web apps, APIs, libraries
24
+ - research — Academic papers, literature reviews
25
+ - book — Books, chapters, outlines
26
+ - course — Courses, curricula, lessons
27
+ - business-plan — Business plans, pitch decks, financials
28
+ - content-marketing — Content calendars, articles
29
+ - tech-docs — Documentation, API references, tutorials`,
30
+ },
31
+ {
32
+ id: 'project-types',
33
+ title: 'Project Types',
34
+ keywords: [
35
+ 'project type',
36
+ 'software',
37
+ 'research',
38
+ 'book',
39
+ 'business',
40
+ 'course',
41
+ 'content',
42
+ 'tech-docs',
43
+ ],
44
+ content: `Each project type determines which agent roles, skills, and tools are most relevant:
45
+
46
+ **software** — Agent roles: dev, pm, qa, arch. Skills: /design, /prd, /architecture, /scaffold, /build
47
+ **research** — Agent roles: researcher, reviewer, writer. Skills: /outline, /literature-review, /methodology, /abstract
48
+ **book** — Agent roles: editor, writer, reviewer. Skills: /outline, /chapter
49
+ **course** — Agent roles: instructor, writer, reviewer. Skills: /outline, /lesson
50
+ **business-plan** — Agent roles: analyst, strategist, writer. Skills: /business-vision, /market-analysis, /financial-model, /pitch
51
+ **content-marketing** — Agent roles: writer, editor, strategist. Skills: /editorial-calendar, /article
52
+ **tech-docs** — Agent roles: writer, dev, reviewer. Skills: /getting-started, /api-reference, /tutorial
53
+
54
+ All project types support: teams, backlog, documents, knowledge base, file references, anchors.`,
55
+ },
56
+ {
57
+ id: 'importing-project',
58
+ title: 'Importing an Existing Project',
59
+ keywords: ['import', 'existing', 'project', 'folder'],
60
+ content: `You can import an existing project directory. The system will:
61
+ 1. Detect the project type from its contents
62
+ 2. Create a project entry in the database
63
+ 3. Read COMPILR.md if present (project context for the agent)
64
+ 4. Set it as the active project
65
+
66
+ The agent then has context about your project and can help immediately.`,
67
+ },
68
+ {
69
+ id: 'switching-projects',
70
+ title: 'Switching Projects',
71
+ keywords: ['switch', 'change', 'project', 'select'],
72
+ content: `You can switch between projects at any time. When you switch:
73
+ - The active project changes
74
+ - Agents get the new project's context (COMPILR.md, anchors, KB)
75
+ - Existing conversations are preserved (per-project)`,
76
+ },
77
+ // ── Teams & Agents ──────────────────────────────────────────────────────
78
+ {
79
+ id: 'team-agents',
80
+ title: 'Team Agents',
81
+ keywords: ['team', 'agents', '$agent', 'mention', 'role', 'specialist'],
82
+ content: `Team agents are specialized AI assistants with different roles and expertise.
83
+
84
+ Use $agent to mention an agent (e.g., "$arch review this design", "$qa write tests").
85
+
86
+ Available roles:
87
+ - $dev — Software developer (coding, debugging)
88
+ - $pm — Product manager (requirements, priorities)
89
+ - $qa — QA engineer (testing, quality)
90
+ - $arch — Architect (design, patterns, decisions)
91
+ - $writer — Technical writer (docs, README)
92
+ - $researcher — Research assistant (literature, analysis)
93
+ - $reviewer — Code/content reviewer
94
+ - $editor — Content editor (prose, structure)
95
+ - $analyst — Data/business analyst
96
+ - $strategist — Strategy and planning
97
+ - $instructor — Teaching and course design
98
+
99
+ Each role has a tailored system prompt and tool set.`,
100
+ },
101
+ {
102
+ id: 'coordinator-mode',
103
+ title: 'Coordinator Mode',
104
+ keywords: ['coordinator', 'delegation', 'delegate', 'background', 'multi-agent'],
105
+ content: `Coordinator mode allows one agent to delegate tasks to others.
106
+
107
+ The coordinator can:
108
+ - delegate_background: Send a task to another agent to run in background
109
+ - delegation_status: Check on running delegations
110
+ - Receive results when delegated tasks complete
111
+
112
+ Useful for: code review ($qa), documentation ($writer), architecture analysis ($arch).
113
+
114
+ The delegated agent runs independently and returns results to the coordinator.`,
115
+ },
116
+ // ── Skills ──────────────────────────────────────────────────────────────
117
+ {
118
+ id: 'skills-overview',
119
+ title: 'Skills Overview',
120
+ keywords: ['skills', 'slash', 'command', '/'],
121
+ content: `Skills are pre-built prompts that guide the agent through specific workflows.
122
+
123
+ Use them by typing / followed by the skill name (e.g., /design, /build).
124
+
125
+ Skills vary by project type. Software projects have: /design, /prd, /architecture, /scaffold, /build, /backlog, /session-notes.
126
+
127
+ Research projects have: /outline, /literature-review, /methodology, /abstract.
128
+
129
+ Business projects have: /business-vision, /market-analysis, /financial-model, /pitch.
130
+
131
+ Skills can be combined with your own instructions: type /design then add context.`,
132
+ },
133
+ // ── Models & Providers ──────────────────────────────────────────────────
134
+ {
135
+ id: 'models',
136
+ title: 'Models and Providers',
137
+ keywords: ['model', 'provider', 'claude', 'openai', 'gemini', 'ollama', 'llm'],
138
+ content: `Compilr Dev supports multiple LLM providers:
139
+
140
+ - Claude (Anthropic) — Claude Opus, Sonnet, Haiku
141
+ - OpenAI — GPT-4o, GPT-4o-mini
142
+ - Gemini (Google) — Gemini 2.5 Pro, Flash
143
+ - Ollama — Local models (llama, codellama, etc.)
144
+ - Together, Groq, Fireworks, Perplexity, OpenRouter
145
+
146
+ Each provider requires an API key (except Ollama which runs locally).
147
+ Models are organized by tier: premium, balanced, fast.`,
148
+ },
149
+ // ── Context & Memory ────────────────────────────────────────────────────
150
+ {
151
+ id: 'file-references',
152
+ title: 'File References (@file)',
153
+ keywords: ['file', 'reference', '@', 'attach', 'mention'],
154
+ content: `Reference files in your messages with @filename.
155
+
156
+ Examples:
157
+ @src/index.ts — Agent reads this file for context
158
+ @package.json — Agent checks dependencies
159
+
160
+ The agent will use its tools to read the referenced files.`,
161
+ },
162
+ {
163
+ id: 'compilr-md',
164
+ title: 'COMPILR.md — Project Context',
165
+ keywords: ['compilr.md', 'context', 'project', 'instructions'],
166
+ content: `COMPILR.md is a markdown file in your project root that gives the agent context.
167
+
168
+ It can include:
169
+ - Project description and goals
170
+ - Tech stack and dependencies
171
+ - Coding conventions
172
+ - Build/test commands
173
+ - Important file locations
174
+
175
+ The agent reads this on every conversation to understand your project.
176
+ Create one manually or let the agent generate it.`,
177
+ },
178
+ {
179
+ id: 'knowledge-base',
180
+ title: 'Knowledge Base',
181
+ keywords: ['knowledge', 'kb', 'reference', 'docs', 'upload', 'pin'],
182
+ content: `The knowledge base stores reference documents for your project.
183
+
184
+ You can add:
185
+ - Files (code, markdown, text, PDF, images)
186
+ - Pasted text snippets
187
+ - URLs (web page content imported)
188
+
189
+ Pin important files to include them in every agent conversation.
190
+ Unpinned files are available on-demand (agent uses view tools).
191
+
192
+ Images in the KB can be viewed by the agent using the view_image tool.`,
193
+ },
194
+ {
195
+ id: 'context-management',
196
+ title: 'Context Management',
197
+ keywords: ['context', 'tokens', 'compaction', 'observation', 'masking', 'window'],
198
+ content: `The agent manages its context window automatically:
199
+
200
+ - Observation masking: Old tool results replaced with compact summaries after a few turns
201
+ - Image masking: Old images replaced with text placeholders (saves 1000+ tokens per image)
202
+ - Tool output compression: Large outputs compressed by 60-90% (git, npm, file listings)
203
+ - Smart windowing: Oldest messages compacted when context fills up
204
+
205
+ You can see context utilization in the status bar or via /context.`,
206
+ },
207
+ // ── Permissions ─────────────────────────────────────────────────────────
208
+ {
209
+ id: 'permissions',
210
+ title: 'Permissions',
211
+ keywords: ['permission', 'approve', 'deny', 'auto-accept', 'security'],
212
+ content: `Agents ask permission before running potentially dangerous tools.
213
+
214
+ Permission modes:
215
+ - Normal — Agent asks before bash, edit, write operations
216
+ - Auto-accept — Automatically approve all tool calls (faster, less safe)
217
+
218
+ You can set per-tool rules (always allow, always deny, always ask).
219
+
220
+ In restricted mode (untrusted workspace), bash/edit/write are blocked entirely.`,
221
+ },
222
+ // ── Images ──────────────────────────────────────────────────────────────
223
+ {
224
+ id: 'image-support',
225
+ title: 'Image Support',
226
+ keywords: ['image', 'screenshot', 'picture', 'paste', 'vision', 'multimodal'],
227
+ content: `You can send images to agents for visual analysis.
228
+
229
+ Supported formats: PNG, JPEG, GIF, WebP.
230
+
231
+ Images are automatically resized to max 1568px (Claude's recommended max) to save tokens.
232
+ After a few turns, images are replaced with text placeholders to further reduce token cost.
233
+
234
+ The agent can also view image files from disk using the view_image tool.
235
+
236
+ All major providers support images: Claude, OpenAI GPT-4o, Gemini.`,
237
+ },
238
+ // ── Workspace Trust ─────────────────────────────────────────────────────
239
+ {
240
+ id: 'workspace-trust',
241
+ title: 'Workspace Trust',
242
+ keywords: ['trust', 'restricted', 'security', 'untrusted', 'safe'],
243
+ content: `When you open a project for the first time, you're asked to trust it.
244
+
245
+ Trusted projects: Full agent capabilities — bash, file editing, terminal.
246
+ Restricted projects: Read-only — agents can read files and answer questions but cannot run commands or modify files.
247
+
248
+ You can change trust status by clicking the "Restricted" badge in the status bar.
249
+
250
+ Trust is inherited: if you trust /projects/myapp, all subdirectories are also trusted.`,
251
+ },
252
+ // ── Anchors ─────────────────────────────────────────────────────────────
253
+ {
254
+ id: 'anchors',
255
+ title: 'Anchors — Persistent Context',
256
+ keywords: ['anchor', 'pin', 'persistent', 'important', 'remember'],
257
+ content: `Anchors are persistent notes that stay in the agent's context across conversations.
258
+
259
+ Use them for:
260
+ - Architecture decisions ("We chose PostgreSQL because...")
261
+ - Important conventions ("All API routes use camelCase")
262
+ - Work-in-progress notes ("Auth module is half-done, don't touch")
263
+
264
+ Anchors survive session restarts and project switches.
265
+ The agent sees them in every conversation.`,
266
+ },
267
+ ];
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Guide types — shared across SDK, CLI, and Desktop.
3
+ */
4
+ /**
5
+ * A single guide entry the agent can return to the user.
6
+ */
7
+ export interface GuideEntry {
8
+ id: string;
9
+ title: string;
10
+ keywords: string[];
11
+ content: string;
12
+ }
13
+ /**
14
+ * Structured content topic (used for tutorials in CLI, converted to GuideEntry for the tool).
15
+ */
16
+ export interface ContentSection {
17
+ title?: string;
18
+ items: string[];
19
+ }
20
+ export interface ContentTopic {
21
+ id: string;
22
+ title: string;
23
+ keywords: string[];
24
+ sections: ContentSection[];
25
+ }
26
+ /**
27
+ * Configuration for the guide tool factory.
28
+ */
29
+ export interface GuideToolConfig {
30
+ /** Which environment the tool is running in */
31
+ environment: 'cli' | 'desktop';
32
+ /** Additional environment-specific content to merge with shared content */
33
+ additionalEntries?: GuideEntry[];
34
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Guide types — shared across SDK, CLI, and Desktop.
3
+ */
4
+ export {};
package/dist/index.d.ts CHANGED
@@ -58,8 +58,10 @@ export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemReposi
58
58
  export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './platform/index.js';
59
59
  export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
60
60
  export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './tools/index.js';
61
- export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, ProjectAnchorStore, } from './platform/index.js';
62
- export type { ProjectAnchorStoreConfig } from './platform/index.js';
61
+ export { createGuideTool, SHARED_GUIDE_ENTRIES, searchGuideEntries, topicToGuideEntry, } from './guide/index.js';
62
+ export type { GuideEntry, ContentTopic, ContentSection, GuideToolConfig } from './guide/index.js';
63
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createImageTools, ProjectAnchorStore, } from './platform/index.js';
64
+ export type { ProjectAnchorStoreConfig, ImageToolsConfig, ImageResizer } from './platform/index.js';
63
65
  export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
64
66
  export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, financialModelSkill, pitchOutlineSkill, businessReviewSkill, brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './skills/index.js';
65
67
  export { ACTION_REGISTRY, getActionsForContext, getActionById, resolveActionPrompt, buildContextSummary, getSuggestedRole, } from './actions/index.js';
package/dist/index.js CHANGED
@@ -129,9 +129,13 @@ export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemReposi
129
129
  // =============================================================================
130
130
  export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
131
131
  // =============================================================================
132
+ // Guide Tool (environment-aware documentation)
133
+ // =============================================================================
134
+ export { createGuideTool, SHARED_GUIDE_ENTRIES, searchGuideEntries, topicToGuideEntry, } from './guide/index.js';
135
+ // =============================================================================
132
136
  // Platform Tools (runtime — createPlatformTools factory + individual factories)
133
137
  // =============================================================================
134
- export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, ProjectAnchorStore, } from './platform/index.js';
138
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createImageTools, ProjectAnchorStore, } from './platform/index.js';
135
139
  // =============================================================================
136
140
  // Platform Workflow (pure step-criteria logic)
137
141
  // =============================================================================
@@ -5,7 +5,8 @@ export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleSt
5
5
  export type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository, } from './repositories.js';
6
6
  export type { IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, } from './services.js';
7
7
  export type { PlatformContext, PlatformToolsConfig, PlatformHooks } from './context.js';
8
- export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
8
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createImageTools, } from './tools/index.js';
9
+ export type { ImageToolsConfig, ImageResizer } from './tools/index.js';
9
10
  export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
10
11
  export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './sqlite/index.js';
11
12
  export { ProjectAnchorStore } from './file-anchor-service.js';
@@ -2,7 +2,7 @@
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, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
5
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createImageTools, } from './tools/index.js';
6
6
  // SQLite implementations (concrete repositories)
7
7
  export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
8
8
  // File-based anchor service (shared by CLI and Desktop)
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Image Tools — View image files for visual analysis.
3
+ *
4
+ * 1 tool: view_image
5
+ *
6
+ * Returns image data as imageBlocks on ToolExecutionResult, which the agent
7
+ * injects as sibling content blocks alongside the tool_result message.
8
+ * This lets vision-capable LLMs see the image.
9
+ */
10
+ /**
11
+ * Max dimension for resizing. Claude recommends 1568px max.
12
+ * Resizing is optional — only applied if a resizer function is provided.
13
+ */
14
+ export declare const DEFAULT_MAX_DIMENSION = 1568;
15
+ /**
16
+ * Optional image resizer function. Provided by the host environment
17
+ * (e.g., Electron's nativeImage, sharp, etc.)
18
+ */
19
+ export interface ImageResizer {
20
+ resize(data: Uint8Array, maxDimension: number): Promise<{
21
+ data: Uint8Array;
22
+ width: number;
23
+ height: number;
24
+ mediaType: string;
25
+ }>;
26
+ }
27
+ export interface ImageToolsConfig {
28
+ /** Working directory for resolving relative paths */
29
+ cwd?: string;
30
+ /** Optional image resizer (e.g., nativeImage in Electron) */
31
+ resizer?: ImageResizer;
32
+ /** Max dimension for resize (default: 1568) */
33
+ maxDimension?: number;
34
+ }
35
+ export declare function createImageTools(config?: ImageToolsConfig): readonly [import("@compilr-dev/agents").Tool<{
36
+ path: string;
37
+ }>];
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Image Tools — View image files for visual analysis.
3
+ *
4
+ * 1 tool: view_image
5
+ *
6
+ * Returns image data as imageBlocks on ToolExecutionResult, which the agent
7
+ * injects as sibling content blocks alongside the tool_result message.
8
+ * This lets vision-capable LLMs see the image.
9
+ */
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import { defineTool, createErrorResult } from '@compilr-dev/agents';
13
+ /** Supported image MIME types */
14
+ const IMAGE_EXTENSIONS = {
15
+ '.png': 'image/png',
16
+ '.jpg': 'image/jpeg',
17
+ '.jpeg': 'image/jpeg',
18
+ '.gif': 'image/gif',
19
+ '.webp': 'image/webp',
20
+ };
21
+ /** Max file size: 10MB (base64 will be ~13MB, well within API limits) */
22
+ const MAX_FILE_SIZE = 10 * 1024 * 1024;
23
+ /**
24
+ * Max dimension for resizing. Claude recommends 1568px max.
25
+ * Resizing is optional — only applied if a resizer function is provided.
26
+ */
27
+ export const DEFAULT_MAX_DIMENSION = 1568;
28
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
29
+ export function createImageTools(config = {}) {
30
+ const cwd = config.cwd ?? process.cwd();
31
+ const maxDimension = config.maxDimension ?? DEFAULT_MAX_DIMENSION;
32
+ const viewImageTool = defineTool({
33
+ name: 'view_image',
34
+ description: 'View an image file for visual analysis. Returns the image so you can see it. ' +
35
+ 'Supports PNG, JPEG, GIF, and WebP formats.',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ path: {
40
+ type: 'string',
41
+ description: 'Path to the image file (absolute or relative to working directory)',
42
+ },
43
+ },
44
+ required: ['path'],
45
+ },
46
+ execute: async (input) => {
47
+ // Resolve path
48
+ const filePath = path.isAbsolute(input.path) ? input.path : path.resolve(cwd, input.path);
49
+ // Validate file exists
50
+ if (!fs.existsSync(filePath)) {
51
+ return createErrorResult(`File not found: ${input.path}`);
52
+ }
53
+ // Validate extension
54
+ const ext = path.extname(filePath).toLowerCase();
55
+ const mediaType = IMAGE_EXTENSIONS[ext];
56
+ if (!mediaType) {
57
+ const supported = Object.keys(IMAGE_EXTENSIONS).join(', ');
58
+ return createErrorResult(`Unsupported image format: ${ext}. Supported formats: ${supported}`);
59
+ }
60
+ // Check file size
61
+ const stat = fs.statSync(filePath);
62
+ if (stat.size > MAX_FILE_SIZE) {
63
+ const sizeMB = (stat.size / (1024 * 1024)).toFixed(1);
64
+ return createErrorResult(`Image too large: ${sizeMB}MB (max 10MB)`);
65
+ }
66
+ // Read file
67
+ let imageData = fs.readFileSync(filePath);
68
+ let finalMediaType = mediaType;
69
+ let width;
70
+ let height;
71
+ // Optional resize
72
+ if (config.resizer) {
73
+ try {
74
+ const resized = await config.resizer.resize(imageData, maxDimension);
75
+ imageData = resized.data;
76
+ width = resized.width;
77
+ height = resized.height;
78
+ finalMediaType = resized.mediaType;
79
+ }
80
+ catch {
81
+ // Resize failed — use original data
82
+ }
83
+ }
84
+ const base64 = Buffer.from(imageData).toString('base64');
85
+ const filename = path.basename(filePath);
86
+ return {
87
+ success: true,
88
+ result: `Image loaded: ${filename} (${finalMediaType})`,
89
+ imageBlocks: [
90
+ {
91
+ data: base64,
92
+ mediaType: finalMediaType,
93
+ filename,
94
+ width,
95
+ height,
96
+ },
97
+ ],
98
+ };
99
+ },
100
+ });
101
+ return [viewImageTool];
102
+ }
@@ -1,20 +1,22 @@
1
1
  /**
2
2
  * Platform Tools — Factory function for all platform tools.
3
3
  *
4
- * Returns up to 33 tool definitions operating against async PlatformContext.
4
+ * Returns up to 34 tool definitions operating against async PlatformContext.
5
5
  * - 25 DB tools (always): project, workitem (incl. comment), document, plan, backlog
6
+ * - 1 image tool (always): view_image
6
7
  * - 3 anchor tools (if ctx.anchors provided)
7
8
  * - 4 artifact tools (if ctx.artifacts provided)
8
9
  * - 1 episode tool (if ctx.episodes provided)
9
10
  */
10
11
  import type { Tool } from '@compilr-dev/agents';
11
12
  import type { PlatformToolsConfig } from '../context.js';
13
+ import type { ImageToolsConfig } from './image-tools.js';
12
14
  /**
13
15
  * 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.
16
+ * Returns 25 DB tools + 1 image tool unconditionally, plus up to 8 service-based
17
+ * tools if the optional anchors/artifacts/episodes services are provided.
16
18
  */
17
- export declare function createPlatformTools(config: PlatformToolsConfig): Tool<never>[];
19
+ export declare function createPlatformTools(config: PlatformToolsConfig, imageConfig?: ImageToolsConfig): Tool<never>[];
18
20
  export { createProjectTools } from './project-tools.js';
19
21
  export { createWorkItemTools } from './workitem-tools.js';
20
22
  export { createDocumentTools } from './document-tools.js';
@@ -23,3 +25,5 @@ export { createBacklogTools } from './backlog-tools.js';
23
25
  export { createAnchorTools } from './anchor-tools.js';
24
26
  export { createArtifactTools } from './artifact-tools.js';
25
27
  export { createEpisodeTools } from './episode-tools.js';
28
+ export { createImageTools } from './image-tools.js';
29
+ export type { ImageToolsConfig, ImageResizer } from './image-tools.js';
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Platform Tools — Factory function for all platform tools.
3
3
  *
4
- * Returns up to 33 tool definitions operating against async PlatformContext.
4
+ * Returns up to 34 tool definitions operating against async PlatformContext.
5
5
  * - 25 DB tools (always): project, workitem (incl. comment), document, plan, backlog
6
+ * - 1 image tool (always): view_image
6
7
  * - 3 anchor tools (if ctx.anchors provided)
7
8
  * - 4 artifact tools (if ctx.artifacts provided)
8
9
  * - 1 episode tool (if ctx.episodes provided)
@@ -15,13 +16,14 @@ import { createBacklogTools } from './backlog-tools.js';
15
16
  import { createAnchorTools } from './anchor-tools.js';
16
17
  import { createArtifactTools } from './artifact-tools.js';
17
18
  import { createEpisodeTools } from './episode-tools.js';
19
+ import { createImageTools } from './image-tools.js';
18
20
  /**
19
21
  * 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.
22
+ * Returns 25 DB tools + 1 image tool unconditionally, plus up to 8 service-based
23
+ * tools if the optional anchors/artifacts/episodes services are provided.
22
24
  */
23
25
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
24
- export function createPlatformTools(config) {
26
+ export function createPlatformTools(config, imageConfig) {
25
27
  // Use Tool<never>[] to accept any Tool<T> — the generic parameter is only
26
28
  // relevant to execute() callers, not to the registry that stores them.
27
29
  const tools = [
@@ -30,6 +32,7 @@ export function createPlatformTools(config) {
30
32
  ...createDocumentTools(config),
31
33
  ...createPlanTools(config),
32
34
  ...createBacklogTools(config),
35
+ ...createImageTools({ cwd: config.cwd, ...imageConfig }),
33
36
  ];
34
37
  if (config.context.anchors) {
35
38
  tools.push(...createAnchorTools(config));
@@ -51,3 +54,4 @@ export { createBacklogTools } from './backlog-tools.js';
51
54
  export { createAnchorTools } from './anchor-tools.js';
52
55
  export { createArtifactTools } from './artifact-tools.js';
53
56
  export { createEpisodeTools } from './episode-tools.js';
57
+ export { createImageTools } from './image-tools.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",