agentdev 0.1.7 → 0.1.9
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.
- package/dist/BasicAgent-UWXLSZP2.js +13 -0
- package/dist/ExplorerAgent-LCM3JQS4.js +13 -0
- package/dist/{chunk-LQTEETML.js → chunk-5T4C2XRT.js} +12 -7
- package/dist/chunk-5T4C2XRT.js.map +1 -0
- package/dist/{chunk-OBOU27DM.js → chunk-A354ZCZF.js} +6735 -1822
- package/dist/chunk-A354ZCZF.js.map +1 -0
- package/dist/{chunk-TSASFMRF.js → chunk-BAP2GCYH.js} +1 -1
- package/dist/chunk-BAP2GCYH.js.map +1 -0
- package/dist/{chunk-3BPSNNK3.js → chunk-EECW6PYP.js} +11 -9
- package/dist/chunk-EECW6PYP.js.map +1 -0
- package/dist/chunk-G5ECPY4K.js +551 -0
- package/dist/chunk-G5ECPY4K.js.map +1 -0
- package/dist/{chunk-LLV3W326.js → chunk-NORTAQIL.js} +67 -20
- package/dist/chunk-NORTAQIL.js.map +1 -0
- package/dist/{chunk-F3PR7UTL.js → chunk-QFHPUAUQ.js} +5 -3
- package/dist/{chunk-F3PR7UTL.js.map → chunk-QFHPUAUQ.js.map} +1 -1
- package/dist/cli/server.js +2 -2
- package/dist/cli/viewer.js +2 -2
- package/dist/create-feature-cli.cmd +2 -0
- package/dist/create-feature-cli.js +292 -0
- package/dist/features/shell/templates/bash.render.d.ts +1 -1
- package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
- package/dist/index.d.ts +1733 -500
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{notification-3VEAP7YF.js → notification-NWVOS2WR.js} +3 -3
- package/dist/tools-LDR3LIJP.js +14 -0
- package/dist/tools-LDR3LIJP.js.map +1 -0
- package/dist/{types-DUKIIntb.d.ts → types-CF5UsxD9.d.ts} +3 -0
- package/node_modules/@sliverp/qqbot/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/README.md +427 -0
- package/node_modules/@sliverp/qqbot/README.standalone.zh.md +77 -0
- package/node_modules/@sliverp/qqbot/README.zh.md +423 -0
- package/node_modules/@sliverp/qqbot/bin/qqbot-cli.js +227 -0
- package/node_modules/@sliverp/qqbot/clawdbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/dist/index.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/index.js +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.d.ts +76 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.js +36 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.d.ts +138 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.js +523 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.d.ts +3 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.js +349 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.d.ts +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.js +156 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.d.ts +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.js +125 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.js +2156 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.d.ts +62 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.js +401 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.d.ts +100 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.js +263 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.d.ts +10 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.js +203 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.d.ts +2 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.js +155 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.d.ts +150 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.js +1175 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.d.ts +170 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.js +399 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.d.ts +5 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.js +16 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.d.ts +52 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.js +254 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.d.ts +145 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.js +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.d.ts +73 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.js +645 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.d.ts +46 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.js +107 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.d.ts +51 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.js +234 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.d.ts +14 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.js +120 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.d.ts +112 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.js +186 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.d.ts +126 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.js +358 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.d.ts +34 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.js +93 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.d.ts +6 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.js +6 -0
- package/node_modules/@sliverp/qqbot/index.ts +30 -0
- package/node_modules/@sliverp/qqbot/moltbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/LICENSE +201 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/README.md +134 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/browser.js +17 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/index.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/node.js +223 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/package.json +54 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/index.js +5 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/package.json +36 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/README.md +265 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/index.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/package.json +58 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/types.d.ts +30 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/README.md +85 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.cjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.d.ts +70 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.mjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/silk.wasm +0 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/utils.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/package.json +39 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.prettierignore +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/LICENSE +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/README.md +163 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/esm.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/index.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/package.json +50 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/rollup.config.js +27 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/src/simple-yenc.js +302 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/LICENSE +20 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/README.md +548 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/browser.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/index.js +13 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket-server.js +554 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket.js +1393 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/package.json +69 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/@sliverp/qqbot/openclaw.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/package.json +81 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-cron/SKILL.md +513 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-media/SKILL.md +194 -0
- package/node_modules/@sliverp/qqbot/src/agent.ts +133 -0
- package/node_modules/@sliverp/qqbot/src/api.ts +704 -0
- package/node_modules/@sliverp/qqbot/src/channel.ts +380 -0
- package/node_modules/@sliverp/qqbot/src/config.ts +182 -0
- package/node_modules/@sliverp/qqbot/src/demo-standalone.ts +144 -0
- package/node_modules/@sliverp/qqbot/src/gateway.ts +2285 -0
- package/node_modules/@sliverp/qqbot/src/image-server.ts +474 -0
- package/node_modules/@sliverp/qqbot/src/known-users.ts +353 -0
- package/node_modules/@sliverp/qqbot/src/onboarding.ts +274 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-agent-adapter.ts +168 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-plugin-sdk.d.ts +483 -0
- package/node_modules/@sliverp/qqbot/src/outbound.ts +1301 -0
- package/node_modules/@sliverp/qqbot/src/proactive.ts +530 -0
- package/node_modules/@sliverp/qqbot/src/runtime.ts +22 -0
- package/node_modules/@sliverp/qqbot/src/session-store.ts +303 -0
- package/node_modules/@sliverp/qqbot/src/types.ts +153 -0
- package/node_modules/@sliverp/qqbot/src/utils/audio-convert.ts +738 -0
- package/node_modules/@sliverp/qqbot/src/utils/file-utils.ts +122 -0
- package/node_modules/@sliverp/qqbot/src/utils/image-size.ts +266 -0
- package/node_modules/@sliverp/qqbot/src/utils/media-tags.ts +134 -0
- package/node_modules/@sliverp/qqbot/src/utils/payload.ts +265 -0
- package/node_modules/@sliverp/qqbot/src/utils/platform.ts +404 -0
- package/node_modules/@sliverp/qqbot/src/utils/upload-cache.ts +128 -0
- package/node_modules/@sliverp/qqbot/standalone.ts +6 -0
- package/node_modules/@sliverp/qqbot/tsconfig.json +16 -0
- package/package.json +12 -3
- package/dist/BasicAgent-QWEYCLV5.js +0 -12
- package/dist/ExplorerAgent-4IT22VB7.js +0 -12
- package/dist/chunk-3BPSNNK3.js.map +0 -1
- package/dist/chunk-LLV3W326.js.map +0 -1
- package/dist/chunk-LQTEETML.js.map +0 -1
- package/dist/chunk-OBOU27DM.js.map +0 -1
- package/dist/chunk-TSASFMRF.js.map +0 -1
- /package/dist/{BasicAgent-QWEYCLV5.js.map → BasicAgent-UWXLSZP2.js.map} +0 -0
- /package/dist/{ExplorerAgent-4IT22VB7.js.map → ExplorerAgent-LCM3JQS4.js.map} +0 -0
- /package/dist/{notification-3VEAP7YF.js.map → notification-NWVOS2WR.js.map} +0 -0
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
TemplateComposer,
|
|
7
7
|
createLLM,
|
|
8
8
|
loadConfigSync
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A354ZCZF.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/system/ExplorerAgent.ts
|
|
12
12
|
import { existsSync } from "fs";
|
|
13
13
|
import { cwd, platform } from "process";
|
|
14
|
-
var ExplorerAgent = class extends AgentBase {
|
|
14
|
+
var ExplorerAgent = class _ExplorerAgent extends AgentBase {
|
|
15
15
|
_systemContext;
|
|
16
16
|
_config;
|
|
17
17
|
_skillsDir;
|
|
@@ -61,6 +61,8 @@ var ExplorerAgent = class extends AgentBase {
|
|
|
61
61
|
this.getTools().disable("safe_trash_delete");
|
|
62
62
|
this.getTools().disable("safe_trash_list");
|
|
63
63
|
this.getTools().disable("safe_trash_restore");
|
|
64
|
+
this.registerAgentType("ExplorerAgent", () => new _ExplorerAgent({ llm: this.llm }));
|
|
65
|
+
this.registerAgentType("BasicAgent", () => import("./BasicAgent-UWXLSZP2.js").then((m) => new m.BasicAgent({ llm: this.llm })));
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* Agent 初始化钩子
|
|
@@ -84,4 +86,4 @@ var ExplorerAgent = class extends AgentBase {
|
|
|
84
86
|
export {
|
|
85
87
|
ExplorerAgent
|
|
86
88
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-QFHPUAUQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agents/system/ExplorerAgent.ts"],"sourcesContent":["/**\r\n * ExplorerAgent - 代码探索者 Agent\r\n *\r\n * 专注于代码库探索和理解的轻量级 Agent\r\n * 仅配备 read、list、bash 三个核心工具\r\n * 适用于代码审查、结构分析、文档生成等场景\r\n */\r\n\r\nimport { Agent } from '../../core/agent.js';\r\nimport { SkillFeature, SubAgentFeature, OpencodeBasicFeature } from '../../features/index.js';\r\nimport type { AgentConfig, LLMClient } from '../../core/types.js';\r\nimport type { AgentConfigFile } from '../../core/config.js';\r\nimport { loadConfigSync } from '../../core/config.js';\r\nimport { createLLM } from '../../llm/index.js';\r\nimport { existsSync } from 'fs';\r\nimport { cwd, platform } from 'process';\r\nimport { TemplateComposer } from '../../template/composer.js';\r\n\r\n/**\r\n * 系统环境信息上下文\r\n */\r\nexport interface SystemContext {\r\n /** 当前工作目录 */\r\n SYSTEM_WORKING_DIR: string;\r\n /** 是否是 Git 仓库 */\r\n SYSTEM_IS_GIT_REPOSITORY: boolean;\r\n /** 操作系统平台 */\r\n SYSTEM_PLATFORM: NodeJS.Platform;\r\n /** 当前日期 (YYYY-MM-DD) */\r\n SYSTEM_DATE: string;\r\n /** 当前使用的模型名称 */\r\n SYSTEM_CURRENT_MODEL: string;\r\n /** 索引签名,允许作为 PlaceholderContext 使用 */\r\n [key: string]: any;\r\n}\r\n\r\n/**\r\n * ExplorerAgent 配置选项\r\n *\r\n * 所有参数都是可选的,默认会自动同步加载配置文件\r\n */\r\nexport interface ExplorerAgentConfig {\r\n /** LLM 客户端(可选,不传则自动同步加载配置创建) */\r\n llm?: LLMClient;\r\n /** 配置文件名(可选,默认 'default') */\r\n configName?: string;\r\n /** Agent 显示名称(可选) */\r\n name?: string;\r\n /** 系统提示词(可选,默认使用 explorer.md) */\r\n systemMessage?: string;\r\n /** Skills 目录(可选,默认使用 .agentdev/skills) */\r\n skillsDir?: string;\r\n}\r\n\r\n/**\r\n * 代码探索者 Agent\r\n *\r\n * 轻量级代码探索 Agent,专注于:\r\n * - 代码库结构分析\r\n * - 代码审查和理解\r\n * - 文档生成\r\n * - 依赖关系梳理\r\n *\r\n * 构造函数不传任何参数时,会自动同步加载配置文件创建 LLM\r\n */\r\nexport class ExplorerAgent extends Agent {\r\n protected _systemContext: SystemContext;\r\n protected _config?: AgentConfigFile;\r\n protected _skillsDir?: string;\r\n\r\n /**\r\n * 构造函数\r\n *\r\n * @param config 探索者配置(全部可选,不传则使用默认配置)\r\n */\r\n constructor(config: ExplorerAgentConfig = {}) {\r\n // 建立系统环境信息\r\n const systemContext: SystemContext = {\r\n SYSTEM_WORKING_DIR: cwd(),\r\n SYSTEM_IS_GIT_REPOSITORY: existsSync(cwd() + '/.git'),\r\n SYSTEM_PLATFORM: platform,\r\n SYSTEM_DATE: new Date().toISOString().split('T')[0], // YYYY-MM-DD\r\n SYSTEM_CURRENT_MODEL: 'unknown', // 稍后更新\r\n };\r\n\r\n // 准备 LLM:如果没传入,同步加载配置\r\n let llm = config.llm;\r\n let fileConfig: AgentConfigFile | undefined;\r\n if (!llm) {\r\n const configName = config.configName ?? 'default';\r\n fileConfig = loadConfigSync(configName);\r\n llm = createLLM(fileConfig);\r\n systemContext.SYSTEM_CURRENT_MODEL = fileConfig.defaultModel.model;\r\n console.log(`[ExplorerAgent] 已加载配置: ${configName}, 模型: ${fileConfig.defaultModel.model}`);\r\n }\r\n\r\n // 构建完整的 Agent 配置\r\n const agentConfig: AgentConfig = {\r\n llm: llm!,\r\n tools: [], // 工具由 Feature 提供\r\n maxTurns: Infinity, // 无限交互次数\r\n systemMessage: config.systemMessage,\r\n name: config.name,\r\n };\r\n\r\n super(agentConfig);\r\n\r\n // 保存配置(必须在 super() 之后)\r\n this._systemContext = systemContext;\r\n this._config = fileConfig;\r\n this._skillsDir = config.skillsDir;\r\n this.setSystemContext(systemContext);\r\n\r\n // 注册 OpencodeBasicFeature(文件操作工具集)\r\n this.use(new OpencodeBasicFeature());\r\n\r\n // 注册 SkillFeature(invokeSkill 工具和 skills 上下文注入)\r\n this.use(new SkillFeature(config.skillsDir));\r\n\r\n // 注册 SubAgentFeature(子代理工具和消息处理)\r\n this.use(new SubAgentFeature());\r\n\r\n // 预禁用只读模式下不应暴露的工具,确保首次快照与运行时一致\r\n this.getTools().disable('write');\r\n this.getTools().disable('edit');\r\n this.getTools().disable('safe_trash_delete');\r\n this.getTools().disable('safe_trash_list');\r\n this.getTools().disable('safe_trash_restore');\r\n }\r\n\r\n /**\r\n * Agent 初始化钩子\r\n * 配置系统提示词,禁用写入和编辑工具(只读模式)\r\n */\r\n protected override async onInitiate(): Promise<void> {\r\n // 配置系统提示词\r\n if (!this.systemMessage) {\r\n this.setSystemPrompt(new TemplateComposer()\r\n .add({ file: '.agentdev/prompts/explorer.md' })\r\n .add('\\n\\n## 系统环境\\n\\n')\r\n .add('- 工作目录: `{{SYSTEM_WORKING_DIR}}`\\n')\r\n .add('- Git 仓库: {{SYSTEM_IS_GIT_REPOSITORY}}\\n')\r\n .add('- 操作系统: {{SYSTEM_PLATFORM}}\\n')\r\n .add('- bash版本:PowerShell 5.1\\n')\r\n .add('- 当前日期: {{SYSTEM_DATE}}\\n')\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * 获取系统环境信息\r\n */\r\n getSystemContext(): SystemContext {\r\n return this._systemContext;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,gBAAgB;AAkDvB,IAAM,gBAAN,
|
|
1
|
+
{"version":3,"sources":["../src/agents/system/ExplorerAgent.ts"],"sourcesContent":["/**\r\n * ExplorerAgent - 代码探索者 Agent\r\n *\r\n * 专注于代码库探索和理解的轻量级 Agent\r\n * 仅配备 read、list、bash 三个核心工具\r\n * 适用于代码审查、结构分析、文档生成等场景\r\n */\r\n\r\nimport { Agent } from '../../core/agent.js';\r\nimport { SkillFeature, SubAgentFeature, OpencodeBasicFeature } from '../../features/index.js';\r\nimport type { AgentConfig, LLMClient } from '../../core/types.js';\r\nimport type { AgentConfigFile } from '../../core/config.js';\r\nimport { loadConfigSync } from '../../core/config.js';\r\nimport { createLLM } from '../../llm/index.js';\r\nimport { existsSync } from 'fs';\r\nimport { cwd, platform } from 'process';\r\nimport { TemplateComposer } from '../../template/composer.js';\r\n\r\n/**\r\n * 系统环境信息上下文\r\n */\r\nexport interface SystemContext {\r\n /** 当前工作目录 */\r\n SYSTEM_WORKING_DIR: string;\r\n /** 是否是 Git 仓库 */\r\n SYSTEM_IS_GIT_REPOSITORY: boolean;\r\n /** 操作系统平台 */\r\n SYSTEM_PLATFORM: NodeJS.Platform;\r\n /** 当前日期 (YYYY-MM-DD) */\r\n SYSTEM_DATE: string;\r\n /** 当前使用的模型名称 */\r\n SYSTEM_CURRENT_MODEL: string;\r\n /** 索引签名,允许作为 PlaceholderContext 使用 */\r\n [key: string]: any;\r\n}\r\n\r\n/**\r\n * ExplorerAgent 配置选项\r\n *\r\n * 所有参数都是可选的,默认会自动同步加载配置文件\r\n */\r\nexport interface ExplorerAgentConfig {\r\n /** LLM 客户端(可选,不传则自动同步加载配置创建) */\r\n llm?: LLMClient;\r\n /** 配置文件名(可选,默认 'default') */\r\n configName?: string;\r\n /** Agent 显示名称(可选) */\r\n name?: string;\r\n /** 系统提示词(可选,默认使用 explorer.md) */\r\n systemMessage?: string;\r\n /** Skills 目录(可选,默认使用 .agentdev/skills) */\r\n skillsDir?: string;\r\n}\r\n\r\n/**\r\n * 代码探索者 Agent\r\n *\r\n * 轻量级代码探索 Agent,专注于:\r\n * - 代码库结构分析\r\n * - 代码审查和理解\r\n * - 文档生成\r\n * - 依赖关系梳理\r\n *\r\n * 构造函数不传任何参数时,会自动同步加载配置文件创建 LLM\r\n */\r\nexport class ExplorerAgent extends Agent {\r\n protected _systemContext: SystemContext;\r\n protected _config?: AgentConfigFile;\r\n protected _skillsDir?: string;\r\n\r\n /**\r\n * 构造函数\r\n *\r\n * @param config 探索者配置(全部可选,不传则使用默认配置)\r\n */\r\n constructor(config: ExplorerAgentConfig = {}) {\r\n // 建立系统环境信息\r\n const systemContext: SystemContext = {\r\n SYSTEM_WORKING_DIR: cwd(),\r\n SYSTEM_IS_GIT_REPOSITORY: existsSync(cwd() + '/.git'),\r\n SYSTEM_PLATFORM: platform,\r\n SYSTEM_DATE: new Date().toISOString().split('T')[0], // YYYY-MM-DD\r\n SYSTEM_CURRENT_MODEL: 'unknown', // 稍后更新\r\n };\r\n\r\n // 准备 LLM:如果没传入,同步加载配置\r\n let llm = config.llm;\r\n let fileConfig: AgentConfigFile | undefined;\r\n if (!llm) {\r\n const configName = config.configName ?? 'default';\r\n fileConfig = loadConfigSync(configName);\r\n llm = createLLM(fileConfig);\r\n systemContext.SYSTEM_CURRENT_MODEL = fileConfig.defaultModel.model;\r\n console.log(`[ExplorerAgent] 已加载配置: ${configName}, 模型: ${fileConfig.defaultModel.model}`);\r\n }\r\n\r\n // 构建完整的 Agent 配置\r\n const agentConfig: AgentConfig = {\r\n llm: llm!,\r\n tools: [], // 工具由 Feature 提供\r\n maxTurns: Infinity, // 无限交互次数\r\n systemMessage: config.systemMessage,\r\n name: config.name,\r\n };\r\n\r\n super(agentConfig);\r\n\r\n // 保存配置(必须在 super() 之后)\r\n this._systemContext = systemContext;\r\n this._config = fileConfig;\r\n this._skillsDir = config.skillsDir;\r\n this.setSystemContext(systemContext);\r\n\r\n // 注册 OpencodeBasicFeature(文件操作工具集)\r\n this.use(new OpencodeBasicFeature());\r\n\r\n // 注册 SkillFeature(invokeSkill 工具和 skills 上下文注入)\r\n this.use(new SkillFeature(config.skillsDir));\r\n\r\n // 注册 SubAgentFeature(子代理工具和消息处理)\r\n this.use(new SubAgentFeature());\r\n\r\n // 预禁用只读模式下不应暴露的工具,确保首次快照与运行时一致\r\n this.getTools().disable('write');\r\n this.getTools().disable('edit');\r\n this.getTools().disable('safe_trash_delete');\r\n this.getTools().disable('safe_trash_list');\r\n this.getTools().disable('safe_trash_restore');\r\n\r\n // 注册可创建的子代理类型\r\n this.registerAgentType('ExplorerAgent', () => new ExplorerAgent({ llm: this.llm }));\r\n this.registerAgentType('BasicAgent', () => import('./BasicAgent.js').then(m => new m.BasicAgent({ llm: this.llm })));\r\n }\r\n\r\n /**\r\n * Agent 初始化钩子\r\n * 配置系统提示词,禁用写入和编辑工具(只读模式)\r\n */\r\n protected override async onInitiate(): Promise<void> {\r\n // 配置系统提示词\r\n if (!this.systemMessage) {\r\n this.setSystemPrompt(new TemplateComposer()\r\n .add({ file: '.agentdev/prompts/explorer.md' })\r\n .add('\\n\\n## 系统环境\\n\\n')\r\n .add('- 工作目录: `{{SYSTEM_WORKING_DIR}}`\\n')\r\n .add('- Git 仓库: {{SYSTEM_IS_GIT_REPOSITORY}}\\n')\r\n .add('- 操作系统: {{SYSTEM_PLATFORM}}\\n')\r\n .add('- bash版本:PowerShell 5.1\\n')\r\n .add('- 当前日期: {{SYSTEM_DATE}}\\n')\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * 获取系统环境信息\r\n */\r\n getSystemContext(): SystemContext {\r\n return this._systemContext;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,gBAAgB;AAkDvB,IAAM,gBAAN,MAAM,uBAAsB,UAAM;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,YAAY,SAA8B,CAAC,GAAG;AAE5C,UAAM,gBAA+B;AAAA,MACnC,oBAAoB,IAAI;AAAA,MACxB,0BAA0B,WAAW,IAAI,IAAI,OAAO;AAAA,MACpD,iBAAiB;AAAA,MACjB,cAAa,oBAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AAAA;AAAA,MAClD,sBAAsB;AAAA;AAAA,IACxB;AAGA,QAAI,MAAM,OAAO;AACjB,QAAI;AACJ,QAAI,CAAC,KAAK;AACR,YAAM,aAAa,OAAO,cAAc;AACxC,mBAAa,eAAe,UAAU;AACtC,YAAM,UAAU,UAAU;AAC1B,oBAAc,uBAAuB,WAAW,aAAa;AAC7D,cAAQ,IAAI,mDAA0B,UAAU,mBAAS,WAAW,aAAa,KAAK,EAAE;AAAA,IAC1F;AAGA,UAAM,cAA2B;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC;AAAA;AAAA,MACR,UAAU;AAAA;AAAA,MACV,eAAe,OAAO;AAAA,MACtB,MAAM,OAAO;AAAA,IACf;AAEA,UAAM,WAAW;AAGjB,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,aAAa,OAAO;AACzB,SAAK,iBAAiB,aAAa;AAGnC,SAAK,IAAI,IAAI,qBAAqB,CAAC;AAGnC,SAAK,IAAI,IAAI,aAAa,OAAO,SAAS,CAAC;AAG3C,SAAK,IAAI,IAAI,gBAAgB,CAAC;AAG9B,SAAK,SAAS,EAAE,QAAQ,OAAO;AAC/B,SAAK,SAAS,EAAE,QAAQ,MAAM;AAC9B,SAAK,SAAS,EAAE,QAAQ,mBAAmB;AAC3C,SAAK,SAAS,EAAE,QAAQ,iBAAiB;AACzC,SAAK,SAAS,EAAE,QAAQ,oBAAoB;AAG5C,SAAK,kBAAkB,iBAAiB,MAAM,IAAI,eAAc,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;AAClF,SAAK,kBAAkB,cAAc,MAAM,OAAO,0BAAiB,EAAE,KAAK,OAAK,IAAI,EAAE,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EACrH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAyB,aAA4B;AAEnD,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK;AAAA,QAAgB,IAAI,iBAAiB,EACvC,IAAI,EAAE,MAAM,gCAAgC,CAAC,EAC7C,IAAI,qCAAiB,EACrB,IAAI,wDAAoC,EACxC,IAAI,oDAA0C,EAC9C,IAAI,mDAA+B,EACnC,IAAI,0CAA2B,EAC/B,IAAI,+CAA2B;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,mBAAkC;AAChC,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/cli/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ViewerWorker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NORTAQIL.js";
|
|
5
5
|
import {
|
|
6
6
|
getDefaultUDSPath
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BAP2GCYH.js";
|
|
8
8
|
import "../chunk-BDS2QGZ5.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/server.ts
|
package/dist/cli/viewer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ViewerWorker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NORTAQIL.js";
|
|
5
5
|
import {
|
|
6
6
|
getDefaultUDSPath
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BAP2GCYH.js";
|
|
8
8
|
import "../chunk-BDS2QGZ5.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/viewer.ts
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/create.ts
|
|
4
|
+
import { mkdirSync, writeFileSync, existsSync as fsExistsSync } from "fs";
|
|
5
|
+
import { join, dirname } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
async function createFeature(featureName2) {
|
|
9
|
+
const packageName = featureName2.startsWith("@agentdev/") ? featureName2 : `@agentdev/${featureName2}`;
|
|
10
|
+
const featureClass = toPascalCase(featureName2.replace("@agentdev/", ""));
|
|
11
|
+
const featureSlug = toKebabCase(featureName2.replace("@agentdev/", ""));
|
|
12
|
+
const targetDir = join(process.cwd(), featureSlug);
|
|
13
|
+
if (existsSync(targetDir)) {
|
|
14
|
+
throw new Error(`Directory already exists: ${targetDir}`);
|
|
15
|
+
}
|
|
16
|
+
console.log(`Creating AgentDev Feature: ${packageName}`);
|
|
17
|
+
console.log(`Target directory: ${targetDir}`);
|
|
18
|
+
mkdirSync(join(targetDir, "src"), { recursive: true });
|
|
19
|
+
mkdirSync(join(targetDir, "src", "templates"), { recursive: true });
|
|
20
|
+
mkdirSync(join(targetDir, "scripts"), { recursive: true });
|
|
21
|
+
generatePackageJson(targetDir, packageName, featureSlug);
|
|
22
|
+
generateTsConfig(targetDir);
|
|
23
|
+
generateCopyAssetsScript(targetDir);
|
|
24
|
+
generateMinimalFeatureClass(targetDir, featureClass);
|
|
25
|
+
generateMinimalReadme(targetDir, packageName, featureSlug);
|
|
26
|
+
console.log("\n\u2705 Feature package created successfully!");
|
|
27
|
+
console.log("\nNext steps:");
|
|
28
|
+
console.log(` cd ${featureSlug}`);
|
|
29
|
+
console.log(` npm install`);
|
|
30
|
+
console.log(` # Edit src/index.ts to implement your feature`);
|
|
31
|
+
console.log(` npm run build`);
|
|
32
|
+
}
|
|
33
|
+
function generatePackageJson(targetDir, packageName, featureSlug) {
|
|
34
|
+
const packageJson = {
|
|
35
|
+
name: packageName,
|
|
36
|
+
version: "0.1.0",
|
|
37
|
+
description: `${featureSlug} feature for AgentDev`,
|
|
38
|
+
type: "module",
|
|
39
|
+
main: "dist/index.js",
|
|
40
|
+
types: "dist/index.d.ts",
|
|
41
|
+
files: ["dist", "README.md"],
|
|
42
|
+
scripts: {
|
|
43
|
+
build: "tsup && npm run copy-assets",
|
|
44
|
+
dev: "tsup --watch",
|
|
45
|
+
"copy-assets": "node scripts/copy-assets.mjs",
|
|
46
|
+
prepublishOnly: "npm run build"
|
|
47
|
+
},
|
|
48
|
+
tsup: {
|
|
49
|
+
entry: ["src/index.ts", "src/templates/*.render.ts"],
|
|
50
|
+
format: "esm",
|
|
51
|
+
dts: true,
|
|
52
|
+
clean: true,
|
|
53
|
+
sourcemap: true
|
|
54
|
+
},
|
|
55
|
+
peerDependencies: {
|
|
56
|
+
agentdev: ">=0.1.0"
|
|
57
|
+
},
|
|
58
|
+
devDependencies: {
|
|
59
|
+
"@types/node": "^20.11.0",
|
|
60
|
+
tsup: "^8.3.5",
|
|
61
|
+
typescript: "^5.3.3",
|
|
62
|
+
agentdev: "latest"
|
|
63
|
+
},
|
|
64
|
+
keywords: ["agentdev", "feature", featureSlug],
|
|
65
|
+
license: "MIT"
|
|
66
|
+
};
|
|
67
|
+
writeFileSync(join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
68
|
+
}
|
|
69
|
+
function generateTsConfig(targetDir) {
|
|
70
|
+
const tsConfig = {
|
|
71
|
+
compilerOptions: {
|
|
72
|
+
target: "ES2022",
|
|
73
|
+
module: "ES2022",
|
|
74
|
+
moduleResolution: "bundler",
|
|
75
|
+
outDir: "./dist",
|
|
76
|
+
rootDir: "./src",
|
|
77
|
+
declaration: true,
|
|
78
|
+
sourceMap: true,
|
|
79
|
+
strict: true,
|
|
80
|
+
esModuleInterop: true,
|
|
81
|
+
skipLibCheck: true,
|
|
82
|
+
forceConsistentCasingInFileNames: true,
|
|
83
|
+
resolveJsonModule: true,
|
|
84
|
+
allowSyntheticDefaultImports: true
|
|
85
|
+
},
|
|
86
|
+
include: ["src/**/*"],
|
|
87
|
+
exclude: ["node_modules", "dist"]
|
|
88
|
+
};
|
|
89
|
+
writeFileSync(join(targetDir, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
90
|
+
}
|
|
91
|
+
function generateMinimalFeatureClass(targetDir, featureClass) {
|
|
92
|
+
const className = toCamelCase(featureClass);
|
|
93
|
+
const content = `/**
|
|
94
|
+
* ${featureClass} Feature
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
import { fileURLToPath } from 'url';
|
|
98
|
+
import type {
|
|
99
|
+
AgentFeature,
|
|
100
|
+
FeatureInitContext,
|
|
101
|
+
PackageInfo,
|
|
102
|
+
} from 'agentdev';
|
|
103
|
+
import type { Tool } from 'agentdev';
|
|
104
|
+
import { getPackageInfoFromSource } from 'agentdev';
|
|
105
|
+
|
|
106
|
+
export interface ${featureClass}Config {
|
|
107
|
+
/** \u914D\u7F6E\u9009\u9879 */
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class ${featureClass} implements AgentFeature {
|
|
112
|
+
readonly name = '${className}';
|
|
113
|
+
readonly dependencies: string[] = [];
|
|
114
|
+
readonly source = fileURLToPath(import.meta.url).replace(/\\\\/g, '/');
|
|
115
|
+
readonly description = '${featureClass} feature';
|
|
116
|
+
|
|
117
|
+
private config: ${featureClass}Config;
|
|
118
|
+
private _packageInfo: PackageInfo | null = null;
|
|
119
|
+
|
|
120
|
+
constructor(config: ${featureClass}Config = {}) {
|
|
121
|
+
this.config = {
|
|
122
|
+
enabled: config.enabled ?? true,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* \u83B7\u53D6\u5305\u4FE1\u606F
|
|
128
|
+
*/
|
|
129
|
+
getPackageInfo(): PackageInfo | null {
|
|
130
|
+
if (!this._packageInfo) {
|
|
131
|
+
this._packageInfo = getPackageInfoFromSource(this.source);
|
|
132
|
+
}
|
|
133
|
+
return this._packageInfo;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* \u83B7\u53D6\u6A21\u677F\u540D\u79F0\u5217\u8868
|
|
138
|
+
*/
|
|
139
|
+
getTemplateNames(): string[] {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* \u83B7\u53D6\u5DE5\u5177\u5217\u8868
|
|
145
|
+
*/
|
|
146
|
+
getTools(): Tool[] {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* \u5F02\u6B65\u83B7\u53D6\u5DE5\u5177\u5217\u8868
|
|
152
|
+
*/
|
|
153
|
+
async getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]> {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* \u521D\u59CB\u5316
|
|
159
|
+
*/
|
|
160
|
+
async onInitiate(_ctx: FeatureInitContext): Promise<void> {
|
|
161
|
+
// TODO: Feature \u521D\u59CB\u5316\u903B\u8F91
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* \u6E05\u7406\u8D44\u6E90
|
|
166
|
+
*/
|
|
167
|
+
async onDestroy(): Promise<void> {
|
|
168
|
+
// TODO: Feature \u6E05\u7406\u903B\u8F91
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
writeFileSync(join(targetDir, "src", "index.ts"), content);
|
|
173
|
+
}
|
|
174
|
+
function generateMinimalReadme(targetDir, packageName, featureSlug) {
|
|
175
|
+
const content = `# ${packageName}
|
|
176
|
+
|
|
177
|
+
${featureSlug} feature for AgentDev.
|
|
178
|
+
|
|
179
|
+
## Installation
|
|
180
|
+
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
npm install ${packageName}
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
## Usage
|
|
186
|
+
|
|
187
|
+
\`\`\`typescript
|
|
188
|
+
import { Agent } from 'agentdev';
|
|
189
|
+
import { ${toPascalCase(featureSlug)} } from '${packageName}';
|
|
190
|
+
|
|
191
|
+
const agent = new Agent().use(new ${toPascalCase(featureSlug)}());
|
|
192
|
+
\`\`\`
|
|
193
|
+
|
|
194
|
+
## Development
|
|
195
|
+
|
|
196
|
+
\`\`\`bash
|
|
197
|
+
npm install
|
|
198
|
+
npm run build # \u6216 npm run dev \u76D1\u542C\u6A21\u5F0F
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
204
|
+
`;
|
|
205
|
+
writeFileSync(join(targetDir, "README.md"), content);
|
|
206
|
+
}
|
|
207
|
+
function generateCopyAssetsScript(targetDir) {
|
|
208
|
+
const content = `#!/usr/bin/env node
|
|
209
|
+
/**
|
|
210
|
+
* Copy non-TypeScript assets to dist directory
|
|
211
|
+
* This script automatically copies files like .py, .mp3, .json, etc.
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
import { copyFileSync, mkdirSync, readdirSync, statSync } from 'fs';
|
|
215
|
+
import { join, dirname, relative } from 'path';
|
|
216
|
+
import { fileURLToPath } from 'url';
|
|
217
|
+
|
|
218
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
219
|
+
const rootDir = join(__dirname, '..');
|
|
220
|
+
const srcDir = join(rootDir, 'src');
|
|
221
|
+
const distDir = join(rootDir, 'dist');
|
|
222
|
+
|
|
223
|
+
// Extensions to copy (non-TypeScript files)
|
|
224
|
+
const ASSET_EXTENSIONS = new Set([
|
|
225
|
+
'.mp3', '.wav', '.ogg', '.flac', // Audio
|
|
226
|
+
'.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', // Images
|
|
227
|
+
'.json', // Config files
|
|
228
|
+
'.py', '.sh', '.bash', '.zsh', // Scripts
|
|
229
|
+
'.txt', '.md', '.rst', // Docs
|
|
230
|
+
'.yml', '.yaml', '.toml', '.ini', // Config
|
|
231
|
+
'.sql', '.graphql', '.gql', // Data
|
|
232
|
+
'.html', '.css', '.scss', '.less', // Styles
|
|
233
|
+
'.wasm', '.bin', // Binary
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
function isAssetFile(filename) {
|
|
237
|
+
const idx = filename.lastIndexOf('.');
|
|
238
|
+
return idx >= 0 && ASSET_EXTENSIONS.has(filename.slice(idx).toLowerCase());
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function copyDirectory(src, dest) {
|
|
242
|
+
const entries = readdirSync(src, { withFileTypes: true });
|
|
243
|
+
|
|
244
|
+
for (const entry of entries) {
|
|
245
|
+
const srcPath = join(src, entry.name);
|
|
246
|
+
const destPath = join(dest, entry.name);
|
|
247
|
+
|
|
248
|
+
if (entry.isDirectory()) {
|
|
249
|
+
copyDirectory(srcPath, destPath);
|
|
250
|
+
} else if (entry.isFile() && isAssetFile(entry.name)) {
|
|
251
|
+
mkdirSync(dirname(destPath), { recursive: true });
|
|
252
|
+
copyFileSync(srcPath, destPath);
|
|
253
|
+
console.log(\`Copied: \${relative(rootDir, srcPath)}\`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Copy assets from src to dist
|
|
259
|
+
copyDirectory(srcDir, distDir);
|
|
260
|
+
`;
|
|
261
|
+
writeFileSync(join(targetDir, "scripts", "copy-assets.mjs"), content);
|
|
262
|
+
}
|
|
263
|
+
function toPascalCase(str) {
|
|
264
|
+
return str.replace(/(?:^|-)([a-z])/g, (_, c) => c.toUpperCase());
|
|
265
|
+
}
|
|
266
|
+
function toCamelCase(str) {
|
|
267
|
+
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
268
|
+
}
|
|
269
|
+
function toKebabCase(str) {
|
|
270
|
+
return str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
271
|
+
}
|
|
272
|
+
function existsSync(path) {
|
|
273
|
+
try {
|
|
274
|
+
return !!fsExistsSync(path);
|
|
275
|
+
} catch {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/cli.ts
|
|
281
|
+
var args = process.argv.slice(2);
|
|
282
|
+
if (args.length === 0) {
|
|
283
|
+
console.error("Usage: create-agentdev-feature <feature-name>");
|
|
284
|
+
console.error("Example: create-agentdev-feature my-feature");
|
|
285
|
+
process.exit(1);
|
|
286
|
+
}
|
|
287
|
+
var featureName = args[0];
|
|
288
|
+
createFeature(featureName).catch((error) => {
|
|
289
|
+
console.error(`Error creating feature: ${error.message}`);
|
|
290
|
+
process.exit(1);
|
|
291
|
+
});
|
|
292
|
+
//# sourceMappingURL=cli.js.map
|