developer-ai 1.0.0
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/README.md +241 -0
- package/bin/developer-ai.js +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +219 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +82 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/schema.d.ts +115 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +29 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/agent.d.ts +38 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +155 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +44 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/types.d.ts +42 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +13 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +202 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/providers/ollama.d.ts +13 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +60 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +9 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +40 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/skills/loader.d.ts +25 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +93 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/tests/tools.test.d.ts +2 -0
- package/dist/tests/tools.test.d.ts.map +1 -0
- package/dist/tests/tools.test.js +170 -0
- package/dist/tests/tools.test.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-files.d.ts +3 -0
- package/dist/tools/list-files.d.ts.map +1 -0
- package/dist/tools/list-files.js +60 -0
- package/dist/tools/list-files.js.map +1 -0
- package/dist/tools/read-file.d.ts +3 -0
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +46 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/registry.d.ts +24 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +37 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/run-command.d.ts +3 -0
- package/dist/tools/run-command.d.ts.map +1 -0
- package/dist/tools/run-command.js +114 -0
- package/dist/tools/run-command.js.map +1 -0
- package/dist/tools/search-text.d.ts +3 -0
- package/dist/tools/search-text.d.ts.map +1 -0
- package/dist/tools/search-text.js +103 -0
- package/dist/tools/search-text.js.map +1 -0
- package/dist/tools/utils.d.ts +6 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +14 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +3 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +80 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write-file.d.ts +3 -0
- package/dist/tools/write-file.d.ts.map +1 -0
- package/dist/tools/write-file.js +66 -0
- package/dist/tools/write-file.js.map +1 -0
- package/package.json +54 -0
- package/skills/accessibility/SKILL.md +496 -0
- package/skills/api-design/SKILL.md +419 -0
- package/skills/code-review/SKILL.md +267 -0
- package/skills/debugging/SKILL.md +332 -0
- package/skills/documentation/SKILL.md +496 -0
- package/skills/error-handling/SKILL.md +504 -0
- package/skills/git-workflow/SKILL.md +448 -0
- package/skills/human-like-coding/SKILL.md +400 -0
- package/skills/performance-optimization/SKILL.md +412 -0
- package/skills/prompt-engineering/SKILL.md +362 -0
- package/skills/refactoring/SKILL.md +457 -0
- package/skills/security-audit/SKILL.md +453 -0
- package/skills/testing-strategy/SKILL.md +501 -0
- package/skills/webapp-testing/SKILL.md +309 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
7
|
+
import { readFileTool } from '../tools/read-file.js';
|
|
8
|
+
import { writeFileTool } from '../tools/write-file.js';
|
|
9
|
+
import { listFilesTool } from '../tools/list-files.js';
|
|
10
|
+
import { searchTextTool } from '../tools/search-text.js';
|
|
11
|
+
import { runCommandTool } from '../tools/run-command.js';
|
|
12
|
+
import { webSearchTool } from '../tools/web-search.js';
|
|
13
|
+
import { resolveSafePath } from '../tools/utils.js';
|
|
14
|
+
import { SkillsLoader } from '../skills/loader.js';
|
|
15
|
+
// ---- Test fixtures ----
|
|
16
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'devai-test-'));
|
|
17
|
+
const ctx = {
|
|
18
|
+
workspaceDir: tmpDir,
|
|
19
|
+
confirmFn: async () => true,
|
|
20
|
+
allowDangerous: false,
|
|
21
|
+
autoYes: true,
|
|
22
|
+
};
|
|
23
|
+
// ---- Path safety ----
|
|
24
|
+
describe('resolveSafePath', () => {
|
|
25
|
+
it('resolves a relative path inside workspace', () => {
|
|
26
|
+
const result = resolveSafePath(tmpDir, 'src/index.ts');
|
|
27
|
+
assert.equal(result, path.join(tmpDir, 'src/index.ts'));
|
|
28
|
+
});
|
|
29
|
+
it('rejects paths that escape workspace', () => {
|
|
30
|
+
const result = resolveSafePath(tmpDir, '../../etc/passwd');
|
|
31
|
+
assert.equal(result, null);
|
|
32
|
+
});
|
|
33
|
+
it('rejects absolute paths outside workspace', () => {
|
|
34
|
+
const result = resolveSafePath(tmpDir, '/etc/passwd');
|
|
35
|
+
assert.equal(result, null);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
// ---- Tool registry ----
|
|
39
|
+
describe('ToolRegistry', () => {
|
|
40
|
+
it('registers and retrieves tools', () => {
|
|
41
|
+
const reg = new ToolRegistry();
|
|
42
|
+
reg.register(readFileTool);
|
|
43
|
+
assert.equal(reg.get('read_file')?.name, 'read_file');
|
|
44
|
+
assert.equal(reg.get('nonexistent'), undefined);
|
|
45
|
+
});
|
|
46
|
+
it('generates tool definitions', () => {
|
|
47
|
+
const reg = new ToolRegistry();
|
|
48
|
+
reg.register(readFileTool);
|
|
49
|
+
reg.register(writeFileTool);
|
|
50
|
+
const defs = reg.getDefinitions();
|
|
51
|
+
assert.equal(defs.length, 2);
|
|
52
|
+
assert.equal(defs[0].function.name, 'read_file');
|
|
53
|
+
assert.equal(defs[1].function.name, 'write_file');
|
|
54
|
+
});
|
|
55
|
+
it('returns error for unknown tool', async () => {
|
|
56
|
+
const reg = new ToolRegistry();
|
|
57
|
+
const result = await reg.execute('not_a_tool', {}, ctx);
|
|
58
|
+
assert.equal(result.success, false);
|
|
59
|
+
assert.ok(result.error?.includes('Unknown tool'));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
// ---- write_file ----
|
|
63
|
+
describe('write_file tool', () => {
|
|
64
|
+
it('creates a new file', async () => {
|
|
65
|
+
const result = await writeFileTool.execute({ path: 'test-write.txt', content: 'hello world', confirmOverwrite: false }, ctx);
|
|
66
|
+
assert.equal(result.success, true);
|
|
67
|
+
const content = fs.readFileSync(path.join(tmpDir, 'test-write.txt'), 'utf-8');
|
|
68
|
+
assert.equal(content, 'hello world');
|
|
69
|
+
});
|
|
70
|
+
it('creates nested directories', async () => {
|
|
71
|
+
const result = await writeFileTool.execute({ path: 'deep/nested/file.txt', content: 'nested', confirmOverwrite: false }, ctx);
|
|
72
|
+
assert.equal(result.success, true);
|
|
73
|
+
assert.ok(fs.existsSync(path.join(tmpDir, 'deep/nested/file.txt')));
|
|
74
|
+
});
|
|
75
|
+
it('rejects paths outside workspace', async () => {
|
|
76
|
+
const result = await writeFileTool.execute({ path: '../escape.txt', content: 'bad', confirmOverwrite: false }, ctx);
|
|
77
|
+
assert.equal(result.success, false);
|
|
78
|
+
assert.ok(result.error?.includes('escapes'));
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
// ---- read_file ----
|
|
82
|
+
describe('read_file tool', () => {
|
|
83
|
+
it('reads an existing file', async () => {
|
|
84
|
+
fs.writeFileSync(path.join(tmpDir, 'readable.txt'), 'content here');
|
|
85
|
+
const result = await readFileTool.execute({ path: 'readable.txt' }, ctx);
|
|
86
|
+
assert.equal(result.success, true);
|
|
87
|
+
assert.equal(result.output, 'content here');
|
|
88
|
+
});
|
|
89
|
+
it('returns error for missing file', async () => {
|
|
90
|
+
const result = await readFileTool.execute({ path: 'missing.txt' }, ctx);
|
|
91
|
+
assert.equal(result.success, false);
|
|
92
|
+
assert.ok(result.error?.includes('Cannot read'));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
// ---- list_files ----
|
|
96
|
+
describe('list_files tool', () => {
|
|
97
|
+
it('lists files in workspace', async () => {
|
|
98
|
+
const result = await listFilesTool.execute({ path: '.' }, ctx);
|
|
99
|
+
assert.equal(result.success, true);
|
|
100
|
+
assert.ok(result.output.includes('readable.txt'));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
// ---- search_text ----
|
|
104
|
+
describe('search_text tool', () => {
|
|
105
|
+
it('finds matching text', async () => {
|
|
106
|
+
fs.writeFileSync(path.join(tmpDir, 'searchme.txt'), 'finding needle here');
|
|
107
|
+
const result = await searchTextTool.execute({ query: 'needle' }, ctx);
|
|
108
|
+
assert.equal(result.success, true);
|
|
109
|
+
assert.ok(result.output.includes('needle'));
|
|
110
|
+
});
|
|
111
|
+
it('returns no matches message', async () => {
|
|
112
|
+
const result = await searchTextTool.execute({ query: 'xyznonexistent123' }, ctx);
|
|
113
|
+
assert.equal(result.success, true);
|
|
114
|
+
assert.ok(result.output.includes('No matches'));
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
// ---- run_command ----
|
|
118
|
+
describe('run_command tool', () => {
|
|
119
|
+
it('runs a safe command', async () => {
|
|
120
|
+
const result = await runCommandTool.execute({ command: 'echo hello' }, ctx);
|
|
121
|
+
assert.equal(result.success, true);
|
|
122
|
+
assert.ok(result.output.includes('hello'));
|
|
123
|
+
});
|
|
124
|
+
it('blocks dangerous commands without allowDangerous', async () => {
|
|
125
|
+
const noConfirmCtx = {
|
|
126
|
+
...ctx,
|
|
127
|
+
autoYes: false,
|
|
128
|
+
confirmFn: async () => false,
|
|
129
|
+
};
|
|
130
|
+
const result = await runCommandTool.execute({ command: 'rm -rf /', allowDangerous: false }, noConfirmCtx);
|
|
131
|
+
assert.equal(result.success, false);
|
|
132
|
+
assert.ok(result.error?.includes('blocked') || result.error?.includes('dangerous'));
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
// ---- web_search ----
|
|
136
|
+
describe('web_search tool', () => {
|
|
137
|
+
it('returns not-configured error when no keys set', async () => {
|
|
138
|
+
const result = await webSearchTool.execute({ query: 'test' }, ctx);
|
|
139
|
+
assert.equal(result.success, false);
|
|
140
|
+
assert.ok(result.error?.includes('not configured'));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
// ---- SkillsLoader ----
|
|
144
|
+
describe('SkillsLoader', () => {
|
|
145
|
+
it('loads no skills from empty dir', async () => {
|
|
146
|
+
const loader = new SkillsLoader([path.join(tmpDir, 'no-skills')]);
|
|
147
|
+
await loader.load();
|
|
148
|
+
assert.equal(loader.getAll().length, 0);
|
|
149
|
+
});
|
|
150
|
+
it('finds relevant skills by keyword', async () => {
|
|
151
|
+
const skillDir = path.join(tmpDir, 'skills-test', 'testing');
|
|
152
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
153
|
+
fs.writeFileSync(path.join(skillDir, 'SKILL.md'), '---\nname: testing-strategy\ndescription: Testing and test plans\n---\n# Testing\nWrite tests.');
|
|
154
|
+
const loader = new SkillsLoader([path.join(tmpDir, 'skills-test')]);
|
|
155
|
+
await loader.load();
|
|
156
|
+
const relevant = loader.findRelevant('write unit tests');
|
|
157
|
+
assert.ok(relevant.length > 0);
|
|
158
|
+
assert.equal(relevant[0].name, 'testing-strategy');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
// ---- Cleanup ----
|
|
162
|
+
process.on('exit', () => {
|
|
163
|
+
try {
|
|
164
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
/* best-effort */
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
//# sourceMappingURL=tools.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.test.js","sourceRoot":"","sources":["../../src/tests/tools.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,cA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AAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,oBAAoB;AAEpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;IACtB,IAAI,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAQ7C,wBAAgB,kBAAkB,IAAI,YAAY,CASjD;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ToolRegistry } from './registry.js';
|
|
2
|
+
import { readFileTool } from './read-file.js';
|
|
3
|
+
import { writeFileTool } from './write-file.js';
|
|
4
|
+
import { listFilesTool } from './list-files.js';
|
|
5
|
+
import { searchTextTool } from './search-text.js';
|
|
6
|
+
import { runCommandTool } from './run-command.js';
|
|
7
|
+
import { webSearchTool } from './web-search.js';
|
|
8
|
+
export function createToolRegistry() {
|
|
9
|
+
const registry = new ToolRegistry();
|
|
10
|
+
registry.register(readFileTool);
|
|
11
|
+
registry.register(writeFileTool);
|
|
12
|
+
registry.register(listFilesTool);
|
|
13
|
+
registry.register(searchTextTool);
|
|
14
|
+
registry.register(runCommandTool);
|
|
15
|
+
registry.register(webSearchTool);
|
|
16
|
+
return registry;
|
|
17
|
+
}
|
|
18
|
+
export { ToolRegistry } from './registry.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,kBAAkB;IAChC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.d.ts","sourceRoot":"","sources":["../../src/tools/list-files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAQ9D,eAAO,MAAM,aAAa,EAAE,WAyD3B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { glob } from 'glob';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const schema = z.object({
|
|
5
|
+
path: z.string().default('.'),
|
|
6
|
+
pattern: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
export const listFilesTool = {
|
|
9
|
+
name: 'list_files',
|
|
10
|
+
description: 'List files under a directory (workspace-relative). ' +
|
|
11
|
+
'Optionally filter with a glob pattern. Excludes node_modules, .git, dist by default.',
|
|
12
|
+
schema,
|
|
13
|
+
jsonSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
path: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Directory path relative to workspace (default: ".")',
|
|
19
|
+
},
|
|
20
|
+
pattern: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'Glob pattern to filter results (default: "**/*")',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
required: ['path'],
|
|
26
|
+
},
|
|
27
|
+
async execute(input, ctx) {
|
|
28
|
+
const { path: dirPath, pattern } = schema.parse(input);
|
|
29
|
+
const dir = path.resolve(ctx.workspaceDir, dirPath);
|
|
30
|
+
if (!dir.startsWith(ctx.workspaceDir + path.sep) &&
|
|
31
|
+
dir !== ctx.workspaceDir) {
|
|
32
|
+
return { success: false, output: '', error: 'Path escapes workspace directory' };
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const globPattern = pattern ?? '**/*';
|
|
36
|
+
const files = await glob(globPattern, {
|
|
37
|
+
cwd: dir,
|
|
38
|
+
nodir: false,
|
|
39
|
+
dot: false,
|
|
40
|
+
ignore: ['node_modules/**', '.git/**', 'dist/**'],
|
|
41
|
+
maxDepth: 5,
|
|
42
|
+
});
|
|
43
|
+
const sorted = files.sort();
|
|
44
|
+
const limited = sorted.slice(0, 300);
|
|
45
|
+
let output = limited.join('\n');
|
|
46
|
+
if (sorted.length > 300) {
|
|
47
|
+
output += `\n... and ${sorted.length - 300} more files`;
|
|
48
|
+
}
|
|
49
|
+
return { success: true, output: output || '(empty directory)' };
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
output: '',
|
|
55
|
+
error: `Cannot list directory: ${err.message}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=list-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.js","sourceRoot":"","sources":["../../src/tools/list-files.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,qDAAqD;QACrD,sFAAsF;IACxF,MAAM;IACN,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qDAAqD;aACnE;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kDAAkD;aAChE;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;IAED,KAAK,CAAC,OAAO,CAAC,KAAc,EAAE,GAAgB;QAC5C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,M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,CAAC,OAAO,EAAE;aAC1D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAS9D,eAAO,MAAM,YAAY,EAAE,WAuC1B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { resolveSafePath } from './utils.js';
|
|
4
|
+
import { MAX_FILE_SIZE } from '../constants.js';
|
|
5
|
+
const schema = z.object({
|
|
6
|
+
path: z.string().describe('Workspace-relative file path'),
|
|
7
|
+
});
|
|
8
|
+
export const readFileTool = {
|
|
9
|
+
name: 'read_file',
|
|
10
|
+
description: 'Read a text file from the workspace. Path is relative to workspace root.',
|
|
11
|
+
schema,
|
|
12
|
+
jsonSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
path: { type: 'string', description: 'Workspace-relative file path' },
|
|
16
|
+
},
|
|
17
|
+
required: ['path'],
|
|
18
|
+
},
|
|
19
|
+
async execute(input, ctx) {
|
|
20
|
+
const { path: filePath } = schema.parse(input);
|
|
21
|
+
const resolved = resolveSafePath(ctx.workspaceDir, filePath);
|
|
22
|
+
if (!resolved) {
|
|
23
|
+
return { success: false, output: '', error: 'Path escapes workspace directory' };
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const stat = await fs.stat(resolved);
|
|
27
|
+
if (stat.size > MAX_FILE_SIZE) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
output: '',
|
|
31
|
+
error: `File too large (${(stat.size / 1024).toFixed(0)} KB). Max: ${MAX_FILE_SIZE / 1024} KB`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const content = await fs.readFile(resolved, 'utf-8');
|
|
35
|
+
return { success: true, output: content };
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
output: '',
|
|
41
|
+
error: `Cannot read file: ${err.message}`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=read-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;CAC1D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,0EAA0E;IAC5E,MAAM;IACN,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8BAA8B,EAAE;SACtE;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;IAED,KAAK,CAAC,OAAO,CAAC,KAAc,EAAE,GAAgB;QAC5C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,kCAAkC,EAAE,CAAC;QACnF,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,IAAI,GAAG,aAAa,EAAE,CAAC;gBAC9B,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,aAAa,GAAG,IAAI,KAAK;iBAC/F,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,qBAAsB,GAAa,CAAC,OAAO,EAAE;aACrD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolResult } from '../core/types.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
export interface ToolHandler {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: z.ZodType;
|
|
7
|
+
jsonSchema: Record<string, unknown>;
|
|
8
|
+
execute(input: unknown, context: ToolContext): Promise<ToolResult>;
|
|
9
|
+
}
|
|
10
|
+
export interface ToolContext {
|
|
11
|
+
workspaceDir: string;
|
|
12
|
+
confirmFn: (message: string) => Promise<boolean>;
|
|
13
|
+
allowDangerous: boolean;
|
|
14
|
+
autoYes: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class ToolRegistry {
|
|
17
|
+
private tools;
|
|
18
|
+
register(handler: ToolHandler): void;
|
|
19
|
+
get(name: string): ToolHandler | undefined;
|
|
20
|
+
getDefinitions(): ToolDefinition[];
|
|
21
|
+
execute(name: string, input: unknown, context: ToolContext): Promise<ToolResult>;
|
|
22
|
+
listNames(): string[];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAkC;IAE/C,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI1C,cAAc,IAAI,cAAc,EAAE;IAW5B,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;IAetB,SAAS,IAAI,MAAM,EAAE;CAGtB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ToolRegistry {
|
|
2
|
+
tools = new Map();
|
|
3
|
+
register(handler) {
|
|
4
|
+
this.tools.set(handler.name, handler);
|
|
5
|
+
}
|
|
6
|
+
get(name) {
|
|
7
|
+
return this.tools.get(name);
|
|
8
|
+
}
|
|
9
|
+
getDefinitions() {
|
|
10
|
+
return Array.from(this.tools.values()).map((t) => ({
|
|
11
|
+
type: 'function',
|
|
12
|
+
function: {
|
|
13
|
+
name: t.name,
|
|
14
|
+
description: t.description,
|
|
15
|
+
parameters: t.jsonSchema,
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
async execute(name, input, context) {
|
|
20
|
+
const handler = this.tools.get(name);
|
|
21
|
+
if (!handler) {
|
|
22
|
+
return { success: false, output: '', error: `Unknown tool: ${name}` };
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const validated = handler.schema.parse(input);
|
|
26
|
+
return await handler.execute(validated, context);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
30
|
+
return { success: false, output: '', error: `Tool "${name}" error: ${msg}` };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
listNames() {
|
|
34
|
+
return Array.from(this.tools.keys());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,YAAY;IACf,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/C,QAAQ,CAAC,OAAoB;QAC3B,IAAI,CAAC,KAAK,CAA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AY,GAAG,EAAE,EAAE,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/tools/run-command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAgD9D,eAAO,MAAM,cAAc,EAAE,WA8E5B,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { COMMAND_TIMEOUT_MS, MAX_OUTPUT_LENGTH } from '../constants.js';
|
|
5
|
+
/** Commands that run without asking the user. */
|
|
6
|
+
const SAFE_COMMANDS = new Set([
|
|
7
|
+
'ls', 'cat', 'head', 'tail', 'wc', 'find', 'grep', 'echo', 'pwd', 'stat',
|
|
8
|
+
'node', 'npm', 'npx', 'tsc', 'python', 'python3', 'pip', 'pip3',
|
|
9
|
+
'git', 'which', 'date', 'tree', 'file', 'diff', 'du',
|
|
10
|
+
'sort', 'uniq', 'cut', 'tr', 'sed', 'awk', 'jq',
|
|
11
|
+
'open', // macOS
|
|
12
|
+
'xdg-open', // Linux
|
|
13
|
+
'mkdir',
|
|
14
|
+
]);
|
|
15
|
+
/** Patterns that are always considered dangerous. */
|
|
16
|
+
const DANGEROUS_PATTERNS = [
|
|
17
|
+
/\brm\s+.*-[a-z]*[rf]/i,
|
|
18
|
+
/\bmkfs\b/i,
|
|
19
|
+
/\bdd\s+if=/i,
|
|
20
|
+
/:\s*\(\)\s*\{/, // fork bomb
|
|
21
|
+
/\bcurl\b.*\|\s*(sh|bash|zsh)\b/i,
|
|
22
|
+
/\bwget\b.*\|\s*(sh|bash|zsh)\b/i,
|
|
23
|
+
/\bchmod\s+777\b/i,
|
|
24
|
+
/>\s*\/dev\//i,
|
|
25
|
+
/\bformat\s+[a-z]:/i,
|
|
26
|
+
/\bsudo\s+(rm|mkfs|dd|chmod|chown)\b/i,
|
|
27
|
+
];
|
|
28
|
+
function baseCommand(command) {
|
|
29
|
+
const firstWord = command.trim().split(/\s+/)[0] ?? '';
|
|
30
|
+
return path.basename(firstWord);
|
|
31
|
+
}
|
|
32
|
+
function isSafe(command) {
|
|
33
|
+
return SAFE_COMMANDS.has(baseCommand(command));
|
|
34
|
+
}
|
|
35
|
+
function isDangerous(command) {
|
|
36
|
+
return DANGEROUS_PATTERNS.some((p) => p.test(command));
|
|
37
|
+
}
|
|
38
|
+
const schema = z.object({
|
|
39
|
+
command: z.string(),
|
|
40
|
+
cwd: z.string().optional(),
|
|
41
|
+
allowDangerous: z.boolean().optional().default(false),
|
|
42
|
+
});
|
|
43
|
+
export const runCommandTool = {
|
|
44
|
+
name: 'run_command',
|
|
45
|
+
description: 'Run a shell command in the workspace. Safe commands (ls, cat, npm, git, node, etc.) ' +
|
|
46
|
+
'run automatically. Other commands require confirmation. Dangerous commands are blocked unless ' +
|
|
47
|
+
'explicitly allowed.',
|
|
48
|
+
schema,
|
|
49
|
+
jsonSchema: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
command: { type: 'string', description: 'Shell command to execute' },
|
|
53
|
+
cwd: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Working directory relative to workspace (default: workspace root)',
|
|
56
|
+
},
|
|
57
|
+
allowDangerous: {
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
description: 'Explicitly allow dangerous commands',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ['command'],
|
|
63
|
+
},
|
|
64
|
+
async execute(input, ctx) {
|
|
65
|
+
const { command, cwd, allowDangerous } = schema.parse(input);
|
|
66
|
+
const workDir = cwd
|
|
67
|
+
? path.resolve(ctx.workspaceDir, cwd)
|
|
68
|
+
: ctx.workspaceDir;
|
|
69
|
+
if (!workDir.startsWith(ctx.workspaceDir + path.sep) &&
|
|
70
|
+
workDir !== ctx.workspaceDir) {
|
|
71
|
+
return { success: false, output: '', error: 'Working directory escapes workspace' };
|
|
72
|
+
}
|
|
73
|
+
// Safety gates
|
|
74
|
+
if (isDangerous(command)) {
|
|
75
|
+
if (!allowDangerous && !ctx.allowDangerous) {
|
|
76
|
+
const confirmed = await ctx.confirmFn(`⚠️ Potentially dangerous command:\n ${command}\nAllow execution?`);
|
|
77
|
+
if (!confirmed) {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
output: '',
|
|
81
|
+
error: 'Command blocked: flagged as dangerous. Use --allow-dangerous or confirm.',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (!isSafe(command) && !ctx.autoYes) {
|
|
87
|
+
const confirmed = await ctx.confirmFn(`Run command?\n ${command}`);
|
|
88
|
+
if (!confirmed) {
|
|
89
|
+
return { success: false, output: '', error: 'Command cancelled by user' };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const stdout = execSync(command, {
|
|
94
|
+
cwd: workDir,
|
|
95
|
+
encoding: 'utf-8',
|
|
96
|
+
timeout: COMMAND_TIMEOUT_MS,
|
|
97
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
98
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
99
|
+
});
|
|
100
|
+
return { success: true, output: stdout.slice(0, MAX_OUTPUT_LENGTH) };
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
const e = err;
|
|
104
|
+
const stderr = (e.stderr ?? '').slice(0, MAX_OUTPUT_LENGTH / 2);
|
|
105
|
+
const stdout = (e.stdout ?? '').slice(0, MAX_OUTPUT_LENGTH / 2);
|
|
106
|
+
return {
|
|
107
|
+
success: false,
|
|
108
|
+
output: stdout,
|
|
109
|
+
error: `Exit code ${e.status ?? 1}: ${stderr}`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=run-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../../src/tools/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAExE,iDAAiD;AACjD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IACxE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;IAC/D,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IACpD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI;IAC/C,MAAM,EAAQ,QAAQ;IACtB,UAAU,EAAI,QAAQ;IACtB,OAAO;CACR,CAAC,CAAC;AAEH,qDAAqD;AACrD,MAAM,kBAAkB,GAAG;IACzB,uBAAuB;IACvB,WAAW;IACX,aAAa;IACb,eAAe,EAAyB,YAAY;IACpD,iCAAiC;IACjC,iCAAiC;IACjC,kBAAkB;IAClB,cAAc;IACd,oBAAoB;IACpB,sCAAsC;CACvC,CAAC;AAEF,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,SAAS,GAAG,OAAO,CAA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