scc-cli 1.5.3__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.

Potentially problematic release.


This version of scc-cli might be problematic. Click here for more details.

Files changed (153) hide show
  1. scc_cli/__init__.py +15 -0
  2. scc_cli/audit/__init__.py +37 -0
  3. scc_cli/audit/parser.py +191 -0
  4. scc_cli/audit/reader.py +180 -0
  5. scc_cli/auth.py +145 -0
  6. scc_cli/claude_adapter.py +485 -0
  7. scc_cli/cli.py +311 -0
  8. scc_cli/cli_common.py +190 -0
  9. scc_cli/cli_helpers.py +244 -0
  10. scc_cli/commands/__init__.py +20 -0
  11. scc_cli/commands/admin.py +708 -0
  12. scc_cli/commands/audit.py +246 -0
  13. scc_cli/commands/config.py +528 -0
  14. scc_cli/commands/exceptions.py +696 -0
  15. scc_cli/commands/init.py +272 -0
  16. scc_cli/commands/launch/__init__.py +73 -0
  17. scc_cli/commands/launch/app.py +1247 -0
  18. scc_cli/commands/launch/render.py +309 -0
  19. scc_cli/commands/launch/sandbox.py +135 -0
  20. scc_cli/commands/launch/workspace.py +339 -0
  21. scc_cli/commands/org/__init__.py +49 -0
  22. scc_cli/commands/org/_builders.py +264 -0
  23. scc_cli/commands/org/app.py +41 -0
  24. scc_cli/commands/org/import_cmd.py +267 -0
  25. scc_cli/commands/org/init_cmd.py +269 -0
  26. scc_cli/commands/org/schema_cmd.py +76 -0
  27. scc_cli/commands/org/status_cmd.py +157 -0
  28. scc_cli/commands/org/update_cmd.py +330 -0
  29. scc_cli/commands/org/validate_cmd.py +138 -0
  30. scc_cli/commands/support.py +323 -0
  31. scc_cli/commands/team.py +910 -0
  32. scc_cli/commands/worktree/__init__.py +72 -0
  33. scc_cli/commands/worktree/_helpers.py +57 -0
  34. scc_cli/commands/worktree/app.py +170 -0
  35. scc_cli/commands/worktree/container_commands.py +385 -0
  36. scc_cli/commands/worktree/context_commands.py +61 -0
  37. scc_cli/commands/worktree/session_commands.py +128 -0
  38. scc_cli/commands/worktree/worktree_commands.py +734 -0
  39. scc_cli/config.py +647 -0
  40. scc_cli/confirm.py +20 -0
  41. scc_cli/console.py +562 -0
  42. scc_cli/contexts.py +394 -0
  43. scc_cli/core/__init__.py +68 -0
  44. scc_cli/core/constants.py +101 -0
  45. scc_cli/core/errors.py +297 -0
  46. scc_cli/core/exit_codes.py +91 -0
  47. scc_cli/core/workspace.py +57 -0
  48. scc_cli/deprecation.py +54 -0
  49. scc_cli/deps.py +189 -0
  50. scc_cli/docker/__init__.py +127 -0
  51. scc_cli/docker/core.py +467 -0
  52. scc_cli/docker/credentials.py +726 -0
  53. scc_cli/docker/launch.py +595 -0
  54. scc_cli/doctor/__init__.py +105 -0
  55. scc_cli/doctor/checks/__init__.py +166 -0
  56. scc_cli/doctor/checks/cache.py +314 -0
  57. scc_cli/doctor/checks/config.py +107 -0
  58. scc_cli/doctor/checks/environment.py +182 -0
  59. scc_cli/doctor/checks/json_helpers.py +157 -0
  60. scc_cli/doctor/checks/organization.py +264 -0
  61. scc_cli/doctor/checks/worktree.py +278 -0
  62. scc_cli/doctor/render.py +365 -0
  63. scc_cli/doctor/types.py +66 -0
  64. scc_cli/evaluation/__init__.py +27 -0
  65. scc_cli/evaluation/apply_exceptions.py +207 -0
  66. scc_cli/evaluation/evaluate.py +97 -0
  67. scc_cli/evaluation/models.py +80 -0
  68. scc_cli/git.py +84 -0
  69. scc_cli/json_command.py +166 -0
  70. scc_cli/json_output.py +159 -0
  71. scc_cli/kinds.py +65 -0
  72. scc_cli/marketplace/__init__.py +123 -0
  73. scc_cli/marketplace/adapter.py +74 -0
  74. scc_cli/marketplace/compute.py +377 -0
  75. scc_cli/marketplace/constants.py +87 -0
  76. scc_cli/marketplace/managed.py +135 -0
  77. scc_cli/marketplace/materialize.py +846 -0
  78. scc_cli/marketplace/normalize.py +548 -0
  79. scc_cli/marketplace/render.py +281 -0
  80. scc_cli/marketplace/resolve.py +459 -0
  81. scc_cli/marketplace/schema.py +506 -0
  82. scc_cli/marketplace/sync.py +279 -0
  83. scc_cli/marketplace/team_cache.py +195 -0
  84. scc_cli/marketplace/team_fetch.py +689 -0
  85. scc_cli/marketplace/trust.py +244 -0
  86. scc_cli/models/__init__.py +41 -0
  87. scc_cli/models/exceptions.py +273 -0
  88. scc_cli/models/plugin_audit.py +434 -0
  89. scc_cli/org_templates.py +269 -0
  90. scc_cli/output_mode.py +167 -0
  91. scc_cli/panels.py +113 -0
  92. scc_cli/platform.py +350 -0
  93. scc_cli/profiles.py +960 -0
  94. scc_cli/remote.py +443 -0
  95. scc_cli/schemas/__init__.py +1 -0
  96. scc_cli/schemas/org-v1.schema.json +456 -0
  97. scc_cli/schemas/team-config.v1.schema.json +163 -0
  98. scc_cli/services/__init__.py +1 -0
  99. scc_cli/services/git/__init__.py +79 -0
  100. scc_cli/services/git/branch.py +151 -0
  101. scc_cli/services/git/core.py +216 -0
  102. scc_cli/services/git/hooks.py +108 -0
  103. scc_cli/services/git/worktree.py +444 -0
  104. scc_cli/services/workspace/__init__.py +36 -0
  105. scc_cli/services/workspace/resolver.py +223 -0
  106. scc_cli/services/workspace/suspicious.py +200 -0
  107. scc_cli/sessions.py +425 -0
  108. scc_cli/setup.py +589 -0
  109. scc_cli/source_resolver.py +470 -0
  110. scc_cli/stats.py +378 -0
  111. scc_cli/stores/__init__.py +13 -0
  112. scc_cli/stores/exception_store.py +251 -0
  113. scc_cli/subprocess_utils.py +88 -0
  114. scc_cli/teams.py +383 -0
  115. scc_cli/templates/__init__.py +2 -0
  116. scc_cli/templates/org/__init__.py +0 -0
  117. scc_cli/templates/org/minimal.json +19 -0
  118. scc_cli/templates/org/reference.json +74 -0
  119. scc_cli/templates/org/strict.json +38 -0
  120. scc_cli/templates/org/teams.json +42 -0
  121. scc_cli/templates/statusline.sh +75 -0
  122. scc_cli/theme.py +348 -0
  123. scc_cli/ui/__init__.py +154 -0
  124. scc_cli/ui/branding.py +68 -0
  125. scc_cli/ui/chrome.py +401 -0
  126. scc_cli/ui/dashboard/__init__.py +62 -0
  127. scc_cli/ui/dashboard/_dashboard.py +794 -0
  128. scc_cli/ui/dashboard/loaders.py +452 -0
  129. scc_cli/ui/dashboard/models.py +185 -0
  130. scc_cli/ui/dashboard/orchestrator.py +735 -0
  131. scc_cli/ui/formatters.py +444 -0
  132. scc_cli/ui/gate.py +350 -0
  133. scc_cli/ui/git_interactive.py +869 -0
  134. scc_cli/ui/git_render.py +176 -0
  135. scc_cli/ui/help.py +157 -0
  136. scc_cli/ui/keys.py +615 -0
  137. scc_cli/ui/list_screen.py +437 -0
  138. scc_cli/ui/picker.py +763 -0
  139. scc_cli/ui/prompts.py +201 -0
  140. scc_cli/ui/quick_resume.py +116 -0
  141. scc_cli/ui/wizard.py +576 -0
  142. scc_cli/update.py +680 -0
  143. scc_cli/utils/__init__.py +39 -0
  144. scc_cli/utils/fixit.py +264 -0
  145. scc_cli/utils/fuzzy.py +124 -0
  146. scc_cli/utils/locks.py +114 -0
  147. scc_cli/utils/ttl.py +376 -0
  148. scc_cli/validate.py +455 -0
  149. scc_cli-1.5.3.dist-info/METADATA +401 -0
  150. scc_cli-1.5.3.dist-info/RECORD +153 -0
  151. scc_cli-1.5.3.dist-info/WHEEL +4 -0
  152. scc_cli-1.5.3.dist-info/entry_points.txt +2 -0
  153. scc_cli-1.5.3.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,272 @@
1
+ """
2
+ Define the SCC init command for project configuration initialization.
3
+
4
+ Create a .scc.yaml configuration file in a project directory with
5
+ sensible defaults and helpful comments.
6
+ """
7
+
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ import typer
12
+ from rich.panel import Panel
13
+
14
+ from ..cli_common import console, handle_errors
15
+ from ..cli_helpers import confirm_action, is_interactive
16
+ from ..core.exit_codes import EXIT_CONFIG, EXIT_SUCCESS, EXIT_USAGE
17
+ from ..json_output import build_envelope
18
+ from ..kinds import Kind
19
+ from ..output_mode import print_json, set_pretty_mode
20
+
21
+ # ─────────────────────────────────────────────────────────────────────────────
22
+ # Pure Functions (No I/O)
23
+ # ─────────────────────────────────────────────────────────────────────────────
24
+
25
+
26
+ def is_git_repo(path: Path) -> bool:
27
+ """Check if path is a git repository.
28
+
29
+ Args:
30
+ path: Directory path to check.
31
+
32
+ Returns:
33
+ True if .git directory exists, False otherwise.
34
+ """
35
+ git_dir = path / ".git"
36
+ return git_dir.exists() and git_dir.is_dir()
37
+
38
+
39
+ def build_init_data(
40
+ file_path: str,
41
+ created: bool,
42
+ overwritten: bool,
43
+ is_git_repo: bool,
44
+ ) -> dict[str, Any]:
45
+ """Build init result data for JSON output.
46
+
47
+ Args:
48
+ file_path: Path to created .scc.yaml file.
49
+ created: Whether the file was created.
50
+ overwritten: Whether an existing file was overwritten.
51
+ is_git_repo: Whether the target is a git repository.
52
+
53
+ Returns:
54
+ Dictionary with init result data.
55
+ """
56
+ return {
57
+ "file_path": file_path,
58
+ "created": created,
59
+ "overwritten": overwritten,
60
+ "is_git_repo": is_git_repo,
61
+ }
62
+
63
+
64
+ def generate_template_content() -> str:
65
+ """Generate .scc.yaml template content with helpful comments.
66
+
67
+ Returns:
68
+ YAML template string with comments.
69
+ """
70
+ return """\
71
+ # SCC Project Configuration
72
+ # ─────────────────────────────────────────────────────────────────────────────
73
+ # This file configures SCC (Sandboxed Claude CLI) for this project.
74
+ # Place this file in your repository root.
75
+ #
76
+ # For full documentation, see: https://github.com/sundsvall/scc-cli#configuration
77
+ # ─────────────────────────────────────────────────────────────────────────────
78
+
79
+ # Additional plugins to enable for this project
80
+ # These plugins are loaded on top of your team profile's plugins.
81
+ # Only plugins allowed by your organization can be added here.
82
+ additional_plugins: []
83
+ # - "project-specific-linter"
84
+ # - "custom-formatter"
85
+
86
+ # Session configuration
87
+ session:
88
+ # Session timeout in hours (default: 8)
89
+ timeout_hours: 8
90
+
91
+ # Optional: MCP servers specific to this project
92
+ # mcp_servers: []
93
+ # - name: "project-db"
94
+ # command: "npx"
95
+ # args: ["@project/mcp-server"]
96
+
97
+ # Optional: Environment variables for the sandbox
98
+ # env: {}
99
+ # PROJECT_NAME: "my-project"
100
+ """
101
+
102
+
103
+ # ─────────────────────────────────────────────────────────────────────────────
104
+ # CLI Command
105
+ # ─────────────────────────────────────────────────────────────────────────────
106
+
107
+
108
+ @handle_errors
109
+ def init_cmd(
110
+ path: str | None = typer.Argument(
111
+ None,
112
+ help="Target directory (default: current directory).",
113
+ ),
114
+ force: bool = typer.Option(
115
+ False,
116
+ "--force",
117
+ "-f",
118
+ help="Overwrite existing .scc.yaml file without prompting.",
119
+ ),
120
+ yes: bool = typer.Option(
121
+ False,
122
+ "-y",
123
+ "--yes",
124
+ help="Skip confirmation prompts (still requires --force to overwrite).",
125
+ ),
126
+ json_output: bool = typer.Option(
127
+ False,
128
+ "--json",
129
+ help="Output as JSON.",
130
+ ),
131
+ pretty: bool = typer.Option(
132
+ False,
133
+ "--pretty",
134
+ help="Pretty-print JSON (implies --json).",
135
+ ),
136
+ ) -> None:
137
+ """Initialize SCC project configuration.
138
+
139
+ Creates a .scc.yaml file in the target directory with sensible defaults
140
+ and helpful comments explaining each configuration option.
141
+
142
+ Three-tier overwrite logic:
143
+ - If file doesn't exist: create it
144
+ - If file exists + --force: overwrite without prompting
145
+ - If file exists + no --force: prompt in interactive mode, or hint to use --force
146
+ """
147
+ # --pretty implies --json
148
+ if pretty:
149
+ json_output = True
150
+ set_pretty_mode(True)
151
+
152
+ # Resolve target path
153
+ if path is None:
154
+ target_dir = Path.cwd()
155
+ else:
156
+ target_dir = Path(path).resolve()
157
+
158
+ # Validate target directory
159
+ if not target_dir.exists():
160
+ if json_output:
161
+ envelope = build_envelope(
162
+ Kind.INIT_RESULT,
163
+ ok=False,
164
+ errors=[f"Directory does not exist: {target_dir}"],
165
+ )
166
+ print_json(envelope)
167
+ raise typer.Exit(EXIT_CONFIG)
168
+ else:
169
+ console.print(f"[red]Error:[/red] Directory does not exist: {target_dir}")
170
+ raise typer.Exit(EXIT_CONFIG)
171
+
172
+ if not target_dir.is_dir():
173
+ if json_output:
174
+ envelope = build_envelope(
175
+ Kind.INIT_RESULT,
176
+ ok=False,
177
+ errors=[f"Path is not a directory: {target_dir}"],
178
+ )
179
+ print_json(envelope)
180
+ raise typer.Exit(EXIT_CONFIG)
181
+ else:
182
+ console.print(f"[red]Error:[/red] Path is not a directory: {target_dir}")
183
+ raise typer.Exit(EXIT_CONFIG)
184
+
185
+ # Check for existing file - three-tier overwrite logic
186
+ scc_yaml = target_dir / ".scc.yaml"
187
+ overwritten = False
188
+
189
+ if scc_yaml.exists():
190
+ if force:
191
+ # Tier 3: --force → overwrite without prompting
192
+ overwritten = True
193
+ elif json_output:
194
+ # JSON mode: never prompt, just tell user to use --force
195
+ envelope = build_envelope(
196
+ Kind.INIT_RESULT,
197
+ ok=False,
198
+ errors=[f"File already exists: {scc_yaml}. Use --force to overwrite."],
199
+ )
200
+ print_json(envelope)
201
+ raise typer.Exit(EXIT_CONFIG)
202
+ elif yes:
203
+ # Tier 4: --yes without --force → hint that --force is required
204
+ console.print(
205
+ f"[yellow]Warning:[/yellow] File already exists: [cyan]{scc_yaml}[/cyan]\n"
206
+ "[dim]--yes skips prompts but does not allow overwriting.[/dim]\n"
207
+ "Use [yellow]--force[/yellow] to overwrite existing file."
208
+ )
209
+ raise typer.Exit(EXIT_USAGE)
210
+ elif is_interactive():
211
+ # Tier 2: Interactive without --force → prompt for confirmation
212
+ console.print(f"[yellow]Warning:[/yellow] File already exists: [cyan]{scc_yaml}[/cyan]")
213
+ try:
214
+ confirm_action(
215
+ yes=False,
216
+ prompt="Overwrite existing .scc.yaml?",
217
+ non_interactive_requires_yes=False,
218
+ )
219
+ overwritten = True
220
+ except typer.Abort:
221
+ console.print("[dim]Aborted.[/dim]")
222
+ raise typer.Exit(EXIT_SUCCESS)
223
+ else:
224
+ # Tier 3: Non-interactive without --force → exit with usage error
225
+ console.print(
226
+ f"[red]Error:[/red] File already exists: [cyan]{scc_yaml}[/cyan]\n"
227
+ "Use [yellow]--force[/yellow] to overwrite in non-interactive mode."
228
+ )
229
+ raise typer.Exit(EXIT_USAGE)
230
+
231
+ # Check if git repo and warn if not
232
+ is_git = is_git_repo(target_dir)
233
+ if not is_git and not json_output:
234
+ console.print(
235
+ "[yellow]Warning:[/yellow] Target directory is not a git repository.\n"
236
+ "SCC works best with git-tracked projects for branch safety and worktree features."
237
+ )
238
+
239
+ # Generate and write template
240
+ template_content = generate_template_content()
241
+ scc_yaml.write_text(template_content)
242
+
243
+ # Build result data
244
+ result_data = build_init_data(
245
+ file_path=str(scc_yaml),
246
+ created=True,
247
+ overwritten=overwritten,
248
+ is_git_repo=is_git,
249
+ )
250
+
251
+ # Output
252
+ if json_output:
253
+ envelope = build_envelope(Kind.INIT_RESULT, data=result_data)
254
+ print_json(envelope)
255
+ raise typer.Exit(EXIT_SUCCESS)
256
+ else:
257
+ action = "Overwrote" if overwritten else "Created"
258
+ console.print(
259
+ Panel(
260
+ f"{action} [cyan]{scc_yaml}[/cyan]\n\n"
261
+ "Edit this file to configure project-specific settings.\n"
262
+ "See the comments in the file for available options.",
263
+ title="[green]SCC Initialized[/green]",
264
+ border_style="green",
265
+ )
266
+ )
267
+ if not is_git:
268
+ console.print(
269
+ "\n[dim]Tip: Initialize a git repository with [cyan]git init[/cyan] "
270
+ "to enable branch safety and worktree features.[/dim]"
271
+ )
272
+ raise typer.Exit(EXIT_SUCCESS)
@@ -0,0 +1,73 @@
1
+ """
2
+ Launch package - commands for starting Claude Code in Docker sandboxes.
3
+
4
+ This package contains the decomposed launch functionality:
5
+ - render.py: Pure output/display functions (no business logic)
6
+ - app.py: Main command logic and orchestration
7
+ - (more modules to be added as extraction continues)
8
+
9
+ Public API re-exports for backward compatibility.
10
+ """
11
+
12
+ from .app import (
13
+ _configure_team_settings,
14
+ _sync_marketplace_settings,
15
+ interactive_start,
16
+ launch_app,
17
+ run_start_wizard_flow,
18
+ start,
19
+ )
20
+ from .render import (
21
+ build_dry_run_data,
22
+ show_dry_run_panel,
23
+ show_launch_panel,
24
+ warn_if_non_worktree,
25
+ )
26
+ from .sandbox import extract_container_name, launch_sandbox
27
+ from .workspace import (
28
+ prepare_workspace,
29
+ resolve_mount_and_branch,
30
+ resolve_workspace_team,
31
+ validate_and_resolve_workspace,
32
+ )
33
+
34
+ # Backward compatibility aliases for orchestrator imports
35
+ _validate_and_resolve_workspace = validate_and_resolve_workspace
36
+ _prepare_workspace = prepare_workspace
37
+ _resolve_workspace_team = resolve_workspace_team
38
+ _resolve_mount_and_branch = resolve_mount_and_branch
39
+ _launch_sandbox = launch_sandbox
40
+ _extract_container_name = extract_container_name
41
+ _warn_if_non_worktree = warn_if_non_worktree
42
+
43
+ __all__ = [
44
+ # Main entry points
45
+ "start",
46
+ "launch_app",
47
+ "interactive_start",
48
+ "run_start_wizard_flow",
49
+ # Private helpers (exposed for orchestrator)
50
+ "_configure_team_settings",
51
+ "_sync_marketplace_settings",
52
+ # Sandbox functions
53
+ "launch_sandbox",
54
+ "extract_container_name",
55
+ "_launch_sandbox",
56
+ "_extract_container_name",
57
+ # Workspace functions (new public API)
58
+ "validate_and_resolve_workspace",
59
+ "prepare_workspace",
60
+ "resolve_workspace_team",
61
+ "resolve_mount_and_branch",
62
+ # Backward compatibility aliases
63
+ "_validate_and_resolve_workspace",
64
+ "_prepare_workspace",
65
+ "_resolve_workspace_team",
66
+ "_resolve_mount_and_branch",
67
+ # Render functions
68
+ "build_dry_run_data",
69
+ "show_dry_run_panel",
70
+ "show_launch_panel",
71
+ "warn_if_non_worktree",
72
+ "_warn_if_non_worktree",
73
+ ]