prompt-language-shell 0.6.0 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prompt-language-shell",
3
- "version": "0.6.0",
3
+ "version": "0.6.4",
4
4
  "description": "Your personal command-line concierge. Ask politely, and it gets things done.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,52 +0,0 @@
1
- import { FeedbackType } from '../types/types.js';
2
- import { createFeedback } from './components.js';
3
- import { FeedbackMessages } from './messages.js';
4
- import { exitApp } from './process.js';
5
- /**
6
- * Higher-order function that wraps queue handler logic with common patterns:
7
- * - Check if queue is empty
8
- * - Extract first element
9
- * - Optionally check component name
10
- * - Execute callback with first element
11
- * - Return new queue state
12
- */
13
- export function withQueueHandler(componentName, callback, shouldExit = false, exitCode = 0) {
14
- return (currentQueue) => {
15
- if (currentQueue.length === 0)
16
- return currentQueue;
17
- const [first, ...rest] = currentQueue;
18
- // If componentName is specified, check if it matches
19
- if (componentName && first.name !== componentName) {
20
- if (shouldExit) {
21
- exitApp(exitCode);
22
- }
23
- return [];
24
- }
25
- // Execute callback with first and rest
26
- const result = callback(first, rest);
27
- // Exit if specified
28
- if (shouldExit) {
29
- exitApp(exitCode);
30
- }
31
- // Return result or empty queue
32
- return result || [];
33
- };
34
- }
35
- /**
36
- * Creates a generic error handler for a component
37
- */
38
- export function createErrorHandler(componentName, addToTimeline) {
39
- return (error) => withQueueHandler(componentName, (first) => {
40
- addToTimeline(first, createFeedback(FeedbackType.Failed, FeedbackMessages.UnexpectedError, error));
41
- return undefined;
42
- }, true, 1);
43
- }
44
- /**
45
- * Creates a generic completion handler for a component
46
- */
47
- export function createCompletionHandler(componentName, addToTimeline, onComplete) {
48
- return withQueueHandler(componentName, (first) => {
49
- onComplete(first);
50
- return undefined;
51
- }, true, 0);
52
- }