asdf
Squash the current repository state back into one baseline commit while preserving the README reframing and repository contents. Constraint: User explicitly requested a single squashed commit with subject "asdf" Confidence: high Scope-risk: broad Reversibility: clean Directive: This commit intentionally rewrites published history; coordinate before future force-pushes Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr Not-tested: Fresh clone verification after push
This commit is contained in:
commit
d2542c9a62
31
src/utils/tempfile.ts
Normal file
31
src/utils/tempfile.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { createHash, randomUUID } from 'crypto'
|
||||
import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
|
||||
/**
|
||||
* Generate a temporary file path.
|
||||
*
|
||||
* @param prefix Optional prefix for the temp file name
|
||||
* @param extension Optional file extension (defaults to '.md')
|
||||
* @param options.contentHash When provided, the identifier is derived from a
|
||||
* SHA-256 hash of this string (first 16 hex chars). This produces a path
|
||||
* that is stable across process boundaries — any process with the same
|
||||
* content will get the same path. Use this when the path ends up in content
|
||||
* sent to the Anthropic API (e.g., sandbox deny lists in tool descriptions),
|
||||
* because a random UUID would change on every subprocess spawn and
|
||||
* invalidate the prompt cache prefix.
|
||||
* @returns Temp file path
|
||||
*/
|
||||
export function generateTempFilePath(
|
||||
prefix: string = 'claude-prompt',
|
||||
extension: string = '.md',
|
||||
options?: { contentHash?: string },
|
||||
): string {
|
||||
const id = options?.contentHash
|
||||
? createHash('sha256')
|
||||
.update(options.contentHash)
|
||||
.digest('hex')
|
||||
.slice(0, 16)
|
||||
: randomUUID()
|
||||
return join(tmpdir(), `${prefix}-${id}${extension}`)
|
||||
}
|
||||
Reference in New Issue
Block a user