repo_id stringclasses 46
values | file_path stringlengths 36 118 | content stringlengths 7 1.68M | __index_level_0__ int64 0 0 |
|---|---|---|---|
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/contributes/context.ts | import * as vscode from 'vscode';
export function regLanguageContext() {
const currentLocale = vscode.env.language;
if (currentLocale === 'zh-cn' || currentLocale === 'zh-tw') {
vscode.commands.executeCommand('setContext', 'isChineseLocale', true);
} else {
vscode.commands.executeCommand('setContext', 'isChines... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/contributes/commandsBase.ts | // src/contributes/commandsBase.ts
import { UiUtilWrapper } from "../util/uiUtil";
import { runCommand } from "../util/commonUtil";
import { logger } from "../util/logger";
import { DevChatConfig } from "../util/config";
let devchatStatus = '';
function locateCommand(command): string | undefined {
try {
// spli... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/contributes/util.ts | import * as vscode from 'vscode';
import { handleCodeSelected } from '../context/contextCodeSelected';
import { handleFileSelected } from '../context/contextFileSelected';
import { MessageHandler } from '../handler/messageHandler';
import { regOutMessage } from '../util/reg_messages';
import { logger } from '../util/l... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/gitDiffWatcher.ts | /*
写一个类,在这个类中监控项目文件是否发生变化,每次变化后,重新执行git diff命令,获取变化的文件列表,并将变化的文件列表返回给调用者。
*/
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
import { exec } from 'child_process';
import { UiUtilWrapper } from '../../util/uiUtil';
import { logger } from '../../util/logger';
import { collap... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/modelConfig.ts |
export interface ModelConfigTemplate {
template: string;
stop: string[];
}
const stableCodeTemplate: ModelConfigTemplate = {
template: "<fim_prefix>{{{prefix}}}<fim_suffix>{{{suffix}}}<fim_middle>",
stop: ["<fim_prefix>", "<fim_suffix>", "<fim_middle>", "<|endoftext|>"],
};
const MODLE_COMPLETE_CONF... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/astTest.ts | import * as path from 'path';
import * as fs from 'fs';
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast/ast";
import Parser from "web-tree-sitter";
import { logger } from "../../util/logger";
import { getCommentPrefix, getLangageFunctionConfig, getLanguageFullName, LanguageFunctionsConfig } ... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/codecomplete.ts | import * as vscode from 'vscode';
import { logger } from '../../util/logger';
import Debouncer from './debouncer';
import MemoryCacheManager from './cache';
import { createPrompt, findSimilarCodeBlock } from './promptCreator';
import { CodeCompleteResult, LLMStreamComplete } from './chunkFilter';
import { DevChatConfi... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ranking.ts | import { RangeInFileWithContents } from "./ast/ast";
import { countTokens } from "./llm/countTokens";
import { Range } from "./utils";
export type AutocompleteSnippet = RangeInFileWithContents & {
score: number;
};
const rx = /[\s.,\/#!$%\^&\*;:{}=\-_`~()\[\]]/g;
function getSymbolsForSnippet(snippet: string): Se... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/utils.ts | import * as vscode from 'vscode';
export interface Range {
start: Position;
end: Position;
}
export interface Position {
line: number;
character: number;
}
export interface RangeInFile {
filepath: string;
range: Range;
}
export async function readRangeInFile(
filepath: string,
range:... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/symbols.ts | /*
获取符号名称、符号类型(函数、变量、类等)、符号所在文件路径、符号所在行数等信息
猜想这些信息会有助于代码补全功能的准确率提升
*/
| 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/lsp.ts | // import { IDE, RangeInFile } from "core";
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast/ast";
import { AutocompleteSnippet } from "./ranking";
import * as vscode from "vscode";
import Parser from "web-tree-sitter";
import { RangeInFile, readRangeInFile } from "./utils";
type GotoProvide... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/README.md |
status.ts: 代码补全状态表达接口。预期有三种状态:未就绪、就绪、代码补全中。
| 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/promptCreator.ts | /*
针对代码补全功能,构建prompt
prompt的好坏,取决于提供的上下文信息。
通过AST获取相对完整的信息,可能会增加提示的准确度,但也会增加代码提示的复杂度。
*/
import * as fs from 'fs/promises';
import * as fsF from 'fs';
import * as path from 'path';
import { logger } from "../../util/logger";
import { getAst, getAstNodeByRange, getTreePathAtCursor, RangeInFileWithContents } from "... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/llm.ts |
/*
通过LLM模型生成代码补全
*/
import axios from 'axios';
import { logger } from "../../util/logger";
import { Chunk } from 'webpack';
import { DevChatConfig } from '../../util/config';
// 定义代码补全chunk结构内容
export interface CodeCompletionChunk {
text: string;
id: string;
}
export async function* streamComplete(prompt:... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/cache.ts | /*
使用内存存储最近的代码补全结果
*/
type CacheItem = {
value: any;
timestamp: number;
};
class MemoryCacheManager {
private maxCapacity: number = 5;
private cache: Map<string, CacheItem>;
constructor(maxCapacity: number = 5) {
this.maxCapacity = maxCapacity;
this.cache = new Map<string, CacheI... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/recentEdits.ts | /*
记录最近修改的内容,用于代码补全
*/
import { logger } from '../../util/logger';
import * as vscode from 'vscode';
import { collapseFile } from './ast/collapseBlock';
import { getCommentPrefix } from './ast/language';
export class RecentEdit {
fileName: string;
content: string;
collapseContent: string;
constructo... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/debouncer.ts | export class Debouncer {
private debouncing = false;
private debounceTimeout?: NodeJS.Timeout;
private lastTimeStampt?: string;
constructor(private debounceDelay: number) { }
async debounce(): Promise<boolean> {
const timestampt = Date.now().toString();
this.lastTimeStampt = timest... | 0 |
devchat_public_repos/devchat-vscode/src/contributes | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/chunkFilter.ts | /*
对实时返回的chunk进行过滤,判断当前是否已经满足停止条件,避免无效代码占用补全时间
*/
import * as vscode from 'vscode';
import { logger } from '../../util/logger';
import { CodeCompletionChunk, streamComplete } from './llm';
import { getCommentPrefix } from './ast/language';
// 代码补全返回结果定义
export interface CodeCompleteResult {
prompt: string;
... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/symbolindex/embedding.ts | import * as path from 'path';
import * as fs from 'fs';
import fspromises from 'fs/promises';
import { getAst } from '../ast/ast';
import Parser from 'web-tree-sitter';
import { UiUtilWrapper } from '../../../util/uiUtil';
import { findFunctionRanges } from '../ast/findFunctions';
import { findIdentifiers } from '../as... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/symbolindex/index.ts | import * as path from 'path';
import * as fsE from 'fs';
import fs from 'fs/promises';
import { logger } from '../../../util/logger';
import { embeddingQuery, embeddingBlocks, getFileBlock } from './embedding';
import { UiUtilWrapper } from '../../../util/uiUtil';
import { getLanguageFullName } from '../ast/language';
... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/llm/constants.ts | const DEFAULT_MAX_TOKENS = 1024;
const DEFAULT_CONTEXT_LENGTH = 4096;
const DEFAULT_TEMPERATURE = 0.5;
const DEFAULT_ARGS = {
maxTokens: DEFAULT_MAX_TOKENS,
temperature: DEFAULT_TEMPERATURE,
};
const CONTEXT_LENGTH_FOR_MODEL: { [name: string]: number } = {
"gpt-3.5-turbo": 4096,
"gpt-3.5-turbo-0613": 4096,
... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/llm/countTokens.ts | // @ts-ignore
import llamaTokenizer from "llama-tokenizer-js";
//import { ChatMessage, MessageContent, MessagePart } from "..";
import { TOKEN_BUFFER_FOR_SAFETY } from "./constants";
export type ChatMessageRole = "user" | "assistant" | "system";
export interface MessagePart {
type: "text" | "imageUrl";
text?: st... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/astIndex/indexStore.ts |
import * as fs from 'fs';
import * as path from 'path';
// 对代码文件进行管理,记录每个文件的block信息
// 同时支持本地文件存储结果,以及支持针对新变量集合进行相似度计算,并返回相似度最高的一组block
import { BlockInfo, FileBlockInfo } from "./types";
import { UiUtilWrapper } from '../../../util/uiUtil';
// difine interface for {score: number, block: BlockInfo}
export interface S... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/astIndex/types.ts | // 代码分为多个block, 每个block包含一个变量集合
export interface BlockInfo {
file: string;
startLine: number;
endLine: number;
lastTime: number;
identifiers: string[];
}
// 每个代码文件包含多个block
export interface FileBlockInfo {
path: string;
lastTime: number;
blocks: BlockInfo[];
hashKey: string;
}
| 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/astIndex/createIdentifierSet.ts | import * as fs from 'fs';
import Parser from "web-tree-sitter";
import { BlockInfo, FileBlockInfo } from "./types";
import { getAst } from "../ast/ast";
import { findFunctionRanges } from "../ast/findFunctions";
import { FunctionInfo, splitFileIntoBlocks } from "../symbolindex/embedding";
import { findIdentifiers } fro... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/astIndex/index.ts | import * as path from 'path';
import * as fsE from 'fs';
import fs from 'fs/promises';
import { logger } from '../../../util/logger';
import { getFileBlock } from '../symbolindex/embedding';
import { UiUtilWrapper } from '../../../util/uiUtil';
import { getLanguageFullName } from '../ast/language';
import { DevChatConf... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/findIdentifiers.ts | /*
针对代码补全功能,构建prompt
prompt的好坏,取决于提供的上下文信息。
通过AST获取相对完整的信息,可能会增加提示的准确度,但也会增加代码提示的复杂度。
*/
import { logger } from "../../../util/logger";
import * as vscode from "vscode";
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast";
import Parser from "web-tree-sitter";
import { getCommentPrefix, g... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/ast.ts | import * as path from "path";
import Parser from "web-tree-sitter";
import { getParserForFile } from "./treeSitter";
import MemoryCacheManager from "../cache";
import * as crypto from 'crypto';
import { UiUtilWrapper } from "../../../util/uiUtil";
export interface RangeInFileWithContents {
filepath: string;
... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/language.ts | /*
不同源码语言有不同语法信息,例如注释标记。
*/
export const supportedLanguages: { [key: string]: string } = {
bash: "bash", // tree-sitter-bash.wasm
sh: "bash", // tree-sitter-bash.wasm
c: "c", // tree-sitter-c.wasm
h: "c", // tree-sitter-c.wasm
cs: "c_sharp", // tree-sitter-c_sharp.wasm
cpp: "... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/treeSitter.ts | /*
This file is copied from Continut repo.
*/
import { logger } from "../../../util/logger";
import { UiUtilWrapper } from "../../../util/uiUtil";
import * as path from "path";
import * as fs from "fs";
import { Language } from "web-tree-sitter";
import Parser = require("web-tree-sitter");
import { getLanguageFullNa... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/findFunctions.ts | /*
针对代码补全功能,构建prompt
prompt的好坏,取决于提供的上下文信息。
通过AST获取相对完整的信息,可能会增加提示的准确度,但也会增加代码提示的复杂度。
*/
import { logger } from "../../../util/logger";
import * as vscode from "vscode";
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast";
import Parser from "web-tree-sitter";
import { getCommentPrefix, g... | 0 |
devchat_public_repos/devchat-vscode/src/contributes/codecomplete | devchat_public_repos/devchat-vscode/src/contributes/codecomplete/ast/collapseBlock.ts | /*
针对代码补全功能,构建prompt
prompt的好坏,取决于提供的上下文信息。
通过AST获取相对完整的信息,可能会增加提示的准确度,但也会增加代码提示的复杂度。
*/
import { logger } from "../../../util/logger";
import { getAst, getTreePathAtCursor, RangeInFileWithContents } from "./ast";
import Parser from "web-tree-sitter";
import { getCommentPrefix, getLangageFunctionConfig, Langu... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/ide_services/README.md | # IDE Service
This module is the VSCode implementation of IDE Service Protocol. | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/ide_services/types.ts | /**
* Type definitions for IDE Service Protocol
*/
export namespace IDEService {
export type LogLevel = "info" | "warn" | "error" | "debug";
export interface Position {
line: number; // 0-based
character: number; // 0-based
}
export interface Range {
start: Position;
... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/ide_services/services.ts | /* eslint-disable @typescript-eslint/naming-convention */
import * as http from "http";
import * as querystring from "querystring";
import { logger } from "../util/logger";
import { getServicePort } from "./endpoints/getServicePort";
import { installPythonEnv } from "./endpoints/installPythonEnv";
import { ideLogging}... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/updateSlashCommands.ts | import * as vscode from 'vscode';
export async function updateSlashCommands() {
vscode.commands.executeCommand('DevChat.InstallCommands');
return true;
} | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/ideLogging.ts | import { logger } from "../../util/logger";
export async function ideLogging(level: string, message: string) {
if (typeof logger.channel()?.[level] === "function") {
// level is one of "info", "warn", "error", "debug"
logger.channel()?.[level](message);
return true;
}
return false;
... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/findDefs.ts | import * as vscode from "vscode";
import { IDEService } from "../types";
import { assert } from "console";
/**
* Find definition locations for a symbol
*
* @param abspath: absolute path of the file
* @param line: line number of the symbol, 0-based
* @param character: character number, 0-based
*/
export async f... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/findTypeDefs.ts | import * as vscode from "vscode";
import { IDEService } from "../types";
import { assert } from "console";
/**
* Find type definition locations for a symbol
*
* @param abspath: absolute path of the file
* @param line: line number of the symbol, 0-based
* @param character: character number, 0-based
*/
export as... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/getDocumentSymbols.ts | import * as vscode from "vscode";
import { IDEService } from "../types";
/**
* Get document symbols of a file
*
* @param abspath: absolute path of the file
* @returns an array of IDEService.SymbolNode
*/
export async function getDocumentSymbols(
abspath: string
): Promise<IDEService.SymbolNode[]> {
const... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/installPythonEnv.ts | import { logger } from "../../util/logger";
import {
createEnvByConda,
createEnvByMamba,
} from "../../util/python_installer/app_install";
import { installRequirements } from "../../util/python_installer/package_install";
export async function installPythonEnv(
command_name: string,
requirements_file:... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/getServicePort.ts | import { logger } from "../../util/logger";
export async function getServicePort() {
logger
.channel()
?.info(`get lsp bridge port: ${process.env.DEVCHAT_IDE_SERVICE_PORT}`);
// return await UiUtilWrapper.getLSPBrigePort();
return process.env.DEVCHAT_IDE_SERVICE_PORT;
}
| 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/ideLanguage.ts | import { DevChatConfig } from "../../util/config";
export async function ideLanguage() {
const language = DevChatConfig.getInstance().get('language');
// 'en' stands for English, 'zh' stands for Simplified Chinese
return language;
}
| 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/legacy.ts | /**
* Legacy endpoints migrated from language-bridge for ask-code
*
* Should remove these endpoints after ask-code migrated to new endpoints
*/
import {
findDefinitions,
findDefinitionsOfToken,
} from "./legacy_bridge/feature/find-defs";
import { findReferences } from "./legacy_bridge/feature/find-refs";
... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/unofficial.ts | import * as vscode from "vscode";
import { applyCodeWithDiff } from "../../handler/diffHandler";
import { getSymbolDefines } from "../../context/contextRefDefs";
export namespace UnofficialEndpoints {
export async function diffApply(filepath: string, content: string) {
applyCodeWithDiff({ fileName: filepa... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services/endpoints/legacy_bridge | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/legacy_bridge/feature/find-defs.ts | import * as vscode from "vscode";
interface Definition {
name: string;
abspath: string;
line: number; // 1-based
character: number; // 1-based
}
/**
* @param abspath: absolute path of the file
* @param line: line number, 1-based
* @param character: character number, 1-based
*
**/
async function f... | 0 |
devchat_public_repos/devchat-vscode/src/ide_services/endpoints/legacy_bridge | devchat_public_repos/devchat-vscode/src/ide_services/endpoints/legacy_bridge/feature/find-refs.ts | import * as vscode from "vscode";
import * as path from "path";
// TODO: merge with find-defs.ts
interface Reference {
name: string;
abspath: string;
line: number; // 1-based
character: number; // 1-based
}
/**
* @param abspath: absolute path of the file
* @param line: line number, 1-based
* @para... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/toolwrapper/devchat.ts | import * as dotenv from 'dotenv';
import * as path from 'path';
import * as fs from 'fs';
import * as os from 'os';
import { logger } from '../util/logger';
import { CommandRun } from "../util/commonUtil";
import { UiUtilWrapper } from '../util/uiUtil';
import { ApiKeyManager } from '../util/apiKey';
import { assertVa... | 0 |
devchat_public_repos/devchat-vscode/src | devchat_public_repos/devchat-vscode/src/toolwrapper/dtm.ts | import { logger } from "../util/logger";
import { CommandRun } from "../util/commonUtil";
import { UiUtilWrapper } from "../util/uiUtil";
interface DtmResponse {
status: number;
message: string;
log: string;
}
class DtmWrapper {
private workspaceDir: string;
private commandRun: CommandRun;
constructor() {
t... | 0 |
devchat_public_repos | devchat_public_repos/workflows/configuration.toml | [recommend]
workflows = ["unit_tests", "commit", "docstring", "comments", "fix", "explain", "refactor"]
| 0 |
devchat_public_repos | devchat_public_repos/workflows/LICENSE | Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
... | 0 |
devchat_public_repos | devchat_public_repos/workflows/requirements.txt | devchat-ask>=0.1.7
| 0 |
devchat_public_repos | devchat_public_repos/workflows/Makefile | .PHONY: setup-dev check fix
div = $(shell printf '=%.0s' {1..120})
setup-dev:
@echo "Setting up development environment..."
@echo "Installing dev dependencies..."
@~/.chat/mamba/envs/devchat-commands/bin/pip install -r requirements-dev.txt
@echo "Done!"
check:
@echo ${div}
~/.chat/mamba/envs/devchat-commands/b... | 0 |
devchat_public_repos | devchat_public_repos/workflows/pyproject.toml | [tool.ruff]
line-length = 100
[tool.ruff.lint]
select = ["I"] # Enable the isort rules
extend-select = ["E501"] # explicitly adding the rules | 0 |
devchat_public_repos | devchat_public_repos/workflows/README.md | # workflows
DevChat workflows (the `sys` directory)
## Quick Start
```shell
cd ~/.chat/workflows
git clone https://github.com/devchat-ai/workflows.git sys
```
| 0 |
devchat_public_repos | devchat_public_repos/workflows/requirements-dev.txt | ruff~=0.1.7
| 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/commit/commit.py | # flake8: noqa: E402
import os
import re
import subprocess
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "libs"))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "libs"))
sys.path.append(os.path.dirname(__file__))
from chatmark import Checkbox, Form, TextEditor # noqa: ... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/commit/command.yml | description: 'Writes a well-formatted commit message for selected code changes and commits them via Git. Include an issue number if desired (e.g., input "/commit to close #12").'
hint: to close Issue #issue_number
input: optional
steps:
- run: $devchat_python $command_path/commit.py "$input" | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/commit/diffCommitMessagePrompt.txt | Objective:** Generate a commit message that succinctly describes the codebase changes reflected in the provided diff, while incorporating any extra context or guidance from the user.
**Commit Message Structure:**
1. **Title Line:** Choose a type such as `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `buil... | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/commit_message_tests.yaml | - vars:
commit_message: The commit fixes a use-after-free error in the AFS volume tree
due to a race condition between volume lookup and removal. The patch prevents
looking up volumes with zero reference count and ensures that once a volume's
refcount reaches zero, it is flagged and not looked up ... | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/commit_cache.json | {"9a6b294ab496650e9f270123730df37030911b55": {"diff": "diff --git a/fs/afs/internal.h b/fs/afs/internal.h\nindex a812952be1c948..7385d62c8cf503 100644\n--- a/fs/afs/internal.h\n+++ b/fs/afs/internal.h\n@@ -586,6 +586,7 @@ struct afs_volume {\n #define AFS_VOLUME_OFFLINE\t4\t/* - T if volume offline notice given */\n #d... | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/commit_message_prompt_config.yaml | prompts:
[
'../../diffCommitMessagePrompt.txt'
]
providers:
- id: "exec:python commit_message_run.py"
tests:
- commit_message_tests.yaml
| 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/requirements-test.txt | requests>=2.31.0
openai>=1.6.1
pyyaml>=6.0.1 | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/run.sh | #!/bin/bash
# 获取脚本所在目录
SCRIPT_DIR=$(dirname "$0")
TEST_DIR="${SCRIPT_DIR}"
REQUIREMENTS_FILE="${TEST_DIR}/requirements-test.txt"
CONFIG_FILE="${TEST_DIR}/commit_message_prompt_config.yaml"
# 安装Node.js依赖
echo "Installing promptfoo using npx..."
npx promptfoo@latest
# 检查Python是否安装
if ! command -v python3 &> /dev/null
... | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/readme.md |
## Overview
This README provides information about the workflow used for generating commit messages based on commit differences. The workflow involves recording prompts, defining test cases, and running scripts to process these cases.
## Dependency Installation
Before you can run the tests for commit message genera... | 0 |
devchat_public_repos/workflows/commit/test | devchat_public_repos/workflows/commit/test/prompt/commit_message_run.py | import json
import os
import sys
import requests
def get_script_path():
"""Return the directory path of the current script."""
return os.path.dirname(__file__)
def update_sys_path():
"""Extend system path to include library directories."""
libs_path = os.path.join(get_script_path(), "..", "..", "..... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/comments/command.yml | description: Automatically add doc comments. Select some code and execute this command to generate comments.
steps:
- run: $devchat_python $command_path/main.py
| 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/comments/README.md |
### 操作指南
生成行间注释,请按照如下步骤操作:
1. 选中行间代码。
2. 输入\/comments,回车发送;或右键点击**DevChat: Generate Comments**按钮。
3. 开始生成行间注释,等待生成结束。
4. 自动弹出Diff View,选择是否接受修改。
如图所示:
 | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/comments/main.py | import os
import re
import sys
from devchat.ide.service import IDEService
from devchat.ide.vscode_services import selected_lines, visible_lines
from devchat.llm import chat
def get_selected_code():
"""
Retrieves the selected lines of code from the user's selection.
This function extracts the text select... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/explain/command.yml | description: Explain selected code.
steps:
- run: $devchat_python $command_path/explain.py
| 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/explain/README.md |
### 操作指南
生成代码解释,请按照如下步骤操作:
1. 选中行间代码。
2. 输入\/explain,回车发送;或右键点击**DevChat: Generate Explain**按钮。
3. 开始生成代码解释,等待生成结束。
如图所示:
 | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/explain/explain.py | import os
import sys
from devchat.ide.service import IDEService
from devchat.llm import chat
def get_selected_code():
"""
Retrieves the selected lines of code from the user's selection.
This function extracts the text selected by the user in their IDE or text editor.
If no text has been selected, it... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/find_reference_tests.py | from typing import List
from assistants.directory_structure.relevant_file_finder import RelevantFileFinder
from prompts import FIND_REFERENCE_PROMPT
from tools.file_util import verify_file_list
def find_reference_tests(root_path: str, function_name: str, file_path: str) -> List[str]:
"""Find reference tests for ... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/propose_test.py | import json
from functools import partial
from typing import List, Optional
from devchat.llm.openai import chat_completion_no_stream_return_json
from find_context import Context
from llm_conf import (
CONTEXT_SIZE,
DEFAULT_CONTEXT_SIZE,
DEFAULT_ENCODING,
USE_USER_MODEL,
USER_LLM_MODEL,
)
from model... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/Makefile |
i18n-gen-msg:
@echo "# Generating i18n base messages..."
xgettext -k_i -o ./locales/base.pot --from-code=UTF-8 main.py
@echo "# Done."
i18n-init-langs:
@echo "# Init i18n language templates."
@echo "- Initializing zh template..."
msginit -i ./locales/base.pot -o ./locales/zh/base.po -l zh
@echo "- Initializing... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/cache.py | import json
import os
class LocalCache:
"""
A file-based cache for storing and retrieving simple data in JSON format.
"""
DIR = "local_cache"
def __init__(self, name: str, base_path: str):
self._name = name
self._cache = {}
self._base_path = base_path
cache_dir =... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/write_tests.py | from functools import partial
from typing import List, Optional
from devchat.llm.chat import chat_completion_stream_out
from find_context import Context
from llm_conf import (
CONTEXT_SIZE,
DEFAULT_CONTEXT_SIZE,
DEFAULT_ENCODING,
USE_USER_MODEL,
USER_LLM_MODEL,
)
from model import FuncToTest, Token... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/command.yml | description: Generate unit tests.
input: required
steps:
- run: $devchat_python $command_path/main.py "$input" | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/prompts.py | # ruff: noqa: E501
# Don not limit the length of each line of the prompts.
PROPOSE_TEST_PROMPT = """
You're an advanced AI test case generator.
Given a user prompt and a target function, propose detailed test cases for the function based on the prompt, categorizing each as either a 'happy path' or an 'edge case'.
Th... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/model.py | from dataclasses import dataclass
from typing import Optional
from tools.file_util import retrieve_file_content
class TokenBudgetExceededException(Exception):
pass
class UserCancelledException(Exception):
pass
@dataclass
class FuncToTest:
func_name: str
repo_root: str
file_path: str # relati... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/README.md |
### 操作指南
生成单元测试,请按照如下步骤操作:
1. 点击函数头部的**DevChat: unit tests**按钮。
2. 选择Happy Path和Edge Case测试用例。
3. (可选)输入控制信息:补充测试用例、参考文件和附加提示词。
4. 点击提交按钮,等待生成结束。
如图所示:
 | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/openai_util.py | import os
from typing import Optional
from openai import OpenAI, Stream
from openai.types.chat import ChatCompletionChunk
from tenacity import retry, stop_after_attempt, wait_random_exponential
# TODO: make this file a common module
def create_chat_completion_chunks(
client: Optional[OpenAI] = None, **kwargs
) ... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/llm_conf.py | import os
USE_USER_MODEL = bool(os.environ.get("DEVCHAT_UNIT_TESTS_USE_USER_MODEL", False))
USER_LLM_MODEL = os.environ.get("LLM_MODEL", "gpt-4-turbo-preview")
DEFAULT_CONTEXT_SIZE = 4000
CONTEXT_SIZE = {
"gpt-3.5-turbo": 16000,
"gpt-4": 8000,
"gpt-4-turbo-preview": 128000,
"claude-3-sonnet": 1000000,... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/i18n.py | import gettext
import os
from enum import Enum
class TUILanguage(Enum):
EN = ("en", "English")
ZH = ("zh", "Chinese")
Other = ("en", "English") # default to show English
@classmethod
def from_str(cls, language: str) -> "TUILanguage":
if language.lower().startswith("en"):
retu... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/main.py | import os
import sys
from typing import Dict, List, Tuple
import click
sys.path.append(os.path.dirname(__file__))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "libs"))
from cache import LocalCache
from chatmark import Checkbox, Form, Step, TextEditor # noqa: E402
from find_context import (
Cont... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/unit_tests/find_context.py | import os
import sys
from collections import defaultdict
from dataclasses import dataclass
from typing import Dict, List, Optional, Set
from assistants.recommend_test_context import get_recommended_symbols
from model import FuncToTest
from tools.symbol_util import (
find_symbol_nodes,
get_symbol_content,
l... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/tools/symbol_util.py | import os
import re
import sys
from collections import defaultdict
from typing import Dict, List, Optional, Tuple
from tools.file_util import retrieve_file_content
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
from libs.ide_services import Position, SymbolNode
def split_tokens(text: str) -> ... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/tools/directory_viewer.py | from abc import ABC, abstractmethod
from collections import defaultdict
from pathlib import Path
from typing import Callable, List, Optional
from tools.file_util import is_not_hidden, is_source_code
from tools.git_util import git_file_of_interest_filter
class DirectoryViewer(ABC):
def __init__(
self,
... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/tools/file_util.py | import os
from pathlib import Path
from typing import List
def retrieve_file_content(file_path: str, root_path: str) -> str:
"""
Retrieve the content of a file given its relative or absolute path.
If a relative path is provided, it will be joined with the root_path to form an absolute path.
Args:
... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/tools/tiktoken_util.py | import tiktoken
def get_encoding(encoding_name: str):
"""
Get a tiktoken encoding by name.
"""
try:
return tiktoken.get_encoding(encoding_name)
except Exception:
from tiktoken import registry
from tiktoken.core import Encoding
from tiktoken.registry import _find_con... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/tools/git_util.py | import functools
import os
from collections import defaultdict
from pathlib import Path
from typing import Callable, Dict, List
import pathspec
# NOTE: git-ignore pattern examples
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore#git-ignore-patterns
def load_gitignore_spec_from_file(
ignore_fil... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/locales/base.pot | # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-15 16... | 0 |
devchat_public_repos/workflows/unit_tests/locales | devchat_public_repos/workflows/unit_tests/locales/zh/base.po | # Chinese translations for PACKAGE package.
# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# kagami <mingjing@merico.dev>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024... | 0 |
devchat_public_repos/workflows/unit_tests/locales | devchat_public_repos/workflows/unit_tests/locales/en/base.po | # English translations for PACKAGE package.
# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# kagami <mingjing@merico.dev>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/assistants/rerank_files.py | import json
from typing import List, Tuple
from devchat.llm.openai import chat_completion_no_stream_return_json
from llm_conf import (
USE_USER_MODEL,
USER_LLM_MODEL,
)
from openai_util import create_chat_completion_content
MODEL = USER_LLM_MODEL if USE_USER_MODEL else "gpt-4-turbo-preview"
# ruff: noqa: E50... | 0 |
devchat_public_repos/workflows/unit_tests | devchat_public_repos/workflows/unit_tests/assistants/recommend_test_context.py | import json
from typing import List, Optional
from devchat.llm.openai import chat_completion_no_stream_return_json
from llm_conf import (
CONTEXT_SIZE,
DEFAULT_CONTEXT_SIZE,
DEFAULT_ENCODING,
USE_USER_MODEL,
USER_LLM_MODEL,
)
from model import FuncToTest
from openai_util import create_chat_completi... | 0 |
devchat_public_repos/workflows/unit_tests/assistants | devchat_public_repos/workflows/unit_tests/assistants/directory_structure/relevant_file_finder.py | import json
from pathlib import Path
from typing import Callable, List
from assistants.directory_structure.base import DirectoryStructureBase
from assistants.rerank_files import rerank_files
from devchat.llm.openai import chat_completion_no_stream_return_json
from llm_conf import (
CONTEXT_SIZE,
DEFAULT_CONTEX... | 0 |
devchat_public_repos/workflows/unit_tests/assistants | devchat_public_repos/workflows/unit_tests/assistants/directory_structure/base.py | from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any, Callable, Optional
from tools.directory_viewer import mk_repo_file_criteria
class DirectoryStructureBase(ABC):
def __init__(
self,
root_path: str,
chat_language: Optional[str] = None,
) -> None:
... | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/ask-code/command.yml | description: Ask questions about the current project's codebase, which requires proactive acquisition of additional context information to answer.
input: required
steps:
- run: $command_python $command_path/ask-code.py query "$input" | 0 |
devchat_public_repos/workflows | devchat_public_repos/workflows/ask-code/ask-code.py | import os
import sys
from chat.ask_codebase.chains.smart_qa import SmartQA
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "libs"))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "libs"))
from ide_services import IDEService # noqa: E402
def query(question, lsp_brige_port):
r... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.