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
6 changes: 3 additions & 3 deletions .github/workflows/lint_test_compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Deno
uses: denoland/setup-deno@v2
with:
deno-version: "2.x"
deno-version: "2.4.0"

- name: Install dependencies
run: |
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Set up Node.js
uses: denoland/setup-deno@v2
with:
deno-version: "2.x"
deno-version: "2.4.0"

- name: Install dependencies
run: |
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up Node.js
uses: denoland/setup-deno@v2
with:
deno-version: "2.x"
deno-version: "2.4.0"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Deno
uses: denoland/setup-deno@v2
with:
deno-version: "2.3.5"
deno-version: "2.4.0"

- name: Get new version and bump deno.json
id: get_version
Expand Down
8 changes: 7 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"version": "1.0.13",
"version": "1.0.14",
"name": "@napi/cli",
"exports": "./src/index.ts",
"nodeModulesDir": "auto",
"lock": false,
"imports": {
"@inquirer/prompts": "npm:@inquirer/prompts@^7.5.3",
"@langchain/anthropic": "npm:@langchain/anthropic@^0.3.23",
"@langchain/core": "npm:@langchain/core@^0.3.61",
"@langchain/google-genai": "npm:@langchain/google-genai@^0.2.14",
"@langchain/google-vertexai": "npm:@langchain/google-vertexai@^0.2.14",
"@langchain/langgraph": "npm:@langchain/langgraph@^0.3.5",
"@langchain/openai": "npm:@langchain/openai@^0.5.15",
"@oak/oak": "jsr:@oak/oak@^17.1.4",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/path": "jsr:@std/path@^1.0.9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
Expand Down
94 changes: 49 additions & 45 deletions examples/java/websocket/pom.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>websocket</artifactId>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
</parent>
<groupId>napi</groupId>
<name>Spring Boot WebSocket Sample</name>
<description>Spring Boot WebSocket Sample</description>
<version>1.0-SNAPSHOT</version>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<artifactId>websocket</artifactId>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
</parent>
<groupId>napi</groupId>
<name>Spring Boot WebSocket Sample</name>
<description>Spring Boot WebSocket Sample</description>
<version>1.0-SNAPSHOT</version>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
65 changes: 65 additions & 0 deletions src/cli/handlers/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import {
import { ApiService } from "../../../apiService/index.ts";
import type { globalConfigSchema } from "../../middlewares/globalConfig.ts";
import { isAuthenticatedMiddleware } from "../../middlewares/isAuthenticated.ts";
import {
ANTHROPIC_PROVIDER,
GOOGLE_PROVIDER,
OPENAI_PROVIDER,
} from "../../../manifest/dependencyManifest/labeling/model.ts";

function builder(
yargs: Arguments & {
Expand Down Expand Up @@ -1031,6 +1036,61 @@ export async function generateConfig(
// Show final file selection to the user
showFinalFileSelection(workDir, includePatterns, excludePatterns);

// Labeling configuration
console.info("\n🏷️ LABELING CONFIGURATION");
console.info(
"Labeling helps categorize and organize your code dependencies using AI models.",
);

const enableLabeling = await confirm({
message: "Would you like to enable AI-powered labeling?",
default: false,
});

let labelingConfig:
| z.infer<typeof localConfigSchema>["labeling"]
| undefined = undefined;

if (enableLabeling) {
console.info("\n🤖 AI MODEL SELECTION");
console.info(
"Choose an AI provider for labeling your dependencies:",
);

const modelProvider = await select({
message: "Select AI model provider:",
choices: [
{ name: "OpenAI (GPT-4o-mini)", value: OPENAI_PROVIDER },
{ name: "Google (Gemini 2.5 Flash)", value: GOOGLE_PROVIDER },
{ name: "Anthropic (Claude 3.5 Sonnet)", value: ANTHROPIC_PROVIDER },
],
}) as
| typeof OPENAI_PROVIDER
| typeof GOOGLE_PROVIDER
| typeof ANTHROPIC_PROVIDER;

const maxConcurrency = await input({
message: "Enter maximum concurrent requests (leave empty for unlimited):",
validate: (value) => {
if (!value.trim()) return true; // Allow empty for unlimited
const num = parseInt(value);
if (isNaN(num) || num <= 0) {
return "Please enter a positive number or leave empty for unlimited";
}
return true;
},
});

labelingConfig = {
modelProvider,
maxConcurrency: maxConcurrency.trim()
? parseInt(maxConcurrency)
: undefined,
};

console.info("✅ Labeling configuration added");
}

// Build the config object
const config: z.infer<typeof localConfigSchema> = {
language: language,
Expand All @@ -1052,5 +1112,10 @@ export async function generateConfig(
config.c = cConfig;
}

// Add labeling config if it exists
if (labelingConfig) {
config.labeling = labelingConfig;
}

return config;
}
11 changes: 10 additions & 1 deletion src/cli/handlers/manifest/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function builder(
}
return value;
},
}).option("labelingApiKey", {
type: "string",
description: "The API key to use for the labeling",
});
}

Expand Down Expand Up @@ -128,6 +131,7 @@ async function handler(
branch?: string;
commitSha?: string;
commitShaDate?: string;
labelingApiKey?: string;
},
) {
const napiConfig = argv.napiConfig as z.infer<typeof localConfigSchema>;
Expand Down Expand Up @@ -217,7 +221,12 @@ async function handler(

console.info(`📊 Processing ${files.size} files...`);

const dependencyManifest = generateDependencyManifest(files, napiConfig);
const dependencyManifest = await generateDependencyManifest(
files,
napiConfig,
globalConfig,
argv.labelingApiKey,
);

// Upload manifest to API instead of writing to disk
const apiService = new ApiService(
Expand Down
53 changes: 53 additions & 0 deletions src/cli/handlers/set/apiKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { Arguments } from "yargs-types";
import type { z } from "zod";
import {
type globalConfigSchema,
setConfig,
} from "../../middlewares/globalConfig.ts";
import {
ANTHROPIC_PROVIDER,
GOOGLE_PROVIDER,
type ModelProvider,
OPENAI_PROVIDER,
} from "../../../manifest/dependencyManifest/labeling/model.ts";
import { input, select } from "@inquirer/prompts";

async function handler(
argv: Arguments & {
globalConfig: z.infer<typeof globalConfigSchema>;
},
) {
const globalConfig = argv.globalConfig as z.infer<typeof globalConfigSchema>;

const provider = await select({
message: "Select a provider",
choices: [
{ name: "Google", value: GOOGLE_PROVIDER },
{ name: "OpenAI", value: OPENAI_PROVIDER },
{ name: "Anthropic", value: ANTHROPIC_PROVIDER },
],
}) as ModelProvider;

const apiKey = await input({
message: "Enter the API key",
validate: (value) => {
if (value.length === 0) {
return "API key cannot be empty";
}
return true;
},
});

const labeling = globalConfig.labeling || { apiKeys: {} };
labeling.apiKeys[provider] = apiKey;
setConfig({ ...globalConfig, labeling });

console.info("API key set successfully");
}

export default {
command: "apiKey",
describe: "set an API key for a model provider in your global config",
builder: () => {},
handler,
};
21 changes: 21 additions & 0 deletions src/cli/handlers/set/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import apiKeyHandler from "./apiKey.ts";
import type { Arguments } from "yargs-types";
import type { globalConfigSchema } from "../../middlewares/globalConfig.ts";
import type { z } from "zod";

function builder(
yargs: Arguments & {
globalConfig: z.infer<typeof globalConfigSchema>;
},
) {
return yargs
.command(apiKeyHandler)
.demandCommand(1, "You need to specify a valid command");
}

export default {
command: "set",
describe: "set a value in the global config",
builder,
handler: () => {},
};
2 changes: 2 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from "./middlewares/checkVersion.ts";
import loginCommand from "./handlers/login/index.ts";
import initCommand from "./handlers/init/index.ts";
import setCommand from "./handlers/set/index.ts";
import manifestCommand from "./handlers/manifest/index.ts";
import extractCommand from "./handlers/extract/index.ts";
import { globalConfigMiddleware } from "./middlewares/globalConfig.ts";
Expand All @@ -27,6 +28,7 @@ export function initCli() {
.middleware(globalConfigMiddleware)
.command(loginCommand)
.command(initCommand)
.command(setCommand)
.command(manifestCommand)
.command(extractCommand)
.demandCommand(1, "You need to specify a command")
Expand Down
7 changes: 7 additions & 0 deletions src/cli/middlewares/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export const globalConfigSchema = z.object({
jwt: z.string().optional(),
token: z.string().optional(),
apiHost: z.string(),
labeling: z.object({
apiKeys: z.object({
google: z.string().optional(),
openai: z.string().optional(),
anthropic: z.string().optional(),
}),
}).optional(),
});

export const defaultApiHost = "https://api.nanoapi.io";
Expand Down
Loading