@migor/cli 0.0.1
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/cli.js +79 -0
- package/dist/create.js +35 -0
- package/dist/generate.js +49 -0
- package/dist/registry.js +34 -0
- package/dist/templates.js +227 -0
- package/package.json +22 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** agentia CLI 入口:手写参数解析 + 命令分发(零依赖) */
|
|
3
|
+
import { createProject } from './create.js';
|
|
4
|
+
import { generateUnit } from './generate.js';
|
|
5
|
+
import { isUnitType, isValidName, UNIT_TYPES } from './templates.js';
|
|
6
|
+
import { RegistryError } from './registry.js';
|
|
7
|
+
const USAGE = `agentia —— Agentia 框架命令行工具
|
|
8
|
+
|
|
9
|
+
用法:
|
|
10
|
+
agentia create <name> [--dir <parent>] 创建项目脚手架(目录 <parent|当前目录>/<name>/)
|
|
11
|
+
agentia g <type> <name> 在当前目录生成单元(别名:generate)
|
|
12
|
+
type: ${UNIT_TYPES.join(' | ')}
|
|
13
|
+
agentia --help 显示本帮助
|
|
14
|
+
|
|
15
|
+
name 规则:小写字母开头的小写 kebab-case(如 hello、doc-reviewer)
|
|
16
|
+
`;
|
|
17
|
+
function fail(message) {
|
|
18
|
+
console.error(`错误:${message}`);
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
function checkName(name) {
|
|
23
|
+
if (name === undefined)
|
|
24
|
+
return false;
|
|
25
|
+
return isValidName(name);
|
|
26
|
+
}
|
|
27
|
+
function main(argv) {
|
|
28
|
+
const [command, ...rest] = argv;
|
|
29
|
+
if (command === undefined || command === '--help' || command === '-h') {
|
|
30
|
+
console.log(USAGE);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
if (command === 'create') {
|
|
34
|
+
const name = rest[0];
|
|
35
|
+
let parent;
|
|
36
|
+
for (let i = 1; i < rest.length; i += 1) {
|
|
37
|
+
if (rest[i] === '--dir') {
|
|
38
|
+
parent = rest[i + 1];
|
|
39
|
+
if (parent === undefined)
|
|
40
|
+
return fail('--dir 需要一个目录参数');
|
|
41
|
+
i += 1;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return fail(`未知参数:${rest[i]}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (name === undefined)
|
|
48
|
+
return fail('缺少项目名,用法:agentia create <name> [--dir <parent>]');
|
|
49
|
+
if (!checkName(name)) {
|
|
50
|
+
return fail(`非法项目名「${name}」:需匹配小写 kebab-case(如 my-app)`);
|
|
51
|
+
}
|
|
52
|
+
return createProject(name, parent);
|
|
53
|
+
}
|
|
54
|
+
if (command === 'g' || command === 'generate') {
|
|
55
|
+
const [type, name, ...extra] = rest;
|
|
56
|
+
if (type === undefined || name === undefined || extra.length > 0) {
|
|
57
|
+
return fail('用法:agentia g <type> <name>(type: tool | skill | prompt | subagent)');
|
|
58
|
+
}
|
|
59
|
+
if (!isUnitType(type)) {
|
|
60
|
+
return fail(`未知单元类型「${type}」,可选:${UNIT_TYPES.join(' | ')}`);
|
|
61
|
+
}
|
|
62
|
+
if (!checkName(name)) {
|
|
63
|
+
return fail(`非法单元名「${name}」:需匹配小写 kebab-case(如 doc-reviewer)`);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return generateUnit(type, name);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (err instanceof RegistryError)
|
|
70
|
+
return fail(err.message);
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
console.error(`错误:未知命令「${command}」\n`);
|
|
75
|
+
console.error(USAGE);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
process.exitCode = main(process.argv.slice(2));
|
package/dist/create.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** create 命令:生成 Agentia 项目脚手架 */
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { mainTs, projectGitignore, projectPackageJson, projectReadme, projectTsconfig, toolIndexTs, emptyRegistryTemplate, } from './templates.js';
|
|
5
|
+
import { registerUnit } from './registry.js';
|
|
6
|
+
function write(dir, rel, content) {
|
|
7
|
+
const file = join(dir, rel);
|
|
8
|
+
mkdirSync(join(file, '..'), { recursive: true });
|
|
9
|
+
writeFileSync(file, content, 'utf8');
|
|
10
|
+
}
|
|
11
|
+
export function createProject(name, parent) {
|
|
12
|
+
const dir = resolve(parent ?? process.cwd(), name);
|
|
13
|
+
if (existsSync(dir) && readdirSync(dir).length > 0) {
|
|
14
|
+
console.error(`错误:目录 ${dir} 已存在且非空`);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
mkdirSync(dir, { recursive: true });
|
|
19
|
+
write(dir, 'package.json', projectPackageJson(name));
|
|
20
|
+
write(dir, 'tsconfig.json', projectTsconfig());
|
|
21
|
+
write(dir, 'src/main.ts', mainTs(name));
|
|
22
|
+
write(dir, 'units/hello/index.ts', toolIndexTs('hello'));
|
|
23
|
+
write(dir, 'units.ts', emptyRegistryTemplate());
|
|
24
|
+
write(dir, 'README.md', projectReadme(name));
|
|
25
|
+
write(dir, '.gitignore', projectGitignore());
|
|
26
|
+
registerUnit(dir, 'hello');
|
|
27
|
+
console.log(`已创建项目 ${dir}
|
|
28
|
+
|
|
29
|
+
后续步骤:
|
|
30
|
+
cd ${dir}
|
|
31
|
+
npm install
|
|
32
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
33
|
+
npm run dev`);
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** g / generate 命令:在 cwd 生成 units/<name>/ 单元并登记注册表 */
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { promptAssetMd, promptIndexTs, skillIndexTs, subagentIndexTs, subagentSystemMd, toolIndexTs, } from './templates.js';
|
|
5
|
+
import { ensureRegistry, registerUnit } from './registry.js';
|
|
6
|
+
export function generateUnit(type, name) {
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const unitDir = join(cwd, 'units', name);
|
|
9
|
+
if (existsSync(unitDir)) {
|
|
10
|
+
console.error(`错误:units/${name}/ 已存在`);
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
mkdirSync(unitDir, { recursive: true });
|
|
15
|
+
const files = [];
|
|
16
|
+
const put = (rel, content) => {
|
|
17
|
+
writeFileSync(join(unitDir, rel), content, 'utf8');
|
|
18
|
+
files.push(`units/${name}/${rel}`);
|
|
19
|
+
};
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'tool':
|
|
22
|
+
put('index.ts', toolIndexTs(name));
|
|
23
|
+
break;
|
|
24
|
+
case 'prompt':
|
|
25
|
+
put('index.ts', promptIndexTs(name));
|
|
26
|
+
put('asset.md', promptAssetMd(name));
|
|
27
|
+
break;
|
|
28
|
+
case 'subagent':
|
|
29
|
+
put('index.ts', subagentIndexTs(name));
|
|
30
|
+
put('system.md', subagentSystemMd(name));
|
|
31
|
+
break;
|
|
32
|
+
case 'skill':
|
|
33
|
+
put('index.ts', skillIndexTs(name));
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
ensureRegistry(cwd);
|
|
37
|
+
const result = registerUnit(cwd, name);
|
|
38
|
+
console.log(`已生成 ${type} 单元:`);
|
|
39
|
+
for (const f of files)
|
|
40
|
+
console.log(` ${f}`);
|
|
41
|
+
if (result === 'registered') {
|
|
42
|
+
console.log(`已登记到 units.ts:{ provide: '${name}' }`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(`units.ts 中「${name}」已注册,跳过登记`);
|
|
46
|
+
}
|
|
47
|
+
console.log('提示:discover 目录扫描路线下无需登记即可生效;显式装配路线从 units.ts 引入 providers');
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** units.ts 注册表 codemod:基于 @agentia 标记行插入/跳过条目,幂等 */
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { IMPORTS_END_MARKER, ENTRIES_END_MARKER, emptyRegistryTemplate, kebabToPascal, } from './templates.js';
|
|
5
|
+
export class RegistryError extends Error {
|
|
6
|
+
}
|
|
7
|
+
/** 注册表文件不存在时按空模板创建 */
|
|
8
|
+
export function ensureRegistry(dir) {
|
|
9
|
+
const file = join(dir, 'units.ts');
|
|
10
|
+
if (!existsSync(file)) {
|
|
11
|
+
writeFileSync(file, emptyRegistryTemplate(), 'utf8');
|
|
12
|
+
}
|
|
13
|
+
return file;
|
|
14
|
+
}
|
|
15
|
+
/** 把单元登记进 dir/units.ts;已存在同名条目则跳过。标记行缺失时报错。 */
|
|
16
|
+
export function registerUnit(dir, name) {
|
|
17
|
+
const file = ensureRegistry(dir);
|
|
18
|
+
const content = readFileSync(file, 'utf8');
|
|
19
|
+
const importLine = `import ${kebabToPascal(name)} from './units/${name}/index.js';`;
|
|
20
|
+
const entryLine = ` { provide: '${name}', useClass: ${kebabToPascal(name)} },`;
|
|
21
|
+
if (content.includes(`'./units/${name}/index.js'`) || content.includes(`provide: '${name}'`)) {
|
|
22
|
+
return 'already';
|
|
23
|
+
}
|
|
24
|
+
const lines = content.split('\n');
|
|
25
|
+
const importsEnd = lines.findIndex((l) => l.trim() === IMPORTS_END_MARKER);
|
|
26
|
+
const entriesEnd = lines.findIndex((l) => l.trim() === ENTRIES_END_MARKER);
|
|
27
|
+
if (importsEnd === -1 || entriesEnd === -1) {
|
|
28
|
+
throw new RegistryError(`units.ts 缺少 ${IMPORTS_END_MARKER} / ${ENTRIES_END_MARKER} 标记行,无法自动登记;请手工维护该文件`);
|
|
29
|
+
}
|
|
30
|
+
lines.splice(entriesEnd, 0, entryLine);
|
|
31
|
+
lines.splice(importsEnd, 0, importLine);
|
|
32
|
+
writeFileSync(file, lines.join('\n'), 'utf8');
|
|
33
|
+
return 'registered';
|
|
34
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/** 命名工具与所有文件模板(零依赖) */
|
|
2
|
+
const NAME_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
3
|
+
export function isValidName(name) {
|
|
4
|
+
return NAME_RE.test(name);
|
|
5
|
+
}
|
|
6
|
+
/** hello-world → HelloWorld */
|
|
7
|
+
export function kebabToPascal(name) {
|
|
8
|
+
return name
|
|
9
|
+
.split('-')
|
|
10
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
11
|
+
.join('');
|
|
12
|
+
}
|
|
13
|
+
/** hello-world → hello_world */
|
|
14
|
+
export function kebabToSnake(name) {
|
|
15
|
+
return name.replace(/-/g, '_');
|
|
16
|
+
}
|
|
17
|
+
export const UNIT_TYPES = ['tool', 'skill', 'prompt', 'subagent'];
|
|
18
|
+
export function isUnitType(value) {
|
|
19
|
+
return UNIT_TYPES.includes(value);
|
|
20
|
+
}
|
|
21
|
+
// ---------- units.ts 注册表模板 ----------
|
|
22
|
+
export const IMPORTS_END_MARKER = '// @agentia:imports-end';
|
|
23
|
+
export const ENTRIES_END_MARKER = '// @agentia:entries-end';
|
|
24
|
+
/** 空注册表模板(无任何单元条目) */
|
|
25
|
+
export function emptyRegistryTemplate() {
|
|
26
|
+
return `// Agentia 单元注册表 —— 由 agentia CLI 维护(agentia g 自动更新,也可手工编辑)
|
|
27
|
+
// @agentia:imports
|
|
28
|
+
${IMPORTS_END_MARKER}
|
|
29
|
+
import type { Provider } from '@migor/agentia';
|
|
30
|
+
|
|
31
|
+
/** 显式装配路线:createApp({ providers, system: ... })(与 discover 目录扫描二选一或混用) */
|
|
32
|
+
export const providers: Provider[] = [
|
|
33
|
+
// @agentia:entries
|
|
34
|
+
${ENTRIES_END_MARKER}
|
|
35
|
+
];
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
// ---------- create 命令模板 ----------
|
|
39
|
+
export function projectPackageJson(name) {
|
|
40
|
+
return `${JSON.stringify({
|
|
41
|
+
name,
|
|
42
|
+
private: true,
|
|
43
|
+
type: 'module',
|
|
44
|
+
scripts: {
|
|
45
|
+
dev: 'tsx src/main.ts',
|
|
46
|
+
typecheck: 'tsc --noEmit -p tsconfig.json',
|
|
47
|
+
},
|
|
48
|
+
dependencies: { '@migor/agentia': '^0.0.1' },
|
|
49
|
+
devDependencies: {
|
|
50
|
+
tsx: '^4.19.0',
|
|
51
|
+
typescript: '^7.0.2',
|
|
52
|
+
'@types/node': '^22.0.0',
|
|
53
|
+
},
|
|
54
|
+
}, null, 2)}\n`;
|
|
55
|
+
}
|
|
56
|
+
export function projectTsconfig() {
|
|
57
|
+
return `${JSON.stringify({
|
|
58
|
+
compilerOptions: {
|
|
59
|
+
target: 'ES2022',
|
|
60
|
+
module: 'NodeNext',
|
|
61
|
+
moduleResolution: 'NodeNext',
|
|
62
|
+
lib: ['ES2022'],
|
|
63
|
+
strict: true,
|
|
64
|
+
esModuleInterop: true,
|
|
65
|
+
skipLibCheck: true,
|
|
66
|
+
},
|
|
67
|
+
include: ['src', 'units.ts'],
|
|
68
|
+
}, null, 2)}\n`;
|
|
69
|
+
}
|
|
70
|
+
export function mainTs(name) {
|
|
71
|
+
return `import { createApp, SystemPrompt } from '@migor/agentia';
|
|
72
|
+
|
|
73
|
+
const app = await createApp({
|
|
74
|
+
name: '${name}',
|
|
75
|
+
discover: 'units', // 目录约定:units/<name>/ 一单元一文件夹,启动期扫描装配
|
|
76
|
+
system: new SystemPrompt().add('role', '你是 ${name} 的主 agent,按任务自主调度菜单里的单元。', true),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const { result } = await app.run(
|
|
80
|
+
[{ role: 'user', content: process.argv[2] ?? '介绍一下你自己' }],
|
|
81
|
+
);
|
|
82
|
+
console.log(result.finalText);
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
export function projectReadme(name) {
|
|
86
|
+
return `# ${name}
|
|
87
|
+
|
|
88
|
+
基于 [Agentia](https://github.com/) 框架的 agent 应用。
|
|
89
|
+
|
|
90
|
+
## 目录约定
|
|
91
|
+
|
|
92
|
+
\`units/<name>/\` 一单元一文件夹,每个单元是一个 default export 的类,用装饰器声明能力:
|
|
93
|
+
|
|
94
|
+
- \`@Tool\` 工具:主 agent 可调用(input → value)
|
|
95
|
+
- \`@Skill\` 技能:方法体内通过 \`ctx.llm()\` 调 LLM
|
|
96
|
+
- \`@SubAgent\` 子代理:按 system 角色设定独立跑一轮
|
|
97
|
+
- \`@Prompt\` 文本资产:.md 文件,按需拉取进上下文
|
|
98
|
+
|
|
99
|
+
## 两条装配路线
|
|
100
|
+
|
|
101
|
+
1. **目录扫描**:\`createApp({ discover: 'units' })\` 启动期扫描 \`units/*/index.ts\`,default export 为类时以文件夹名为 DI token 注册(见 \`src/main.ts\`)。
|
|
102
|
+
2. **显式装配**:\`createApp({ providers, system })\`,providers 来自 \`units.ts\` 注册表(由 \`agentia g\` 自动维护,也可手工编辑)。
|
|
103
|
+
|
|
104
|
+
两者二选一或混用。
|
|
105
|
+
|
|
106
|
+
## 生成单元
|
|
107
|
+
|
|
108
|
+
\`\`\`bash
|
|
109
|
+
agentia g tool my-tool # 工具
|
|
110
|
+
agentia g skill my-skill # 技能
|
|
111
|
+
agentia g prompt my-prompt # 文本资产(含 asset.md)
|
|
112
|
+
agentia g subagent my-agent # 子代理(含 system.md)
|
|
113
|
+
\`\`\`
|
|
114
|
+
|
|
115
|
+
生成的单元在 \`units/<name>/\`,并自动登记到 \`units.ts\`。
|
|
116
|
+
|
|
117
|
+
## 运行
|
|
118
|
+
|
|
119
|
+
需要 Anthropic API key:
|
|
120
|
+
|
|
121
|
+
\`\`\`bash
|
|
122
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
123
|
+
npm run dev -- "你的问题"
|
|
124
|
+
\`\`\`
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
export function projectGitignore() {
|
|
128
|
+
return `node_modules
|
|
129
|
+
dist
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
// ---------- g 命令单元模板 ----------
|
|
133
|
+
export function toolIndexTs(name) {
|
|
134
|
+
const cls = kebabToPascal(name);
|
|
135
|
+
const method = kebabToSnake(name);
|
|
136
|
+
return `import { Tool } from '@migor/agentia';
|
|
137
|
+
|
|
138
|
+
/** ${name} 工具单元 */
|
|
139
|
+
export default class ${cls} {
|
|
140
|
+
@Tool({
|
|
141
|
+
description: '示例工具:回显输入',
|
|
142
|
+
schema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: { text: { type: 'string' } },
|
|
145
|
+
required: ['text'],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
},
|
|
148
|
+
strict: true,
|
|
149
|
+
})
|
|
150
|
+
${method}(input: { text: string }): string {
|
|
151
|
+
return \`echo: \${input.text}\`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
export function promptIndexTs(name) {
|
|
157
|
+
const cls = kebabToPascal(name);
|
|
158
|
+
const method = kebabToSnake(name);
|
|
159
|
+
return `import { Prompt, asset } from '@migor/agentia';
|
|
160
|
+
|
|
161
|
+
/** ${name} 文本资产单元 */
|
|
162
|
+
export default class ${cls} {
|
|
163
|
+
@Prompt({ description: '${name} 文本资产(描述何时该拉取)' })
|
|
164
|
+
${method}(): string {
|
|
165
|
+
return asset(import.meta.url, './asset.md');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
export function promptAssetMd(name) {
|
|
171
|
+
return `# ${name}
|
|
172
|
+
|
|
173
|
+
在此编写提示文本资产(按需被主 agent 拉取进上下文)。
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
export function subagentIndexTs(name) {
|
|
177
|
+
const cls = kebabToPascal(name);
|
|
178
|
+
const method = kebabToSnake(name);
|
|
179
|
+
return `import { SubAgent, asset } from '@migor/agentia';
|
|
180
|
+
|
|
181
|
+
/** ${name} 子代理单元 */
|
|
182
|
+
export default class ${cls} {
|
|
183
|
+
@SubAgent({
|
|
184
|
+
description: '示例子代理:按 system.md 的角色设定独立处理任务',
|
|
185
|
+
schema: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: { task: { type: 'string' } },
|
|
188
|
+
required: ['task'],
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
},
|
|
191
|
+
system: asset(import.meta.url, './system.md'),
|
|
192
|
+
})
|
|
193
|
+
// 方法体不会执行:@SubAgent 只读取方法名与装饰器元数据,调用时由框架按 system 另起 agent 执行
|
|
194
|
+
${method}(_input: { task: string }): void {}
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
export function subagentSystemMd(name) {
|
|
199
|
+
return `# ${name}
|
|
200
|
+
|
|
201
|
+
在此编写子代理的角色描述(作为其子 agent 的 system prompt)。
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
export function skillIndexTs(name) {
|
|
205
|
+
const cls = kebabToPascal(name);
|
|
206
|
+
const method = kebabToSnake(name);
|
|
207
|
+
return `import { Skill } from '@migor/agentia';
|
|
208
|
+
import type { SkillContext } from '@migor/agentia';
|
|
209
|
+
|
|
210
|
+
/** ${name} 技能单元 */
|
|
211
|
+
export default class ${cls} {
|
|
212
|
+
@Skill({
|
|
213
|
+
description: '示例技能:就给定主题调用 LLM 产出要点',
|
|
214
|
+
schema: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
properties: { topic: { type: 'string' } },
|
|
217
|
+
required: ['topic'],
|
|
218
|
+
additionalProperties: false,
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
async ${method}(input: { topic: string }, ctx: SkillContext): Promise<string> {
|
|
222
|
+
const r = await ctx.llm({ prompt: \`就「\${input.topic}」给出三个要点\` });
|
|
223
|
+
return r.text;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@migor/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Agentia 框架命令行工具:create 脚手架 + g 单元生成器",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agentia": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": ["dist"],
|
|
10
|
+
"repository": "retrychx/agentia",
|
|
11
|
+
"keywords": ["agentia", "agent", "cli", "scaffold"],
|
|
12
|
+
"engines": { "node": ">=18" },
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^22.0.2",
|
|
20
|
+
"typescript": "^7.0.2"
|
|
21
|
+
}
|
|
22
|
+
}
|