@link-assistant/agent 0.0.8 → 0.0.11
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/EXAMPLES.md +80 -1
- package/MODELS.md +72 -24
- package/README.md +95 -2
- package/TOOLS.md +20 -0
- package/package.json +36 -2
- package/src/agent/agent.ts +68 -54
- package/src/auth/claude-oauth.ts +426 -0
- package/src/auth/index.ts +28 -26
- package/src/auth/plugins.ts +876 -0
- package/src/bun/index.ts +53 -43
- package/src/bus/global.ts +5 -5
- package/src/bus/index.ts +59 -53
- package/src/cli/bootstrap.js +12 -12
- package/src/cli/bootstrap.ts +6 -6
- package/src/cli/cmd/agent.ts +97 -92
- package/src/cli/cmd/auth.ts +468 -0
- package/src/cli/cmd/cmd.ts +2 -2
- package/src/cli/cmd/export.ts +41 -41
- package/src/cli/cmd/mcp.ts +210 -53
- package/src/cli/cmd/models.ts +30 -29
- package/src/cli/cmd/run.ts +269 -213
- package/src/cli/cmd/stats.ts +185 -146
- package/src/cli/error.ts +17 -13
- package/src/cli/ui.ts +78 -0
- package/src/command/index.ts +26 -26
- package/src/config/config.ts +528 -288
- package/src/config/markdown.ts +15 -15
- package/src/file/ripgrep.ts +201 -169
- package/src/file/time.ts +21 -18
- package/src/file/watcher.ts +51 -42
- package/src/file.ts +1 -1
- package/src/flag/flag.ts +26 -11
- package/src/format/formatter.ts +206 -162
- package/src/format/index.ts +61 -61
- package/src/global/index.ts +21 -21
- package/src/id/id.ts +47 -33
- package/src/index.js +554 -332
- package/src/json-standard/index.ts +173 -0
- package/src/mcp/index.ts +135 -128
- package/src/patch/index.ts +336 -267
- package/src/project/bootstrap.ts +15 -15
- package/src/project/instance.ts +43 -36
- package/src/project/project.ts +47 -47
- package/src/project/state.ts +37 -33
- package/src/provider/models-macro.ts +5 -5
- package/src/provider/models.ts +32 -32
- package/src/provider/opencode.js +19 -19
- package/src/provider/provider.ts +518 -277
- package/src/provider/transform.ts +143 -102
- package/src/server/project.ts +21 -21
- package/src/server/server.ts +111 -105
- package/src/session/agent.js +66 -60
- package/src/session/compaction.ts +136 -111
- package/src/session/index.ts +189 -156
- package/src/session/message-v2.ts +312 -268
- package/src/session/message.ts +73 -57
- package/src/session/processor.ts +180 -166
- package/src/session/prompt.ts +678 -533
- package/src/session/retry.ts +26 -23
- package/src/session/revert.ts +76 -62
- package/src/session/status.ts +26 -26
- package/src/session/summary.ts +97 -76
- package/src/session/system.ts +77 -63
- package/src/session/todo.ts +22 -16
- package/src/snapshot/index.ts +92 -76
- package/src/storage/storage.ts +157 -120
- package/src/tool/bash.ts +116 -106
- package/src/tool/batch.ts +73 -59
- package/src/tool/codesearch.ts +60 -53
- package/src/tool/edit.ts +319 -263
- package/src/tool/glob.ts +32 -28
- package/src/tool/grep.ts +72 -53
- package/src/tool/invalid.ts +7 -7
- package/src/tool/ls.ts +77 -64
- package/src/tool/multiedit.ts +30 -21
- package/src/tool/patch.ts +121 -94
- package/src/tool/read.ts +140 -122
- package/src/tool/registry.ts +38 -38
- package/src/tool/task.ts +93 -60
- package/src/tool/todo.ts +16 -16
- package/src/tool/tool.ts +45 -36
- package/src/tool/webfetch.ts +97 -74
- package/src/tool/websearch.ts +78 -64
- package/src/tool/write.ts +21 -15
- package/src/util/binary.ts +27 -19
- package/src/util/context.ts +8 -8
- package/src/util/defer.ts +7 -5
- package/src/util/error.ts +24 -19
- package/src/util/eventloop.ts +16 -10
- package/src/util/filesystem.ts +37 -33
- package/src/util/fn.ts +11 -8
- package/src/util/iife.ts +1 -1
- package/src/util/keybind.ts +44 -44
- package/src/util/lazy.ts +7 -7
- package/src/util/locale.ts +20 -16
- package/src/util/lock.ts +43 -38
- package/src/util/log.ts +95 -85
- package/src/util/queue.ts +8 -8
- package/src/util/rpc.ts +35 -23
- package/src/util/scrap.ts +4 -4
- package/src/util/signal.ts +5 -5
- package/src/util/timeout.ts +6 -6
- package/src/util/token.ts +2 -2
- package/src/util/wildcard.ts +38 -27
package/src/cli/cmd/agent.ts
CHANGED
|
@@ -1,165 +1,170 @@
|
|
|
1
|
-
import { cmd } from
|
|
2
|
-
import * as prompts from
|
|
3
|
-
import { UI } from
|
|
4
|
-
import { Global } from
|
|
5
|
-
import { Agent } from
|
|
6
|
-
import path from
|
|
7
|
-
import matter from
|
|
8
|
-
import { Instance } from
|
|
9
|
-
import { EOL } from
|
|
1
|
+
import { cmd } from './cmd';
|
|
2
|
+
import * as prompts from '@clack/prompts';
|
|
3
|
+
import { UI } from '../ui';
|
|
4
|
+
import { Global } from '../../global';
|
|
5
|
+
import { Agent } from '../../agent/agent';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import matter from 'gray-matter';
|
|
8
|
+
import { Instance } from '../../project/instance';
|
|
9
|
+
import { EOL } from 'os';
|
|
10
10
|
|
|
11
11
|
const AgentCreateCommand = cmd({
|
|
12
|
-
command:
|
|
13
|
-
describe:
|
|
12
|
+
command: 'create',
|
|
13
|
+
describe: 'create a new agent',
|
|
14
14
|
async handler() {
|
|
15
15
|
await Instance.provide({
|
|
16
16
|
directory: process.cwd(),
|
|
17
17
|
async fn() {
|
|
18
|
-
UI.empty()
|
|
19
|
-
prompts.intro(
|
|
20
|
-
const project = Instance.project
|
|
18
|
+
UI.empty();
|
|
19
|
+
prompts.intro('Create agent');
|
|
20
|
+
const project = Instance.project;
|
|
21
21
|
|
|
22
|
-
let scope:
|
|
23
|
-
if (project.vcs ===
|
|
22
|
+
let scope: 'global' | 'project' = 'global';
|
|
23
|
+
if (project.vcs === 'git') {
|
|
24
24
|
const scopeResult = await prompts.select({
|
|
25
|
-
message:
|
|
25
|
+
message: 'Location',
|
|
26
26
|
options: [
|
|
27
27
|
{
|
|
28
|
-
label:
|
|
29
|
-
value:
|
|
28
|
+
label: 'Current project',
|
|
29
|
+
value: 'project' as const,
|
|
30
30
|
hint: Instance.worktree,
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
label:
|
|
34
|
-
value:
|
|
33
|
+
label: 'Global',
|
|
34
|
+
value: 'global' as const,
|
|
35
35
|
hint: Global.Path.config,
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
|
-
})
|
|
39
|
-
if (prompts.isCancel(scopeResult)) throw new UI.CancelledError()
|
|
40
|
-
scope = scopeResult
|
|
38
|
+
});
|
|
39
|
+
if (prompts.isCancel(scopeResult)) throw new UI.CancelledError();
|
|
40
|
+
scope = scopeResult;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const query = await prompts.text({
|
|
44
|
-
message:
|
|
45
|
-
placeholder:
|
|
46
|
-
validate: (x) => (x && x.length > 0 ? undefined :
|
|
47
|
-
})
|
|
48
|
-
if (prompts.isCancel(query)) throw new UI.CancelledError()
|
|
49
|
-
|
|
50
|
-
const spinner = prompts.spinner()
|
|
51
|
-
|
|
52
|
-
spinner.start(
|
|
53
|
-
const generated = await Agent.generate({ description: query }).catch(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
message: 'Description',
|
|
45
|
+
placeholder: 'What should this agent do?',
|
|
46
|
+
validate: (x) => (x && x.length > 0 ? undefined : 'Required'),
|
|
47
|
+
});
|
|
48
|
+
if (prompts.isCancel(query)) throw new UI.CancelledError();
|
|
49
|
+
|
|
50
|
+
const spinner = prompts.spinner();
|
|
51
|
+
|
|
52
|
+
spinner.start('Generating agent configuration...');
|
|
53
|
+
const generated = await Agent.generate({ description: query }).catch(
|
|
54
|
+
(error) => {
|
|
55
|
+
spinner.stop(`LLM failed to generate agent: ${error.message}`, 1);
|
|
56
|
+
throw new UI.CancelledError();
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
spinner.stop(`Agent ${generated.identifier} generated`);
|
|
58
60
|
|
|
59
61
|
const availableTools = [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
]
|
|
62
|
+
'bash',
|
|
63
|
+
'read',
|
|
64
|
+
'write',
|
|
65
|
+
'edit',
|
|
66
|
+
'list',
|
|
67
|
+
'glob',
|
|
68
|
+
'grep',
|
|
69
|
+
'webfetch',
|
|
70
|
+
'task',
|
|
71
|
+
'todowrite',
|
|
72
|
+
'todoread',
|
|
73
|
+
];
|
|
72
74
|
|
|
73
75
|
const selectedTools = await prompts.multiselect({
|
|
74
|
-
message:
|
|
76
|
+
message: 'Select tools to enable',
|
|
75
77
|
options: availableTools.map((tool) => ({
|
|
76
78
|
label: tool,
|
|
77
79
|
value: tool,
|
|
78
80
|
})),
|
|
79
81
|
initialValues: availableTools,
|
|
80
|
-
})
|
|
81
|
-
if (prompts.isCancel(selectedTools)) throw new UI.CancelledError()
|
|
82
|
+
});
|
|
83
|
+
if (prompts.isCancel(selectedTools)) throw new UI.CancelledError();
|
|
82
84
|
|
|
83
85
|
const modeResult = await prompts.select({
|
|
84
|
-
message:
|
|
86
|
+
message: 'Agent mode',
|
|
85
87
|
options: [
|
|
86
88
|
{
|
|
87
|
-
label:
|
|
88
|
-
value:
|
|
89
|
-
hint:
|
|
89
|
+
label: 'All',
|
|
90
|
+
value: 'all' as const,
|
|
91
|
+
hint: 'Can function in both primary and subagent roles',
|
|
90
92
|
},
|
|
91
93
|
{
|
|
92
|
-
label:
|
|
93
|
-
value:
|
|
94
|
-
hint:
|
|
94
|
+
label: 'Primary',
|
|
95
|
+
value: 'primary' as const,
|
|
96
|
+
hint: 'Acts as a primary/main agent',
|
|
95
97
|
},
|
|
96
98
|
{
|
|
97
|
-
label:
|
|
98
|
-
value:
|
|
99
|
-
hint:
|
|
99
|
+
label: 'Subagent',
|
|
100
|
+
value: 'subagent' as const,
|
|
101
|
+
hint: 'Can be used as a subagent by other agents',
|
|
100
102
|
},
|
|
101
103
|
],
|
|
102
|
-
initialValue:
|
|
103
|
-
})
|
|
104
|
-
if (prompts.isCancel(modeResult)) throw new UI.CancelledError()
|
|
104
|
+
initialValue: 'all',
|
|
105
|
+
});
|
|
106
|
+
if (prompts.isCancel(modeResult)) throw new UI.CancelledError();
|
|
105
107
|
|
|
106
|
-
const tools: Record<string, boolean> = {}
|
|
108
|
+
const tools: Record<string, boolean> = {};
|
|
107
109
|
for (const tool of availableTools) {
|
|
108
110
|
if (!selectedTools.includes(tool)) {
|
|
109
|
-
tools[tool] = false
|
|
111
|
+
tools[tool] = false;
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
const frontmatter: any = {
|
|
114
116
|
description: generated.whenToUse,
|
|
115
117
|
mode: modeResult,
|
|
116
|
-
}
|
|
118
|
+
};
|
|
117
119
|
if (Object.keys(tools).length > 0) {
|
|
118
|
-
frontmatter.tools = tools
|
|
120
|
+
frontmatter.tools = tools;
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
const content = matter.stringify(generated.systemPrompt, frontmatter)
|
|
123
|
+
const content = matter.stringify(generated.systemPrompt, frontmatter);
|
|
122
124
|
const filePath = path.join(
|
|
123
|
-
scope ===
|
|
125
|
+
scope === 'global'
|
|
126
|
+
? Global.Path.config
|
|
127
|
+
: path.join(Instance.worktree, '.opencode'),
|
|
124
128
|
`agent`,
|
|
125
|
-
`${generated.identifier}.md
|
|
126
|
-
)
|
|
129
|
+
`${generated.identifier}.md`
|
|
130
|
+
);
|
|
127
131
|
|
|
128
|
-
await Bun.write(filePath, content)
|
|
132
|
+
await Bun.write(filePath, content);
|
|
129
133
|
|
|
130
|
-
prompts.log.success(`Agent created: ${filePath}`)
|
|
131
|
-
prompts.outro(
|
|
134
|
+
prompts.log.success(`Agent created: ${filePath}`);
|
|
135
|
+
prompts.outro('Done');
|
|
132
136
|
},
|
|
133
|
-
})
|
|
137
|
+
});
|
|
134
138
|
},
|
|
135
|
-
})
|
|
139
|
+
});
|
|
136
140
|
|
|
137
141
|
const AgentListCommand = cmd({
|
|
138
|
-
command:
|
|
139
|
-
describe:
|
|
142
|
+
command: 'list',
|
|
143
|
+
describe: 'list all available agents',
|
|
140
144
|
async handler() {
|
|
141
145
|
await Instance.provide({
|
|
142
146
|
directory: process.cwd(),
|
|
143
147
|
async fn() {
|
|
144
|
-
const agents = await Agent.list()
|
|
148
|
+
const agents = await Agent.list();
|
|
145
149
|
const sortedAgents = agents.sort((a, b) => {
|
|
146
150
|
if (a.builtIn !== b.builtIn) {
|
|
147
|
-
return a.builtIn ? -1 : 1
|
|
151
|
+
return a.builtIn ? -1 : 1;
|
|
148
152
|
}
|
|
149
|
-
return a.name.localeCompare(b.name)
|
|
150
|
-
})
|
|
153
|
+
return a.name.localeCompare(b.name);
|
|
154
|
+
});
|
|
151
155
|
|
|
152
156
|
for (const agent of sortedAgents) {
|
|
153
|
-
process.stdout.write(`${agent.name} (${agent.mode})${EOL}`)
|
|
157
|
+
process.stdout.write(`${agent.name} (${agent.mode})${EOL}`);
|
|
154
158
|
}
|
|
155
159
|
},
|
|
156
|
-
})
|
|
160
|
+
});
|
|
157
161
|
},
|
|
158
|
-
})
|
|
162
|
+
});
|
|
159
163
|
|
|
160
164
|
export const AgentCommand = cmd({
|
|
161
|
-
command:
|
|
162
|
-
describe:
|
|
163
|
-
builder: (yargs) =>
|
|
165
|
+
command: 'agent',
|
|
166
|
+
describe: 'manage agents',
|
|
167
|
+
builder: (yargs) =>
|
|
168
|
+
yargs.command(AgentCreateCommand).command(AgentListCommand).demandCommand(),
|
|
164
169
|
async handler() {},
|
|
165
|
-
})
|
|
170
|
+
});
|