nexus/server/src
Nexus Dev 22e14545d4 fix(nexus): extend tilde expansion and mkdir to all user path endpoints
Follow-up to commit 91530b07 which only covered agents.adapter_config
.cwd. An audit found three additional user-facing endpoints that
accept filesystem paths without normalization. Same zero-terminal bug
in each: user supplies "~/foo", server stores it raw, downstream
consumers can't resolve the tilde.

Extract the two helpers (expandUserPath, normalizeWorkspaceDir) from
the agents.ts closure into a shared utility so all endpoints use the
same primitive.

new: server/src/utils/path-normalization.ts
  - expandUserPath(candidate): resolves ~ / ~/foo to homedir() and
    path.resolve() to absolute. Null-safe on non-string input.
  - normalizeWorkspaceDir(rawPath, { field }): expand + assert
    absolute + mkdir -p + stat isDirectory + log the change.
    Throws unprocessable (422) on any filesystem failure with a
    field-aware error message.

changed: server/src/routes/agents.ts
  - Replaced the inline expandUserPath + normalizeAdapterConfigPaths
    helpers with a narrow wrapper that delegates to the shared utility.
    Three call sites (create, hire, patch) unchanged in behavior.
  - Removed now-unused imports: mkdir, stat, homedir.

changed: server/src/routes/projects.ts
  - POST /projects/:id/workspaces: normalize req.body.cwd before the
    service call.
  - PATCH /projects/:id/workspaces/:workspaceId: same.
  - Added import.

changed: server/src/routes/execution-workspaces.ts
  - PATCH /execution-workspaces/🆔 normalize req.body.cwd before the
    patch object is built.
  - Added import.

changed: server/src/services/nexus-settings.ts
  - In set(): expand ~ in piperBinaryPath and whisperBinaryPath before
    merging and validating. These are executable paths so we expand
    but don't mkdir — caller still has to install the binary itself,
    but the stored path is now resolvable by the server.
  - Added import.

Not extended:
  - Storage provider baseDir: computed at startup from environment,
    not user request body. Sandboxed. No change needed.
  - Instructions bundle paths: indirectly covered — the legacy path
    resolver depends on cwd being absolute, which 91530b07 ensures.
  - Chat file upload object keys: system-generated, not user-supplied.

Verification: npx tsc --noEmit on server — zero errors introduced in
any touched file. Dev server on :6100 still returns 200.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 18:22:33 +00:00
..
__tests__ feat: Phase 45 — Content as Skills (9 SKILL.md files, Creative group, gap fixes) 2026-04-05 09:57:20 +00:00
adapters Merge branch 'master' into add-gpt-5-4-xhigh-effort 2026-03-31 06:19:26 -05:00
auth fix: disable secure cookies for HTTP deployments 2026-03-08 22:00:51 -05:00
data feat(30-01): hardware detection, nexus-settings, extended model catalog 2026-04-04 03:55:49 +00:00
middleware fix: align telemetry client payload and dimensions with backend schema 2026-04-02 10:47:29 -05:00
onboarding-assets [nexus] fix: restore upstream delegation and fact-extraction content lost during rebase 2026-04-04 03:55:42 +00:00
realtime update typing to node v24 from v20 2026-03-05 14:36:00 -03:00
routes fix(nexus): extend tilde expansion and mkdir to all user path endpoints 2026-04-10 18:22:33 +00:00
secrets refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
services fix(nexus): extend tilde expansion and mkdir to all user path endpoints 2026-04-10 18:22:33 +00:00
skills/content feat: Phase 45 — Content as Skills (9 SKILL.md files, Creative group, gap fixes) 2026-04-05 09:57:20 +00:00
storage refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
types feat: Phase 44 — Video & Presentations (Remotion MP4, SSE progress) 2026-04-05 09:57:11 +00:00
utils fix(nexus): extend tilde expansion and mkdir to all user path endpoints 2026-04-10 18:22:33 +00:00
agent-auth-jwt.ts Implement local agent JWT authentication for adapters 2026-02-18 16:46:45 -06:00
app.ts fix(nexus): auto-bootstrap invite and vite onnxruntime middleware 2026-04-10 16:50:28 +00:00
attachment-types.ts feat: Phase 40 — Job Infrastructure (content jobs, SSE events, namespaced storage) 2026-04-05 09:55:08 +00:00
board-claim.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
bootstrap-invite.ts fix(nexus): auto-bootstrap invite and vite onnxruntime middleware 2026-04-10 16:50:28 +00:00
config-file.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
config.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
dev-server-status.ts Add guarded dev restart handling 2026-03-20 08:50:00 -05:00
dev-watch-ignore.ts Harden dev-watch excludes for nested UI outputs 2026-03-26 12:35:19 -05:00
errors.ts Add server routes for companies, approvals, costs, and dashboard 2026-02-17 09:07:27 -06:00
home-paths.ts feat(09-01): install @libsql/client, schema, DB init, path helpers 2026-04-04 03:55:42 +00:00
index.ts fix(nexus): auto-bootstrap invite and vite onnxruntime middleware 2026-04-10 16:50:28 +00:00
log-redaction.ts Add username log censor setting 2026-03-20 08:50:00 -05:00
paths.ts feat(cli): add client commands and home-based local runtime defaults 2026-02-20 07:10:58 -06:00
redaction.ts Implement secrets service with local encryption, redaction, and runtime resolution 2026-02-19 15:43:52 -06:00
startup-banner.ts feat(02-01): replace PAPERCLIP ASCII art with NEXUS in banners 2026-04-04 03:55:41 +00:00
telemetry.ts fix: add periodic flush and graceful shutdown for server-side telemetry 2026-04-02 10:47:29 -05:00
ui-branding.ts Add worktree UI branding 2026-03-13 11:12:43 -05:00
version.ts add app version label 2026-03-17 09:40:07 +05:30
worktree-config.ts Avoid sibling worktree port collisions 2026-03-26 11:12:39 -05:00