Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Stabilized the `tests-passing` Jest result projector heap regression test by running Jest with `--expose-gc` and asserting median post-GC retained heap growth instead of a single pre-GC delta.
- Routed PREVC phase auto-commit diagnostics to stderr and installed an MCP stdio console guard so non-protocol output cannot corrupt JSON-RPC on stdout (fixes MCP client disconnect on phase completion).
- Honoured `dryRun` on MCP `exportSkills` sync actions so previews no longer write skill export files to the repository.
- Removed MCP response-body reparsing from action logging and replaced oversized response truncation risk with typed smaller-page or artifact-reference responses.
- Applied the same bounded UTF-8 budget to every MCP resource, rejected oversized files before reading their bodies, enforced action-specific list maxima, and paginated `explore` file listings.
- Bounded `explore` reads before file materialization and replaced whole-glob/whole-file code search with byte-capped streaming discovery, search, and cursor pages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import * as path from 'path';

import { HarnessSyncActionService } from '../syncActionService';

const EXPORT_MARKER_DIRS = ['.claude', '.codex', '.gemini', '.windsurf', '.github', '.agents'] as const;

async function listExportMarkerDirs(repoPath: string): Promise<string[]> {
const entries = await fs.readdir(repoPath);
return entries.filter((entry) => EXPORT_MARKER_DIRS.includes(entry as (typeof EXPORT_MARKER_DIRS)[number]));
}

describe('HarnessSyncActionService', () => {
let tempDir: string;
let service: HarnessSyncActionService;
Expand All @@ -30,4 +37,25 @@ describe('HarnessSyncActionService', () => {
expect(result.dryRun).toBe(true);
expect(result.filesSkipped).toBeGreaterThan(0);
});

it('exportSkills dry run previews without creating export directories', async () => {
await fs.outputFile(
path.join(tempDir, '.context', 'skills', 'sample', 'SKILL.md'),
'---\nname: sample\ndescription: Sample skill\n---\n# Sample\n'
);

const before = await listExportMarkerDirs(tempDir);
const result = await service.execute({
action: 'exportSkills',
preset: 'claude',
dryRun: true,
});
const after = await listExportMarkerDirs(tempDir);

expect(before).toEqual(after);
expect(result.dryRun).toBe(true);
expect(result.success).toBe(true);
expect(result.filesCreated).toBeGreaterThan(0);
expect(result.skillsExported).toContain('sample');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,29 @@ describe('SkillExportService', () => {
expect(content).toContain('## Resource Strategy');
expect(content).not.toContain('## When to Use');
});

it('dry run previews skill exports without writing files', async () => {
const scaffoldPath = path.join(repoPath, '.context', 'skills', 'sample', 'SKILL.md');
await fs.outputFile(
scaffoldPath,
'---\nname: sample\ndescription: Sample skill\n---\n# Sample\n',
'utf-8'
);

const service = new SkillExportService({
ui: minimalUI as any,
t: mockTranslate,
version: 'test',
});

const result = await service.run(repoPath, {
targets: ['.claude/skills'],
skills: ['sample'],
dryRun: true,
});

expect(result.filesCreated).toBe(1);
expect(result.skillsExported).toEqual(['sample']);
expect(await fs.pathExists(path.join(repoPath, '.claude', 'skills', 'sample', 'SKILL.md'))).toBe(false);
});
});
15 changes: 14 additions & 1 deletion src/harness/application/exchange/export/skillExportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,21 @@ export class SkillExportService {
this.deps.ui.startSpinner(`Exporting skills to ${target.name}...`);

if (options.dryRun) {
for (const skill of skills) {
const skillFile = path.join(targetPath, skill.slug, 'SKILL.md');

if (await pathExists(skillFile) && !options.force) {
result.filesSkipped++;
continue;
}

result.filesCreated++;
if (!result.skillsExported.includes(skill.slug)) {
result.skillsExported.push(skill.slug);
}
}

this.deps.ui.updateSpinner(`[DRY-RUN] Would export to ${targetPath}`, 'success');
result.filesSkipped++;
this.deps.ui.stopSpinner();
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/harness/application/exchange/syncActionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@ export class HarnessSyncActionService {
preset: params.preset,
includeBuiltIn: params.includeBuiltIn,
force: params.force,
dryRun: params.dryRun,
});

return {
success: result.filesCreated > 0,
success: params.dryRun ? result.filesCreated > 0 || result.filesSkipped > 0 : result.filesCreated > 0,
targets: result.targets,
skillsExported: result.skillsExported,
filesCreated: result.filesCreated,
filesSkipped: result.filesSkipped,
dryRun: params.dryRun || false,
};
}
case 'reverseSync': {
Expand Down
27 changes: 27 additions & 0 deletions src/mcp/gateway/__tests__/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,31 @@ describe('handleSync', () => {
expect(payload.success).toBe(true);
expect(payload.dryRun).toBe(true);
});

it('exportSkills dry run reports a preview without writing files', async () => {
await fs.outputFile(
path.join(tempDir, '.context', 'skills', 'sample', 'SKILL.md'),
'---\nname: sample\ndescription: Sample skill\n---\n# Sample\n'
);

const markers = ['.claude', '.codex', '.gemini', '.windsurf', '.github', '.agents'];
const before = new Set((await fs.readdir(tempDir)).filter((entry) => markers.includes(entry)));

const response = await handleSync(
{
action: 'exportSkills',
preset: 'claude',
dryRun: true,
},
{ repoPath: tempDir }
);
const payload = JSON.parse(response.content[0].text);
const after = new Set((await fs.readdir(tempDir)).filter((entry) => markers.includes(entry)));

expect(before).toEqual(after);
expect(payload.dryRun).toBe(true);
expect(payload.filesCreated).toBeGreaterThan(0);
expect(payload.skillsExported).toContain('sample');
expect(await fs.pathExists(path.join(tempDir, '.claude', 'skills', 'sample', 'SKILL.md'))).toBe(false);
});
});
2 changes: 1 addition & 1 deletion src/mcp/server/mcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Actions:
- exportDocs: Export docs to AI tools (params: preset?, indexMode?, force?, dryRun?)
- exportAgents: Export agents to AI tools (params: preset?, mode?, force?, dryRun?)
- exportContext: Export all context (params: preset?, skipDocs?, skipAgents?, skipSkills?, docsIndexMode?, agentMode?, force?, dryRun?)
- exportSkills: Export skills to AI tools (params: preset?, includeBuiltIn?, force?)
- exportSkills: Export skills to AI tools (params: preset?, includeBuiltIn?, force?, dryRun?)
- reverseSync: Import from AI tools to .context/ (params: skipRules?, skipAgents?, skipSkills?, mergeStrategy?, dryRun?, force?, addMetadata?)
- importDocs: Import docs from AI tools (params: autoDetect?, force?, dryRun?)
- importAgents: Import agents from AI tools (params: autoDetect?, force?, dryRun?)
Expand Down
Loading