@redaksjon/protokoll 0.0.13 → 0.0.14
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 +198 -0
- package/dist/feedback.js +5193 -0
- package/dist/feedback.js.map +1 -0
- package/dist/main.js +1858 -9
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js +1330 -0
- package/dist/mcp/server.js.map +1 -0
- package/guide/index.md +16 -0
- package/guide/mcp-integration.md +341 -0
- package/package.json +5 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +13 -29
- package/dist/agentic/executor.js +0 -747
- package/dist/agentic/executor.js.map +0 -1
- package/dist/agentic/index.js +0 -19
- package/dist/agentic/index.js.map +0 -1
- package/dist/agentic/registry.js +0 -41
- package/dist/agentic/registry.js.map +0 -1
- package/dist/agentic/tools/lookup-person.js +0 -185
- package/dist/agentic/tools/lookup-person.js.map +0 -1
- package/dist/agentic/tools/lookup-project.js +0 -210
- package/dist/agentic/tools/lookup-project.js.map +0 -1
- package/dist/agentic/tools/route-note.js +0 -49
- package/dist/agentic/tools/route-note.js.map +0 -1
- package/dist/agentic/tools/store-context.js +0 -51
- package/dist/agentic/tools/store-context.js.map +0 -1
- package/dist/agentic/tools/verify-spelling.js +0 -57
- package/dist/agentic/tools/verify-spelling.js.map +0 -1
- package/dist/arguments.js +0 -178
- package/dist/arguments.js.map +0 -1
- package/dist/cli/action.js +0 -704
- package/dist/cli/action.js.map +0 -1
- package/dist/cli/config.js +0 -482
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/context.js +0 -466
- package/dist/cli/context.js.map +0 -1
- package/dist/cli/feedback.js +0 -858
- package/dist/cli/feedback.js.map +0 -1
- package/dist/cli/index.js +0 -103
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/install.js +0 -572
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/transcript.js +0 -199
- package/dist/cli/transcript.js.map +0 -1
- package/dist/constants.js +0 -91
- package/dist/constants.js.map +0 -1
- package/dist/context/discovery.js +0 -114
- package/dist/context/discovery.js.map +0 -1
- package/dist/context/index.js +0 -82
- package/dist/context/index.js.map +0 -1
- package/dist/context/storage.js +0 -184
- package/dist/context/storage.js.map +0 -1
- package/dist/interactive/handler.js +0 -524
- package/dist/interactive/handler.js.map +0 -1
- package/dist/interactive/index.js +0 -18
- package/dist/interactive/index.js.map +0 -1
- package/dist/interactive/onboarding.js +0 -28
- package/dist/interactive/onboarding.js.map +0 -1
- package/dist/logging.js +0 -46
- package/dist/logging.js.map +0 -1
- package/dist/output/index.js +0 -8
- package/dist/output/index.js.map +0 -1
- package/dist/output/manager.js +0 -150
- package/dist/output/manager.js.map +0 -1
- package/dist/phases/complete.js +0 -142
- package/dist/phases/complete.js.map +0 -1
- package/dist/phases/locate.js +0 -64
- package/dist/phases/locate.js.map +0 -1
- package/dist/pipeline/index.js +0 -8
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/orchestrator.js +0 -354
- package/dist/pipeline/orchestrator.js.map +0 -1
- package/dist/protokoll.js +0 -180
- package/dist/protokoll.js.map +0 -1
- package/dist/reasoning/client.js +0 -233
- package/dist/reasoning/client.js.map +0 -1
- package/dist/reasoning/index.js +0 -37
- package/dist/reasoning/index.js.map +0 -1
- package/dist/reasoning/strategy.js +0 -60
- package/dist/reasoning/strategy.js.map +0 -1
- package/dist/reflection/collector.js +0 -124
- package/dist/reflection/collector.js.map +0 -1
- package/dist/reflection/index.js +0 -16
- package/dist/reflection/index.js.map +0 -1
- package/dist/reflection/reporter.js +0 -238
- package/dist/reflection/reporter.js.map +0 -1
- package/dist/routing/classifier.js +0 -201
- package/dist/routing/classifier.js.map +0 -1
- package/dist/routing/index.js +0 -27
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/router.js +0 -153
- package/dist/routing/router.js.map +0 -1
- package/dist/transcription/index.js +0 -41
- package/dist/transcription/index.js.map +0 -1
- package/dist/transcription/service.js +0 -64
- package/dist/transcription/service.js.map +0 -1
- package/dist/transcription/types.js +0 -31
- package/dist/transcription/types.js.map +0 -1
- package/dist/util/dates.js +0 -96
- package/dist/util/dates.js.map +0 -1
- package/dist/util/media.js +0 -103
- package/dist/util/media.js.map +0 -1
- package/dist/util/metadata.js +0 -95
- package/dist/util/metadata.js.map +0 -1
- package/dist/util/sound.js +0 -116
- package/dist/util/sound.js.map +0 -1
- package/dist/util/storage.js +0 -135
- package/dist/util/storage.js.map +0 -1
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import * as readline from 'readline';
|
|
2
|
-
import { getLogger } from '../logging.js';
|
|
3
|
-
import { create as create$1 } from '../util/sound.js';
|
|
4
|
-
|
|
5
|
-
const createReadlineInterface = ()=>{
|
|
6
|
-
// Ensure stdin is in the correct mode for readline
|
|
7
|
-
// This helps prevent issues with some terminal emulators
|
|
8
|
-
if (process.stdin.setRawMode) {
|
|
9
|
-
try {
|
|
10
|
-
// Ensure we're NOT in raw mode - readline handles this itself
|
|
11
|
-
process.stdin.setRawMode(false);
|
|
12
|
-
} catch {
|
|
13
|
-
// Ignore errors - some environments don't support setRawMode
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return readline.createInterface({
|
|
17
|
-
input: process.stdin,
|
|
18
|
-
output: process.stdout,
|
|
19
|
-
terminal: true
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const askQuestion = (rl, question)=>{
|
|
23
|
-
return new Promise((resolve)=>{
|
|
24
|
-
rl.question(question, (answer)=>{
|
|
25
|
-
resolve(answer.trim());
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
// Helper to write to stdout without triggering no-console lint rule
|
|
30
|
-
const write = (text)=>process.stdout.write(text + '\n');
|
|
31
|
-
// Simplified project creation (used when creating project from term/person association)
|
|
32
|
-
const runCreateProjectFlow = async (rl, contextMessage)=>{
|
|
33
|
-
if (contextMessage) {
|
|
34
|
-
write('');
|
|
35
|
-
write(contextMessage);
|
|
36
|
-
}
|
|
37
|
-
// Step 1: Project name (required)
|
|
38
|
-
const projectName = await askQuestion(rl, '\nProject name: ');
|
|
39
|
-
if (!projectName) {
|
|
40
|
-
write('Project name is required. Skipping project creation.');
|
|
41
|
-
return {
|
|
42
|
-
action: 'skip'
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Step 2: Destination
|
|
46
|
-
const destination = await askQuestion(rl, '\nWhere should output be routed to? (Enter for default): ');
|
|
47
|
-
// Step 3: Description
|
|
48
|
-
const description = await askQuestion(rl, '\nCan you tell me something about this project? (Enter to skip): ');
|
|
49
|
-
return {
|
|
50
|
-
action: 'create',
|
|
51
|
-
projectName: projectName.trim(),
|
|
52
|
-
destination: destination || undefined,
|
|
53
|
-
description: description || undefined
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const runNewProjectWizard = async (rl, term, context, projectOptions)=>{
|
|
57
|
-
write('');
|
|
58
|
-
write('─'.repeat(60));
|
|
59
|
-
write(`[Unknown Project/Term]`);
|
|
60
|
-
write(`Term: "${term}"`);
|
|
61
|
-
write('');
|
|
62
|
-
if (context) {
|
|
63
|
-
// Display context with proper formatting (it now includes file info)
|
|
64
|
-
write(context);
|
|
65
|
-
}
|
|
66
|
-
write('─'.repeat(60));
|
|
67
|
-
// Step 1: Is this a project or a term?
|
|
68
|
-
const entityType = await askQuestion(rl, '\nIs this a Project or a Term? (P/T/X to ignore, or Enter to skip): ');
|
|
69
|
-
if (entityType === '' || entityType.toLowerCase() === 's' || entityType.toLowerCase() === 'skip') {
|
|
70
|
-
return {
|
|
71
|
-
action: 'skip'
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
// IGNORE FLOW - user doesn't want to be asked about this term again
|
|
75
|
-
if (entityType.toLowerCase() === 'x' || entityType.toLowerCase() === 'i' || entityType.toLowerCase() === 'ignore') {
|
|
76
|
-
write(`\n[Adding "${term}" to ignore list - you won't be asked about this again]`);
|
|
77
|
-
return {
|
|
78
|
-
action: 'ignore',
|
|
79
|
-
ignoredTerm: term
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
// PROJECT FLOW
|
|
83
|
-
if (entityType.toLowerCase() === 'p' || entityType.toLowerCase() === 'project') {
|
|
84
|
-
// Step 2: Project name
|
|
85
|
-
const projectName = await askQuestion(rl, `\nWhat is this project's name? [${term}]: `);
|
|
86
|
-
const finalName = projectName || term;
|
|
87
|
-
// Step 3: Destination
|
|
88
|
-
const destination = await askQuestion(rl, '\nWhere should output be routed to? (Enter for default): ');
|
|
89
|
-
// Step 4: Description
|
|
90
|
-
const description = await askQuestion(rl, '\nCan you tell me something about this project? (Enter to skip): ');
|
|
91
|
-
return {
|
|
92
|
-
action: 'create',
|
|
93
|
-
projectName: finalName,
|
|
94
|
-
destination: destination || undefined,
|
|
95
|
-
description: description || undefined
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
// TERM FLOW
|
|
99
|
-
if (entityType.toLowerCase() === 't' || entityType.toLowerCase() === 'term') {
|
|
100
|
-
// Step 2: Validate spelling
|
|
101
|
-
const termCorrection = await askQuestion(rl, `\nIs "${term}" spelled correctly? (Enter to accept, or type correction): `);
|
|
102
|
-
const finalTermName = termCorrection || term;
|
|
103
|
-
if (termCorrection) {
|
|
104
|
-
write(`Term updated to: "${finalTermName}"`);
|
|
105
|
-
}
|
|
106
|
-
// Step 3: Is this an acronym?
|
|
107
|
-
const expansion = await askQuestion(rl, `\nIf "${finalTermName}" is an acronym, what does it stand for? (Enter to skip): `);
|
|
108
|
-
// Step 4: Which project(s) is this term associated with?
|
|
109
|
-
const termProjects = [];
|
|
110
|
-
let createdProject;
|
|
111
|
-
if (projectOptions && projectOptions.length > 0) {
|
|
112
|
-
write('\nExisting projects:');
|
|
113
|
-
projectOptions.forEach((opt, i)=>{
|
|
114
|
-
write(` ${i + 1}. ${opt}`);
|
|
115
|
-
});
|
|
116
|
-
write(` N. Create a new project`);
|
|
117
|
-
const projectSelection = await askQuestion(rl, `\nWhich project(s) is "${finalTermName}" associated with? (Enter numbers separated by commas, N for new, or Enter to skip): `);
|
|
118
|
-
if (projectSelection.toLowerCase().includes('n')) {
|
|
119
|
-
// User wants to create a new project to associate with this term
|
|
120
|
-
write('');
|
|
121
|
-
write(`[Create New Project for Term "${finalTermName}"]`);
|
|
122
|
-
createdProject = await runCreateProjectFlow(rl, `The term "${finalTermName}" will be associated with this new project.`);
|
|
123
|
-
if (createdProject.action === 'create' && createdProject.projectName) {
|
|
124
|
-
write(`\n[Project "${createdProject.projectName}" will be created and associated with term "${finalTermName}"]`);
|
|
125
|
-
}
|
|
126
|
-
} else if (projectSelection) {
|
|
127
|
-
const indices = projectSelection.split(',').map((s)=>parseInt(s.trim(), 10) - 1);
|
|
128
|
-
for (const idx of indices){
|
|
129
|
-
if (!isNaN(idx) && idx >= 0 && idx < projectOptions.length) {
|
|
130
|
-
termProjects.push(idx);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (termProjects.length > 0) {
|
|
134
|
-
write(`Associated with: ${termProjects.map((i)=>projectOptions[i].split(' - ')[0]).join(', ')}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
// No existing projects - offer to create one
|
|
139
|
-
const createNew = await askQuestion(rl, `\nNo existing projects found. Create a new project for term "${finalTermName}"? (Y/N, or Enter to skip): `);
|
|
140
|
-
if (createNew.toLowerCase() === 'y' || createNew.toLowerCase() === 'yes') {
|
|
141
|
-
write('');
|
|
142
|
-
write(`[Create New Project for Term "${finalTermName}"]`);
|
|
143
|
-
createdProject = await runCreateProjectFlow(rl, `The term "${finalTermName}" will be associated with this new project.`);
|
|
144
|
-
if (createdProject.action === 'create' && createdProject.projectName) {
|
|
145
|
-
write(`\n[Project "${createdProject.projectName}" will be created and associated with term "${finalTermName}"]`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Step 5: Description
|
|
150
|
-
const termDesc = await askQuestion(rl, `\nBrief description of "${finalTermName}"? (Enter to skip): `);
|
|
151
|
-
return {
|
|
152
|
-
action: 'term',
|
|
153
|
-
termName: finalTermName,
|
|
154
|
-
termExpansion: expansion || undefined,
|
|
155
|
-
termProjects: termProjects.length > 0 ? termProjects : undefined,
|
|
156
|
-
termDescription: termDesc || undefined,
|
|
157
|
-
createdProject
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
// Unrecognized input
|
|
161
|
-
write('\nUnrecognized input. Please enter P for Project, T for Term, or press Enter to skip.');
|
|
162
|
-
return {
|
|
163
|
-
action: 'skip'
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
const runNewPersonWizard = async (rl, name, context, projectOptions)=>{
|
|
167
|
-
write('');
|
|
168
|
-
write('─'.repeat(60));
|
|
169
|
-
write(`[Unknown Person Detected]`);
|
|
170
|
-
write(`Name heard: "${name}"`);
|
|
171
|
-
write('');
|
|
172
|
-
if (context) {
|
|
173
|
-
// Display context with proper formatting (it now includes file info)
|
|
174
|
-
write(context);
|
|
175
|
-
}
|
|
176
|
-
write('─'.repeat(60));
|
|
177
|
-
// Step 1: Confirm name spelling
|
|
178
|
-
const nameCorrection = await askQuestion(rl, `\nIs the name spelled correctly? (Enter to accept, or type correction): `);
|
|
179
|
-
const finalName = nameCorrection || name;
|
|
180
|
-
if (nameCorrection) {
|
|
181
|
-
write(`Name updated to: "${finalName}"`);
|
|
182
|
-
}
|
|
183
|
-
// Step 2: Ask for organization/company
|
|
184
|
-
const organization = await askQuestion(rl, `\nWhat organization/company is ${finalName} with? (Enter to skip): `);
|
|
185
|
-
// Step 3: Project association
|
|
186
|
-
let linkedProjectIndex;
|
|
187
|
-
let createdProject;
|
|
188
|
-
// Show project options with "N" for new project
|
|
189
|
-
if (projectOptions && projectOptions.length > 0) {
|
|
190
|
-
write('\nExisting projects:');
|
|
191
|
-
projectOptions.forEach((opt, i)=>{
|
|
192
|
-
write(` ${i + 1}. ${opt}`);
|
|
193
|
-
});
|
|
194
|
-
write(` N. Create a new project`);
|
|
195
|
-
const projectSelection = await askQuestion(rl, `\nWhich project is ${finalName} related to? (Enter number, N for new, or Enter to skip): `);
|
|
196
|
-
if (projectSelection.toLowerCase() === 'n') {
|
|
197
|
-
// User wants to create a new project for this person
|
|
198
|
-
write('');
|
|
199
|
-
write(`[Create New Project for ${finalName}]`);
|
|
200
|
-
const contextMsg = organization ? `Creating project for ${finalName} (${organization})` : `Creating project for ${finalName}`;
|
|
201
|
-
createdProject = await runCreateProjectFlow(rl, contextMsg);
|
|
202
|
-
if (createdProject.action === 'create' && createdProject.projectName) {
|
|
203
|
-
write(`\n[Project "${createdProject.projectName}" will be created and linked to ${finalName}]`);
|
|
204
|
-
}
|
|
205
|
-
} else if (projectSelection && /^\d+$/.test(projectSelection)) {
|
|
206
|
-
const idx = parseInt(projectSelection, 10) - 1;
|
|
207
|
-
if (idx >= 0 && idx < projectOptions.length) {
|
|
208
|
-
linkedProjectIndex = idx;
|
|
209
|
-
write(`Linked to: ${projectOptions[idx]}`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
// No existing projects - offer to create one
|
|
214
|
-
const createNew = await askQuestion(rl, `\nNo existing projects found. Create a new project for ${finalName}? (Y/N, or Enter to skip): `);
|
|
215
|
-
if (createNew.toLowerCase() === 'y' || createNew.toLowerCase() === 'yes') {
|
|
216
|
-
write('');
|
|
217
|
-
write(`[Create New Project for ${finalName}]`);
|
|
218
|
-
const contextMsg = organization ? `Creating project for ${finalName} (${organization})` : `Creating project for ${finalName}`;
|
|
219
|
-
createdProject = await runCreateProjectFlow(rl, contextMsg);
|
|
220
|
-
if (createdProject.action === 'create' && createdProject.projectName) {
|
|
221
|
-
write(`\n[Project "${createdProject.projectName}" will be created and linked to ${finalName}]`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// Step 4: Ask for notes about the person
|
|
226
|
-
const notes = await askQuestion(rl, `\nAny notes about ${finalName}? (Enter to skip): `);
|
|
227
|
-
// Determine if we should create the person
|
|
228
|
-
const hasInfo = organization || linkedProjectIndex !== undefined || createdProject || notes;
|
|
229
|
-
if (!hasInfo) {
|
|
230
|
-
// User skipped everything - confirm if they want to skip entirely
|
|
231
|
-
const confirm = await askQuestion(rl, `\nNo information provided. Skip saving ${finalName}? (Enter to skip, or any key to save anyway): `);
|
|
232
|
-
if (confirm === '') {
|
|
233
|
-
return {
|
|
234
|
-
action: 'skip'
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
action: 'create',
|
|
240
|
-
personName: finalName,
|
|
241
|
-
organization: organization || undefined,
|
|
242
|
-
linkedProjectIndex,
|
|
243
|
-
notes: notes || undefined,
|
|
244
|
-
createdProject
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
const formatClarificationPrompt = (request)=>{
|
|
248
|
-
const lines = [];
|
|
249
|
-
lines.push('');
|
|
250
|
-
lines.push('─'.repeat(60));
|
|
251
|
-
switch(request.type){
|
|
252
|
-
case 'name_spelling':
|
|
253
|
-
lines.push(`[Name Spelling Clarification]`);
|
|
254
|
-
lines.push(`Context: ${request.context}`);
|
|
255
|
-
lines.push(`Heard: "${request.term}"`);
|
|
256
|
-
if (request.suggestion) {
|
|
257
|
-
lines.push(`Suggested correction: "${request.suggestion}"`);
|
|
258
|
-
}
|
|
259
|
-
lines.push('');
|
|
260
|
-
lines.push('Enter correct spelling (or press Enter to accept suggestion):');
|
|
261
|
-
break;
|
|
262
|
-
case 'new_person':
|
|
263
|
-
lines.push(`[New Person Detected]`);
|
|
264
|
-
lines.push(`Context: ${request.context}`);
|
|
265
|
-
lines.push(`Name heard: "${request.term}"`);
|
|
266
|
-
lines.push('');
|
|
267
|
-
lines.push('Who is this person? (brief description, or press Enter to skip):');
|
|
268
|
-
break;
|
|
269
|
-
case 'new_project':
|
|
270
|
-
// This case is handled by the wizard, but provide fallback prompt
|
|
271
|
-
lines.push(`[Unknown Project/Term]`);
|
|
272
|
-
lines.push(`Term: "${request.term}"`);
|
|
273
|
-
if (request.context) {
|
|
274
|
-
lines.push(`${request.context}`);
|
|
275
|
-
}
|
|
276
|
-
lines.push('');
|
|
277
|
-
lines.push('Is this a new project? (Y/N, or Enter to skip):');
|
|
278
|
-
break;
|
|
279
|
-
case 'new_company':
|
|
280
|
-
lines.push(`[New Company Detected]`);
|
|
281
|
-
lines.push(`Context: ${request.context}`);
|
|
282
|
-
lines.push(`Company name: "${request.term}"`);
|
|
283
|
-
lines.push('');
|
|
284
|
-
lines.push('Any notes about this company? (or press Enter to skip):');
|
|
285
|
-
break;
|
|
286
|
-
case 'new_term':
|
|
287
|
-
lines.push(`[New Term Found]`);
|
|
288
|
-
lines.push(`Context: ${request.context}`);
|
|
289
|
-
lines.push(`Term: "${request.term}"`);
|
|
290
|
-
lines.push('');
|
|
291
|
-
lines.push('What does this term mean? (brief description, or press Enter to skip):');
|
|
292
|
-
break;
|
|
293
|
-
case 'routing_decision':
|
|
294
|
-
lines.push(`[Routing Decision Required]`);
|
|
295
|
-
lines.push(`Context: ${request.context}`);
|
|
296
|
-
if (request.options && request.options.length > 0) {
|
|
297
|
-
lines.push('Available destinations:');
|
|
298
|
-
request.options.forEach((opt, i)=>{
|
|
299
|
-
lines.push(` ${i + 1}. ${opt}`);
|
|
300
|
-
});
|
|
301
|
-
lines.push('');
|
|
302
|
-
lines.push('Enter number or destination path:');
|
|
303
|
-
} else {
|
|
304
|
-
lines.push('');
|
|
305
|
-
lines.push('Where should this note be filed?');
|
|
306
|
-
}
|
|
307
|
-
break;
|
|
308
|
-
case 'low_confidence_routing':
|
|
309
|
-
lines.push(`[Confirm Note Routing]`);
|
|
310
|
-
lines.push(`Confidence: ${request.term}`);
|
|
311
|
-
lines.push(`${request.context}`);
|
|
312
|
-
lines.push('');
|
|
313
|
-
lines.push('Is this correct? (Y/Enter to accept, or enter different path):');
|
|
314
|
-
break;
|
|
315
|
-
case 'first_run_onboarding':
|
|
316
|
-
lines.push(`[First Run Setup]`);
|
|
317
|
-
lines.push(`${request.context}`);
|
|
318
|
-
lines.push('');
|
|
319
|
-
if (request.options && request.options.length > 0) {
|
|
320
|
-
request.options.forEach((opt, i)=>{
|
|
321
|
-
lines.push(` ${i + 1}. ${opt}`);
|
|
322
|
-
});
|
|
323
|
-
lines.push('');
|
|
324
|
-
lines.push('Enter your choice:');
|
|
325
|
-
} else {
|
|
326
|
-
lines.push('Enter your response:');
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
case 'general':
|
|
330
|
-
default:
|
|
331
|
-
lines.push(`[Clarification Needed]`);
|
|
332
|
-
lines.push(`${request.context}`);
|
|
333
|
-
if (request.term) {
|
|
334
|
-
lines.push(`Term: "${request.term}"`);
|
|
335
|
-
}
|
|
336
|
-
if (request.suggestion) {
|
|
337
|
-
lines.push(`Suggested spelling: "${request.suggestion}"`);
|
|
338
|
-
lines.push('');
|
|
339
|
-
lines.push('Press Enter or Y to accept suggestion, or type alternative:');
|
|
340
|
-
} else {
|
|
341
|
-
lines.push('');
|
|
342
|
-
lines.push('Your response:');
|
|
343
|
-
}
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
lines.push('─'.repeat(60));
|
|
347
|
-
return lines.join('\n') + '\n> ';
|
|
348
|
-
};
|
|
349
|
-
const create = (config)=>{
|
|
350
|
-
var _config_silent;
|
|
351
|
-
const logger = getLogger();
|
|
352
|
-
const sound = create$1({
|
|
353
|
-
silent: (_config_silent = config.silent) !== null && _config_silent !== void 0 ? _config_silent : false
|
|
354
|
-
});
|
|
355
|
-
let session = null;
|
|
356
|
-
let rl = null;
|
|
357
|
-
const startSession = ()=>{
|
|
358
|
-
session = {
|
|
359
|
-
requests: [],
|
|
360
|
-
responses: [],
|
|
361
|
-
startedAt: new Date()
|
|
362
|
-
};
|
|
363
|
-
// Check if we can run interactively:
|
|
364
|
-
// 1. Interactive mode must be enabled (not --batch)
|
|
365
|
-
// 2. stdin must be a TTY (not piped/cron/etc)
|
|
366
|
-
const isTTY = process.stdin.isTTY === true;
|
|
367
|
-
if (config.enabled && isTTY) {
|
|
368
|
-
// Only create readline interface if one doesn't already exist
|
|
369
|
-
// This prevents duplicate input handlers when processing multiple files
|
|
370
|
-
if (!rl) {
|
|
371
|
-
rl = createReadlineInterface();
|
|
372
|
-
logger.info('Interactive session started - will prompt for clarifications');
|
|
373
|
-
} else {
|
|
374
|
-
logger.debug('Interactive session continued (readline already active)');
|
|
375
|
-
}
|
|
376
|
-
} else if (config.enabled && !isTTY) {
|
|
377
|
-
logger.info('Interactive mode enabled but stdin is not a TTY - running in auto-resolve mode');
|
|
378
|
-
} else {
|
|
379
|
-
logger.debug('Interactive session started (batch mode)');
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
const endSession = ()=>{
|
|
383
|
-
if (!session) {
|
|
384
|
-
throw new Error('No active session');
|
|
385
|
-
}
|
|
386
|
-
if (rl) {
|
|
387
|
-
// Remove all listeners before closing to prevent any lingering handlers
|
|
388
|
-
// Check if method exists (may not in mocks)
|
|
389
|
-
if (typeof rl.removeAllListeners === 'function') {
|
|
390
|
-
rl.removeAllListeners();
|
|
391
|
-
}
|
|
392
|
-
rl.close();
|
|
393
|
-
rl = null;
|
|
394
|
-
// Resume stdin in case it was paused
|
|
395
|
-
if (process.stdin.isPaused && process.stdin.isPaused()) {
|
|
396
|
-
process.stdin.resume();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
session.completedAt = new Date();
|
|
400
|
-
const completed = session;
|
|
401
|
-
session = null;
|
|
402
|
-
logger.info('Interactive session ended', {
|
|
403
|
-
requests: completed.requests.length,
|
|
404
|
-
responses: completed.responses.length
|
|
405
|
-
});
|
|
406
|
-
return completed;
|
|
407
|
-
};
|
|
408
|
-
const handleClarification = async (request)=>{
|
|
409
|
-
if (session) {
|
|
410
|
-
session.requests.push(request);
|
|
411
|
-
}
|
|
412
|
-
// In non-interactive mode, return the suggestion or the original term
|
|
413
|
-
if (!config.enabled || !rl) {
|
|
414
|
-
const response = {
|
|
415
|
-
type: request.type,
|
|
416
|
-
term: request.term,
|
|
417
|
-
response: request.suggestion ? request.suggestion : request.term,
|
|
418
|
-
shouldRemember: false
|
|
419
|
-
};
|
|
420
|
-
if (session) {
|
|
421
|
-
session.responses.push(response);
|
|
422
|
-
}
|
|
423
|
-
logger.debug('Clarification auto-resolved (non-interactive)', {
|
|
424
|
-
type: request.type,
|
|
425
|
-
term: request.term,
|
|
426
|
-
response: response.response
|
|
427
|
-
});
|
|
428
|
-
return response;
|
|
429
|
-
}
|
|
430
|
-
// Interactive mode - actually prompt the user
|
|
431
|
-
// Play notification sound to get user's attention (like Cursor does)
|
|
432
|
-
await sound.playNotification();
|
|
433
|
-
// Special handling for new_project - use wizard
|
|
434
|
-
if (request.type === 'new_project') {
|
|
435
|
-
const wizardResult = await runNewProjectWizard(rl, request.term, request.context, request.options);
|
|
436
|
-
const response = {
|
|
437
|
-
type: request.type,
|
|
438
|
-
term: request.term,
|
|
439
|
-
response: wizardResult.action,
|
|
440
|
-
shouldRemember: wizardResult.action !== 'skip',
|
|
441
|
-
additionalInfo: wizardResult
|
|
442
|
-
};
|
|
443
|
-
if (session) {
|
|
444
|
-
session.responses.push(response);
|
|
445
|
-
}
|
|
446
|
-
logger.debug('New project wizard completed', {
|
|
447
|
-
term: request.term,
|
|
448
|
-
action: wizardResult.action,
|
|
449
|
-
additionalInfo: wizardResult
|
|
450
|
-
});
|
|
451
|
-
return response;
|
|
452
|
-
}
|
|
453
|
-
// Special handling for new_person - use wizard
|
|
454
|
-
if (request.type === 'new_person') {
|
|
455
|
-
const wizardResult = await runNewPersonWizard(rl, request.term, request.context, request.options);
|
|
456
|
-
const response = {
|
|
457
|
-
type: request.type,
|
|
458
|
-
term: request.term,
|
|
459
|
-
response: wizardResult.action,
|
|
460
|
-
shouldRemember: wizardResult.action !== 'skip',
|
|
461
|
-
additionalInfo: wizardResult
|
|
462
|
-
};
|
|
463
|
-
if (session) {
|
|
464
|
-
session.responses.push(response);
|
|
465
|
-
}
|
|
466
|
-
logger.debug('New person wizard completed', {
|
|
467
|
-
term: request.term,
|
|
468
|
-
action: wizardResult.action,
|
|
469
|
-
additionalInfo: wizardResult
|
|
470
|
-
});
|
|
471
|
-
return response;
|
|
472
|
-
}
|
|
473
|
-
// Standard single-prompt flow for other types
|
|
474
|
-
const prompt = formatClarificationPrompt(request);
|
|
475
|
-
const userInput = await askQuestion(rl, prompt);
|
|
476
|
-
// Process the user's response
|
|
477
|
-
let finalResponse;
|
|
478
|
-
let shouldRemember = false;
|
|
479
|
-
if (userInput === '' || userInput.toLowerCase() === 'y') {
|
|
480
|
-
// User pressed Enter or typed Y - use suggestion or original
|
|
481
|
-
finalResponse = request.suggestion || request.term;
|
|
482
|
-
} else if (request.options && /^\d+$/.test(userInput)) {
|
|
483
|
-
// User entered a number - select from options
|
|
484
|
-
const index = parseInt(userInput, 10) - 1;
|
|
485
|
-
if (index >= 0 && index < request.options.length) {
|
|
486
|
-
finalResponse = request.options[index];
|
|
487
|
-
} else {
|
|
488
|
-
finalResponse = userInput;
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
finalResponse = userInput;
|
|
492
|
-
// If user provided a custom answer, they might want to remember it
|
|
493
|
-
shouldRemember = true;
|
|
494
|
-
}
|
|
495
|
-
const response = {
|
|
496
|
-
type: request.type,
|
|
497
|
-
term: request.term,
|
|
498
|
-
response: finalResponse,
|
|
499
|
-
shouldRemember
|
|
500
|
-
};
|
|
501
|
-
if (session) {
|
|
502
|
-
session.responses.push(response);
|
|
503
|
-
}
|
|
504
|
-
logger.debug('Clarification resolved via user input', {
|
|
505
|
-
type: request.type,
|
|
506
|
-
term: request.term,
|
|
507
|
-
response: response.response,
|
|
508
|
-
shouldRemember
|
|
509
|
-
});
|
|
510
|
-
return response;
|
|
511
|
-
};
|
|
512
|
-
const isEnabled = ()=>config.enabled;
|
|
513
|
-
const getSession = ()=>session;
|
|
514
|
-
return {
|
|
515
|
-
startSession,
|
|
516
|
-
endSession,
|
|
517
|
-
handleClarification,
|
|
518
|
-
isEnabled,
|
|
519
|
-
getSession
|
|
520
|
-
};
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
export { create };
|
|
524
|
-
//# sourceMappingURL=handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sources":["../../src/interactive/handler.ts"],"sourcesContent":["/**\n * Interactive Handler\n * \n * Manages interactive sessions and clarification requests.\n * Uses readline for actual user prompting.\n * Plays notification sounds when user input is needed (like Cursor).\n */\n\nimport * as readline from 'readline';\nimport { \n InteractiveConfig, \n InteractiveSession, \n ClarificationRequest, \n ClarificationResponse,\n NewProjectWizardResult,\n NewPersonWizardResult,\n} from './types';\nimport * as Logging from '../logging';\nimport * as Sound from '../util/sound';\n\nexport interface HandlerInstance {\n startSession(): void;\n endSession(): InteractiveSession;\n handleClarification(request: ClarificationRequest): Promise<ClarificationResponse>;\n isEnabled(): boolean;\n getSession(): InteractiveSession | null;\n}\n\nconst createReadlineInterface = () => {\n // Ensure stdin is in the correct mode for readline\n // This helps prevent issues with some terminal emulators\n if (process.stdin.setRawMode) {\n try {\n // Ensure we're NOT in raw mode - readline handles this itself\n process.stdin.setRawMode(false);\n } catch {\n // Ignore errors - some environments don't support setRawMode\n }\n }\n \n return readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: true, // Explicitly enable terminal mode for proper echo handling\n });\n};\n\nconst askQuestion = (rl: readline.Interface, question: string): Promise<string> => {\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n resolve(answer.trim());\n });\n });\n};\n\n// Helper to write to stdout without triggering no-console lint rule\nconst write = (text: string) => process.stdout.write(text + '\\n');\n\n// Simplified project creation (used when creating project from term/person association)\nconst runCreateProjectFlow = async (\n rl: readline.Interface,\n contextMessage?: string\n): Promise<NewProjectWizardResult> => {\n if (contextMessage) {\n write('');\n write(contextMessage);\n }\n \n // Step 1: Project name (required)\n const projectName = await askQuestion(rl, '\\nProject name: ');\n \n if (!projectName) {\n write('Project name is required. Skipping project creation.');\n return { action: 'skip' };\n }\n \n // Step 2: Destination\n const destination = await askQuestion(rl, '\\nWhere should output be routed to? (Enter for default): ');\n \n // Step 3: Description\n const description = await askQuestion(rl, '\\nCan you tell me something about this project? (Enter to skip): ');\n \n return {\n action: 'create',\n projectName: projectName.trim(),\n destination: destination || undefined,\n description: description || undefined,\n };\n};\n\nconst runNewProjectWizard = async (\n rl: readline.Interface,\n term: string,\n context: string | undefined,\n projectOptions: string[] | undefined\n): Promise<NewProjectWizardResult> => {\n write('');\n write('─'.repeat(60));\n write(`[Unknown Project/Term]`);\n write(`Term: \"${term}\"`);\n write('');\n if (context) {\n // Display context with proper formatting (it now includes file info)\n write(context);\n }\n write('─'.repeat(60));\n \n // Step 1: Is this a project or a term?\n const entityType = await askQuestion(rl, '\\nIs this a Project or a Term? (P/T/X to ignore, or Enter to skip): ');\n \n if (entityType === '' || entityType.toLowerCase() === 's' || entityType.toLowerCase() === 'skip') {\n return { action: 'skip' };\n }\n \n // IGNORE FLOW - user doesn't want to be asked about this term again\n if (entityType.toLowerCase() === 'x' || entityType.toLowerCase() === 'i' || entityType.toLowerCase() === 'ignore') {\n write(`\\n[Adding \"${term}\" to ignore list - you won't be asked about this again]`);\n return { action: 'ignore', ignoredTerm: term };\n }\n \n // PROJECT FLOW\n if (entityType.toLowerCase() === 'p' || entityType.toLowerCase() === 'project') {\n // Step 2: Project name\n const projectName = await askQuestion(rl, `\\nWhat is this project's name? [${term}]: `);\n const finalName = projectName || term;\n \n // Step 3: Destination\n const destination = await askQuestion(rl, '\\nWhere should output be routed to? (Enter for default): ');\n \n // Step 4: Description\n const description = await askQuestion(rl, '\\nCan you tell me something about this project? (Enter to skip): ');\n \n return {\n action: 'create',\n projectName: finalName,\n destination: destination || undefined,\n description: description || undefined,\n };\n }\n \n // TERM FLOW\n if (entityType.toLowerCase() === 't' || entityType.toLowerCase() === 'term') {\n // Step 2: Validate spelling\n const termCorrection = await askQuestion(rl, `\\nIs \"${term}\" spelled correctly? (Enter to accept, or type correction): `);\n const finalTermName = termCorrection || term;\n \n if (termCorrection) {\n write(`Term updated to: \"${finalTermName}\"`);\n }\n \n // Step 3: Is this an acronym?\n const expansion = await askQuestion(rl, `\\nIf \"${finalTermName}\" is an acronym, what does it stand for? (Enter to skip): `);\n \n // Step 4: Which project(s) is this term associated with?\n const termProjects: number[] = [];\n let createdProject: NewProjectWizardResult | undefined;\n \n if (projectOptions && projectOptions.length > 0) {\n write('\\nExisting projects:');\n projectOptions.forEach((opt, i) => {\n write(` ${i + 1}. ${opt}`);\n });\n write(` N. Create a new project`);\n \n const projectSelection = await askQuestion(rl, `\\nWhich project(s) is \"${finalTermName}\" associated with? (Enter numbers separated by commas, N for new, or Enter to skip): `);\n \n if (projectSelection.toLowerCase().includes('n')) {\n // User wants to create a new project to associate with this term\n write('');\n write(`[Create New Project for Term \"${finalTermName}\"]`);\n createdProject = await runCreateProjectFlow(rl, `The term \"${finalTermName}\" will be associated with this new project.`);\n \n if (createdProject.action === 'create' && createdProject.projectName) {\n write(`\\n[Project \"${createdProject.projectName}\" will be created and associated with term \"${finalTermName}\"]`);\n }\n } else if (projectSelection) {\n const indices = projectSelection.split(',').map(s => parseInt(s.trim(), 10) - 1);\n for (const idx of indices) {\n if (!isNaN(idx) && idx >= 0 && idx < projectOptions.length) {\n termProjects.push(idx);\n }\n }\n \n if (termProjects.length > 0) {\n write(`Associated with: ${termProjects.map(i => projectOptions[i].split(' - ')[0]).join(', ')}`);\n }\n }\n } else {\n // No existing projects - offer to create one\n const createNew = await askQuestion(rl, `\\nNo existing projects found. Create a new project for term \"${finalTermName}\"? (Y/N, or Enter to skip): `);\n \n if (createNew.toLowerCase() === 'y' || createNew.toLowerCase() === 'yes') {\n write('');\n write(`[Create New Project for Term \"${finalTermName}\"]`);\n createdProject = await runCreateProjectFlow(rl, `The term \"${finalTermName}\" will be associated with this new project.`);\n \n if (createdProject.action === 'create' && createdProject.projectName) {\n write(`\\n[Project \"${createdProject.projectName}\" will be created and associated with term \"${finalTermName}\"]`);\n }\n }\n }\n \n // Step 5: Description\n const termDesc = await askQuestion(rl, `\\nBrief description of \"${finalTermName}\"? (Enter to skip): `);\n \n return {\n action: 'term',\n termName: finalTermName,\n termExpansion: expansion || undefined,\n termProjects: termProjects.length > 0 ? termProjects : undefined,\n termDescription: termDesc || undefined,\n createdProject,\n };\n }\n \n // Unrecognized input\n write('\\nUnrecognized input. Please enter P for Project, T for Term, or press Enter to skip.');\n return { action: 'skip' };\n};\n\nconst runNewPersonWizard = async (\n rl: readline.Interface,\n name: string,\n context: string | undefined,\n projectOptions: string[] | undefined\n): Promise<NewPersonWizardResult> => {\n write('');\n write('─'.repeat(60));\n write(`[Unknown Person Detected]`);\n write(`Name heard: \"${name}\"`);\n write('');\n if (context) {\n // Display context with proper formatting (it now includes file info)\n write(context);\n }\n write('─'.repeat(60));\n \n // Step 1: Confirm name spelling\n const nameCorrection = await askQuestion(rl, `\\nIs the name spelled correctly? (Enter to accept, or type correction): `);\n const finalName = nameCorrection || name;\n \n if (nameCorrection) {\n write(`Name updated to: \"${finalName}\"`);\n }\n \n // Step 2: Ask for organization/company\n const organization = await askQuestion(rl, `\\nWhat organization/company is ${finalName} with? (Enter to skip): `);\n \n // Step 3: Project association\n let linkedProjectIndex: number | undefined;\n let createdProject: NewProjectWizardResult | undefined;\n \n // Show project options with \"N\" for new project\n if (projectOptions && projectOptions.length > 0) {\n write('\\nExisting projects:');\n projectOptions.forEach((opt, i) => {\n write(` ${i + 1}. ${opt}`);\n });\n write(` N. Create a new project`);\n \n const projectSelection = await askQuestion(rl, `\\nWhich project is ${finalName} related to? (Enter number, N for new, or Enter to skip): `);\n \n if (projectSelection.toLowerCase() === 'n') {\n // User wants to create a new project for this person\n write('');\n write(`[Create New Project for ${finalName}]`);\n const contextMsg = organization \n ? `Creating project for ${finalName} (${organization})`\n : `Creating project for ${finalName}`;\n createdProject = await runCreateProjectFlow(rl, contextMsg);\n \n if (createdProject.action === 'create' && createdProject.projectName) {\n write(`\\n[Project \"${createdProject.projectName}\" will be created and linked to ${finalName}]`);\n }\n } else if (projectSelection && /^\\d+$/.test(projectSelection)) {\n const idx = parseInt(projectSelection, 10) - 1;\n if (idx >= 0 && idx < projectOptions.length) {\n linkedProjectIndex = idx;\n write(`Linked to: ${projectOptions[idx]}`);\n }\n }\n } else {\n // No existing projects - offer to create one\n const createNew = await askQuestion(rl, `\\nNo existing projects found. Create a new project for ${finalName}? (Y/N, or Enter to skip): `);\n \n if (createNew.toLowerCase() === 'y' || createNew.toLowerCase() === 'yes') {\n write('');\n write(`[Create New Project for ${finalName}]`);\n const contextMsg = organization \n ? `Creating project for ${finalName} (${organization})`\n : `Creating project for ${finalName}`;\n createdProject = await runCreateProjectFlow(rl, contextMsg);\n \n if (createdProject.action === 'create' && createdProject.projectName) {\n write(`\\n[Project \"${createdProject.projectName}\" will be created and linked to ${finalName}]`);\n }\n }\n }\n \n // Step 4: Ask for notes about the person\n const notes = await askQuestion(rl, `\\nAny notes about ${finalName}? (Enter to skip): `);\n \n // Determine if we should create the person\n const hasInfo = organization || linkedProjectIndex !== undefined || createdProject || notes;\n \n if (!hasInfo) {\n // User skipped everything - confirm if they want to skip entirely\n const confirm = await askQuestion(rl, `\\nNo information provided. Skip saving ${finalName}? (Enter to skip, or any key to save anyway): `);\n if (confirm === '') {\n return { action: 'skip' };\n }\n }\n \n return {\n action: 'create',\n personName: finalName,\n organization: organization || undefined,\n linkedProjectIndex,\n notes: notes || undefined,\n createdProject,\n };\n};\n\nconst formatClarificationPrompt = (request: ClarificationRequest): string => {\n const lines: string[] = [];\n \n lines.push('');\n lines.push('─'.repeat(60));\n \n switch (request.type) {\n case 'name_spelling':\n lines.push(`[Name Spelling Clarification]`);\n lines.push(`Context: ${request.context}`);\n lines.push(`Heard: \"${request.term}\"`);\n if (request.suggestion) {\n lines.push(`Suggested correction: \"${request.suggestion}\"`);\n }\n lines.push('');\n lines.push('Enter correct spelling (or press Enter to accept suggestion):');\n break;\n \n case 'new_person':\n lines.push(`[New Person Detected]`);\n lines.push(`Context: ${request.context}`);\n lines.push(`Name heard: \"${request.term}\"`);\n lines.push('');\n lines.push('Who is this person? (brief description, or press Enter to skip):');\n break;\n \n case 'new_project':\n // This case is handled by the wizard, but provide fallback prompt\n lines.push(`[Unknown Project/Term]`);\n lines.push(`Term: \"${request.term}\"`);\n if (request.context) {\n lines.push(`${request.context}`);\n }\n lines.push('');\n lines.push('Is this a new project? (Y/N, or Enter to skip):');\n break;\n \n case 'new_company':\n lines.push(`[New Company Detected]`);\n lines.push(`Context: ${request.context}`);\n lines.push(`Company name: \"${request.term}\"`);\n lines.push('');\n lines.push('Any notes about this company? (or press Enter to skip):');\n break;\n \n case 'new_term':\n lines.push(`[New Term Found]`);\n lines.push(`Context: ${request.context}`);\n lines.push(`Term: \"${request.term}\"`);\n lines.push('');\n lines.push('What does this term mean? (brief description, or press Enter to skip):');\n break;\n \n case 'routing_decision':\n lines.push(`[Routing Decision Required]`);\n lines.push(`Context: ${request.context}`);\n if (request.options && request.options.length > 0) {\n lines.push('Available destinations:');\n request.options.forEach((opt, i) => {\n lines.push(` ${i + 1}. ${opt}`);\n });\n lines.push('');\n lines.push('Enter number or destination path:');\n } else {\n lines.push('');\n lines.push('Where should this note be filed?');\n }\n break;\n \n case 'low_confidence_routing':\n lines.push(`[Confirm Note Routing]`);\n lines.push(`Confidence: ${request.term}`);\n lines.push(`${request.context}`);\n lines.push('');\n lines.push('Is this correct? (Y/Enter to accept, or enter different path):');\n break;\n \n case 'first_run_onboarding':\n lines.push(`[First Run Setup]`);\n lines.push(`${request.context}`);\n lines.push('');\n if (request.options && request.options.length > 0) {\n request.options.forEach((opt, i) => {\n lines.push(` ${i + 1}. ${opt}`);\n });\n lines.push('');\n lines.push('Enter your choice:');\n } else {\n lines.push('Enter your response:');\n }\n break;\n \n case 'general':\n default:\n lines.push(`[Clarification Needed]`);\n lines.push(`${request.context}`);\n if (request.term) {\n lines.push(`Term: \"${request.term}\"`);\n }\n if (request.suggestion) {\n lines.push(`Suggested spelling: \"${request.suggestion}\"`);\n lines.push('');\n lines.push('Press Enter or Y to accept suggestion, or type alternative:');\n } else {\n lines.push('');\n lines.push('Your response:');\n }\n break;\n }\n \n lines.push('─'.repeat(60));\n \n return lines.join('\\n') + '\\n> ';\n};\n\nexport const create = (config: InteractiveConfig): HandlerInstance => {\n const logger = Logging.getLogger();\n const sound = Sound.create({ silent: config.silent ?? false });\n \n let session: InteractiveSession | null = null;\n let rl: readline.Interface | null = null;\n \n const startSession = () => {\n session = {\n requests: [],\n responses: [],\n startedAt: new Date(),\n };\n \n // Check if we can run interactively:\n // 1. Interactive mode must be enabled (not --batch)\n // 2. stdin must be a TTY (not piped/cron/etc)\n const isTTY = process.stdin.isTTY === true;\n \n if (config.enabled && isTTY) {\n // Only create readline interface if one doesn't already exist\n // This prevents duplicate input handlers when processing multiple files\n if (!rl) {\n rl = createReadlineInterface();\n logger.info('Interactive session started - will prompt for clarifications');\n } else {\n logger.debug('Interactive session continued (readline already active)');\n }\n } else if (config.enabled && !isTTY) {\n logger.info('Interactive mode enabled but stdin is not a TTY - running in auto-resolve mode');\n } else {\n logger.debug('Interactive session started (batch mode)');\n }\n };\n \n const endSession = (): InteractiveSession => {\n if (!session) {\n throw new Error('No active session');\n }\n \n if (rl) {\n // Remove all listeners before closing to prevent any lingering handlers\n // Check if method exists (may not in mocks)\n if (typeof rl.removeAllListeners === 'function') {\n rl.removeAllListeners();\n }\n rl.close();\n rl = null;\n \n // Resume stdin in case it was paused\n if (process.stdin.isPaused && process.stdin.isPaused()) {\n process.stdin.resume();\n }\n }\n \n session.completedAt = new Date();\n const completed = session;\n session = null;\n \n logger.info('Interactive session ended', { \n requests: completed.requests.length,\n responses: completed.responses.length,\n });\n \n return completed;\n };\n \n const handleClarification = async (\n request: ClarificationRequest\n ): Promise<ClarificationResponse> => {\n if (session) {\n session.requests.push(request);\n }\n \n // In non-interactive mode, return the suggestion or the original term\n if (!config.enabled || !rl) {\n const response: ClarificationResponse = {\n type: request.type,\n term: request.term,\n response: config.defaultToSuggestion && request.suggestion \n ? request.suggestion \n : request.term,\n shouldRemember: false,\n };\n \n if (session) {\n session.responses.push(response);\n }\n \n logger.debug('Clarification auto-resolved (non-interactive)', { \n type: request.type, \n term: request.term,\n response: response.response,\n });\n \n return response;\n }\n \n // Interactive mode - actually prompt the user\n // Play notification sound to get user's attention (like Cursor does)\n await sound.playNotification();\n \n // Special handling for new_project - use wizard\n if (request.type === 'new_project') {\n const wizardResult = await runNewProjectWizard(\n rl,\n request.term,\n request.context,\n request.options\n );\n \n const response: ClarificationResponse = {\n type: request.type,\n term: request.term,\n response: wizardResult.action,\n shouldRemember: wizardResult.action !== 'skip',\n additionalInfo: wizardResult as unknown as Record<string, unknown>,\n };\n \n if (session) {\n session.responses.push(response);\n }\n \n logger.debug('New project wizard completed', {\n term: request.term,\n action: wizardResult.action,\n additionalInfo: wizardResult,\n });\n \n return response;\n }\n \n // Special handling for new_person - use wizard\n if (request.type === 'new_person') {\n const wizardResult = await runNewPersonWizard(\n rl,\n request.term,\n request.context,\n request.options\n );\n \n const response: ClarificationResponse = {\n type: request.type,\n term: request.term,\n response: wizardResult.action,\n shouldRemember: wizardResult.action !== 'skip',\n additionalInfo: wizardResult as unknown as Record<string, unknown>,\n };\n \n if (session) {\n session.responses.push(response);\n }\n \n logger.debug('New person wizard completed', {\n term: request.term,\n action: wizardResult.action,\n additionalInfo: wizardResult,\n });\n \n return response;\n }\n \n // Standard single-prompt flow for other types\n const prompt = formatClarificationPrompt(request);\n const userInput = await askQuestion(rl, prompt);\n \n // Process the user's response\n let finalResponse: string;\n let shouldRemember = false;\n \n if (userInput === '' || userInput.toLowerCase() === 'y') {\n // User pressed Enter or typed Y - use suggestion or original\n finalResponse = request.suggestion || request.term;\n } else if (request.options && /^\\d+$/.test(userInput)) {\n // User entered a number - select from options\n const index = parseInt(userInput, 10) - 1;\n if (index >= 0 && index < request.options.length) {\n finalResponse = request.options[index];\n } else {\n finalResponse = userInput;\n }\n } else {\n finalResponse = userInput;\n // If user provided a custom answer, they might want to remember it\n shouldRemember = true;\n }\n \n const response: ClarificationResponse = {\n type: request.type,\n term: request.term,\n response: finalResponse,\n shouldRemember,\n };\n \n if (session) {\n session.responses.push(response);\n }\n \n logger.debug('Clarification resolved via user input', { \n type: request.type, \n term: request.term,\n response: response.response,\n shouldRemember,\n });\n \n return response;\n };\n \n const isEnabled = () => config.enabled;\n \n const getSession = () => session;\n \n return {\n startSession,\n endSession,\n handleClarification,\n isEnabled,\n getSession,\n };\n};\n"],"names":["createReadlineInterface","process","stdin","setRawMode","readline","createInterface","input","output","stdout","terminal","askQuestion","rl","question","Promise","resolve","answer","trim","write","text","runCreateProjectFlow","contextMessage","projectName","action","destination","description","undefined","runNewProjectWizard","term","context","projectOptions","repeat","entityType","toLowerCase","ignoredTerm","finalName","termCorrection","finalTermName","expansion","termProjects","createdProject","length","forEach","opt","i","projectSelection","includes","indices","split","map","s","parseInt","idx","isNaN","push","join","createNew","termDesc","termName","termExpansion","termDescription","runNewPersonWizard","name","nameCorrection","organization","linkedProjectIndex","contextMsg","test","notes","hasInfo","confirm","personName","formatClarificationPrompt","request","lines","type","suggestion","options","create","config","logger","Logging","sound","Sound","silent","session","startSession","requests","responses","startedAt","Date","isTTY","enabled","info","debug","endSession","Error","removeAllListeners","close","isPaused","resume","completedAt","completed","handleClarification","response","shouldRemember","playNotification","wizardResult","additionalInfo","prompt","userInput","finalResponse","index","isEnabled","getSession"],"mappings":";;;;AA4BA,MAAMA,uBAAAA,GAA0B,IAAA;;;AAG5B,IAAA,IAAIC,OAAAA,CAAQC,KAAK,CAACC,UAAU,EAAE;QAC1B,IAAI;;YAEAF,OAAAA,CAAQC,KAAK,CAACC,UAAU,CAAC,KAAA,CAAA;AAC7B,QAAA,CAAA,CAAE,OAAM;;AAER,QAAA;AACJ,IAAA;IAEA,OAAOC,QAAAA,CAASC,eAAe,CAAC;AAC5BC,QAAAA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;AACJ,KAAA;AACJ;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { create as create$2 } from './handler.js';
|
|
2
|
-
import { create as create$1 } from './onboarding.js';
|
|
3
|
-
|
|
4
|
-
const create = (config, context)=>{
|
|
5
|
-
const handler = create$2(config);
|
|
6
|
-
const onboarding = create$1(context);
|
|
7
|
-
return {
|
|
8
|
-
startSession: handler.startSession,
|
|
9
|
-
endSession: handler.endSession,
|
|
10
|
-
getSession: handler.getSession,
|
|
11
|
-
handleClarification: handler.handleClarification,
|
|
12
|
-
isEnabled: handler.isEnabled,
|
|
13
|
-
checkNeedsOnboarding: onboarding.checkNeedsOnboarding
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { create };
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/interactive/index.ts"],"sourcesContent":["/**\n * Interactive Mode System\n * \n * Main entry point for the interactive mode system. Provides session management,\n * clarification handling, and onboarding detection.\n */\n\nimport { \n InteractiveConfig, \n InteractiveSession, \n ClarificationRequest, \n ClarificationResponse,\n OnboardingState \n} from './types';\nimport * as Handler from './handler';\nimport * as Onboarding from './onboarding';\nimport * as Context from '../context';\n\nexport interface InteractiveInstance {\n // Session management\n startSession(): void;\n endSession(): InteractiveSession;\n getSession(): InteractiveSession | null;\n \n // Clarification handling\n handleClarification(request: ClarificationRequest): Promise<ClarificationResponse>;\n \n // State\n isEnabled(): boolean;\n \n // Onboarding\n checkNeedsOnboarding(): OnboardingState;\n}\n\nexport const create = (\n config: InteractiveConfig,\n context: Context.ContextInstance\n): InteractiveInstance => {\n const handler = Handler.create(config);\n const onboarding = Onboarding.create(context);\n \n return {\n startSession: handler.startSession,\n endSession: handler.endSession,\n getSession: handler.getSession,\n handleClarification: handler.handleClarification,\n isEnabled: handler.isEnabled,\n checkNeedsOnboarding: onboarding.checkNeedsOnboarding,\n };\n};\n\n// Re-export types\nexport * from './types';\n\n// Re-export utilities\nexport { createDefaultOnboardingResult } from './onboarding';\n\n"],"names":["create","config","context","handler","Handler","onboarding","Onboarding","startSession","endSession","getSession","handleClarification","isEnabled","checkNeedsOnboarding"],"mappings":";;;AAkCO,MAAMA,MAAAA,GAAS,CAClBC,MAAAA,EACAC,OAAAA,GAAAA;IAEA,MAAMC,OAAAA,GAAUC,QAAc,CAACH,MAAAA,CAAAA;IAC/B,MAAMI,UAAAA,GAAaC,QAAiB,CAACJ,OAAAA,CAAAA;IAErC,OAAO;AACHK,QAAAA,YAAAA,EAAcJ,QAAQI,YAAY;AAClCC,QAAAA,UAAAA,EAAYL,QAAQK,UAAU;AAC9BC,QAAAA,UAAAA,EAAYN,QAAQM,UAAU;AAC9BC,QAAAA,mBAAAA,EAAqBP,QAAQO,mBAAmB;AAChDC,QAAAA,SAAAA,EAAWR,QAAQQ,SAAS;AAC5BC,QAAAA,oBAAAA,EAAsBP,WAAWO;AACrC,KAAA;AACJ;;;;"}
|