Skip to content

feat: sync modern opencode directories and portable extra paths#41

Closed
lnilluv wants to merge 3 commits intoiHildy:mainfrom
lnilluv:feat/opencode-modern-paths
Closed

feat: sync modern opencode directories and portable extra paths#41
lnilluv wants to merge 3 commits intoiHildy:mainfrom
lnilluv:feat/opencode-modern-paths

Conversation

@lnilluv
Copy link

@lnilluv lnilluv commented Feb 27, 2026

Summary

  • include modern OpenCode directories by default (agents, instructions, plugins, skills, superpowers) while retaining legacy directory support
  • store extraConfigPaths/extraSecretPaths source paths in home-relative form (~/...) to avoid Linux/macOS/WSL path churn
  • expand home-relative paths when applying extra manifests so pull/apply stays cross-platform

Validation

  • npm run check
  • npm test

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the OpenCode synchronization process by incorporating modern configuration directories into the default sync scope and improving the portability of extra paths. By transitioning to home-relative path storage for extra manifests and ensuring their proper expansion during application, the system becomes more robust and cross-platform compatible, reducing issues related to varying file system structures across different environments.

Highlights

  • Modern OpenCode Directories: Included modern OpenCode configuration directories (agents, instructions, plugins, skills, superpowers) for synchronization by default, alongside existing legacy directories.
  • Portable Extra Paths: Implemented a mechanism to store and source extra configuration paths in a home-relative (~) format, enhancing cross-platform compatibility and reducing path churn between different operating systems (Linux, macOS, WSL).
  • Home-Relative Path Expansion: Ensured that home-relative paths are correctly expanded when applying extra manifests, maintaining consistent behavior during pull/apply operations.
  • Git Ignore Update: Added a new .worktrees/ entry to the .gitignore file.
Changelog
  • .gitignore
    • Added .worktrees/ to ignored paths.
  • README.md
    • Updated the list of default synced OpenCode directories to include new modern directories.
    • Added a note explaining that extra path manifests now store home-relative paths for portability.
  • src/sync/apply.ts
    • Imported expandHome function.
    • Modified applyExtraPaths to expand home-relative sourcePath values before use.
  • src/sync/paths.test.ts
    • Added a test case to verify that modern OpenCode config directories are included in the sync plan by default.
    • Added a test case to confirm that extra config paths are stored as portable home-relative source paths.
    • Added a test case to ensure stable repository paths for home-relative extras across different platforms.
  • src/sync/paths.ts
    • Updated CONFIG_DIRS array to include new modern OpenCode directories.
    • Introduced a new toPortableSourcePath function to convert absolute paths to home-relative paths where applicable.
    • Modified buildExtraPathPlan to use toPortableSourcePath for sourcePath and its encoded version.
Activity
  • No human activity has been recorded on this pull request since its creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two main features: it adds support for syncing modern OpenCode directories and makes extra paths portable by storing them in a home-relative format. While these changes are well-tested, there is a suggestion for code clarity regarding a redundant function call. More critically, the changes highlight an existing security vulnerability where the manifest file from the sync repository is trusted blindly, allowing the repoPath to be manipulated to point to arbitrary locations on the local file system, which could lead to data exfiltration. It is recommended to add validation to ensure all repository paths are relative and confined within the repository root.

? entry.repoPath
: path.join(plan.repoRoot, entry.repoPath);
const localPath = entry.sourcePath;
const localPath = expandHome(entry.sourcePath, plan.homeDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The applyExtraPaths function trusts the repoPath provided in the manifest file from the repository. An attacker who controls the sync repository can modify the extra-manifest.json to set repoPath to an absolute path or use path traversal (e.g., ../../etc/passwd). During a syncRepoToLocal operation, this would cause the client to copy arbitrary files from the local system into the synced directories. If these directories are subsequently synced back to the repository (via syncLocalToRepo), sensitive local files could be exfiltrated to the attacker-controlled repository.

To remediate this, ensure that repoPath is a relative path and that the resolved path remains within the repository root.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 95a77c0. applyExtraPaths now validates manifest repoPath with resolveManifestRepoPath: absolute paths are rejected and any path that escapes plan.repoRoot is rejected. Added regression tests in src/sync/apply.test.ts for absolute and traversal cases.

Comment on lines 358 to 364
const entries = allowlist.map((sourcePath) => ({
sourcePath,
repoPath: path.join(repoExtraDir, encodeExtraPath(sourcePath)),
sourcePath: toPortableSourcePath(sourcePath, locations.xdg.homeDir, platform),
repoPath: path.join(
repoExtraDir,
encodeExtraPath(toPortableSourcePath(sourcePath, locations.xdg.homeDir, platform))
),
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The function toPortableSourcePath is called twice with the same arguments. This is redundant. It's better to call it once, store the result in a variable, and then reuse it. This will improve both readability and avoid a repeated computation.

  const entries = allowlist.map((sourcePath) => {
    const portableSourcePath = toPortableSourcePath(sourcePath, locations.xdg.homeDir, platform);
    return {
      sourcePath: portableSourcePath,
      repoPath: path.join(
        repoExtraDir,
        encodeExtraPath(portableSourcePath)
      ),
    };
  });

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 95a77c0. buildExtraPathPlan now computes portableSourcePath once per entry and reuses it for both sourcePath and encodeExtraPath(...).

@lnilluv lnilluv closed this Mar 3, 2026
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