@lovelybunch/core 1.0.73 → 1.0.74

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,454 @@
1
+ import { z } from 'zod';
2
+ import { zodToJsonSchema } from 'zod-to-json-schema';
3
+ import { MarkdownStorageAdapter } from './markdown-storage.js';
4
+ import Fuse from 'fuse.js';
5
+ import { getLogger, ProposalKinds } from './logging/index.js';
6
+ // ============================================================================
7
+ // Storage initialization with environment-aware path resolution
8
+ // ============================================================================
9
+ function resolveGaitPath() {
10
+ if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
11
+ return process.env.GAIT_DEV_ROOT;
12
+ }
13
+ if (process.env.GAIT_DATA_PATH) {
14
+ return `${process.env.GAIT_DATA_PATH}/.nut`;
15
+ }
16
+ return '.nut';
17
+ }
18
+ // Create storage adapter with resolved path
19
+ function getStorage() {
20
+ return new MarkdownStorageAdapter(resolveGaitPath());
21
+ }
22
+ function logProposalEvent(kind, proposalId, payload) {
23
+ try {
24
+ const logger = getLogger();
25
+ logger.log({
26
+ kind,
27
+ actor: 'cli:nut', // CLI operations
28
+ subject: `proposal:${proposalId}`,
29
+ tags: ['proposal'],
30
+ payload: {
31
+ proposalId,
32
+ ...payload,
33
+ },
34
+ });
35
+ }
36
+ catch (err) {
37
+ // Don't fail the operation if logging fails
38
+ console.error('Failed to log proposal event:', err);
39
+ }
40
+ }
41
+ // ============================================================================
42
+ // Zod Schemas
43
+ // ============================================================================
44
+ export const ProposalStatusSchema = z.enum([
45
+ 'draft', 'proposed', 'in-review', 'code-complete', 'approved', 'merged', 'rejected'
46
+ ]);
47
+ export const ProposalPrioritySchema = z.enum(['low', 'medium', 'high', 'critical']);
48
+ export const AuthorSchema = z.object({
49
+ id: z.string().min(1, 'Author ID is required'),
50
+ name: z.string().min(1, 'Author name is required'),
51
+ email: z.string().email().optional(),
52
+ role: z.string().optional(),
53
+ type: z.enum(['human', 'agent']),
54
+ });
55
+ export const ProposalFiltersSchema = z.object({
56
+ status: ProposalStatusSchema.optional(),
57
+ author: z.string().optional(),
58
+ priority: ProposalPrioritySchema.optional(),
59
+ tags: z.array(z.string()).optional(),
60
+ search: z.string().optional(),
61
+ });
62
+ export const PlanStepInputSchema = z.union([
63
+ z.string(),
64
+ z.object({
65
+ id: z.string().optional(),
66
+ description: z.string().min(1, 'Step description is required'),
67
+ status: z.enum(['pending', 'in-progress', 'completed', 'failed']).optional(),
68
+ command: z.string().optional(),
69
+ expectedOutcome: z.string().optional(),
70
+ })
71
+ ]);
72
+ export const CreateProposalInputSchema = z.object({
73
+ intent: z.string().min(1, 'Intent is required'),
74
+ content: z.string().min(1, 'Content is required'),
75
+ author: AuthorSchema.optional(),
76
+ planSteps: z.array(PlanStepInputSchema).optional(),
77
+ status: ProposalStatusSchema.optional().default('draft'),
78
+ metadata: z.object({
79
+ tags: z.array(z.string()).optional(),
80
+ priority: ProposalPrioritySchema.optional(),
81
+ reviewers: z.array(z.string()).optional(),
82
+ }).optional(),
83
+ productSpecRef: z.string().optional(),
84
+ });
85
+ export const UpdateProposalInputSchema = z.object({
86
+ intent: z.string().min(1).optional(),
87
+ content: z.string().min(1).optional(),
88
+ status: ProposalStatusSchema.optional(),
89
+ planSteps: z.array(PlanStepInputSchema).optional(),
90
+ metadata: z.object({
91
+ tags: z.array(z.string()).optional(),
92
+ priority: ProposalPrioritySchema.optional(),
93
+ reviewers: z.array(z.string()).optional(),
94
+ }).optional(),
95
+ productSpecRef: z.string().optional(),
96
+ }).refine(data => Object.keys(data).length > 0, {
97
+ message: 'At least one field must be provided for update'
98
+ });
99
+ // ============================================================================
100
+ // Helper Functions
101
+ // ============================================================================
102
+ function normalizePlanSteps(steps) {
103
+ if (!steps || steps.length === 0)
104
+ return [];
105
+ return steps.map((step, index) => {
106
+ if (typeof step === 'string') {
107
+ return {
108
+ id: `step-${index + 1}`,
109
+ description: step,
110
+ status: 'pending',
111
+ command: undefined,
112
+ output: undefined,
113
+ executedAt: undefined,
114
+ expectedOutcome: undefined,
115
+ };
116
+ }
117
+ return {
118
+ id: step.id || `step-${index + 1}`,
119
+ description: step.description,
120
+ status: step.status || 'pending',
121
+ command: step.command,
122
+ output: undefined,
123
+ executedAt: undefined,
124
+ expectedOutcome: step.expectedOutcome,
125
+ };
126
+ });
127
+ }
128
+ function createDefaultAuthor() {
129
+ return {
130
+ id: 'mcp-agent',
131
+ name: 'MCP Agent',
132
+ type: 'agent',
133
+ };
134
+ }
135
+ function createEmptyProposal(id, now) {
136
+ return {
137
+ id,
138
+ intent: '',
139
+ content: '',
140
+ author: createDefaultAuthor(),
141
+ planSteps: [],
142
+ evidence: [],
143
+ policies: [],
144
+ featureFlags: [],
145
+ experiments: [],
146
+ telemetryContracts: [],
147
+ releasePlan: {
148
+ strategy: 'immediate',
149
+ stages: [],
150
+ rollbackPlan: '',
151
+ },
152
+ status: 'draft',
153
+ metadata: {
154
+ createdAt: now,
155
+ updatedAt: now,
156
+ reviewers: [],
157
+ aiInteractions: [],
158
+ tags: [],
159
+ priority: 'medium',
160
+ },
161
+ };
162
+ }
163
+ // ============================================================================
164
+ // Core Functions
165
+ // ============================================================================
166
+ /**
167
+ * List proposals with optional filtering and search
168
+ */
169
+ export async function listProposals(filters) {
170
+ const opts = ProposalFiltersSchema.parse(filters || {});
171
+ const storage = getStorage();
172
+ let proposals = await storage.loadAllProposals();
173
+ // Apply filters
174
+ if (opts.status) {
175
+ proposals = proposals.filter(p => p.status === opts.status);
176
+ }
177
+ if (opts.priority) {
178
+ proposals = proposals.filter(p => p.metadata?.priority === opts.priority);
179
+ }
180
+ if (opts.tags && opts.tags.length > 0) {
181
+ proposals = proposals.filter(p => opts.tags.some(tag => p.metadata?.tags?.includes(tag)));
182
+ }
183
+ if (opts.author) {
184
+ const authorLower = opts.author.toLowerCase();
185
+ proposals = proposals.filter(p => p.author.name?.toLowerCase().includes(authorLower) ||
186
+ p.author.id?.toLowerCase().includes(authorLower) ||
187
+ p.author.email?.toLowerCase().includes(authorLower));
188
+ }
189
+ // Apply fuzzy search
190
+ if (opts.search) {
191
+ const fuse = new Fuse(proposals, {
192
+ keys: ['intent', 'content', 'author.name', 'metadata.tags'],
193
+ threshold: 0.4,
194
+ ignoreLocation: true,
195
+ });
196
+ proposals = fuse.search(opts.search).map(r => r.item);
197
+ }
198
+ // Sort by updatedAt descending (most recent first)
199
+ proposals.sort((a, b) => {
200
+ const aTime = a.metadata?.updatedAt ? new Date(a.metadata.updatedAt).getTime() : 0;
201
+ const bTime = b.metadata?.updatedAt ? new Date(b.metadata.updatedAt).getTime() : 0;
202
+ return bTime - aTime;
203
+ });
204
+ return proposals;
205
+ }
206
+ /**
207
+ * Get a single proposal by ID
208
+ */
209
+ export async function getProposal(id) {
210
+ if (!id || typeof id !== 'string') {
211
+ throw new Error('Proposal ID is required');
212
+ }
213
+ const storage = getStorage();
214
+ return storage.loadProposal(id);
215
+ }
216
+ /**
217
+ * Create a new proposal
218
+ */
219
+ export async function createProposal(input) {
220
+ const validated = CreateProposalInputSchema.parse(input);
221
+ const now = new Date();
222
+ // Add random suffix to prevent ID collisions when creating quickly
223
+ const randomSuffix = Math.random().toString(36).substring(2, 6);
224
+ const id = `cp-${Date.now()}-${randomSuffix}`;
225
+ const proposal = {
226
+ ...createEmptyProposal(id, now),
227
+ intent: validated.intent,
228
+ content: validated.content,
229
+ author: validated.author || createDefaultAuthor(),
230
+ planSteps: normalizePlanSteps(validated.planSteps),
231
+ status: validated.status || 'draft',
232
+ productSpecRef: validated.productSpecRef,
233
+ metadata: {
234
+ createdAt: now,
235
+ updatedAt: now,
236
+ reviewers: validated.metadata?.reviewers || [],
237
+ aiInteractions: [],
238
+ tags: validated.metadata?.tags || [],
239
+ priority: validated.metadata?.priority || 'medium',
240
+ },
241
+ };
242
+ const storage = getStorage();
243
+ await storage.saveProposal(proposal);
244
+ logProposalEvent(ProposalKinds.CREATE, id, {
245
+ intent: validated.intent,
246
+ status: proposal.status,
247
+ authorType: proposal.author.type,
248
+ authorName: proposal.author.name,
249
+ tags: proposal.metadata?.tags,
250
+ priority: proposal.metadata?.priority,
251
+ });
252
+ return proposal;
253
+ }
254
+ /**
255
+ * Update an existing proposal
256
+ */
257
+ export async function updateProposal(id, updates) {
258
+ if (!id || typeof id !== 'string') {
259
+ throw new Error('Proposal ID is required');
260
+ }
261
+ const validated = UpdateProposalInputSchema.parse(updates);
262
+ const storage = getStorage();
263
+ const existing = await storage.loadProposal(id);
264
+ if (!existing) {
265
+ throw new Error(`Proposal not found: ${id}`);
266
+ }
267
+ // Ensure updatedAt is at least 1ms after createdAt to avoid duplicate detection
268
+ const createdAtTime = existing.metadata.createdAt.getTime();
269
+ const now = Math.max(Date.now(), createdAtTime + 1);
270
+ // Merge updates
271
+ const merged = {
272
+ ...existing,
273
+ ...(validated.intent !== undefined && { intent: validated.intent }),
274
+ ...(validated.content !== undefined && { content: validated.content }),
275
+ ...(validated.status !== undefined && { status: validated.status }),
276
+ ...(validated.productSpecRef !== undefined && { productSpecRef: validated.productSpecRef }),
277
+ ...(validated.planSteps !== undefined && { planSteps: normalizePlanSteps(validated.planSteps) }),
278
+ metadata: {
279
+ ...existing.metadata,
280
+ updatedAt: new Date(now),
281
+ ...(validated.metadata?.tags !== undefined && { tags: validated.metadata.tags }),
282
+ ...(validated.metadata?.priority !== undefined && { priority: validated.metadata.priority }),
283
+ ...(validated.metadata?.reviewers !== undefined && { reviewers: validated.metadata.reviewers }),
284
+ },
285
+ };
286
+ await storage.saveProposal(merged);
287
+ // Log status change specifically if status changed
288
+ if (validated.status !== undefined && validated.status !== existing.status) {
289
+ logProposalEvent(ProposalKinds.STATUS_CHANGE, id, {
290
+ previousStatus: existing.status,
291
+ newStatus: validated.status,
292
+ });
293
+ }
294
+ else {
295
+ logProposalEvent(ProposalKinds.UPDATE, id, {
296
+ intent: merged.intent,
297
+ status: merged.status,
298
+ fieldsUpdated: Object.keys(validated),
299
+ });
300
+ }
301
+ return merged;
302
+ }
303
+ /**
304
+ * Delete a proposal by ID
305
+ */
306
+ export async function deleteProposal(id) {
307
+ if (!id || typeof id !== 'string') {
308
+ throw new Error('Proposal ID is required');
309
+ }
310
+ const storage = getStorage();
311
+ return storage.deleteProposal(id);
312
+ }
313
+ // ============================================================================
314
+ // Plan Step Schema and Function
315
+ // ============================================================================
316
+ export const AddPlanStepInputSchema = z.object({
317
+ description: z.string().min(1, 'Step description is required'),
318
+ status: z.enum(['pending', 'in-progress', 'completed', 'failed']).optional(),
319
+ command: z.string().optional(),
320
+ expectedOutcome: z.string().optional(),
321
+ });
322
+ export const AddCommentInputSchema = z.object({
323
+ author: z.string().min(1, 'Comment author is required'),
324
+ content: z.string().min(1, 'Comment content is required'),
325
+ });
326
+ /**
327
+ * Add a plan step to an existing proposal
328
+ */
329
+ export async function addPlanStep(proposalId, step) {
330
+ if (!proposalId || typeof proposalId !== 'string') {
331
+ throw new Error('Proposal ID is required');
332
+ }
333
+ const validated = AddPlanStepInputSchema.parse(step);
334
+ const storage = getStorage();
335
+ const proposal = await storage.loadProposal(proposalId);
336
+ if (!proposal) {
337
+ throw new Error(`Proposal not found: ${proposalId}`);
338
+ }
339
+ const existingSteps = proposal.planSteps || [];
340
+ const stepNum = (existingSteps.length + 1).toString().padStart(2, '0');
341
+ const stepId = `step-${stepNum}`;
342
+ const newStep = {
343
+ id: stepId,
344
+ description: validated.description,
345
+ status: validated.status || 'pending',
346
+ command: validated.command,
347
+ expectedOutcome: validated.expectedOutcome,
348
+ output: undefined,
349
+ executedAt: undefined,
350
+ };
351
+ // Ensure updatedAt is at least 1ms after createdAt to avoid duplicate detection
352
+ const createdAtTime = proposal.metadata.createdAt.getTime();
353
+ const now = Math.max(Date.now(), createdAtTime + 1);
354
+ const updatedProposal = {
355
+ ...proposal,
356
+ planSteps: [...existingSteps, newStep],
357
+ metadata: {
358
+ ...proposal.metadata,
359
+ updatedAt: new Date(now),
360
+ },
361
+ };
362
+ await storage.saveProposal(updatedProposal);
363
+ logProposalEvent(ProposalKinds.UPDATE, proposalId, {
364
+ action: 'add_plan_step',
365
+ stepId,
366
+ stepDescription: validated.description,
367
+ });
368
+ return newStep;
369
+ }
370
+ /**
371
+ * Add a comment to an existing proposal
372
+ */
373
+ export async function addComment(proposalId, comment) {
374
+ if (!proposalId || typeof proposalId !== 'string') {
375
+ throw new Error('Proposal ID is required');
376
+ }
377
+ const validated = AddCommentInputSchema.parse(comment);
378
+ const storage = getStorage();
379
+ const proposal = await storage.loadProposal(proposalId);
380
+ if (!proposal) {
381
+ throw new Error(`Proposal not found: ${proposalId}`);
382
+ }
383
+ const existingComments = proposal.comments || [];
384
+ const commentNum = (existingComments.length + 1).toString().padStart(2, '0');
385
+ const commentId = `cmt-${commentNum}`;
386
+ const createdAt = new Date().toISOString();
387
+ const newComment = {
388
+ id: commentId,
389
+ author: validated.author,
390
+ content: validated.content,
391
+ createdAt,
392
+ };
393
+ // Ensure updatedAt is at least 1ms after createdAt to avoid duplicate detection
394
+ const createdAtTime = proposal.metadata.createdAt.getTime();
395
+ const now = Math.max(Date.now(), createdAtTime + 1);
396
+ const updatedProposal = {
397
+ ...proposal,
398
+ comments: [...existingComments, newComment],
399
+ metadata: {
400
+ ...proposal.metadata,
401
+ updatedAt: new Date(now),
402
+ },
403
+ };
404
+ await storage.saveProposal(updatedProposal);
405
+ logProposalEvent(ProposalKinds.UPDATE, proposalId, {
406
+ action: 'add_comment',
407
+ commentId,
408
+ author: validated.author,
409
+ });
410
+ return newComment;
411
+ }
412
+ // ============================================================================
413
+ // Export all schemas for MCP tool generation
414
+ // ============================================================================
415
+ export const proposalSchemas = {
416
+ ProposalStatusSchema,
417
+ ProposalPrioritySchema,
418
+ AuthorSchema,
419
+ ProposalFiltersSchema,
420
+ PlanStepInputSchema,
421
+ CreateProposalInputSchema,
422
+ UpdateProposalInputSchema,
423
+ AddPlanStepInputSchema,
424
+ AddCommentInputSchema,
425
+ };
426
+ // ============================================================================
427
+ // Pre-computed JSON Schemas for MCP tool parameters
428
+ // ============================================================================
429
+ // Helper to extract properties from JSON schema
430
+ // Using 'any' to avoid TypeScript's deep type instantiation issues with zod-to-json-schema
431
+ function extractJsonSchemaProperties(schema) {
432
+ const jsonSchema = zodToJsonSchema(schema, { $refStrategy: 'none' });
433
+ return (jsonSchema.properties || {});
434
+ }
435
+ // Base schema for update (without .refine()) to avoid TypeScript issues
436
+ const UpdateProposalBaseSchema = z.object({
437
+ intent: z.string().min(1).optional(),
438
+ content: z.string().min(1).optional(),
439
+ status: ProposalStatusSchema.optional(),
440
+ planSteps: z.array(PlanStepInputSchema).optional(),
441
+ metadata: z.object({
442
+ tags: z.array(z.string()).optional(),
443
+ priority: ProposalPrioritySchema.optional(),
444
+ reviewers: z.array(z.string()).optional(),
445
+ }).optional(),
446
+ productSpecRef: z.string().optional(),
447
+ });
448
+ export const proposalJsonSchemas = {
449
+ filters: extractJsonSchemaProperties(ProposalFiltersSchema),
450
+ create: extractJsonSchemaProperties(CreateProposalInputSchema),
451
+ update: extractJsonSchemaProperties(UpdateProposalBaseSchema),
452
+ createRequired: ['intent', 'content'],
453
+ };
454
+ //# sourceMappingURL=proposals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposals.js","sourceRoot":"","sources":["../src/proposals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE7D,+EAA+E;AAC/E,gEAAgE;AAChE,+EAA+E;AAE/E,SAAS,eAAe;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACxE,OAAO,OAAO,CAAC,GAAG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wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IACvC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IAClD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACpC,QAAQ,EAAE,sBAAsB,CAAC,QAAQ,EAAE;QAC3C,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC1C,CAAC,CAAC,QAAQ,EAAE;IACb,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO,EAAE,2BAA2B,CAAC,qBAAqB,CAAC;IAC3D,MAAM,EAAE,2BAA2B,CAAC,yBAAyB,CAAC;IAC9D,MAAM,EAAE,2BAA2B,CAAC,wBAAwB,CAAC;IAC7D,cAAc,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAU;CAC/C,CAAA"}
@@ -13,45 +13,51 @@ You are primarily focused on **working with knowledge documents** — synthesizi
13
13
  - Project context — the core definition of what's being built
14
14
  - Architecture context — the technical foundation and conventions
15
15
 
16
- ✅ **WRITE to context documents:**
16
+ ✅ **WRITE to documents and tasks:**
17
17
  - Knowledge documents — create new, update existing
18
+ - Tasks — create new, update existing (for coding agents to execute)
18
19
  - Project context — define and refine the project definition
19
20
  - Architecture context — document the technical architecture
20
- - **ONE document at a time** — never batch multiple writes
21
+ - **ONE document/task at a time** — never batch multiple writes
21
22
 
22
23
  ✅ **Help users:**
23
24
  - Understand and synthesize information
24
25
  - Draft content for knowledge documents
25
26
  - **Plan projects** — strategy, architecture, go-to-market, roadmaps
26
- - **Structure responses as actionable tasks** that can be passed to coding agents
27
+ - **Create tasks** with clear, actionable details for coding agents to execute
27
28
 
28
29
  ### Creating Tasks (Important!)
29
30
 
30
- Every response you give has a **"Create task from above message"** button at the bottom. This makes it easy for users to turn your response into a task that can be executed by coding agents like:
31
+ You can **create tasks directly** using the `change_proposals` tool. Tasks are executed by coding agents like:
31
32
  - **Claude Code** (Anthropic)
32
33
  - **Cursor** (with Claude/GPT)
33
34
  - **GitHub Copilot**
34
- - **OpenAI Codex**
35
- - **Google Gemini Code Assist**
35
+ - **Windsurf** (Codeium)
36
36
 
37
- **Be proactive about suggesting task creation.** When your response contains actionable work, remind users they can click the button to create a task. Examples of great tasks to suggest:
37
+ **Be proactive about creating tasks.** When discussions lead to actionable work, offer to create a task. Examples:
38
38
 
39
- - **Scaffold a new project** — "I've outlined the architecture for your e-commerce site. Click 'Create task' to have a coding agent scaffold this structure."
40
- - **Update existing code** — "Here's how to refactor your authentication flow. Create a task from this and pass it to your coding agent."
41
- - **Go-to-market support** — "I've drafted your landing page copy and SEO strategy. Create a task to have an agent implement this, including interfacing with CMS or marketing MCP servers."
42
- - **Business automation** — "Here's a plan for your customer onboarding flow. Create a task to build the automation with appropriate integrations."
39
+ - **Scaffold a new project** — "I'll create a task for a coding agent to scaffold this e-commerce site architecture."
40
+ - **Update existing code** — "Let me create a task for refactoring the authentication flow."
41
+ - **Go-to-market support** — "I'll create a task for implementing this landing page with the SEO strategy we discussed."
42
+ - **Business automation** — "Let me create a task for building this customer onboarding flow."
43
43
 
44
- ### What You CANNOT Do Directly
44
+ **Task creation workflow:**
45
+ 1. Discuss and plan with the user
46
+ 2. Create the task with clear `intent` and detailed `content`
47
+ 3. The task appears in the Tasks view for coding agents to pick up
48
+ 4. Update the task status as work progresses
49
+
50
+ **Alternative:** Users can also click the **"Create task from above message"** button at the bottom of your responses to manually create a task from your structured advice.
45
51
 
46
- **Create, update, or delete tasks via API** — This is intentionally restricted.
52
+ ### What You CANNOT Do Directly
47
53
 
48
- **Why?** Tasks require broader context awareness (code structure, dependencies, implementation details) that **coding agents** are better equipped to execute. However, **you excel at planning and structuring work** that coding agents will implement.
54
+ **Execute code or make file system changes** You cannot run commands, edit source files, or deploy code. For implementation work, pass tasks to coding agents.
49
55
 
50
56
  **Your role in the task workflow:**
51
57
  1. Help users think through what they want to build
52
- 2. Structure your response with clear, actionable details
53
- 3. Remind users to click "Create task" to pass the work to a coding agent
54
- 4. Save important context as knowledge documents for reference
58
+ 2. **Create tasks** with clear, actionable details that coding agents can execute
59
+ 3. Save important context as knowledge documents for reference
60
+ 4. Update task status as work progresses
55
61
 
56
62
  ### System Awareness
57
63
 
@@ -108,20 +114,25 @@ Every response you give has a **"Create task from above message"** button at the
108
114
 
109
115
  ---
110
116
 
111
- ### tasks — READ ONLY
117
+ ### tasks — READ + WRITE
112
118
 
113
- **What it can do:** Search and read tasks. **CANNOT create, update, or delete via API.**
119
+ **What it can do:** Search, read, create, and update tasks.
114
120
 
115
121
  | Operation | Description | Example |
116
122
  |-----------|-------------|---------|
117
123
  | `list` | Search tasks | `{ "operation": "list", "filters": { "search": "keyword" } }` |
118
124
  | `get` | Read a task | `{ "operation": "get", "id": "cp-123456" }` |
125
+ | `create` | Create new task | `{ "operation": "create", "proposal": { "intent": "...", "content": "..." } }` |
126
+ | `update` | Update existing | `{ "operation": "update", "id": "cp-123456", "updates": { "status": "in-review" } }` |
119
127
 
120
- **If asked to create a task**, respond helpfully:
128
+ **Creating tasks:**
129
+ - `intent` (required): Brief description of what the task aims to achieve
130
+ - `content` (required): Detailed content/description of the task
131
+ - `status` (optional): One of `draft`, `proposed`, `in-review`, `code-complete`, `approved`, `merged`, `rejected`
132
+ - `metadata.priority` (optional): One of `low`, `medium`, `high`, `critical`
133
+ - `metadata.tags` (optional): Array of string tags
121
134
 
122
- > "I can absolutely help with that! Let me structure the details, and then you can click the **'Create task from above message'** button at the bottom of my response. This will create a task you can pass to a coding agent like Claude Code or Cursor for implementation."
123
-
124
- Then proceed to write out a clear, actionable description of the work.
135
+ **When creating a task**, structure it clearly so coding agents can execute it effectively.
125
136
 
126
137
  ---
127
138
 
@@ -219,6 +230,73 @@ After discussions that reveal new information about the project or architecture,
219
230
 
220
231
  ---
221
232
 
233
+ ## Handling "I Want to Build..." Requests
234
+
235
+ When users express intent to build something — websites, apps, features, improvements, automations — follow this workflow to help them go from idea to actionable tasks.
236
+
237
+ ### Common Request Patterns
238
+
239
+ | User Says | Your Approach |
240
+ |-----------|---------------|
241
+ | "I want to build a website" | Clarify purpose, audience, features → Create task(s) |
242
+ | "I want to create an app" | Explore platform, core functionality → Create task(s) |
243
+ | "I want to improve my QA" | Understand current state, goals → Research + task(s) |
244
+ | "I want to automate X" | Map the workflow, identify tools → Create task(s) |
245
+ | "I need a dashboard for Y" | Define metrics, data sources → Create task(s) |
246
+ | "Help me refactor Z" | Understand pain points, constraints → Create task(s) |
247
+
248
+ ### The Discovery → Research → Task Workflow
249
+
250
+ **1. Discovery (Conversation)**
251
+ - Ask clarifying questions to understand scope, constraints, and goals
252
+ - Don't assume — let the user guide the direction
253
+ - Identify what's in scope vs. out of scope
254
+
255
+ **2. Research (Knowledge Documents)**
256
+ - If the request involves unfamiliar domains, technologies, or best practices:
257
+ - Research and synthesize relevant information
258
+ - Create knowledge documents to capture findings
259
+ - Examples: "React vs Vue comparison", "E-commerce platform options", "QA automation frameworks"
260
+ - Knowledge docs become **persistent context** for future conversations and tasks
261
+
262
+ **3. Planning (Tasks)**
263
+ - Break down the work into clear, actionable tasks
264
+ - Each task should be **self-contained** enough for a coding agent to execute
265
+ - Include acceptance criteria or success measures when helpful
266
+ - Set appropriate priority (`low`, `medium`, `high`, `critical`)
267
+
268
+ ### Example Workflow
269
+
270
+ **User:** "I want to build a portfolio website"
271
+
272
+ **You:**
273
+ 1. **Clarify:** "Great! A few questions: Is this for personal branding, showcasing projects, or both? Do you have a preferred tech stack? Any specific features like a blog, contact form, or project gallery?"
274
+
275
+ 2. **Research (if needed):** Create a knowledge doc on "Modern portfolio website best practices" covering design trends, performance considerations, hosting options.
276
+
277
+ 3. **Create tasks:**
278
+ - Task 1: "Scaffold portfolio site with Next.js and Tailwind" (high priority)
279
+ - Task 2: "Build project showcase component with filtering" (medium priority)
280
+ - Task 3: "Add contact form with email integration" (medium priority)
281
+ - Task 4: "Set up deployment to Vercel" (low priority)
282
+
283
+ ### Guidelines
284
+
285
+ - **Start with conversation, not tasks** — understand before creating
286
+ - **Create knowledge docs for research** — they persist and help future work
287
+ - **Tasks should be specific** — vague tasks lead to vague results
288
+ - **Offer to break down large requests** — "This is a big project. Want me to create tasks for the first milestone?"
289
+ - **Update project/architecture context** — if the request reveals new project direction
290
+
291
+ ### Anti-Patterns to Avoid
292
+
293
+ ❌ Creating tasks immediately without understanding requirements
294
+ ❌ Creating one giant task for complex projects
295
+ ❌ Skipping research when domain knowledge would help
296
+ ❌ Forgetting to update project context after major planning
297
+
298
+ ---
299
+
222
300
  ## Editing Large Documents (Project & Architecture)
223
301
 
224
302
  Large documents like `project.md` and `architecture.md` require special handling. Choose your approach based on the type of edit:
@@ -267,6 +345,6 @@ The `update` operation sends the entire document and frequently fails on large f
267
345
 
268
346
  - Do NOT include `metadata`, `tags`, `summary` unless specifically asked — the system handles these
269
347
  - If a document's content was already provided as context, DO NOT fetch it again
270
- - If you need to create multiple knowledge documents, create ONE, wait for success, then offer to continue
271
- - When users want tasks created, help structure the work and remind them to click the "Create task" button to pass it to a coding agent
348
+ - If you need to create multiple documents or tasks, create ONE at a time, wait for success, then continue
349
+ - **Tasks should have clear, actionable details** that coding agents can execute without additional context
272
350
  - For project/architecture documents, plain markdown is fine — YAML frontmatter is optional but helpful for structured data