@iservu-inc/adf-cli 0.14.6 → 0.17.0

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.
Files changed (37) hide show
  1. package/.project/chats/current/SESSION-STATUS.md +25 -279
  2. package/.project/docs/PHASE-6-ADVANCED-LEARNING.md +46 -0
  3. package/.project/docs/ROADMAP.md +72 -157
  4. package/.project/docs/designs/CUSTOM-ARTIFACT-UPLOAD.md +259 -0
  5. package/.project/docs/designs/LEARNING-RULES-EXCHANGE.md +77 -0
  6. package/CHANGELOG.md +2054 -2995
  7. package/README.md +4 -7
  8. package/bin/adf.js +80 -0
  9. package/conductor/tracks/session_resume_review_20260113/plan.md +18 -0
  10. package/conductor/tracks.md +4 -0
  11. package/gemini.md +3 -0
  12. package/lib/ai/ai-client.js +9 -9
  13. package/lib/commands/deploy.js +14 -0
  14. package/lib/commands/guide.js +32 -0
  15. package/lib/commands/import.js +439 -0
  16. package/lib/commands/init.js +17 -4
  17. package/lib/frameworks/interviewer.js +277 -85
  18. package/lib/frameworks/progress-tracker.js +18 -0
  19. package/lib/generators/a2a-generator.js +289 -0
  20. package/lib/generators/index.js +11 -0
  21. package/lib/learning/learning-manager.js +107 -8
  22. package/lib/learning/rules-exporter.js +103 -0
  23. package/lib/learning/rules-importer.js +141 -0
  24. package/lib/templates/shared/agents/analyst.md +1 -1
  25. package/lib/templates/shared/agents/architect.md +1 -1
  26. package/lib/templates/shared/agents/dev.md +1 -1
  27. package/lib/templates/shared/agents/pm.md +2 -2
  28. package/lib/templates/shared/agents/qa.md +1 -1
  29. package/lib/templates/shared/agents/sm.md +3 -3
  30. package/lib/templates/shared/memory/constitution.md +2 -2
  31. package/lib/templates/shared/templates/README.md +14 -14
  32. package/lib/templates/shared/templates/prd-template.md +1 -1
  33. package/lib/utils/artifact-detector.js +253 -0
  34. package/lib/utils/tool-feature-registry.js +6 -0
  35. package/package.json +1 -1
  36. package/tests/a2a-generator.test.js +288 -0
  37. package/tests/progress-tracker.test.js +16 -0
@@ -0,0 +1,288 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+ const A2AGenerator = require('../lib/generators/a2a-generator');
4
+
5
+ const TEST_PROJECT_PATH = path.join(__dirname, 'test-project-a2a');
6
+ const TEST_SESSION_PATH = path.join(TEST_PROJECT_PATH, '.adf', 'sessions', 'test-session');
7
+
8
+ describe('A2AGenerator', () => {
9
+ beforeEach(async () => {
10
+ await fs.remove(TEST_PROJECT_PATH);
11
+ await fs.ensureDir(TEST_PROJECT_PATH);
12
+ await fs.ensureDir(TEST_SESSION_PATH);
13
+ await fs.ensureDir(path.join(TEST_SESSION_PATH, 'outputs'));
14
+ });
15
+
16
+ afterEach(async () => {
17
+ await fs.remove(TEST_PROJECT_PATH);
18
+ });
19
+
20
+ async function createPRPOutput() {
21
+ const prpContent = `# Product Requirement Prompt (PRP)
22
+
23
+ ## 1. Goal Definition
24
+ Build a React dashboard for analytics.
25
+
26
+ ## 2. Business Justification
27
+ Improve data-driven decisions.
28
+
29
+ ## 3. Contextual Intelligence
30
+ ### Technology Stack
31
+ - Frontend: React 18, TypeScript
32
+ - Backend: Node.js, Express
33
+ `;
34
+ await fs.writeFile(
35
+ path.join(TEST_SESSION_PATH, 'outputs', 'prp.md'),
36
+ prpContent,
37
+ 'utf-8'
38
+ );
39
+ await fs.writeJson(path.join(TEST_SESSION_PATH, '_metadata.json'), {
40
+ framework: 'rapid',
41
+ projectName: 'Test Dashboard'
42
+ });
43
+ }
44
+
45
+ async function createBalancedOutputs() {
46
+ await fs.writeFile(
47
+ path.join(TEST_SESSION_PATH, 'outputs', 'constitution.md'),
48
+ '# Constitution\n\n## Core Principles\n1. Privacy first',
49
+ 'utf-8'
50
+ );
51
+ await fs.writeFile(
52
+ path.join(TEST_SESSION_PATH, 'outputs', 'specification.md'),
53
+ '# Specification\n\n## Overview\nUser management system.',
54
+ 'utf-8'
55
+ );
56
+ await fs.writeJson(path.join(TEST_SESSION_PATH, '_metadata.json'), {
57
+ framework: 'balanced',
58
+ projectName: 'Test UserMgmt'
59
+ });
60
+ }
61
+
62
+ async function createComprehensiveOutputs() {
63
+ await fs.writeFile(
64
+ path.join(TEST_SESSION_PATH, 'outputs', 'prd.md'),
65
+ '# PRD\n\n## Executive Summary\nE-commerce platform.',
66
+ 'utf-8'
67
+ );
68
+ await fs.writeFile(
69
+ path.join(TEST_SESSION_PATH, 'outputs', 'architecture.md'),
70
+ '# Architecture\n\n## System Overview\nMicroservices.',
71
+ 'utf-8'
72
+ );
73
+ await fs.writeJson(path.join(TEST_SESSION_PATH, '_metadata.json'), {
74
+ framework: 'comprehensive',
75
+ projectName: 'Test Ecommerce'
76
+ });
77
+ }
78
+
79
+ describe('Rapid Framework', () => {
80
+ it('should generate A2A cards for rapid workflow (dev, qa)', async () => {
81
+ await createPRPOutput();
82
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
83
+ const result = await generator.generate();
84
+
85
+ // Check combined card exists
86
+ expect(await fs.pathExists(result.agentCard)).toBe(true);
87
+
88
+ // Check individual agents
89
+ expect(result.agents).toHaveLength(2);
90
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'dev.json'))).toBe(true);
91
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'qa.json'))).toBe(true);
92
+ });
93
+
94
+ it('should include correct fields in individual agent card', async () => {
95
+ await createPRPOutput();
96
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
97
+ await generator.generate();
98
+
99
+ const devCard = await fs.readJson(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'dev.json'));
100
+
101
+ expect(devCard).toHaveProperty('name');
102
+ expect(devCard).toHaveProperty('description');
103
+ expect(devCard).toHaveProperty('version');
104
+ expect(devCard).toHaveProperty('url', 'local://adf/agents/dev');
105
+ expect(devCard).toHaveProperty('supportedInterfaces');
106
+ expect(devCard.supportedInterfaces[0]).toHaveProperty('protocolBinding', 'JSONRPC');
107
+ expect(devCard.supportedInterfaces[0]).toHaveProperty('protocolVersion', '0.3');
108
+ expect(devCard).toHaveProperty('defaultInputModes');
109
+ expect(devCard).toHaveProperty('defaultOutputModes');
110
+ expect(devCard).toHaveProperty('capabilities');
111
+ expect(devCard).toHaveProperty('provider');
112
+ expect(devCard.provider.organization).toBe('ADF CLI');
113
+ expect(devCard).toHaveProperty('skills');
114
+ expect(devCard.skills.length).toBeGreaterThan(0);
115
+ });
116
+ });
117
+
118
+ describe('Balanced Framework', () => {
119
+ it('should generate A2A cards for balanced workflow (analyst, pm, dev, qa)', async () => {
120
+ await createBalancedOutputs();
121
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'balanced');
122
+ const result = await generator.generate();
123
+
124
+ expect(result.agents).toHaveLength(4);
125
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'analyst.json'))).toBe(true);
126
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'pm.json'))).toBe(true);
127
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'dev.json'))).toBe(true);
128
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'qa.json'))).toBe(true);
129
+ });
130
+ });
131
+
132
+ describe('Comprehensive Framework', () => {
133
+ it('should generate A2A cards for comprehensive workflow (all 6 agents)', async () => {
134
+ await createComprehensiveOutputs();
135
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'comprehensive');
136
+ const result = await generator.generate();
137
+
138
+ expect(result.agents).toHaveLength(6);
139
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'architect.json'))).toBe(true);
140
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'sm.json'))).toBe(true);
141
+ });
142
+ });
143
+
144
+ describe('Combined Agent Card', () => {
145
+ it('should contain all agents and merged skills', async () => {
146
+ await createPRPOutput();
147
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
148
+ await generator.generate();
149
+
150
+ const combined = await fs.readJson(path.join(TEST_PROJECT_PATH, '.a2a', 'agent-card.json'));
151
+
152
+ expect(combined.name).toContain('Test Dashboard');
153
+ expect(combined.description).toContain('rapid');
154
+ expect(combined).toHaveProperty('agents');
155
+ expect(combined.agents).toHaveLength(2);
156
+ expect(combined).toHaveProperty('skills');
157
+ expect(combined.skills.length).toBeGreaterThan(0);
158
+
159
+ // Skills from both dev and qa should be present
160
+ const skillIds = combined.skills.map(s => s.id);
161
+ expect(skillIds).toContain('tdd-implementation');
162
+ expect(skillIds).toContain('risk-assessment');
163
+ });
164
+
165
+ it('should have correct A2A protocol fields', async () => {
166
+ await createPRPOutput();
167
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
168
+ await generator.generate();
169
+
170
+ const combined = await fs.readJson(path.join(TEST_PROJECT_PATH, '.a2a', 'agent-card.json'));
171
+
172
+ expect(combined).toHaveProperty('supportedInterfaces');
173
+ expect(combined.supportedInterfaces[0].protocolBinding).toBe('JSONRPC');
174
+ expect(combined).toHaveProperty('defaultInputModes');
175
+ expect(combined.defaultInputModes).toContain('text/plain');
176
+ expect(combined.defaultInputModes).toContain('application/json');
177
+ });
178
+ });
179
+
180
+ describe('Frontmatter Parsing', () => {
181
+ it('should parse agent YAML frontmatter correctly', async () => {
182
+ await createPRPOutput();
183
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
184
+
185
+ const content = `---
186
+ agent:
187
+ id: dev
188
+ name: Dev
189
+ role: Senior Full-Stack Developer
190
+ focus: TDD implementation with context engineering
191
+
192
+ mcp_tools:
193
+ - context7
194
+ - mem0
195
+ ---
196
+
197
+ # Dev Agent`;
198
+
199
+ const frontmatter = generator.parseAgentFrontmatter(content);
200
+
201
+ expect(frontmatter.agent).toBeDefined();
202
+ expect(frontmatter.agent.id).toBe('dev');
203
+ expect(frontmatter.agent.name).toBe('Dev');
204
+ expect(frontmatter.agent.role).toBe('Senior Full-Stack Developer');
205
+ expect(frontmatter.mcp_tools).toContain('context7');
206
+ expect(frontmatter.mcp_tools).toContain('mem0');
207
+ });
208
+
209
+ it('should return empty object for content without frontmatter', async () => {
210
+ await createPRPOutput();
211
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
212
+
213
+ const content = '# Just a heading\nNo frontmatter here.';
214
+ const frontmatter = generator.parseAgentFrontmatter(content);
215
+
216
+ expect(frontmatter).toEqual({});
217
+ });
218
+ });
219
+
220
+ describe('Skills Mapping', () => {
221
+ it('should include MCP tools as skills', async () => {
222
+ await createPRPOutput();
223
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
224
+ await generator.generate();
225
+
226
+ const devCard = await fs.readJson(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'dev.json'));
227
+ const mcpSkills = devCard.skills.filter(s => s.id.startsWith('mcp-'));
228
+
229
+ expect(mcpSkills.length).toBeGreaterThan(0);
230
+ expect(mcpSkills.some(s => s.id === 'mcp-context7')).toBe(true);
231
+ });
232
+
233
+ it('should map dev agent to development skills', async () => {
234
+ await createPRPOutput();
235
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
236
+ await generator.generate();
237
+
238
+ const devCard = await fs.readJson(path.join(TEST_PROJECT_PATH, '.a2a', 'agents', 'dev.json'));
239
+ const coreSkills = devCard.skills.filter(s => !s.id.startsWith('mcp-'));
240
+
241
+ expect(coreSkills.some(s => s.id === 'tdd-implementation')).toBe(true);
242
+ expect(coreSkills.some(s => s.id === 'code-review')).toBe(true);
243
+ });
244
+ });
245
+
246
+ describe('Idempotency', () => {
247
+ it('should safely regenerate without errors', async () => {
248
+ await createPRPOutput();
249
+ const generator1 = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
250
+ await generator1.generate();
251
+
252
+ // Run again — should not throw
253
+ const generator2 = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
254
+ const result = await generator2.generate();
255
+
256
+ expect(await fs.pathExists(result.agentCard)).toBe(true);
257
+ expect(result.agents).toHaveLength(2);
258
+ });
259
+ });
260
+
261
+ describe('Output Structure', () => {
262
+ it('should create .a2a directory with correct structure', async () => {
263
+ await createPRPOutput();
264
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'rapid');
265
+ await generator.generate();
266
+
267
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a'))).toBe(true);
268
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agent-card.json'))).toBe(true);
269
+ expect(await fs.pathExists(path.join(TEST_PROJECT_PATH, '.a2a', 'agents'))).toBe(true);
270
+ });
271
+
272
+ it('should produce valid JSON in all output files', async () => {
273
+ await createComprehensiveOutputs();
274
+ const generator = new A2AGenerator(TEST_SESSION_PATH, TEST_PROJECT_PATH, 'comprehensive');
275
+ await generator.generate();
276
+
277
+ // All files should be parseable JSON
278
+ const agentsDir = path.join(TEST_PROJECT_PATH, '.a2a', 'agents');
279
+ const files = await fs.readdir(agentsDir);
280
+
281
+ for (const file of files) {
282
+ const content = await fs.readJson(path.join(agentsDir, file));
283
+ expect(content).toHaveProperty('name');
284
+ expect(content).toHaveProperty('skills');
285
+ }
286
+ });
287
+ });
288
+ });
@@ -76,6 +76,22 @@ describe('ProgressTracker', () => {
76
76
  expect(progress.averageAnswerQuality).toBe(80); // (80+90+70)/3 = 80
77
77
  });
78
78
 
79
+ it('should update existing answer correctly', async () => {
80
+ const tracker = new ProgressTracker(TEST_SESSION_PATH, 5, 'rapid');
81
+ await tracker.initialize();
82
+
83
+ const initialMetrics = { qualityScore: 80, wordCount: 10, isComprehensive: true };
84
+ await tracker.answerQuestion('q1', 'Q1', 'Initial Answer', initialMetrics);
85
+
86
+ const newAnswerText = 'Updated Answer with more words';
87
+ await tracker.updateAnswer('q1', newAnswerText);
88
+
89
+ const progress = tracker.getProgress();
90
+ expect(progress.answers['q1'].text).toBe(newAnswerText);
91
+ expect(progress.answers['q1'].quality.wordCount).toBe(5); // Updated word count
92
+ expect(progress.totalWordCount).toBe(5); // totalWordCount should be updated correctly
93
+ });
94
+
79
95
  it('should calculate information richness based on quality and completion', async () => {
80
96
  const tracker = new ProgressTracker(TEST_SESSION_PATH, 5, 'rapid');
81
97
  await tracker.initialize();