@compilr-dev/sdk 0.7.13 → 0.7.15

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/agent.js CHANGED
@@ -99,9 +99,7 @@ class CompilrAgentImpl {
99
99
  apiKey: config?.apiKey,
100
100
  });
101
101
  // Resolve preset — non-software projects get 'general' by default
102
- const defaultPreset = config?.projectCategory && config.projectCategory !== 'software'
103
- ? 'general'
104
- : 'coding';
102
+ const defaultPreset = config?.projectCategory && config.projectCategory !== 'software' ? 'general' : 'coding';
105
103
  const preset = resolvePreset(config?.preset ?? defaultPreset);
106
104
  // Build system prompt
107
105
  let systemPrompt;
@@ -239,6 +237,41 @@ class CompilrAgentImpl {
239
237
  : [];
240
238
  mergedHooks.beforeLLM = [...existingHooks, ...capabilityHooks];
241
239
  }
240
+ // Build observation mask config — SDK defaults include platform tools
241
+ const observationMask = config?.context?.observationMask !== false
242
+ ? {
243
+ maskAfterTurns: 3,
244
+ minCharsToMask: 200,
245
+ alwaysMaskEarly: [
246
+ // Coding tools (agents library defaults)
247
+ 'read_file',
248
+ 'bash',
249
+ 'bash_output',
250
+ 'grep',
251
+ 'glob',
252
+ // Platform document/model tools (large results)
253
+ 'project_document_get',
254
+ 'project_document_list',
255
+ 'backlog_read',
256
+ 'workitem_query',
257
+ // Factory model tools
258
+ 'app_model_get',
259
+ 'research_model_get',
260
+ 'business_model_get',
261
+ 'brand_model_get',
262
+ 'curriculum_model_get',
263
+ 'book_model_get',
264
+ // Other large-output tools
265
+ 'anchor_list',
266
+ 'artifact_list',
267
+ 'plan_get',
268
+ ],
269
+ // Merge user overrides if provided
270
+ ...(typeof config?.context?.observationMask === 'object'
271
+ ? config.context.observationMask
272
+ : {}),
273
+ }
274
+ : false;
242
275
  this.agent = new Agent({
243
276
  provider,
244
277
  systemPrompt,
@@ -246,6 +279,7 @@ class CompilrAgentImpl {
246
279
  toolTimeoutMs: config?.toolTimeoutMs,
247
280
  contextManager,
248
281
  autoContextManagement: contextManager !== undefined,
282
+ observationMask: contextManager ? observationMask : undefined,
249
283
  hooks: mergedHooks,
250
284
  pins: {},
251
285
  permissions: {
@@ -279,13 +313,15 @@ class CompilrAgentImpl {
279
313
  }
280
314
  }
281
315
  async run(message, options) {
282
- // Set external listener so constructor's onEvent can forward events
316
+ // Set external listener so constructor's onEvent can forward events.
317
+ // Do NOT also pass onEvent to agent.run() — the underlying Agent's emit()
318
+ // already calls both this.onEvent (constructor) AND options.onEvent (per-run).
319
+ // Passing the same callback via both paths would double-deliver every event.
283
320
  this.externalEventListener = options?.onEvent;
284
321
  try {
285
322
  const result = await this.agent.run(message, {
286
323
  signal: options?.signal ?? this.abortController.signal,
287
324
  maxIterations: options?.maxIterations,
288
- onEvent: options?.onEvent,
289
325
  toolFilter: options?.toolFilter,
290
326
  });
291
327
  return toRunResult(result);
@@ -261,13 +261,26 @@ export const CAPABILITY_PACKS = {
261
261
  id: 'factory_models',
262
262
  label: 'Structured Models',
263
263
  tools: [
264
- 'app_model_get', 'app_model_update', 'app_model_validate',
265
- 'research_model_get', 'research_model_update', 'research_model_validate',
266
- 'bibliography_generate', 'bibtex_import',
267
- 'business_model_get', 'business_model_update', 'business_model_validate',
268
- 'brand_model_get', 'brand_model_update', 'brand_model_validate',
269
- 'curriculum_model_get', 'curriculum_model_update', 'curriculum_model_validate',
270
- 'book_model_get', 'book_model_update', 'book_model_validate',
264
+ 'app_model_get',
265
+ 'app_model_update',
266
+ 'app_model_validate',
267
+ 'research_model_get',
268
+ 'research_model_update',
269
+ 'research_model_validate',
270
+ 'bibliography_generate',
271
+ 'bibtex_import',
272
+ 'business_model_get',
273
+ 'business_model_update',
274
+ 'business_model_validate',
275
+ 'brand_model_get',
276
+ 'brand_model_update',
277
+ 'brand_model_validate',
278
+ 'curriculum_model_get',
279
+ 'curriculum_model_update',
280
+ 'curriculum_model_validate',
281
+ 'book_model_get',
282
+ 'book_model_update',
283
+ 'book_model_validate',
271
284
  ],
272
285
  readOnly: false,
273
286
  promptModules: ['factory-tool-hints'],
@@ -279,8 +292,12 @@ export const CAPABILITY_PACKS = {
279
292
  id: 'factory_scaffold',
280
293
  label: 'Code Scaffolding',
281
294
  tools: [
282
- 'factory_scaffold', 'factory_list_toolkits',
283
- 'research_scaffold', 'business_scaffold', 'content_scaffold', 'book_scaffold',
295
+ 'factory_scaffold',
296
+ 'factory_list_toolkits',
297
+ 'research_scaffold',
298
+ 'business_scaffold',
299
+ 'content_scaffold',
300
+ 'book_scaffold',
284
301
  ],
285
302
  readOnly: false,
286
303
  promptModules: ['factory-tool-hints'],
package/dist/config.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * SDK configuration types
3
3
  */
4
- import type { LLMProvider, Message, Tool, ToolPermission, HooksConfig, AnchorInput, AgentEvent, ToolExecutionResult, DelegationConfig } from '@compilr-dev/agents';
4
+ import type { LLMProvider, Message, Tool, ToolPermission, HooksConfig, AnchorInput, AgentEvent, ToolExecutionResult, DelegationConfig, ObservationMaskConfig } from '@compilr-dev/agents';
5
5
  import type { Preset } from './presets/types.js';
6
6
  import type { ToolProfile } from './team/tool-config.js';
7
7
  import type { ConditionalModule } from './capabilities/hook.js';
@@ -100,6 +100,12 @@ export interface ContextConfig {
100
100
  compactionThreshold?: number;
101
101
  /** Threshold (0-1) to trigger emergency summarization. Default: 0.9 */
102
102
  summarizationThreshold?: number;
103
+ /**
104
+ * Observation masking — replaces old tool results with compact placeholders.
105
+ * When omitted, SDK defaults are used (includes platform tools in alwaysMaskEarly).
106
+ * Set to false to disable masking entirely.
107
+ */
108
+ observationMask?: Partial<ObservationMaskConfig> | false;
103
109
  }
104
110
  /**
105
111
  * Usage information for the agent
@@ -1,15 +1,22 @@
1
1
  /**
2
2
  * Document Tools — CRUD operations for project documents.
3
3
  *
4
- * 4 tools: project_document_add, project_document_get,
5
- * project_document_list, project_document_delete
4
+ * 5 tools: project_document_add, project_document_get,
5
+ * project_document_list, project_document_delete,
6
+ * project_document_patch
6
7
  *
7
8
  * Ported from CLI's src/tools/document-db.ts.
8
9
  */
9
10
  import type { PlatformToolsConfig } from '../context.js';
10
- export declare function createDocumentTools(config: PlatformToolsConfig): import("@compilr-dev/agents").Tool<{
11
+ export declare function createDocumentTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
11
12
  project_id?: number;
12
13
  doc_type: string;
13
14
  title: string;
14
15
  content: string;
15
- }>[];
16
+ }> | import("@compilr-dev/agents").Tool<{
17
+ project_id?: number;
18
+ doc_type: string;
19
+ operation: string;
20
+ content: string;
21
+ section_heading?: string;
22
+ }>)[];
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Document Tools — CRUD operations for project documents.
3
3
  *
4
- * 4 tools: project_document_add, project_document_get,
5
- * project_document_list, project_document_delete
4
+ * 5 tools: project_document_add, project_document_get,
5
+ * project_document_list, project_document_delete,
6
+ * project_document_patch
6
7
  *
7
8
  * Ported from CLI's src/tools/document-db.ts.
8
9
  */
@@ -10,19 +11,41 @@ import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev
10
11
  /** All valid document types — keep in sync with DocumentType in types.ts. */
11
12
  const DOC_TYPE_ENUM = [
12
13
  // Software
13
- 'prd', 'architecture', 'design', 'notes', 'plan',
14
+ 'prd',
15
+ 'architecture',
16
+ 'design',
17
+ 'notes',
18
+ 'plan',
14
19
  // Structured models
15
- 'app-model', 'research-model', 'business-model', 'brand-model', 'curriculum-model', 'book-model',
20
+ 'app-model',
21
+ 'research-model',
22
+ 'business-model',
23
+ 'brand-model',
24
+ 'curriculum-model',
25
+ 'book-model',
16
26
  // Research
17
- 'outline', 'literature-review', 'abstract', 'methodology', 'bibliography',
27
+ 'outline',
28
+ 'literature-review',
29
+ 'abstract',
30
+ 'methodology',
31
+ 'bibliography',
18
32
  // Business
19
- 'executive-summary', 'market-analysis', 'financial-model', 'pitch',
33
+ 'executive-summary',
34
+ 'market-analysis',
35
+ 'financial-model',
36
+ 'pitch',
20
37
  // Content & Marketing
21
- 'editorial-calendar', 'article',
38
+ 'editorial-calendar',
39
+ 'article',
22
40
  // Tech Docs
23
- 'getting-started', 'api-reference', 'tutorial',
41
+ 'getting-started',
42
+ 'api-reference',
43
+ 'tutorial',
24
44
  // General
25
- 'draft', 'review', 'session-notes', 'chapter',
45
+ 'draft',
46
+ 'review',
47
+ 'session-notes',
48
+ 'chapter',
26
49
  ];
27
50
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
28
51
  export function createDocumentTools(config) {
@@ -225,10 +248,133 @@ export function createDocumentTools(config) {
225
248
  }
226
249
  },
227
250
  });
251
+ // ---------------------------------------------------------------------------
252
+ // project_document_patch
253
+ // ---------------------------------------------------------------------------
254
+ const projectDocumentPatchTool = defineTool({
255
+ name: 'project_document_patch',
256
+ description: 'Patch a project document without reading the full content. ' +
257
+ 'Supports append, prepend, and replace_section operations. ' +
258
+ 'The full document is read and modified server-side — only the patch content goes through context.',
259
+ inputSchema: {
260
+ type: 'object',
261
+ properties: {
262
+ doc_type: {
263
+ type: 'string',
264
+ enum: DOC_TYPE_ENUM,
265
+ description: 'Document type to patch',
266
+ },
267
+ operation: {
268
+ type: 'string',
269
+ enum: ['append', 'prepend', 'replace_section'],
270
+ description: 'append: add content to end. ' +
271
+ 'prepend: add content to beginning. ' +
272
+ 'replace_section: replace content under a markdown heading (## Heading).',
273
+ },
274
+ content: {
275
+ type: 'string',
276
+ description: 'Content to insert or replace with',
277
+ },
278
+ section_heading: {
279
+ type: 'string',
280
+ description: 'Required for replace_section. The exact markdown heading text (e.g., "## Section 4: Results"). ' +
281
+ 'Replaces everything from this heading to the next heading of equal or higher level (or end of document).',
282
+ },
283
+ project_id: {
284
+ type: 'number',
285
+ description: 'Override active project.',
286
+ },
287
+ },
288
+ required: ['doc_type', 'operation', 'content'],
289
+ },
290
+ execute: async (input) => {
291
+ try {
292
+ const projectId = input.project_id ?? ctx.currentProjectId;
293
+ if (!projectId) {
294
+ return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
295
+ }
296
+ const doc = await ctx.documents.getByType(projectId, input.doc_type);
297
+ if (!doc) {
298
+ return createErrorResult(`No ${input.doc_type} document found. Use project_document_add to create it first.`);
299
+ }
300
+ let newContent;
301
+ switch (input.operation) {
302
+ case 'append':
303
+ newContent = doc.content + '\n\n' + input.content;
304
+ break;
305
+ case 'prepend':
306
+ newContent = input.content + '\n\n' + doc.content;
307
+ break;
308
+ case 'replace_section': {
309
+ if (!input.section_heading) {
310
+ return createErrorResult('section_heading is required for replace_section operation.');
311
+ }
312
+ const heading = input.section_heading.trim();
313
+ // Determine heading level from the target
314
+ const headingLevel = heading.match(/^(#{1,6})\s/)?.[1]?.length ?? 2;
315
+ // Find the heading in the document
316
+ const lines = doc.content.split('\n');
317
+ let sectionStart = -1;
318
+ let sectionEnd = lines.length;
319
+ for (let i = 0; i < lines.length; i++) {
320
+ const line = lines[i].trim();
321
+ if (sectionStart === -1) {
322
+ // Look for the target heading
323
+ if (line === heading) {
324
+ sectionStart = i;
325
+ }
326
+ }
327
+ else {
328
+ // Look for the next heading of same or higher level
329
+ const nextMatch = line.match(/^(#{1,6})\s/);
330
+ if (nextMatch && nextMatch[1].length <= headingLevel) {
331
+ sectionEnd = i;
332
+ break;
333
+ }
334
+ }
335
+ }
336
+ if (sectionStart === -1) {
337
+ return createErrorResult(`Section "${heading}" not found in document. Available headings: ${lines
338
+ .filter((l) => l.trim().match(/^#{1,6}\s/))
339
+ .map((l) => l.trim())
340
+ .join(', ') || '(none)'}`);
341
+ }
342
+ // Replace the section (heading + body) with new content
343
+ const before = lines.slice(0, sectionStart).join('\n');
344
+ const after = lines.slice(sectionEnd).join('\n');
345
+ newContent = [before, input.content, after].filter((s) => s.length > 0).join('\n\n');
346
+ break;
347
+ }
348
+ default:
349
+ return createErrorResult(`Unknown operation: ${input.operation}. Use append, prepend, or replace_section.`);
350
+ }
351
+ const updated = await ctx.documents.update(doc.id, { content: newContent });
352
+ if (!updated) {
353
+ return createErrorResult('Failed to update document.');
354
+ }
355
+ return createSuccessResult({
356
+ success: true,
357
+ message: `Document "${doc.title}" patched (${input.operation})`,
358
+ document: {
359
+ id: updated.id,
360
+ docType: updated.docType,
361
+ title: updated.title,
362
+ contentLength: updated.content.length,
363
+ previousLength: doc.content.length,
364
+ updatedAt: updated.updatedAt.toISOString(),
365
+ },
366
+ });
367
+ }
368
+ catch (error) {
369
+ return createErrorResult(`Failed to patch document: ${error instanceof Error ? error.message : String(error)}`);
370
+ }
371
+ },
372
+ });
228
373
  return [
229
374
  projectDocumentAddTool,
230
375
  projectDocumentGetTool,
231
376
  projectDocumentListTool,
232
377
  projectDocumentDeleteTool,
378
+ projectDocumentPatchTool,
233
379
  ];
234
380
  }
@@ -55,29 +55,129 @@ export const ACTION_META_REGISTRY = {
55
55
  description: 'Review the paper',
56
56
  },
57
57
  // ── Business Plan project actions ──────────────────────────────────────────
58
- 'business-vision': { id: 'business-vision', label: 'Vision', icon: 'Target', description: 'Define your business' },
59
- 'market-analysis': { id: 'market-analysis', label: 'Market', icon: 'TrendingUp', description: 'Analyze the market' },
60
- 'competitor-analysis': { id: 'competitor-analysis', label: 'Competitors', icon: 'Swords', description: 'Map competition' },
58
+ 'business-vision': {
59
+ id: 'business-vision',
60
+ label: 'Vision',
61
+ icon: 'Target',
62
+ description: 'Define your business',
63
+ },
64
+ 'market-analysis': {
65
+ id: 'market-analysis',
66
+ label: 'Market',
67
+ icon: 'TrendingUp',
68
+ description: 'Analyze the market',
69
+ },
70
+ 'competitor-analysis': {
71
+ id: 'competitor-analysis',
72
+ label: 'Competitors',
73
+ icon: 'Swords',
74
+ description: 'Map competition',
75
+ },
61
76
  // ── Content & Marketing actions ───────────────────────────────────────────
62
- 'brand-setup': { id: 'brand-setup', label: 'Brand', icon: 'Palette', description: 'Set up brand identity' },
63
- 'content-strategy': { id: 'content-strategy', label: 'Strategy', icon: 'Target', description: 'Define pillars' },
64
- 'content-calendar': { id: 'content-calendar', label: 'Calendar', icon: 'Calendar', description: 'Plan content' },
65
- 'create-content': { id: 'create-content', label: 'Create', icon: 'PenTool', description: 'Write content' },
66
- 'content-review': { id: 'content-review', label: 'Review', icon: 'CheckCircle', description: 'Check quality' },
77
+ 'brand-setup': {
78
+ id: 'brand-setup',
79
+ label: 'Brand',
80
+ icon: 'Palette',
81
+ description: 'Set up brand identity',
82
+ },
83
+ 'content-strategy': {
84
+ id: 'content-strategy',
85
+ label: 'Strategy',
86
+ icon: 'Target',
87
+ description: 'Define pillars',
88
+ },
89
+ 'content-calendar': {
90
+ id: 'content-calendar',
91
+ label: 'Calendar',
92
+ icon: 'Calendar',
93
+ description: 'Plan content',
94
+ },
95
+ 'create-content': {
96
+ id: 'create-content',
97
+ label: 'Create',
98
+ icon: 'PenTool',
99
+ description: 'Write content',
100
+ },
101
+ 'content-review': {
102
+ id: 'content-review',
103
+ label: 'Review',
104
+ icon: 'CheckCircle',
105
+ description: 'Check quality',
106
+ },
67
107
  // ── Book actions ─────────────────────────────────────────────────────────
68
- 'book-outline': { id: 'book-outline', label: 'Outline', icon: 'BookOpen', description: 'Plan structure' },
69
- 'character-design': { id: 'character-design', label: 'Characters', icon: 'Users', description: 'Build cast' },
70
- 'plot-threads': { id: 'plot-threads', label: 'Threads', icon: 'GitBranch', description: 'Map plot lines' },
71
- 'scene-breakdown': { id: 'scene-breakdown', label: 'Scenes', icon: 'Layers', description: 'Detail scenes' },
72
- 'book-review': { id: 'book-review', label: 'Review', icon: 'CheckCircle', description: 'Structure check' },
108
+ 'book-outline': {
109
+ id: 'book-outline',
110
+ label: 'Outline',
111
+ icon: 'BookOpen',
112
+ description: 'Plan structure',
113
+ },
114
+ 'character-design': {
115
+ id: 'character-design',
116
+ label: 'Characters',
117
+ icon: 'Users',
118
+ description: 'Build cast',
119
+ },
120
+ 'plot-threads': {
121
+ id: 'plot-threads',
122
+ label: 'Threads',
123
+ icon: 'GitBranch',
124
+ description: 'Map plot lines',
125
+ },
126
+ 'scene-breakdown': {
127
+ id: 'scene-breakdown',
128
+ label: 'Scenes',
129
+ icon: 'Layers',
130
+ description: 'Detail scenes',
131
+ },
132
+ 'book-review': {
133
+ id: 'book-review',
134
+ label: 'Review',
135
+ icon: 'CheckCircle',
136
+ description: 'Structure check',
137
+ },
73
138
  // ── Course / Training actions ─────────────────────────────────────────────
74
- 'curriculum-design': { id: 'curriculum-design', label: 'Curriculum', icon: 'School', description: 'Define structure' },
75
- 'lesson-plan': { id: 'lesson-plan', label: 'Lessons', icon: 'BookOpen', description: 'Plan lessons' },
76
- 'assessment-design': { id: 'assessment-design', label: 'Assess', icon: 'ClipboardCheck', description: 'Create assessments' },
77
- 'course-review': { id: 'course-review', label: 'Review', icon: 'CheckCircle', description: 'Quality check' },
78
- 'financial-model': { id: 'financial-model', label: 'Financials', icon: 'DollarSign', description: 'Build projections' },
79
- 'pitch-outline': { id: 'pitch-outline', label: 'Pitch', icon: 'Rocket', description: 'Structure a pitch' },
80
- 'business-review': { id: 'business-review', label: 'Review', icon: 'ShieldCheck', description: 'Validate the plan' },
139
+ 'curriculum-design': {
140
+ id: 'curriculum-design',
141
+ label: 'Curriculum',
142
+ icon: 'School',
143
+ description: 'Define structure',
144
+ },
145
+ 'lesson-plan': {
146
+ id: 'lesson-plan',
147
+ label: 'Lessons',
148
+ icon: 'BookOpen',
149
+ description: 'Plan lessons',
150
+ },
151
+ 'assessment-design': {
152
+ id: 'assessment-design',
153
+ label: 'Assess',
154
+ icon: 'ClipboardCheck',
155
+ description: 'Create assessments',
156
+ },
157
+ 'course-review': {
158
+ id: 'course-review',
159
+ label: 'Review',
160
+ icon: 'CheckCircle',
161
+ description: 'Quality check',
162
+ },
163
+ 'financial-model': {
164
+ id: 'financial-model',
165
+ label: 'Financials',
166
+ icon: 'DollarSign',
167
+ description: 'Build projections',
168
+ },
169
+ 'pitch-outline': {
170
+ id: 'pitch-outline',
171
+ label: 'Pitch',
172
+ icon: 'Rocket',
173
+ description: 'Structure a pitch',
174
+ },
175
+ 'business-review': {
176
+ id: 'business-review',
177
+ label: 'Review',
178
+ icon: 'ShieldCheck',
179
+ description: 'Validate the plan',
180
+ },
81
181
  // ── Work item actions ────────────────────────────────────────────────────
82
182
  build: {
83
183
  id: 'build',
@@ -340,7 +340,11 @@ export const businessPlanConfig = {
340
340
  { role: 'writer', label: 'Writer', description: 'Clear, persuasive business writing' },
341
341
  ],
342
342
  documentTemplates: [
343
- { type: 'business-model', label: 'Business Model', description: 'Structured business model (identity, market, competitors, financials)' },
343
+ {
344
+ type: 'business-model',
345
+ label: 'Business Model',
346
+ description: 'Structured business model (identity, market, competitors, financials)',
347
+ },
344
348
  { type: 'executive-summary', label: 'Executive Summary', description: 'Business overview' },
345
349
  {
346
350
  type: 'market-analysis',
@@ -351,7 +355,15 @@ export const businessPlanConfig = {
351
355
  { type: 'pitch', label: 'Pitch Narrative', description: 'Investor pitch content' },
352
356
  { type: 'session-notes', label: 'Session Notes', description: 'Summary of work done' },
353
357
  ],
354
- projectActions: ['business-vision', 'market-analysis', 'competitor-analysis', 'financial-model', 'pitch-outline', 'business-review', 'session-notes'],
358
+ projectActions: [
359
+ 'business-vision',
360
+ 'market-analysis',
361
+ 'competitor-analysis',
362
+ 'financial-model',
363
+ 'pitch-outline',
364
+ 'business-review',
365
+ 'session-notes',
366
+ ],
355
367
  workItemActions: ['refine-item', 'explain'],
356
368
  workItemLabels: {
357
369
  feature: { short: 'ML', full: 'Milestone' },
@@ -419,23 +431,61 @@ export const contentConfig = {
419
431
  description: 'Plan content for the period',
420
432
  completionCheck: 'has-workitems',
421
433
  },
422
- { id: 'create', label: 'Create', description: 'Write copy and visual briefs', completionCheck: 'has-workitems' },
423
- { id: 'review', label: 'Review', description: 'Check voice and brand consistency', completionCheck: 'manual' },
424
- { id: 'publish', label: 'Publish', description: 'Finalize and publish', completionCheck: 'manual' },
434
+ {
435
+ id: 'create',
436
+ label: 'Create',
437
+ description: 'Write copy and visual briefs',
438
+ completionCheck: 'has-workitems',
439
+ },
440
+ {
441
+ id: 'review',
442
+ label: 'Review',
443
+ description: 'Check voice and brand consistency',
444
+ completionCheck: 'manual',
445
+ },
446
+ {
447
+ id: 'publish',
448
+ label: 'Publish',
449
+ description: 'Finalize and publish',
450
+ completionCheck: 'manual',
451
+ },
425
452
  ],
426
453
  suggestedAgents: [
427
- { role: 'strategist', label: 'Content Strategist', description: 'Planning, ideation, calendar, repurposing' },
428
- { role: 'writer', label: 'Copywriter', description: 'Headlines, captions, CTAs, long-form copy' },
454
+ {
455
+ role: 'strategist',
456
+ label: 'Content Strategist',
457
+ description: 'Planning, ideation, calendar, repurposing',
458
+ },
459
+ {
460
+ role: 'writer',
461
+ label: 'Copywriter',
462
+ description: 'Headlines, captions, CTAs, long-form copy',
463
+ },
429
464
  { role: 'designer', label: 'Visual Director', description: 'Visual briefs from Brand Model' },
430
- { role: 'editor', label: 'Editor', description: 'Voice consistency, quality review, on-brand checks' },
465
+ {
466
+ role: 'editor',
467
+ label: 'Editor',
468
+ description: 'Voice consistency, quality review, on-brand checks',
469
+ },
431
470
  ],
432
471
  documentTemplates: [
433
- { type: 'brand-model', label: 'Brand Model', description: 'Brand identity, voice, visual guidelines, audience, strategy' },
472
+ {
473
+ type: 'brand-model',
474
+ label: 'Brand Model',
475
+ description: 'Brand identity, voice, visual guidelines, audience, strategy',
476
+ },
434
477
  { type: 'editorial-calendar', label: 'Editorial Calendar', description: 'Content schedule' },
435
478
  { type: 'article', label: 'Article', description: 'Blog post or article draft' },
436
479
  { type: 'session-notes', label: 'Session Notes', description: 'Summary of work done' },
437
480
  ],
438
- projectActions: ['brand-setup', 'content-strategy', 'content-calendar', 'create-content', 'content-review', 'session-notes'],
481
+ projectActions: [
482
+ 'brand-setup',
483
+ 'content-strategy',
484
+ 'content-calendar',
485
+ 'create-content',
486
+ 'content-review',
487
+ 'session-notes',
488
+ ],
439
489
  workItemActions: ['refine-item', 'explain'],
440
490
  workItemLabels: {
441
491
  feature: { short: 'PC', full: 'Content Piece' },
@@ -607,16 +657,34 @@ export const courseConfig = {
607
657
  },
608
658
  ],
609
659
  suggestedAgents: [
610
- { role: 'instructor', label: 'Instructor', description: 'Curriculum design, sequencing, pedagogy' },
611
- { role: 'content-designer', label: 'Content Designer', description: 'Lesson planning, exercises, assessments' },
660
+ {
661
+ role: 'instructor',
662
+ label: 'Instructor',
663
+ description: 'Curriculum design, sequencing, pedagogy',
664
+ },
665
+ {
666
+ role: 'content-designer',
667
+ label: 'Content Designer',
668
+ description: 'Lesson planning, exercises, assessments',
669
+ },
612
670
  { role: 'reviewer', label: 'Reviewer', description: 'Pedagogical quality, balance, coverage' },
613
671
  ],
614
672
  documentTemplates: [
615
- { type: 'curriculum-model', label: 'Curriculum', description: 'Course structure, modules, lessons, assessments' },
673
+ {
674
+ type: 'curriculum-model',
675
+ label: 'Curriculum',
676
+ description: 'Course structure, modules, lessons, assessments',
677
+ },
616
678
  { type: 'notes', label: 'Lesson Notes', description: 'Lesson content and materials' },
617
679
  { type: 'session-notes', label: 'Session Notes', description: 'Summary of work done' },
618
680
  ],
619
- projectActions: ['curriculum-design', 'lesson-plan', 'assessment-design', 'course-review', 'session-notes'],
681
+ projectActions: [
682
+ 'curriculum-design',
683
+ 'lesson-plan',
684
+ 'assessment-design',
685
+ 'course-review',
686
+ 'session-notes',
687
+ ],
620
688
  workItemActions: ['refine-item', 'explain'],
621
689
  workItemLabels: {
622
690
  feature: { short: 'LS', full: 'Lesson' },
@@ -687,20 +755,48 @@ export const bookConfig = {
687
755
  description: 'Break chapters into scenes',
688
756
  completionCheck: 'has-workitems',
689
757
  },
690
- { id: 'draft', label: 'Draft', description: 'Write chapter drafts', completionCheck: 'has-workitems' },
758
+ {
759
+ id: 'draft',
760
+ label: 'Draft',
761
+ description: 'Write chapter drafts',
762
+ completionCheck: 'has-workitems',
763
+ },
691
764
  { id: 'review', label: 'Review', description: 'Structural review', completionCheck: 'manual' },
692
765
  ],
693
766
  suggestedAgents: [
694
- { role: 'plotter', label: 'Plotter', description: 'Story architecture, beats, pacing, plot threads' },
695
- { role: 'character-dev', label: 'Character Dev', description: 'Characters, arcs, relationships, voice' },
696
- { role: 'scene-writer', label: 'Scene Writer', description: 'Scene construction, setting, POV, transitions' },
767
+ {
768
+ role: 'plotter',
769
+ label: 'Plotter',
770
+ description: 'Story architecture, beats, pacing, plot threads',
771
+ },
772
+ {
773
+ role: 'character-dev',
774
+ label: 'Character Dev',
775
+ description: 'Characters, arcs, relationships, voice',
776
+ },
777
+ {
778
+ role: 'scene-writer',
779
+ label: 'Scene Writer',
780
+ description: 'Scene construction, setting, POV, transitions',
781
+ },
697
782
  ],
698
783
  documentTemplates: [
699
- { type: 'book-model', label: 'Book Model', description: 'Story structure, characters, plot threads, beats' },
784
+ {
785
+ type: 'book-model',
786
+ label: 'Book Model',
787
+ description: 'Story structure, characters, plot threads, beats',
788
+ },
700
789
  { type: 'notes', label: 'Chapter Draft', description: 'Chapter content' },
701
790
  { type: 'session-notes', label: 'Session Notes', description: 'Summary of work done' },
702
791
  ],
703
- projectActions: ['book-outline', 'character-design', 'plot-threads', 'scene-breakdown', 'book-review', 'session-notes'],
792
+ projectActions: [
793
+ 'book-outline',
794
+ 'character-design',
795
+ 'plot-threads',
796
+ 'scene-breakdown',
797
+ 'book-review',
798
+ 'session-notes',
799
+ ],
704
800
  workItemActions: ['refine-item', 'explain'],
705
801
  workItemLabels: {
706
802
  feature: { short: 'CH', full: 'Chapter' },
@@ -25,10 +25,10 @@ export const PROJECT_TYPES = [
25
25
  ];
26
26
  /** Type aliases — legacy or alternative IDs that map to a canonical config */
27
27
  const TYPE_ALIASES = {
28
- 'generated': 'web', // Legacy: factory-scaffolded projects before type selection
29
- 'cli': 'web',
30
- 'api': 'web',
31
- 'library': 'web',
28
+ generated: 'web', // Legacy: factory-scaffolded projects before type selection
29
+ cli: 'web',
30
+ api: 'web',
31
+ library: 'web',
32
32
  };
33
33
  /** Get a project type config by ID. Falls back to general. */
34
34
  export function getProjectTypeConfig(typeId) {
@@ -107,29 +107,149 @@ export const SKILL_META_REGISTRY = {
107
107
  category: 'research',
108
108
  },
109
109
  // ── Business Plan Skills ──────────────────────────────────────────────────
110
- 'business-vision': { id: 'business-vision', label: 'Business Vision', description: 'Define business identity and value proposition', icon: 'Target', category: 'planning' },
111
- 'market-analysis': { id: 'market-analysis', label: 'Market Analysis', description: 'Analyze market size, trends, and segments', icon: 'TrendingUp', category: 'analysis' },
112
- 'competitor-analysis': { id: 'competitor-analysis', label: 'Competitor Analysis', description: 'Map competitive landscape', icon: 'Swords', category: 'analysis' },
113
- 'financial-model': { id: 'financial-model', label: 'Financial Model', description: 'Build revenue and cost projections', icon: 'DollarSign', category: 'analysis' },
114
- 'pitch-outline': { id: 'pitch-outline', label: 'Pitch Outline', description: 'Structure an investor pitch', icon: 'Rocket', category: 'planning' },
115
- 'business-review': { id: 'business-review', label: 'Business Review', description: 'Validate the business plan', icon: 'ShieldCheck', category: 'analysis' },
110
+ 'business-vision': {
111
+ id: 'business-vision',
112
+ label: 'Business Vision',
113
+ description: 'Define business identity and value proposition',
114
+ icon: 'Target',
115
+ category: 'planning',
116
+ },
117
+ 'market-analysis': {
118
+ id: 'market-analysis',
119
+ label: 'Market Analysis',
120
+ description: 'Analyze market size, trends, and segments',
121
+ icon: 'TrendingUp',
122
+ category: 'analysis',
123
+ },
124
+ 'competitor-analysis': {
125
+ id: 'competitor-analysis',
126
+ label: 'Competitor Analysis',
127
+ description: 'Map competitive landscape',
128
+ icon: 'Swords',
129
+ category: 'analysis',
130
+ },
131
+ 'financial-model': {
132
+ id: 'financial-model',
133
+ label: 'Financial Model',
134
+ description: 'Build revenue and cost projections',
135
+ icon: 'DollarSign',
136
+ category: 'analysis',
137
+ },
138
+ 'pitch-outline': {
139
+ id: 'pitch-outline',
140
+ label: 'Pitch Outline',
141
+ description: 'Structure an investor pitch',
142
+ icon: 'Rocket',
143
+ category: 'planning',
144
+ },
145
+ 'business-review': {
146
+ id: 'business-review',
147
+ label: 'Business Review',
148
+ description: 'Validate the business plan',
149
+ icon: 'ShieldCheck',
150
+ category: 'analysis',
151
+ },
116
152
  // ── Content & Marketing Skills ───────────────────────────────────────────
117
- 'brand-setup': { id: 'brand-setup', label: 'Brand Setup', description: 'Define brand identity, voice, and visual guidelines', icon: 'Palette', category: 'planning' },
118
- 'content-strategy': { id: 'content-strategy', label: 'Content Strategy', description: 'Define content pillars and cadence', icon: 'Target', category: 'planning' },
119
- 'content-calendar': { id: 'content-calendar', label: 'Content Calendar', description: 'Plan content for a period', icon: 'Calendar', category: 'planning' },
120
- 'create-content': { id: 'create-content', label: 'Create Content', description: 'Write copy and visual brief', icon: 'PenTool', category: 'development' },
121
- 'content-review': { id: 'content-review', label: 'Content Review', description: 'Review for brand consistency', icon: 'CheckCircle', category: 'analysis' },
153
+ 'brand-setup': {
154
+ id: 'brand-setup',
155
+ label: 'Brand Setup',
156
+ description: 'Define brand identity, voice, and visual guidelines',
157
+ icon: 'Palette',
158
+ category: 'planning',
159
+ },
160
+ 'content-strategy': {
161
+ id: 'content-strategy',
162
+ label: 'Content Strategy',
163
+ description: 'Define content pillars and cadence',
164
+ icon: 'Target',
165
+ category: 'planning',
166
+ },
167
+ 'content-calendar': {
168
+ id: 'content-calendar',
169
+ label: 'Content Calendar',
170
+ description: 'Plan content for a period',
171
+ icon: 'Calendar',
172
+ category: 'planning',
173
+ },
174
+ 'create-content': {
175
+ id: 'create-content',
176
+ label: 'Create Content',
177
+ description: 'Write copy and visual brief',
178
+ icon: 'PenTool',
179
+ category: 'development',
180
+ },
181
+ 'content-review': {
182
+ id: 'content-review',
183
+ label: 'Content Review',
184
+ description: 'Review for brand consistency',
185
+ icon: 'CheckCircle',
186
+ category: 'analysis',
187
+ },
122
188
  // ── Course / Training Skills ─────────────────────────────────────────────
123
- 'curriculum-design': { id: 'curriculum-design', label: 'Curriculum', description: 'Define modules and learning objectives', icon: 'School', category: 'planning' },
124
- 'lesson-plan': { id: 'lesson-plan', label: 'Lesson Plan', description: 'Break modules into lessons', icon: 'BookOpen', category: 'planning' },
125
- 'assessment-design': { id: 'assessment-design', label: 'Assessment', description: 'Create quizzes and exercises', icon: 'ClipboardCheck', category: 'planning' },
126
- 'course-review': { id: 'course-review', label: 'Course Review', description: 'Pedagogical quality check', icon: 'CheckCircle', category: 'analysis' },
189
+ 'curriculum-design': {
190
+ id: 'curriculum-design',
191
+ label: 'Curriculum',
192
+ description: 'Define modules and learning objectives',
193
+ icon: 'School',
194
+ category: 'planning',
195
+ },
196
+ 'lesson-plan': {
197
+ id: 'lesson-plan',
198
+ label: 'Lesson Plan',
199
+ description: 'Break modules into lessons',
200
+ icon: 'BookOpen',
201
+ category: 'planning',
202
+ },
203
+ 'assessment-design': {
204
+ id: 'assessment-design',
205
+ label: 'Assessment',
206
+ description: 'Create quizzes and exercises',
207
+ icon: 'ClipboardCheck',
208
+ category: 'planning',
209
+ },
210
+ 'course-review': {
211
+ id: 'course-review',
212
+ label: 'Course Review',
213
+ description: 'Pedagogical quality check',
214
+ icon: 'CheckCircle',
215
+ category: 'analysis',
216
+ },
127
217
  // ── Book Skills ──────────────────────────────────────────────────────────
128
- 'book-outline': { id: 'book-outline', label: 'Book Outline', description: 'Define structure, beats, and chapters', icon: 'BookOpen', category: 'planning' },
129
- 'character-design': { id: 'character-design', label: 'Characters', description: 'Build character profiles and relationships', icon: 'Users', category: 'planning' },
130
- 'plot-threads': { id: 'plot-threads', label: 'Plot Threads', description: 'Define and track narrative threads', icon: 'GitBranch', category: 'planning' },
131
- 'scene-breakdown': { id: 'scene-breakdown', label: 'Scenes', description: 'Break chapters into scenes', icon: 'Layers', category: 'development' },
132
- 'book-review': { id: 'book-review', label: 'Book Review', description: 'Structural review of the book', icon: 'CheckCircle', category: 'analysis' },
218
+ 'book-outline': {
219
+ id: 'book-outline',
220
+ label: 'Book Outline',
221
+ description: 'Define structure, beats, and chapters',
222
+ icon: 'BookOpen',
223
+ category: 'planning',
224
+ },
225
+ 'character-design': {
226
+ id: 'character-design',
227
+ label: 'Characters',
228
+ description: 'Build character profiles and relationships',
229
+ icon: 'Users',
230
+ category: 'planning',
231
+ },
232
+ 'plot-threads': {
233
+ id: 'plot-threads',
234
+ label: 'Plot Threads',
235
+ description: 'Define and track narrative threads',
236
+ icon: 'GitBranch',
237
+ category: 'planning',
238
+ },
239
+ 'scene-breakdown': {
240
+ id: 'scene-breakdown',
241
+ label: 'Scenes',
242
+ description: 'Break chapters into scenes',
243
+ icon: 'Layers',
244
+ category: 'development',
245
+ },
246
+ 'book-review': {
247
+ id: 'book-review',
248
+ label: 'Book Review',
249
+ description: 'Structural review of the book',
250
+ icon: 'CheckCircle',
251
+ category: 'analysis',
252
+ },
133
253
  // ── Builtin Skills (agents library) ──────────────────────────────────────
134
254
  'code-review': {
135
255
  id: 'code-review',
@@ -216,7 +216,7 @@ Key categories:
216
216
  - **Git**: git_status, git_diff, git_log, git_commit, git_branch
217
217
  - **Project Management**: project_get, project_list, project_create, project_update
218
218
  - **Work Items**: workitem_query, workitem_add, workitem_update, workitem_next
219
- - **Documents**: project_document_add, project_document_get, project_document_list
219
+ - **Documents**: project_document_add, project_document_get, project_document_list, project_document_patch
220
220
  - **Planning**: plan_create, plan_get, plan_list
221
221
  - **Runners**: run_tests, run_lint
222
222
  - **Anchors**: anchor_add, anchor_list, anchor_remove
@@ -225,7 +225,10 @@ Key categories:
225
225
 
226
226
  Project documents (drafts, outlines, analyses, plans) are stored in the **database**, not the filesystem.
227
227
  - **Read**: \`project_document_get({ doc_type: "outline" })\` or \`project_document_list()\`
228
- - **Write**: \`project_document_add({ doc_type: "outline", title: "...", content: "..." })\`
228
+ - **Write (new)**: \`project_document_add({ doc_type: "outline", title: "...", content: "..." })\`
229
+ - **Patch (update without reading)**: \`project_document_patch({ doc_type: "draft", operation: "append", content: "## New Section\\n..." })\`
230
+ - Operations: \`append\`, \`prepend\`, \`replace_section\` (with \`section_heading\`)
231
+ - Prefer patch over add when updating large documents — avoids reading the full content into context
229
232
  - Do NOT use write_file or edit for project documents — always use these database tools
230
233
  - **Software doc_types**: prd, architecture, design, notes, plan
231
234
  - **Research doc_types**: outline, literature-review, abstract, methodology, bibliography
@@ -77,6 +77,7 @@ const TOOL_NAMES = {
77
77
  PROJECT_DOCUMENT_GET: 'document_get',
78
78
  PROJECT_DOCUMENT_LIST: 'document_list',
79
79
  PROJECT_DOCUMENT_DELETE: 'document_delete',
80
+ PROJECT_DOCUMENT_PATCH: 'document_patch',
80
81
  // Plans
81
82
  PLAN_CREATE: 'plan_create',
82
83
  PLAN_UPDATE: 'plan_update',
@@ -255,6 +256,7 @@ export const TOOL_GROUPS = {
255
256
  TOOL_NAMES.PROJECT_DOCUMENT_GET,
256
257
  TOOL_NAMES.PROJECT_DOCUMENT_LIST,
257
258
  TOOL_NAMES.PROJECT_DOCUMENT_DELETE,
259
+ TOOL_NAMES.PROJECT_DOCUMENT_PATCH,
258
260
  ],
259
261
  readOnly: false,
260
262
  tier: 'meta',
@@ -306,13 +308,26 @@ export const TOOL_GROUPS = {
306
308
  factory_models: {
307
309
  label: 'Structured Models',
308
310
  tools: [
309
- 'app_model_get', 'app_model_update', 'app_model_validate',
310
- 'research_model_get', 'research_model_update', 'research_model_validate',
311
- 'bibliography_generate', 'bibtex_import',
312
- 'business_model_get', 'business_model_update', 'business_model_validate',
313
- 'brand_model_get', 'brand_model_update', 'brand_model_validate',
314
- 'curriculum_model_get', 'curriculum_model_update', 'curriculum_model_validate',
315
- 'book_model_get', 'book_model_update', 'book_model_validate',
311
+ 'app_model_get',
312
+ 'app_model_update',
313
+ 'app_model_validate',
314
+ 'research_model_get',
315
+ 'research_model_update',
316
+ 'research_model_validate',
317
+ 'bibliography_generate',
318
+ 'bibtex_import',
319
+ 'business_model_get',
320
+ 'business_model_update',
321
+ 'business_model_validate',
322
+ 'brand_model_get',
323
+ 'brand_model_update',
324
+ 'brand_model_validate',
325
+ 'curriculum_model_get',
326
+ 'curriculum_model_update',
327
+ 'curriculum_model_validate',
328
+ 'book_model_get',
329
+ 'book_model_update',
330
+ 'book_model_validate',
316
331
  ],
317
332
  readOnly: false,
318
333
  tier: 'meta',
@@ -321,8 +336,12 @@ export const TOOL_GROUPS = {
321
336
  factory_scaffold: {
322
337
  label: 'Code Scaffolding',
323
338
  tools: [
324
- 'factory_scaffold', 'factory_list_toolkits',
325
- 'research_scaffold', 'business_scaffold', 'content_scaffold', 'book_scaffold',
339
+ 'factory_scaffold',
340
+ 'factory_list_toolkits',
341
+ 'research_scaffold',
342
+ 'business_scaffold',
343
+ 'content_scaffold',
344
+ 'book_scaffold',
326
345
  ],
327
346
  readOnly: false,
328
347
  tier: 'meta',
@@ -390,7 +409,18 @@ export const TOOL_PROFILES = {
390
409
  'dependencies',
391
410
  ],
392
411
  // Docs - documentation + project documents
393
- docs: ['file_read', 'file_write', 'interaction', 'handoff', 'guide', 'meta', 'project', 'search', 'documents', 'factory_models'],
412
+ docs: [
413
+ 'file_read',
414
+ 'file_write',
415
+ 'interaction',
416
+ 'handoff',
417
+ 'guide',
418
+ 'meta',
419
+ 'project',
420
+ 'search',
421
+ 'documents',
422
+ 'factory_models',
423
+ ],
394
424
  // DevOps - CI/CD tasks
395
425
  devops: [
396
426
  'file_read',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.7.13",
3
+ "version": "0.7.15",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@anthropic-ai/sdk": "^0.78.0",
71
- "@compilr-dev/agents": "^0.3.27",
71
+ "@compilr-dev/agents": "^0.3.28",
72
72
  "@compilr-dev/agents-coding": "^1.0.2",
73
73
  "@eslint/js": "^9.39.1",
74
74
  "@opentelemetry/api": "^1.9.0",