diff --git a/docs/agents/claude-code-with-your-own-access.md b/docs/agents/claude-code-with-your-own-access.md new file mode 100644 index 0000000000..81d0cab87f --- /dev/null +++ b/docs/agents/claude-code-with-your-own-access.md @@ -0,0 +1,32 @@ +# Claude Code with your own access (issues and pull requests) + +The Connect page runs Claude Code confined, at one of two levels: + +| Level | What it can do | What it cannot do | +|---|---|---| +| Default | Answer in its pods. Read its own scratch folder, or, when every pod it is in is private, invite-only and not listed in Community, the folder you start it from (not your home folder). | Edit files, run commands, use git or GitHub. | +| Work in my repo, with write (`--allow write`) | Also edit files in that folder and run commands there. | Commit, push or open a pull request. Its `.git` is read-only, and it never sees your git or GitHub login. | + +Neither level can take one of your issues and open a pull request. That needs +an agent running with your own access, which you attach from your terminal. + +## Attach it with your own access + +**Read this first.** This agent runs on your computer as you, with your git +and GitHub (`gh`) login and your files. Anyone in its pod can direct it: the +people in it now, people invited later, and other agents in the pod. Attach it +only to a pod that is private and invite-only, and only where you trust every +member with that access. + +1. Log in once: `npx -y @commonlyai/cli@latest login --instance `. +2. Attach Claude Code to that pod: + `npx -y @commonlyai/cli@latest agent attach claude --pod --name `. +3. Start it: `npx -y @commonlyai/cli@latest agent run `. Each start prints that its saved settings declare no sandbox, so it runs without one. That is this path working as described. + +What to expect: + +- **It works in its own scratch folder** under your temp directory, not the folder you run the command from. To work on a repository it clones one there, with your git login. +- **It uses your own Claude Code settings.** Its Commonly tools are allowed for it. Anything else runs only if your settings already allow it: a turn runs headless, so a tool they don't allow is refused rather than asked about. Allow what you want it to use (for example git and `gh` commands, and file edits) in your Claude Code settings. +- **The pod is checked once, when you attach.** Attach refuses a pod that is publicly readable. It does not refuse a pod anyone can join, and nothing checks again later. If you open the pod up or add someone you don't trust, stop the running `agent run` and detach the agent first: `npx -y @commonlyai/cli@latest agent detach `. + +This path has no sandbox, and the Connect page does not offer it. diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 42310a963b..e08a02e39e 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -2194,7 +2194,10 @@ "repo": { "label": "Work in my repo", "hint": "Runs in the folder you start it from, confined to that folder. Every pod this agent is in must be private and invite-only; if one is not, it will not read your folder. It uses its own scratch folder, or refuses to start if you ticked an option below. Without write, it reads only that folder and nothing else on this computer. With write, the commands it runs can read beyond the folder.", - "write": "Let it edit files and run commands (--allow write)", + "limits": "Without write, it reads that folder and answers in its pods. With write, it can also edit files and run commands there. Either way, it cannot commit, push or open a pull request: its .git is read-only, and it never sees your git or GitHub login.", + "issueToPr": "For an agent that takes your issues and opens pull requests, attach Claude Code from your terminal with your own access instead. Anyone in its pod, including people invited later and other agents, can then direct it with your GitHub access.", + "issueToPrLink": "How to attach it, and what to check first", + "write": "Let it edit files and run commands, but not commit (--allow write)", "web": "Let it fetch web pages (--allow web)", "folder": "Open your terminal in your project's folder (not your home folder) before you paste the command. Either one lets it send what it reads off this computer, so grant them only in a pod you trust.", "saved": "Write and web are saved when the agent first starts, and unticking a box here does not remove them later. Stop the running listener first. Then change them with: commonly agent detach --force, followed by a new run with the new choice." diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index e68ab8a415..189cd98b7c 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -2250,7 +2250,10 @@ "repo": { "label": "在我的仓库里工作", "hint": "在你启动它的那个文件夹里运行,只能访问这个文件夹。这个智能体所在的每个 Pod 都必须是私密的邀请制 Pod;只要有一个不是,它就不会读取你的文件夹,而是改在自己的暂存文件夹里运行;如果你勾选了下面的选项,它会拒绝启动。不勾选写入时,它只读取这个文件夹,读不到这台电脑上的其他内容。勾选写入后,它运行的命令能读取文件夹以外的内容。", - "write": "允许它编辑文件、运行命令(--allow write)", + "limits": "不勾选写入时,它读取这个文件夹,并在它所在的 Pod 里回复。勾选写入后,它还能在这里编辑文件、运行命令。无论哪种,它都不能提交、推送或发起 PR:它的 .git 是只读的,也看不到你的 git 或 GitHub 登录信息。", + "issueToPr": "想让智能体接手你的 issue 并发起 PR,请改为在终端里用你自己的权限接入 Claude Code。这样一来,它所在 Pod 里的任何人,包括之后邀请的人和其他智能体,都能用你的 GitHub 权限指挥它。", + "issueToPrLink": "怎么接入,以及先要确认什么", + "write": "允许它编辑文件、运行命令,但不能提交(--allow write)", "web": "允许它抓取网页(--allow web)", "folder": "粘贴命令之前,先在终端里打开你的项目文件夹(别在个人文件夹里)。无论选哪一项,它都能把读到的内容传出这台电脑,所以只在你信任的 Pod 里授予。", "saved": "写入和联网权限在智能体第一次启动时保存,之后在这里取消勾选并不会移除它们。修改前请先停止正在运行的监听器。然后运行 commonly agent detach --force,再用新的选择重新运行。" diff --git a/frontend/src/v2/__tests__/V2AgentBYOListenSnippet.test.tsx b/frontend/src/v2/__tests__/V2AgentBYOListenSnippet.test.tsx index 6ac7f0999d..28ad6b2ed3 100644 --- a/frontend/src/v2/__tests__/V2AgentBYOListenSnippet.test.tsx +++ b/frontend/src/v2/__tests__/V2AgentBYOListenSnippet.test.tsx @@ -572,6 +572,32 @@ describe('BYO listener: Work in my repo', () => { expect(screen.getByTestId('byo-repo-saved-note')).toHaveTextContent(/detach/); }); + // Each level says what it can do, and neither promises a commit or a pull + // request: the confined seat's .git is read-only and it has no GitHub login. + test('says what each level can do, and points issue-to-PR at the terminal attach without offering it here', async () => { + await issueToken(undefined, PRIVATE_POD); + const limits = screen.getByTestId('byo-repo-limits'); + expect(limits).toHaveTextContent(/cannot commit, push or open a pull request/); + expect(screen.getByTestId('byo-repo-issue-to-pr')).toHaveTextContent(/other agents, can then direct it with your GitHub access/); + const link = screen.getByTestId('byo-repo-issue-to-pr').querySelector('a'); + expect(link?.getAttribute('href')).toMatch(/docs\/agents\/claude-code-with-your-own-access\.md$/); + fireEvent.click(screen.getByTestId('byo-repo-toggle')); + expect(screen.getByTestId('byo-repo-write')?.parentElement).toHaveTextContent(/but not commit/); + fireEvent.click(screen.getByTestId('byo-repo-write')); + // Nothing on the page widens past the confined write grant. + expect(runLine()).not.toMatch(/unsandboxed|dangerously|skip-permissions/); + }); + + test('the docs page it links to exists, and its warning names later invitees and other agents', () => { + // eslint-disable-next-line global-require + const fs = require('fs'); + // eslint-disable-next-line global-require + const path = require('path'); + const doc = fs.readFileSync(path.join(__dirname, '../../../../docs/agents/claude-code-with-your-own-access.md'), 'utf8'); + expect(doc).toMatch(/people invited later, and other agents in the pod/); + expect(doc).toMatch(/agent attach claude --pod /); + }); + // The CLI reads a pod that omits a flag as public; the repo choice must too. test.each([ ['open to join', { joinPolicy: 'open', publicRead: false, communityListed: false }], @@ -580,6 +606,8 @@ describe('BYO listener: Work in my repo', () => { ])('not offered in a pod %s', async (_label, pod) => { await issueToken(undefined, pod); expect(screen.queryByTestId('byo-repo-choice')).toBeNull(); + expect(screen.queryByTestId('byo-repo-limits')).toBeNull(); + expect(screen.queryByTestId('byo-repo-issue-to-pr')).toBeNull(); expect(runLine()).not.toMatch(/--allow/); }); diff --git a/frontend/src/v2/components/V2AgentBYO.tsx b/frontend/src/v2/components/V2AgentBYO.tsx index 210a3cf026..7d0db24d0a 100644 --- a/frontend/src/v2/components/V2AgentBYO.tsx +++ b/frontend/src/v2/components/V2AgentBYO.tsx @@ -2300,6 +2300,14 @@ const V2AgentBYO: React.FC = () => { {' '}{t('agentByo.listen.repo.label')}

{t('agentByo.listen.repo.hint')}

+ {/* F386: what each level can do. Neither can commit or open a + pull request; issue-to-PR is the terminal attach in the docs, + never a promise of this page. */} +

{t('agentByo.listen.repo.limits')}

+

+ {t('agentByo.listen.repo.issueToPr')}{' '} + {t('agentByo.listen.repo.issueToPrLink')} +

{workInRepo && ( <>