@autonav/core 1.0.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/README.md +115 -0
- package/dist/adapter/claude-adapter.d.ts +136 -0
- package/dist/adapter/claude-adapter.d.ts.map +1 -0
- package/dist/adapter/claude-adapter.js +340 -0
- package/dist/adapter/claude-adapter.js.map +1 -0
- package/dist/adapter/index.d.ts +7 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +7 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/cli/autonav.d.ts +11 -0
- package/dist/cli/autonav.d.ts.map +1 -0
- package/dist/cli/autonav.js +79 -0
- package/dist/cli/autonav.js.map +1 -0
- package/dist/cli/nav-chat.d.ts +3 -0
- package/dist/cli/nav-chat.d.ts.map +1 -0
- package/dist/cli/nav-chat.js +151 -0
- package/dist/cli/nav-chat.js.map +1 -0
- package/dist/cli/nav-init.d.ts +3 -0
- package/dist/cli/nav-init.d.ts.map +1 -0
- package/dist/cli/nav-init.js +366 -0
- package/dist/cli/nav-init.js.map +1 -0
- package/dist/cli/nav-query.d.ts +3 -0
- package/dist/cli/nav-query.d.ts.map +1 -0
- package/dist/cli/nav-query.js +217 -0
- package/dist/cli/nav-query.js.map +1 -0
- package/dist/conversation/App.d.ts +14 -0
- package/dist/conversation/App.d.ts.map +1 -0
- package/dist/conversation/App.js +229 -0
- package/dist/conversation/App.js.map +1 -0
- package/dist/conversation/index.d.ts +29 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +44 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/prompts.d.ts +9 -0
- package/dist/conversation/prompts.d.ts.map +1 -0
- package/dist/conversation/prompts.js +47 -0
- package/dist/conversation/prompts.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/interview/App.d.ts +14 -0
- package/dist/interview/App.d.ts.map +1 -0
- package/dist/interview/App.js +159 -0
- package/dist/interview/App.js.map +1 -0
- package/dist/interview/index.d.ts +30 -0
- package/dist/interview/index.d.ts.map +1 -0
- package/dist/interview/index.js +52 -0
- package/dist/interview/index.js.map +1 -0
- package/dist/interview/prompts.d.ts +36 -0
- package/dist/interview/prompts.d.ts.map +1 -0
- package/dist/interview/prompts.js +116 -0
- package/dist/interview/prompts.js.map +1 -0
- package/dist/pack-installer/github.d.ts +41 -0
- package/dist/pack-installer/github.d.ts.map +1 -0
- package/dist/pack-installer/github.js +294 -0
- package/dist/pack-installer/github.js.map +1 -0
- package/dist/pack-installer/index.d.ts +57 -0
- package/dist/pack-installer/index.d.ts.map +1 -0
- package/dist/pack-installer/index.js +257 -0
- package/dist/pack-installer/index.js.map +1 -0
- package/dist/plugins/config-schema.d.ts +32 -0
- package/dist/plugins/config-schema.d.ts.map +1 -0
- package/dist/plugins/config-schema.js +26 -0
- package/dist/plugins/config-schema.js.map +1 -0
- package/dist/plugins/implementations/file-watcher/index.d.ts +110 -0
- package/dist/plugins/implementations/file-watcher/index.d.ts.map +1 -0
- package/dist/plugins/implementations/file-watcher/index.js +212 -0
- package/dist/plugins/implementations/file-watcher/index.js.map +1 -0
- package/dist/plugins/implementations/github/index.d.ts +201 -0
- package/dist/plugins/implementations/github/index.d.ts.map +1 -0
- package/dist/plugins/implementations/github/index.js +337 -0
- package/dist/plugins/implementations/github/index.js.map +1 -0
- package/dist/plugins/implementations/slack/index.d.ts +153 -0
- package/dist/plugins/implementations/slack/index.d.ts.map +1 -0
- package/dist/plugins/implementations/slack/index.js +221 -0
- package/dist/plugins/implementations/slack/index.js.map +1 -0
- package/dist/plugins/index.d.ts +23 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +35 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +66 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.js +198 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/plugins/types.d.ts +102 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +38 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/utils/security.d.ts +43 -0
- package/dist/plugins/utils/security.d.ts.map +1 -0
- package/dist/plugins/utils/security.js +115 -0
- package/dist/plugins/utils/security.js.map +1 -0
- package/dist/query-engine/index.d.ts +10 -0
- package/dist/query-engine/index.d.ts.map +1 -0
- package/dist/query-engine/index.js +10 -0
- package/dist/query-engine/index.js.map +1 -0
- package/dist/query-engine/navigator-loader.d.ts +37 -0
- package/dist/query-engine/navigator-loader.d.ts.map +1 -0
- package/dist/query-engine/navigator-loader.js +167 -0
- package/dist/query-engine/navigator-loader.js.map +1 -0
- package/dist/query-engine/output-formatter.d.ts +55 -0
- package/dist/query-engine/output-formatter.d.ts.map +1 -0
- package/dist/query-engine/output-formatter.js +165 -0
- package/dist/query-engine/output-formatter.js.map +1 -0
- package/dist/query-engine/response-validator.d.ts +55 -0
- package/dist/query-engine/response-validator.d.ts.map +1 -0
- package/dist/query-engine/response-validator.js +92 -0
- package/dist/query-engine/response-validator.js.map +1 -0
- package/dist/templates/.gitignore.template +23 -0
- package/dist/templates/CLAUDE-pack.md.template +32 -0
- package/dist/templates/CLAUDE.md.template +128 -0
- package/dist/templates/README.md.template +174 -0
- package/dist/templates/config-pack.json.template +16 -0
- package/dist/templates/config.json.template +11 -0
- package/dist/templates/index.d.ts +22 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +32 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/plugins.json.template +33 -0
- package/dist/templates/system-configuration.md.template +66 -0
- package/dist/tools/handler.d.ts +20 -0
- package/dist/tools/handler.d.ts.map +1 -0
- package/dist/tools/handler.js +202 -0
- package/dist/tools/handler.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/response.d.ts +30 -0
- package/dist/tools/response.d.ts.map +1 -0
- package/dist/tools/response.js +68 -0
- package/dist/tools/response.js.map +1 -0
- package/dist/tools/self-config.d.ts +54 -0
- package/dist/tools/self-config.d.ts.map +1 -0
- package/dist/tools/self-config.js +84 -0
- package/dist/tools/self-config.js.map +1 -0
- package/dist/validation/index.d.ts +19 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +91 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
import { ClaudeAdapter } from "../adapter/index.js";
|
|
6
|
+
import { loadNavigator, validateResponse, formatResponse, formatErrorMessage, formatWarningMessage, formatSuggestion, NavigatorLoadError, } from "../query-engine/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Parse a human-readable duration string into milliseconds
|
|
9
|
+
* Supports formats: "30s", "1m", "1m30s", "90", "90000" (plain ms)
|
|
10
|
+
* Max timeout: 10 minutes (600000ms) to prevent overflow issues
|
|
11
|
+
*/
|
|
12
|
+
function parseDuration(input) {
|
|
13
|
+
const MAX_TIMEOUT_MS = 600000; // 10 minutes
|
|
14
|
+
// Try plain number first (milliseconds)
|
|
15
|
+
const plainNumber = Number(input);
|
|
16
|
+
if (!isNaN(plainNumber) && Number.isFinite(plainNumber)) {
|
|
17
|
+
const ms = Math.floor(plainNumber);
|
|
18
|
+
if (ms <= 0) {
|
|
19
|
+
throw new Error("Timeout must be positive");
|
|
20
|
+
}
|
|
21
|
+
return Math.min(ms, MAX_TIMEOUT_MS);
|
|
22
|
+
}
|
|
23
|
+
// Parse human-readable format: 1m30s, 30s, 2m, etc.
|
|
24
|
+
const pattern = /^(?:(\d+)m)?(?:(\d+)s)?$/i;
|
|
25
|
+
const match = input.trim().match(pattern);
|
|
26
|
+
if (!match || (!match[1] && !match[2])) {
|
|
27
|
+
throw new Error(`Invalid duration format: "${input}". Use formats like: 30s, 1m, 1m30s, or milliseconds`);
|
|
28
|
+
}
|
|
29
|
+
const minutes = match[1] ? parseInt(match[1], 10) : 0;
|
|
30
|
+
const seconds = match[2] ? parseInt(match[2], 10) : 0;
|
|
31
|
+
// Calculate total milliseconds with overflow protection
|
|
32
|
+
const totalMs = (minutes * 60 + seconds) * 1000;
|
|
33
|
+
if (totalMs <= 0) {
|
|
34
|
+
throw new Error("Timeout must be positive");
|
|
35
|
+
}
|
|
36
|
+
if (totalMs > MAX_TIMEOUT_MS) {
|
|
37
|
+
console.error(`Warning: Timeout capped at 10 minutes (was ${input})`);
|
|
38
|
+
return MAX_TIMEOUT_MS;
|
|
39
|
+
}
|
|
40
|
+
return totalMs;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Main CLI program
|
|
44
|
+
*/
|
|
45
|
+
const program = new Command();
|
|
46
|
+
program
|
|
47
|
+
.name("autonav query")
|
|
48
|
+
.description("Query a Platform AI navigator")
|
|
49
|
+
.version("1.0.0")
|
|
50
|
+
.argument("<navigator>", "Path to the navigator directory")
|
|
51
|
+
.argument("<question>", "Question to ask the navigator")
|
|
52
|
+
.option("--compact", "Compact output (answer + minimal sources)")
|
|
53
|
+
.option("--json", "Raw JSON output")
|
|
54
|
+
.option("--no-color", "Disable colored output")
|
|
55
|
+
.option("--validate", "Enable strict source validation (fail on missing sources)")
|
|
56
|
+
.option("--confidence <level>", "Minimum acceptable confidence (high|medium|low)")
|
|
57
|
+
.option("--timeout <duration>", "Query timeout (e.g., 30s, 1m, 1m30s, or milliseconds)", parseDuration, 30000)
|
|
58
|
+
.option("--verbose", "Show additional debug information")
|
|
59
|
+
.action(async (navigator, question, options) => {
|
|
60
|
+
await executeQuery(navigator, question, options);
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Execute the query command
|
|
64
|
+
*/
|
|
65
|
+
async function executeQuery(navigatorPath, question, options) {
|
|
66
|
+
// Disable chalk if noColor is set
|
|
67
|
+
if (options.noColor) {
|
|
68
|
+
chalk.level = 0;
|
|
69
|
+
}
|
|
70
|
+
// Note: No API key check needed - Claude Agent SDK uses Claude Code's OAuth
|
|
71
|
+
// Validate confidence level option
|
|
72
|
+
if (options.confidence) {
|
|
73
|
+
const validLevels = ["high", "medium", "low"];
|
|
74
|
+
if (!validLevels.includes(options.confidence)) {
|
|
75
|
+
console.error(formatErrorMessage(`Invalid confidence level: ${options.confidence}. Must be one of: ${validLevels.join(", ")}`));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
let spinner;
|
|
80
|
+
try {
|
|
81
|
+
// Determine output format
|
|
82
|
+
const format = options.json
|
|
83
|
+
? "json"
|
|
84
|
+
: options.compact
|
|
85
|
+
? "compact"
|
|
86
|
+
: "pretty";
|
|
87
|
+
// Show loading spinner (only in non-JSON mode)
|
|
88
|
+
if (format !== "json") {
|
|
89
|
+
spinner = ora("Loading navigator...").start();
|
|
90
|
+
}
|
|
91
|
+
// Load navigator (sync, from query-engine)
|
|
92
|
+
const navigator = loadNavigator(navigatorPath);
|
|
93
|
+
if (spinner) {
|
|
94
|
+
spinner.succeed(`Loaded: ${chalk.bold(navigator.config.name)}`);
|
|
95
|
+
if (options.verbose) {
|
|
96
|
+
console.error(chalk.dim(`Knowledge base: ${navigator.knowledgeBasePath}`));
|
|
97
|
+
}
|
|
98
|
+
console.error(""); // Blank line
|
|
99
|
+
}
|
|
100
|
+
// Show question (only in non-JSON mode)
|
|
101
|
+
if (format !== "json") {
|
|
102
|
+
console.error(chalk.blue("❓") + " Question: " + chalk.italic(question));
|
|
103
|
+
console.error(""); // Blank line
|
|
104
|
+
spinner = ora("Querying Claude...").start();
|
|
105
|
+
}
|
|
106
|
+
// Initialize adapter
|
|
107
|
+
const adapter = new ClaudeAdapter();
|
|
108
|
+
// Execute query with timeout
|
|
109
|
+
const queryPromise = adapter.query(navigator, question);
|
|
110
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
reject(new Error(`Query timed out after ${options.timeout}ms`));
|
|
113
|
+
}, options.timeout);
|
|
114
|
+
});
|
|
115
|
+
const response = await Promise.race([queryPromise, timeoutPromise]);
|
|
116
|
+
if (spinner) {
|
|
117
|
+
spinner.succeed("Query completed");
|
|
118
|
+
console.error(""); // Blank line
|
|
119
|
+
}
|
|
120
|
+
// Validate response (extended validation from query-engine)
|
|
121
|
+
const validation = validateResponse(response, {
|
|
122
|
+
minimumConfidence: options.confidence,
|
|
123
|
+
strictSourceValidation: options.validate,
|
|
124
|
+
knowledgeBasePath: navigator.knowledgeBasePath,
|
|
125
|
+
});
|
|
126
|
+
// Show warnings (only in non-JSON mode)
|
|
127
|
+
if (format !== "json" && validation.warnings.length > 0) {
|
|
128
|
+
for (const warning of validation.warnings) {
|
|
129
|
+
console.error(formatWarningMessage(warning));
|
|
130
|
+
}
|
|
131
|
+
console.error(""); // Blank line
|
|
132
|
+
}
|
|
133
|
+
// Check if validation failed
|
|
134
|
+
if (!validation.valid) {
|
|
135
|
+
if (format !== "json") {
|
|
136
|
+
console.error(chalk.red.bold("Validation Failed:"));
|
|
137
|
+
console.error("");
|
|
138
|
+
for (const error of validation.errors) {
|
|
139
|
+
console.error(formatErrorMessage(error.message));
|
|
140
|
+
}
|
|
141
|
+
console.error("");
|
|
142
|
+
// Provide helpful suggestions
|
|
143
|
+
if (options.confidence && !validation.confidenceMet) {
|
|
144
|
+
console.error(formatSuggestion("Try:", [
|
|
145
|
+
"Rephrase the question more specifically",
|
|
146
|
+
"Check if knowledge base covers this topic",
|
|
147
|
+
`Accept ${validation.confidenceLevel || "lower"} confidence: remove --confidence flag`,
|
|
148
|
+
]));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
// Format and output response
|
|
154
|
+
const formattedOutput = formatResponse(response, {
|
|
155
|
+
format,
|
|
156
|
+
noColor: options.noColor,
|
|
157
|
+
verbose: options.verbose,
|
|
158
|
+
});
|
|
159
|
+
console.log(formattedOutput);
|
|
160
|
+
// Success message (only in non-JSON mode)
|
|
161
|
+
if (format !== "json") {
|
|
162
|
+
console.error(""); // Blank line
|
|
163
|
+
console.error(chalk.green("✅") +
|
|
164
|
+
` Query completed successfully! (${response.sources.length} source${response.sources.length !== 1 ? "s" : ""} cited)`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (spinner) {
|
|
169
|
+
spinner.fail("Query failed");
|
|
170
|
+
console.error(""); // Blank line
|
|
171
|
+
}
|
|
172
|
+
// Handle different error types
|
|
173
|
+
if (error instanceof NavigatorLoadError) {
|
|
174
|
+
console.error(formatErrorMessage(error.message));
|
|
175
|
+
console.error("");
|
|
176
|
+
// Show helpful suggestions based on error context
|
|
177
|
+
if (error.context?.suggestions) {
|
|
178
|
+
const suggestions = error.context.suggestions;
|
|
179
|
+
if (suggestions.length > 0) {
|
|
180
|
+
console.error(chalk.bold("Did you mean?"));
|
|
181
|
+
for (const suggestion of suggestions) {
|
|
182
|
+
console.error(chalk.dim(` ./${suggestion}`));
|
|
183
|
+
}
|
|
184
|
+
console.error("");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (error.context?.suggestion) {
|
|
188
|
+
console.error(chalk.dim(error.context.suggestion));
|
|
189
|
+
console.error("");
|
|
190
|
+
}
|
|
191
|
+
if (error.context?.missingFile === "config.json") {
|
|
192
|
+
console.error(formatSuggestion("Create a new navigator:", [
|
|
193
|
+
"autonav init <navigator-name>",
|
|
194
|
+
]));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (error instanceof Error) {
|
|
198
|
+
console.error(formatErrorMessage(error.message));
|
|
199
|
+
// Timeout error suggestions
|
|
200
|
+
if (error.message.includes("timed out")) {
|
|
201
|
+
console.error("");
|
|
202
|
+
console.error(formatSuggestion("Try:", [
|
|
203
|
+
`Increase timeout: autonav query "${navigatorPath}" "${question}" --timeout 1m`,
|
|
204
|
+
"Simplify the question",
|
|
205
|
+
"Check knowledge base size",
|
|
206
|
+
]));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
console.error(formatErrorMessage(String(error)));
|
|
211
|
+
}
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Parse and execute
|
|
216
|
+
program.parse(process.argv);
|
|
217
|
+
//# sourceMappingURL=nav-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-query.js","sourceRoot":"","sources":["../../src/cli/nav-query.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,0BAA0B,CAAC;AAelC;;;;GAIG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,aAAa;IAE5C,wCAAwC;IACxC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,C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yBAAyB,EAAE;oBAC1C,+BAA+B;iBAChC,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAEjD,4BAA4B;YAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,OAAO,CAAC,KAAK,CACX,gBAAgB,CAAC,MAAM,EAAE;oBACvB,oCAAoC,aAAa,MAAM,QAAQ,gBAAgB;oBAC/E,uBAAuB;oBACvB,2BAA2B;iBAC5B,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,oBAAoB;AACpB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ink-based TUI for interactive navigator conversation
|
|
3
|
+
*
|
|
4
|
+
* Uses Claude Agent SDK for authentication (leverages Claude Code's OAuth)
|
|
5
|
+
*/
|
|
6
|
+
interface ConversationAppProps {
|
|
7
|
+
navigatorName: string;
|
|
8
|
+
navigatorPath: string;
|
|
9
|
+
navigatorSystemPrompt: string;
|
|
10
|
+
knowledgeBasePath: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function ConversationApp({ navigatorName, navigatorPath, navigatorSystemPrompt, knowledgeBasePath, }: ConversationAppProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=App.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/conversation/App.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH,UAAU,oBAAoB;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,iBAAiB,GAClB,EAAE,oBAAoB,2CAkUtB"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Ink-based TUI for interactive navigator conversation
|
|
4
|
+
*
|
|
5
|
+
* Uses Claude Agent SDK for authentication (leverages Claude Code's OAuth)
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useEffect, useCallback, useRef } from "react";
|
|
8
|
+
import { Box, Text, useApp, useInput } from "ink";
|
|
9
|
+
import TextInput from "ink-text-input";
|
|
10
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
11
|
+
import { buildConversationSystemPrompt } from "./prompts.js";
|
|
12
|
+
// Check if debug mode is enabled
|
|
13
|
+
const DEBUG = process.env.AUTONAV_DEBUG === "1" || process.env.DEBUG === "1";
|
|
14
|
+
// Model to use for conversation
|
|
15
|
+
const CONVERSATION_MODEL = "claude-sonnet-4-5";
|
|
16
|
+
function debugLog(...args) {
|
|
17
|
+
if (DEBUG) {
|
|
18
|
+
console.error("[DEBUG]", ...args);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function ConversationApp({ navigatorName, navigatorPath, navigatorSystemPrompt, knowledgeBasePath, }) {
|
|
22
|
+
const [messages, setMessages] = useState([]);
|
|
23
|
+
const [input, setInput] = useState("");
|
|
24
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
25
|
+
const [activity, setActivity] = useState(null);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
const queryRef = useRef(null);
|
|
28
|
+
const { exit } = useApp();
|
|
29
|
+
// Helper to determine activity type from tool name
|
|
30
|
+
const getActivityFromTool = (toolName) => {
|
|
31
|
+
const name = toolName.toLowerCase();
|
|
32
|
+
if (name.includes("read") || name === "cat") {
|
|
33
|
+
return { type: "reading", detail: toolName };
|
|
34
|
+
}
|
|
35
|
+
if (name.includes("write") || name.includes("edit")) {
|
|
36
|
+
return { type: "writing", detail: toolName };
|
|
37
|
+
}
|
|
38
|
+
if (name.includes("grep") || name.includes("glob") || name.includes("search") || name.includes("find")) {
|
|
39
|
+
return { type: "searching", detail: toolName };
|
|
40
|
+
}
|
|
41
|
+
return { type: "tool", detail: toolName };
|
|
42
|
+
};
|
|
43
|
+
// Format activity for display
|
|
44
|
+
const formatActivity = (act) => {
|
|
45
|
+
switch (act.type) {
|
|
46
|
+
case "thinking":
|
|
47
|
+
return "Thinking...";
|
|
48
|
+
case "reading":
|
|
49
|
+
return `Reading ${act.detail || "file"}...`;
|
|
50
|
+
case "writing":
|
|
51
|
+
return `Writing ${act.detail || "file"}...`;
|
|
52
|
+
case "searching":
|
|
53
|
+
return `Searching ${act.detail || ""}...`;
|
|
54
|
+
case "tool":
|
|
55
|
+
return `Running ${act.detail || "tool"}...`;
|
|
56
|
+
default:
|
|
57
|
+
return "Working...";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Build the full system prompt
|
|
61
|
+
const systemPrompt = buildConversationSystemPrompt(navigatorName, navigatorSystemPrompt, knowledgeBasePath);
|
|
62
|
+
// Process messages from Claude
|
|
63
|
+
const processResponse = useCallback(async () => {
|
|
64
|
+
const queryInstance = queryRef.current;
|
|
65
|
+
if (!queryInstance)
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
debugLog("Waiting for Claude response...");
|
|
69
|
+
setActivity({ type: "thinking" });
|
|
70
|
+
for await (const message of queryInstance) {
|
|
71
|
+
debugLog("Received message type:", message.type);
|
|
72
|
+
if (message.type === "assistant") {
|
|
73
|
+
// Extract text content and tool use from the assistant message
|
|
74
|
+
const content = message.message.content;
|
|
75
|
+
// Check for tool use blocks first
|
|
76
|
+
const toolUseBlocks = content.filter((b) => b.type === "tool_use");
|
|
77
|
+
// Update activity based on tool calls
|
|
78
|
+
for (const toolBlock of toolUseBlocks) {
|
|
79
|
+
const toolActivity = getActivityFromTool(toolBlock.name);
|
|
80
|
+
setActivity(toolActivity);
|
|
81
|
+
// Add activity message to show what's happening
|
|
82
|
+
setMessages((prev) => [
|
|
83
|
+
...prev,
|
|
84
|
+
{ role: "activity", content: `⚙️ ${toolBlock.name}` },
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
// Extract text content
|
|
88
|
+
const textBlocks = content.filter((b) => b.type === "text");
|
|
89
|
+
const text = textBlocks.map((b) => b.text).join("\n");
|
|
90
|
+
if (text) {
|
|
91
|
+
setActivity({ type: "thinking" });
|
|
92
|
+
setMessages((prev) => [
|
|
93
|
+
...prev,
|
|
94
|
+
{ role: "assistant", content: text },
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (message.type === "tool_progress") {
|
|
99
|
+
// Tool execution happening
|
|
100
|
+
debugLog("Tool progress:", message);
|
|
101
|
+
// The tool_progress event has a tool_name property
|
|
102
|
+
const toolName = message.tool_name;
|
|
103
|
+
if (toolName) {
|
|
104
|
+
setActivity(getActivityFromTool(toolName));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (message.type === "result") {
|
|
108
|
+
debugLog("Result received:", message.subtype);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setActivity(null);
|
|
113
|
+
setIsLoading(false);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
debugLog("Error processing response:", err);
|
|
117
|
+
setError(err instanceof Error ? err.message : "Error communicating with Claude");
|
|
118
|
+
setActivity(null);
|
|
119
|
+
setIsLoading(false);
|
|
120
|
+
}
|
|
121
|
+
}, [getActivityFromTool]);
|
|
122
|
+
// Send initial greeting
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
setMessages([
|
|
125
|
+
{
|
|
126
|
+
role: "system",
|
|
127
|
+
content: `Connected to ${navigatorName}. Type /help for commands, or start chatting.`,
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
}, [navigatorName]);
|
|
131
|
+
// Handle special commands
|
|
132
|
+
const handleCommand = useCallback((command) => {
|
|
133
|
+
const cmd = command.toLowerCase().trim();
|
|
134
|
+
if (cmd === "/help") {
|
|
135
|
+
setMessages((prev) => [
|
|
136
|
+
...prev,
|
|
137
|
+
{
|
|
138
|
+
role: "system",
|
|
139
|
+
content: `Available commands:
|
|
140
|
+
/help - Show this help message
|
|
141
|
+
/status - Show navigator status
|
|
142
|
+
/clear - Clear conversation history
|
|
143
|
+
/exit - Exit conversation mode
|
|
144
|
+
|
|
145
|
+
Or just type naturally to chat with your navigator.`,
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (cmd === "/status") {
|
|
151
|
+
setMessages((prev) => [
|
|
152
|
+
...prev,
|
|
153
|
+
{
|
|
154
|
+
role: "system",
|
|
155
|
+
content: `Navigator: ${navigatorName}
|
|
156
|
+
Path: ${navigatorPath}
|
|
157
|
+
Knowledge Base: ${knowledgeBasePath}
|
|
158
|
+
Model: ${CONVERSATION_MODEL}`,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (cmd === "/clear") {
|
|
164
|
+
setMessages([
|
|
165
|
+
{
|
|
166
|
+
role: "system",
|
|
167
|
+
content: "Conversation cleared. Start fresh!",
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (cmd === "/exit") {
|
|
173
|
+
exit();
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}, [navigatorName, navigatorPath, knowledgeBasePath, exit]);
|
|
178
|
+
// Handle user input submission
|
|
179
|
+
const handleSubmit = useCallback(async (value) => {
|
|
180
|
+
if (!value.trim() || isLoading)
|
|
181
|
+
return;
|
|
182
|
+
setInput("");
|
|
183
|
+
// Check for commands
|
|
184
|
+
if (value.startsWith("/")) {
|
|
185
|
+
if (handleCommand(value)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Add user message to history
|
|
190
|
+
setMessages((prev) => [...prev, { role: "user", content: value }]);
|
|
191
|
+
setIsLoading(true);
|
|
192
|
+
setError(null);
|
|
193
|
+
try {
|
|
194
|
+
debugLog("Sending user message:", value);
|
|
195
|
+
// Build conversation history for context
|
|
196
|
+
const conversationHistory = messages
|
|
197
|
+
.filter((m) => m.role !== "system")
|
|
198
|
+
.map((m) => `${m.role === "user" ? "User" : "Assistant"}: ${m.content}`)
|
|
199
|
+
.join("\n\n");
|
|
200
|
+
const fullPrompt = conversationHistory
|
|
201
|
+
? `${conversationHistory}\n\nUser: ${value}`
|
|
202
|
+
: value;
|
|
203
|
+
const queryInstance = query({
|
|
204
|
+
prompt: fullPrompt,
|
|
205
|
+
options: {
|
|
206
|
+
model: CONVERSATION_MODEL,
|
|
207
|
+
systemPrompt,
|
|
208
|
+
permissionMode: "acceptEdits", // Allow file operations
|
|
209
|
+
cwd: navigatorPath, // Set working directory to navigator
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
queryRef.current = queryInstance;
|
|
213
|
+
await processResponse();
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
debugLog("Error sending message:", err);
|
|
217
|
+
setError(err instanceof Error ? err.message : "Failed to send message");
|
|
218
|
+
setIsLoading(false);
|
|
219
|
+
}
|
|
220
|
+
}, [isLoading, messages, systemPrompt, navigatorPath, handleCommand, processResponse]);
|
|
221
|
+
// Handle Ctrl+C or Ctrl+D to exit
|
|
222
|
+
useInput((input, key) => {
|
|
223
|
+
if (key.ctrl && (input === "c" || input === "d")) {
|
|
224
|
+
exit();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { bold: true, color: "cyan", children: ["\uD83D\uDCAC ", navigatorName] }), _jsx(Text, { color: "gray", children: " - conversation mode" })] }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "gray", children: "Type /help for commands. Press Ctrl+C or Ctrl+D to exit." }) }), messages.map((msg, i) => (_jsx(Box, { marginBottom: 1, flexDirection: "column", children: msg.role === "user" ? (_jsxs(Box, { children: [_jsx(Text, { color: "green", children: "you › " }), _jsx(Text, { children: msg.content })] })) : msg.role === "assistant" ? (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "blue", children: [navigatorName, ":"] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { children: msg.content }) })] })) : msg.role === "activity" ? (_jsx(Box, { children: _jsx(Text, { color: "yellow", dimColor: true, children: msg.content }) })) : (_jsx(Box, { children: _jsx(Text, { color: "gray", dimColor: true, children: msg.content }) })) }, i))), error && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) })), isLoading && activity && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "cyan", children: formatActivity(activity) }) })), !isLoading && (_jsxs(Box, { children: [_jsx(Text, { color: "green", children: "you › " }), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: handleSubmit, placeholder: "Type a message..." })] }))] }));
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/conversation/App.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,O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,wBAAS,KAAK,IAAQ,GACnC,CACP,EAGA,SAAS,IAAI,QAAQ,IAAI,CACxB,KAAC,GAAG,IAAC,YAAY,EAAE,CAAC,YAClB,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAAE,cAAc,CAAC,QAAQ,CAAC,GAAQ,GAChD,CACP,EAGA,CAAC,SAAS,IAAI,CACb,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,YAAE,QAAQ,GAAQ,EACrC,KAAC,SAAS,IACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAC,mBAAmB,GAC/B,IACE,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation module for interactive nav management
|
|
3
|
+
*
|
|
4
|
+
* Exports the runConversationTUI function which launches an Ink-based
|
|
5
|
+
* conversational interface for managing navigators.
|
|
6
|
+
*/
|
|
7
|
+
export { buildConversationSystemPrompt } from "./prompts.js";
|
|
8
|
+
/**
|
|
9
|
+
* Check if the current environment supports interactive TTY input
|
|
10
|
+
*/
|
|
11
|
+
export declare function isInteractiveTerminal(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Options for running the conversation TUI
|
|
14
|
+
*/
|
|
15
|
+
export interface ConversationOptions {
|
|
16
|
+
navigatorName: string;
|
|
17
|
+
navigatorPath: string;
|
|
18
|
+
navigatorSystemPrompt: string;
|
|
19
|
+
knowledgeBasePath: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Run the interactive conversation TUI
|
|
23
|
+
*
|
|
24
|
+
* @param options - Navigator configuration for the conversation
|
|
25
|
+
* @returns Promise that resolves when conversation ends
|
|
26
|
+
* @throws Error if terminal doesn't support interactive mode
|
|
27
|
+
*/
|
|
28
|
+
export declare function runConversationTUI(options: ConversationOptions): Promise<void>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAM/C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation module for interactive nav management
|
|
3
|
+
*
|
|
4
|
+
* Exports the runConversationTUI function which launches an Ink-based
|
|
5
|
+
* conversational interface for managing navigators.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { render } from "ink";
|
|
9
|
+
import { ConversationApp } from "./App.js";
|
|
10
|
+
export { buildConversationSystemPrompt } from "./prompts.js";
|
|
11
|
+
/**
|
|
12
|
+
* Check if the current environment supports interactive TTY input
|
|
13
|
+
*/
|
|
14
|
+
export function isInteractiveTerminal() {
|
|
15
|
+
return Boolean(process.stdin.isTTY &&
|
|
16
|
+
process.stdout.isTTY &&
|
|
17
|
+
process.stdin.setRawMode);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run the interactive conversation TUI
|
|
21
|
+
*
|
|
22
|
+
* @param options - Navigator configuration for the conversation
|
|
23
|
+
* @returns Promise that resolves when conversation ends
|
|
24
|
+
* @throws Error if terminal doesn't support interactive mode
|
|
25
|
+
*/
|
|
26
|
+
export function runConversationTUI(options) {
|
|
27
|
+
// Check for TTY support before attempting to render
|
|
28
|
+
if (!isInteractiveTerminal()) {
|
|
29
|
+
return Promise.reject(new Error("Interactive conversation requires a TTY terminal."));
|
|
30
|
+
}
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
try {
|
|
33
|
+
const instance = render(React.createElement(ConversationApp, options));
|
|
34
|
+
// Wait for the app to exit
|
|
35
|
+
instance.waitUntilExit().then(() => {
|
|
36
|
+
resolve();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
reject(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,CACZ,OAAO,CAAC,KAAK,CAAC,KAAK;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK;QACpB,OAAO,CAAC,KAAK,CAAC,UAAU,CACzB,CAAC;AACJ,CAAC;AAYD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC7D,oDAAoD;IACpD,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAC7B,mDAAmD,CACpD,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,CACrB,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,CAC9C,CAAC;YAEF,2BAA2B;YAC3B,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;gBACjC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation prompts for interactive nav management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Build a system prompt for conversation mode
|
|
6
|
+
* Incorporates the navigator's own CLAUDE.md plus conversation-specific guidance
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildConversationSystemPrompt(navigatorName: string, navigatorSystemPrompt: string, knowledgeBasePath: string): string;
|
|
9
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/conversation/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,EACrB,qBAAqB,EAAE,MAAM,EAC7B,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAsCR"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation prompts for interactive nav management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Build a system prompt for conversation mode
|
|
6
|
+
* Incorporates the navigator's own CLAUDE.md plus conversation-specific guidance
|
|
7
|
+
*/
|
|
8
|
+
export function buildConversationSystemPrompt(navigatorName, navigatorSystemPrompt, knowledgeBasePath) {
|
|
9
|
+
return `${navigatorSystemPrompt}
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Conversation Mode
|
|
14
|
+
|
|
15
|
+
You are now in **conversation mode** with the user. This is an interactive session where you can help the user manage and evolve this navigator.
|
|
16
|
+
|
|
17
|
+
### What You Can Do
|
|
18
|
+
|
|
19
|
+
1. **Answer questions** about the knowledge base
|
|
20
|
+
2. **Reorganize knowledge** - suggest or make changes to how information is structured
|
|
21
|
+
3. **Add new knowledge** - help capture new information into the knowledge base
|
|
22
|
+
4. **Update configuration** - modify settings, plugin configs, or behavior rules
|
|
23
|
+
5. **Explain your capabilities** - help the user understand what this navigator can do
|
|
24
|
+
|
|
25
|
+
### Navigator Context
|
|
26
|
+
|
|
27
|
+
- **Name**: ${navigatorName}
|
|
28
|
+
- **Knowledge Base**: ${knowledgeBasePath}
|
|
29
|
+
|
|
30
|
+
### Guidelines
|
|
31
|
+
|
|
32
|
+
- Be conversational and helpful
|
|
33
|
+
- When making changes to files, explain what you're doing
|
|
34
|
+
- For significant reorganizations, describe the plan before executing
|
|
35
|
+
- You have access to the navigator's knowledge base and can read/write files there
|
|
36
|
+
- Ask clarifying questions when requests are ambiguous
|
|
37
|
+
|
|
38
|
+
### Special Commands
|
|
39
|
+
|
|
40
|
+
The user can type these at any time:
|
|
41
|
+
- \`/help\` - Show available commands
|
|
42
|
+
- \`/status\` - Show current navigator state
|
|
43
|
+
- \`/exit\` or Ctrl+C - End the conversation
|
|
44
|
+
|
|
45
|
+
Remember: You are this navigator. Help the user make it better.`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/conversation/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,aAAqB,EACrB,qBAA6B,EAC7B,iBAAyB;IAEzB,OAAO,GAAG,qBAAqB;;;;;;;;;;;;;;;;;;cAkBnB,aAAa;wBACH,iBAAiB;;;;;;;;;;;;;;;;;gEAiBuB,CAAC;AACjE,CAAC"}
|