applied-cli 0.2.3__tar.gz → 0.2.5__tar.gz

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 (40) hide show
  1. {applied_cli-0.2.3 → applied_cli-0.2.5}/PKG-INFO +1 -1
  2. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/auth.py +18 -1
  3. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/mcp_server.py +26 -25
  4. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/PKG-INFO +1 -1
  5. {applied_cli-0.2.3 → applied_cli-0.2.5}/pyproject.toml +1 -1
  6. {applied_cli-0.2.3 → applied_cli-0.2.5}/README.md +0 -0
  7. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/__init__.py +0 -0
  8. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/auth_store.py +0 -0
  9. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/__init__.py +0 -0
  10. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/_hints.py +0 -0
  11. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/_normalize.py +0 -0
  12. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/_parsers.py +0 -0
  13. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/_ui.py +0 -0
  14. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/agent.py +0 -0
  15. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/chat.py +0 -0
  16. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/coverage.py +0 -0
  17. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/discover.py +0 -0
  18. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/fix.py +0 -0
  19. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/insights.py +0 -0
  20. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/intents.py +0 -0
  21. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/rate.py +0 -0
  22. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/responses.py +0 -0
  23. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/shop.py +0 -0
  24. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/simulate.py +0 -0
  25. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/commands/spec.py +0 -0
  26. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/config.py +0 -0
  27. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/error_reporting.py +0 -0
  28. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/http.py +0 -0
  29. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/main.py +0 -0
  30. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/presets/demo.yaml +0 -0
  31. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/runtime.py +0 -0
  32. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/shop_spec.py +0 -0
  33. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli/spec_workflow.py +0 -0
  34. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/SOURCES.txt +0 -0
  35. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/dependency_links.txt +0 -0
  36. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/entry_points.txt +0 -0
  37. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/requires.txt +0 -0
  38. {applied_cli-0.2.3 → applied_cli-0.2.5}/applied_cli.egg-info/top_level.txt +0 -0
  39. {applied_cli-0.2.3 → applied_cli-0.2.5}/setup.cfg +0 -0
  40. {applied_cli-0.2.3 → applied_cli-0.2.5}/tests/test_parsers_and_insights.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: applied-cli
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: CLI and MCP server for Applied Labs AI support agents
5
5
  Author: Applied Labs
6
6
  License-Expression: MIT
@@ -465,6 +465,7 @@ def status(
465
465
  json.dumps(
466
466
  {
467
467
  "logged_in": True,
468
+ "authenticated": True,
468
469
  "endpoint": creds.base_url,
469
470
  "shop_id": creds.shop_id,
470
471
  "token_masked": mask_token(creds.api_token),
@@ -485,7 +486,22 @@ def status(
485
486
  timeout_seconds=timeout,
486
487
  )
487
488
  except APIError as exc:
488
- typer.echo(render_api_error(exc, action="check auth status"), err=True)
489
+ if output_json:
490
+ typer.echo(
491
+ json.dumps(
492
+ {
493
+ "logged_in": False,
494
+ "authenticated": False,
495
+ "verified": False,
496
+ "error": "token_invalid",
497
+ "message": str(exc.detail) if exc.detail else str(exc),
498
+ "hint": "Token was rejected by the server. Re-authenticate using the auth login flow.",
499
+ },
500
+ indent=2,
501
+ )
502
+ )
503
+ else:
504
+ typer.echo(render_api_error(exc, action="check auth status"), err=True)
489
505
  raise typer.Exit(code=1) from exc
490
506
 
491
507
  if output_json:
@@ -493,6 +509,7 @@ def status(
493
509
  json.dumps(
494
510
  {
495
511
  "logged_in": True,
512
+ "authenticated": True,
496
513
  "endpoint": creds.base_url,
497
514
  "shop_id": creds.shop_id,
498
515
  "token_masked": mask_token(creds.api_token),
@@ -13,12 +13,13 @@ Usage:
13
13
 
14
14
  import json
15
15
  import os
16
- import subprocess
17
- import sys
18
16
  import tempfile
19
17
  from typing import Any
20
18
 
21
19
  from mcp.server.fastmcp import FastMCP
20
+ from typer.testing import CliRunner as _CliRunner
21
+
22
+ from applied_cli.main import app as _cli_app
22
23
 
23
24
  # Initialize FastMCP server
24
25
  mcp = FastMCP(
@@ -85,41 +86,41 @@ All tools return JSON.
85
86
  )
86
87
 
87
88
 
88
- def _run_cli(args: list[str], timeout: int = 120) -> dict[str, Any]:
89
- """Run an applied-cli command and return structured output."""
90
- cmd = ["python", "-m", "applied_cli.main"] + args
91
-
92
- try:
93
- result = subprocess.run(
94
- cmd,
95
- capture_output=True,
96
- text=True,
97
- timeout=timeout,
98
- )
89
+ _runner = _CliRunner(mix_stderr=False)
99
90
 
100
- output = result.stdout.strip()
101
- error = result.stderr.strip()
102
91
 
103
- # Try to parse as JSON
92
+ def _run_cli(args: list[str], timeout: int = 120) -> dict[str, Any]:
93
+ """Run an applied-cli command in-process (no subprocess) and return structured output."""
94
+ try:
95
+ result = _runner.invoke(_cli_app, args, catch_exceptions=True)
96
+ output = (result.output or "").strip()
97
+ exit_code = result.exit_code
98
+
99
+ # Derive an error message when the command failed.
100
+ # Prefer exceptions that aren't plain SystemExit (which carries no message).
101
+ error: str | None = None
102
+ if exit_code != 0:
103
+ exc = result.exception
104
+ if exc is not None and not isinstance(exc, SystemExit):
105
+ error = str(exc)
106
+ else:
107
+ error = f"Command failed (exit {exit_code})"
108
+
109
+ # Try to parse stdout as JSON (all --json commands write only JSON to stdout).
104
110
  try:
105
111
  parsed = json.loads(output)
106
112
  return {
107
- "success": result.returncode == 0,
113
+ "success": exit_code == 0,
108
114
  "data": parsed,
109
- "error": error if result.returncode != 0 else None,
115
+ "error": error,
110
116
  }
111
117
  except json.JSONDecodeError:
112
118
  return {
113
- "success": result.returncode == 0,
119
+ "success": exit_code == 0,
114
120
  "output": output,
115
- "error": error if result.returncode != 0 else None,
121
+ "error": error,
116
122
  }
117
123
 
118
- except subprocess.TimeoutExpired:
119
- return {
120
- "success": False,
121
- "error": f"Command timed out after {timeout} seconds",
122
- }
123
124
  except Exception as e:
124
125
  return {
125
126
  "success": False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: applied-cli
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: CLI and MCP server for Applied Labs AI support agents
5
5
  Author: Applied Labs
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "applied-cli"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "CLI and MCP server for Applied Labs AI support agents"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
File without changes
File without changes