Refactor linear chat lead workflow into checked-in files

Merged
KH
5mo ago
+491-206

User description

Summary

  • move the linear-chat-lead implementation workflow into a checked-in workflow file
  • replace the base64 inlined PR script with a checked-in CommonJS helper that reads JSON args
  • keep the Linear chat/implement classification flow and pass structured invocation args through ctx.workflow.run

Verification

  • npm test
  • npm run compile

Summary by cubic

Refactored the Linear chat lead to use checked-in workflow and PR helper files, removing inline base64 scripts and runtime file writes for better security and reliability. The user flow is unchanged.

  • Refactors
    • Added workflows/linear-chat-lead.ts that reads process.env.invocationArgs, clones the repo, delegates work, and writes a UUID-based temp helper script and JSON args (with trap cleanup) before running it via @agent-relay/sdk/workflows.
    • Added workflows/linear-create-pr.cjs to open PRs from JSON args; auto-detects baseBranch from origin/HEAD or the base SHA, rejects symlinks and paths outside the repo, and posts to /api/v1/github/pull-request using WORKFORCE_WORKSPACE_TOKEN or CLOUD_API_ACCESS_TOKEN.
    • Removed linear/create-pr.script.ts; simplified linear/agent.ts to pass structured args to ctx.workflow.run('linear-chat-lead', ...).
    • Added workflows/agent-relay-workflows.d.ts and updated tsconfig.json to include workflow files; updated tests to cover structured invocation args, no base64 embedding, safety checks, and base-branch detection.

CodeAnt-AI Description

Move the Linear chat lead workflow and PR helper into checked-in files

What Changed

  • The Linear implementation flow now runs from a checked-in workflow file instead of being written at runtime.
  • The workflow now receives structured input directly, including issue details and PR details, instead of embedding script content in the request.
  • PR creation now uses a checked-in helper that can infer the base branch from the repository, includes deleted files in the PR payload, and rejects unsafe file paths or symlinks.
  • Tests were updated to verify the new workflow inputs and the checked-in helper files.

Impact

✅ Safer PR creation from agent-generated changes
✅ Fewer runtime workflow failures
✅ Correct PRs when the base branch is not main

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.