@agentuity/opencode 0.1.15
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/AGENTS.md +40 -0
- package/README.md +113 -0
- package/dist/agents/builder.d.ts +4 -0
- package/dist/agents/builder.d.ts.map +1 -0
- package/dist/agents/builder.js +298 -0
- package/dist/agents/builder.js.map +1 -0
- package/dist/agents/expert.d.ts +4 -0
- package/dist/agents/expert.d.ts.map +1 -0
- package/dist/agents/expert.js +773 -0
- package/dist/agents/expert.js.map +1 -0
- package/dist/agents/index.d.ts +10 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +40 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/lead.d.ts +4 -0
- package/dist/agents/lead.d.ts.map +1 -0
- package/dist/agents/lead.js +463 -0
- package/dist/agents/lead.js.map +1 -0
- package/dist/agents/memory.d.ts +4 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +317 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/reviewer.d.ts +4 -0
- package/dist/agents/reviewer.d.ts.map +1 -0
- package/dist/agents/reviewer.js +321 -0
- package/dist/agents/reviewer.js.map +1 -0
- package/dist/agents/scout.d.ts +4 -0
- package/dist/agents/scout.d.ts.map +1 -0
- package/dist/agents/scout.js +280 -0
- package/dist/agents/scout.js.map +1 -0
- package/dist/agents/types.d.ts +29 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +14 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +98 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/mcps/context7.d.ts +3 -0
- package/dist/mcps/context7.d.ts.map +1 -0
- package/dist/mcps/context7.js +7 -0
- package/dist/mcps/context7.js.map +1 -0
- package/dist/mcps/grep-app.d.ts +3 -0
- package/dist/mcps/grep-app.d.ts.map +1 -0
- package/dist/mcps/grep-app.js +7 -0
- package/dist/mcps/grep-app.js.map +1 -0
- package/dist/mcps/index.d.ts +8 -0
- package/dist/mcps/index.d.ts.map +1 -0
- package/dist/mcps/index.js +25 -0
- package/dist/mcps/index.js.map +1 -0
- package/dist/plugin/hooks/keyword.d.ts +6 -0
- package/dist/plugin/hooks/keyword.d.ts.map +1 -0
- package/dist/plugin/hooks/keyword.js +110 -0
- package/dist/plugin/hooks/keyword.js.map +1 -0
- package/dist/plugin/hooks/params.d.ts +20 -0
- package/dist/plugin/hooks/params.d.ts.map +1 -0
- package/dist/plugin/hooks/params.js +157 -0
- package/dist/plugin/hooks/params.js.map +1 -0
- package/dist/plugin/hooks/session.d.ts +6 -0
- package/dist/plugin/hooks/session.d.ts.map +1 -0
- package/dist/plugin/hooks/session.js +20 -0
- package/dist/plugin/hooks/session.js.map +1 -0
- package/dist/plugin/hooks/tools.d.ts +7 -0
- package/dist/plugin/hooks/tools.d.ts.map +1 -0
- package/dist/plugin/hooks/tools.js +111 -0
- package/dist/plugin/hooks/tools.js.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/plugin.d.ts +3 -0
- package/dist/plugin/plugin.d.ts.map +1 -0
- package/dist/plugin/plugin.js +249 -0
- package/dist/plugin/plugin.js.map +1 -0
- package/dist/services/auth.d.ts +14 -0
- package/dist/services/auth.d.ts.map +1 -0
- package/dist/services/auth.js +54 -0
- package/dist/services/auth.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tools/delegate.d.ts +35 -0
- package/dist/tools/delegate.d.ts.map +1 -0
- package/dist/tools/delegate.js +51 -0
- package/dist/tools/delegate.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
- package/src/agents/builder.ts +300 -0
- package/src/agents/expert.ts +775 -0
- package/src/agents/index.ts +49 -0
- package/src/agents/lead.ts +466 -0
- package/src/agents/memory.ts +320 -0
- package/src/agents/reviewer.ts +323 -0
- package/src/agents/scout.ts +283 -0
- package/src/agents/types.ts +30 -0
- package/src/config/index.ts +1 -0
- package/src/config/loader.ts +127 -0
- package/src/index.ts +24 -0
- package/src/mcps/context7.ts +8 -0
- package/src/mcps/grep-app.ts +8 -0
- package/src/mcps/index.ts +34 -0
- package/src/plugin/hooks/keyword.ts +126 -0
- package/src/plugin/hooks/params.ts +188 -0
- package/src/plugin/hooks/session.ts +27 -0
- package/src/plugin/hooks/tools.ts +127 -0
- package/src/plugin/index.ts +1 -0
- package/src/plugin/plugin.ts +280 -0
- package/src/services/auth.ts +88 -0
- package/src/services/index.ts +1 -0
- package/src/tools/delegate.ts +62 -0
- package/src/tools/index.ts +1 -0
- package/src/types.ts +131 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { YAML } from 'bun';
|
|
4
|
+
|
|
5
|
+
export interface CloudContext {
|
|
6
|
+
authenticated: boolean;
|
|
7
|
+
orgId?: string;
|
|
8
|
+
userId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ConfigFile {
|
|
12
|
+
name?: string;
|
|
13
|
+
auth?: {
|
|
14
|
+
api_key?: string;
|
|
15
|
+
user_id?: string;
|
|
16
|
+
expires?: number;
|
|
17
|
+
};
|
|
18
|
+
preferences?: {
|
|
19
|
+
orgId?: string;
|
|
20
|
+
};
|
|
21
|
+
coder?: {
|
|
22
|
+
org?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const AGENTUITY_CONFIG_DIR = join(homedir(), '.config', 'agentuity');
|
|
27
|
+
const DEFAULT_PROFILE = 'production.yaml';
|
|
28
|
+
|
|
29
|
+
async function getProfilePath(): Promise<string> {
|
|
30
|
+
const profileFile = Bun.file(join(AGENTUITY_CONFIG_DIR, 'profile'));
|
|
31
|
+
|
|
32
|
+
if (await profileFile.exists()) {
|
|
33
|
+
const savedPath = (await profileFile.text()).trim();
|
|
34
|
+
const savedFile = Bun.file(savedPath);
|
|
35
|
+
if (await savedFile.exists()) {
|
|
36
|
+
return savedPath;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return join(AGENTUITY_CONFIG_DIR, DEFAULT_PROFILE);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function getCloudContext(): Promise<CloudContext> {
|
|
44
|
+
try {
|
|
45
|
+
const configPath = await getProfilePath();
|
|
46
|
+
const configFile = Bun.file(configPath);
|
|
47
|
+
|
|
48
|
+
if (!(await configFile.exists())) {
|
|
49
|
+
return { authenticated: false };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const content = await configFile.text();
|
|
53
|
+
const config = YAML.parse(content) as ConfigFile;
|
|
54
|
+
|
|
55
|
+
const hasAuth = Boolean(config.auth?.api_key);
|
|
56
|
+
const orgId = config.preferences?.orgId;
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
authenticated: hasAuth,
|
|
60
|
+
orgId,
|
|
61
|
+
userId: config.auth?.user_id,
|
|
62
|
+
};
|
|
63
|
+
} catch {
|
|
64
|
+
return { authenticated: false };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function checkAuth(): Promise<
|
|
69
|
+
{ ok: true; context: CloudContext } | { ok: false; error: string }
|
|
70
|
+
> {
|
|
71
|
+
const context = await getCloudContext();
|
|
72
|
+
|
|
73
|
+
if (!context.authenticated) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
error: 'Not authenticated. Run `agentuity auth login` first.',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!context.orgId) {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
error: 'No organization selected. Run `agentuity cloud org select` first.',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { ok: true, context };
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkAuth, getCloudContext, type CloudContext } from './auth';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AgentRole } from '../types';
|
|
3
|
+
|
|
4
|
+
// Schema for the delegate tool
|
|
5
|
+
export const DelegateArgsSchema = z.object({
|
|
6
|
+
agent: z
|
|
7
|
+
.enum(['scout', 'builder', 'reviewer', 'memory', 'expert'])
|
|
8
|
+
.describe('The agent to delegate to'),
|
|
9
|
+
task: z.string().describe('Clear description of the task to delegate'),
|
|
10
|
+
context: z.string().optional().describe('Additional context from previous tasks'),
|
|
11
|
+
waitForResult: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.default(true)
|
|
14
|
+
.describe('Whether to wait for the result before continuing'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type DelegateArgs = z.infer<typeof DelegateArgsSchema>;
|
|
18
|
+
|
|
19
|
+
// Agent display names for @mentions
|
|
20
|
+
const AGENT_MENTIONS: Record<AgentRole, string> = {
|
|
21
|
+
lead: '@Agentuity Coder Lead',
|
|
22
|
+
scout: '@Agentuity Coder Scout',
|
|
23
|
+
builder: '@Agentuity Coder Builder',
|
|
24
|
+
reviewer: '@Agentuity Coder Reviewer',
|
|
25
|
+
memory: '@Agentuity Coder Memory',
|
|
26
|
+
expert: '@Agentuity Coder Expert',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const delegateTool = {
|
|
30
|
+
name: 'coder_delegate',
|
|
31
|
+
description: `Delegate a task to a specialized Agentuity Coder agent.
|
|
32
|
+
|
|
33
|
+
Use this to:
|
|
34
|
+
- Scout: Explore codebase, find patterns, research documentation
|
|
35
|
+
- Builder: Implement features, write code, run tests
|
|
36
|
+
- Reviewer: Review changes, catch issues, apply fixes
|
|
37
|
+
- Memory: Store context, remember decisions across sessions
|
|
38
|
+
- Expert: Get help with Agentuity CLI and cloud services
|
|
39
|
+
|
|
40
|
+
The task will be executed by the specified agent and the result returned.`,
|
|
41
|
+
|
|
42
|
+
args: DelegateArgsSchema,
|
|
43
|
+
|
|
44
|
+
async execute(args: DelegateArgs, _context: unknown): Promise<{ output: string }> {
|
|
45
|
+
const mention = AGENT_MENTIONS[args.agent as AgentRole];
|
|
46
|
+
|
|
47
|
+
// Build the delegation prompt
|
|
48
|
+
let prompt = `${mention}\n\n## Task\n${args.task}`;
|
|
49
|
+
|
|
50
|
+
if (args.context) {
|
|
51
|
+
prompt = `${mention}\n\n## Context\n${args.context}\n\n## Task\n${args.task}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// In Open Code, this would trigger the Task tool with the appropriate agent
|
|
55
|
+
// For now, return the formatted prompt that Lead should use
|
|
56
|
+
return {
|
|
57
|
+
output: `To delegate this task, use the Task tool with this prompt:\n\n${prompt}\n\nThe ${args.agent} agent will handle this task.`,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default delegateTool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { delegateTool, DelegateArgsSchema, type DelegateArgs } from './delegate';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const AgentRoleSchema = z.enum(['lead', 'scout', 'builder', 'reviewer', 'memory', 'expert']);
|
|
4
|
+
export type AgentRole = z.infer<typeof AgentRoleSchema>;
|
|
5
|
+
|
|
6
|
+
export const TaskStatusSchema = z.enum(['pending', 'running', 'completed', 'failed', 'cancelled']);
|
|
7
|
+
export type TaskStatus = z.infer<typeof TaskStatusSchema>;
|
|
8
|
+
|
|
9
|
+
export const OrchestrationPatternSchema = z.enum(['single', 'fanout', 'pipeline']);
|
|
10
|
+
export type OrchestrationPattern = z.infer<typeof OrchestrationPatternSchema>;
|
|
11
|
+
|
|
12
|
+
export interface AgentConfig {
|
|
13
|
+
/** Agent description - explains what it does and when to use it */
|
|
14
|
+
description: string;
|
|
15
|
+
/** Model ID in provider/model-id format */
|
|
16
|
+
model: string;
|
|
17
|
+
/** System prompt content (not a file path) */
|
|
18
|
+
prompt: string;
|
|
19
|
+
/** Agent mode: 'primary', 'subagent', or 'all' (default) */
|
|
20
|
+
mode?: 'primary' | 'subagent' | 'all';
|
|
21
|
+
/** Tool configuration */
|
|
22
|
+
tools?: Record<string, boolean>;
|
|
23
|
+
/** Model variant for thinking/reasoning (e.g., 'high', 'max' for Anthropic) */
|
|
24
|
+
variant?: string;
|
|
25
|
+
/** Temperature for response creativity (0.0-2.0) */
|
|
26
|
+
temperature?: number;
|
|
27
|
+
/** Maximum agentic steps before forcing text response */
|
|
28
|
+
maxSteps?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AgentContext {
|
|
32
|
+
projectRoot: string;
|
|
33
|
+
orgId?: string;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
taskId?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CoderTask {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
status: TaskStatus;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
assignedTo?: AgentRole;
|
|
46
|
+
parentTaskId?: string;
|
|
47
|
+
result?: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CoderConfig {
|
|
52
|
+
org?: string;
|
|
53
|
+
agents?: Partial<Record<AgentRole, AgentModelConfig>>;
|
|
54
|
+
disabledMcps?: string[];
|
|
55
|
+
/** CLI command patterns to block for security (e.g., 'cloud secrets', 'auth token') */
|
|
56
|
+
blockedCommands?: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface AgentModelConfig {
|
|
60
|
+
model?: string;
|
|
61
|
+
temperature?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const CoderConfigSchema = z.object({
|
|
65
|
+
org: z.string().optional(),
|
|
66
|
+
agents: z
|
|
67
|
+
.record(
|
|
68
|
+
AgentRoleSchema,
|
|
69
|
+
z.object({
|
|
70
|
+
model: z.string().optional(),
|
|
71
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
.optional(),
|
|
75
|
+
disabledMcps: z.array(z.string()).optional(),
|
|
76
|
+
blockedCommands: z.array(z.string()).optional(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export interface McpConfig {
|
|
80
|
+
name: string;
|
|
81
|
+
type: 'remote';
|
|
82
|
+
url: string;
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface PluginClient {
|
|
88
|
+
app: {
|
|
89
|
+
log: (options: {
|
|
90
|
+
body: { service: string; level: string; message: string; extra?: unknown };
|
|
91
|
+
}) => void;
|
|
92
|
+
};
|
|
93
|
+
tui?: {
|
|
94
|
+
showToast?: (options: {
|
|
95
|
+
body: { message: string };
|
|
96
|
+
}) => void;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface PluginContext {
|
|
101
|
+
directory: string;
|
|
102
|
+
client: PluginClient;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface PluginHooks {
|
|
106
|
+
agents?: Record<string, AgentConfig>;
|
|
107
|
+
tool?: Record<string, unknown>; // Open Code tool format (created via tool() helper)
|
|
108
|
+
config?: (config: Record<string, unknown>) => Promise<void>;
|
|
109
|
+
'chat.message'?: (input: unknown, output: unknown) => Promise<void>;
|
|
110
|
+
'chat.params'?: (input: unknown, output: unknown) => Promise<void>;
|
|
111
|
+
'tool.execute.before'?: (input: unknown, output: unknown) => Promise<void>;
|
|
112
|
+
'tool.execute.after'?: (input: unknown, output: unknown) => Promise<void>;
|
|
113
|
+
event?: (input: unknown) => Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface CommandDefinition {
|
|
117
|
+
name: string;
|
|
118
|
+
description?: string;
|
|
119
|
+
template: string;
|
|
120
|
+
agent?: string;
|
|
121
|
+
model?: string;
|
|
122
|
+
argumentHint?: string;
|
|
123
|
+
/** Force command to run as subagent for context isolation */
|
|
124
|
+
subtask?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ToolDefinition {
|
|
128
|
+
description: string;
|
|
129
|
+
args: unknown; // Zod schema or JSON schema
|
|
130
|
+
execute: (args: unknown, context: unknown) => Promise<unknown>;
|
|
131
|
+
}
|