Skip to content

fix: allow glob outside workspace#283

Merged
kermanx merged 5 commits into
mainfrom
xtr/allow-glob-outside-workspace
Jun 2, 2026
Merged

fix: allow glob outside workspace#283
kermanx merged 5 commits into
mainfrom
xtr/allow-glob-outside-workspace

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented Jun 1, 2026

Related Issue

No linked issue; this addresses model tool calls being rejected when Glob is given an explicit absolute path outside the configured workspace roots.

Problem

Glob used a strict workspace path policy, so paths like /tmp/g10b-test were rejected before the tool could run even though other file tools allow deliberate absolute paths outside the workspace. That made temporary directories and sibling repositories impossible to inspect with glob patterns.

What changed

  • Removed the strict workspace guard mode from the path access policy.
  • Updated Glob to use the same absolute-outside-allowed policy as the other file tools.
  • Kept relative paths that escape the workspace rejected.
  • Updated the glob tool description, tests, and changeset.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification

  • pnpm exec vitest run test/tools/glob.test.ts test/tools/path-guard.test.ts
  • pnpm --filter @moonshot-ai/agent-core typecheck

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 1, 2026

🦋 Changeset detected

Latest commit: 147e33b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@147e33b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@147e33b

commit: 147e33b

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67cdcd0bf9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

workspace: this.workspace,
operation: 'search',
policy: { guardMode: 'strict', checkSensitive: false },
policy: { guardMode: 'absolute-outside-allowed', checkSensitive: false },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return absolute paths for outside glob roots

When this allows an absolute path outside the workspace, the existing result rendering still relativizes matches to the search root, so Glob({ path: '/extra', pattern: '*.py' }) shows test.py rather than /extra/test.py. Follow-up Read/Edit calls resolve relative paths against the workspace cwd, so the model can read or edit a same-named workspace file (or fail) instead of the outside match; outside-root glob results should remain absolute or include the root in the model-visible output.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60efd82fab

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +269 to +271
const shouldRelativize = isWithinWorkspace(relBase, this.workspace, pathClass);
const displayLines = paths.map((p) =>
shouldRelativize ? relativizeIfUnder(p, relBase, pathClass) : p,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep additionalDir glob results absolute

When path is an explicit additionalDirs root such as /extra, this condition treats it as “within workspace” and still returns test.py instead of /extra/test.py; the new test even codifies that case. Because Read/Edit resolve relative paths against workspace.workspaceDir, a follow-up on the model-visible result will target /workspace/test.py rather than /extra/test.py. Fresh evidence beyond the prior outside-root comment is that isWithinWorkspace() includes additionalDirs, so the newly added guard still strips exactly these outside-working-directory roots.

Useful? React with 👍 / 👎.

@kermanx kermanx merged commit 91b292e into main Jun 2, 2026
8 checks passed
@kermanx kermanx deleted the xtr/allow-glob-outside-workspace branch June 2, 2026 04:36
@github-actions github-actions Bot mentioned this pull request Jun 2, 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