@meltstudio/meltctl 4.29.1 → 4.31.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.
@@ -3,6 +3,8 @@ vi.mock('fs-extra', () => ({
3
3
  default: {
4
4
  pathExists: vi.fn(),
5
5
  readFile: vi.fn(),
6
+ ensureDir: vi.fn(),
7
+ writeFile: vi.fn(),
6
8
  },
7
9
  }));
8
10
  vi.mock('../utils/api.js', () => ({
@@ -19,7 +21,7 @@ vi.mock('../utils/git.js', () => ({
19
21
  import fs from 'fs-extra';
20
22
  import { getToken, tokenFetch } from '../utils/api.js';
21
23
  import { getGitBranch, getGitCommit, getGitRepository, getProjectName, findMdFiles, } from '../utils/git.js';
22
- import { auditSubmitCommand, auditListCommand } from './audit.js';
24
+ import { auditSubmitCommand, auditListCommand, auditViewCommand } from './audit.js';
23
25
  beforeEach(() => {
24
26
  vi.clearAllMocks();
25
27
  vi.spyOn(console, 'log').mockImplementation(() => { });
@@ -320,3 +322,94 @@ describe('auditListCommand', () => {
320
322
  expect(errorCalls.some((msg) => typeof msg === 'string' && msg.includes('No audits found'))).toBe(true);
321
323
  });
322
324
  });
325
+ describe('auditViewCommand', () => {
326
+ const sampleAudit = {
327
+ id: 'audit-abc123',
328
+ type: 'ux-audit',
329
+ project: 'my-project',
330
+ repository: 'Org/Repo',
331
+ author: 'dev@meltstudio.co',
332
+ branch: 'main',
333
+ commit: 'abc1234',
334
+ content: '# UX Audit\n\nFindings here.',
335
+ createdAt: '2026-03-25T10:00:00Z',
336
+ };
337
+ it('exits with "Access denied" on 403 response', async () => {
338
+ ;
339
+ getToken.mockResolvedValue('test-token');
340
+ tokenFetch.mockResolvedValue({
341
+ ok: false,
342
+ status: 403,
343
+ statusText: 'Forbidden',
344
+ });
345
+ await expect(auditViewCommand('audit-abc123', {})).rejects.toThrow('process.exit(1)');
346
+ const errorCalls = console.error.mock.calls.map((c) => String(c[0]));
347
+ expect(errorCalls.some((msg) => msg.includes('Access denied'))).toBe(true);
348
+ });
349
+ it('exits with "Audit not found" on 404 response', async () => {
350
+ ;
351
+ getToken.mockResolvedValue('test-token');
352
+ tokenFetch.mockResolvedValue({
353
+ ok: false,
354
+ status: 404,
355
+ statusText: 'Not Found',
356
+ });
357
+ await expect(auditViewCommand('nonexistent-id', {})).rejects.toThrow('process.exit(1)');
358
+ const errorCalls = console.error.mock.calls.map((c) => String(c[0]));
359
+ expect(errorCalls.some((msg) => msg.includes('Audit not found'))).toBe(true);
360
+ });
361
+ it('exits with error from body on non-ok response', async () => {
362
+ ;
363
+ getToken.mockResolvedValue('test-token');
364
+ tokenFetch.mockResolvedValue({
365
+ ok: false,
366
+ status: 500,
367
+ statusText: 'Internal Server Error',
368
+ json: vi.fn().mockResolvedValue({ error: 'Database unavailable' }),
369
+ });
370
+ await expect(auditViewCommand('audit-abc123', {})).rejects.toThrow('process.exit(1)');
371
+ const errorCalls = console.error.mock.calls.map((c) => String(c[0]));
372
+ expect(errorCalls.some((msg) => msg.includes('Database unavailable'))).toBe(true);
373
+ });
374
+ it('prints audit content with header when no --output flag', async () => {
375
+ ;
376
+ getToken.mockResolvedValue('test-token');
377
+ tokenFetch.mockResolvedValue({
378
+ ok: true,
379
+ status: 200,
380
+ json: vi.fn().mockResolvedValue(sampleAudit),
381
+ });
382
+ await auditViewCommand('audit-abc123', {});
383
+ const logCalls = console.log.mock.calls.map((c) => String(c[0]));
384
+ // Header should contain type label, repo, author, and date
385
+ expect(logCalls.some((msg) => msg.includes('UX Audit'))).toBe(true);
386
+ expect(logCalls.some((msg) => msg.includes('Org/Repo'))).toBe(true);
387
+ expect(logCalls.some((msg) => msg.includes('dev@meltstudio.co'))).toBe(true);
388
+ // Content should be printed
389
+ expect(logCalls.some((msg) => msg.includes('# UX Audit'))).toBe(true);
390
+ });
391
+ it('writes content to file with --output flag', async () => {
392
+ ;
393
+ getToken.mockResolvedValue('test-token');
394
+ tokenFetch.mockResolvedValue({
395
+ ok: true,
396
+ status: 200,
397
+ json: vi.fn().mockResolvedValue(sampleAudit),
398
+ });
399
+ fs.ensureDir.mockResolvedValue(undefined);
400
+ fs.writeFile.mockResolvedValue(undefined);
401
+ await auditViewCommand('audit-abc123', { output: 'output/audit.md' });
402
+ expect(fs.ensureDir).toHaveBeenCalled();
403
+ expect(fs.writeFile).toHaveBeenCalledWith(expect.stringContaining('audit.md'), '# UX Audit\n\nFindings here.', 'utf-8');
404
+ const logCalls = console.log.mock.calls.map((c) => String(c[0]));
405
+ expect(logCalls.some((msg) => msg.includes('Audit saved to'))).toBe(true);
406
+ });
407
+ it('exits with error message on network error', async () => {
408
+ ;
409
+ getToken.mockResolvedValue('test-token');
410
+ tokenFetch.mockRejectedValue(new Error('Network error'));
411
+ await expect(auditViewCommand('audit-abc123', {})).rejects.toThrow('process.exit(1)');
412
+ const errorCalls = console.error.mock.calls.map((c) => String(c[0]));
413
+ expect(errorCalls.some((msg) => msg.includes('Network error'))).toBe(true);
414
+ });
415
+ });
package/dist/index.js CHANGED
@@ -29,6 +29,20 @@ program
29
29
  printBanner();
30
30
  return '';
31
31
  })
32
+ .addHelpText('after', `
33
+ ${chalk.bold('AI Skills')} ${chalk.dim('(run these in your AI coding tool, not the CLI):')}
34
+ ${chalk.dim(' /melt-setup Analyze the project and customize AGENTS.md')}
35
+ ${chalk.dim(' /melt-plan Design an implementation approach before writing code')}
36
+ ${chalk.dim(' /melt-validate Run the validation plan and verify end-to-end')}
37
+ ${chalk.dim(' /melt-review Review changes against project standards')}
38
+ ${chalk.dim(' /melt-pr Create a well-structured pull request')}
39
+ ${chalk.dim(' /melt-debug Systematically investigate and fix bugs')}
40
+ ${chalk.dim(' /melt-audit Run a project compliance audit')}
41
+ ${chalk.dim(' /melt-ux-audit Review UI against usability heuristics')}
42
+ ${chalk.dim(' /melt-security-audit Run a security posture audit across the platform')}
43
+ ${chalk.dim(' /melt-update Update Melt skills to the latest version')}
44
+ ${chalk.dim(' /melt-help Answer questions about the development playbook')}
45
+ `)
32
46
  .hook('preAction', async () => {
33
47
  await checkAndEnforceUpdate();
34
48
  });
@@ -44,7 +58,14 @@ program
44
58
  .action(async () => {
45
59
  await logoutCommand();
46
60
  });
47
- const project = program.command('project').description('manage project configuration');
61
+ const project = program
62
+ .command('project')
63
+ .description('manage project configuration')
64
+ .addHelpText('after', `
65
+ ${chalk.dim('Related skills (run in your AI coding tool after init):')}
66
+ ${chalk.dim(' /melt-setup Analyze the project and customize AGENTS.md')}
67
+ ${chalk.dim(' /melt-update Update Melt skills to the latest version')}
68
+ `);
48
69
  project
49
70
  .command('init')
50
71
  .description('scaffold Melt development tools into the current directory (AGENTS.md, .claude/, .cursor/, .opencode/, .mcp.json)')
@@ -91,7 +112,15 @@ program
91
112
  .action(async (options) => {
92
113
  await coinsCommand(options);
93
114
  });
94
- const audit = program.command('audit').description('submit and list audits');
115
+ const audit = program
116
+ .command('audit')
117
+ .description('submit and list audits')
118
+ .addHelpText('after', `
119
+ ${chalk.dim('Related skills (run in your AI coding tool):')}
120
+ ${chalk.dim(' /melt-audit Run a project compliance audit')}
121
+ ${chalk.dim(' /melt-ux-audit Review UI against usability heuristics')}
122
+ ${chalk.dim(' /melt-security-audit Run a security posture audit across the platform')}
123
+ `);
95
124
  audit
96
125
  .command('submit')
97
126
  .description('submit an audit report from a markdown file')
@@ -117,7 +146,13 @@ audit
117
146
  .action(async (id, options) => {
118
147
  await auditViewCommand(id, options);
119
148
  });
120
- const plan = program.command('plan').description('submit and list plans');
149
+ const plan = program
150
+ .command('plan')
151
+ .description('submit and list plans')
152
+ .addHelpText('after', `
153
+ ${chalk.dim('Related skill (run in your AI coding tool):')}
154
+ ${chalk.dim(' /melt-plan Design an implementation approach before writing code')}
155
+ `);
121
156
  plan
122
157
  .command('submit')
123
158
  .description('submit or update a plan from a markdown file')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltstudio/meltctl",
3
- "version": "4.29.1",
3
+ "version": "4.31.0",
4
4
  "description": "AI-first development tools for teams - set up AGENTS.md, Claude Code, Cursor, and OpenCode standards",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",