@agntk/cli 0.1.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/dist/args.d.ts +40 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +90 -0
- package/dist/args.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +126 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +63 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +96 -0
- package/dist/config.js.map +1 -0
- package/dist/environment.d.ts +37 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +164 -0
- package/dist/environment.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +11 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +81 -0
- package/dist/init.js.map +1 -0
- package/dist/repl.d.ts +31 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +213 -0
- package/dist/repl.js.map +1 -0
- package/dist/runner.d.ts +38 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +214 -0
- package/dist/runner.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +15 -0
- package/dist/version.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA6BjC,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,SAAS,QAAQ;IACf,QAAQ,OAA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,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAEnF,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,sBAAsB,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,GAAG,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,yBAAyB,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Public API for @agntk/cli.
|
|
3
|
+
* Re-exports key types and utilities for programmatic CLI usage.
|
|
4
|
+
*/
|
|
5
|
+
export { getVersion } from './version.js';
|
|
6
|
+
export { parseArgs } from './args.js';
|
|
7
|
+
export type { ParsedArgs } from './args.js';
|
|
8
|
+
export { resolveConfig, detectApiKey, loadConfigFile } from './config.js';
|
|
9
|
+
export type { ResolvedCLIConfig } from './config.js';
|
|
10
|
+
export { detectEnvironment, formatEnvironmentPrompt } from './environment.js';
|
|
11
|
+
export type { EnvironmentContext } from './environment.js';
|
|
12
|
+
export { runOneShot, readStdin } from './runner.js';
|
|
13
|
+
export type { RunResult, RunOptions } from './runner.js';
|
|
14
|
+
export { runRepl } from './repl.js';
|
|
15
|
+
export type { ReplOptions, ReplResult } from './repl.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Public API for @agntk/cli.
|
|
3
|
+
* Re-exports key types and utilities for programmatic CLI usage.
|
|
4
|
+
*/
|
|
5
|
+
export { getVersion } from './version.js';
|
|
6
|
+
export { parseArgs } from './args.js';
|
|
7
|
+
export { resolveConfig, detectApiKey, loadConfigFile } from './config.js';
|
|
8
|
+
export { detectEnvironment, formatEnvironmentPrompt } from './environment.js';
|
|
9
|
+
export { runOneShot, readStdin } from './runner.js';
|
|
10
|
+
export { runRepl } from './repl.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Initializes .agntk/ directory with template memory files.
|
|
3
|
+
*
|
|
4
|
+
* Usage: npx agntk --init
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create .agntk/ directory with template files.
|
|
8
|
+
* Skips files that already exist.
|
|
9
|
+
*/
|
|
10
|
+
export declare function initMemoryDirectory(workspace: string): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoDH;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B1E"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Initializes .agntk/ directory with template memory files.
|
|
3
|
+
*
|
|
4
|
+
* Usage: npx agntk --init
|
|
5
|
+
*/
|
|
6
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join, resolve } from 'node:path';
|
|
9
|
+
const DIR_NAME = '.agntk';
|
|
10
|
+
const TEMPLATES = {
|
|
11
|
+
'project.md': `# Project Context
|
|
12
|
+
|
|
13
|
+
<!-- Describe your project here. This file is always loaded into the agent's context. -->
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
<!-- What does this project do? -->
|
|
18
|
+
|
|
19
|
+
## Tech Stack
|
|
20
|
+
|
|
21
|
+
<!-- Languages, frameworks, key dependencies -->
|
|
22
|
+
|
|
23
|
+
## Conventions
|
|
24
|
+
|
|
25
|
+
<!-- Coding style, naming conventions, patterns to follow -->
|
|
26
|
+
`,
|
|
27
|
+
'memory.md': `# Memory
|
|
28
|
+
|
|
29
|
+
<!-- Agent-curated facts. The agent updates this file automatically when you use "remember". -->
|
|
30
|
+
|
|
31
|
+
## World Facts
|
|
32
|
+
|
|
33
|
+
## Decisions
|
|
34
|
+
|
|
35
|
+
## Entity Knowledge
|
|
36
|
+
|
|
37
|
+
## Preferences & Patterns
|
|
38
|
+
`,
|
|
39
|
+
'context.md': `# Current Context
|
|
40
|
+
|
|
41
|
+
<!-- The agent rewrites this file each session to summarize the current working state. -->
|
|
42
|
+
|
|
43
|
+
No context yet. Start a session with \`agntk --memory\` to populate this file.
|
|
44
|
+
`,
|
|
45
|
+
'decisions.md': `# Decision Log
|
|
46
|
+
|
|
47
|
+
<!-- Append-only log of key decisions. The agent adds entries automatically. -->
|
|
48
|
+
`,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Create .agntk/ directory with template files.
|
|
52
|
+
* Skips files that already exist.
|
|
53
|
+
*/
|
|
54
|
+
export async function initMemoryDirectory(workspace) {
|
|
55
|
+
const dir = resolve(workspace, DIR_NAME);
|
|
56
|
+
if (!existsSync(dir)) {
|
|
57
|
+
await mkdir(dir, { recursive: true });
|
|
58
|
+
console.log(`Created ${DIR_NAME}/`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log(`${DIR_NAME}/ already exists`);
|
|
62
|
+
}
|
|
63
|
+
let created = 0;
|
|
64
|
+
let skipped = 0;
|
|
65
|
+
for (const [filename, content] of Object.entries(TEMPLATES)) {
|
|
66
|
+
const filePath = join(dir, filename);
|
|
67
|
+
if (existsSync(filePath)) {
|
|
68
|
+
skipped++;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
await writeFile(filePath, content, 'utf-8');
|
|
72
|
+
created++;
|
|
73
|
+
console.log(` Created ${DIR_NAME}/${filename}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (skipped > 0) {
|
|
77
|
+
console.log(` Skipped ${skipped} existing file(s)`);
|
|
78
|
+
}
|
|
79
|
+
console.log(`\nDone! Run \`agntk --memory "your prompt"\` to use persistent memory.`);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAE1B,MAAM,SAAS,GAA2B;IACxC,YAAY,EAAE;;;;;;;;;;;;;;;CAef;IAEC,WAAW,EAAE;;;;;;;;;;;CAWd;IAEC,YAAY,EAAE;;;;;CAKf;IAEC,cAAc,EAAE;;;C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fileoverview Interactive REPL mode for agntk.
|
|
3
|
+
* Provides a readline-based conversational loop with the agent.
|
|
4
|
+
*
|
|
5
|
+
* Usage: npx agntk -i [--memory] [--role coder]
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedCLIConfig } from './config.js';
|
|
8
|
+
import type { EnvironmentContext } from './environment.js';
|
|
9
|
+
export interface ReplOptions {
|
|
10
|
+
/** Resolved CLI config */
|
|
11
|
+
config: ResolvedCLIConfig;
|
|
12
|
+
/** Environment context */
|
|
13
|
+
environment: EnvironmentContext;
|
|
14
|
+
/** Input stream (for testing). Default: process.stdin */
|
|
15
|
+
input?: NodeJS.ReadableStream;
|
|
16
|
+
/** Output stream (for testing). Default: process.stdout */
|
|
17
|
+
output?: NodeJS.WritableStream;
|
|
18
|
+
}
|
|
19
|
+
export interface ReplResult {
|
|
20
|
+
/** Total number of exchanges in the session */
|
|
21
|
+
exchanges: number;
|
|
22
|
+
/** Whether the session ended normally */
|
|
23
|
+
success: boolean;
|
|
24
|
+
/** Error if session crashed */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run the interactive REPL.
|
|
29
|
+
*/
|
|
30
|
+
export declare function runRepl(options: ReplOptions): Promise<ReplResult>;
|
|
31
|
+
//# sourceMappingURL=repl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../src/repl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQ3D,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,0BAA0B;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA4DD;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAqLvE"}
|
package/dist/repl.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Interactive REPL mode for agntk.
|
|
3
|
+
* Provides a readline-based conversational loop with the agent.
|
|
4
|
+
*
|
|
5
|
+
* Usage: npx agntk -i [--memory] [--role coder]
|
|
6
|
+
*/
|
|
7
|
+
import { createInterface } from 'node:readline';
|
|
8
|
+
import { createAgent } from '@agntk/core';
|
|
9
|
+
import { formatEnvironmentPrompt } from './environment.js';
|
|
10
|
+
import { getVersion } from './version.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// REPL Commands
|
|
13
|
+
// ============================================================================
|
|
14
|
+
const REPL_COMMANDS = {
|
|
15
|
+
'/help': {
|
|
16
|
+
description: 'Show available commands',
|
|
17
|
+
handler: (ctx) => {
|
|
18
|
+
ctx.output.write('\nAvailable commands:\n');
|
|
19
|
+
for (const [cmd, { description }] of Object.entries(REPL_COMMANDS)) {
|
|
20
|
+
ctx.output.write(` ${cmd.padEnd(12)} ${description}\n`);
|
|
21
|
+
}
|
|
22
|
+
ctx.output.write('\n');
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
'/clear': {
|
|
26
|
+
description: 'Clear conversation history',
|
|
27
|
+
handler: (ctx) => {
|
|
28
|
+
ctx.history = [];
|
|
29
|
+
ctx.output.write('Conversation cleared.\n');
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'/role': {
|
|
33
|
+
description: 'Show current agent role',
|
|
34
|
+
handler: (ctx) => {
|
|
35
|
+
ctx.output.write(`Current role: ${ctx.config.role}\n`);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'/env': {
|
|
39
|
+
description: 'Show detected environment',
|
|
40
|
+
handler: (ctx) => {
|
|
41
|
+
ctx.output.write(formatEnvironmentPrompt(ctx.environment) + '\n');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
'/exit': {
|
|
45
|
+
description: 'Exit the REPL',
|
|
46
|
+
handler: (ctx) => {
|
|
47
|
+
ctx.shouldExit = true;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Interactive REPL
|
|
53
|
+
// ============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Run the interactive REPL.
|
|
56
|
+
*/
|
|
57
|
+
export async function runRepl(options) {
|
|
58
|
+
const { config, environment } = options;
|
|
59
|
+
const input = options.input ?? process.stdin;
|
|
60
|
+
const output = options.output ?? process.stdout;
|
|
61
|
+
// Validate API key
|
|
62
|
+
if (!config.apiKey) {
|
|
63
|
+
output.write('Error: No API key found. Set OPENROUTER_API_KEY or OPENAI_API_KEY.\n');
|
|
64
|
+
return { exchanges: 0, success: false, error: 'No API key' };
|
|
65
|
+
}
|
|
66
|
+
// Build agent options
|
|
67
|
+
const envPrompt = formatEnvironmentPrompt(environment);
|
|
68
|
+
const agentOptions = {
|
|
69
|
+
role: config.role,
|
|
70
|
+
maxSteps: config.maxSteps,
|
|
71
|
+
toolPreset: config.toolPreset,
|
|
72
|
+
workspaceRoot: config.workspace,
|
|
73
|
+
enableMemory: config.memory,
|
|
74
|
+
};
|
|
75
|
+
if (config.model && config.provider) {
|
|
76
|
+
agentOptions.modelProvider = config.provider;
|
|
77
|
+
agentOptions.modelName = config.model;
|
|
78
|
+
}
|
|
79
|
+
// Create agent
|
|
80
|
+
const agent = createAgent(agentOptions);
|
|
81
|
+
// Print welcome banner
|
|
82
|
+
const version = getVersion();
|
|
83
|
+
output.write(`\nagntk v${version} — interactive mode\n`);
|
|
84
|
+
output.write(`Role: ${config.role} | Model: ${config.model ?? 'default'} | Memory: ${config.memory ? 'on' : 'off'}\n`);
|
|
85
|
+
output.write(`Type /help for commands, /exit or Ctrl+C to quit.\n\n`);
|
|
86
|
+
// Create readline interface
|
|
87
|
+
const rl = createInterface({
|
|
88
|
+
input: input,
|
|
89
|
+
output: output,
|
|
90
|
+
prompt: '> ',
|
|
91
|
+
terminal: true,
|
|
92
|
+
});
|
|
93
|
+
const ctx = {
|
|
94
|
+
config,
|
|
95
|
+
environment,
|
|
96
|
+
history: [],
|
|
97
|
+
output,
|
|
98
|
+
shouldExit: false,
|
|
99
|
+
};
|
|
100
|
+
let exchanges = 0;
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
rl.prompt();
|
|
103
|
+
rl.on('line', async (line) => {
|
|
104
|
+
const trimmed = line.trim();
|
|
105
|
+
// Empty line
|
|
106
|
+
if (!trimmed) {
|
|
107
|
+
rl.prompt();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Check for REPL commands
|
|
111
|
+
const cmdKey = trimmed.split(' ')[0].toLowerCase();
|
|
112
|
+
if (REPL_COMMANDS[cmdKey]) {
|
|
113
|
+
REPL_COMMANDS[cmdKey].handler(ctx);
|
|
114
|
+
if (ctx.shouldExit) {
|
|
115
|
+
rl.close();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
rl.prompt();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Send to agent
|
|
122
|
+
ctx.history.push({ role: 'user', content: trimmed });
|
|
123
|
+
const maxHistoryPairs = 10; // keep last 10 user/assistant pairs
|
|
124
|
+
const recentHistory = ctx.history.length > maxHistoryPairs * 2
|
|
125
|
+
? ctx.history.slice(-maxHistoryPairs * 2)
|
|
126
|
+
: ctx.history;
|
|
127
|
+
const historyLines = recentHistory.map((h) => h.role === 'user' ? `[User]: ${h.content}` : `[Assistant]: ${h.content}`);
|
|
128
|
+
const contextPrompt = [
|
|
129
|
+
'<conversation_history>',
|
|
130
|
+
...historyLines.slice(0, -1), // all but current user message
|
|
131
|
+
'</conversation_history>',
|
|
132
|
+
'',
|
|
133
|
+
recentHistory[recentHistory.length - 1].content, // current user message as the actual prompt
|
|
134
|
+
].join('\n');
|
|
135
|
+
try {
|
|
136
|
+
output.write('\n');
|
|
137
|
+
// Stream output progressively (show tool calls + results + text)
|
|
138
|
+
const streamResult = await agent.stream({ prompt: contextPrompt });
|
|
139
|
+
let afterToolResult = false;
|
|
140
|
+
for await (const chunk of streamResult.fullStream) {
|
|
141
|
+
if (chunk.type === 'tool-call') {
|
|
142
|
+
const toolChunk = chunk;
|
|
143
|
+
const argsStr = toolChunk.input ? JSON.stringify(toolChunk.input) : '';
|
|
144
|
+
output.write(`\n⚡ ${toolChunk.toolName}(${argsStr})\n`);
|
|
145
|
+
afterToolResult = false;
|
|
146
|
+
}
|
|
147
|
+
else if (chunk.type === 'tool-result') {
|
|
148
|
+
const resultChunk = chunk;
|
|
149
|
+
const raw = typeof resultChunk.output === 'string'
|
|
150
|
+
? resultChunk.output
|
|
151
|
+
: JSON.stringify(resultChunk.output);
|
|
152
|
+
let displayOutput = raw;
|
|
153
|
+
try {
|
|
154
|
+
const parsed = JSON.parse(raw);
|
|
155
|
+
if (parsed && typeof parsed.output === 'string') {
|
|
156
|
+
displayOutput = parsed.output;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Use raw output as-is
|
|
161
|
+
}
|
|
162
|
+
const maxLen = 2000;
|
|
163
|
+
if (displayOutput.length > maxLen) {
|
|
164
|
+
displayOutput = displayOutput.slice(0, maxLen) + `\n... (${displayOutput.length} chars total)`;
|
|
165
|
+
}
|
|
166
|
+
output.write(`${displayOutput}\n`);
|
|
167
|
+
afterToolResult = true;
|
|
168
|
+
}
|
|
169
|
+
else if (chunk.type === 'text-delta') {
|
|
170
|
+
const textChunk = chunk;
|
|
171
|
+
if (afterToolResult) {
|
|
172
|
+
output.write('\n');
|
|
173
|
+
afterToolResult = false;
|
|
174
|
+
}
|
|
175
|
+
output.write(textChunk.text);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const responseText = (await streamResult.text) ?? '';
|
|
179
|
+
if (responseText && !responseText.endsWith('\n')) {
|
|
180
|
+
output.write('\n');
|
|
181
|
+
}
|
|
182
|
+
ctx.history.push({ role: 'assistant', content: responseText });
|
|
183
|
+
exchanges++;
|
|
184
|
+
if (config.verbose) {
|
|
185
|
+
const totalUsage = await streamResult.totalUsage;
|
|
186
|
+
const steps = await streamResult.steps;
|
|
187
|
+
if (totalUsage) {
|
|
188
|
+
const usage = totalUsage;
|
|
189
|
+
output.write(`\n[${usage.inputTokens ?? 0} in / ${usage.outputTokens ?? 0} out | ${steps?.length ?? 0} step(s)]\n`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
195
|
+
output.write(`\nError: ${msg}\n`);
|
|
196
|
+
}
|
|
197
|
+
output.write('\n');
|
|
198
|
+
rl.prompt();
|
|
199
|
+
});
|
|
200
|
+
rl.on('close', () => {
|
|
201
|
+
output.write('\nGoodbye!\n');
|
|
202
|
+
resolve({
|
|
203
|
+
exchanges,
|
|
204
|
+
success: true,
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
rl.on('SIGINT', () => {
|
|
208
|
+
output.write('\n');
|
|
209
|
+
rl.close();
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=repl.js.map
|
package/dist/repl.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl.js","sourceRoot":"","sources":["../src/repl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eA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KAAK,EAAE,MAAM,IAAI,CAAC,aAAa,CACtG,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnE,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;YACpC,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnB,EAAE,CAAC,MAAM,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAClB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC7B,OAAO,CAAC;gBACN,SAAS;gBACT,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACnB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnB,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview One-shot execution runner for agntk CLI.
|
|
3
|
+
* Takes a resolved config + prompt, creates an agent, and streams output progressively to stdout.
|
|
4
|
+
*
|
|
5
|
+
* This is the "happy path": npx agntk "organize this folder by date"
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedCLIConfig } from './config.js';
|
|
8
|
+
import type { EnvironmentContext } from './environment.js';
|
|
9
|
+
export interface RunResult {
|
|
10
|
+
/** Final text output from the agent */
|
|
11
|
+
text: string;
|
|
12
|
+
/** Number of tool steps executed */
|
|
13
|
+
steps: number;
|
|
14
|
+
/** Whether the run completed successfully */
|
|
15
|
+
success: boolean;
|
|
16
|
+
/** Error message if failed */
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RunOptions {
|
|
20
|
+
/** Resolved CLI config */
|
|
21
|
+
config: ResolvedCLIConfig;
|
|
22
|
+
/** Environment context (for system prompt injection) */
|
|
23
|
+
environment: EnvironmentContext;
|
|
24
|
+
/** Where to write streaming output. Default: process.stdout */
|
|
25
|
+
output?: NodeJS.WritableStream;
|
|
26
|
+
/** Where to write status messages. Default: process.stderr */
|
|
27
|
+
statusOutput?: NodeJS.WritableStream;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run the agent in one-shot mode.
|
|
31
|
+
* Creates an agent, sends the prompt, streams output to stdout.
|
|
32
|
+
*/
|
|
33
|
+
export declare function runOneShot(prompt: string, options: RunOptions): Promise<RunResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Read piped stdin (e.g., `cat file.log | agntk "explain this"`)
|
|
36
|
+
*/
|
|
37
|
+
export declare function readStdin(timeoutMs?: number): Promise<string | null>;
|
|
38
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAO3D,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,wDAAwD;IACxD,WAAW,EAAE,kBAAkB,CAAC;IAChC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CACtC;AAgCD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,SAAS,CAAC,CA8JpB;AAMD;;GAEG;AACH,wBAAsB,SAAS,CAAC,SAAS,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgC/E"}
|