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
6 changes: 5 additions & 1 deletion src/__tests__/dry-run-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ describe('--dry-run guard decisions', () => {
}

it.each([
'stats', 'digest', 'recall',
'digest',
])('refuses %s until its writes have a preview', (path) => {
expect(dryRunRefusal(command(path))).toBe(`teamai ${path} has no --dry-run preview, nothing was run`);
});

it.each(['stats', 'recall'])('allows the merged %s preview', (path) => {
expect(dryRunRefusal(command(path))).toBeUndefined();
});

it.each([
'remove', 'roles init', 'roles add', 'roles remove', 'roles update',
'projects add', 'projects update', 'projects remove',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/e2e/dry-run-refusal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('--dry-run on a command with no preview', () => {
});

it.each([
['stats'], ['digest'], ['recall', 'query'],
['digest'],
['import', '--from-iwiki', 'page', '--from-mr', 'url'], ['import', '--from-claude'],
])('refuses unsafe preview %j before writing', (...args) => {
const before = snapshot(home);
Expand Down
8 changes: 6 additions & 2 deletions src/__tests__/e2e/stats-recall-dry-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ function git(args: string[], cwd: string): void {

const fwd = (value: string): string => value.split(path.sep).join('/');

/** Every file under `dir` mapped to a content hash; git's transient lock files left out. */
/**
* Every file under `dir` mapped to a content hash. Git's transient lock files
* and the CLI diagnostic log are left out: every log line appends to it,
* preview or not, the same way the other dry-run e2e suites ignore it.
*/
function snapshotTree(dir: string): Record<string, string> {
const out: Record<string, string> = {};
const walk = (current: string): void => {
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
const full = path.join(current, entry.name);
if (entry.isDirectory()) walk(full);
else if (entry.isFile() && !entry.name.endsWith('.lock') && entry.name !== 'gc.pid') {
else if (entry.isFile() && !entry.name.endsWith('.lock') && entry.name !== 'gc.pid' && entry.name !== 'debug.log') {
out[path.relative(dir, full)] = createHash('sha256').update(fs.readFileSync(full)).digest('hex');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dry-run-guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const DRY_RUN_PREVIEW: ReadonlySet<string> = new Set([
'models restore',
'session save',
'contribute',
'stats',
'recall',
'recall feedback',
'recall disable',
'recall enable',
Expand All @@ -93,8 +95,6 @@ export const DRY_RUN_PREVIEW: ReadonlySet<string> = new Set([
* on a command that is in neither.
*/
export const NO_DRY_RUN_PREVIEW: Readonly<Record<string, string>> = {
stats: 'creates or refreshes the reports worktree until #970 lands',
recall: 'writes recall quality and the search index until #970 lands',
digest: 'creates or refreshes the reports worktree; #900 C11',
init: 'no preview; clones, saves config and injects hooks (single-repo: bootstraps the clone)',
'models add': 'writes the personal profile and its key',
Expand Down
Loading