elan-cli 0.1.1__tar.gz → 0.1.3__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 (29) hide show
  1. elan_cli-0.1.3/CHANGELOG.md +53 -0
  2. {elan_cli-0.1.1 → elan_cli-0.1.3}/PKG-INFO +2 -2
  3. {elan_cli-0.1.1 → elan_cli-0.1.3}/pyproject.toml +15 -2
  4. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/config.py +25 -16
  5. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/scaffold.py +185 -2
  6. {elan_cli-0.1.1 → elan_cli-0.1.3}/.gitignore +0 -0
  7. {elan_cli-0.1.1 → elan_cli-0.1.3}/LICENSE +0 -0
  8. {elan_cli-0.1.1 → elan_cli-0.1.3}/README.md +0 -0
  9. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/__init__.py +0 -0
  10. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/adk.py +0 -0
  11. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/auth.py +0 -0
  12. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/client.py +0 -0
  13. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/deploy.py +0 -0
  14. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/destroy.py +0 -0
  15. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/doctor.py +0 -0
  16. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/env.py +0 -0
  17. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/files.py +0 -0
  18. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/invoke.py +0 -0
  19. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/logs.py +0 -0
  20. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/main.py +0 -0
  21. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/manifests.py +0 -0
  22. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/project.py +0 -0
  23. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/projects.py +0 -0
  24. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/rollback.py +0 -0
  25. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/secret.py +0 -0
  26. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/stream.py +0 -0
  27. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/tenant.py +0 -0
  28. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/validate.py +0 -0
  29. {elan_cli-0.1.1 → elan_cli-0.1.3}/src/elan_cli/wallet.py +0 -0
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ Versions follow the tag that published them — `cli/v*`. A version with no date
4
+ has not been published yet.
5
+
6
+ ## 0.1.3 — unreleased
7
+
8
+ ### Added
9
+ - `elan init` makes the repository ready for an AI coding assistant. It writes
10
+ a `CLAUDE.md` naming the rules a deploy enforces — bump `MANIFEST.version`,
11
+ add targets with `elan new`, push before deploying, never put a secret in a
12
+ file — and linking this platform's docs and its `llms-full.txt`. It also
13
+ writes a `.claude/settings.json` that lets an assistant run read-only
14
+ commands unasked, asks before anything that deploys, spends, deletes or
15
+ pushes, and refuses to read `.env`. Neither file is overwritten if it exists,
16
+ and `.claude/settings.local.json` is git-ignored.
17
+
18
+ ## 0.1.2 — 2026-11-10
19
+
20
+ ### Changed
21
+ - `elan login` reaches the production API with no arguments. `--api` is now the
22
+ override for anything else, which is what this README has said since the
23
+ first release. Precedence, highest first: `--api` (which is written down and
24
+ therefore remembered), then `ELAN_API`, then the stored `config.json`, then
25
+ production.
26
+
27
+ It used to refuse to run without one, on the reasoning that a client aimed at
28
+ a staging environment deploys somebody's first agent there without saying so.
29
+ That was sound while there was no production to point at, and stopped being
30
+ sound once there was — a developer who had just installed the CLI was asked
31
+ for a URL that appears nowhere in the package they installed.
32
+
33
+ ### Fixed
34
+ - The CLI reference documented `ELAN_CONFIG_HOME`, which nothing read; the
35
+ variable is and always was `ELAN_HOME`.
36
+
37
+ ## 0.1.1 — 2026-11-09
38
+
39
+ ### Added
40
+ - `elan --version`, which also names the `elan-sdk` version it is running
41
+ against. The two publish independently, so a current-looking CLI can be
42
+ sitting on an older SDK. Nothing sends either number to the platform, so this
43
+ answers "which one have I got" and not "is mine too old".
44
+
45
+ ## 0.1.0 — 2026-11-09
46
+
47
+ First public release.
48
+
49
+ `uv tool install elan-cli` — the install five documents had described since
50
+ before it was possible. Sign in with a device-code flow whose refresh token
51
+ goes to the OS keyring and never to a file; scaffold a project; build the local
52
+ environment; validate your manifests against your deploy file; deploy, invoke,
53
+ tail logs, roll back and tear down.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: elan-cli
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: The command line a developer deploys an agent with
5
5
  Project-URL: Homepage, https://openelan.ai
6
6
  Project-URL: Documentation, https://openelan.ai/app/docs
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
17
  Requires-Python: >=3.12
18
18
  Requires-Dist: certifi>=2024.2.2
19
- Requires-Dist: elan-agentkit-contracts
19
+ Requires-Dist: elan-agentkit-contracts>=0.1.1
20
20
  Requires-Dist: elan-sdk
21
21
  Requires-Dist: httpx>=0.27
22
22
  Requires-Dist: keyring>=25.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "elan-cli"
3
- version = "0.1.1"
3
+ version = "0.1.3"
4
4
  description = "The command line a developer deploys an agent with"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -29,7 +29,7 @@ dependencies = [
29
29
  # so `uv tool install elan-cli` no longer pulls a token verifier, a
30
30
  # database layer and a Pub/Sub broker onto a developer's laptop to read one
31
31
  # YAML file.
32
- "elan-agentkit-contracts",
32
+ "elan-agentkit-contracts>=0.1.1",
33
33
  # THE SHARED CLIENT CODE, ONE WAY (ADR-0104). `text_of` and the certifi
34
34
  # context live there now; this re-exports them. The dependency runs
35
35
  # elan-cli -> elan-sdk and never back: the SDK must not import `elan_cli`,
@@ -74,3 +74,16 @@ build-backend = "hatchling.build"
74
74
 
75
75
  [tool.hatch.build.targets.wheel]
76
76
  packages = ["src/elan_cli"]
77
+
78
+ [tool.hatch.build.targets.sdist]
79
+ # AN ALLOWLIST, BECAUSE THE DEFAULT SDIST IS "EVERYTHING NOT GITIGNORED" and
80
+ # that is an open set — so a file that appears beside this one ships to PyPI
81
+ # without anybody deciding it should. `elan-agentkit-runtime` shipped three
82
+ # Dockerfiles that way; its manifest records the detail. Nothing here is
83
+ # excluded today, which is the point: the guard is against the NEXT file.
84
+ #
85
+ # `.gitignore` survives this and cannot be removed — hatchling force-includes
86
+ # the VCS exclusion files it found, which is also why README and LICENSE need
87
+ # no entry. See `agent-pipeline/runtime/pyproject.toml` for why that is left
88
+ # alone rather than worked around.
89
+ include = ["src", "README.md", "CHANGELOG.md"]
@@ -26,15 +26,21 @@ import os
26
26
  from dataclasses import dataclass
27
27
  from pathlib import Path
28
28
 
29
+ from elan_agentkit_contracts.endpoints import DEFAULT_API_URL, ENV_API
30
+
29
31
  #: The platform this CLI is built for.
30
32
  #:
31
- #: EMPTY UNTIL THERE IS A PRODUCTION ONE, and empty rather than pointed at
32
- #: non-prod. A client that ships aimed at a staging environment is a client
33
- #: that quietly deploys somebody's first agent to the wrong place — and unlike
34
- #: a missing default, that failure does not announce itself. When production
35
- #: exists this becomes its URL and `--api` becomes the override for everyone
36
- #: else, which is how `gh` and `stripe` work and what a developer expects.
37
- DEFAULT_API = ""
33
+ #: IT USED TO BE EMPTY, and the reasoning was sound while it held: "a client
34
+ #: that ships aimed at a staging environment is a client that quietly deploys
35
+ #: somebody's first agent to the wrong place — and unlike a missing default,
36
+ #: that failure does not announce itself." Production exists now, so the
37
+ #: default IS production and `--api` is the override for everyone else, which
38
+ #: is how `gh` and `stripe` work and what a developer expects.
39
+ #:
40
+ #: NOT SPELLED HERE. Three clients need the same answer and only one of them is
41
+ #: this one; `elan_agentkit_contracts.endpoints` is the single place, shared
42
+ #: with the Python SDK and generated into the TypeScript one.
43
+ DEFAULT_API = DEFAULT_API_URL
38
44
 
39
45
 
40
46
  def config_home() -> Path:
@@ -103,15 +109,18 @@ class Config:
103
109
  except ValueError as exc:
104
110
  raise ConfigError(f"{path} is not valid JSON: {exc}") from exc
105
111
 
106
- api = os.environ.get("ELAN_API") or data.get("api") or DEFAULT_API
107
- if not api:
108
- raise ConfigError(
109
- "this CLI does not know which platform to talk to.\n"
110
- " Pass it once — `elan login --api https://your-platform` —\n"
111
- " and it is remembered. There is no built-in default yet,\n"
112
- " deliberately: a client aimed at the wrong environment\n"
113
- " deploys somebody's first agent there without saying so."
114
- )
112
+ # PRECEDENCE, HIGHEST FIRST: the environment, then what `elan login
113
+ # --api` remembered, then production. `--api` does not appear here
114
+ # because it is not a read — `login` writes it, which is what makes it
115
+ # remembered; a flag that only applied to the command carrying it would
116
+ # mean `elan login --api X` followed by `elan deploy` talking to a
117
+ # different platform.
118
+ #
119
+ # NO REFUSAL ANY MORE. This used to raise "there is no built-in default
120
+ # yet, deliberately", which was true and is not: a developer who had
121
+ # just run `uv tool install elan-cli` was told to supply a URL that
122
+ # appears nowhere in the package they installed.
123
+ api = os.environ.get(ENV_API) or data.get("api") or DEFAULT_API
115
124
  return cls(api=api.rstrip("/"), issuer=data.get("issuer", ""),
116
125
  client_id=data.get("client_id", ""),
117
126
  audience=data.get("audience", ""),
@@ -10,7 +10,9 @@ exactly the failure the cross-check exists to catch.
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
+ import json
13
14
  from pathlib import Path
15
+ from urllib.parse import urlsplit
14
16
 
15
17
  from elan_agentkit_contracts import templates
16
18
  from elan_agentkit_contracts.identity import (
@@ -42,12 +44,16 @@ KINDS = {"agent": ("agents", "agent.py"), "workflow": ("workflows", "workflow.py
42
44
  PLACEHOLDER_SHA = "0" * 40
43
45
 
44
46
  #: DELIBERATELY SHORT. A scaffolder that writes somebody's whole ignore file
45
- #: is guessing at their editor and their operating system; these three are the
46
- #: ones THIS TOOL causes.
47
+ #: is guessing at their editor and their operating system; these are the ones
48
+ #: THIS TOOL causes. `.claude/settings.local.json` is one of them because
49
+ #: `init` writes the shared `.claude/settings.json` beside it, and the local
50
+ #: file is where one developer's own permissions go — committing it would hand
51
+ #: their choices to everybody who clones the repo.
47
52
  GITIGNORE = """\
48
53
  .env
49
54
  .venv/
50
55
  .elan/
56
+ .claude/settings.local.json
51
57
  __pycache__/
52
58
  *.pyc
53
59
  """
@@ -163,6 +169,173 @@ elan deploy
163
169
  """
164
170
 
165
171
 
172
+ #: WHAT AN AI CODING ASSISTANT READS BEFORE IT TOUCHES ANYTHING.
173
+ #:
174
+ #: THE RULES HERE ARE THE ONES A DEPLOY ENFORCES, which is what makes them
175
+ #: worth a file. An assistant that does not know a changed target needs a
176
+ #: version bump, or that a module must be declared in `elan.yaml`, writes a
177
+ #: change that `elan validate` or the deploy refuses — and then, without being
178
+ #: told why, "fixes" it in the wrong direction. Each rule below names the
179
+ #: refusal it avoids.
180
+ #:
181
+ #: SHORTER THAN THE README, ON PURPOSE. The README explains the design to a
182
+ #: person; this is loaded into every conversation an assistant has about the
183
+ #: repo, so it carries rules and pointers, and the documentation — reachable as
184
+ #: one `llms-full.txt` — carries the rest.
185
+ CLAUDE_TEMPLATE = """\
186
+ # {project}
187
+
188
+ Google ADK agents and workflows that the Elan platform builds, deploys and runs.
189
+ This repository holds only agent code and one deploy contract. The platform
190
+ supplies the image, the infrastructure and the pipeline, so there is no
191
+ Dockerfile, Kubernetes manifest, Terraform or CI workflow here, and none should
192
+ be added.
193
+
194
+ ## Documentation
195
+
196
+ {docs}
197
+
198
+ ## Layout
199
+
200
+ - `elan.yaml` is the deploy contract: the tenant, the project, the source
201
+ repository, every target, and what each is given — resources, scaling, model
202
+ keys, secrets, egress. The platform reads it without running your code.
203
+ - `agents/<module>/agent.py` and `workflows/<module>/workflow.py` are one target
204
+ each. Every one exports `MANIFEST` (slug, version, model, tools, limits,
205
+ price) and `build(ctx)`, which returns the ADK agent or `google.adk.Workflow`.
206
+ - `.env` holds local settings and the model key, for `elan adk web` only. It is
207
+ git-ignored and a deployed pod never reads it.
208
+
209
+ ## Commands
210
+
211
+ ```bash
212
+ elan validate # elan.yaml against every MANIFEST, both ways
213
+ elan adk web # run the agents locally, behind the platform's plugins
214
+ elan new agent <slug> # add a target: writes the module AND declares it
215
+ elan new workflow <slug>
216
+ elan deploy # builds the PUSHED commit, not the working tree
217
+ elan status <deployment-id> # the phase a deploy reached, and why it stopped
218
+ elan logs <deployment-id> # the build output
219
+ elan invoke <slug> --text "..." # talk to a deployed agent
220
+ elan secret ls # which secrets are set, names only
221
+ ```
222
+
223
+ ## Rules
224
+
225
+ - **Add a target with `elan new`, never by hand.** A module missing from
226
+ `elan.yaml`, or an entry with no module, is refused at deploy.
227
+ - **Bump `MANIFEST.version` whenever you change a target.** A deploy refuses a
228
+ target whose code changed under an unchanged version.
229
+ - **Run `elan validate` before every commit** and fix everything it reports.
230
+ - **Commit and push before `elan deploy`.** It builds the remote commit.
231
+ - **No secret value goes in any file** — not `elan.yaml`, a MANIFEST, code or a
232
+ commit. A person sets the value with `elan secret set`; `elan.yaml` names it
233
+ under a target's `secrets:`; code reads `os.environ["..."]`. Never read,
234
+ print or edit `.env`.
235
+ - **Use the platform's variable names.** The model key is `GOOGLE_API_KEY`
236
+ because `llm.keys` in `elan.yaml` resolves to it; an invented name works
237
+ locally and reads nothing once deployed.
238
+ - **Keep everything a target imports inside its own directory.** The image is
239
+ built from `agents/` and `workflows/` only; a `lib/` at the root is gone in
240
+ the pod.
241
+ - **Never list `agentkit-*` packages in a `pyproject.toml`.** The runtime image
242
+ carries ADK and the platform's packages; add one only for libraries beyond
243
+ those.
244
+ - **Declare every tool that acts in `MANIFEST.actions`.** An undeclared tool is
245
+ not governed by autonomy policy, so it runs without anybody being asked.
246
+ - **Slugs are identity.** 5 to 16 characters, lowercase letters, digits and
247
+ single hyphens, starting with a letter. Renaming one makes a new agent.
248
+
249
+ ## ADK behavior that surprises people
250
+
251
+ - The graph class is `google.adk.Workflow`. ADK's docs describe a `GraphAgent`
252
+ that does not ship.
253
+ - A workflow node receives the previous node's output, so put model nodes at
254
+ the end: a model between two function nodes hands the second a sentence.
255
+ - A workflow whose last node is a `FunctionNode` returns nothing to a caller
256
+ unless that node returns an `Event` with `content`.
257
+ - `node_input` is a reserved parameter name, and an optional declared input
258
+ must still be present in session state.
259
+ - A paused run emits no `finished` event; a client waiting for one waits out
260
+ its whole timeout.
261
+ - To test with no model access, register a fake model in ADK's `LLMRegistry`
262
+ and select it with `MODEL_OVERRIDE`; the building-an-agent guide has the
263
+ recipe. `AGENTKIT_ENV=local`, already in `.env`, is what permits it.
264
+ """
265
+
266
+ #: Allowed without asking: commands that only read. Asked about: everything
267
+ #: that deploys, spends, deletes or publishes. Denied: the file with the key.
268
+ #:
269
+ #: `.env` IS DENIED RATHER THAN MERELY ASKED ABOUT because nothing an assistant
270
+ #: does needs the key's value — the CLI and `adk web` read it themselves — and
271
+ #: a value read into a conversation is a value that can end up in a commit, a
272
+ #: log or a paste.
273
+ _READ_ONLY = ("validate", "status", "logs", "whoami", "agents", "secret ls",
274
+ "doctor")
275
+ _CONSEQUENTIAL = ("deploy", "rollback", "destroy", "secret set", "secret rm",
276
+ "wallet", "projects create")
277
+
278
+
279
+ def _claude_settings(console: str) -> str:
280
+ """`.claude/settings.json`, shared by everybody who clones the repo."""
281
+ allow = [f"Bash(elan {command}:*)" for command in _READ_ONLY]
282
+ allow += ["Bash(git status:*)", "Bash(git diff:*)", "Bash(git log:*)"]
283
+ if host := urlsplit(console).hostname:
284
+ # THE DOCS ARE WHAT IT SHOULD READ INSTEAD OF GUESSING, so fetching
285
+ # them is not something to stop and ask about.
286
+ allow.append(f"WebFetch(domain:{host})")
287
+ settings = {
288
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
289
+ "permissions": {
290
+ "allow": allow,
291
+ "ask": [f"Bash(elan {command}:*)" for command in _CONSEQUENTIAL]
292
+ + ["Bash(git push:*)"],
293
+ "deny": ["Read(./.env)", "Read(./.env.*)", "Edit(./.env)"],
294
+ },
295
+ }
296
+ return json.dumps(settings, indent=2) + "\n"
297
+
298
+
299
+ def _console() -> str:
300
+ """This platform's console, e.g. `https://openelan.ai/app`, or `""`.
301
+
302
+ ANSWERED BY THE PLATFORM WHEN IT CAN BE. `elan login` caches the device
303
+ sign-in page the platform names, which is `<console>/device` — so after a
304
+ login the console is known rather than composed. Before one, the API's own
305
+ `api.<domain>` naming gives `<domain>/app`; anything else (a laptop's
306
+ `localhost`) gives nothing, and the file says where the docs live in words
307
+ instead of linking somewhere wrong.
308
+
309
+ NEVER RAISES. A config this cannot read must not stop a scaffold — the docs
310
+ link is a convenience, and `init` has written nothing else that depends on
311
+ it.
312
+ """
313
+ from elan_cli.config import Config, ConfigError # noqa: PLC0415
314
+
315
+ try:
316
+ config = Config.load()
317
+ except ConfigError:
318
+ return ""
319
+ if config.device_url.endswith("/device"):
320
+ return config.device_url[: -len("/device")]
321
+ parts = urlsplit(config.api)
322
+ if parts.hostname and parts.hostname.startswith("api."):
323
+ return f"{parts.scheme}://{parts.netloc[len('api.'):]}/app"
324
+ return ""
325
+
326
+
327
+ def _docs_section(console: str) -> str:
328
+ if not console:
329
+ return ("The platform's documentation is in its console, under `/docs`. "
330
+ "Beside it,\n`llms-full.txt` holds every page in one file, "
331
+ "written for a model.")
332
+ return (f"This platform's documentation is at {console}/docs. Read the "
333
+ "page for\nwhat you are changing before guessing at an API.\n\n"
334
+ f"- {console}/llms.txt indexes every page, one line each.\n"
335
+ f"- {console}/llms-full.txt holds every page in one file,\n"
336
+ " written for a model.")
337
+
338
+
166
339
  def _slug_ok(slug: str, *, lo: int, hi: int) -> bool:
167
340
  import re
168
341
 
@@ -270,14 +443,24 @@ def init(directory: Path, *, tenant: str, project: str, repo: str,
270
443
  # NONE OF THESE OVERWRITE. A directory that already has one has it for
271
444
  # reasons this does not know, and `init` refusing to clobber is the same
272
445
  # rule elan.yaml gets a paragraph about above.
446
+ #
447
+ # CLAUDE.md AND .claude/ MAKE THE REPO READY FOR AN AI ASSISTANT from its
448
+ # first commit: the rules a deploy enforces, where the docs are, and which
449
+ # commands it may run without asking. Not overwritten either — a repo that
450
+ # already instructs its assistant has reasons this does not know.
451
+ console = _console()
273
452
  written = []
274
453
  for name, body in (
275
454
  (".gitignore", GITIGNORE),
276
455
  (".env", ENV_TEMPLATE.format(project=project)),
277
456
  ("README.md", README_TEMPLATE.format(project=project)),
457
+ ("CLAUDE.md", CLAUDE_TEMPLATE.format(project=project,
458
+ docs=_docs_section(console))),
459
+ (".claude/settings.json", _claude_settings(console)),
278
460
  ):
279
461
  path = directory / name
280
462
  if not path.exists():
463
+ path.parent.mkdir(parents=True, exist_ok=True)
281
464
  path.write_text(body)
282
465
  written.append(path)
283
466
  spec_path.write_text(SPEC_TEMPLATE.format(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes