npcsh 1.1.20__py3-none-any.whl → 1.1.22__py3-none-any.whl
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.
- npcsh/_state.py +15 -76
- npcsh/benchmark/npcsh_agent.py +22 -14
- npcsh/benchmark/templates/install-npcsh.sh.j2 +2 -2
- npcsh/diff_viewer.py +3 -3
- npcsh/mcp_server.py +9 -1
- npcsh/npc_team/alicanto.npc +12 -6
- npcsh/npc_team/corca.npc +0 -1
- npcsh/npc_team/frederic.npc +2 -3
- npcsh/npc_team/jinxs/lib/core/compress.jinx +373 -85
- npcsh/npc_team/jinxs/lib/core/edit_file.jinx +83 -61
- npcsh/npc_team/jinxs/lib/core/search/db_search.jinx +17 -6
- npcsh/npc_team/jinxs/lib/core/search/file_search.jinx +17 -6
- npcsh/npc_team/jinxs/lib/core/search/web_search.jinx +52 -14
- npcsh/npc_team/jinxs/{bin → lib/utils}/benchmark.jinx +2 -2
- npcsh/npc_team/jinxs/{bin → lib/utils}/jinxs.jinx +12 -12
- npcsh/npc_team/jinxs/{bin → lib/utils}/models.jinx +7 -7
- npcsh/npc_team/jinxs/{bin → lib/utils}/setup.jinx +6 -6
- npcsh/npc_team/jinxs/modes/alicanto.jinx +1633 -295
- npcsh/npc_team/jinxs/modes/arxiv.jinx +5 -5
- npcsh/npc_team/jinxs/modes/build.jinx +378 -0
- npcsh/npc_team/jinxs/modes/config_tui.jinx +300 -0
- npcsh/npc_team/jinxs/modes/convene.jinx +597 -0
- npcsh/npc_team/jinxs/modes/corca.jinx +777 -387
- npcsh/npc_team/jinxs/modes/git.jinx +795 -0
- {npcsh-1.1.20.data/data/npcsh/npc_team → npcsh/npc_team/jinxs/modes}/kg.jinx +82 -15
- npcsh/npc_team/jinxs/modes/memories.jinx +414 -0
- npcsh/npc_team/jinxs/{bin → modes}/nql.jinx +10 -21
- npcsh/npc_team/jinxs/modes/papers.jinx +578 -0
- npcsh/npc_team/jinxs/modes/plonk.jinx +503 -308
- npcsh/npc_team/jinxs/modes/reattach.jinx +3 -3
- npcsh/npc_team/jinxs/modes/spool.jinx +3 -3
- npcsh/npc_team/jinxs/{bin → modes}/team.jinx +12 -12
- npcsh/npc_team/jinxs/modes/vixynt.jinx +388 -0
- npcsh/npc_team/jinxs/modes/wander.jinx +454 -181
- npcsh/npc_team/jinxs/modes/yap.jinx +630 -182
- npcsh/npc_team/kadiefa.npc +2 -1
- npcsh/npc_team/sibiji.npc +3 -3
- npcsh/npcsh.py +112 -47
- npcsh/routes.py +4 -1
- npcsh/salmon_simulation.py +0 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/alicanto.jinx +1694 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/alicanto.npc +12 -6
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/arxiv.jinx +5 -5
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/benchmark.jinx +2 -2
- npcsh-1.1.22.data/data/npcsh/npc_team/build.jinx +378 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/compress.jinx +428 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/config_tui.jinx +300 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/corca.jinx +820 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/corca.npc +0 -1
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/db_search.jinx +17 -6
- npcsh-1.1.22.data/data/npcsh/npc_team/edit_file.jinx +119 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/file_search.jinx +17 -6
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/frederic.npc +2 -3
- npcsh-1.1.22.data/data/npcsh/npc_team/git.jinx +795 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/jinxs.jinx +12 -12
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/kadiefa.npc +2 -1
- {npcsh/npc_team/jinxs/bin → npcsh-1.1.22.data/data/npcsh/npc_team}/kg.jinx +82 -15
- npcsh-1.1.22.data/data/npcsh/npc_team/memories.jinx +414 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/models.jinx +7 -7
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/nql.jinx +10 -21
- npcsh-1.1.22.data/data/npcsh/npc_team/papers.jinx +578 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/plonk.jinx +574 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/reattach.jinx +3 -3
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/setup.jinx +6 -6
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sibiji.npc +3 -3
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/spool.jinx +3 -3
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/team.jinx +12 -12
- npcsh-1.1.22.data/data/npcsh/npc_team/vixynt.jinx +388 -0
- npcsh-1.1.22.data/data/npcsh/npc_team/wander.jinx +728 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/web_search.jinx +52 -14
- npcsh-1.1.22.data/data/npcsh/npc_team/yap.jinx +716 -0
- {npcsh-1.1.20.dist-info → npcsh-1.1.22.dist-info}/METADATA +246 -281
- npcsh-1.1.22.dist-info/RECORD +240 -0
- npcsh-1.1.22.dist-info/entry_points.txt +11 -0
- npcsh/npc_team/jinxs/bin/config_tui.jinx +0 -300
- npcsh/npc_team/jinxs/bin/memories.jinx +0 -317
- npcsh/npc_team/jinxs/bin/vixynt.jinx +0 -122
- npcsh/npc_team/jinxs/lib/core/search/kg_search.jinx +0 -418
- npcsh/npc_team/jinxs/lib/core/search/mem_review.jinx +0 -73
- npcsh/npc_team/jinxs/lib/core/search/mem_search.jinx +0 -388
- npcsh/npc_team/jinxs/lib/core/search.jinx +0 -54
- npcsh/npc_team/jinxs/lib/research/paper_search.jinx +0 -412
- npcsh/npc_team/jinxs/lib/research/semantic_scholar.jinx +0 -386
- npcsh/npc_team/jinxs/lib/utils/build.jinx +0 -65
- npcsh/npc_team/plonkjr.npc +0 -23
- npcsh-1.1.20.data/data/npcsh/npc_team/alicanto.jinx +0 -356
- npcsh-1.1.20.data/data/npcsh/npc_team/build.jinx +0 -65
- npcsh-1.1.20.data/data/npcsh/npc_team/compress.jinx +0 -140
- npcsh-1.1.20.data/data/npcsh/npc_team/config_tui.jinx +0 -300
- npcsh-1.1.20.data/data/npcsh/npc_team/corca.jinx +0 -430
- npcsh-1.1.20.data/data/npcsh/npc_team/edit_file.jinx +0 -97
- npcsh-1.1.20.data/data/npcsh/npc_team/kg_search.jinx +0 -418
- npcsh-1.1.20.data/data/npcsh/npc_team/mem_review.jinx +0 -73
- npcsh-1.1.20.data/data/npcsh/npc_team/mem_search.jinx +0 -388
- npcsh-1.1.20.data/data/npcsh/npc_team/memories.jinx +0 -317
- npcsh-1.1.20.data/data/npcsh/npc_team/paper_search.jinx +0 -412
- npcsh-1.1.20.data/data/npcsh/npc_team/plonk.jinx +0 -379
- npcsh-1.1.20.data/data/npcsh/npc_team/plonkjr.npc +0 -23
- npcsh-1.1.20.data/data/npcsh/npc_team/search.jinx +0 -54
- npcsh-1.1.20.data/data/npcsh/npc_team/semantic_scholar.jinx +0 -386
- npcsh-1.1.20.data/data/npcsh/npc_team/vixynt.jinx +0 -122
- npcsh-1.1.20.data/data/npcsh/npc_team/wander.jinx +0 -455
- npcsh-1.1.20.data/data/npcsh/npc_team/yap.jinx +0 -268
- npcsh-1.1.20.dist-info/RECORD +0 -248
- npcsh-1.1.20.dist-info/entry_points.txt +0 -25
- /npcsh/npc_team/jinxs/lib/{orchestration → core}/convene.jinx +0 -0
- /npcsh/npc_team/jinxs/lib/{orchestration → core}/delegate.jinx +0 -0
- /npcsh/npc_team/jinxs/{bin → lib/core}/sample.jinx +0 -0
- /npcsh/npc_team/jinxs/lib/{core → utils}/chat.jinx +0 -0
- /npcsh/npc_team/jinxs/lib/{core → utils}/cmd.jinx +0 -0
- /npcsh/npc_team/jinxs/{bin → lib/utils}/sync.jinx +0 -0
- /npcsh/npc_team/jinxs/{bin → modes}/roll.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/add_tab.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/alicanto.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/browser_action.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/browser_screenshot.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/chat.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/click.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/close_browser.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/close_pane.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/close_tab.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/cmd.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/compile.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/confirm.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/convene.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/corca.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/corca_example.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/delegate.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/focus_pane.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/frederic4.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/guac.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/guac.npc +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/guac.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/help.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/incognide.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/init.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/kadiefa.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/key_press.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/launch_app.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/list_panes.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/load_file.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/navigate.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/notify.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/npcsh.ctx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/npcsh_sibiji.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/open_browser.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/open_pane.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/ots.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/paste.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/plonk.npc +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/plonk.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/plonkjr.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/pti.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/python.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/read_pane.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/roll.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/run_terminal.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sample.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/screenshot.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/send_message.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/serve.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/set.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sh.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/shh.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sibiji.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sleep.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/split_pane.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/spool.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sql.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/switch.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/switch_npc.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/switch_tab.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/switches.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/sync.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/teamviz.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/trigger.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/type_text.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/usage.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/verbose.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/wait.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/write_file.jinx +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/yap.png +0 -0
- {npcsh-1.1.20.data → npcsh-1.1.22.data}/data/npcsh/npc_team/zen_mode.jinx +0 -0
- {npcsh-1.1.20.dist-info → npcsh-1.1.22.dist-info}/WHEEL +0 -0
- {npcsh-1.1.20.dist-info → npcsh-1.1.22.dist-info}/licenses/LICENSE +0 -0
- {npcsh-1.1.20.dist-info → npcsh-1.1.22.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
jinx_name: db_search
|
|
2
2
|
description: Search conversation history database with interactive TUI
|
|
3
|
+
interactive: true
|
|
3
4
|
inputs:
|
|
4
5
|
- query: ""
|
|
5
6
|
- path: ""
|
|
@@ -179,7 +180,7 @@ steps:
|
|
|
179
180
|
header = f" DB SEARCH ({len(display_rows)} results): '{query}' [sort:{sort_mode}({sort_ind}) filter:{role_filter}] "
|
|
180
181
|
else:
|
|
181
182
|
header = f" PREVIEW: {display_rows[selected]['conversation_id'][:16]} "
|
|
182
|
-
sys.stdout.write(f'\033[
|
|
183
|
+
sys.stdout.write(f'\033[7;1m{header.ljust(width)}\033[0m\n')
|
|
183
184
|
|
|
184
185
|
# Column headers
|
|
185
186
|
if mode == 'list':
|
|
@@ -225,7 +226,7 @@ steps:
|
|
|
225
226
|
if len(path) > 40:
|
|
226
227
|
path = '...' + path[-37:]
|
|
227
228
|
sys.stdout.write(f'\033[{height-1};1H\033[K {cid} @ {path}'.ljust(width))
|
|
228
|
-
sys.stdout.write(f'\033[{height};1H\033[K\033[
|
|
229
|
+
sys.stdout.write(f'\033[{height};1H\033[K\033[7m j/k:Nav 1/2/3:Sort f:Filter p:Preview r:Reattach q:Quit [{selected+1}/{len(display_rows)}] \033[0m')
|
|
229
230
|
|
|
230
231
|
else: # preview mode
|
|
231
232
|
sel = display_rows[selected]
|
|
@@ -243,16 +244,26 @@ steps:
|
|
|
243
244
|
npc_name = sel.get('npc') or 'default'
|
|
244
245
|
ts = format_ts(sel.get('timestamp'))
|
|
245
246
|
sys.stdout.write(f'\033[{height-1};1H\033[K {role}/{npc_name} - {ts} [{preview_scroll+1}/{len(lines)} lines]')
|
|
246
|
-
sys.stdout.write(f'\033[{height};1H\033[K\033[
|
|
247
|
+
sys.stdout.write(f'\033[{height};1H\033[K\033[7m j/k:Scroll b:Back r:Reattach q:Quit \033[0m')
|
|
247
248
|
|
|
248
249
|
sys.stdout.flush()
|
|
249
250
|
|
|
250
|
-
c =
|
|
251
|
+
c = os.read(fd, 1).decode('latin-1')
|
|
251
252
|
|
|
252
253
|
if c == '\x1b':
|
|
253
|
-
|
|
254
|
+
import select as _sel
|
|
255
|
+
if _sel.select([fd], [], [], 0.05)[0]:
|
|
256
|
+
c2 = os.read(fd, 1).decode('latin-1')
|
|
257
|
+
else:
|
|
258
|
+
if mode == 'preview':
|
|
259
|
+
mode = 'list'
|
|
260
|
+
sys.stdout.write('\033[2J\033[H')
|
|
261
|
+
else:
|
|
262
|
+
context['output'] = "Cancelled."
|
|
263
|
+
break
|
|
264
|
+
continue
|
|
254
265
|
if c2 == '[':
|
|
255
|
-
c3 =
|
|
266
|
+
c3 = os.read(fd, 1).decode('latin-1')
|
|
256
267
|
if c3 == 'A': # Up
|
|
257
268
|
if mode == 'list' and selected > 0:
|
|
258
269
|
selected -= 1
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
jinx_name: edit_file
|
|
2
|
+
description: Creates or edits a file. If the file does not exist, creates it with
|
|
3
|
+
the specified content. If the file exists, examines it and applies changes.
|
|
4
|
+
inputs:
|
|
5
|
+
- file_path
|
|
6
|
+
- edit_instructions
|
|
7
|
+
- backup: true
|
|
8
|
+
steps:
|
|
9
|
+
- name: "edit_file"
|
|
10
|
+
engine: "python"
|
|
11
|
+
code: |
|
|
12
|
+
import os
|
|
13
|
+
from npcpy.llm_funcs import get_llm_response
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
file_path = os.path.expanduser({{ file_path | tojson }})
|
|
17
|
+
edit_instructions = {{ edit_instructions | string | tojson }}
|
|
18
|
+
backup_str = {{ backup | default("true") | string | tojson }}
|
|
19
|
+
create_backup = backup_str.lower() not in ('false', 'no', '0', '')
|
|
20
|
+
|
|
21
|
+
# Ensure parent directory exists
|
|
22
|
+
os.makedirs(os.path.dirname(file_path) or '.', exist_ok=True)
|
|
23
|
+
|
|
24
|
+
# If file doesn't exist, create it
|
|
25
|
+
if not os.path.exists(file_path):
|
|
26
|
+
prompt = """You are a code writing assistant. Create the content for a new file based on these instructions.
|
|
27
|
+
|
|
28
|
+
Instructions: """ + edit_instructions + """
|
|
29
|
+
|
|
30
|
+
Return a JSON object with:
|
|
31
|
+
1. "content": The full content to write to the file
|
|
32
|
+
2. "explanation": Brief explanation of what was created
|
|
33
|
+
|
|
34
|
+
Example response:
|
|
35
|
+
{"content": "print('hello world')", "explanation": "Created a Python hello world script"}
|
|
36
|
+
"""
|
|
37
|
+
response = get_llm_response(prompt, model=npc.model, provider=npc.provider, npc=npc, format="json")
|
|
38
|
+
result = response.get("response", {})
|
|
39
|
+
content = result.get("content", edit_instructions)
|
|
40
|
+
explanation = result.get("explanation", "Created new file")
|
|
41
|
+
|
|
42
|
+
with open(file_path, 'w') as f:
|
|
43
|
+
f.write(content)
|
|
44
|
+
|
|
45
|
+
output = "Created " + file_path + "\n\n" + explanation
|
|
46
|
+
else:
|
|
47
|
+
with open(file_path, 'r') as f:
|
|
48
|
+
original_content = f.read()
|
|
49
|
+
|
|
50
|
+
if create_backup:
|
|
51
|
+
backup_path = file_path + ".bak"
|
|
52
|
+
with open(backup_path, 'w') as f:
|
|
53
|
+
f.write(original_content)
|
|
54
|
+
|
|
55
|
+
prompt = """You are a code editing assistant. Analyze this file and make the requested changes.
|
|
56
|
+
|
|
57
|
+
File content:
|
|
58
|
+
""" + original_content + """
|
|
59
|
+
|
|
60
|
+
Edit instructions: """ + edit_instructions + """
|
|
61
|
+
|
|
62
|
+
Return a JSON object with these fields:
|
|
63
|
+
1. "modifications": An array of modification objects, where each object has:
|
|
64
|
+
- "type": One of "replace", "insert_after", "insert_before", or "delete"
|
|
65
|
+
- "target": For "insert_after" and "insert_before", the text to insert after/before
|
|
66
|
+
For "delete", the text to delete
|
|
67
|
+
- "original": For "replace", the text to be replaced
|
|
68
|
+
- "replacement": For "replace", the text to replace with
|
|
69
|
+
- "insertion": For "insert_after" and "insert_before", the text to insert
|
|
70
|
+
2. "explanation": Brief explanation of the changes made
|
|
71
|
+
|
|
72
|
+
Example response:
|
|
73
|
+
{"modifications": [{"type": "replace", "original": "old code", "replacement": "new code"}], "explanation": "Updated the code"}
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
response = get_llm_response(prompt, model=npc.model, provider=npc.provider, npc=npc, format="json")
|
|
77
|
+
|
|
78
|
+
result = response.get("response", {})
|
|
79
|
+
modifications = result.get("modifications", [])
|
|
80
|
+
explanation = result.get("explanation", "No explanation provided")
|
|
81
|
+
|
|
82
|
+
updated_content = original_content
|
|
83
|
+
changes_applied = 0
|
|
84
|
+
|
|
85
|
+
for mod in modifications:
|
|
86
|
+
print(mod)
|
|
87
|
+
mod_type = mod.get("type")
|
|
88
|
+
|
|
89
|
+
if mod_type == "replace":
|
|
90
|
+
original = mod.get("original")
|
|
91
|
+
replacement = mod.get("replacement")
|
|
92
|
+
if original in updated_content:
|
|
93
|
+
updated_content = updated_content.replace(original, replacement)
|
|
94
|
+
changes_applied += 1
|
|
95
|
+
|
|
96
|
+
elif mod_type == "insert_after":
|
|
97
|
+
target = mod.get("target")
|
|
98
|
+
insertion = mod.get("insertion")
|
|
99
|
+
if target in updated_content:
|
|
100
|
+
updated_content = updated_content.replace(target, target + insertion)
|
|
101
|
+
changes_applied += 1
|
|
102
|
+
|
|
103
|
+
elif mod_type == "insert_before":
|
|
104
|
+
target = mod.get("target")
|
|
105
|
+
insertion = mod.get("insertion")
|
|
106
|
+
if target in updated_content:
|
|
107
|
+
updated_content = updated_content.replace(target, insertion + target)
|
|
108
|
+
changes_applied += 1
|
|
109
|
+
|
|
110
|
+
elif mod_type == "delete":
|
|
111
|
+
target = mod.get("target")
|
|
112
|
+
if target in updated_content:
|
|
113
|
+
updated_content = updated_content.replace(target, "")
|
|
114
|
+
changes_applied += 1
|
|
115
|
+
|
|
116
|
+
with open(file_path, 'w') as f:
|
|
117
|
+
f.write(updated_content)
|
|
118
|
+
|
|
119
|
+
output = "Applied " + str(changes_applied) + " changes to " + file_path + "\n\n" + explanation
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
jinx_name: file_search
|
|
2
2
|
description: Find and browse files with interactive TUI
|
|
3
|
+
interactive: true
|
|
3
4
|
inputs:
|
|
4
5
|
- pattern: ""
|
|
5
6
|
- path: "."
|
|
@@ -176,7 +177,7 @@ steps:
|
|
|
176
177
|
header = f" FILES ({len(display_files)}): '{pattern}' [sort:{sort_mode}({sort_ind})] "
|
|
177
178
|
else:
|
|
178
179
|
header = f" PREVIEW: {display_files[selected]['name']} "
|
|
179
|
-
sys.stdout.write(f'\033[
|
|
180
|
+
sys.stdout.write(f'\033[7;1m{header.ljust(width)}\033[0m\n')
|
|
180
181
|
|
|
181
182
|
# Column headers
|
|
182
183
|
if mode == 'list':
|
|
@@ -216,7 +217,7 @@ steps:
|
|
|
216
217
|
f = display_files[selected] if display_files else {}
|
|
217
218
|
full_path = f.get('path', '')
|
|
218
219
|
sys.stdout.write(f'\033[{height-1};1H\033[K {full_path}'.ljust(width)[:width])
|
|
219
|
-
sys.stdout.write(f'\033[{height};1H\033[K\033[
|
|
220
|
+
sys.stdout.write(f'\033[{height};1H\033[K\033[7m j/k:Nav 1/2/3:Sort p:Preview o:Edit i:Incog c:Copy q:Quit [{selected+1}/{len(display_files)}] \033[0m')
|
|
220
221
|
|
|
221
222
|
elif mode == 'preview':
|
|
222
223
|
for i in range(list_height):
|
|
@@ -227,16 +228,26 @@ steps:
|
|
|
227
228
|
|
|
228
229
|
sys.stdout.write(f'\033[{height-2};1H\033[K\033[90m{"─" * width}\033[0m')
|
|
229
230
|
sys.stdout.write(f'\033[{height-1};1H\033[K [{preview_scroll+1}/{len(preview_lines)} lines]')
|
|
230
|
-
sys.stdout.write(f'\033[{height};1H\033[K\033[
|
|
231
|
+
sys.stdout.write(f'\033[{height};1H\033[K\033[7m j/k:Scroll b:Back o:Edit q:Quit \033[0m')
|
|
231
232
|
|
|
232
233
|
sys.stdout.flush()
|
|
233
234
|
|
|
234
|
-
c =
|
|
235
|
+
c = os.read(fd, 1).decode('latin-1')
|
|
235
236
|
|
|
236
237
|
if c == '\x1b':
|
|
237
|
-
|
|
238
|
+
import select as _sel
|
|
239
|
+
if _sel.select([fd], [], [], 0.05)[0]:
|
|
240
|
+
c2 = os.read(fd, 1).decode('latin-1')
|
|
241
|
+
else:
|
|
242
|
+
if mode == 'preview':
|
|
243
|
+
mode = 'list'
|
|
244
|
+
sys.stdout.write('\033[2J\033[H')
|
|
245
|
+
else:
|
|
246
|
+
context['output'] = "Cancelled."
|
|
247
|
+
break
|
|
248
|
+
continue
|
|
238
249
|
if c2 == '[':
|
|
239
|
-
c3 =
|
|
250
|
+
c3 = os.read(fd, 1).decode('latin-1')
|
|
240
251
|
if c3 == 'A':
|
|
241
252
|
if mode == 'list' and selected > 0:
|
|
242
253
|
selected -= 1
|