aws-runtime-bridge 1.9.32 → 1.9.40
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/adapter/AcodeSdkAdapter.d.ts +35 -1
- package/dist/adapter/AcodeSdkAdapter.d.ts.map +1 -1
- package/dist/adapter/AcodeSdkAdapter.js +417 -40
- package/dist/adapter/ClaudeSdkAdapter.d.ts +6 -0
- package/dist/adapter/ClaudeSdkAdapter.d.ts.map +1 -1
- package/dist/adapter/ClaudeSdkAdapter.js +23 -1
- package/dist/adapter/idle-poll-loop.d.ts +2 -1
- package/dist/adapter/idle-poll-loop.d.ts.map +1 -1
- package/dist/adapter/types.d.ts +65 -3
- package/dist/adapter/types.d.ts.map +1 -1
- package/dist/adapter/types.js +5 -4
- package/dist/index.js +4 -0
- package/dist/routes/acode-todos.d.ts +11 -0
- package/dist/routes/acode-todos.d.ts.map +1 -0
- package/dist/routes/acode-todos.js +75 -0
- package/dist/routes/memory.d.ts +1 -1
- package/dist/routes/memory.d.ts.map +1 -1
- package/dist/routes/memory.js +3 -3
- package/dist/routes/pty.d.ts.map +1 -1
- package/dist/routes/pty.js +9 -0
- package/dist/routes/sub-agents.d.ts +14 -0
- package/dist/routes/sub-agents.d.ts.map +1 -0
- package/dist/routes/sub-agents.js +253 -0
- package/dist/routes/terminal.d.ts +9 -1
- package/dist/routes/terminal.d.ts.map +1 -1
- package/dist/routes/terminal.js +207 -22
- package/dist/services/agent-event-store.d.ts +1 -0
- package/dist/services/agent-event-store.d.ts.map +1 -1
- package/dist/services/event-delta-pusher.js +4 -4
- package/dist/services/session-output.d.ts +3 -0
- package/dist/services/session-output.d.ts.map +1 -1
- package/dist/services/session-output.js +38 -2
- package/dist/services/sub-agent-manager-instance.d.ts +4 -0
- package/dist/services/sub-agent-manager-instance.d.ts.map +1 -0
- package/dist/services/sub-agent-manager-instance.js +12 -0
- package/dist/services/workspace-files.d.ts +1 -0
- package/dist/services/workspace-files.d.ts.map +1 -1
- package/dist/services/workspace-files.js +57 -1
- package/package/acode/dist/ask-user-question-tool.d.ts +47 -0
- package/package/acode/dist/ask-user-question-tool.d.ts.map +1 -0
- package/package/acode/dist/ask-user-question-tool.js +233 -0
- package/package/acode/dist/built-in-file-tools.d.ts +2 -0
- package/package/acode/dist/built-in-file-tools.d.ts.map +1 -1
- package/package/acode/dist/compaction.d.ts +206 -0
- package/package/acode/dist/compaction.d.ts.map +1 -0
- package/package/acode/dist/compaction.js +664 -0
- package/package/acode/dist/config.d.ts +6 -1
- package/package/acode/dist/config.d.ts.map +1 -1
- package/package/acode/dist/config.js +27 -2
- package/package/acode/dist/index.d.ts +4 -0
- package/package/acode/dist/index.d.ts.map +1 -1
- package/package/acode/dist/index.js +4 -0
- package/package/acode/dist/runtime.d.ts +137 -0
- package/package/acode/dist/runtime.d.ts.map +1 -1
- package/package/acode/dist/runtime.js +974 -172
- package/package/acode/dist/skill-tool.d.ts +30 -0
- package/package/acode/dist/skill-tool.d.ts.map +1 -0
- package/package/acode/dist/skill-tool.js +174 -0
- package/package/acode/dist/sub-agent-manager.d.ts +169 -0
- package/package/acode/dist/sub-agent-manager.d.ts.map +1 -0
- package/package/acode/dist/sub-agent-manager.js +535 -0
- package/package/acode/dist/sub-agent-store.d.ts +33 -0
- package/package/acode/dist/sub-agent-store.d.ts.map +1 -0
- package/package/acode/dist/sub-agent-store.js +109 -0
- package/package/acode/dist/sub-agent-tools.d.ts +72 -0
- package/package/acode/dist/sub-agent-tools.d.ts.map +1 -0
- package/package/acode/dist/sub-agent-tools.js +429 -0
- package/package/acode/dist/sub-agent-types.d.ts +81 -0
- package/package/acode/dist/sub-agent-types.d.ts.map +1 -0
- package/package/acode/dist/sub-agent-types.js +8 -0
- package/package/acode/dist/todo-store.d.ts +42 -0
- package/package/acode/dist/todo-store.d.ts.map +1 -0
- package/package/acode/dist/todo-store.js +68 -0
- package/package/acode/dist/todo-tool.d.ts +6 -0
- package/package/acode/dist/todo-tool.d.ts.map +1 -0
- package/package/acode/dist/todo-tool.js +138 -0
- package/package/acode/dist/types.d.ts +22 -1
- package/package/acode/dist/types.d.ts.map +1 -1
- package/package/acode/package.json +13 -2
- package/package/aws-client-agent-mcp/dist/context-manager.test.js +0 -2
- package/package/aws-client-agent-mcp/dist/context-manager.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +83 -45
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.js +451 -325
- package/package/aws-client-agent-mcp/dist/mcp-server.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js +259 -241
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +1 -19
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +2 -69
- package/package/aws-client-agent-mcp/dist/mcp-tools.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +17 -19
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-store.js +62 -99
- package/package/aws-client-agent-mcp/dist/memory-store.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-store.test.js +207 -125
- package/package/aws-client-agent-mcp/dist/memory-store.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts +3 -4
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.js +28 -33
- package/package/aws-client-agent-mcp/dist/memory-tools.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts +27 -9
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/message-buffer.js +100 -23
- package/package/aws-client-agent-mcp/dist/message-buffer.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +1 -3
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.js +7 -11
- package/package/aws-client-agent-mcp/dist/server-memory-store.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.js +8 -5
- package/package/aws-client-agent-mcp/dist/status-reporter.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js +93 -0
- package/package/aws-client-agent-mcp/dist/status-reporter.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/types.d.ts +3 -25
- package/package/aws-client-agent-mcp/dist/types.d.ts.map +1 -1
- package/package.json +17 -7
- package/dist/adapter/AcodeSdkAdapter.test.d.ts +0 -2
- package/dist/adapter/AcodeSdkAdapter.test.d.ts.map +0 -1
- package/dist/adapter/AcodeSdkAdapter.test.js +0 -2000
- package/dist/adapter/AdapterRegistry.test.d.ts +0 -5
- package/dist/adapter/AdapterRegistry.test.d.ts.map +0 -1
- package/dist/adapter/AdapterRegistry.test.js +0 -118
- package/dist/adapter/ClaudeSdkAdapter.test.d.ts +0 -2
- package/dist/adapter/ClaudeSdkAdapter.test.d.ts.map +0 -1
- package/dist/adapter/ClaudeSdkAdapter.test.js +0 -311
- package/dist/adapter/CodexSdkAdapter.test.d.ts +0 -2
- package/dist/adapter/CodexSdkAdapter.test.d.ts.map +0 -1
- package/dist/adapter/CodexSdkAdapter.test.js +0 -270
- package/dist/adapter/OpencodeSdkAdapter.test.d.ts +0 -2
- package/dist/adapter/OpencodeSdkAdapter.test.d.ts.map +0 -1
- package/dist/adapter/OpencodeSdkAdapter.test.js +0 -158
- package/dist/adapter/acode-tool-names.test.d.ts +0 -2
- package/dist/adapter/acode-tool-names.test.d.ts.map +0 -1
- package/dist/adapter/acode-tool-names.test.js +0 -28
- package/dist/adapter/adapter.test.d.ts +0 -5
- package/dist/adapter/adapter.test.d.ts.map +0 -1
- package/dist/adapter/adapter.test.js +0 -180
- package/dist/adapter/idle-poll-loop.test.d.ts +0 -2
- package/dist/adapter/idle-poll-loop.test.d.ts.map +0 -1
- package/dist/adapter/idle-poll-loop.test.js +0 -85
- package/dist/adapter/types.test.d.ts +0 -2
- package/dist/adapter/types.test.d.ts.map +0 -1
- package/dist/adapter/types.test.js +0 -50
- package/dist/adapters/cc-switch/mcp-acode.test.d.ts +0 -2
- package/dist/adapters/cc-switch/mcp-acode.test.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-acode.test.js +0 -80
- package/dist/adapters/cc-switch/mcp-claudecode.test.d.ts +0 -2
- package/dist/adapters/cc-switch/mcp-claudecode.test.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-claudecode.test.js +0 -75
- package/dist/adapters/cc-switch/mcp-codex.test.d.ts +0 -2
- package/dist/adapters/cc-switch/mcp-codex.test.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-codex.test.js +0 -126
- package/dist/adapters/cc-switch/mcp-opencode.test.d.ts +0 -2
- package/dist/adapters/cc-switch/mcp-opencode.test.d.ts.map +0 -1
- package/dist/adapters/cc-switch/mcp-opencode.test.js +0 -62
- package/dist/adapters/cc-switch/skill-directory.test.d.ts +0 -2
- package/dist/adapters/cc-switch/skill-directory.test.d.ts.map +0 -1
- package/dist/adapters/cc-switch/skill-directory.test.js +0 -74
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -107
- package/dist/routes/ai-sources.test.d.ts +0 -2
- package/dist/routes/ai-sources.test.d.ts.map +0 -1
- package/dist/routes/ai-sources.test.js +0 -169
- package/dist/routes/file-browser.test.d.ts +0 -5
- package/dist/routes/file-browser.test.d.ts.map +0 -1
- package/dist/routes/file-browser.test.js +0 -155
- package/dist/routes/git.test.d.ts +0 -2
- package/dist/routes/git.test.d.ts.map +0 -1
- package/dist/routes/git.test.js +0 -330
- package/dist/routes/instance.test.d.ts +0 -5
- package/dist/routes/instance.test.d.ts.map +0 -1
- package/dist/routes/instance.test.js +0 -389
- package/dist/routes/mcp.test.d.ts +0 -5
- package/dist/routes/mcp.test.d.ts.map +0 -1
- package/dist/routes/mcp.test.js +0 -92
- package/dist/routes/memory-route-wiring.test.d.ts +0 -2
- package/dist/routes/memory-route-wiring.test.d.ts.map +0 -1
- package/dist/routes/memory-route-wiring.test.js +0 -15
- package/dist/routes/memory.test.d.ts +0 -2
- package/dist/routes/memory.test.d.ts.map +0 -1
- package/dist/routes/memory.test.js +0 -177
- package/dist/routes/properties.test.d.ts +0 -5
- package/dist/routes/properties.test.d.ts.map +0 -1
- package/dist/routes/properties.test.js +0 -72
- package/dist/routes/pty.test.d.ts +0 -2
- package/dist/routes/pty.test.d.ts.map +0 -1
- package/dist/routes/pty.test.js +0 -82
- package/dist/routes/runtime-binding.test.d.ts +0 -2
- package/dist/routes/runtime-binding.test.d.ts.map +0 -1
- package/dist/routes/runtime-binding.test.js +0 -32
- package/dist/routes/sessions.test.d.ts +0 -5
- package/dist/routes/sessions.test.d.ts.map +0 -1
- package/dist/routes/sessions.test.js +0 -86
- package/dist/routes/skills.test.d.ts +0 -5
- package/dist/routes/skills.test.d.ts.map +0 -1
- package/dist/routes/skills.test.js +0 -50
- package/dist/routes/system-metrics.test.d.ts +0 -2
- package/dist/routes/system-metrics.test.d.ts.map +0 -1
- package/dist/routes/system-metrics.test.js +0 -16
- package/dist/routes/terminal.stop-options.test.d.ts +0 -2
- package/dist/routes/terminal.stop-options.test.d.ts.map +0 -1
- package/dist/routes/terminal.stop-options.test.js +0 -39
- package/dist/routes/terminal.test.d.ts +0 -2
- package/dist/routes/terminal.test.d.ts.map +0 -1
- package/dist/routes/terminal.test.js +0 -746
- package/dist/routes/yml.test.d.ts +0 -5
- package/dist/routes/yml.test.d.ts.map +0 -1
- package/dist/routes/yml.test.js +0 -58
- package/dist/services/ai-source-apply.test.d.ts +0 -2
- package/dist/services/ai-source-apply.test.d.ts.map +0 -1
- package/dist/services/ai-source-apply.test.js +0 -138
- package/dist/services/auto-register.test.d.ts +0 -2
- package/dist/services/auto-register.test.d.ts.map +0 -1
- package/dist/services/auto-register.test.js +0 -184
- package/dist/services/aws-client-agent-mcp.test.d.ts +0 -2
- package/dist/services/aws-client-agent-mcp.test.d.ts.map +0 -1
- package/dist/services/aws-client-agent-mcp.test.js +0 -242
- package/dist/services/bridge-package-publish-hooks.test.d.ts +0 -2
- package/dist/services/bridge-package-publish-hooks.test.d.ts.map +0 -1
- package/dist/services/bridge-package-publish-hooks.test.js +0 -136
- package/dist/services/cc-switch-discovery.test.d.ts +0 -2
- package/dist/services/cc-switch-discovery.test.d.ts.map +0 -1
- package/dist/services/cc-switch-discovery.test.js +0 -56
- package/dist/services/cli-commands.test.d.ts +0 -2
- package/dist/services/cli-commands.test.d.ts.map +0 -1
- package/dist/services/cli-commands.test.js +0 -230
- package/dist/services/instance-init-service.test.d.ts +0 -2
- package/dist/services/instance-init-service.test.d.ts.map +0 -1
- package/dist/services/instance-init-service.test.js +0 -140
- package/dist/services/instance-state.test.d.ts +0 -2
- package/dist/services/instance-state.test.d.ts.map +0 -1
- package/dist/services/instance-state.test.js +0 -245
- package/dist/services/mcp-launch-binding-queue.test.d.ts +0 -2
- package/dist/services/mcp-launch-binding-queue.test.d.ts.map +0 -1
- package/dist/services/mcp-launch-binding-queue.test.js +0 -181
- package/dist/services/runtime-binding.test.d.ts +0 -2
- package/dist/services/runtime-binding.test.d.ts.map +0 -1
- package/dist/services/runtime-binding.test.js +0 -78
- package/dist/services/runtime-lifecycle-policy.test.d.ts +0 -2
- package/dist/services/runtime-lifecycle-policy.test.d.ts.map +0 -1
- package/dist/services/runtime-lifecycle-policy.test.js +0 -41
- package/dist/services/session-output.test.d.ts +0 -5
- package/dist/services/session-output.test.d.ts.map +0 -1
- package/dist/services/session-output.test.js +0 -177
- package/dist/services/startup-config-wizard.test.d.ts +0 -2
- package/dist/services/startup-config-wizard.test.d.ts.map +0 -1
- package/dist/services/startup-config-wizard.test.js +0 -184
- package/dist/services/terminal-persistence.test.d.ts +0 -5
- package/dist/services/terminal-persistence.test.d.ts.map +0 -1
- package/dist/services/terminal-persistence.test.js +0 -159
- package/dist/services/tool-installer.test.d.ts +0 -2
- package/dist/services/tool-installer.test.d.ts.map +0 -1
- package/dist/services/tool-installer.test.js +0 -225
- package/dist/services/workspace-files.test.d.ts +0 -2
- package/dist/services/workspace-files.test.d.ts.map +0 -1
- package/dist/services/workspace-files.test.js +0 -648
- package/dist/services/workspace-watch.test.d.ts +0 -2
- package/dist/services/workspace-watch.test.d.ts.map +0 -1
- package/dist/services/workspace-watch.test.js +0 -38
- package/dist/utils/file-utils.test.d.ts +0 -2
- package/dist/utils/file-utils.test.d.ts.map +0 -1
- package/dist/utils/file-utils.test.js +0 -244
- package/dist/utils/logger.test.d.ts +0 -2
- package/dist/utils/logger.test.d.ts.map +0 -1
- package/dist/utils/logger.test.js +0 -93
- package/dist/utils/sdk-package-loader.test.d.ts +0 -2
- package/dist/utils/sdk-package-loader.test.d.ts.map +0 -1
- package/dist/utils/sdk-package-loader.test.js +0 -84
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/dist/utils/validation.test.js +0 -88
- package/dist/utils/yaml-utils.test.d.ts +0 -2
- package/dist/utils/yaml-utils.test.d.ts.map +0 -1
- package/dist/utils/yaml-utils.test.js +0 -363
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { promises as fs } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import { hasMatchingAgentPath, extractAgentConfigOrTemplate, generateEmptyTemplate, autoFillPathInYml, loadYmlWithUpwardSearch, } from './yaml-utils.js';
|
|
6
|
-
describe('yaml-utils', () => {
|
|
7
|
-
describe('hasMatchingAgentPath', () => {
|
|
8
|
-
it('should return null for invalid YAML content', () => {
|
|
9
|
-
expect(hasMatchingAgentPath('invalid yaml [[', 'test')).toBeNull();
|
|
10
|
-
});
|
|
11
|
-
it('should return null for empty content', () => {
|
|
12
|
-
expect(hasMatchingAgentPath('', 'test')).toBeNull();
|
|
13
|
-
});
|
|
14
|
-
it('should return null when no agent key exists', () => {
|
|
15
|
-
const yaml = `
|
|
16
|
-
other:
|
|
17
|
-
- name: test
|
|
18
|
-
`;
|
|
19
|
-
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
20
|
-
});
|
|
21
|
-
it('should return null when agent is not an array', () => {
|
|
22
|
-
const yaml = `
|
|
23
|
-
agent:
|
|
24
|
-
name: single
|
|
25
|
-
`;
|
|
26
|
-
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
27
|
-
});
|
|
28
|
-
it('should return null when agent has no path', () => {
|
|
29
|
-
const yaml = `
|
|
30
|
-
agent:
|
|
31
|
-
- name: test
|
|
32
|
-
description: no path
|
|
33
|
-
`;
|
|
34
|
-
expect(hasMatchingAgentPath(yaml, 'test')).toBeNull();
|
|
35
|
-
});
|
|
36
|
-
it('should match exact path', () => {
|
|
37
|
-
const yaml = `
|
|
38
|
-
agent:
|
|
39
|
-
- name: test
|
|
40
|
-
path: src/modules
|
|
41
|
-
`;
|
|
42
|
-
expect(hasMatchingAgentPath(yaml, 'src/modules')).toBe('src/modules');
|
|
43
|
-
});
|
|
44
|
-
it('should match path with different separators (backslash)', () => {
|
|
45
|
-
const yaml = `
|
|
46
|
-
agent:
|
|
47
|
-
- name: test
|
|
48
|
-
path: src/modules
|
|
49
|
-
`;
|
|
50
|
-
expect(hasMatchingAgentPath(yaml, 'src\\modules')).toBe('src/modules');
|
|
51
|
-
});
|
|
52
|
-
it('should match path with forward slash when yaml has backslash', () => {
|
|
53
|
-
const yaml = `
|
|
54
|
-
agent:
|
|
55
|
-
- name: test
|
|
56
|
-
path: src\\modules
|
|
57
|
-
`;
|
|
58
|
-
expect(hasMatchingAgentPath(yaml, 'src/modules')).toBe('src\\modules');
|
|
59
|
-
});
|
|
60
|
-
it('should match current directory "." path', () => {
|
|
61
|
-
const yaml = `
|
|
62
|
-
agent:
|
|
63
|
-
- name: test
|
|
64
|
-
path: .
|
|
65
|
-
`;
|
|
66
|
-
expect(hasMatchingAgentPath(yaml, '.')).toBe('.');
|
|
67
|
-
});
|
|
68
|
-
it('should match empty path when target is "."', () => {
|
|
69
|
-
const yaml = `
|
|
70
|
-
agent:
|
|
71
|
-
- name: test
|
|
72
|
-
path: ''
|
|
73
|
-
`;
|
|
74
|
-
expect(hasMatchingAgentPath(yaml, '.')).toBe('');
|
|
75
|
-
});
|
|
76
|
-
it('should return null when no matching path found', () => {
|
|
77
|
-
const yaml = `
|
|
78
|
-
agent:
|
|
79
|
-
- name: test
|
|
80
|
-
path: other/path
|
|
81
|
-
`;
|
|
82
|
-
expect(hasMatchingAgentPath(yaml, 'different/path')).toBeNull();
|
|
83
|
-
});
|
|
84
|
-
it('should return first matching path from multiple agents', () => {
|
|
85
|
-
const yaml = `
|
|
86
|
-
agent:
|
|
87
|
-
- name: first
|
|
88
|
-
path: first/path
|
|
89
|
-
- name: second
|
|
90
|
-
path: second/path
|
|
91
|
-
`;
|
|
92
|
-
expect(hasMatchingAgentPath(yaml, 'first/path')).toBe('first/path');
|
|
93
|
-
expect(hasMatchingAgentPath(yaml, 'second/path')).toBe('second/path');
|
|
94
|
-
});
|
|
95
|
-
it('should handle complex YAML with nested objects', () => {
|
|
96
|
-
const yaml = `
|
|
97
|
-
agent:
|
|
98
|
-
- name: complex
|
|
99
|
-
path: complex/path
|
|
100
|
-
project: my-project
|
|
101
|
-
prompt: |
|
|
102
|
-
This is a multi-line
|
|
103
|
-
prompt
|
|
104
|
-
`;
|
|
105
|
-
expect(hasMatchingAgentPath(yaml, 'complex/path')).toBe('complex/path');
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
describe('extractAgentConfigOrTemplate', () => {
|
|
109
|
-
it('should return original content for invalid YAML', () => {
|
|
110
|
-
const invalidYaml = 'invalid: [[[';
|
|
111
|
-
const result = extractAgentConfigOrTemplate(invalidYaml, 'test');
|
|
112
|
-
expect(result.content).toBe(invalidYaml);
|
|
113
|
-
expect(result.isTemplate).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
it('should return matching agent config', () => {
|
|
116
|
-
const yaml = `
|
|
117
|
-
agent:
|
|
118
|
-
- name: my-agent
|
|
119
|
-
path: src/modules
|
|
120
|
-
project: my-project
|
|
121
|
-
prompt: test prompt
|
|
122
|
-
`;
|
|
123
|
-
const result = extractAgentConfigOrTemplate(yaml, 'src/modules');
|
|
124
|
-
expect(result.isTemplate).toBe(false);
|
|
125
|
-
expect(result.content).toContain('my-agent');
|
|
126
|
-
expect(result.content).toContain('src/modules');
|
|
127
|
-
expect(result.content).toContain('my-project');
|
|
128
|
-
});
|
|
129
|
-
it('should generate template when no matching agent found', () => {
|
|
130
|
-
const yaml = `
|
|
131
|
-
agent:
|
|
132
|
-
- name: other-agent
|
|
133
|
-
path: other/path
|
|
134
|
-
project: existing-project
|
|
135
|
-
`;
|
|
136
|
-
const result = extractAgentConfigOrTemplate(yaml, 'new/path');
|
|
137
|
-
expect(result.isTemplate).toBe(true);
|
|
138
|
-
expect(result.projectFromSibling).toBe('existing-project');
|
|
139
|
-
expect(result.content).toContain('new/path');
|
|
140
|
-
});
|
|
141
|
-
it('should generate template with empty project when no agents have project', () => {
|
|
142
|
-
const yaml = `
|
|
143
|
-
agent:
|
|
144
|
-
- name: agent1
|
|
145
|
-
path: path1
|
|
146
|
-
`;
|
|
147
|
-
const result = extractAgentConfigOrTemplate(yaml, 'new/path');
|
|
148
|
-
expect(result.isTemplate).toBe(true);
|
|
149
|
-
expect(result.projectFromSibling).toBeNull();
|
|
150
|
-
expect(result.content).toContain('project: ""');
|
|
151
|
-
});
|
|
152
|
-
it('should match current directory "." path', () => {
|
|
153
|
-
const yaml = `
|
|
154
|
-
agent:
|
|
155
|
-
- name: root-agent
|
|
156
|
-
path: .
|
|
157
|
-
project: root-project
|
|
158
|
-
`;
|
|
159
|
-
const result = extractAgentConfigOrTemplate(yaml, '.');
|
|
160
|
-
expect(result.isTemplate).toBe(false);
|
|
161
|
-
expect(result.content).toContain('root-agent');
|
|
162
|
-
});
|
|
163
|
-
it('should normalize path separators in output', () => {
|
|
164
|
-
const yaml = `
|
|
165
|
-
agent:
|
|
166
|
-
- name: test
|
|
167
|
-
path: src\\modules
|
|
168
|
-
`;
|
|
169
|
-
const result = extractAgentConfigOrTemplate(yaml, 'src/modules');
|
|
170
|
-
expect(result.isTemplate).toBe(false);
|
|
171
|
-
expect(result.content).toContain('src/modules');
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
describe('generateEmptyTemplate', () => {
|
|
175
|
-
it('should generate valid YAML with empty agent', () => {
|
|
176
|
-
const template = generateEmptyTemplate('.');
|
|
177
|
-
expect(template).toContain('agent:');
|
|
178
|
-
expect(template).toContain('name: ""');
|
|
179
|
-
expect(template).toContain('path: .');
|
|
180
|
-
expect(template).toContain('project: ""');
|
|
181
|
-
});
|
|
182
|
-
it('should use normalized target path in generated template', () => {
|
|
183
|
-
const template1 = generateEmptyTemplate('path1');
|
|
184
|
-
const template2 = generateEmptyTemplate('path\\to\\child');
|
|
185
|
-
expect(template1).toContain('path: path1');
|
|
186
|
-
expect(template2).toContain('path: path/to/child');
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
describe('autoFillPathInYml', () => {
|
|
190
|
-
it('should return original content for invalid YAML', () => {
|
|
191
|
-
const invalidYaml = 'invalid: [[[';
|
|
192
|
-
expect(autoFillPathInYml(invalidYaml, 'test/path')).toBe(invalidYaml);
|
|
193
|
-
});
|
|
194
|
-
it('should return original content when no agent key', () => {
|
|
195
|
-
const yaml = `
|
|
196
|
-
other:
|
|
197
|
-
- name: test
|
|
198
|
-
`;
|
|
199
|
-
expect(autoFillPathInYml(yaml, 'test/path')).toBe(yaml);
|
|
200
|
-
});
|
|
201
|
-
it('should fill empty path', () => {
|
|
202
|
-
const yaml = `
|
|
203
|
-
agent:
|
|
204
|
-
- name: test
|
|
205
|
-
path: ''
|
|
206
|
-
project: my-project
|
|
207
|
-
`;
|
|
208
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
209
|
-
expect(result).toContain('new/path');
|
|
210
|
-
expect(result).not.toContain("path: ''");
|
|
211
|
-
});
|
|
212
|
-
it('should fill undefined path', () => {
|
|
213
|
-
const yaml = `
|
|
214
|
-
agent:
|
|
215
|
-
- name: test
|
|
216
|
-
project: my-project
|
|
217
|
-
`;
|
|
218
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
219
|
-
expect(result).toContain('new/path');
|
|
220
|
-
});
|
|
221
|
-
it('should fill null path', () => {
|
|
222
|
-
const yaml = `
|
|
223
|
-
agent:
|
|
224
|
-
- name: test
|
|
225
|
-
path: null
|
|
226
|
-
`;
|
|
227
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
228
|
-
expect(result).toContain('new/path');
|
|
229
|
-
});
|
|
230
|
-
it('should fill whitespace-only path', () => {
|
|
231
|
-
const yaml = `
|
|
232
|
-
agent:
|
|
233
|
-
- name: test
|
|
234
|
-
path: ' '
|
|
235
|
-
`;
|
|
236
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
237
|
-
expect(result).toContain('new/path');
|
|
238
|
-
});
|
|
239
|
-
it('should not modify existing non-empty path', () => {
|
|
240
|
-
const yaml = `
|
|
241
|
-
agent:
|
|
242
|
-
- name: test
|
|
243
|
-
path: existing/path
|
|
244
|
-
`;
|
|
245
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
246
|
-
expect(result).toContain('existing/path');
|
|
247
|
-
expect(result).not.toContain('new/path');
|
|
248
|
-
});
|
|
249
|
-
it('should handle multiple agents', () => {
|
|
250
|
-
const yaml = `
|
|
251
|
-
agent:
|
|
252
|
-
- name: agent1
|
|
253
|
-
path: ''
|
|
254
|
-
- name: agent2
|
|
255
|
-
path: existing/path
|
|
256
|
-
- name: agent3
|
|
257
|
-
`;
|
|
258
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
259
|
-
// agent1 should have path filled
|
|
260
|
-
expect(result).toContain('new/path');
|
|
261
|
-
});
|
|
262
|
-
it('should return original content when no modification needed', () => {
|
|
263
|
-
const yaml = `
|
|
264
|
-
agent:
|
|
265
|
-
- name: test
|
|
266
|
-
path: existing/path
|
|
267
|
-
`;
|
|
268
|
-
const result = autoFillPathInYml(yaml, 'new/path');
|
|
269
|
-
expect(result).toBe(yaml);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
describe('loadYmlWithUpwardSearch', () => {
|
|
273
|
-
const tempRoot = path.join(os.tmpdir(), `aws-yaml-test-${Date.now()}`);
|
|
274
|
-
const workspacePath = path.join(tempRoot, 'project', 'module', 'src');
|
|
275
|
-
const relativePath = '.agentswork/my.yml';
|
|
276
|
-
beforeEach(async () => {
|
|
277
|
-
// 创建目录结构
|
|
278
|
-
await fs.mkdir(workspacePath, { recursive: true });
|
|
279
|
-
await fs.mkdir(path.join(tempRoot, 'project', 'module', relativePath.split('/')[0]), {
|
|
280
|
-
recursive: true,
|
|
281
|
-
});
|
|
282
|
-
await fs.mkdir(path.join(tempRoot, 'project', relativePath.split('/')[0]), {
|
|
283
|
-
recursive: true,
|
|
284
|
-
});
|
|
285
|
-
await fs.mkdir(path.join(tempRoot, relativePath.split('/')[0]), { recursive: true });
|
|
286
|
-
});
|
|
287
|
-
afterEach(async () => {
|
|
288
|
-
await fs.rm(tempRoot, { recursive: true, force: true });
|
|
289
|
-
});
|
|
290
|
-
it('should return null content when no config file exists', async () => {
|
|
291
|
-
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
292
|
-
expect(result.content).toBeNull();
|
|
293
|
-
expect(result.foundInParent).toBe(false);
|
|
294
|
-
expect(result.matchedAgentPath).toBeNull();
|
|
295
|
-
});
|
|
296
|
-
it('should load config from workspace directory with matching path "."', async () => {
|
|
297
|
-
const configPath = path.join(workspacePath, relativePath);
|
|
298
|
-
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
299
|
-
await fs.writeFile(configPath, `
|
|
300
|
-
agent:
|
|
301
|
-
- name: local-agent
|
|
302
|
-
path: .
|
|
303
|
-
project: local-project
|
|
304
|
-
`, 'utf-8');
|
|
305
|
-
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
306
|
-
expect(result.content).not.toBeNull();
|
|
307
|
-
expect(result.content).toContain('local-agent');
|
|
308
|
-
expect(result.foundInParent).toBe(false);
|
|
309
|
-
expect(result.matchedAgentPath).toBe('.');
|
|
310
|
-
});
|
|
311
|
-
it('should find matching config in parent directory', async () => {
|
|
312
|
-
// 在 project/module 目录创建配置,匹配 src 路径
|
|
313
|
-
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
314
|
-
await fs.mkdir(path.dirname(parentConfigPath), { recursive: true });
|
|
315
|
-
await fs.writeFile(parentConfigPath, `
|
|
316
|
-
agent:
|
|
317
|
-
- name: module-agent
|
|
318
|
-
path: src
|
|
319
|
-
project: module-project
|
|
320
|
-
`, 'utf-8');
|
|
321
|
-
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
322
|
-
expect(result.content).not.toBeNull();
|
|
323
|
-
expect(result.content).toContain('module-agent');
|
|
324
|
-
expect(result.foundInParent).toBe(true);
|
|
325
|
-
expect(result.matchedAgentPath).toBe('src');
|
|
326
|
-
});
|
|
327
|
-
it('should use last found config when no matching path', async () => {
|
|
328
|
-
// 在 project/module 目录创建配置,但不匹配 src 路径
|
|
329
|
-
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
330
|
-
await fs.mkdir(path.dirname(parentConfigPath), { recursive: true });
|
|
331
|
-
await fs.writeFile(parentConfigPath, `
|
|
332
|
-
agent:
|
|
333
|
-
- name: other-agent
|
|
334
|
-
path: other/path
|
|
335
|
-
`, 'utf-8');
|
|
336
|
-
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
337
|
-
expect(result.content).not.toBeNull();
|
|
338
|
-
expect(result.content).toContain('other-agent');
|
|
339
|
-
expect(result.matchedAgentPath).toBeNull();
|
|
340
|
-
});
|
|
341
|
-
it('should prioritize closer matching config', async () => {
|
|
342
|
-
// 在 workspace 目录创建匹配的配置
|
|
343
|
-
const localConfigPath = path.join(workspacePath, relativePath);
|
|
344
|
-
await fs.mkdir(path.dirname(localConfigPath), { recursive: true });
|
|
345
|
-
await fs.writeFile(localConfigPath, `
|
|
346
|
-
agent:
|
|
347
|
-
- name: local-agent
|
|
348
|
-
path: .
|
|
349
|
-
`, 'utf-8');
|
|
350
|
-
// 在 parent 目录也创建配置
|
|
351
|
-
const parentConfigPath = path.join(tempRoot, 'project', 'module', relativePath);
|
|
352
|
-
await fs.writeFile(parentConfigPath, `
|
|
353
|
-
agent:
|
|
354
|
-
- name: parent-agent
|
|
355
|
-
path: src
|
|
356
|
-
`, 'utf-8');
|
|
357
|
-
const result = await loadYmlWithUpwardSearch(workspacePath, relativePath);
|
|
358
|
-
// 应该使用 local 的配置,因为更近且匹配
|
|
359
|
-
expect(result.content).toContain('local-agent');
|
|
360
|
-
expect(result.foundInParent).toBe(false);
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
});
|