prompt-language-shell 0.2.4 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/EXECUTE.md +700 -0
- package/dist/config/PLAN.md +155 -27
- package/dist/index.js +18 -22
- package/dist/services/anthropic.js +5 -1
- package/dist/services/config.js +23 -23
- package/dist/tools/plan.tool.js +5 -1
- package/dist/types/components.js +6 -0
- package/dist/ui/Column.js +1 -1
- package/dist/ui/Command.js +13 -3
- package/dist/ui/Component.js +3 -0
- package/dist/ui/Config.js +30 -12
- package/dist/ui/Feedback.js +22 -0
- package/dist/ui/Main.js +144 -53
- package/dist/ui/Welcome.js +1 -1
- package/package.json +1 -1
package/dist/ui/Main.js
CHANGED
|
@@ -1,66 +1,157 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { FeedbackType } from '../types/components.js';
|
|
3
4
|
import { Column } from './Column.js';
|
|
4
|
-
|
|
5
|
+
function exit(code) {
|
|
6
|
+
setTimeout(() => globalThis.process.exit(code), 100);
|
|
7
|
+
}
|
|
8
|
+
function markAsDone(component) {
|
|
9
|
+
return { ...component, state: { ...component.state, done: true } };
|
|
10
|
+
}
|
|
11
|
+
function createWelcomeDefinition(app) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'welcome',
|
|
14
|
+
props: { app },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createConfigSteps() {
|
|
18
|
+
return [
|
|
19
|
+
{ description: 'Anthropic API key', key: 'key', value: null },
|
|
20
|
+
{
|
|
21
|
+
description: 'Model',
|
|
22
|
+
key: 'model',
|
|
23
|
+
value: 'claude-haiku-4-5-20251001',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function createConfigDefinition(onFinished, onAborted) {
|
|
28
|
+
return {
|
|
29
|
+
name: 'config',
|
|
30
|
+
state: { done: false },
|
|
31
|
+
props: {
|
|
32
|
+
steps: createConfigSteps(),
|
|
33
|
+
onFinished,
|
|
34
|
+
onAborted,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function createCommandDefinition(command, service, onError, onComplete) {
|
|
39
|
+
return {
|
|
40
|
+
name: 'command',
|
|
41
|
+
state: {
|
|
42
|
+
done: false,
|
|
43
|
+
isLoading: true,
|
|
44
|
+
},
|
|
45
|
+
props: {
|
|
46
|
+
command,
|
|
47
|
+
service,
|
|
48
|
+
onError,
|
|
49
|
+
onComplete,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export const Main = ({ app, command, service: initialService, isReady, onConfigured, }) => {
|
|
5
54
|
const [history, setHistory] = React.useState([]);
|
|
6
55
|
const [current, setCurrent] = React.useState(null);
|
|
7
|
-
React.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
56
|
+
const [service, setService] = React.useState(initialService);
|
|
57
|
+
const handleConfigFinished = React.useCallback((config) => {
|
|
58
|
+
const service = onConfigured?.(config);
|
|
59
|
+
if (service) {
|
|
60
|
+
setService(service);
|
|
61
|
+
}
|
|
62
|
+
// Move config to history with done state and add success feedback
|
|
63
|
+
setCurrent((previous) => {
|
|
64
|
+
if (previous && previous.name === 'config') {
|
|
65
|
+
setHistory((history) => [
|
|
66
|
+
...history,
|
|
67
|
+
markAsDone(previous),
|
|
68
|
+
{
|
|
69
|
+
name: 'feedback',
|
|
70
|
+
props: {
|
|
71
|
+
type: FeedbackType.Succeeded,
|
|
72
|
+
message: 'Configuration complete',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
});
|
|
79
|
+
}, [onConfigured]);
|
|
80
|
+
const handleConfigAborted = React.useCallback(() => {
|
|
81
|
+
// Move config to history with done state and add aborted feedback
|
|
82
|
+
setCurrent((previous) => {
|
|
83
|
+
if (previous && previous.name === 'config') {
|
|
84
|
+
setHistory((history) => [
|
|
85
|
+
...history,
|
|
86
|
+
markAsDone(previous),
|
|
87
|
+
{
|
|
88
|
+
name: 'feedback',
|
|
89
|
+
props: {
|
|
90
|
+
type: FeedbackType.Aborted,
|
|
91
|
+
message: 'Configuration aborted by user',
|
|
92
|
+
},
|
|
16
93
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
94
|
+
]);
|
|
95
|
+
// Exit after showing abort message
|
|
96
|
+
exit(0);
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
});
|
|
100
|
+
}, []);
|
|
101
|
+
const handleCommandError = React.useCallback((error) => {
|
|
102
|
+
// Move command to history with done state and add error feedback
|
|
103
|
+
setCurrent((previous) => {
|
|
104
|
+
if (previous && previous.name === 'command') {
|
|
105
|
+
setHistory((history) => [
|
|
106
|
+
...history,
|
|
107
|
+
markAsDone(previous),
|
|
108
|
+
{
|
|
109
|
+
name: 'feedback',
|
|
110
|
+
props: {
|
|
111
|
+
type: FeedbackType.Failed,
|
|
112
|
+
message: `Unexpected error occurred:\n\n ${error}`,
|
|
113
|
+
},
|
|
38
114
|
},
|
|
39
|
-
|
|
40
|
-
|
|
115
|
+
]);
|
|
116
|
+
// Exit after showing error
|
|
117
|
+
exit(1);
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
});
|
|
121
|
+
}, []);
|
|
122
|
+
const addToHistory = React.useCallback((...items) => {
|
|
123
|
+
setHistory((history) => [...history, ...items]);
|
|
124
|
+
}, []);
|
|
125
|
+
const handleCommandComplete = React.useCallback(() => {
|
|
126
|
+
// Move command to history with done state
|
|
127
|
+
setCurrent((previous) => {
|
|
128
|
+
if (previous && previous.name === 'command') {
|
|
129
|
+
addToHistory(markAsDone(previous));
|
|
130
|
+
// Exit after showing plan
|
|
131
|
+
exit(0);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
});
|
|
135
|
+
}, [addToHistory]);
|
|
136
|
+
// Initialize configuration flow when not ready
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
if (!isReady) {
|
|
139
|
+
setHistory(command ? [] : [createWelcomeDefinition(app)]);
|
|
140
|
+
setCurrent(createConfigDefinition(handleConfigFinished, handleConfigAborted));
|
|
41
141
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isLoading: true,
|
|
48
|
-
},
|
|
49
|
-
props: {
|
|
50
|
-
command,
|
|
51
|
-
service,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
142
|
+
}, [isReady, app, command, handleConfigFinished, handleConfigAborted]);
|
|
143
|
+
// Execute command when service and command are available
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
if (command && service) {
|
|
146
|
+
setCurrent(createCommandDefinition(command, service, handleCommandError, handleCommandComplete));
|
|
54
147
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
});
|
|
148
|
+
}, [command, service, handleCommandError, handleCommandComplete]);
|
|
149
|
+
// Show welcome screen when ready but no command
|
|
150
|
+
React.useEffect(() => {
|
|
151
|
+
if (isReady && !command) {
|
|
152
|
+
setCurrent(createWelcomeDefinition(app));
|
|
62
153
|
}
|
|
63
|
-
}, [isReady, command,
|
|
154
|
+
}, [isReady, command, app]);
|
|
64
155
|
const items = [...history, ...(current ? [current] : [])];
|
|
65
156
|
return _jsx(Column, { items: items });
|
|
66
157
|
};
|
package/dist/ui/Welcome.js
CHANGED
|
@@ -18,5 +18,5 @@ function Usage() {
|
|
|
18
18
|
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color: "brightWhite", bold: true, children: "Usage:" }), _jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "whiteBright", dimColor: true, children: ">" }), _jsxs(Box, { gap: 1, children: [_jsx(Text, { color: "greenBright", bold: true, children: "pls" }), _jsx(Text, { color: "yellow", bold: true, children: "[describe your request]" })] })] })] }));
|
|
19
19
|
}
|
|
20
20
|
export function Welcome({ app }) {
|
|
21
|
-
return (_jsx(Box, { alignSelf: "flex-start",
|
|
21
|
+
return (_jsx(Box, { alignSelf: "flex-start", children: _jsxs(Panel, { children: [_jsx(Header, { app: app }), _jsx(Description, { description: app.description }), _jsx(Usage, {})] }) }));
|
|
22
22
|
}
|