-
Notifications
You must be signed in to change notification settings - Fork 2
Scope Linear connections to the active project + fix composer model picker #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,6 +48,7 @@ import { MACOS_VM_PHASES } from "../../desktop/src/shared/types/macosVm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { AdeServiceCommand } from "./serviceManager/common"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { normalizeAdeRuntimeRole, resolveAdeDefaultRole } from "./runtimeRoles"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { AdeRuntime } from "./bootstrap"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { EncryptedFileCredentialStore } from "./services/credentials/credentialStore"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type JsonObject = Record<string, unknown>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -9057,16 +9058,23 @@ function checkGitHubReadiness(projectRoot: string): ReadinessCheck { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function checkLinearReadiness(projectRoot: string): ReadinessCheck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { resolveAdeLayout } = requireAdeLayout(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const layout = resolveAdeLayout(projectRoot); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const encryptedTokenPresent = fs.existsSync( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const legacyEncryptedTokenPresent = fs.existsSync( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path.join(layout.secretsDir, "linear-token.v1.bin"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const projectCredentialStoreTokenPresent = hasProjectCredentialStoreValue( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| layout.secretsDir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "linear.token.v1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
9059
to
+9067
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the machine-scoped path for the legacy Linear token fallback.
Suggested fix function checkLinearReadiness(projectRoot: string): ReadinessCheck {
const { resolveAdeLayout } = requireAdeLayout();
const layout = resolveAdeLayout(projectRoot);
+ const machineLayout = resolveMachineAdeLayout();
const legacyEncryptedTokenPresent = fs.existsSync(
- path.join(layout.secretsDir, "linear-token.v1.bin"),
+ path.join(machineLayout.secretsDir, "linear-token.v1.bin"),
);
const projectCredentialStoreTokenPresent = hasProjectCredentialStoreValue(
layout.secretsDir,
"linear.token.v1",
);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const envTokenPresent = Boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.ADE_LINEAR_API?.trim() || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.LINEAR_API_KEY?.trim() || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.ADE_LINEAR_TOKEN?.trim() || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.LINEAR_TOKEN?.trim(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ready = encryptedTokenPresent || envTokenPresent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ready = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| legacyEncryptedTokenPresent || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| projectCredentialStoreTokenPresent || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| envTokenPresent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: ready ? "ready" : "warning", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -9077,12 +9085,35 @@ function checkLinearReadiness(projectRoot: string): ReadinessCheck { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : "Configure Linear in ADE desktop or set ADE_LINEAR_API/LINEAR_API_KEY for headless mode.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| details: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encryptedTokenPresent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encryptedTokenPresent: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| legacyEncryptedTokenPresent || projectCredentialStoreTokenPresent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| legacyEncryptedTokenPresent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| projectCredentialStoreTokenPresent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenEnvPresent: envTokenPresent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function hasProjectCredentialStoreValue( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| secretsDir: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): boolean { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const credentialsPath = path.join(secretsDir, "credentials.json.enc"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const machineKeyPath = path.join(secretsDir, ".machine-key"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fs.existsSync(credentialsPath) || !fs.existsSync(machineKeyPath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const credentialStore = new EncryptedFileCredentialStore({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| credentialsPath, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| machineKeyPath, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return Boolean(credentialStore.getSync(key)?.trim()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9097
to
+9115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/ade-cli/src/cli.ts
Line: 9097-9115
Comment:
`hasProjectCredentialStoreValue` hardcodes `"credentials.json.enc"` and `".machine-key"` — the same values as `DEFAULT_CREDENTIALS_FILE` / `DEFAULT_MACHINE_KEY_FILE` in `credentialStore.ts`. If those constants are ever renamed, this function will silently return `false` for every project (making `ade doctor` always report no credentials). The `existsSync` pre-check is still needed to avoid triggering `readOrCreateMachineKey` on a fresh project dir, but the store itself could be constructed with just `{ secretsDir }` to stay DRY.
```suggestion
function hasProjectCredentialStoreValue(
secretsDir: string,
key: string,
): boolean {
// Pre-check both files so we don't trigger readOrCreateMachineKey on a
// fresh project directory that has never stored credentials.
const credentialsPath = path.join(secretsDir, "credentials.json.enc");
const machineKeyPath = path.join(secretsDir, ".machine-key");
if (!fs.existsSync(credentialsPath) || !fs.existsSync(machineKeyPath)) {
return false;
}
try {
const credentialStore = new EncryptedFileCredentialStore({ secretsDir });
return Boolean(credentialStore.getSync(key)?.trim());
} catch {
return false;
}
}
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function checkProviderReadiness(value: unknown): ReadinessCheck { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const configResult = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isRecord(value) && isRecord(value.result) ? value.result : value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -13323,6 +13354,7 @@ if (/(^|[/\\])cli\.(?:ts|js|cjs)$/.test(process.argv[1] ?? "")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildCliPlan, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildAdeCodeArgs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkLinearReadiness, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| findProjectRoots, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formatOutput, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| graphWaitState, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.