201 lines
8.0 KiB
TypeScript
201 lines
8.0 KiB
TypeScript
// CNB_NPC_SLUG 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
|
||
// CNB_NPC_NAME 对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
|
||
// CNB_NPC_SHA 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
|
||
// CNB_NPC_PROMPT 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
|
||
// CNB_NPC_AVATAR 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
|
||
// CNB_NPC_ENABLE_THINKING 对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
|
||
import { useKey } from "@kevisual/context";
|
||
|
||
export function useNPCEnv() {
|
||
const npcSlug = useKey("CNB_NPC_SLUG");
|
||
const npcName = useKey("CNB_NPC_NAME");
|
||
const npcSha = useKey("CNB_NPC_SHA");
|
||
const npcPrompt = useKey("CNB_NPC_PROMPT");
|
||
const npcAvatar = useKey("CNB_NPC_AVATAR");
|
||
const npcEnableThinking = useKey("CNB_NPC_ENABLE_THINKING");
|
||
|
||
return {
|
||
/**
|
||
* @key CNB_NPC_SLUG
|
||
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
|
||
*/
|
||
npcSlug,
|
||
npcSlugLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串",
|
||
/**
|
||
* @key CNB_NPC_NAME
|
||
* @description:对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
|
||
*/
|
||
npcName,
|
||
npcNameLabel: "对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串",
|
||
/**
|
||
* @key CNB_NPC_SHA
|
||
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
|
||
*/
|
||
npcSha,
|
||
npcShaLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串",
|
||
/**
|
||
* @key CNB_NPC_PROMPT
|
||
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
|
||
*/
|
||
npcPrompt,
|
||
npcPromptLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串",
|
||
/**
|
||
* @key CNB_NPC_AVATAR
|
||
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
|
||
*/
|
||
npcAvatar,
|
||
npcAvatarLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串",
|
||
/**
|
||
* @key CNB_NPC_ENABLE_THINKING
|
||
* @description:对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
|
||
*/
|
||
npcEnableThinking,
|
||
npcEnableThinkingLabel: "对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串"
|
||
};
|
||
}
|
||
|
||
// CNB_COMMENT_ID 对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
|
||
// CNB_COMMENT_BODY 对于评论事件触发的构建,值为评论内容,否则为空字符串
|
||
// CNB_COMMENT_TYPE note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
|
||
// CNB_COMMENT_FILE_PATH 对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
|
||
// CNB_COMMENT_RANGE 对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
|
||
// CNB_REVIEW_ID 对于 PR 代码评审,值为评审 ID,否则为空字符串
|
||
|
||
export function useCommentEnv() {
|
||
const commentId = useKey("CNB_COMMENT_ID");
|
||
const commentBody = useKey("CNB_COMMENT_BODY");
|
||
const commentType = useKey("CNB_COMMENT_TYPE");
|
||
const commentFilePath = useKey("CNB_COMMENT_FILE_PATH");
|
||
const commentRange = useKey("CNB_COMMENT_RANGE");
|
||
const reviewId = useKey("CNB_REVIEW_ID");
|
||
|
||
return {
|
||
/**
|
||
* @key CNB_COMMENT_ID
|
||
* @description:对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
|
||
*/
|
||
commentId,
|
||
commentIdLabel: "对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串",
|
||
/**
|
||
* @key CNB_COMMENT_BODY
|
||
* @description:对于评论事件触发的构建,值为评论内容,否则为空字符串
|
||
*/
|
||
commentBody,
|
||
commentBodyLabel: "对于评论事件触发的构建,值为评论内容,否则为空字符串",
|
||
/**
|
||
* @key CNB_COMMENT_TYPE
|
||
* @description:note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
|
||
*/
|
||
commentType,
|
||
commentTypeLabel: "对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串",
|
||
/**
|
||
* @key CNB_COMMENT_FILE_PATH
|
||
* @description:对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
|
||
*/
|
||
commentFilePath,
|
||
commentFilePathLabel: "对于 PR 代码评审评论,值为评论所在文件,否则为空字符串",
|
||
/**
|
||
* @key CNB_COMMENT_RANGE
|
||
* @description:对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
|
||
*/
|
||
commentRange,
|
||
commentRangeLabel: "对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串",
|
||
/**
|
||
* @key CNB_REVIEW_ID
|
||
* @description:对于 PR 代码评审,值为评审 ID,否则为空字符串
|
||
*/
|
||
reviewId,
|
||
reviewIdLabel: "对于 PR 代码评审,值为评审 ID,否则为空字符串"
|
||
};
|
||
}
|
||
|
||
// CNB_ISSUE_ID Issue 全局唯一 ID
|
||
// CNB_ISSUE_IID Issue 仓库编号
|
||
// CNB_ISSUE_TITLE Issue 标题
|
||
// CNB_ISSUE_DESCRIPTION Issue 描述
|
||
// CNB_ISSUE_OWNER Issue 作者
|
||
// CNB_ISSUE_STATE Issue 状态
|
||
// CNB_ISSUE_IS_RESOLVED Issue 是否已解决
|
||
// CNB_ISSUE_ASSIGNEES Issue 处理人列表
|
||
// CNB_ISSUE_LABELS Issue 标签列表
|
||
// CNB_ISSUE_PRIORITY Issue 优先级
|
||
export const useIssueEnv = () => {
|
||
const issueId = useKey("CNB_ISSUE_ID");
|
||
const issueIid = useKey("CNB_ISSUE_IID");
|
||
const issueTitle = useKey("CNB_ISSUE_TITLE");
|
||
const issueDescription = useKey("CNB_ISSUE_DESCRIPTION");
|
||
const issueOwner = useKey("CNB_ISSUE_OWNER");
|
||
const issueState = useKey("CNB_ISSUE_STATE");
|
||
const issueIsResolved = useKey("CNB_ISSUE_IS_RESOLVED");
|
||
const issueAssignees = useKey("CNB_ISSUE_ASSIGNEES");
|
||
const issueLabels = useKey("CNB_ISSUE_LABELS");
|
||
const issuePriority = useKey("CNB_ISSUE_PRIORITY");
|
||
|
||
return {
|
||
/**
|
||
* @key CNB_ISSUE_ID
|
||
* @description:Issue 全局唯一 ID
|
||
*/
|
||
issueId,
|
||
issueIdLabel: "Issue 全局唯一 ID",
|
||
/**
|
||
* @key CNB_ISSUE_IID
|
||
* @description:Issue 仓库编号
|
||
*/
|
||
issueIid,
|
||
issueIidLabel: "Issue 仓库编号",
|
||
/**
|
||
* @key CNB_ISSUE_TITLE
|
||
* @description:Issue 标题
|
||
*/
|
||
issueTitle,
|
||
issueTitleLabel: "Issue 标题",
|
||
/**
|
||
* @key CNB_ISSUE_DESCRIPTION
|
||
* @description:Issue 描述
|
||
*/
|
||
issueDescription,
|
||
issueDescriptionLabel: "Issue 描述",
|
||
/**
|
||
* @key CNB_ISSUE_OWNER
|
||
* @description:Issue 作者
|
||
*/
|
||
issueOwner,
|
||
issueOwnerLabel: "Issue 作者",
|
||
/**
|
||
* @key CNB_ISSUE_STATE
|
||
* @description:Issue 状态
|
||
*/
|
||
issueState,
|
||
issueStateLabel: "Issue 状态",
|
||
/**
|
||
* @key CNB_ISSUE_IS_RESOLVED
|
||
* @description:Issue 是否已解决
|
||
*/
|
||
issueIsResolved,
|
||
issueIsResolvedLabel: "Issue 是否已解决",
|
||
/**
|
||
* @key CNB_ISSUE_ASSIGNEES
|
||
* @description:Issue 处理人列表
|
||
*/
|
||
issueAssignees,
|
||
issueAssigneesLabel: "Issue 处理人列表",
|
||
/**
|
||
* @key CNB_ISSUE_LABELS
|
||
* @description:Issue 标签列表
|
||
*/
|
||
issueLabels,
|
||
issueLabelsLabel: "Issue 标签列表",
|
||
/**
|
||
* @key CNB_ISSUE_PRIORITY
|
||
* @description:Issue 优先级
|
||
*/
|
||
issuePriority,
|
||
issuePriorityLabel: "Issue 优先级"
|
||
};
|
||
}
|
||
|
||
|
||
export * from './build-env.ts'
|
||
export * from './pr-env.ts'
|
||
export * from './repo-env.ts' |