mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-19 20:10:39 +09:00
[codex] Show bundled plugins in plugin manager (#6734)
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies. > - The plugin system is how Paperclip exposes optional capabilities and integrations without bloating the control plane. > - Operators need the Instance Settings plugin manager to show both installed external plugins and bundled built-in plugins. > - Bundled plugins were available in the server/UI surface but were not represented consistently in the plugin manager list. > - Workspace runtime reuse also needed to stay pinned to the current branch/base so the plugin manager can be validated from the intended checkout. > - This pull request shows bundled plugins in the manager, marks experimental bundled plugins clearly, and tightens runtime/worktree reuse guards. > - The benefit is that operators can discover bundled plugins from the same management screen as installed plugins without stale workspace sessions hiding the latest branch state. ## What Changed - Lists bundled monorepo plugin packages through the plugin routes API, including plugin status and install metadata needed by the UI. - Updates the plugin manager UI/API client to render bundled plugins and display experimental badges based on installed plugin records. - Adds server authorization coverage around plugin routes so board and agent access stay company-scoped. - Guards execution workspace/runtime reuse against stale base refs and defaults new worktrees to the fetched target base. - Expands workspace runtime tests for service reuse, stale workspace prevention, and controlled runtime stops. - Addressed Greptile feedback by respecting `origin/HEAD`, using async cached bundled-plugin discovery, and avoiding duplicated UI experimental plugin lists. ## Verification - `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts server/src/__tests__/workspace-runtime.test.ts server/src/__tests__/heartbeat-workspace-session.test.ts` - `pnpm --filter @paperclipai/ui typecheck` - `pnpm --filter @paperclipai/plugin-sdk build && pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/server typecheck` - `gh pr checks 6734 --repo paperclipai/paperclip` reports all checks passing on `10e1ba9e0f505637cd913713fb28c2c99ae92011`. - Greptile Review reports 5/5 on `10e1ba9e0f505637cd913713fb28c2c99ae92011`. - Confirmed the branch is rebased onto `public-gh/master` and the PR diff does not include `pnpm-lock.yaml` or `.github/workflows` changes. - UI screenshots were not captured in this PR-creation pass because the available local board runtime is authenticated; the visible UI path is covered by the plugin manager code changes and server/API tests above. ## Risks - Medium risk: this touches shared plugin listing behavior and workspace runtime reuse, so regressions could affect plugin manager visibility or service reuse across execution workspaces. - No database migrations. - No lockfile or GitHub workflow changes. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI GPT-5 Codex, coding-agent workflow with shell/tool use in a local Paperclip worktree. Context window not surfaced by the runtime; reasoning mode not externally reported. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
9aea3e3d35
commit
f0ddd24d61
9 changed files with 609 additions and 93 deletions
|
|
@ -170,6 +170,8 @@ describe("mergeExecutionWorkspaceMetadataForPersistence", () => {
|
|||
provisionCommand: "bash ./scripts/provision.sh",
|
||||
},
|
||||
shouldReuseExisting: false,
|
||||
baseRef: null,
|
||||
baseRefSha: null,
|
||||
})).toEqual({
|
||||
source: "task_session",
|
||||
createdByRuntime: true,
|
||||
|
|
@ -200,6 +202,8 @@ describe("mergeExecutionWorkspaceMetadataForPersistence", () => {
|
|||
provisionCommand: "bash ./scripts/new-provision.sh",
|
||||
},
|
||||
shouldReuseExisting: true,
|
||||
baseRef: null,
|
||||
baseRefSha: null,
|
||||
})).toEqual({
|
||||
config: {
|
||||
environmentId: "env-old",
|
||||
|
|
@ -209,6 +213,25 @@ describe("mergeExecutionWorkspaceMetadataForPersistence", () => {
|
|||
createdByRuntime: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("records the resolved base ref SHA for newly realized workspaces", () => {
|
||||
expect(mergeExecutionWorkspaceMetadataForPersistence({
|
||||
existingMetadata: null,
|
||||
source: "task_session",
|
||||
createdByRuntime: true,
|
||||
configSnapshot: null,
|
||||
shouldReuseExisting: false,
|
||||
baseRef: "origin/main",
|
||||
baseRefSha: "abc1234567890",
|
||||
})).toEqual({
|
||||
source: "task_session",
|
||||
createdByRuntime: true,
|
||||
baseRefSnapshot: {
|
||||
baseRef: "origin/main",
|
||||
resolvedSha: "abc1234567890",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildRealizedExecutionWorkspaceFromPersisted", () => {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,27 @@ describe.sequential("plugin install and upgrade authz", () => {
|
|||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("lists bundled monorepo plugin packages", async () => {
|
||||
const { app } = await createApp(boardActor());
|
||||
|
||||
const res = await request(app).get("/api/plugins/examples");
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
const packageNames = res.body.map((plugin: { packageName: string }) => plugin.packageName);
|
||||
const byPackageName = new Map(
|
||||
res.body.map((plugin: { packageName: string; experimental: boolean }) => [plugin.packageName, plugin]),
|
||||
);
|
||||
expect(packageNames).toContain("@paperclipai/plugin-workspace-diff");
|
||||
expect(packageNames).toContain("@paperclipai/plugin-llm-wiki");
|
||||
expect(packageNames).toContain("@paperclipai/plugin-modal");
|
||||
expect(packageNames).toContain("@paperclipai/plugin-authoring-smoke-example");
|
||||
expect(packageNames).not.toContain("@paperclipai/plugin-sdk");
|
||||
expect(byPackageName.get("@paperclipai/plugin-workspace-diff")?.experimental).toBe(true);
|
||||
expect(byPackageName.get("@paperclipai/plugin-llm-wiki")?.experimental).toBe(true);
|
||||
expect(byPackageName.get("@paperclipai/plugin-modal")?.experimental).toBe(true);
|
||||
expect(byPackageName.get("@paperclipai/plugin-authoring-smoke-example")?.experimental).toBe(false);
|
||||
}, 20_000);
|
||||
|
||||
it("rejects plugin installation for non-admin board users", async () => {
|
||||
const { app, loader } = await createApp({
|
||||
type: "board",
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ async function runGit(cwd: string, args: string[]) {
|
|||
await execFileAsync("git", args, { cwd });
|
||||
}
|
||||
|
||||
async function readGit(cwd: string, args: string[]) {
|
||||
return (await execFileAsync("git", args, { cwd })).stdout.trim();
|
||||
}
|
||||
|
||||
async function runPnpm(cwd: string, args: string[]) {
|
||||
await execFileAsync("pnpm", args, { cwd });
|
||||
}
|
||||
|
|
@ -304,6 +308,57 @@ describe("ensureServerWorkspaceLinksCurrent", () => {
|
|||
});
|
||||
|
||||
describe("realizeExecutionWorkspace", () => {
|
||||
it("defaults new git worktrees to freshly fetched origin/master", async () => {
|
||||
const sourceRepo = await createTempRepo("master");
|
||||
const remoteDir = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-worktree-remote-"));
|
||||
const remotePath = path.join(remoteDir, "paperclip.git");
|
||||
await execFileAsync("git", ["clone", "--bare", sourceRepo, remotePath]);
|
||||
|
||||
const cloneRoot = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-worktree-clone-"));
|
||||
const repoRoot = path.join(cloneRoot, "paperclip");
|
||||
await execFileAsync("git", ["clone", remotePath, repoRoot]);
|
||||
await runGit(repoRoot, ["config", "user.email", "paperclip@example.com"]);
|
||||
await runGit(repoRoot, ["config", "user.name", "Paperclip Test"]);
|
||||
|
||||
await fs.writeFile(path.join(sourceRepo, "auth-fix.txt"), "cookie fix\n", "utf8");
|
||||
await runGit(sourceRepo, ["add", "auth-fix.txt"]);
|
||||
await runGit(sourceRepo, ["commit", "-m", "Add auth fix"]);
|
||||
await runGit(sourceRepo, ["push", remotePath, "master"]);
|
||||
const expectedRemoteHead = await readGit(sourceRepo, ["rev-parse", "master"]);
|
||||
expect(await readGit(repoRoot, ["rev-parse", "origin/master"])).not.toBe(expectedRemoteHead);
|
||||
|
||||
const workspace = await realizeExecutionWorkspace({
|
||||
base: {
|
||||
baseCwd: repoRoot,
|
||||
source: "project_primary",
|
||||
projectId: "project-1",
|
||||
workspaceId: "workspace-1",
|
||||
repoUrl: null,
|
||||
repoRef: null,
|
||||
},
|
||||
config: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
branchTemplate: "{{issue.identifier}}-{{slug}}",
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
id: "issue-1",
|
||||
identifier: "PAP-447",
|
||||
title: "Add Worktree Support",
|
||||
},
|
||||
agent: {
|
||||
id: "agent-1",
|
||||
name: "Codex Coder",
|
||||
companyId: "company-1",
|
||||
},
|
||||
});
|
||||
|
||||
expect(workspace.baseRefSha).toBe(expectedRemoteHead);
|
||||
expect(await readGit(repoRoot, ["rev-parse", "origin/master"])).toBe(expectedRemoteHead);
|
||||
expect(await readGit(workspace.cwd, ["rev-parse", "HEAD"])).toBe(expectedRemoteHead);
|
||||
});
|
||||
|
||||
it("creates and reuses a git worktree for an issue-scoped branch", async () => {
|
||||
const repoRoot = await createTempRepo();
|
||||
|
||||
|
|
@ -372,6 +427,75 @@ describe("realizeExecutionWorkspace", () => {
|
|||
expect(second.branchName).toBe(first.branchName);
|
||||
});
|
||||
|
||||
it("warns when reusing a git worktree whose base ref has advanced", async () => {
|
||||
const repoRoot = await createTempRepo();
|
||||
|
||||
const initial = await realizeExecutionWorkspace({
|
||||
base: {
|
||||
baseCwd: repoRoot,
|
||||
source: "project_primary",
|
||||
projectId: "project-1",
|
||||
workspaceId: "workspace-1",
|
||||
repoUrl: null,
|
||||
repoRef: "main",
|
||||
},
|
||||
config: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
branchTemplate: "{{issue.identifier}}-{{slug}}",
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
id: "issue-1",
|
||||
identifier: "PAP-447",
|
||||
title: "Add Worktree Support",
|
||||
},
|
||||
agent: {
|
||||
id: "agent-1",
|
||||
name: "Codex Coder",
|
||||
companyId: "company-1",
|
||||
},
|
||||
});
|
||||
expect(initial.baseRefSha).toMatch(/^[0-9a-f]{40}$/);
|
||||
|
||||
await fs.writeFile(path.join(repoRoot, "server-auth-fix.txt"), "cookie fix\n", "utf8");
|
||||
await runGit(repoRoot, ["add", "server-auth-fix.txt"]);
|
||||
await runGit(repoRoot, ["commit", "-m", "Add auth runtime fix"]);
|
||||
|
||||
const reused = await realizeExecutionWorkspace({
|
||||
base: {
|
||||
baseCwd: repoRoot,
|
||||
source: "project_primary",
|
||||
projectId: "project-1",
|
||||
workspaceId: "workspace-1",
|
||||
repoUrl: null,
|
||||
repoRef: "main",
|
||||
},
|
||||
config: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
branchTemplate: "{{issue.identifier}}-{{slug}}",
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
id: "issue-1",
|
||||
identifier: "PAP-447",
|
||||
title: "Add Worktree Support",
|
||||
},
|
||||
agent: {
|
||||
id: "agent-1",
|
||||
name: "Codex Coder",
|
||||
companyId: "company-1",
|
||||
},
|
||||
});
|
||||
|
||||
expect(reused.created).toBe(false);
|
||||
expect(reused.cwd).toBe(initial.cwd);
|
||||
expect(reused.warnings).toEqual([
|
||||
expect.stringContaining("is behind main by 1 commit"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects reusing an empty directory that only looks like a worktree because it sits inside the repo", async () => {
|
||||
const repoRoot = await createTempRepo();
|
||||
const branchName = "PAP-447-add-worktree-support";
|
||||
|
|
@ -1773,7 +1897,7 @@ describe("realizeExecutionWorkspace", () => {
|
|||
config: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
// No baseRef configured — should auto-detect "master"
|
||||
// No baseRef configured — should default to origin/master.
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
|
|
@ -1791,25 +1915,23 @@ describe("realizeExecutionWorkspace", () => {
|
|||
|
||||
expect(workspace.strategy).toBe("git_worktree");
|
||||
expect(workspace.created).toBe(true);
|
||||
// The worktree should have been created successfully (baseRef resolved to "master")
|
||||
// The worktree should have been created successfully from the canonical remote base.
|
||||
const worktreeOp = operations.find(op => op.phase === "worktree_prepare" && op.metadata?.created);
|
||||
expect(worktreeOp).toBeDefined();
|
||||
expect(worktreeOp!.metadata!.baseRef).toBe("master");
|
||||
expect(worktreeOp!.metadata!.baseRef).toBe("origin/master");
|
||||
}, 10_000);
|
||||
|
||||
it("auto-detects the default branch via symbolic-ref when origin/HEAD is set", async () => {
|
||||
// Create a repo with "master" as default branch
|
||||
const repoRoot = await createTempRepo("master");
|
||||
const repoRoot = await createTempRepo("main");
|
||||
|
||||
// Set up a bare remote and push
|
||||
const bareRemote = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-worktree-bare-symref-"));
|
||||
await runGit(bareRemote, ["init", "--bare"]);
|
||||
await runGit(repoRoot, ["remote", "add", "origin", bareRemote]);
|
||||
await runGit(repoRoot, ["push", "-u", "origin", "master"]);
|
||||
await runGit(repoRoot, ["push", "-u", "origin", "main", "master"]);
|
||||
await runGit(repoRoot, ["fetch", "origin"]);
|
||||
// Explicitly set refs/remotes/origin/HEAD to exercise the symbolic-ref path
|
||||
// (git remote set-head -a requires the remote to advertise HEAD, so we set it manually)
|
||||
await runGit(repoRoot, ["remote", "set-head", "origin", "master"]);
|
||||
await runGit(repoRoot, ["remote", "set-head", "origin", "main"]);
|
||||
|
||||
const { recorder, operations } = createWorkspaceOperationRecorderDouble();
|
||||
|
||||
|
|
@ -1825,7 +1947,7 @@ describe("realizeExecutionWorkspace", () => {
|
|||
config: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
// No baseRef configured — should auto-detect "master" via symbolic-ref
|
||||
// No baseRef configured — origin/HEAD should win over fallback branches.
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
|
|
@ -1845,7 +1967,7 @@ describe("realizeExecutionWorkspace", () => {
|
|||
expect(workspace.created).toBe(true);
|
||||
const worktreeOp = operations.find(op => op.phase === "worktree_prepare" && op.metadata?.created);
|
||||
expect(worktreeOp).toBeDefined();
|
||||
expect(worktreeOp!.metadata!.baseRef).toBe("master");
|
||||
expect(worktreeOp!.metadata!.baseRef).toBe("origin/main");
|
||||
}, 10_000);
|
||||
|
||||
it("removes a created git worktree and branch during cleanup", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue