co-maintainer 0.6.0 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/ai/oauth/ids.d.ts +10 -0
  3. package/dist/src/ai/oauth/ids.js +10 -0
  4. package/dist/src/ai/oauth/registry.d.ts +33 -0
  5. package/dist/src/ai/oauth/registry.js +40 -0
  6. package/dist/src/ai/oauth/sign-in-with-chatgpt.d.ts +56 -0
  7. package/dist/src/ai/oauth/sign-in-with-chatgpt.js +552 -0
  8. package/dist/src/ai/openai.d.ts +18 -1
  9. package/dist/src/ai/openai.js +68 -5
  10. package/dist/src/ai/provider.d.ts +3 -0
  11. package/dist/src/ai/provider.js +11 -2
  12. package/dist/src/cli/args.js +40 -18
  13. package/dist/src/cli/commands/config.d.ts +1 -1
  14. package/dist/src/cli/commands/config.js +2 -0
  15. package/dist/src/cli/commands/oauth.d.ts +1 -0
  16. package/dist/src/cli/commands/oauth.js +73 -0
  17. package/dist/src/cli/commands/registry.js +46 -0
  18. package/dist/src/cli/commands/review.js +2 -1
  19. package/dist/src/cli/commands/set.js +14 -1
  20. package/dist/src/cli/main.js +5 -0
  21. package/dist/src/cli/review_args.js +6 -0
  22. package/dist/src/config.d.ts +4 -0
  23. package/dist/src/github/collect.d.ts +2 -2
  24. package/dist/src/github/collect.js +60 -23
  25. package/dist/src/knowledge/types.d.ts +3 -4
  26. package/dist/src/pr/codegraph_tools.d.ts +13 -3
  27. package/dist/src/pr/codegraph_tools.js +26 -7
  28. package/dist/src/pr/reviewer.d.ts +4 -0
  29. package/dist/src/pr/reviewer.js +16 -4
  30. package/dist/src/server/pages/settings.js +2 -2
  31. package/dist/src/services/clear.js +2 -0
  32. package/dist/src/services/setup.js +3 -12
  33. package/dist/src/store/cache_db.js +1 -1
  34. package/dist/src/tools/codegraph.d.ts +15 -0
  35. package/dist/src/tools/codegraph.js +59 -24
  36. package/dist/src/types.d.ts +9 -1
  37. package/package.json +1 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.6.0",
3
+ "version": "0.6.3",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",
@@ -0,0 +1,10 @@
1
+ /** The OAuth provider ids and labels, in a leaf module.
2
+ *
3
+ * `registry.ts` and `sign-in-with-chatgpt.ts` both need these strings, and
4
+ * `sign-in-with-chatgpt.ts` reaches `openai.ts` which reaches `provider.ts`
5
+ * which reaches `registry.ts`. Keeping the constants here, with no imports,
6
+ * lets both sides read them without a cycle that leaves them undefined. */
7
+ export declare const SIWC_PROVIDER = "sign-in-with-chatgpt";
8
+ export declare const SIWC_LABEL = "Sign in with ChatGPT";
9
+ /** The alias users may type instead of the full provider id. */
10
+ export declare const SIWC_ALIAS = "siwc";
@@ -0,0 +1,10 @@
1
+ /** The OAuth provider ids and labels, in a leaf module.
2
+ *
3
+ * `registry.ts` and `sign-in-with-chatgpt.ts` both need these strings, and
4
+ * `sign-in-with-chatgpt.ts` reaches `openai.ts` which reaches `provider.ts`
5
+ * which reaches `registry.ts`. Keeping the constants here, with no imports,
6
+ * lets both sides read them without a cycle that leaves them undefined. */
7
+ export const SIWC_PROVIDER = "sign-in-with-chatgpt";
8
+ export const SIWC_LABEL = "Sign in with ChatGPT";
9
+ /** The alias users may type instead of the full provider id. */
10
+ export const SIWC_ALIAS = "siwc";
@@ -0,0 +1,33 @@
1
+ /** The OAuth providers `co-maintainer oauth` knows.
2
+ *
3
+ * One entry today, Sign in with ChatGPT. A future provider (say Claude under
4
+ * a subscription) is a new id plus a new ops object here, with no change to
5
+ * the command or to the experimental flag's plumbing. */
6
+ import type { AiProvider } from "../../types.ts";
7
+ import { CliError } from "../../cli/error.ts";
8
+ import { type Credentials, type ModelInfo } from "./sign-in-with-chatgpt.ts";
9
+ export declare const OAUTH_PROVIDER_IDS: readonly ["sign-in-with-chatgpt"];
10
+ export type OAuthProviderId = (typeof OAUTH_PROVIDER_IDS)[number];
11
+ /** The provider `--experimental-siwc` selects. Kept here so the flag's
12
+ * plumbing never names a provider string directly. */
13
+ export declare const EXPERIMENTAL_OAUTH_PROVIDER: OAuthProviderId;
14
+ /** The plain alias for a given id, if it has one. */
15
+ export declare function oauthAlias(id: OAuthProviderId): string;
16
+ /** `--provider` value to a known id, or undefined. Accepts the short alias. */
17
+ export declare function resolveOAuthProvider(value: string | undefined): OAuthProviderId | undefined;
18
+ export declare function oauthUnknownProvider(value: string | undefined): CliError;
19
+ export type OAuthOps = {
20
+ label: string;
21
+ credentialsPath(): string;
22
+ /** The browser flow; always starts a new sign-in. */
23
+ login(): Promise<Credentials>;
24
+ logout(): Promise<boolean>;
25
+ refresh(): Promise<Credentials>;
26
+ ping(): Promise<{
27
+ credentials: Credentials;
28
+ models: ModelInfo[];
29
+ }>;
30
+ listModels(): Promise<ModelInfo[]>;
31
+ createProvider(model: string): AiProvider;
32
+ };
33
+ export declare function oauthOps(id: OAuthProviderId): OAuthOps;
@@ -0,0 +1,40 @@
1
+ import { CliError, EXIT_USAGE } from "../../cli/error.js";
2
+ import { SIWC_ALIAS, SIWC_LABEL, SIWC_PROVIDER } from "./ids.js";
3
+ import { SignInWithChatGptProvider, credentialsPath, listModels, login, logout, refresh, requireCredentials, } from "./sign-in-with-chatgpt.js";
4
+ export const OAUTH_PROVIDER_IDS = [SIWC_PROVIDER];
5
+ /** The provider `--experimental-siwc` selects. Kept here so the flag's
6
+ * plumbing never names a provider string directly. */
7
+ export const EXPERIMENTAL_OAUTH_PROVIDER = SIWC_PROVIDER;
8
+ /** The plain alias for a given id, if it has one. */
9
+ export function oauthAlias(id) {
10
+ return id === SIWC_PROVIDER ? SIWC_ALIAS : id;
11
+ }
12
+ /** `--provider` value to a known id, or undefined. Accepts the short alias. */
13
+ export function resolveOAuthProvider(value) {
14
+ if (!value)
15
+ return undefined;
16
+ if (value === SIWC_PROVIDER || value === SIWC_ALIAS)
17
+ return SIWC_PROVIDER;
18
+ return undefined;
19
+ }
20
+ export function oauthUnknownProvider(value) {
21
+ return new CliError("oauth_unknown_provider", `Unknown OAuth provider ${value ? `"${value}"` : ""}.`, `Pass --provider=${SIWC_PROVIDER} (or ${SIWC_ALIAS}).`, EXIT_USAGE);
22
+ }
23
+ const SIWC_OPS = {
24
+ label: SIWC_LABEL,
25
+ credentialsPath,
26
+ login,
27
+ logout,
28
+ refresh: async () => refresh(await requireCredentials()),
29
+ ping: async () => {
30
+ const credentials = await requireCredentials();
31
+ return { credentials, models: await listModels(credentials) };
32
+ },
33
+ listModels: async () => listModels(await requireCredentials()),
34
+ createProvider: (model) => new SignInWithChatGptProvider(model),
35
+ };
36
+ export function oauthOps(id) {
37
+ if (id === SIWC_PROVIDER)
38
+ return SIWC_OPS;
39
+ throw oauthUnknownProvider(id);
40
+ }
@@ -0,0 +1,56 @@
1
+ import type { AiProvider, AiRequest, AiResponse } from "../../types.ts";
2
+ import { SIWC_ALIAS, SIWC_LABEL, SIWC_PROVIDER } from "./ids.ts";
3
+ export { SIWC_ALIAS, SIWC_LABEL, SIWC_PROVIDER };
4
+ export declare function credentialsDir(): string;
5
+ export declare function credentialsPath(): string;
6
+ export type Credentials = {
7
+ email?: string;
8
+ issuer: string;
9
+ subject: string;
10
+ client_id: string;
11
+ ext_agent_host_id: string;
12
+ id_token: string;
13
+ access_token: string;
14
+ refresh_token: string;
15
+ token_type: string;
16
+ expires_in: number;
17
+ expires_at: number;
18
+ scopes: string[];
19
+ saved_at: string;
20
+ };
21
+ /** OpenRouter-style ids carry a provider prefix (`openai/gpt-6-luna`) the
22
+ * plan route does not know. Stripping it lets the same value work on both. */
23
+ export declare function normalizeModel(model: string): string;
24
+ export declare function loadCredentials(): Credentials | undefined;
25
+ export declare function logout(): Promise<boolean>;
26
+ type BrowserOpener = (url: string) => void;
27
+ /** Tests replace the browser with a helper that completes the callback; the
28
+ * real opener shells out to the platform's open command. */
29
+ export declare function setBrowserOpener(opener: BrowserOpener | undefined): void;
30
+ /** The browser flow. Always runs, so a user can switch accounts; `logout`
31
+ * first if the old one should not be reused. */
32
+ export declare function login(): Promise<Credentials>;
33
+ export declare function refresh(creds: Credentials): Promise<Credentials>;
34
+ /** Credentials for a run: reuse the freshest token this process has seen,
35
+ * refresh an expired one, or start the browser flow. `inflight` dedups so
36
+ * `init`'s low and high providers never open two browsers; `cached` keeps a
37
+ * 401 refresh done inside `complete()` visible to later callers. */
38
+ export declare function ensureCredentials(): Promise<Credentials>;
39
+ export type ModelInfo = {
40
+ slug: string;
41
+ displayName: string;
42
+ };
43
+ /** For `oauth refresh|ping|list-models`, which operate on an existing login
44
+ * and must not start a browser flow. A live token is reused, an expired one
45
+ * refreshed; no login at all is a clear error. */
46
+ export declare function requireCredentials(): Promise<Credentials>;
47
+ export declare function listModels(creds: Credentials): Promise<ModelInfo[]>;
48
+ /** The model slugs a user can pick, for prompts and error messages. */
49
+ export declare function availableModelSlugs(): Promise<string[]>;
50
+ export declare class SignInWithChatGptProvider implements AiProvider {
51
+ readonly supportsTools = true;
52
+ private readonly model;
53
+ constructor(model: string);
54
+ private post;
55
+ complete(request: AiRequest): Promise<AiResponse>;
56
+ }