@lovelybunch/core 1.0.76-alpha.1 → 1.0.76-alpha.3

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.
@@ -1,160 +0,0 @@
1
- export const SCHEMA_REFERENCE_INSTRUCTION = 'Consult the schema references in .nut/.schema (proposal.schema.md, project.schema.md, architecture.schema.md, agent.schema.md, knowledge.schema.md) so any updates you make follow the documented structure and include complete arrays for plan steps, dependencies, tags, labels, and comments.';
2
- export const PROJECT_REFERENCE_INSTRUCTION = 'Use .nut/context/project.md and .nut/context/architecture.md for reference.';
3
- /**
4
- * Get instructions for change proposal (cp-*) workflows
5
- */
6
- export function getChangeProposalInstructions(proposalId, agentPaths, customInstruction, includeDefaultInstructions = true) {
7
- const sections = [];
8
- // Add default instructions only if requested
9
- if (includeDefaultInstructions) {
10
- // Task section
11
- sections.push([
12
- `## Task`,
13
- ``,
14
- `- Review and begin working on the following task proposal:`,
15
- ` .nut/proposals/${proposalId}.md`,
16
- `- Retrieve your firstName, lastName, and email address from: .nut/config.json and use this identity to address yourself in any task updates, comments, git commits, etc.`,
17
- ].join('\n'));
18
- // Task Lifecycle section
19
- sections.push([
20
- `## Task Lifecycle`,
21
- ``,
22
- `- Before beginning any work: nut task update ${proposalId} --status active`,
23
- `- Add appropriate steps with: nut task step ${proposalId} "Step description" --author "firstName lastName"`,
24
- ``,
25
- `- If you need human clarification or input: nut task update ${proposalId} --status blocked. The clarification can be communicated as follows: nut task comment ${proposalId} "Comments here" --author "firstName lastName". At this point please stop work.`,
26
- ``,
27
- `- When implementation is complete and ready for approval: nut task update ${proposalId} --status review`,
28
- `- Only mark the task complete once approval criteria are satisfied: nut task update ${proposalId} --status done`,
29
- ].join('\n'));
30
- // Abilities section
31
- sections.push([
32
- `## Abilities`,
33
- ``,
34
- `- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):`,
35
- ` - Work with knowledge documents (used for the output of any research-centric tasks):`,
36
- ` - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"`,
37
- ` - nut knowledge list`,
38
- ` - nut knowledge get example-filename.md`,
39
- ` - Creating media such as images, audio, or video:`,
40
- ` - nut resource`,
41
- ` - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:`,
42
- ` - nut skills list`,
43
- ` - nut skills registry list`,
44
- `- Similarly, the following are available: git, gh, node, python`,
45
- ].join('\n'));
46
- // Operational Rules section
47
- sections.push([
48
- `## Operational Rules`,
49
- ``,
50
- `- DO use the nut CLI to update task status as progress changes`,
51
- ` (nut --help or nut task --help for details)`,
52
- `- DO NOT edit files outside the scope of the approved proposal (unless instructed by the Additional Instructions below)`,
53
- ].join('\n'));
54
- }
55
- // Agents section (conditional)
56
- if (agentPaths.length > 0) {
57
- sections.push([
58
- `## Agents`,
59
- ``,
60
- `These agents are available to you if needed:`,
61
- ...agentPaths.map(p => `- ${p}`),
62
- ].join('\n'));
63
- }
64
- // Additional Instructions section (conditional)
65
- if (customInstruction && customInstruction.trim()) {
66
- sections.push([
67
- `## Additional Instructions`,
68
- ``,
69
- `DO strictly adhere to these additional instructions:`,
70
- customInstruction.trim(),
71
- ].join('\n'));
72
- }
73
- return [sections.join('\n\n')];
74
- }
75
- /**
76
- * Get instructions for reviewing / preparing a change proposal (cp-*) before implementation.
77
- * Assesses readiness without starting any actual work.
78
- */
79
- export function getPrepareChangeProposalInstructions(proposalId, agentPaths, customInstruction) {
80
- const sections = [];
81
- // Task section
82
- sections.push([
83
- `## Task`,
84
- ``,
85
- `- Review and assess the following task (include provided comments from the user and act on these accordingly) to ensure you have enough information, context, and resources (skills, MCP tools, appropriate access, etc) to successfully complete it, although DO NOT start any work at this stage: .nut/proposals/${proposalId}.md`,
86
- `- Generate a readiness score on a scale of 1-100 (where 1 is not ready at all and 100 is complete certainty on your ability to complete this task without ANY additional user interaction) and add this as a comment (details on how to do this below).`,
87
- `- Be sure to suggest to the user (again via a comment) if it would make sense to decompose this into separate tasks, although DO NOT do this without user confirmation first.`,
88
- `- Retrieve your firstName, lastName, and email address from: .nut/config.json and use this identity to address yourself in any task updates, comments, git commits, etc.`,
89
- ].join('\n'));
90
- // Task Lifecycle section
91
- sections.push([
92
- `## Task Lifecycle`,
93
- ``,
94
- `- Before beginning any work: nut task update ${proposalId} --status active`,
95
- `- Add appropriate implementation steps with: nut task step ${proposalId} "Step description" --author "firstName lastName"`,
96
- `- If you need human clarification or input: nut task update ${proposalId} --status blocked. The clarification can be communicated as follows: nut task comment ${proposalId} "Comments here" --author "firstName lastName". At this point please stop work.`,
97
- ].join('\n'));
98
- // Abilities section
99
- sections.push([
100
- `## Abilities`,
101
- ``,
102
- `- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):`,
103
- ` - Work with knowledge documents (used for the output of any research-centric tasks):`,
104
- ` - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"`,
105
- ` - nut knowledge list`,
106
- ` - nut knowledge get example-filename.md`,
107
- ` - Creating media such as images, audio, or video:`,
108
- ` - nut resource`,
109
- ` - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:`,
110
- ` - nut skills list`,
111
- ` - nut skills registry list`,
112
- `- Similarly, the following are available: git, gh, node, python`,
113
- ].join('\n'));
114
- // Operational Rules section
115
- sections.push([
116
- `## Operational Rules`,
117
- ``,
118
- `- DO NOT use 'npx' when running the nut CLI`,
119
- `- DO use the nut CLI to update task status as progress changes`,
120
- ` (nut --help or nut task --help for details)`,
121
- `- DO NOT edit files outside the scope of the approved proposal (unless instructed by the Additional Instructions below)`,
122
- ].join('\n'));
123
- // Skills section (conditional)
124
- if (agentPaths.length > 0) {
125
- sections.push([
126
- `## Skills`,
127
- ``,
128
- `These skills are available to you if needed (if you are able to test access, etc without any writes please do so):`,
129
- ...agentPaths.map(p => `- ${p}`),
130
- ].join('\n'));
131
- }
132
- // Additional Instructions section (conditional)
133
- if (customInstruction && customInstruction.trim()) {
134
- sections.push([
135
- `## Additional Instructions`,
136
- ``,
137
- `DO strictly adhere to these additional instructions:`,
138
- customInstruction.trim(),
139
- ].join('\n'));
140
- }
141
- return [sections.join('\n\n')];
142
- }
143
- /**
144
- * Get instructions for agent (ag-*) workflows
145
- * Agent content and custom instructions drive the behavior
146
- */
147
- export function getAgentInstructions(agentPaths, customInstruction) {
148
- const parts = [];
149
- parts.push(PROJECT_REFERENCE_INSTRUCTION);
150
- // Add agent references if provided
151
- if (agentPaths.length > 0) {
152
- parts.push(`Please use these skills: ${agentPaths.join(', ')}`);
153
- }
154
- // Add custom instruction if provided
155
- if (customInstruction && customInstruction.trim()) {
156
- parts.push(`Additional instruction: ${customInstruction.trim()}`);
157
- }
158
- return parts;
159
- }
160
- //# sourceMappingURL=agent-instructions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-instructions.js","sourceRoot":"","sources":["../src/agent-instructions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GACvC,mSAAmS,CAAC;AACtS,MAAM,CAAC,MAAM,6BAA6B,GACxC,6EAA6E,CAAA;AAE/E;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAAkB,EAClB,UAAoB,EACpB,iBAA0B,EAC1B,6BAAsC,IAAI;IAE1C,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,6CAA6C;IAC7C,IAAI,0BAA0B,EAAE,CAAC;QAC/B,eAAe;QACf,QAAQ,CAAC,IAAI,CAAC;YACZ,SAAS;YACT,EAAE;YACF,4DAA4D;YAC5D,oBAAoB,UAAU,KAAK;YACnC,0KAA0K;SAC3K,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAEb,yBAAyB;QACzB,QAAQ,CAAC,IAAI,CAAC;YACZ,mBAAmB;YACnB,EAAE;YACF,gDAAgD,UAAU,kBAAkB;YAC5E,+CAA+C,UAAU,mDAAmD;YAC5G,EAAE;YACF,+DAA+D,UAAU,yFAAyF,UAAU,iFAAiF;YAC7P,EAAE;YACF,6EAA6E,UAAU,kBAA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AAE,EAAE,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC;YACZ,4BAA4B;YAC5B,EAAE;YACF,sDAAsD;YACtD,iBAAiB,CAAC,IAAI,EAAE;SACzB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACf,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAoB,EACpB,iBAA0B;IAE1B,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAE1C,mCAAmC;IACnC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,4BAA4B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;IAED,qCAAqC;IACrC,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;QAClD,KAAK,CAAC,IAAI,CAAC,2BAA2B,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,74 +0,0 @@
1
- import type { ChangeProposal, CPStatus, Author, PlanStep, Evidence, AIInteraction } from '@lovelybunch/types';
2
- export declare class ChangeProposalManager {
3
- private proposals;
4
- /**
5
- * Create a new Change Proposal
6
- */
7
- create(params: {
8
- intent: string;
9
- author: Author;
10
- productSpecRef?: string;
11
- content?: string;
12
- tags?: string[];
13
- priority?: 'low' | 'medium' | 'high' | 'critical';
14
- }): ChangeProposal;
15
- /**
16
- * Get a Change Proposal by ID
17
- */
18
- get(id: string): ChangeProposal | undefined;
19
- /**
20
- * List all Change Proposals with optional filtering
21
- */
22
- list(options?: {
23
- status?: CPStatus;
24
- author?: string;
25
- limit?: number;
26
- offset?: number;
27
- }): ChangeProposal[];
28
- /**
29
- * Update a Change Proposal
30
- */
31
- update(id: string, updates: Partial<ChangeProposal>): ChangeProposal | undefined;
32
- /**
33
- * Update the status of a Change Proposal
34
- */
35
- updateStatus(id: string, status: CPStatus): ChangeProposal | undefined;
36
- /**
37
- * Add a plan step to a Change Proposal
38
- */
39
- addPlanStep(cpId: string, step: Omit<PlanStep, 'id'>): PlanStep | undefined;
40
- /**
41
- * Execute a plan step
42
- */
43
- executePlanStep(cpId: string, stepId: string, result: {
44
- output?: string;
45
- error?: string;
46
- status: 'completed' | 'failed';
47
- }): boolean;
48
- /**
49
- * Add evidence to a Change Proposal
50
- */
51
- addEvidence(cpId: string, evidence: Omit<Evidence, 'timestamp'>): Evidence | undefined;
52
- /**
53
- * Add an AI interaction to a Change Proposal
54
- */
55
- addAIInteraction(cpId: string, interaction: AIInteraction): boolean;
56
- /**
57
- * Delete a Change Proposal
58
- */
59
- delete(id: string): boolean;
60
- /**
61
- * Generate a unique ID for a Change Proposal
62
- */
63
- private generateId;
64
- /**
65
- * Export all proposals (for persistence)
66
- */
67
- export(): ChangeProposal[];
68
- /**
69
- * Import proposals (for loading from storage)
70
- */
71
- import(proposals: ChangeProposal[]): void;
72
- }
73
- export declare const cpManager: ChangeProposalManager;
74
- //# sourceMappingURL=change-proposal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-proposal.d.ts","sourceRoot":"","sources":["../src/change-proposal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,qBAAqB;IAChC,OAAO,CAAC,SAAS,CAA0C;IAE3D;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,OAAO,CAAC,EAA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iBnE;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI3B;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,IAAI;CAyB1C;AAGD,eAAO,MAAM,SAAS,uBAA8B,CAAC"}
@@ -1,207 +0,0 @@
1
- import { nanoid } from 'nanoid';
2
- export class ChangeProposalManager {
3
- proposals = new Map();
4
- /**
5
- * Create a new Change Proposal
6
- */
7
- create(params) {
8
- const id = this.generateId();
9
- const now = new Date();
10
- const proposal = {
11
- id,
12
- intent: params.intent,
13
- content: params.content,
14
- author: params.author,
15
- productSpecRef: params.productSpecRef,
16
- planSteps: [],
17
- evidence: [],
18
- policies: [],
19
- featureFlags: [],
20
- experiments: [],
21
- telemetryContracts: [],
22
- releasePlan: {
23
- strategy: 'immediate'
24
- },
25
- status: 'draft',
26
- metadata: {
27
- createdAt: now,
28
- updatedAt: now,
29
- reviewers: [],
30
- aiInteractions: [],
31
- tags: params.tags,
32
- priority: params.priority
33
- }
34
- };
35
- this.proposals.set(id, proposal);
36
- return proposal;
37
- }
38
- /**
39
- * Get a Change Proposal by ID
40
- */
41
- get(id) {
42
- return this.proposals.get(id);
43
- }
44
- /**
45
- * List all Change Proposals with optional filtering
46
- */
47
- list(options) {
48
- let proposals = Array.from(this.proposals.values());
49
- if (options?.status) {
50
- proposals = proposals.filter(p => p.status === options.status);
51
- }
52
- if (options?.author) {
53
- proposals = proposals.filter(p => p.author.id === options.author ||
54
- p.author.name === options.author ||
55
- p.author.email === options.author);
56
- }
57
- // Sort by creation date (newest first)
58
- proposals.sort((a, b) => b.metadata.createdAt.getTime() - a.metadata.createdAt.getTime());
59
- // Apply pagination
60
- const offset = options?.offset || 0;
61
- const limit = options?.limit || proposals.length;
62
- return proposals.slice(offset, offset + limit);
63
- }
64
- /**
65
- * Update a Change Proposal
66
- */
67
- update(id, updates) {
68
- const proposal = this.proposals.get(id);
69
- if (!proposal) {
70
- return undefined;
71
- }
72
- const updated = {
73
- ...proposal,
74
- ...updates,
75
- id: proposal.id, // Ensure ID cannot be changed
76
- metadata: {
77
- ...proposal.metadata,
78
- ...updates.metadata,
79
- updatedAt: new Date()
80
- }
81
- };
82
- this.proposals.set(id, updated);
83
- return updated;
84
- }
85
- /**
86
- * Update the status of a Change Proposal
87
- */
88
- updateStatus(id, status) {
89
- return this.update(id, { status });
90
- }
91
- /**
92
- * Add a plan step to a Change Proposal
93
- */
94
- addPlanStep(cpId, step) {
95
- const proposal = this.get(cpId);
96
- if (!proposal) {
97
- return undefined;
98
- }
99
- const planStep = {
100
- ...step,
101
- id: nanoid(8),
102
- status: step.status || 'pending'
103
- };
104
- const updatedSteps = [...proposal.planSteps, planStep];
105
- this.update(cpId, { planSteps: updatedSteps });
106
- return planStep;
107
- }
108
- /**
109
- * Execute a plan step
110
- */
111
- executePlanStep(cpId, stepId, result) {
112
- const proposal = this.get(cpId);
113
- if (!proposal) {
114
- return false;
115
- }
116
- const stepIndex = proposal.planSteps.findIndex(s => s.id === stepId);
117
- if (stepIndex === -1) {
118
- return false;
119
- }
120
- const updatedSteps = [...proposal.planSteps];
121
- updatedSteps[stepIndex] = {
122
- ...updatedSteps[stepIndex],
123
- ...result,
124
- executedAt: new Date()
125
- };
126
- this.update(cpId, { planSteps: updatedSteps });
127
- return true;
128
- }
129
- /**
130
- * Add evidence to a Change Proposal
131
- */
132
- addEvidence(cpId, evidence) {
133
- const proposal = this.get(cpId);
134
- if (!proposal) {
135
- return undefined;
136
- }
137
- const newEvidence = {
138
- ...evidence,
139
- timestamp: new Date()
140
- };
141
- const updatedEvidence = [...proposal.evidence, newEvidence];
142
- this.update(cpId, { evidence: updatedEvidence });
143
- return newEvidence;
144
- }
145
- /**
146
- * Add an AI interaction to a Change Proposal
147
- */
148
- addAIInteraction(cpId, interaction) {
149
- const proposal = this.get(cpId);
150
- if (!proposal) {
151
- return false;
152
- }
153
- const updatedInteractions = [...proposal.metadata.aiInteractions, interaction];
154
- this.update(cpId, {
155
- metadata: {
156
- ...proposal.metadata,
157
- aiInteractions: updatedInteractions
158
- }
159
- });
160
- return true;
161
- }
162
- /**
163
- * Delete a Change Proposal
164
- */
165
- delete(id) {
166
- return this.proposals.delete(id);
167
- }
168
- /**
169
- * Generate a unique ID for a Change Proposal
170
- */
171
- generateId() {
172
- return `cp-${Date.now()}`;
173
- }
174
- /**
175
- * Export all proposals (for persistence)
176
- */
177
- export() {
178
- return Array.from(this.proposals.values());
179
- }
180
- /**
181
- * Import proposals (for loading from storage)
182
- */
183
- import(proposals) {
184
- this.proposals.clear();
185
- for (const proposal of proposals) {
186
- // Convert date strings back to Date objects
187
- proposal.metadata.createdAt = new Date(proposal.metadata.createdAt);
188
- proposal.metadata.updatedAt = new Date(proposal.metadata.updatedAt);
189
- // Convert other date fields
190
- proposal.planSteps.forEach(step => {
191
- if (step.executedAt) {
192
- step.executedAt = new Date(step.executedAt);
193
- }
194
- });
195
- proposal.evidence.forEach(e => {
196
- e.timestamp = new Date(e.timestamp);
197
- });
198
- proposal.metadata.aiInteractions.forEach(ai => {
199
- ai.timestamp = new Date(ai.timestamp);
200
- });
201
- this.proposals.set(proposal.id, proposal);
202
- }
203
- }
204
- }
205
- // Export a singleton instance
206
- export const cpManager = new ChangeProposalManager();
207
- //# sourceMappingURL=change-proposal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-proposal.js","sourceRoot":"","sources":["../src/change-proposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,MAAM,OAAO,qBAAqB;IACxB,SAAS,GAAgC,IAAI,GAAG,EAAE,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,MAON;QACC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CA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