devstuff 2.14.0__py3-none-any.whl → 2.15.0__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.
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
3
4
  import subprocess
4
5
  from collections.abc import Callable
5
6
  from typing import Any
@@ -58,6 +59,69 @@ def tool_info(ws: Workspace, config: AgentConfig, args: dict[str, Any]) -> str:
58
59
  return "\n".join(lines)
59
60
 
60
61
 
62
+ def _string_list(args: dict[str, Any], name: str) -> list[str]:
63
+ """A list-of-strings argument. `bind()` checks names, not types, so this is the type check."""
64
+ value = args.get(name, [])
65
+ if not isinstance(value, list) or not all(isinstance(v, str) for v in value):
66
+ # A bare string must be refused, not iterated: "eslint" would read as six one-letter keys.
67
+ raise SandboxError(f"'{name}' must be a list of strings, e.g. [\"uv\", \"nvm\"]")
68
+ return value
69
+
70
+
71
+ def outdated(ws: Workspace, config: AgentConfig, args: dict[str, Any]) -> str:
72
+ """`devstuff outdated --json`: the same rows, built by the same function (spec FR-9).
73
+
74
+ `unknown` and `unsupported` rows are returned as such and never as `current` -- that honesty
75
+ is the point of the command, and it is decided in `updates.classify`, not here.
76
+ """
77
+ from dev_setup.updates import State, build_rows
78
+
79
+ updates_only = args.get("updates_only", False)
80
+ if not isinstance(updates_only, bool):
81
+ raise SandboxError("'updates_only' must be true or false")
82
+
83
+ keys = _string_list(args, "packages")
84
+ tool_registry.init()
85
+ named = None
86
+ if keys:
87
+ named = []
88
+ for key in keys:
89
+ tool = tool_registry.get(key)
90
+ if tool is None:
91
+ raise SandboxError(f"unknown catalog tool '{key}'; try search_catalog first")
92
+ named.append(tool)
93
+
94
+ rows = build_rows(named)
95
+ if updates_only:
96
+ rows = [r for r in rows if r.state is State.OUTDATED]
97
+ return json.dumps([r.to_json() for r in rows], indent=2)
98
+
99
+
100
+ def profile_diff(ws: Workspace, config: AgentConfig, args: dict[str, Any]) -> str:
101
+ """`devstuff profile diff @name --json`, for a bundle that ships with devstuff (spec FR-10).
102
+
103
+ Only a bundle name is accepted. A path would let a caller read any YAML file the user can read,
104
+ and `bundles.resolve` matches the name against a directory listing rather than building a path
105
+ from it, so there is nothing to traverse.
106
+ """
107
+ from dev_setup import bundles, profile, snapshot
108
+
109
+ name = args["profile"]
110
+ if not isinstance(name, str) or not bundles.is_bundle(name):
111
+ raise SandboxError(
112
+ f"'profile' must be a bundle name such as @devops, not a file path. "
113
+ f"Bundles: {', '.join(f'@{n}' for n in bundles.names())}"
114
+ )
115
+ try:
116
+ wanted = bundles.resolve(name)
117
+ except profile.ProfileError as exc:
118
+ raise SandboxError(str(exc)) from exc
119
+
120
+ tool_registry.init()
121
+ rows = profile.sort_diff_rows(profile.compare(wanted, snapshot.machine_facts(wanted)))
122
+ return json.dumps([r.to_json() for r in rows], indent=2)
123
+
124
+
61
125
  def install_tool(ws: Workspace, config: AgentConfig, args: dict[str, Any]) -> str:
62
126
  tool_registry.init()
63
127
  tool = tool_registry.get(args["key"])
@@ -117,6 +181,8 @@ _BRIDGES: dict[str, Bridge] = {
117
181
  "list_tools": list_tools,
118
182
  "search_catalog": search_catalog,
119
183
  "tool_info": tool_info,
184
+ "outdated": outdated,
185
+ "profile_diff": profile_diff,
120
186
  "install_tool": install_tool,
121
187
  }
122
188
 
@@ -17,7 +17,7 @@ VERSION = 1
17
17
  VALID_KEY = re.compile(r"^[a-z][a-z0-9_]*$")
18
18
 
19
19
  IMPLS = {"primitive", "catalog", "function"}
20
- PARAM_TYPES = {"string", "integer", "number", "boolean"}
20
+ PARAM_TYPES = {"string", "integer", "number", "boolean", "array"}
21
21
 
22
22
  SUPPORTED_TOP_FIELDS = {"version", "expose_functions", "exclude_functions", "tools"}
23
23
  SUPPORTED_FIELDS = {"name", "description", "impl", "target", "mutating", "params"}
@@ -17,6 +17,10 @@ class AgentParam:
17
17
 
18
18
  def to_schema(self) -> dict[str, Any]:
19
19
  schema: dict[str, Any] = {"type": self.type}
20
+ if self.type == "array":
21
+ # JSON Schema wants `items`, and a bare array tells a model nothing about what goes
22
+ # in it. Every array parameter is a list of strings: none needs another element type.
23
+ schema["items"] = {"type": "string"}
20
24
  if self.description:
21
25
  schema["description"] = self.description
22
26
  if self.enum:
@@ -86,7 +86,7 @@
86
86
  "description": "Parameter name. Passed to the implementation as a dict key."
87
87
  },
88
88
  "type": {
89
- "enum": ["string", "integer", "number", "boolean"],
89
+ "enum": ["string", "integer", "number", "boolean", "array"],
90
90
  "default": "string",
91
91
  "description": "JSON Schema type advertised to the model."
92
92
  },
@@ -129,6 +129,43 @@ tools:
129
129
  description: Catalog key, e.g. "uv" or "nvm".
130
130
  required: true
131
131
 
132
+ outdated:
133
+ name: Devstuff Outdated
134
+ description: >-
135
+ Report which installed devstuff tools have a newer version available. Returns a
136
+ JSON array with one row per tool: state is "outdated", "current", "unknown" (a
137
+ check exists but could not answer, e.g. offline), "unsupported" (this install
138
+ type has no way to check) or "not-installed". Only "current" means up to date --
139
+ never read "unknown" or "unsupported" as current. Changes nothing.
140
+ impl: catalog
141
+ target: outdated
142
+ mutating: false
143
+ params:
144
+ - name: packages
145
+ type: array
146
+ description: Catalog keys to check, e.g. ["uv", "nvm"]. Omit to check every installed tool.
147
+ required: false
148
+ - name: updates_only
149
+ type: boolean
150
+ description: Return only the tools that have an update available.
151
+ required: false
152
+ default: false
153
+
154
+ profile_diff:
155
+ name: Devstuff Profile Diff
156
+ description: >-
157
+ Compare this machine to a profile that ships with devstuff and return a JSON array,
158
+ one row per tool: "ok", "missing", "drift", "unverifiable", "unpinnable",
159
+ "unknown-key" or "extra". Only "ok" means it matches. Changes nothing.
160
+ impl: catalog
161
+ target: profile_diff
162
+ mutating: false
163
+ params:
164
+ - name: profile
165
+ type: string
166
+ description: Name of a bundled profile, with the leading @, e.g. "@devops" or "@python".
167
+ required: true
168
+
132
169
  install_tool:
133
170
  name: Install Devstuff Tool
134
171
  description: >-
@@ -9,7 +9,7 @@ from rich.markup import escape
9
9
 
10
10
  from dev_setup import registry, ui, verbose
11
11
  from dev_setup.base import Tool
12
- from dev_setup.updates import Row, State, collect_candidates, make_row, sort_rows, summarize
12
+ from dev_setup.updates import Row, State, build_rows, summarize
13
13
 
14
14
  # One glyph + wording per state. `unknown` and `unsupported` deliberately share nothing
15
15
  # with `current`: "could not check" must never read as "up to date" (spec FR-7).
@@ -71,14 +71,8 @@ def outdated_cmd(packages: tuple[str, ...], updates_only: bool, show_all: bool,
71
71
  verbose.step("Checking installed packages for updates...") if interactive else nullcontext()
72
72
  )
73
73
  with progress:
74
- candidates = collect_candidates(named)
74
+ result = build_rows(named)
75
75
 
76
- result = [make_row(tool, status) for tool, status in candidates]
77
- if named is not None:
78
- found = {tool.key for tool, _ in candidates}
79
- result += [make_row(t, None, installed=False) for t in named if t.key not in found]
80
-
81
- result = sort_rows(result)
82
76
  shown = [r for r in result if r.state is State.OUTDATED] if updates_only else result
83
77
 
84
78
  if as_json:
@@ -0,0 +1 @@
1
+ """`devstuff mcp` — devstuff's tools as an MCP / HTTP tool server (docs/specs/mcp)."""
dev_setup/mcp/core.py ADDED
@@ -0,0 +1,66 @@
1
+ """What the MCP server runs and what it will let a client reach (docs/specs/mcp).
2
+
3
+ Pure: no I/O, no sockets, no processes. Everything here is decided from data, so the whole table
4
+ is tested without a server — the reason `profile.py` and `apply_plan.py` are built the same way.
5
+
6
+ M-1 holds only the classification (FR-1a). Dispatch, the probe lifecycle and the JSON-RPC
7
+ handling arrive in M-2 and read the same classified toolbox, so listing and calling cannot
8
+ disagree about what exists (FR-3).
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from enum import StrEnum
14
+
15
+ from dev_setup.agent.registry import AgentTool
16
+
17
+
18
+ class Gate(StrEnum):
19
+ READ_ONLY = "read-only" # always exposed
20
+ INSTALL = "install" # only with --allow-install
21
+ FUNCTION = "function" # only with --allow-functions
22
+ UNCLASSIFIED = "unclassified" # never: an unknown catalog bridge fails closed
23
+ PRIMITIVE = "primitive" # never: workspace tools do not exist on this surface (FR-1)
24
+
25
+
26
+ # One row per bridge in `agent.bridges._BRIDGES`, keyed by *target* — what the entry runs.
27
+ # `test_every_bridge_has_a_gate` fails when a bridge is added without a row, so a new bridge
28
+ # cannot ship without someone deciding which flag, if any, guards it.
29
+ CATALOG_GATES: dict[str, Gate] = {
30
+ "list_tools": Gate.READ_ONLY,
31
+ "search_catalog": Gate.READ_ONLY,
32
+ "tool_info": Gate.READ_ONLY,
33
+ "outdated": Gate.READ_ONLY,
34
+ "profile_diff": Gate.READ_ONLY,
35
+ "install_tool": Gate.INSTALL,
36
+ }
37
+
38
+
39
+ def classify(tool: AgentTool) -> Gate:
40
+ """The gate for one agent-toolbox entry, from `(impl, target)` and nothing else.
41
+
42
+ Never from the key and never from `tool.mutating` alone: both are chosen by the user's
43
+ `agent_tools.yaml`, which can rename `install_tool`, alias it, or label it harmless (F-10a).
44
+ `mutating: true` can only move a read-only entry *into* a gate, never out of one.
45
+ """
46
+ if tool.impl == "primitive":
47
+ return Gate.PRIMITIVE
48
+ if tool.impl == "function":
49
+ return Gate.FUNCTION
50
+ if tool.impl == "catalog":
51
+ gate = CATALOG_GATES.get(tool.target or "", Gate.UNCLASSIFIED)
52
+ if gate is Gate.READ_ONLY and tool.mutating:
53
+ return Gate.FUNCTION
54
+ return gate
55
+ return Gate.UNCLASSIFIED
56
+
57
+
58
+ def is_exposed(gate: Gate, *, allow_install: bool, allow_functions: bool) -> bool:
59
+ """Whether a tool of this class exists for a server started with these flags (FR-3)."""
60
+ if gate is Gate.READ_ONLY:
61
+ return True
62
+ if gate is Gate.INSTALL:
63
+ return allow_install
64
+ if gate is Gate.FUNCTION:
65
+ return allow_functions
66
+ return False
dev_setup/updates.py CHANGED
@@ -140,6 +140,21 @@ def sort_rows(rows: Iterable[Row]) -> list[Row]:
140
140
  return sorted(rows, key=lambda r: (_ORDER[r.state], r.key))
141
141
 
142
142
 
143
+ def build_rows(named: Sequence[Tool] | None = None) -> list[Row]:
144
+ """Every row `outdated` reports, in display order — the one place that decides what they are.
145
+
146
+ `named` limits the check to those tools; one that is not installed gets a `not-installed` row
147
+ rather than vanishing, because the caller asked about it by name. Shared by the command and
148
+ the `outdated` agent/MCP bridge so the two cannot disagree about an answer.
149
+ """
150
+ candidates = collect_candidates(named)
151
+ rows = [make_row(tool, status) for tool, status in candidates]
152
+ if named is not None:
153
+ found = {tool.key for tool, _ in candidates}
154
+ rows += [make_row(t, None, installed=False) for t in named if t.key not in found]
155
+ return sort_rows(rows)
156
+
157
+
143
158
  def summarize(rows: Iterable[Row]) -> dict[State, int]:
144
159
  """Count rows per state. Every state is present, so the counts always sum to the rows."""
145
160
  counts = dict.fromkeys(State, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: devstuff
3
- Version: 2.14.0
3
+ Version: 2.15.0
4
4
  Summary: Development environment setup CLI for Linux
5
5
  Project-URL: Repository, https://github.com/thesawdawg/dev-setup-py
6
6
  Author-email: Sawyer <sawyerksu@gmail.com>
@@ -1260,6 +1260,8 @@ deny_patterns: [] # extra regexes refused on top of the built-in
1260
1260
  | `list_tools` | | List the devstuff catalog with install state |
1261
1261
  | `search_catalog` | | Find a catalog tool by name or description |
1262
1262
  | `tool_info` | | Details for one catalog tool |
1263
+ | `outdated` | | Which installed tools have a newer version (the rows `devstuff outdated --json` prints) |
1264
+ | `profile_diff` | | Compare this machine to a bundled profile such as `@devops` (the rows `profile diff --json` prints) |
1263
1265
  | `install_tool` | ! | Install a catalog tool (handles sudo itself) |
1264
1266
  | `fn_<key>` | ! | Every `type: script` entry in `functions.yaml`, exposed automatically |
1265
1267
 
@@ -1,7 +1,7 @@
1
1
  dev_setup/__init__.py,sha256=BfTc-iAf16B_sxLK1PM3P7QlMGy7k33ColMK0o6KkdA,158
2
2
  dev_setup/__main__.py,sha256=w-Vnqe3bgAw_UNlPywPkbOqoFKcEk2H2S79wrQjXvU4,102
3
- dev_setup/agent_tools.schema.json,sha256=veXnih00xW4w9yK3ruWz-npUrCnJmcQpQdFvfcu7v_I,4928
4
- dev_setup/agent_tools.yaml,sha256=56E70B1W7hBqjGhYhhCAGzFQvi1nUZ04cnNiqZlMjyY,4506
3
+ dev_setup/agent_tools.schema.json,sha256=lNu8N5nm4VPzUJar3gI7SHP7rPrJAcVwaA7Sx0Zd26Y,4937
4
+ dev_setup/agent_tools.yaml,sha256=YQy6Y6MS65nsRd3MsfuyilaiVBQp89t1TDimeIJw6L8,5944
5
5
  dev_setup/apply_exec.py,sha256=czzQxxYHWCAmAsgd9BvMPYlG2b63g0b3RHbbO5UyPRA,6364
6
6
  dev_setup/apply_plan.py,sha256=L_ZmSGnjM7T1hKT7RLXSvCZgjbRpX_AaTKg5N9fp1zs,8474
7
7
  dev_setup/base.py,sha256=j2EQ5gzeGgtveWQN_BgbLcZianMENJ7PQy8EQ9J9MPE,1946
@@ -24,19 +24,19 @@ dev_setup/registry.py,sha256=eHEuo4p0O0CHDWatFuOlSFiSAz5L6YFYmv9tAGHYMt4,2510
24
24
  dev_setup/snapshot.py,sha256=A2G_6pHSaGhDT1PJAZ6eW83GdSdCGs2r79yH8FCa0Qs,5330
25
25
  dev_setup/tools.yaml,sha256=m2MEYq_mZuzEU8vCJgPWHdhLuqRjQGNWheqhwQgMXXQ,34234
26
26
  dev_setup/ui.py,sha256=B0t4hYlZ7jIMIdldMCImLNBJT1NQgZ4ff8ItjfHRNl0,23879
27
- dev_setup/updates.py,sha256=D6dH6G_Bv07XWSyzXvYESbV5s2d0N7euHu69zUyBbs4,5289
27
+ dev_setup/updates.py,sha256=p9_nbfaX_73hE71kr5ZDZA5o85T9XTR0mjbo15f950I,6046
28
28
  dev_setup/verbose.py,sha256=N3U9JAYOvFwdd8DT6W7Pqq6RCIUfbcQnPsm0O1TnvQY,5003
29
29
  dev_setup/agent/__init__.py,sha256=znrgxUCr_y0Qp-f41S6EaTv-hoTYwoZ9mOMLVge-IJg,226
30
30
  dev_setup/agent/approval.py,sha256=DNPV5iM_UpCx39xFzCu8kyr03tjfyfD7iVcTfQMJRwY,3630
31
- dev_setup/agent/bridges.py,sha256=RX5coPXJUSkyZApxgUZghz_57ibcPrWHVz3D44S6z2Q,4814
32
- dev_setup/agent/catalog.py,sha256=-5SbDxlT_W8PHoFRJA905eJ9aIe6cHtNrAtZJcImwkY,6304
31
+ dev_setup/agent/bridges.py,sha256=eTn5Sj9OET_o8Ntctub6DJjndM8bjywDeEbjYrdtDPE,7541
32
+ dev_setup/agent/catalog.py,sha256=yh4x50GuUwwk6IaESDbosbTU4ehCsITUCWG0-BuAAFk,6313
33
33
  dev_setup/agent/completion.py,sha256=BhreXV0MwyMejAFmXe6gX6h64nTH713RIy-Dy0KK-Ig,1854
34
34
  dev_setup/agent/config.py,sha256=a0vagUWyKd1MOBsdJeNGVRlAGZdqfozPRNJyNxXN16Q,5970
35
35
  dev_setup/agent/loop.py,sha256=PKmGokOkKNLcwaSlnZ0v8XhwIx0N4t1Zj6Ia1kSflNM,4982
36
36
  dev_setup/agent/ollama.py,sha256=B1YfJQQzdF5hagd3Q_6rGe82IISwolhP-zMZh_7DN1o,8774
37
37
  dev_setup/agent/preflight.py,sha256=pTaDqrwGI99b5WedU4ujyggTEcrUZmBh4mo8UYrMYd4,3463
38
38
  dev_setup/agent/primitives.py,sha256=g8WuzQZuqLU-Nv_XlLBcsOVsrBku-_5yWRHEXD5i4ZY,3714
39
- dev_setup/agent/registry.py,sha256=Glj7VM-L4ttVYK9YtX63jvsrnU6Rr7-GN0RdqsJjaio,5368
39
+ dev_setup/agent/registry.py,sha256=LT2W5dAJgAVlSwJ5wgJctkOnRKOE_7jkYW1Hz0E_pWg,5644
40
40
  dev_setup/agent/sandbox.py,sha256=wS_9kwc6r0spKSX8CBJFDkhWSiVG60D8dCKBrKbVnYA,10891
41
41
  dev_setup/agent/session.py,sha256=1UB0Mxz-cflDHqOfj1PFzufb1yz1ECbcObXIPubZfMU,12654
42
42
  dev_setup/agent/transcript.py,sha256=hJQuSLriAe5hvnD3SCMqOWduuYtblyhmqzZQ3jDco1Y,1868
@@ -61,7 +61,7 @@ dev_setup/commands/help_cmd.py,sha256=O2dnhqsMZx5tVHdJVixixCJwc9TYlKdlZ2vYYPApl0
61
61
  dev_setup/commands/install_cmd.py,sha256=YgVm8r2RevoSrfBBAvZpDmL0NOQFdOGTFp3aIx-9xwo,8519
62
62
  dev_setup/commands/links_cmd.py,sha256=kvnoBXdM9QWRZRIwWgnmWqVkOYE7AZxywFTQD5_Uwv4,4924
63
63
  dev_setup/commands/list_cmd.py,sha256=Env6bwAmREDek4L-ZB2CIfvLT4PgaKcz5sQKJ1GhL8g,2913
64
- dev_setup/commands/outdated_cmd.py,sha256=YljnMw-KZd1jcZO5FEce3H6nrX1MnWOt0fRBSAdlpQE,5070
64
+ dev_setup/commands/outdated_cmd.py,sha256=afwYyq0M-tWVOk2qyXQqsdWSTK6yuFbVpbrOmMPKS_w,4757
65
65
  dev_setup/commands/profile_cmd.py,sha256=jo7al_nBwuWtzOLYKjcqEGmHp4eQrzM5s7ahv6iiGaw,18299
66
66
  dev_setup/commands/remove_cmd.py,sha256=Az0qMes4M5237c_ntQ1SemS38gTpLZy2GhSK_gUrw3s,4974
67
67
  dev_setup/commands/run_cmd.py,sha256=e1xfWt09UALiAe03AxzdvZyYpj0V7WKk2-E_nbk9hIw,2933
@@ -113,7 +113,9 @@ dev_setup/configure/starship/model.py,sha256=ct1YrR3xLqcKMP20TvKZQ0Oc-OxHMrRjnei
113
113
  dev_setup/configure/starship/preview.py,sha256=ZaNhNA3AeHHtPnMqrJbB9XVVXDFbH1R36jm8xyYdt2U,6145
114
114
  dev_setup/configure/starship/render.py,sha256=25O8w4IteVd_ELwmIWhcYAn042W6yZ--zbTMcJpzVJc,11277
115
115
  dev_setup/configure/starship/wizard.py,sha256=F3-xVQmZjYtiQAICyJXeSogjcASSsVbaP2b8YHAX9TM,28726
116
- devstuff-2.14.0.dist-info/METADATA,sha256=b2qlJDqyH_cdiuL9YdBtkb-6BlpUBdBPuVJ-M3abYyg,93513
117
- devstuff-2.14.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
118
- devstuff-2.14.0.dist-info/entry_points.txt,sha256=48ITy9ENdXDFrTHwAyVPUpq1MDmgFqcOisOo5mAR6OQ,53
119
- devstuff-2.14.0.dist-info/RECORD,,
116
+ dev_setup/mcp/__init__.py,sha256=a3DUEjK_mIpC4QsaPaArwKqaVvtujfzSu8WMpMh6G70,89
117
+ dev_setup/mcp/core.py,sha256=b79cJAM3W6qLMGW110UlX7KI5JbplO3ptfVEeiUDFc0,2598
118
+ devstuff-2.15.0.dist-info/METADATA,sha256=8ekogNHBXp0qG0rp5g3iTPCwNSvzLV2361ajMO55Vz8,93743
119
+ devstuff-2.15.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
120
+ devstuff-2.15.0.dist-info/entry_points.txt,sha256=48ITy9ENdXDFrTHwAyVPUpq1MDmgFqcOisOo5mAR6OQ,53
121
+ devstuff-2.15.0.dist-info/RECORD,,