@trans-ai/trans-code 0.1.3 → 0.1.4
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/package.json +1 -1
- package/src/acp/session.ts +5 -3
- package/src/agent/system-prompt.ts +11 -2
- package/src/agent/tools.ts +9 -9
- package/src/provider/provider.ts +6 -0
- package/src/screens/REPL.tsx +10 -6
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/acp/session.ts
CHANGED
|
@@ -117,7 +117,11 @@ export class AcpSession {
|
|
|
117
117
|
const signal = this.abortController.signal;
|
|
118
118
|
|
|
119
119
|
try {
|
|
120
|
-
const
|
|
120
|
+
const provider =
|
|
121
|
+
process.env.TRANSCODE_MOCK === '1' ? undefined : createModel(this.modelSpec);
|
|
122
|
+
const systemPrompt = buildSystemPrompt(await loadProjectContext(this.cwd), {
|
|
123
|
+
modelName: provider?.config.name,
|
|
124
|
+
});
|
|
121
125
|
if (this.messages[0]?.getType() === 'system') {
|
|
122
126
|
this.messages[0] = new SystemMessage(systemPrompt);
|
|
123
127
|
} else {
|
|
@@ -126,8 +130,6 @@ export class AcpSession {
|
|
|
126
130
|
|
|
127
131
|
this.messages.push(new HumanMessage(text));
|
|
128
132
|
|
|
129
|
-
const provider =
|
|
130
|
-
process.env.TRANSCODE_MOCK === '1' ? undefined : createModel(this.modelSpec);
|
|
131
133
|
const result = await runAgentLoop({
|
|
132
134
|
model: provider?.model,
|
|
133
135
|
cwd: this.cwd,
|
|
@@ -53,10 +53,19 @@ export async function loadProjectContext(cwd: string): Promise<ProjectContext> {
|
|
|
53
53
|
return { cwd, gitBranch: await gitBranch(cwd), projectFiles };
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function buildSystemPrompt(
|
|
56
|
+
export function buildSystemPrompt(
|
|
57
|
+
context: ProjectContext,
|
|
58
|
+
options?: { modelName?: string },
|
|
59
|
+
): string {
|
|
60
|
+
const poweredBy = options?.modelName ? `, powered by the ${options.modelName} model` : '';
|
|
57
61
|
const sections: string[] = [
|
|
58
|
-
|
|
62
|
+
`You are transcode${poweredBy}, a coding agent running as a local CLI agent in a terminal.`,
|
|
59
63
|
'You work directly in the user-provided workspace and can read, search, edit and execute code.',
|
|
64
|
+
...(options?.modelName
|
|
65
|
+
? [
|
|
66
|
+
`When asked which model or company you are, answer that you are transcode running on ${options.modelName}. Never claim to be a different model or company.`,
|
|
67
|
+
]
|
|
68
|
+
: []),
|
|
60
69
|
'',
|
|
61
70
|
'## Environment',
|
|
62
71
|
`- Workspace: ${context.cwd}`,
|
package/src/agent/tools.ts
CHANGED
|
@@ -161,8 +161,8 @@ const readFileTool: AgentTool = {
|
|
|
161
161
|
isMutating: false,
|
|
162
162
|
schema: z.object({
|
|
163
163
|
path: z.string().describe('File path, relative to the workspace root'),
|
|
164
|
-
offset: z.number().int().min(1).optional().describe('First line to read (1-based)'),
|
|
165
|
-
limit: z.number().int().min(1).max(5000).optional().describe('Maximum number of lines'),
|
|
164
|
+
offset: z.number().int().min(1).nullable().optional().describe('First line to read (1-based)'),
|
|
165
|
+
limit: z.number().int().min(1).max(5000).nullable().optional().describe('Maximum number of lines'),
|
|
166
166
|
}),
|
|
167
167
|
title: (input) => `read: ${String(input.path ?? '')}`,
|
|
168
168
|
async execute(input, ctx) {
|
|
@@ -232,7 +232,7 @@ const editFileTool: AgentTool = {
|
|
|
232
232
|
path: z.string().describe('File path, relative to the workspace root'),
|
|
233
233
|
old_string: z.string().describe('Exact text to replace'),
|
|
234
234
|
new_string: z.string().describe('Replacement text'),
|
|
235
|
-
replace_all: z.boolean().optional().describe('Replace every occurrence'),
|
|
235
|
+
replace_all: z.boolean().nullable().optional().describe('Replace every occurrence'),
|
|
236
236
|
}),
|
|
237
237
|
title: (input) => `patch: ${String(input.path ?? '')}`,
|
|
238
238
|
async execute(input, ctx) {
|
|
@@ -274,7 +274,7 @@ const globTool: AgentTool = {
|
|
|
274
274
|
isMutating: false,
|
|
275
275
|
schema: z.object({
|
|
276
276
|
pattern: z.string().describe('Glob pattern, matched against workspace-relative paths'),
|
|
277
|
-
path: z.string().optional().describe('Directory to search in (default: workspace root)'),
|
|
277
|
+
path: z.string().nullable().optional().describe('Directory to search in (default: workspace root)'),
|
|
278
278
|
}),
|
|
279
279
|
title: (input) => `search: ${String(input.pattern ?? '')}`,
|
|
280
280
|
async execute(input, ctx) {
|
|
@@ -309,9 +309,9 @@ const grepTool: AgentTool = {
|
|
|
309
309
|
isMutating: false,
|
|
310
310
|
schema: z.object({
|
|
311
311
|
pattern: z.string().describe('JavaScript regular expression to search for'),
|
|
312
|
-
path: z.string().optional().describe('Directory or file to search (default: workspace root)'),
|
|
313
|
-
include: z.string().optional().describe('Glob that file paths must match'),
|
|
314
|
-
ignore_case: z.boolean().optional().describe('Case-insensitive search'),
|
|
312
|
+
path: z.string().nullable().optional().describe('Directory or file to search (default: workspace root)'),
|
|
313
|
+
include: z.string().nullable().optional().describe('Glob that file paths must match'),
|
|
314
|
+
ignore_case: z.boolean().nullable().optional().describe('Case-insensitive search'),
|
|
315
315
|
}),
|
|
316
316
|
title: (input) => `search: ${String(input.pattern ?? '')}`,
|
|
317
317
|
async execute(input, ctx) {
|
|
@@ -369,8 +369,8 @@ const bashTool: AgentTool = {
|
|
|
369
369
|
isMutating: true,
|
|
370
370
|
schema: z.object({
|
|
371
371
|
command: z.string().describe('Shell command to run'),
|
|
372
|
-
timeout_ms: z.number().int().min(1000).max(600_000).optional().describe('Timeout in ms'),
|
|
373
|
-
description: z.string().optional().describe('Short description of what the command does'),
|
|
372
|
+
timeout_ms: z.number().int().min(1000).max(600_000).nullable().optional().describe('Timeout in ms'),
|
|
373
|
+
description: z.string().nullable().optional().describe('Short description of what the command does'),
|
|
374
374
|
}),
|
|
375
375
|
title: (input) => {
|
|
376
376
|
const command = String(input.command ?? '');
|
package/src/provider/provider.ts
CHANGED
|
@@ -149,6 +149,12 @@ function defaultModelSpec(): string {
|
|
|
149
149
|
const explicit = process.env.TRANSCODE_MODEL?.trim();
|
|
150
150
|
if (explicit) return explicit;
|
|
151
151
|
|
|
152
|
+
// A model saved from the REPL `models` flow (~/.transcode.json) applies
|
|
153
|
+
// everywhere — REPL, ACP (`transcode acp`), and model checks — so an
|
|
154
|
+
// integration host without an explicit model gets the user's choice.
|
|
155
|
+
const preferred = preferredModelId();
|
|
156
|
+
if (preferred) return preferred;
|
|
157
|
+
|
|
152
158
|
if (anthropicAuthToken() || anthropicGatewayUrl()) {
|
|
153
159
|
const fable = fableModelName();
|
|
154
160
|
if (fable) return `anthropic:${fable}`;
|
package/src/screens/REPL.tsx
CHANGED
|
@@ -103,7 +103,16 @@ export default function REPL({ ctx }: REPLProps) {
|
|
|
103
103
|
addHistory({ input: text, output: '' });
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
106
|
+
const provider =
|
|
107
|
+
process.env.TRANSCODE_MOCK === '1'
|
|
108
|
+
? undefined
|
|
109
|
+
: createProvider(ctx.modelId);
|
|
110
|
+
|
|
111
|
+
const projectContext = await loadProjectContext(process.cwd());
|
|
112
|
+
const systemPrompt = buildSystemPrompt(
|
|
113
|
+
projectContext,
|
|
114
|
+
provider ? { modelName: provider.config.name } : undefined,
|
|
115
|
+
);
|
|
107
116
|
if (messagesRef.current[0]?.getType() === 'system') {
|
|
108
117
|
messagesRef.current[0] = new SystemMessage(systemPrompt);
|
|
109
118
|
} else {
|
|
@@ -111,11 +120,6 @@ export default function REPL({ ctx }: REPLProps) {
|
|
|
111
120
|
}
|
|
112
121
|
messagesRef.current.push(new HumanMessage(text));
|
|
113
122
|
|
|
114
|
-
const provider =
|
|
115
|
-
process.env.TRANSCODE_MOCK === '1'
|
|
116
|
-
? undefined
|
|
117
|
-
: createProvider(ctx.modelId);
|
|
118
|
-
|
|
119
123
|
let lastWasTool = false;
|
|
120
124
|
const result = await runAgentLoop({
|
|
121
125
|
model: provider?.model,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated from package.json by scripts/sync-version.ts (npm version hook)
|
|
2
|
-
export const VERSION = '0.1.
|
|
2
|
+
export const VERSION = '0.1.4';
|