Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/devin/scripts/lib/devin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function getDevinAuthStatus(cwd) {
return { authenticated: false, detail };
}
const output = result.stdout;
const loggedIn = /logged in/i.test(output);
const loggedIn = /^\s*logged in/im.test(output) && !/\bnot logged in\b/i.test(output);
const email = output.match(/Email:\s*(\S+)/)?.[1] ?? null;
const tier = output.match(/Tier:\s*(.+)/)?.[1]?.trim() ?? null;
return {
Expand Down
17 changes: 17 additions & 0 deletions tests/companion.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ test("setup reports ready=false when devin auth fails", () => {
}
});

test("setup reports authenticated=false when devin auth status exits 0 while logged out", () => {
const repo = createTempRepo();
const fake = createFakeDevin({ loggedOutExitZero: true });
const dataDir = fs.mkdtempSync("/tmp/devin-plugin-data-");
try {
const env = { ...fake.env, CLAUDE_PLUGIN_DATA: dataDir };
const result = runCompanion(["setup", "--json"], { cwd: repo.dir, env });
const payload = JSON.parse(result.stdout);
assert.equal(payload.devin.installed, true);
assert.equal(payload.devin.authenticated, false);
assert.equal(payload.ready, false);
} finally {
repo.cleanup();
fake.cleanup();
}
});

test("setup --enable-review-gate persists config", () => {
const repo = createTempRepo();
const fake = createFakeDevin();
Expand Down
8 changes: 7 additions & 1 deletion tests/fake-devin-fixture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "node:path";

// Creates a fake `devin` executable that answers the subcommands the companion
// uses. The marker file records each -p invocation's prompt file for assertions.
export function createFakeDevin({ responseText = "FAKE_DEVIN_OUTPUT", exitCode = 0, failAuth = false, stderrText = "" } = {}) {
export function createFakeDevin({ responseText = "FAKE_DEVIN_OUTPUT", exitCode = 0, failAuth = false, loggedOutExitZero = false, stderrText = "" } = {}) {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fake-devin-"));
const marker = path.join(dir, "invocations.jsonl");
const stderrFile = path.join(dir, "stderr.txt");
Expand All @@ -23,6 +23,12 @@ case "$cmd" in
echo "Not logged in" >&2
exit 1
fi
if [ "${loggedOutExitZero}" = "true" ]; then
echo "Not logged in."
echo " Credentials path: /Users/fake/.local/share/devin/credentials.toml"
echo "Run \\\`devin auth login\\\` to authenticate."
exit 0
fi
echo "Logged in (via Devin)."
echo " Email: fake@example.com"
echo " Tier: Devin Pro"
Expand Down
Loading