fix: apply PR #49 (tilde expansion + natural language commands)#52
fix: apply PR #49 (tilde expansion + natural language commands)#52memorysaver merged 8 commits intomainfrom
Conversation
…e commands - Replace /looplia:build and /looplia:run slash commands with natural language prompts (SDK does not recognize slash commands) - Expand tilde (~) in LOOPLIA_DEV_ROOT env var for dev plugin path resolution - Update all test assertions in build.test.ts (both commands/ and integration/) to expect the new natural language prompt format Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewOverall this is a clean, well-scoped change. The natural-language command rename is clearly necessary and the test updates are accurate. A few things worth addressing: Bug: use
|
There was a problem hiding this comment.
Pull request overview
This PR updates Looplia’s dev-mode plugin path resolution and CLI agent prompts: it expands ~ in LOOPLIA_DEV_ROOT for provider bootstrap, and switches CLI “slash command” prompts to natural-language prefixes to align with SDK behavior.
Changes:
- Expand
~/...inLOOPLIA_DEV_ROOTbefore computing dev plugin paths. - Replace
/looplia:buildprompt prefix with a natural-language prompt prefix (and update related build tests). - Update integration/unit test assertions that depended on the old
/looplia:*prompt format.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/provider/src/bootstrap/index.ts | Adds tilde expansion when resolving dev plugin root. |
| packages/provider/test/bootstrap/index.test.ts | Adds coverage for ~ expansion in LOOPLIA_DEV_ROOT. |
| apps/cli/src/constants.ts | Switches command prefixes from /looplia:* to natural-language prompt strings. |
| apps/cli/test/commands/build.test.ts | Updates unit tests to expect the new build prompt prefix. |
| apps/cli/test/integration/build.test.ts | Updates integration assertions to expect the new build prompt prefix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/cli/test/commands/build.test.ts
Outdated
| expect(result).toBe("Create a looplia workflow from the following description: summarize articles"); | ||
| }); | ||
|
|
||
| it("should return just /build when no description", () => { |
There was a problem hiding this comment.
These test names still refer to “/build” prompts, but buildPrompt() now emits a natural-language prefix. Renaming the test descriptions (including the one below for the empty description case) will keep the tests self-explanatory.
| if (devRoot.startsWith("~/")) { | ||
| devRoot = devRoot.replace("~", process.env.HOME || ""); |
There was a problem hiding this comment.
The tilde expansion uses process.env.HOME and replaces ~ with an empty string when HOME is unset. This can yield an invalid absolute path (e.g. ~/x -> /x) and is inconsistent with the rest of this module (which uses os.homedir()). Consider expanding ~/~/ via homedir() (and ideally normalize()/join()), and handle the devRoot === "~" case as well.
| if (devRoot.startsWith("~/")) { | |
| devRoot = devRoot.replace("~", process.env.HOME || ""); | |
| if (devRoot === "~") { | |
| devRoot = homedir(); | |
| } else if (devRoot.startsWith("~/")) { | |
| devRoot = join(homedir(), devRoot.slice(2)); |
| process.env.LOOPLIA_DEV = "true"; | ||
| process.env.LOOPLIA_DEV_ROOT = "~/test/workspace"; | ||
| process.env.HOME = "/Users/testuser"; | ||
|
|
||
| const paths = await getPluginPaths(); | ||
|
|
||
| process.env.LOOPLIA_DEV = originalDev; | ||
| process.env.LOOPLIA_DEV_ROOT = originalRoot; | ||
| process.env.HOME = originalHome; |
There was a problem hiding this comment.
This test restores env vars by assigning the saved value back. If the original value was undefined, process.env.X = originalX may set the literal string "undefined" (and if getPluginPaths() throws, the restore code won’t run). Prefer a try/finally and delete process.env.X when the original value was unset.
apps/cli/src/constants.ts
Outdated
| * Command prefixes for looplia slash commands | ||
| * v0.6.5: Use looplia: prefix to avoid conflict with built-in commands | ||
| * v0.8.1: Changed to natural language prompts - SDK doesn't recognize /looplia:* commands |
There was a problem hiding this comment.
The doc comment still describes these as “slash commands”, but the constants are now natural-language prompt prefixes. Updating the comment will avoid confusion for future changes (and reduces the chance someone reintroduces /looplia:* based on the comment).
| * Command prefixes for looplia slash commands | |
| * v0.6.5: Use looplia: prefix to avoid conflict with built-in commands | |
| * v0.8.1: Changed to natural language prompts - SDK doesn't recognize /looplia:* commands | |
| * Prompt prefixes for looplia CLI commands (natural-language prompts) | |
| * v0.6.5: Used a looplia: prefix on slash commands to avoid conflict with built-in commands | |
| * v0.8.1: Switched from /looplia:* slash commands to natural-language prompts (SDK does not recognize /looplia:* commands) |
- Use homedir() from node:os instead of process.env.HOME for tilde expansion (cross-platform, handles bare ~ and ~/path) - Add try/finally with proper delete for env cleanup in tilde test - Update tilde test to assert against homedir() rather than a hardcoded path (homedir() is OS-level, not env-driven) - Wrap long string assertions in build tests to satisfy Biome's 80-char print width (affects build.test.ts and integration/build.test.ts) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewThe previous automated review comment was written against an earlier PR version — this PR has already addressed all the concerns raised there (uses OverallClean, well-scoped change. The tilde-expansion fix is implemented correctly and the natural-language command rename is a necessary fix for SDK compatibility. All 17 test assertion updates look accurate. bootstrap/index.ts — looks goodif (devRoot.startsWith("~/")) {
devRoot = join(homedir(), devRoot.slice(2));
} else if (devRoot === "~") {
devRoot = homedir();
}
No issues. Minor: JSDoc comment still says "slash commands"
/**
* Command prefixes for looplia slash commands
* v0.6.5: Use looplia: prefix to avoid conflict with built-in commands
* v0.8.1: Changed to natural language prompts - SDK doesn't recognize /looplia:* commands
*/The block heading still says "looplia slash commands" — this will mislead future readers. Consider updating to "Command prefixes for looplia agent prompts" or similar. Minor: test doesn't cover the bare
|
- Replace delete process.env.X with direct assignment in finally block to comply with Biome lint/performance/noDelete rule - Rename test descriptions in build.test.ts to remove /build references - Update JSDoc in constants.ts from slash commands to natural-language prompts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewThe implementation is clean and the natural-language command rename is well-scoped. A few observations: Correctness: tilde expansion implementation is good
Bug: env cleanup sets
|
- Rebuild root provider before CLI bundle so new presets (M2.5) are picked up when node_modules symlinks resolve to the root repo - Force-rebuild CLI via tsup after turbo build to bypass stale cache in git worktrees where the root node_modules are shared - Run copy-plugins after build so apps/cli/plugins/ exists for init - Unset CLAUDECODE in setup_test_env() to allow nested claude sessions - Default preset updated: ZENMUX_MINIMAX_M21 → ZENMUX_MINIMAX_M25 - SKILL.md: document env -u CLAUDECODE for direct invocation inside Claude Code sessions; update preset reference M2.1 → M2.5 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewThe implementation is correct and well-scoped. Two issues remain worth addressing before merge. Bug: env cleanup sets
|
Extend the env cleanup pattern to the pre-existing 'should return dev paths when LOOPLIA_DEV=true' test. Previously, direct assignment of potentially-undefined values back to process.env could leak env state into subsequent tests if getPluginPaths() threw. Now uses try/finally with assertions inside the try block, matching the established pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewThe core changes here are correct and well-targeted. The two outstanding issues from previous reviews are still present — confirming them below plus a few additional observations on the e2e script. Bug (confirmed): env cleanup assigns string
|
PR ReviewOverall this is a clean, focused PR that correctly ports and fixes PR #49's changes. The test isolation improvements are a good defensive practice. A few observations: Positive
Issues1. Missing test coverage for the bare The implementation handles both process.env.LOOPLIA_DEV_ROOT = "~";
// expect paths[0].path to start with homedir()2. Inconsistent env-var isolation in same test file ( The pre-existing 3. The updated The structured 4. Brittle worktree detection in root_repo="$(cd "$PROJECT_ROOT/../.." 2>/dev/null && pwd)" || trueThis navigates exactly two levels up, which implicitly assumes a specific directory depth for git worktrees. If the worktree is nested at a different depth the check silently produces a wrong 5. CHANGELOG appears incomplete for this PR's scope The diff only adds an entry for the test isolation fix. The two behaviorally significant changes — tilde expansion in Minor / Nits
Summary: The two primary fixes are correct. The blocking concern before merge is item 5 (CHANGELOG completeness). Items 1–2 are small enough to fix inline. Items 3–4 are design/maintainability notes that can be tracked as follow-up issues if not addressed now. |
…hs test - Add test for bare `~` LOOPLIA_DEV_ROOT (exercises the else-if branch in bootstrap/index.ts:463) - Wrap `should return prod paths` test in try/finally to prevent env leak if getPluginPaths() throws Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewOverall this is a clean, well-motivated PR. The two core changes (tilde expansion and natural-language prompt migration) are sound, and the test-isolation improvements are a genuine step forward. A few things worth addressing before merge: Bug:
|
- Add SDK parenthetical to v0.8.1 history in constants.ts - Replace env var assignment with delete-when-undefined in 4 getPluginPaths finally blocks to avoid setting literal "undefined" string in non-Bun runtimes; suppress noDelete lint rule with biome-ignore comments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewThis is a clean, well-scoped PR that correctly implements two fixes from PR #49. The previously raised concerns (env-var cleanup bug, missing bare-tilde test) have all been addressed in the current diff. Here's a final pass: Previously raised bugs — confirmed fixed
Remaining minor items1. CHANGELOG may be incomplete for this PR's scope The diff adds only one - **Tilde expansion for LOOPLIA_DEV_ROOT** - `~` and `~/path` in `LOOPLIA_DEV_ROOT` are now expanded to the OS home directory, making dev-mode plugin path configuration portable across environments.
- **Natural language commands** - Replaced `/looplia:build` and `/looplia:run` slash commands with natural-language prompt prefixes to fix SDK compatibility.2.
3. E2E worktree detection fragility (informational)
Everything else looks good
Summary: Item 1 (CHANGELOG completeness) is the only thing worth verifying before merge. Items 2–3 are low-priority follow-ups. The implementation is correct and the previous bugs are all resolved. |
|
Merged via squash. The changes from this PR (addressing Copilot review comments on the tilde expansion and natural language commands work) have landed on main. |
Summary
Applies and fixes PR #49 from @jimmyliao (fork) with two improvements:
LOOPLIA_DEV_ROOTenv var now expands~for dev plugin path resolution/looplia:buildand/looplia:runslash commands with natural language prompts (Create a looplia workflow from the following description:/Execute the workflow:), since the SDK doesn't recognize slash commandsAlso fixes all test assertions that expected the old slash command format:
apps/cli/test/commands/build.test.ts— 14 unit test assertions updatedapps/cli/test/integration/build.test.ts— 3 integration test assertions updated (as identified in PR fix: expand tilde in LOOPLIA_DEV_ROOT and use natural language commands #49 review comments)Test plan
bun test)bun run check-types)🤖 Generated with Claude Code