prompt-language-shell 0.2.9 → 0.3.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.
@@ -2,8 +2,8 @@ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Box, Text } from 'ink';
4
4
  import { TaskType } from '../types/components.js';
5
+ import { Label } from './Label.js';
5
6
  import { List } from './List.js';
6
- import { Separator } from './Separator.js';
7
7
  import { Spinner } from './Spinner.js';
8
8
  const MIN_PROCESSING_TIME = 1000; // purely for visual effect
9
9
  // Color palette
@@ -14,7 +14,7 @@ const ColorPalette = {
14
14
  },
15
15
  [TaskType.Plan]: {
16
16
  description: '#ffffff', // white
17
- type: '#cc5c9c', // magenta
17
+ type: '#5ccccc', // magenta
18
18
  },
19
19
  [TaskType.Execute]: {
20
20
  description: '#ffffff', // white
@@ -69,9 +69,9 @@ function taskToListItem(task) {
69
69
  }
70
70
  return item;
71
71
  }
72
- export function Command({ command, state, service, error: errorProp, children, onError, onComplete, }) {
72
+ export function Command({ command, state, service, children, onError, onComplete, }) {
73
73
  const done = state?.done ?? false;
74
- const [error, setError] = useState(state?.error || errorProp || null);
74
+ const [error, setError] = useState(null);
75
75
  const [isLoading, setIsLoading] = useState(state?.isLoading ?? !done);
76
76
  const [message, setMessage] = useState('');
77
77
  const [tasks, setTasks] = useState([]);
@@ -122,5 +122,5 @@ export function Command({ command, state, service, error: errorProp, children, o
122
122
  mounted = false;
123
123
  };
124
124
  }, [command, done, service]);
125
- return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", marginLeft: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { color: "gray", children: ["> pls ", command] }), isLoading && (_jsxs(_Fragment, { children: [_jsx(Text, { children: " " }), _jsx(Spinner, {})] }))] }), error && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) })), !isLoading && tasks.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [message && (_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { children: [" ", message] }), _jsx(Separator, { color: "#9c5ccc" }), _jsx(Text, { color: "#9c5ccc", children: "plan" })] })), _jsx(List, { items: tasks.map(taskToListItem) })] })), children] }));
125
+ return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", marginLeft: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { color: "gray", children: ["> pls ", command] }), isLoading && (_jsxs(_Fragment, { children: [_jsx(Text, { children: " " }), _jsx(Spinner, {})] }))] }), error && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) })), !isLoading && tasks.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [message && (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { children: " " }), _jsx(Label, { description: message, descriptionColor: ColorPalette[TaskType.Plan].description, type: TaskType.Plan, typeColor: ColorPalette[TaskType.Plan].type })] })), _jsx(List, { items: tasks.map(taskToListItem) })] })), children] }));
126
126
  }
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { Separator } from './Separator.js';
4
+ export function Label({ description, descriptionColor, type, typeColor, }) {
5
+ return (_jsxs(Box, { children: [_jsx(Text, { color: descriptionColor, children: description }), _jsx(Separator, {}), _jsx(Text, { color: typeColor, children: type })] }));
6
+ }
package/dist/ui/List.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from 'ink';
3
- import { Separator } from './Separator.js';
3
+ import { Label } from './Label.js';
4
4
  export const List = ({ items, level = 0 }) => {
5
5
  const marginLeft = level > 0 ? 4 : 0;
6
- return (_jsx(Box, { flexDirection: "column", marginLeft: marginLeft, children: items.map((item, index) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "whiteBright", children: ' - ' }), _jsx(Text, { color: item.description.color, children: item.description.text }), _jsx(Separator, {}), _jsx(Text, { color: item.type.color, children: item.type.text })] }), item.children && item.children.length > 0 && (_jsx(List, { items: item.children, level: level + 1 }))] }, index))) }));
6
+ return (_jsx(Box, { flexDirection: "column", marginLeft: marginLeft, children: items.map((item, index) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "whiteBright", children: ' - ' }), _jsx(Label, { description: item.description.text, descriptionColor: item.description.color, type: item.type.text, typeColor: item.type.color })] }), item.children && item.children.length > 0 && (_jsx(List, { items: item.children, level: level + 1 }))] }, index))) }));
7
7
  };
package/dist/ui/Main.js CHANGED
@@ -72,52 +72,49 @@ export const Main = ({ app, command, service: initialService, isReady, onConfigu
72
72
  setService(service);
73
73
  }
74
74
  // Move config to history with done state and add success feedback
75
- setCurrent((previous) => {
76
- if (previous && previous.name === 'config') {
77
- addToHistory(markAsDone(previous), createFeedback(FeedbackType.Succeeded, 'Configuration complete'));
78
- }
75
+ setCurrent((current) => {
76
+ if (!current)
77
+ return null;
78
+ addToHistory(markAsDone(current), createFeedback(FeedbackType.Succeeded, 'Configuration complete'));
79
79
  return null;
80
80
  });
81
81
  }, [onConfigured, addToHistory]);
82
82
  const handleConfigAborted = React.useCallback(() => {
83
83
  // Move config to history with done state and add aborted feedback
84
- setCurrent((previous) => {
85
- if (previous && previous.name === 'config') {
86
- addToHistory(markAsDone(previous), createFeedback(FeedbackType.Aborted, 'Configuration aborted by user'));
87
- // Exit after showing abort message
88
- exit(0);
89
- }
84
+ setCurrent((current) => {
85
+ addToHistory(markAsDone(current), createFeedback(FeedbackType.Aborted, 'Configuration aborted by user'));
86
+ // Exit after showing abort message
87
+ exit(0);
90
88
  return null;
91
89
  });
92
90
  }, [addToHistory]);
93
91
  const handleCommandError = React.useCallback((error) => {
94
92
  // Move command to history with done state and add error feedback
95
- setCurrent((previous) => {
96
- if (previous && previous.name === 'command') {
97
- addToHistory(markAsDone(previous), createFeedback(FeedbackType.Failed, 'Unexpected error occurred:', error));
98
- // Exit after showing error
99
- exit(1);
100
- }
93
+ setCurrent((current) => {
94
+ addToHistory(markAsDone(current), createFeedback(FeedbackType.Failed, 'Unexpected error occurred:', error));
95
+ // Exit after showing error
96
+ exit(1);
101
97
  return null;
102
98
  });
103
99
  }, [addToHistory]);
104
100
  const handleCommandComplete = React.useCallback(() => {
105
101
  // Move command to history with done state
106
- setCurrent((previous) => {
107
- if (previous && previous.name === 'command') {
108
- addToHistory(markAsDone(previous));
109
- // Exit after showing plan
110
- exit(0);
111
- }
102
+ setCurrent((current) => {
103
+ addToHistory(markAsDone(current));
104
+ // Exit after showing plan
105
+ exit(0);
112
106
  return null;
113
107
  });
114
108
  }, [addToHistory]);
115
109
  // Initialize configuration flow when not ready
116
110
  React.useEffect(() => {
117
- if (!isReady) {
118
- setHistory(command ? [] : [createWelcomeDefinition(app)]);
119
- setCurrent(createConfigDefinition(handleConfigFinished, handleConfigAborted));
111
+ if (isReady) {
112
+ return;
120
113
  }
114
+ if (!command) {
115
+ setHistory([createWelcomeDefinition(app)]);
116
+ }
117
+ setCurrent(createConfigDefinition(handleConfigFinished, handleConfigAborted));
121
118
  }, [isReady, app, command, handleConfigFinished, handleConfigAborted]);
122
119
  // Execute command when service and command are available
123
120
  React.useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prompt-language-shell",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
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",
@@ -54,6 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.10.6",
56
56
  "@types/react": "^19.2.2",
57
+ "@vitest/coverage-v8": "^4.0.8",
57
58
  "eslint": "^9.17.0",
58
59
  "husky": "^9.1.7",
59
60
  "prettier": "^3.6.2",