Skip to content

refactor(repo): restructure into apps/ + packages/ + native/ (atomic)#724

Merged
muqsitnawaz merged 3 commits into
mainfrom
restructure2
Jul 7, 2026
Merged

refactor(repo): restructure into apps/ + packages/ + native/ (atomic)#724
muqsitnawaz merged 3 commits into
mainfrom
restructure2

Conversation

@muqsitnawaz

Copy link
Copy Markdown
Contributor

What

Supersedes #722 (rebased onto latest main — the old branch conflicted after main advanced ~10 commits, which blocked CI from running).
Restructures the repo by kind so it's navigable for humans and agents — one atomic move, matching the Turborepo/Nx apps/ + packages/ convention with a native/ bucket for standalone daemons (the Swift/C# analog of everyone's crates/).

apps/cli/            @phnx-labs/agents-cli (was repo root)
  └─ menubar/        native menu-bar helper (welded — ships in the CLI tarball)
apps/factory/        the Factory GUI (was packages/factory) — extension + ui + app
packages/            session-tracker, swarmify-mirror (shared libs, unchanged)
native/computer-mac  was packages/computer-helper  (fixes the mac/win naming asymmetry)
native/computer-win  was packages/computer-helper-win
root                 now { "private": true } monorepo root + new README

Why no workspaces

The CLI imports nothing from sibling packages except the 3 native helpers (verified: 0 cross-imports of session-tracker/swarmify/factory). So each package self-installs exactly as before — which also means the @inquirer/core hoisting break (caused by adding workspaces) cannot recur.

Only hand-edits (everything else is git mv)

  • menubar resolver (install-menubar.ts): ../../../packages/menubar-helper../../../menubar (moved with the CLI, same depth).
  • computer-* resolvers (computer-rpc.ts, ssh-tunnel.ts): depth +2../../../../native/computer-{mac,win} — because native/ sits at the repo root while the CLI is now nested under apps/cli. (This was the one real trap; recomputed, not blind-replaced.)
  • CI: working-directory: apps/cli on tests/tests-windows/ci/bench; path filters re-prefixed in lockstep (tests-windows + its -noop companion); computer-helper-win.ymlnative/computer-win.
  • release.sh: git show <ref>:package.json:apps/cli/package.json (2 lines).

VS Code publish identity unchanged (publisher: swarmify, name: swarm-ext, appId: com.swarmify.factory).

Verified (local, macOS)

  • cd apps/cli && bun install --frozen-lockfile && bun run buildrc=0 (no @inquirer/core recurrence).
  • bun run test4313 pass; the only 2 failures are pre-existing env-pollution in src/lib/exec.test.ts (assert DISABLE_AUTOUPDATER/AGENTS_MAILBOX_DIR unset — both set in an agent session; green on clean CI).
  • npm pack --dry-run → 769 files, no apps/packages/native leak into the CLI tarball.
  • apps/factory extension host compiles (rc=0).
  • native/computer-mac builds; the built CLI's agents computer status resolves the helper from the new location (reports daemon/policy, not "helper not built").

Not verifiable locally (release-machine step)

The full release.sh <ver> dry-run previews the tarball via prepack, which needs the notarized keychain .app (only on the release machine — same reason there's no CI publish). The build/test portions are verified above; the 2 release.sh path edits are trivial and exercised at the next release.

muqsitnawaz and others added 3 commits July 7, 2026 03:52
Sorts the repo by kind (Turborepo/Nx apps+packages convention + a native/ bucket
for standalone daemons). One atomic move; no JS workspaces (nothing cross-imports,
so each package self-installs — avoids the @inquirer/core hoisting break).

  apps/cli/            @phnx-labs/agents-cli (was repo root) + menubar/ (welded, in tarball)
  apps/factory/        the Factory GUI (was packages/factory)
  packages/            session-tracker, swarmify-mirror (shared libs)
  native/computer-mac  was packages/computer-helper (fixes mac/win naming asymmetry)
  native/computer-win  was packages/computer-helper-win
  root                 now { "private": true } monorepo root + new README

Hand-edits: menubar resolver -> ../../../menubar; computer-* resolvers ->
../../../../native/computer-{mac,win} (depth +2, native/ at repo root while the CLI
is nested under apps/cli); CI working-directory: apps/cli on tests/tests-windows/
ci/bench + path filters re-prefixed in lockstep + computer-helper-win.yml ->
native/computer-win; release.sh git show <ref>:package.json -> :apps/cli/package.json.

VS Code publish identity (publisher swarmify / swarm-ext / appId) unchanged.
Verified: apps/cli frozen install + build rc=0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@muqsitnawaz muqsitnawaz merged commit 26a70b0 into main Jul 7, 2026
7 checks passed
@muqsitnawaz muqsitnawaz deleted the restructure2 branch July 7, 2026 11:04
@prix-cloud

prix-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Code Reviewer

Verdict: Changes requested

Build: Green — cd apps/cli && bun install && bun run build exits rc=0, tsc emits without errors.
Tests: computer.test.ts — 13/13 passed (confirmed). Full 4313-test suite was still running at post time; author's local run reports 4313 pass + 2 pre-existing env-pollution failures in src/lib/exec.test.ts (only fail inside agent sessions where DISABLE_AUTOUPDATER/AGENTS_MAILBOX_DIR are set; clean on CI).

AGENTS.md / CLAUDE.md read: /workspace/task-8bd9d787/AGENTS.md — confirmed read before building.


What works well

The core restructure is solid. All three runtime path fixes are correct:

  • computer-rpc.ts:190-191../../../../native/computer-mac from apps/cli/dist/lib/ is 4 levels up → repo root ✓
  • ssh-tunnel.ts:135 — same 4-level depth → ../../../../native/computer-win
  • install-menubar.ts:101 — 3 levels up from apps/cli/dist/lib/menubar/apps/cli/menubar/

CI workflows (tests.yml, ci.yml, bench.yml, tests-windows.yml, tests-windows-noop.yml, computer-helper-win.yml) all correctly updated with working-directory: apps/cli or native/computer-win. release.sh git-show references correctly updated to apps/cli/package.json at lines 366 and 541. Root package.json is private:true with correct monorepo wrapper scripts.


Issues that need attention

1. apps/cli/scripts/build-win.sh — local cross-compile broken after move (functional bug)

# Line 17
cd "$(dirname "$0")/.."
# ...
# Line 42
PROJECT="native/computer-win"

Before the rename, the script was at scripts/build-win.sh (repo root), so cd "$(dirname "$0")/.." landed at the repo root and native/computer-win resolved correctly.

After the rename, the script is at apps/cli/scripts/build-win.sh. The cd now lands at apps/cli/, but native/computer-win is at the repo root — not at apps/cli/native/computer-win (that directory doesn't exist).

Running scripts/build-win.sh from macOS/Linux for local cross-compilation will immediately fail with a dotnet "project not found" error.

The CI computer-helper-win.yml is unaffected (it uses working-directory: native/computer-win directly and never calls this script). But the local dev path is broken.

Fix: Change the cd on line 17 to go 3 levels up:

cd "$(dirname "$0")/../../.."

2. apps/cli/src/lib/ssh-tunnel.ts:129 — stale JSDoc after rename (minor)

/**
 * Locate the cross-published Windows daemon exe. Only the local build output is
 * a candidate — `scripts/build-win.sh` writes it to packages/.../dist/.
 */

The path reference packages/.../dist/ is the old location. The code on the next line correctly resolves to native/computer-win/dist/ — only the comment is stale. Low risk but will mislead the next reader.

Fix: Update to native/computer-win/dist/.

3. AGENTS.md build instructions and links broken after restructure

AGENTS.md is the canonical AI navigation file for this repo — every AI agent session reads it first. After this restructure it contains:

Broken build command (AGENTS.md:142):

bun install && bun run build && bun test

Running this from the repo root now fails — root package.json has no build or test scripts (only build:cli and test:cli). Any AI agent spinning up a new session will fail its first build attempt.

Correct command (from repo root):

cd apps/cli && bun install && bun run build && bun test

Broken relative links (all 404 after this merge on GitHub):

  • AGENTS.md:29[src/lib/capabilities.ts](src/lib/capabilities.ts)apps/cli/src/lib/capabilities.ts
  • AGENTS.md:33[src/lib/migrate.ts](src/lib/migrate.ts)apps/cli/src/lib/migrate.ts
  • AGENTS.md:39src/lib/types.ts:176-177apps/cli/src/lib/types.ts:176-177
  • AGENTS.md:68 — three src/lib/*.ts links → need apps/cli/ prefix each
  • AGENTS.md:102src/lib/agents.ts (×2) → apps/cli/src/lib/agents.ts
  • AGENTS.md:147,150scripts/install.shapps/cli/scripts/install.sh
  • AGENTS.md:157scripts/build.shapps/cli/scripts/build.sh
  • AGENTS.md:170scripts/build-keychain-helper.sh, scripts/verify-keychain-helper.sh, scripts/Agents CLI.app.sha256, src/lib/secrets/keychain-helper.swift → all need apps/cli/ prefix
  • AGENTS.md:174[packages/menubar-helper](packages/menubar-helper)apps/cli/menubar; scripts/verify-menubar-helper.shapps/cli/scripts/verify-menubar-helper.sh

Stale source layout (AGENTS.md:118-137):

src/
  index.ts
  ...

Should now be apps/cli/src/.

Given that AGENTS.md is read by AI coding agents to orient themselves, the broken build command in particular will cause every new session to fail its first build — making the "Build, test, dev" section actively harmful rather than helpful.


Things to verify manually

  • The build-win.sh fix cannot be end-to-end verified here (no .NET SDK / Windows). Confirm dotnet publish resolves native/computer-win correctly after applying the cd depth fix.

Reviewed by Code Reviewer — built from apps/cli/ (rc=0), test suite was running at post time.

muqsitnawaz added a commit that referenced this pull request Jul 7, 2026
#728)

* fix(sessions): stop co-located sessions from sharing one preview/topic

`sessions --active` showed the IDENTICAL preview + topic for every session in one
cwd — 6 editor tabs, or two worktree siblings, all looked like duplicate cards.

Root cause: findClaudeSessionFile fell back to the newest `.jsonl` in the cwd
whenever a session's `<id>.jsonl` wasn't found, so N distinct sessions collapsed
onto ONE file (preview + topic derive solely from that file). The id goes stale
because an editor caches the launch uuid in live-terminals.json, but Claude rotates
its transcript uuid on resume/compact.

- Extract `pickSessionFile(projectDir, id?)`: a concrete id returns its own file or
  undefined, NEVER a sibling's; the newest-file fallback is gated to the no-id case.
- listTerminalsActive resolves each tab's EXACT id from the pid registry first
  (mirroring the headless path).
- classifyActivity: no resolvable file now means `idle`, not `running`.
- Test active.pickfile.test.ts (vitest, real temp files, no mocks).

Verified end-to-end pre-restructure: 6 codium tabs went from 6x identical preview
-> 6x distinct (blank, idle). Rebuilt on the apps/cli layout after #724.

Supersedes #727 (which targeted the pre-restructure src/ path).

* docs(sessions): correct pid-registry comment — no-op for editor shell pids

Reviewer flagged the comment overstated the registry lookup: live-terminals.json
stores the shell pid but the by-pid registry is keyed by the agent pid, so for
editor-launched terminals the lookup returns undefined and falls back to the
cached id. The duplicate-card fix is pickSessionFile no longer borrowing a
sibling. Comment now says so; no behavior change.
muqsitnawaz added a commit that referenced this pull request Jul 7, 2026
The #724 restructure moved src/scripts/tests into apps/cli/ but left docs/ at
the repo root. Colocate the CLI docs with the CLI. Doc-internal ../src links now
resolve to apps/cli/src again.
muqsitnawaz added a commit that referenced this pull request Jul 7, 2026
…/cli/bin, repoint stale refs

The restructure left the release broken: the signed keychain + menubar .app
bundles live at repo-root bin/ (untracked, gitignored via /bin/), but every
apps/cli script now looks in apps/cli/bin/. prepack (verify-*-helper.sh) fails →
npm publish aborts; the build cp is swallowed by || true → JS-only tarball.

- .gitignore: /bin/ -> /apps/cli/bin/ so staged signed bundles stay ignored
  (and don't dirty the release tree). Bundles get placed at apps/cli/bin/ at
  release time; sha already matches the pin, no rebuild/notarization.
- Dockerfile.test: build + test from apps/cli (no root build script; src moved).
- apps/cli/scripts/build-win.sh: native/ is a repo-root sibling of apps/, not
  under apps/cli — point PROJECT at ../../native/computer-win.
- .gitleaks.toml: anchor allowlist paths at apps/cli/src/lib.
- AGENTS.md / README.md / CONTRIBUTING.md: repoint src/docs/scripts links,
  build/release/install commands, and the menubar path at the apps/cli layout.
muqsitnawaz added a commit that referenced this pull request Jul 7, 2026
Reconciles headless dispatch (#719) with the apps/ restructure (#724) and the
factory action-model parity work landed since. Union of protocol messages;
headless Focus/Stop added into main's evolved agent-card action block (main's
reply-based Focus buttons don't cover headless runs).
muqsitnawaz added a commit that referenced this pull request Jul 7, 2026
Replays the browser session-cookie changes onto the apps/cli/ layout (restructure
#724 moved src/ -> apps/cli/src/) and rebases the CHANGELOG onto main's current
Unreleased section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant