Skip to content

feat(kiloclaw): add Linear CLI integration#1407

Open
evanjacobson wants to merge 22 commits intomainfrom
feature/kiloclaw-linear-cli
Open

feat(kiloclaw): add Linear CLI integration#1407
evanjacobson wants to merge 22 commits intomainfrom
feature/kiloclaw-linear-cli

Conversation

@evanjacobson
Copy link
Contributor

@evanjacobson evanjacobson commented Mar 23, 2026

Summary

Adds Linear CLI (@schpet/linear-cli) as a tool available in KiloClaw instances, letting agents manage Linear issues directly from the terminal.

  • Dockerfile: Installs @schpet/linear-cli@1.11.1 in both production and local images; defers xz-utils cleanup until after the install
    • This package uses the ISC license. The license is bundled with the package itself, satisfying its requirement.
  • Secret catalog: Adds LINEAR_API_KEY field with lin_api_ validation pattern, icon, and help link to Linear security settings
  • Bootstrap: New configureLinear step that wires up the env var; updateToolsMdLinearSection appends/removes a bounded reference section in TOOLS.md so the agent knows how to use the CLI (flags, gotchas, config file)
  • Credential cleanup: When LINEAR_API_KEY is removed, configureLinear deletes ~/.config/linear/ and ~/.linear.toml from the persistent /root volume to prevent stale credentials from surviving across redeploys. Each removal is independently try/caught so both are always attempted.
  • Dashboard UI: Adds Linear to the "Developer Tools" section in SettingsTab, new LinearIcon SVG component, and secret-ui-adapter wiring (icon map + description)
  • Tests: Full coverage for configureLinear, updateToolsMdLinearSection, and updated catalog/route assertions

Verification

  • pnpm vitest — bootstrap, secret-catalog, and route tests pass
  • Dockerfile builds with linear binary available
  • E2E test documented in the Loom linked below

Visual Changes

image image

Reviewer Notes

  • The TOOLS.md section uses <!-- BEGIN:linear --> / <!-- END:linear --> markers, same pattern as the other tool sections
  • xz-utils purge was moved to a later Dockerfile stage because the Linear CLI npm install needs it

Follow-up

validationPattern: '^lin_api_[a-zA-Z0-9_-]{40}$',
validationMessage:
'Linear API keys start with lin_api_ followed by 40 alphanumeric, underscore, or hyphen characters.',
maxLength: 100,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this can be shortened to 50 safely (or 48 exactly), however the other entries in this catalog also pad their keys substantially, and it arguably provides a better UX when matched with the regex (for example, if whitespace was copied in addition to the key)

RUN npm install -g @schpet/linear-cli@1.11.1

# Clean up xz-utils now that Node.js and linear-cli are installed
RUN apt-get purge -y xz-utils \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

linear-cli requires node for install

@evanjacobson evanjacobson changed the title Feature/kiloclaw linear cli feat(kiloclaw): add Linear CLI integration Mar 26, 2026
RUN npm install -g @kilocode/cli@7.0.46

# Install Linear CLI (issue tracker)
RUN npm install -g @schpet/linear-cli@1.11.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are security vulnerabilities on a dependency of this package. I have posted a PR to fix them.

I will bump the version to the latest release after it merges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are security vulnerabilities on a dependency of this package. I have posted a PR to fix them.

I will bump the version to the latest release after it merges.

I am still discussing the changes with the repo owner. This may need to be a follow-up. The vulnerabilities are not exposed in linear-cli regardless.

@evanjacobson evanjacobson marked this pull request as ready for review March 26, 2026 06:46
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 26, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
kiloclaw/Dockerfile.local 60 Local image still installs the known vulnerable @schpet/linear-cli@1.11.1 release
Other Observations (not in diff)

N/A

Files Reviewed (11 files)
  • kiloclaw/Dockerfile - 0 new issues
  • kiloclaw/Dockerfile.local - 1 issue
  • kiloclaw/controller/src/bootstrap.test.ts - 0 new issues
  • kiloclaw/controller/src/bootstrap.ts - 0 new issues
  • kiloclaw/packages/secret-catalog/src/__tests__/catalog.test.ts - 0 new issues
  • kiloclaw/packages/secret-catalog/src/catalog.ts - 0 new issues
  • kiloclaw/packages/secret-catalog/src/types.ts - 0 new issues
  • kiloclaw/src/routes/kiloclaw.test.ts - 0 new issues
  • src/app/(app)/claw/components/SettingsTab.tsx - 0 new issues
  • src/app/(app)/claw/components/icons/LinearIcon.tsx - 0 new issues
  • src/app/(app)/claw/components/secret-ui-adapter.ts - 0 new issues

Reviewed by gpt-5.4-20260305 · 2,340,145 tokens

The /root volume persists across redeploys, so `linear auth login --plaintext`
leaves credentials on disk that survive after LINEAR_API_KEY is removed from
env. Now configureLinear() removes ~/.config/linear/ (credentials.toml +
linear.toml) when no API key is set, matching the cleanup pattern used by
configureGitHub().
These files store API secrets, so credential cleanup failures should
not be silently swallowed. Split the two rm calls into independent
try/catch blocks so both are always attempted, and surface the error
message in warnings since rm -rf/-f already exit 0 for absent targets.
Cover the second rm failure, both rm calls failing simultaneously,
and non-Error thrown values exercising the instanceof fallback.
// Remove any previously stored credentials from the persistent volume.
// The CLI recreates ~/.config/linear/ via ensureDir on next auth login.
try {
deps.execFileSync('rm', ['-rf', '/root/.config/linear'], { stdio: 'pipe' });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

// The CLI recreates ~/.config/linear/ via ensureDir on next auth login.
try {
deps.execFileSync('rm', ['-rf', '/root/.config/linear'], { stdio: 'pipe' });
deps.execFileSync('rm', ['-f', '/root/.linear.toml'], { stdio: 'pipe' });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

// The CLI recreates ~/.config/linear/ via ensureDir on next auth login.
// rm -rf/-f exit 0 when the target is absent, so errors here are
// genuine failures (permissions, I/O) worth surfacing.
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

separately trying each file delete operation out of an abundance of caution — if one fails, the other one is still tried.

deps.execFileSync('rm', ['-rf', '/root/.config/linear'], { stdio: 'pipe' });
} catch (err) {
console.warn(
`WARNING: failed to remove /root/.config/linear: ${err instanceof Error ? err.message : err}`
Copy link
Contributor Author

@evanjacobson evanjacobson Mar 26, 2026

Choose a reason for hiding this comment

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

Other warnings logged after a catch in this file do not contain the error, but these are intentionally included, as these files contain credentials and need to be deleted

Cc: line 364

@evanjacobson evanjacobson self-assigned this Mar 26, 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.

2 participants