-
Notifications
You must be signed in to change notification settings - Fork 292
fix: keep Ambient Resume for Classic-only projects #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3526,6 +3526,36 @@ describe('update command helpers', () => { | |
| expect(claude).toContain('<comet-ambient-resume>'); | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Add coverage for Classic-only projects with To fully cover this bug, please add a companion test for a Classic-only project with Suggested implementation: expect(claude).toContain('<comet-ambient-resume>');
});
it('does not install ambient resume instructions for Classic-only projects with ambient_resume disabled', async () => {
await arrangeClassicDocsOpenSpecUpdate(tmpDir, { ambientResume: false });
// Pre-existing user content plus a previously inserted ambient resume block
await fs.writeFile(
path.join(tmpDir, 'AGENTS.md'),
'# User\n\nKeep this.\n\n<comet-ambient-resume>\nPrevious content\n</comet-ambient-resume>\n',
'utf8',
);
await fs.writeFile(
path.join(tmpDir, 'CLAUDE.md'),
'# User\n\nAlso keep this.\n\n<comet-ambient-resume>\nPrevious content\n</comet-ambient-resume>\n',
'utf8',
);
const fakeHome = path.join(tmpDir, 'fake-home-classic-instructions-disabled');
const homedirSpy = vi.spyOn(os, 'homedir').mockReturnValue(fakeHome);
const log = vi.spyOn(console, 'log').mockImplementation(() => undefined);
let json: string;
try {
await updateCommand(tmpDir, { json: true, skipNpm: true });
} finally {
homedirSpy.mockRestore();
log.mockRestore();
}
const agents = await fs.readFile(path.join(tmpDir, 'AGENTS.md'), 'utf8');
const claude = await fs.readFile(path.join(tmpDir, 'CLAUDE.md'), 'utf8');
// The managed ambient resume block should be absent
expect(agents).not.toContain('<comet-ambient-resume>');
expect(claude).not.toContain('<comet-ambient-resume>');
// User content should be preserved
expect(agents).toContain('# User\n\nKeep this.\n');
expect(claude).toContain('# User\n\nAlso keep this.\n');
});
it('installs ambient resume instructions for Classic-only projects', async () => {To fully wire this up, ensure that Classic-only projects with
|
||
|
|
||
| it('installs ambient resume instructions for Classic-only projects', async () => { | ||
| await arrangeClassicDocsOpenSpecUpdate(tmpDir); | ||
| await fs.writeFile(path.join(tmpDir, 'AGENTS.md'), '# User\n\nKeep this.\n', 'utf8'); | ||
| await fs.writeFile(path.join(tmpDir, 'CLAUDE.md'), '# User\n\nAlso keep this.\n', 'utf8'); | ||
|
|
||
| const fakeHome = path.join(tmpDir, 'fake-home-classic-instructions'); | ||
| const homedirSpy = vi.spyOn(os, 'homedir').mockReturnValue(fakeHome); | ||
| const log = vi.spyOn(console, 'log').mockImplementation(() => undefined); | ||
| let json: string; | ||
| try { | ||
| await updateCommand(tmpDir, { json: true, skipNpm: true }); | ||
| json = log.mock.calls.map((call) => call.join(' ')).join('\n'); | ||
| } finally { | ||
| log.mockRestore(); | ||
| homedirSpy.mockRestore(); | ||
| } | ||
|
|
||
| const result = JSON.parse(json); | ||
| expect(result.projectInstructions.updated).toBe(2); | ||
|
|
||
| const agents = await fs.readFile(path.join(tmpDir, 'AGENTS.md'), 'utf8'); | ||
| const claude = await fs.readFile(path.join(tmpDir, 'CLAUDE.md'), 'utf8'); | ||
| for (const content of [agents, claude]) { | ||
| expect(content).toContain('<comet-ambient-resume>'); | ||
| expect(content).toContain('comet resume-probe . --stdin --json'); | ||
| } | ||
| expect(agents).toContain('# User\n\nKeep this.'); | ||
| expect(claude).toContain('# User\n\nAlso keep this.'); | ||
| }); | ||
|
|
||
| it('removes ambient resume instructions when the project disables the probe', async () => { | ||
| await fs.mkdir(path.join(tmpDir, '.comet'), { recursive: true }); | ||
| await fs.writeFile( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add a negative-path init E2E test for Classic-only projects with
ambient_resume: false.Please also add a negative-path E2E that initializes a Classic-only project with
ambient_resume: false(or the probe disabled via config) and asserts that no<comet-ambient-resume>block is written toAGENTS.md/CLAUDE.mdand existing user content is preserved. This will mirror the non-Classic removal behavior and verify thatambient_resume: falsesemantics remain unchanged.Suggested implementation:
If this repository uses a different config file name, location, or schema to disable Ambient Resume (e.g.
.claude/project.json, YAML, or a nestedfeatures: { ambient_resume: false }object), adjust thefs.writeFilepath and JSON structure in the new test to match the existing non-Classic negative-path Ambient Resume tests so that the init command actually observes the disabled setting.