nc1709 1.15.4__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.
Files changed (86) hide show
  1. nc1709/__init__.py +13 -0
  2. nc1709/agent/__init__.py +36 -0
  3. nc1709/agent/core.py +505 -0
  4. nc1709/agent/mcp_bridge.py +245 -0
  5. nc1709/agent/permissions.py +298 -0
  6. nc1709/agent/tools/__init__.py +21 -0
  7. nc1709/agent/tools/base.py +440 -0
  8. nc1709/agent/tools/bash_tool.py +367 -0
  9. nc1709/agent/tools/file_tools.py +454 -0
  10. nc1709/agent/tools/notebook_tools.py +516 -0
  11. nc1709/agent/tools/search_tools.py +322 -0
  12. nc1709/agent/tools/task_tool.py +284 -0
  13. nc1709/agent/tools/web_tools.py +555 -0
  14. nc1709/agents/__init__.py +17 -0
  15. nc1709/agents/auto_fix.py +506 -0
  16. nc1709/agents/test_generator.py +507 -0
  17. nc1709/checkpoints.py +372 -0
  18. nc1709/cli.py +3380 -0
  19. nc1709/cli_ui.py +1080 -0
  20. nc1709/cognitive/__init__.py +149 -0
  21. nc1709/cognitive/anticipation.py +594 -0
  22. nc1709/cognitive/context_engine.py +1046 -0
  23. nc1709/cognitive/council.py +824 -0
  24. nc1709/cognitive/learning.py +761 -0
  25. nc1709/cognitive/router.py +583 -0
  26. nc1709/cognitive/system.py +519 -0
  27. nc1709/config.py +155 -0
  28. nc1709/custom_commands.py +300 -0
  29. nc1709/executor.py +333 -0
  30. nc1709/file_controller.py +354 -0
  31. nc1709/git_integration.py +308 -0
  32. nc1709/github_integration.py +477 -0
  33. nc1709/image_input.py +446 -0
  34. nc1709/linting.py +519 -0
  35. nc1709/llm_adapter.py +667 -0
  36. nc1709/logger.py +192 -0
  37. nc1709/mcp/__init__.py +18 -0
  38. nc1709/mcp/client.py +370 -0
  39. nc1709/mcp/manager.py +407 -0
  40. nc1709/mcp/protocol.py +210 -0
  41. nc1709/mcp/server.py +473 -0
  42. nc1709/memory/__init__.py +20 -0
  43. nc1709/memory/embeddings.py +325 -0
  44. nc1709/memory/indexer.py +474 -0
  45. nc1709/memory/sessions.py +432 -0
  46. nc1709/memory/vector_store.py +451 -0
  47. nc1709/models/__init__.py +86 -0
  48. nc1709/models/detector.py +377 -0
  49. nc1709/models/formats.py +315 -0
  50. nc1709/models/manager.py +438 -0
  51. nc1709/models/registry.py +497 -0
  52. nc1709/performance/__init__.py +343 -0
  53. nc1709/performance/cache.py +705 -0
  54. nc1709/performance/pipeline.py +611 -0
  55. nc1709/performance/tiering.py +543 -0
  56. nc1709/plan_mode.py +362 -0
  57. nc1709/plugins/__init__.py +17 -0
  58. nc1709/plugins/agents/__init__.py +18 -0
  59. nc1709/plugins/agents/django_agent.py +912 -0
  60. nc1709/plugins/agents/docker_agent.py +623 -0
  61. nc1709/plugins/agents/fastapi_agent.py +887 -0
  62. nc1709/plugins/agents/git_agent.py +731 -0
  63. nc1709/plugins/agents/nextjs_agent.py +867 -0
  64. nc1709/plugins/base.py +359 -0
  65. nc1709/plugins/manager.py +411 -0
  66. nc1709/plugins/registry.py +337 -0
  67. nc1709/progress.py +443 -0
  68. nc1709/prompts/__init__.py +22 -0
  69. nc1709/prompts/agent_system.py +180 -0
  70. nc1709/prompts/task_prompts.py +340 -0
  71. nc1709/prompts/unified_prompt.py +133 -0
  72. nc1709/reasoning_engine.py +541 -0
  73. nc1709/remote_client.py +266 -0
  74. nc1709/shell_completions.py +349 -0
  75. nc1709/slash_commands.py +649 -0
  76. nc1709/task_classifier.py +408 -0
  77. nc1709/version_check.py +177 -0
  78. nc1709/web/__init__.py +8 -0
  79. nc1709/web/server.py +950 -0
  80. nc1709/web/templates/index.html +1127 -0
  81. nc1709-1.15.4.dist-info/METADATA +858 -0
  82. nc1709-1.15.4.dist-info/RECORD +86 -0
  83. nc1709-1.15.4.dist-info/WHEEL +5 -0
  84. nc1709-1.15.4.dist-info/entry_points.txt +2 -0
  85. nc1709-1.15.4.dist-info/licenses/LICENSE +9 -0
  86. nc1709-1.15.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,649 @@
1
+ """
2
+ Slash Commands System for NC1709
3
+ Provides "/" command autocomplete with descriptions
4
+ """
5
+
6
+ from dataclasses import dataclass
7
+ from typing import List, Optional, Callable, Dict, Any
8
+ from prompt_toolkit.completion import Completer, Completion
9
+ from prompt_toolkit.document import Document
10
+
11
+
12
+ @dataclass
13
+ class SlashCommand:
14
+ """Definition of a slash command"""
15
+ name: str # Command name without "/"
16
+ description: str # Short description shown in popup
17
+ handler: Optional[Callable] = None # Function to execute
18
+ category: str = "general" # Category for grouping
19
+ aliases: Optional[List[str]] = None # Alternative names
20
+
21
+
22
+ # All available slash commands
23
+ SLASH_COMMANDS: List[SlashCommand] = [
24
+ # General Commands
25
+ SlashCommand(
26
+ name="help",
27
+ description="Show all available commands and shortcuts",
28
+ category="general"
29
+ ),
30
+ SlashCommand(
31
+ name="clear",
32
+ description="Clear conversation history and start fresh",
33
+ category="general"
34
+ ),
35
+ SlashCommand(
36
+ name="exit",
37
+ description="Exit NC1709 and save session",
38
+ category="general",
39
+ aliases=["quit", "q"]
40
+ ),
41
+ SlashCommand(
42
+ name="history",
43
+ description="Show recent command execution history",
44
+ category="general"
45
+ ),
46
+ SlashCommand(
47
+ name="config",
48
+ description="View current configuration summary",
49
+ category="general"
50
+ ),
51
+ SlashCommand(
52
+ name="config raw",
53
+ description="Show full configuration as JSON",
54
+ category="general"
55
+ ),
56
+ SlashCommand(
57
+ name="version",
58
+ description="Show NC1709 version information",
59
+ category="general"
60
+ ),
61
+
62
+ # Agent Commands
63
+ SlashCommand(
64
+ name="agent",
65
+ description="Toggle agent mode for autonomous tool execution",
66
+ category="agent"
67
+ ),
68
+ SlashCommand(
69
+ name="agent on",
70
+ description="Enable agent mode with tool execution",
71
+ category="agent"
72
+ ),
73
+ SlashCommand(
74
+ name="agent off",
75
+ description="Disable agent mode",
76
+ category="agent"
77
+ ),
78
+ SlashCommand(
79
+ name="agent tools",
80
+ description="List all available agent tools",
81
+ category="agent"
82
+ ),
83
+ SlashCommand(
84
+ name="agent status",
85
+ description="Show agent status and recent tool history",
86
+ category="agent"
87
+ ),
88
+
89
+ # File Operations
90
+ SlashCommand(
91
+ name="read",
92
+ description="Read and display a file's contents",
93
+ category="files"
94
+ ),
95
+ SlashCommand(
96
+ name="edit",
97
+ description="Edit a file with AI assistance",
98
+ category="files"
99
+ ),
100
+ SlashCommand(
101
+ name="create",
102
+ description="Create a new file",
103
+ category="files"
104
+ ),
105
+ SlashCommand(
106
+ name="diff",
107
+ description="Show changes in a file or directory",
108
+ category="files"
109
+ ),
110
+
111
+ # Search & Navigation
112
+ SlashCommand(
113
+ name="search",
114
+ description="Search code semantically in indexed project",
115
+ category="search"
116
+ ),
117
+ SlashCommand(
118
+ name="find",
119
+ description="Find files by name pattern",
120
+ category="search"
121
+ ),
122
+ SlashCommand(
123
+ name="grep",
124
+ description="Search for text in files",
125
+ category="search"
126
+ ),
127
+ SlashCommand(
128
+ name="index",
129
+ description="Index current project for semantic search",
130
+ category="search"
131
+ ),
132
+
133
+ # Session Management
134
+ SlashCommand(
135
+ name="sessions",
136
+ description="List all saved conversation sessions",
137
+ category="session"
138
+ ),
139
+ SlashCommand(
140
+ name="save",
141
+ description="Save current session",
142
+ category="session"
143
+ ),
144
+ SlashCommand(
145
+ name="resume",
146
+ description="Resume a previous session by ID",
147
+ category="session"
148
+ ),
149
+
150
+ # Git Commands
151
+ SlashCommand(
152
+ name="git status",
153
+ description="Show git working tree status",
154
+ category="git"
155
+ ),
156
+ SlashCommand(
157
+ name="git diff",
158
+ description="Show git diff of changes",
159
+ category="git"
160
+ ),
161
+ SlashCommand(
162
+ name="git log",
163
+ description="Show recent git commit history",
164
+ category="git"
165
+ ),
166
+ SlashCommand(
167
+ name="git commit",
168
+ description="Commit staged changes with AI-generated message",
169
+ category="git"
170
+ ),
171
+ SlashCommand(
172
+ name="git branch",
173
+ description="List or create git branches",
174
+ category="git"
175
+ ),
176
+ SlashCommand(
177
+ name="git push",
178
+ description="Push commits to remote",
179
+ category="git"
180
+ ),
181
+ SlashCommand(
182
+ name="git pull",
183
+ description="Pull latest changes from remote",
184
+ category="git"
185
+ ),
186
+
187
+ # Docker Commands
188
+ SlashCommand(
189
+ name="docker ps",
190
+ description="List running Docker containers",
191
+ category="docker"
192
+ ),
193
+ SlashCommand(
194
+ name="docker images",
195
+ description="List Docker images",
196
+ category="docker"
197
+ ),
198
+ SlashCommand(
199
+ name="docker logs",
200
+ description="View Docker container logs",
201
+ category="docker"
202
+ ),
203
+ SlashCommand(
204
+ name="docker compose up",
205
+ description="Start Docker Compose services",
206
+ category="docker"
207
+ ),
208
+ SlashCommand(
209
+ name="docker compose down",
210
+ description="Stop Docker Compose services",
211
+ category="docker"
212
+ ),
213
+
214
+ # Code Actions
215
+ SlashCommand(
216
+ name="fix",
217
+ description="Auto-detect and fix errors in code",
218
+ category="code"
219
+ ),
220
+ SlashCommand(
221
+ name="test",
222
+ description="Generate unit tests for a file",
223
+ category="code"
224
+ ),
225
+ SlashCommand(
226
+ name="explain",
227
+ description="Explain what a piece of code does",
228
+ category="code"
229
+ ),
230
+ SlashCommand(
231
+ name="refactor",
232
+ description="Suggest refactoring improvements",
233
+ category="code"
234
+ ),
235
+ SlashCommand(
236
+ name="review",
237
+ description="Review code for issues and improvements",
238
+ category="code"
239
+ ),
240
+ SlashCommand(
241
+ name="optimize",
242
+ description="Suggest performance optimizations",
243
+ category="code"
244
+ ),
245
+ SlashCommand(
246
+ name="document",
247
+ description="Generate documentation for code",
248
+ category="code"
249
+ ),
250
+
251
+ # MCP Commands
252
+ SlashCommand(
253
+ name="mcp",
254
+ description="Show MCP server status",
255
+ category="mcp"
256
+ ),
257
+ SlashCommand(
258
+ name="mcp tools",
259
+ description="List available MCP tools",
260
+ category="mcp"
261
+ ),
262
+
263
+ # Plugins
264
+ SlashCommand(
265
+ name="plugins",
266
+ description="List available plugins",
267
+ category="plugins"
268
+ ),
269
+
270
+ # Custom Commands
271
+ SlashCommand(
272
+ name="commands",
273
+ description="List available custom slash commands",
274
+ category="custom"
275
+ ),
276
+
277
+ # GitHub/PR Commands
278
+ SlashCommand(
279
+ name="pr",
280
+ description="Create a new Pull Request from current branch",
281
+ category="github"
282
+ ),
283
+ SlashCommand(
284
+ name="pr list",
285
+ description="List open Pull Requests",
286
+ category="github"
287
+ ),
288
+ SlashCommand(
289
+ name="pr view",
290
+ description="View a specific Pull Request",
291
+ category="github"
292
+ ),
293
+ SlashCommand(
294
+ name="issues",
295
+ description="List open issues",
296
+ category="github"
297
+ ),
298
+ SlashCommand(
299
+ name="gh",
300
+ description="Run a gh CLI command",
301
+ category="github"
302
+ ),
303
+
304
+ # Linting Commands
305
+ SlashCommand(
306
+ name="lint",
307
+ description="Run linter on project or file",
308
+ category="lint"
309
+ ),
310
+ SlashCommand(
311
+ name="lint file",
312
+ description="Lint a specific file",
313
+ category="lint"
314
+ ),
315
+ SlashCommand(
316
+ name="lint fix",
317
+ description="Run linter with auto-fix enabled",
318
+ category="lint"
319
+ ),
320
+ SlashCommand(
321
+ name="lint linters",
322
+ description="List available linters",
323
+ category="lint"
324
+ ),
325
+
326
+ # Plan Mode
327
+ SlashCommand(
328
+ name="plan",
329
+ description="Enter plan mode (think before acting)",
330
+ category="plan"
331
+ ),
332
+ SlashCommand(
333
+ name="plan approve",
334
+ description="Approve the current plan and execute it",
335
+ category="plan"
336
+ ),
337
+ SlashCommand(
338
+ name="plan reject",
339
+ description="Reject the current plan",
340
+ category="plan"
341
+ ),
342
+ SlashCommand(
343
+ name="plan show",
344
+ description="Show the current plan",
345
+ category="plan"
346
+ ),
347
+ SlashCommand(
348
+ name="plan exit",
349
+ description="Exit plan mode without executing",
350
+ category="plan"
351
+ ),
352
+
353
+ # Image/Screenshot Input
354
+ SlashCommand(
355
+ name="image",
356
+ description="Add an image file to your next prompt",
357
+ category="image"
358
+ ),
359
+ SlashCommand(
360
+ name="screenshot",
361
+ description="Capture a screenshot to include in your next prompt",
362
+ category="image"
363
+ ),
364
+ SlashCommand(
365
+ name="paste",
366
+ description="Paste image from clipboard for your next prompt",
367
+ category="image"
368
+ ),
369
+ SlashCommand(
370
+ name="images",
371
+ description="List pending images for next prompt",
372
+ category="image"
373
+ ),
374
+ SlashCommand(
375
+ name="clear-images",
376
+ description="Clear pending images",
377
+ category="image"
378
+ ),
379
+
380
+ # Quick Actions
381
+ SlashCommand(
382
+ name="run",
383
+ description="Run a shell command",
384
+ category="quick"
385
+ ),
386
+ SlashCommand(
387
+ name="web",
388
+ description="Start the web dashboard",
389
+ category="quick"
390
+ ),
391
+ SlashCommand(
392
+ name="compact",
393
+ description="Summarize conversation to reduce context",
394
+ category="quick"
395
+ ),
396
+
397
+ # Checkpoint Commands
398
+ SlashCommand(
399
+ name="rewind",
400
+ description="Undo last file change (rewind to previous checkpoint)",
401
+ category="checkpoint",
402
+ aliases=["undo"]
403
+ ),
404
+ SlashCommand(
405
+ name="checkpoints",
406
+ description="List recent file checkpoints",
407
+ category="checkpoint"
408
+ ),
409
+ SlashCommand(
410
+ name="forward",
411
+ description="Redo after rewind (go forward in checkpoint history)",
412
+ category="checkpoint",
413
+ aliases=["redo"]
414
+ ),
415
+
416
+ # Git Auto-commit Commands
417
+ SlashCommand(
418
+ name="autocommit",
419
+ description="Toggle automatic git commits after file changes",
420
+ category="git"
421
+ ),
422
+ SlashCommand(
423
+ name="autocommit on",
424
+ description="Enable automatic git commits",
425
+ category="git"
426
+ ),
427
+ SlashCommand(
428
+ name="autocommit off",
429
+ description="Disable automatic git commits",
430
+ category="git"
431
+ ),
432
+
433
+ # Model Registry Commands
434
+ SlashCommand(
435
+ name="models",
436
+ description="Show Model Registry status and available models",
437
+ category="models"
438
+ ),
439
+ SlashCommand(
440
+ name="models list",
441
+ description="List all known models with capabilities",
442
+ category="models"
443
+ ),
444
+ SlashCommand(
445
+ name="models detect",
446
+ description="Auto-detect models from Ollama",
447
+ category="models"
448
+ ),
449
+ SlashCommand(
450
+ name="models recommend",
451
+ description="Get model recommendations for tasks",
452
+ category="models"
453
+ ),
454
+
455
+ # Brain/Cognitive System Commands
456
+ SlashCommand(
457
+ name="brain",
458
+ description="Show cognitive system status",
459
+ category="brain"
460
+ ),
461
+ SlashCommand(
462
+ name="brain status",
463
+ description="Show cognitive system status",
464
+ category="brain"
465
+ ),
466
+ SlashCommand(
467
+ name="brain suggest",
468
+ description="Get AI suggestions for current context",
469
+ category="brain"
470
+ ),
471
+ SlashCommand(
472
+ name="brain index",
473
+ description="Index project for cognitive understanding",
474
+ category="brain"
475
+ ),
476
+ SlashCommand(
477
+ name="brain insights",
478
+ description="Show AI insights about your codebase",
479
+ category="brain"
480
+ ),
481
+ ]
482
+
483
+
484
+ class SlashCommandCompleter(Completer):
485
+ """Autocomplete for slash commands including custom commands"""
486
+
487
+ def __init__(self, commands: Optional[List[SlashCommand]] = None):
488
+ self.commands = commands or SLASH_COMMANDS
489
+ self._custom_manager = None
490
+
491
+ def _get_custom_manager(self):
492
+ """Lazy load custom command manager"""
493
+ if self._custom_manager is None:
494
+ try:
495
+ from .custom_commands import get_custom_command_manager
496
+ self._custom_manager = get_custom_command_manager()
497
+ except ImportError:
498
+ pass
499
+ return self._custom_manager
500
+
501
+ def get_completions(self, document: Document, complete_event) -> List[Completion]:
502
+ """Get completions for current input"""
503
+ text = document.text_before_cursor
504
+
505
+ # Only complete if starting with /
506
+ if not text.startswith('/'):
507
+ return
508
+
509
+ # Get the partial command (without the /)
510
+ partial = text[1:].lower()
511
+
512
+ # Find matching built-in commands
513
+ for cmd in self.commands:
514
+ cmd_name = cmd.name.lower()
515
+
516
+ # Match if partial is empty (show all) or partial is prefix of command name
517
+ if partial == "" or cmd_name.startswith(partial):
518
+ # Calculate how much to complete
519
+ completion_text = cmd.name[len(partial):]
520
+
521
+ yield Completion(
522
+ completion_text,
523
+ start_position=0,
524
+ display=f"/{cmd.name}",
525
+ display_meta=cmd.description,
526
+ style='class:completion',
527
+ selected_style='class:completion.selected'
528
+ )
529
+
530
+ # Also check aliases (but not when showing all)
531
+ elif cmd.aliases:
532
+ for alias in cmd.aliases:
533
+ if alias.lower().startswith(partial):
534
+ completion_text = alias[len(partial):]
535
+ yield Completion(
536
+ completion_text,
537
+ start_position=0,
538
+ display=f"/{alias}",
539
+ display_meta=f"{cmd.description} (alias for /{cmd.name})",
540
+ style='class:completion',
541
+ selected_style='class:completion.selected'
542
+ )
543
+
544
+ # Add custom commands
545
+ manager = self._get_custom_manager()
546
+ if manager:
547
+ for custom_cmd in manager.list_commands():
548
+ cmd_name = custom_cmd.name.lower()
549
+ if partial == "" or cmd_name.startswith(partial):
550
+ completion_text = custom_cmd.name[len(partial):]
551
+ scope_tag = "[project]" if custom_cmd.scope == "project" else "[personal]"
552
+
553
+ yield Completion(
554
+ completion_text,
555
+ start_position=0,
556
+ display=f"/{custom_cmd.name}",
557
+ display_meta=f"{custom_cmd.description} {scope_tag}",
558
+ style='class:completion.custom',
559
+ selected_style='class:completion.selected'
560
+ )
561
+
562
+
563
+ def get_command_by_name(name: str) -> Optional[SlashCommand]:
564
+ """Get a slash command by name or alias
565
+
566
+ Args:
567
+ name: Command name (with or without leading /)
568
+
569
+ Returns:
570
+ SlashCommand if found, None otherwise
571
+ """
572
+ # Remove leading / if present
573
+ if name.startswith('/'):
574
+ name = name[1:]
575
+
576
+ name = name.lower()
577
+
578
+ for cmd in SLASH_COMMANDS:
579
+ if cmd.name.lower() == name:
580
+ return cmd
581
+ if cmd.aliases and name in [a.lower() for a in cmd.aliases]:
582
+ return cmd
583
+
584
+ return None
585
+
586
+
587
+ def list_commands_by_category() -> Dict[str, List[SlashCommand]]:
588
+ """Get all commands grouped by category
589
+
590
+ Returns:
591
+ Dict mapping category names to lists of commands
592
+ """
593
+ by_category: Dict[str, List[SlashCommand]] = {}
594
+
595
+ for cmd in SLASH_COMMANDS:
596
+ if cmd.category not in by_category:
597
+ by_category[cmd.category] = []
598
+ by_category[cmd.category].append(cmd)
599
+
600
+ return by_category
601
+
602
+
603
+ def format_help_text() -> str:
604
+ """Format all commands as help text
605
+
606
+ Returns:
607
+ Formatted help string
608
+ """
609
+ lines = []
610
+ lines.append("\n\033[1mSlash Commands\033[0m")
611
+ lines.append("Type / to see available commands with autocomplete.\n")
612
+
613
+ category_titles = {
614
+ "general": "General",
615
+ "agent": "Agent Mode",
616
+ "files": "File Operations",
617
+ "search": "Search & Navigation",
618
+ "session": "Session Management",
619
+ "git": "Git",
620
+ "docker": "Docker",
621
+ "code": "Code Actions",
622
+ "mcp": "MCP",
623
+ "plugins": "Plugins",
624
+ "custom": "Custom Commands",
625
+ "github": "GitHub/PR",
626
+ "lint": "Linting",
627
+ "plan": "Plan Mode",
628
+ "image": "Image/Screenshot Input",
629
+ "quick": "Quick Actions",
630
+ "checkpoint": "Checkpoints (Undo/Redo)",
631
+ "models": "Model Registry",
632
+ "brain": "Brain (Cognitive System)",
633
+ }
634
+
635
+ by_category = list_commands_by_category()
636
+
637
+ for category, title in category_titles.items():
638
+ if category not in by_category:
639
+ continue
640
+
641
+ commands = by_category[category]
642
+ lines.append(f"\033[36m{title}:\033[0m")
643
+
644
+ for cmd in commands:
645
+ lines.append(f" \033[1m/{cmd.name:<16}\033[0m {cmd.description}")
646
+
647
+ lines.append("")
648
+
649
+ return "\n".join(lines)