FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/commands/insert_queue.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
11
(11)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
commands
/
insert_queue.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
100 lines (85 loc) · 3.8 KB
Breadcrumbs
cecli
/
cecli
/
commands
/
insert_queue.py
Copy path
File metadata and controls
100 lines (85 loc) · 3.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""Insert-queue command for CLI-33: inserts a prompt at a specific queue position."""
from
typing
import
List
from
cecli
.
commands
.
utils
.
base_command
import
BaseCommand
from
cecli
.
commands
.
utils
.
helpers
import
format_command_result
from
cecli
.
helpers
import
command_queue
class
InsertQueueCommand
(
BaseCommand
):
NORM_NAME
=
"insert-queue"
DESCRIPTION
=
"Insert a prompt into the queue at a specific position"
@
classmethod
async
def
execute
(
cls
,
io
,
coder
,
args
,
**
kwargs
):
"""Execute the insert-queue command with given parameters.
Args:
io: InputOutput instance
coder: Coder instance (may be None for some commands)
args: Command arguments as string ("<index> <prompt text>")
**kwargs: Additional context
Returns:
Formatted result string
"""
# Sad path: coder.commands is None
if
not
coder
.
commands
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
"Command system not available. Cannot insert into queue."
,
)
# Sad path: missing index or prompt text
parts
=
(
args
or
""
).
strip
().
split
(
maxsplit
=
1
)
if
len
(
parts
)
!=
2
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
"Usage: /insert-queue <index> <prompt text>"
,
)
# Sad path: non-integer index
try
:
index
=
int
(
parts
[
0
])
except
ValueError
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
f"Invalid index: '
{
parts
[
0
]
}
'. Please provide a number."
,
)
prompt_text
=
parts
[
1
].
strip
()
# Happy path: insert the prompt
try
:
item
=
command_queue
.
insert_prompt
(
coder
,
prompt_text
,
index
)
io
.
tool_output
(
f"Prompt inserted at position
{
index
+
1
}
(id:
{
item
[
'id'
]
}
)"
)
return
f"Successfully executed
{
cls
.
NORM_NAME
}
."
except
ValueError
as
e
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
str
(
e
))
except
RuntimeError
as
e
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
str
(
e
))
@
classmethod
def
get_completions
(
cls
,
io
,
coder
,
args
)
->
List
[
str
]:
"""Get completion options for insert-queue command.
Args are "<index> <prompt text>"; once the index token and a space
are present, mirror the nested prompt's completions (e.g. a nested
slash command delegates to the original command's completions).
"""
text
=
args
or
""
first_space
=
text
.
find
(
" "
)
if
first_space
==
-
1
:
# Still typing the index; suggest valid positions.
if
not
coder
.
commands
:
return
[]
return
[
str
(
i
)
for
i
in
range
(
1
,
command_queue
.
get_queue_length
(
coder
)
+
2
)]
return
command_queue
.
nested_command_completions
(
coder
,
text
[
first_space
+
1
:])
@
classmethod
def
get_help
(
cls
)
->
str
:
"""Get help text for the insert-queue command."""
help_text
=
super
().
get_help
()
help_text
+=
"
\n
Usage:
\n
"
help_text
+=
" /insert-queue <index> <prompt text> # Insert at a specific position
\n
"
help_text
+=
"
\n
Description:
\n
"
help_text
+=
" Inserts a prompt into the queue at the given 1-based position.
\n
"
help_text
+=
" Existing items shift down. Index is clamped to the queue bounds.
\n
"
help_text
+=
"
\n
Examples:
\n
"
help_text
+=
" /insert-queue 1 Review the changes in src/main.py
\n
"
help_text
+=
" /insert-queue 3 Write unit tests for the new feature
\n
"
help_text
+=
"
\n
See also: /queue, /list-queue, /remove-queue, /run-queue
\n
"
return
help_text
Back
|
FazBrowse Home
|
New Git URL