agentforge-multi 0.1.9 → 0.1.10
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/agentforge +51 -13
- package/package.json +1 -1
package/agentforge
CHANGED
|
@@ -339,20 +339,58 @@ SLASH_COMMANDS = [
|
|
|
339
339
|
|
|
340
340
|
class SlashCompleter(Completer):
|
|
341
341
|
def get_completions(self, document, complete_event):
|
|
342
|
+
import html as _html
|
|
342
343
|
text = document.text_before_cursor
|
|
343
|
-
if text.startswith('/'):
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
344
|
+
if not text.startswith('/'):
|
|
345
|
+
return
|
|
346
|
+
|
|
347
|
+
# ── /dir 경로 자동완성 ────────────────────────────────────────────
|
|
348
|
+
if re.match(r'^/dir\s', text):
|
|
349
|
+
partial = text[5:] # "/dir " 이후 부분
|
|
350
|
+
partial_expanded = os.path.expanduser(partial)
|
|
351
|
+
|
|
352
|
+
# 상위 디렉토리와 입력 중인 파일명 분리
|
|
353
|
+
if partial_expanded.endswith(os.sep) or not partial_expanded:
|
|
354
|
+
base_dir = partial_expanded or '.'
|
|
355
|
+
prefix = ''
|
|
356
|
+
else:
|
|
357
|
+
base_dir = os.path.dirname(partial_expanded) or '.'
|
|
358
|
+
prefix = os.path.basename(partial_expanded)
|
|
359
|
+
|
|
360
|
+
try:
|
|
361
|
+
entries = sorted(Path(base_dir).iterdir())
|
|
362
|
+
except (PermissionError, FileNotFoundError):
|
|
363
|
+
return
|
|
364
|
+
|
|
365
|
+
for entry in entries:
|
|
366
|
+
if not entry.is_dir():
|
|
367
|
+
continue
|
|
368
|
+
name = entry.name
|
|
369
|
+
if not name.startswith(prefix):
|
|
370
|
+
continue
|
|
371
|
+
# 완성 후 문자열: 원래 partial의 디렉토리 부분 + 이 항목 + /
|
|
372
|
+
orig_dir = partial[: len(partial) - len(prefix)]
|
|
373
|
+
completion_text = '/dir ' + orig_dir + name + '/'
|
|
374
|
+
yield Completion(
|
|
375
|
+
completion_text,
|
|
376
|
+
start_position=-len(text),
|
|
377
|
+
display=HTML(f'<ansicyan>{_html.escape(name)}/</ansicyan>'),
|
|
378
|
+
display_meta=HTML('<ansiwhite>디렉토리</ansiwhite>'),
|
|
379
|
+
)
|
|
380
|
+
return
|
|
381
|
+
|
|
382
|
+
# ── 일반 슬래시 커맨드 자동완성 ──────────────────────────────────
|
|
383
|
+
typed = text[1:]
|
|
384
|
+
for cmd, desc in SLASH_COMMANDS:
|
|
385
|
+
name = cmd[1:].split()[0]
|
|
386
|
+
full = cmd[1:]
|
|
387
|
+
if full.startswith(typed) or name.startswith(typed.split()[0] if typed else ''):
|
|
388
|
+
yield Completion(
|
|
389
|
+
cmd,
|
|
390
|
+
start_position=-len(text),
|
|
391
|
+
display=HTML(f'<ansicyan>{_html.escape(cmd)}</ansicyan>'),
|
|
392
|
+
display_meta=HTML(f'<ansiwhite>{_html.escape(desc)}</ansiwhite>'),
|
|
393
|
+
)
|
|
356
394
|
|
|
357
395
|
PROMPT_STYLE = PtStyle.from_dict({
|
|
358
396
|
'prompt': 'ansicyan bold',
|