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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 0 additions & 23 deletions .eslintrc.json

This file was deleted.

14 changes: 9 additions & 5 deletions apps/airiscode-cli/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import * as fs from "node:fs/promises";
import * as path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest";

vi.mock("node:os", () => ({
homedir: () => "/mock/home"
homedir: () => "/mock/home",
}));

import { loadConfig, saveConfig } from "../src/utils/config.js";
import { saveSession, listSessions, loadSession } from "../src/utils/session.js";
import { listSessions, loadSession, saveSession } from "../src/utils/session.js";

vi.mock("node:fs/promises");

Expand All @@ -26,7 +26,7 @@ describe("CLI Utilities", () => {
it("should save and merge config", async () => {
vi.mocked(fs.readFile).mockResolvedValue(JSON.stringify({ plannerModel: "new-model" }));
const updated = await saveConfig({ coderModel: "coder-9b" });

expect(updated.plannerModel).toBe("new-model");
expect(updated.coderModel).toBe("coder-9b");
expect(fs.writeFile).toHaveBeenCalled();
Expand All @@ -35,7 +35,11 @@ describe("CLI Utilities", () => {

describe("Session Utility", () => {
it("should list sessions", async () => {
vi.mocked(fs.readdir).mockResolvedValue(["session-1.json", "session-2.json", "other.txt"] as any);
vi.mocked(fs.readdir).mockResolvedValue([
"session-1.json",
"session-2.json",
"other.txt",
] as any);
const sessions = await listSessions();
expect(sessions).toHaveLength(2);
expect(sessions[0]).toBe("session-2.json"); // Sorted reverse
Expand Down
2 changes: 1 addition & 1 deletion apps/airiscode-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dev": "tsup --watch",
"typecheck": "tsc --noEmit",
"start": "node dist/index.js",
"lint": "eslint . --ext .ts,.tsx",
"lint": "biome check .",
"format": "prettier --write .",
"test": "vitest run"
},
Expand Down
48 changes: 21 additions & 27 deletions apps/airiscode-cli/src/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,52 @@
* SPDX-License-Identifier: Apache-2.0
*/

import type { CommandModule, Argv } from 'yargs';
import {
handleQwenAuth,
runInteractiveAuth,
showAuthStatus,
} from './auth/handler.js';
import { t } from '../i18n/index.js';
import type { Argv, CommandModule } from "yargs";
import { t } from "../i18n/index.js";
import { handleQwenAuth, runInteractiveAuth, showAuthStatus } from "./auth/handler.js";

// Qwen OAuth subcommand removed - use coding-plan or interactive auth instead.

const codePlanCommand = {
command: 'coding-plan',
describe: t('Authenticate using Alibaba Cloud Coding Plan'),
command: "coding-plan",
describe: t("Authenticate using Alibaba Cloud Coding Plan"),
builder: (yargs: Argv) =>
yargs
.option('region', {
alias: 'r',
describe: t('Region for Coding Plan (china/global)'),
type: 'string',
.option("region", {
alias: "r",
describe: t("Region for Coding Plan (china/global)"),
type: "string",
})
.option('key', {
alias: 'k',
describe: t('API key for Coding Plan'),
type: 'string',
.option("key", {
alias: "k",
describe: t("API key for Coding Plan"),
type: "string",
}),
handler: async (argv: { region?: string; key?: string }) => {
const region = argv['region'] as string | undefined;
const key = argv['key'] as string | undefined;
const region = argv["region"] as string | undefined;
const key = argv["key"] as string | undefined;

// If region and key are provided, use them directly
if (region && key) {
await handleQwenAuth('coding-plan', { region, key });
await handleQwenAuth("coding-plan", { region, key });
} else {
// Otherwise, prompt interactively
await handleQwenAuth('coding-plan', {});
await handleQwenAuth("coding-plan", {});
}
},
};

const statusCommand = {
command: 'status',
describe: t('Show current authentication status'),
command: "status",
describe: t("Show current authentication status"),
handler: async () => {
await showAuthStatus();
},
};

export const authCommand: CommandModule = {
command: 'auth',
describe: t(
'Configure authentication information with Alibaba Cloud Coding Plan',
),
command: "auth",
describe: t("Configure authentication information with Alibaba Cloud Coding Plan"),
builder: (yargs: Argv) =>
yargs
.command(codePlanCommand)
Expand Down
Loading
Loading