/** * Stack-agnostic workspace orientation for build turns. * * Weak models often skip fs.list/fs.read and plan against an imaginary empty * destination — then re-scaffold into a non-empty folder ("Operation cancelled") * or write into the agent package. This module snapshots the real cwd / * destination / candidate project paths so the model always sees ground truth * before plan.create or implement. */ /** Filenames that strongly suggest "this directory is already a software project". */ export declare const PROJECT_MARKERS: readonly ["package.json", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "Cargo.toml", "go.mod", "pyproject.toml", "requirements.txt", "Pipfile", "composer.json", "Gemfile", "pom.xml", "build.gradle", "build.gradle.kts", "CMakeLists.txt", "Makefile", "mix.exs", "pubspec.yaml", "Package.swift", "deno.json", "deno.jsonc", "tsconfig.json", "index.html", "setup.py", "manage.py", "Cargo.lock", ".git"]; export declare function isBareParentDirectory(path: string): boolean; export declare function detectProjectMarkers(dir: string): string[]; /** * Infer package manager from lockfiles / markers present in a project dir. * Prefer lockfile over bare package.json. */ export declare function detectPackageManager(dir: string): "npm" | "pnpm" | "yarn" | "bun" | "pip" | "poetry" | "cargo" | "go" | undefined; export declare function isExistingProjectDir(dir: string): boolean; /** * Discover marker-bearing immediate children under a user-named destination. * This is intentionally bounded and non-recursive: enough to resume an * arbitrary existing Desktop project without crawling the user's filesystem. */ export declare function discoverImmediateProjectRoots(parent: string, maxEntries?: number): string[]; export interface DirSnapshot { path: string; exists: boolean; isDir: boolean; entryCount: number; /** Up to maxNames entry basenames. */ entries: string[]; markers: string[]; isProject: boolean; emptyOrMissing: boolean; } export declare function snapshotDir(path: string, maxNames?: number): DirSnapshot; export interface WorkspaceOrientationInput { cwd?: string; /** User-named parent destination (e.g. Desktop). */ destinationHint?: string; /** Candidate project path from plan/prompt (may not exist yet). */ candidateProject?: string; /** Extra absolute paths to snapshot (e.g. Desktop/todo-app guessed from prompt). */ extraPaths?: string[]; } /** * Guess a likely project subfolder name from free text (todo-app, my-api, …). * Stack-agnostic: any reasonable folder token after create/scaffold/in/on. */ export declare function guessProjectFolderName(text: string): string | undefined; /** * Human + model-facing block injected into the system prompt for build turns. */ export declare function buildWorkspaceOrientation(input: WorkspaceOrientationInput): string; /** * Extract the directory name a scaffolder would create (stack-agnostic). * Returns undefined when the command is not a one-shot create into a named path. */ export declare function extractScaffoldTargetName(command: string): string | undefined; /** * Resolve absolute path a scaffolder would write into. */ export declare function resolveScaffoldTargetPath(command: string, shellCwd?: string): string | undefined; /** Scaffold cancelled / refused without creating a usable tree. */ export declare function isScaffoldCancelledOutput(output: string): boolean; /** * True when the target path looks like a materialized project after scaffold. */ export declare function scaffoldLooksMaterialized(targetPath: string | undefined): boolean; /** * Soft preflight: block scaffold into an existing non-empty project path. * Returns an error message for the model, or undefined if OK to proceed. */ export declare function scaffoldTargetConflictMessage(command: string, shellCwd?: string): string | undefined;