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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
]

[workspace.package]
version = "2026.10324.11958"
version = "2026.10325.12228"
edition = "2024"
license = "AGPL-3.0-only"
authors = ["TrueNine"]
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@truenine/memory-sync-cli-darwin-arm64",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@truenine/memory-sync-cli-darwin-x64",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@truenine/memory-sync-cli-linux-arm64-gnu",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@truenine/memory-sync-cli-linux-x64-gnu",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@truenine/memory-sync-cli-win32-x64-msvc",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@truenine/memory-sync-cli",
"type": "module",
"version": "2026.10324.11958",
"version": "2026.10325.12228",
"description": "TrueNine Memory Synchronization CLI",
"author": "TrueNine",
"license": "AGPL-3.0-only",
Expand Down
71 changes: 71 additions & 0 deletions cli/src/cleanup/delete-targets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as path from 'node:path'
import {resolveAbsolutePath} from '../ProtectedDeletionGuard'

export interface CompactedDeletionTargets {
readonly files: string[]
readonly dirs: string[]
}

function stripTrailingSeparator(rawPath: string): string {
const {root} = path.parse(rawPath)
if (rawPath === root) return rawPath
return rawPath.endsWith(path.sep) ? rawPath.slice(0, -1) : rawPath
}

export function isSameOrChildDeletionPath(candidate: string, parent: string): boolean {
const normalizedCandidate = stripTrailingSeparator(candidate)
const normalizedParent = stripTrailingSeparator(parent)
if (normalizedCandidate === normalizedParent) return true
return normalizedCandidate.startsWith(`${normalizedParent}${path.sep}`)
}

export function compactDeletionTargets(
files: readonly string[],
dirs: readonly string[]
): CompactedDeletionTargets {
const filesByKey = new Map<string, string>()
const dirsByKey = new Map<string, string>()

for (const filePath of files) {
const resolvedPath = resolveAbsolutePath(filePath)
filesByKey.set(resolvedPath, resolvedPath)
}

for (const dirPath of dirs) {
const resolvedPath = resolveAbsolutePath(dirPath)
dirsByKey.set(resolvedPath, resolvedPath)
}

const compactedDirs = new Map<string, string>()
const sortedDirEntries = [...dirsByKey.entries()].sort((a, b) => a[0].length - b[0].length)

for (const [dirKey, dirPath] of sortedDirEntries) {
let coveredByParent = false
for (const existingParentKey of compactedDirs.keys()) {
if (isSameOrChildDeletionPath(dirKey, existingParentKey)) {
coveredByParent = true
break
}
}

if (!coveredByParent) compactedDirs.set(dirKey, dirPath)
}

const compactedFiles: string[] = []
for (const [fileKey, filePath] of filesByKey) {
let coveredByDir = false
for (const dirKey of compactedDirs.keys()) {
if (isSameOrChildDeletionPath(fileKey, dirKey)) {
coveredByDir = true
break
}
}

if (!coveredByDir) compactedFiles.push(filePath)
}

compactedFiles.sort((a, b) => a.localeCompare(b))
const compactedDirPaths = [...compactedDirs.values()].sort((a, b) => a.localeCompare(b))

return {files: compactedFiles, dirs: compactedDirPaths}
}
59 changes: 59 additions & 0 deletions cli/src/commands/CleanupUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ function createMockLogger(): ILogger {
} as ILogger
}

function createRecordingLogger(): ILogger & {debugMessages: unknown[]} {
const debugMessages: unknown[] = []

return {
debugMessages,
trace: () => {},
debug: message => {
debugMessages.push(message)
},
info: () => {},
warn: () => {},
error: () => {},
fatal: () => {}
} as ILogger & {debugMessages: unknown[]}
}

function createCleanContext(
overrides?: Partial<OutputCleanContext['collectedOutputContext']>,
pluginOptionsOverrides?: Parameters<typeof mergeConfig>[0]
Expand Down Expand Up @@ -630,4 +646,47 @@ describe('performCleanup', () => {
fs.rmSync(tempDir, {recursive: true, force: true})
}
})

it('logs aggregated cleanup execution summaries instead of per-path success logs', async () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tnmsc-perform-cleanup-logging-'))
const outputFile = path.join(tempDir, 'project-a', 'AGENTS.md')
const outputDir = path.join(tempDir, '.codex', 'prompts')
const stalePrompt = path.join(outputDir, 'demo.md')
const logger = createRecordingLogger()

fs.mkdirSync(path.dirname(outputFile), {recursive: true})
fs.mkdirSync(outputDir, {recursive: true})
fs.writeFileSync(outputFile, '# agent', 'utf8')
fs.writeFileSync(stalePrompt, '# prompt', 'utf8')

try {
const ctx = createCleanContext({
workspace: {
directory: {
pathKind: FilePathKind.Absolute,
path: tempDir,
getDirectoryName: () => path.basename(tempDir),
getAbsolutePath: () => tempDir
},
projects: []
}
})
const plugin = createMockOutputPlugin('MockOutputPlugin', [outputFile], {
delete: [{kind: 'directory', path: outputDir}]
})

await performCleanup([plugin], ctx, logger)

expect(logger.debugMessages).toEqual(expect.arrayContaining([
'cleanup plan built',
'cleanup delete execution started',
'cleanup delete execution complete'
]))
expect(logger.debugMessages).not.toContainEqual(expect.objectContaining({path: outputFile}))
expect(logger.debugMessages).not.toContainEqual(expect.objectContaining({path: outputDir}))
}
finally {
fs.rmSync(tempDir, {recursive: true, force: true})
}
})
})
Loading
Loading