Files
AgentHub/client/src/lib/resolvePath.ts
T
nntrivi2001 22de5009ff feat: v2.7.8 — Artifacts hub, clone related repos as extra folders, quieter resume prompt
- Artifacts (/artifacts): claude.ai pages sessions publish (captured from the
  Artifact tool's hook), pinned workspace files, skills and plugins, each
  kept as a snapshot; shared ones appear in a Hub and a skill or plugin
  installs into the viewer's own account (server/lib/artifacts.js,
  /api/artifacts, docs/plans/artifacts/).
- Workspace extra folders: clone one or more related repos beside the
  workspace and add them in one step (POST /api/lanes/:id/sources/clone).
- A pane that ended by itself while tmux kept running is no longer offered
  for resume (tmux.serverStartedAt in reconcileOrphans).
- Changes panel: a folder that is not a git repo opens on Files, and its
  files open from there.
- Plus the parallel sessions' work in this tree: File Explorer button in the
  panel header, user delete, RSA SSH keys, chat/terminal and pet fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 16:06:54 +07:00

21 lines
876 B
TypeScript

/**
* @file resolvePath.ts — resolves a path a chat reply names against the pane's
* folder: an absolute one (POSIX, `~`-less, or `C:\…`) is kept, a relative one
* (`server/lib/x.js`, `./a`, `../b`) is joined to `cwd` with `.`/`..` folded,
* so the preview and the Changes panel see the same absolute path the agent meant.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
/** `path` as an absolute path; relative ones resolve against `cwd`. */
export function resolveIn(cwd: string, path: string): string {
if (/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(path) || !cwd) return path;
const parts = cwd.replace(/[\\/]+$/, "").split(/[\\/]/);
for (const seg of path.split(/[\\/]/)) {
if (seg === "" || seg === ".") continue;
if (seg === "..") {
if (parts.length > 1) parts.pop();
} else parts.push(seg);
}
return parts.join("/") || "/";
}