prompt-language-shell 0.4.4 → 0.4.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/CONFIG.md +66 -0
- package/dist/config/INTROSPECT.md +29 -14
- package/dist/config/PLAN.md +21 -0
- package/dist/handlers/config.js +42 -1
- package/dist/handlers/execution.js +22 -2
- package/dist/handlers/plan.js +2 -2
- package/dist/services/anthropic.js +41 -12
- package/dist/services/colors.js +62 -28
- package/dist/services/components.js +142 -22
- package/dist/services/configuration.js +80 -0
- package/dist/services/keyboard.js +86 -0
- package/dist/services/messages.js +30 -0
- package/dist/services/tool-registry.js +5 -0
- package/dist/tools/config.tool.js +43 -0
- package/dist/ui/Answer.js +9 -7
- package/dist/ui/Command.js +17 -5
- package/dist/ui/Component.js +1 -1
- package/dist/ui/Config.js +6 -3
- package/dist/ui/Confirm.js +6 -5
- package/dist/ui/Introspect.js +22 -9
- package/dist/ui/Main.js +8 -8
- package/dist/ui/Plan.js +2 -1
- package/dist/ui/Refinement.js +2 -1
- package/dist/ui/Report.js +8 -7
- package/package.json +1 -1
package/dist/ui/Introspect.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import { Box, Text
|
|
4
|
-
import { getTextColor } from '../services/colors.js';
|
|
3
|
+
import { Box, Text } from 'ink';
|
|
4
|
+
import { Colors, getTextColor } from '../services/colors.js';
|
|
5
|
+
import { useInput } from '../services/keyboard.js';
|
|
6
|
+
import { formatErrorMessage } from '../services/messages.js';
|
|
5
7
|
import { Spinner } from './Spinner.js';
|
|
6
8
|
const MIN_PROCESSING_TIME = 1000;
|
|
7
9
|
const BUILT_IN_CAPABILITIES = new Set([
|
|
@@ -12,26 +14,32 @@ const BUILT_IN_CAPABILITIES = new Set([
|
|
|
12
14
|
'EXECUTE',
|
|
13
15
|
'REPORT',
|
|
14
16
|
]);
|
|
17
|
+
const INDIRECT_CAPABILITIES = new Set(['PLAN', 'REPORT']);
|
|
15
18
|
function parseCapabilityFromTask(task) {
|
|
16
19
|
// Parse "NAME: Description" format from task.action
|
|
17
20
|
const colonIndex = task.action.indexOf(':');
|
|
18
21
|
if (colonIndex === -1) {
|
|
22
|
+
const upperName = task.action.toUpperCase();
|
|
19
23
|
return {
|
|
20
24
|
name: task.action,
|
|
21
25
|
description: '',
|
|
22
|
-
isBuiltIn: BUILT_IN_CAPABILITIES.has(
|
|
26
|
+
isBuiltIn: BUILT_IN_CAPABILITIES.has(upperName),
|
|
27
|
+
isIndirect: INDIRECT_CAPABILITIES.has(upperName),
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
const name = task.action.substring(0, colonIndex).trim();
|
|
26
31
|
const description = task.action.substring(colonIndex + 1).trim();
|
|
27
|
-
const
|
|
32
|
+
const upperName = name.toUpperCase();
|
|
33
|
+
const isBuiltIn = BUILT_IN_CAPABILITIES.has(upperName);
|
|
34
|
+
const isIndirect = INDIRECT_CAPABILITIES.has(upperName);
|
|
28
35
|
return {
|
|
29
36
|
name,
|
|
30
37
|
description,
|
|
31
38
|
isBuiltIn,
|
|
39
|
+
isIndirect,
|
|
32
40
|
};
|
|
33
41
|
}
|
|
34
|
-
export function Introspect({ tasks, state, service, children, onError, onComplete, onAborted, }) {
|
|
42
|
+
export function Introspect({ tasks, state, service, children, debug = false, onError, onComplete, onAborted, }) {
|
|
35
43
|
const done = state?.done ?? false;
|
|
36
44
|
const isCurrent = done === false;
|
|
37
45
|
const [error, setError] = useState(null);
|
|
@@ -66,7 +74,12 @@ export function Introspect({ tasks, state, service, children, onError, onComplet
|
|
|
66
74
|
await new Promise((resolve) => setTimeout(resolve, remainingTime));
|
|
67
75
|
if (mounted) {
|
|
68
76
|
// Parse capabilities from returned tasks
|
|
69
|
-
|
|
77
|
+
let capabilities = result.tasks.map(parseCapabilityFromTask);
|
|
78
|
+
// Filter out internal capabilities when not in debug mode
|
|
79
|
+
if (!debug) {
|
|
80
|
+
capabilities = capabilities.filter((cap) => cap.name.toUpperCase() !== 'PLAN' &&
|
|
81
|
+
cap.name.toUpperCase() !== 'REPORT');
|
|
82
|
+
}
|
|
70
83
|
setIsLoading(false);
|
|
71
84
|
onComplete?.(result.message, capabilities);
|
|
72
85
|
}
|
|
@@ -76,7 +89,7 @@ export function Introspect({ tasks, state, service, children, onError, onComplet
|
|
|
76
89
|
const remainingTime = Math.max(0, MIN_PROCESSING_TIME - elapsed);
|
|
77
90
|
await new Promise((resolve) => setTimeout(resolve, remainingTime));
|
|
78
91
|
if (mounted) {
|
|
79
|
-
const errorMessage = err
|
|
92
|
+
const errorMessage = formatErrorMessage(err);
|
|
80
93
|
setIsLoading(false);
|
|
81
94
|
if (onError) {
|
|
82
95
|
onError(errorMessage);
|
|
@@ -91,10 +104,10 @@ export function Introspect({ tasks, state, service, children, onError, onComplet
|
|
|
91
104
|
return () => {
|
|
92
105
|
mounted = false;
|
|
93
106
|
};
|
|
94
|
-
}, [tasks, done, service]);
|
|
107
|
+
}, [tasks, done, service, debug, onComplete, onError]);
|
|
95
108
|
// Don't render wrapper when done and nothing to show
|
|
96
109
|
if (!isLoading && !error && !children) {
|
|
97
110
|
return null;
|
|
98
111
|
}
|
|
99
|
-
return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [isLoading && (_jsxs(Box, { children: [_jsx(Text, { color: getTextColor(isCurrent), children: "Listing capabilities. " }), _jsx(Spinner, {})] })), error && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color:
|
|
112
|
+
return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [isLoading && (_jsxs(Box, { children: [_jsx(Text, { color: getTextColor(isCurrent), children: "Listing capabilities. " }), _jsx(Spinner, {})] })), error && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: Colors.Status.Error, children: ["Error: ", error] }) })), children] }));
|
|
100
113
|
}
|
package/dist/ui/Main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useInput } from 'ink';
|
|
4
3
|
import { FeedbackType } from '../types/types.js';
|
|
5
4
|
import { createAnthropicService, } from '../services/anthropic.js';
|
|
6
5
|
import { getConfigurationRequiredMessage, hasValidAnthropicKey, loadConfig, loadDebugSetting, saveDebugSetting, } from '../services/configuration.js';
|
|
6
|
+
import { registerGlobalShortcut } from '../services/keyboard.js';
|
|
7
7
|
import { getCancellationMessage } from '../services/messages.js';
|
|
8
8
|
import { createCommandDefinition, createConfigDefinition, createFeedback, createMessage, createWelcomeDefinition, isStateless, markAsDone, } from '../services/components.js';
|
|
9
9
|
import { exitApp } from '../services/process.js';
|
|
@@ -31,17 +31,17 @@ export const Main = ({ app, command }) => {
|
|
|
31
31
|
React.useEffect(() => {
|
|
32
32
|
timelineRef.current = timeline;
|
|
33
33
|
}, [timeline]);
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
// Register global keyboard shortcuts
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
// Shift+Tab: Toggle debug mode
|
|
37
|
+
registerGlobalShortcut('shift+tab', () => {
|
|
38
38
|
setIsDebug((prev) => {
|
|
39
39
|
const newValue = !prev;
|
|
40
40
|
saveDebugSetting(newValue);
|
|
41
41
|
return newValue;
|
|
42
42
|
});
|
|
43
|
-
}
|
|
44
|
-
},
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
45
|
const addToTimeline = React.useCallback((...items) => {
|
|
46
46
|
setTimeline((timeline) => [...timeline, ...items]);
|
|
47
47
|
}, []);
|
|
@@ -84,7 +84,7 @@ export const Main = ({ app, command }) => {
|
|
|
84
84
|
const handleAnswerAborted = React.useCallback(createAnswerAbortedHandler(handleAborted), [handleAborted]);
|
|
85
85
|
const handleAnswerError = React.useCallback((error) => setQueue(createAnswerErrorHandler(addToTimeline)(error)), [addToTimeline]);
|
|
86
86
|
const handleAnswerComplete = React.useCallback((answer) => setQueue(createAnswerCompleteHandler(addToTimeline)(answer)), [addToTimeline]);
|
|
87
|
-
const handleExecutionConfirmed = React.useCallback(() => setQueue(createExecutionConfirmedHandler(timelineRef, addToTimeline, service, handleIntrospectError, handleIntrospectComplete, handleIntrospectAborted, handleAnswerError, handleAnswerComplete, handleAnswerAborted)()), [
|
|
87
|
+
const handleExecutionConfirmed = React.useCallback(() => setQueue(createExecutionConfirmedHandler(timelineRef, addToTimeline, service, handleIntrospectError, handleIntrospectComplete, handleIntrospectAborted, handleAnswerError, handleAnswerComplete, handleAnswerAborted, setQueue)()), [
|
|
88
88
|
addToTimeline,
|
|
89
89
|
service,
|
|
90
90
|
handleIntrospectError,
|
package/dist/ui/Plan.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import { Box
|
|
3
|
+
import { Box } from 'ink';
|
|
4
4
|
import { TaskType } from '../types/types.js';
|
|
5
5
|
import { getTaskColors } from '../services/colors.js';
|
|
6
|
+
import { useInput } from '../services/keyboard.js';
|
|
6
7
|
import { Label } from './Label.js';
|
|
7
8
|
import { List } from './List.js';
|
|
8
9
|
function taskToListItem(task, highlightedChildIndex = null, isDefineTaskWithoutSelection = false, isCurrent = false) {
|
package/dist/ui/Refinement.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box
|
|
2
|
+
import { Box } from 'ink';
|
|
3
|
+
import { useInput } from '../services/keyboard.js';
|
|
3
4
|
import { Message } from './Message.js';
|
|
4
5
|
import { Spinner } from './Spinner.js';
|
|
5
6
|
export const Refinement = ({ text, state, onAborted }) => {
|
package/dist/ui/Report.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { Colors } from '../services/colors.js';
|
|
4
|
+
function CapabilityItem({ name, description, isBuiltIn, isIndirect, }) {
|
|
5
|
+
const color = isIndirect
|
|
6
|
+
? Colors.Origin.Indirect
|
|
7
|
+
: isBuiltIn
|
|
8
|
+
? Colors.Origin.BuiltIn
|
|
9
|
+
: Colors.Origin.UserProvided;
|
|
9
10
|
return (_jsxs(Box, { children: [_jsx(Text, { children: "- " }), _jsx(Text, { color: color, children: name }), _jsxs(Text, { children: [" - ", description] })] }));
|
|
10
11
|
}
|
|
11
12
|
export function Report({ message, capabilities }) {
|
|
12
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: message }), _jsx(Box, { flexDirection: "column", marginLeft: 2, marginTop: 1, children: capabilities.map((capability, index) => (_jsx(CapabilityItem, { name: capability.name, description: capability.description, isBuiltIn: capability.isBuiltIn }, index))) })] }));
|
|
13
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: message }), _jsx(Box, { flexDirection: "column", marginLeft: 2, marginTop: 1, children: capabilities.map((capability, index) => (_jsx(CapabilityItem, { name: capability.name, description: capability.description, isBuiltIn: capability.isBuiltIn, isIndirect: capability.isIndirect }, index))) })] }));
|
|
13
14
|
}
|