framework-py 0.1.0.dev31__py3-none-any.whl → 0.1.0.dev32__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.
framework/_agents_md.py CHANGED
@@ -7,10 +7,15 @@ user's to edit.
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
+ import base64
11
+ import binascii
10
12
  import re
13
+ from collections.abc import Mapping
11
14
  from pathlib import Path
12
15
  from typing import Any
13
16
 
17
+ from framework.spec.resolve import is_app_type
18
+
14
19
  REGENERATE = "<!-- @framework:regenerate -->"
15
20
  PACKAGES_HEADING = "Installed Packages"
16
21
 
@@ -61,12 +66,33 @@ def _header(name: str) -> str:
61
66
  def skill_description(folder: Path) -> str:
62
67
  """A skill's own description, from its SKILL.md front matter, on one line with pipes
63
68
  escaped, for skills Framework has no line for. R: ``.skill_description()``."""
64
- from framework import _yaml
65
-
66
69
  try:
67
70
  text = (folder / "SKILL.md").read_text(encoding="utf-8")
68
71
  except OSError:
69
72
  return ""
73
+ return _front_description(text)
74
+
75
+
76
+ def _entry_skill_md(entry: object) -> str | None:
77
+ """A spec skill entry's SKILL.md text: its ``content``, else the file in its Cloud
78
+ ``bundle`` (base64). None for a package skill, which ships its own."""
79
+ if not isinstance(entry, Mapping):
80
+ return None
81
+ content = entry.get("content")
82
+ if isinstance(content, str) and content:
83
+ return content
84
+ for item in entry.get("bundle") or []:
85
+ if isinstance(item, Mapping) and item.get("path") == "SKILL.md":
86
+ try:
87
+ return base64.b64decode(str(item.get("content") or "")).decode("utf-8")
88
+ except (binascii.Error, ValueError):
89
+ return None
90
+ return None
91
+
92
+
93
+ def _front_description(text: str) -> str:
94
+ from framework import _yaml
95
+
70
96
  found = re.match(r"---\r?\n(.*?)\r?\n---", text, re.DOTALL)
71
97
  try:
72
98
  meta = _yaml.load(found.group(1)) if found else None
@@ -78,12 +104,25 @@ def skill_description(folder: Path) -> str:
78
104
  return " ".join(value.split()).replace("|", "\\|")
79
105
 
80
106
 
81
- def _skills(skills: list[str], skills_dir: str, root: Path | None = None) -> str:
107
+ def _skills(
108
+ skills: list[str],
109
+ skills_dir: str,
110
+ root: Path | None = None,
111
+ entries: Mapping[str, Any] | None = None,
112
+ ) -> str:
113
+ """The Skills section. A skill Framework has no line for is described by its SKILL.md
114
+ front matter: from the spec's entry when there is one, else the copy in the project."""
115
+
82
116
  def covers(skill: str) -> str:
83
117
  known = SKILL_DESCRIPTIONS.get(skill)
84
- if known is not None or root is None:
85
- return known or ""
86
- return skill_description(root / skills_dir / skill)
118
+ if known is not None:
119
+ return known
120
+ text = _entry_skill_md((entries or {}).get(skill))
121
+ if text is not None:
122
+ described = _front_description(text)
123
+ if described:
124
+ return described
125
+ return skill_description(root / skills_dir / skill) if root is not None else ""
87
126
 
88
127
  rows = [
89
128
  f"| `{skill}` | {covers(skill)} | `{skills_dir}/{skill}/SKILL.md` |" for skill in skills
@@ -103,7 +142,61 @@ def _skills(skills: list[str], skills_dir: str, root: Path | None = None) -> str
103
142
  )
104
143
 
105
144
 
145
+ def _folder(spec: Mapping[str, Any], key: str) -> str:
146
+ """A folder's name from the spec's directories, else its usual name."""
147
+ value = (spec.get("directories") or {}).get(key)
148
+ return str(value).strip("/") if isinstance(value, str) and value else key
149
+
150
+
151
+ def _app_environment(spec: dict[str, Any]) -> str | None:
152
+ """The Framework Environment section of an app, which doesn't call ``fw.scaffold()``.
153
+ None for other project types."""
154
+ www, data, tests = (_folder(spec, key) for key in ("www", "data", "tests"))
155
+ publish = (
156
+ "- Ask before publishing anything public. GitHub Pages is public even from a "
157
+ "private repository."
158
+ )
159
+ package = '- Add packages with `fw.package_add("name")`. It records them in pyproject.toml.'
160
+ if spec.get("type") == "shiny_python":
161
+ kind = "a Shiny for Python app"
162
+ lines = [
163
+ f"- The interface and server are in `app.py`. Static files go in `{www}/`, data "
164
+ f"files in `{data}/`, and tests in `{tests}/`.",
165
+ "- Run it with `uv run shiny run --reload app.py`.",
166
+ package,
167
+ publish,
168
+ ]
169
+ elif spec.get("type") == "fastapi":
170
+ app = _folder(spec, "app")
171
+ module = app.replace("/", ".")
172
+ kind = "a FastAPI app"
173
+ lines = [
174
+ f"- The endpoints are in `{app}/main.py`. Tests in `{tests}/` use FastAPI's test "
175
+ f"client. Data files go in `{data}/`.",
176
+ f"- Run it with `uv run uvicorn {module}.main:app --reload`. The API docs are at "
177
+ "`/docs`.",
178
+ "- Run the tests with `uv run pytest`.",
179
+ package,
180
+ publish,
181
+ ]
182
+ else:
183
+ return None
184
+ return "\n".join(
185
+ [
186
+ f"## Framework Environment {REGENERATE}",
187
+ "",
188
+ f"This is {kind}. Framework manages its packages, skills, and settings. The app "
189
+ "doesn't call `fw.scaffold()`.",
190
+ "",
191
+ *lines,
192
+ ]
193
+ )
194
+
195
+
106
196
  def _environment(spec: dict[str, Any]) -> str:
197
+ app = _app_environment(spec)
198
+ if app is not None:
199
+ return app
107
200
  scaffold = spec.get("scaffold") or {}
108
201
  functions = (spec.get("directories") or {}).get("functions") or "functions"
109
202
  steps = [
@@ -247,7 +340,7 @@ def _data(spec: dict[str, Any]) -> str:
247
340
  )
248
341
 
249
342
 
250
- def _type_section(spec: dict[str, Any]) -> str:
343
+ def _type_section(spec: dict[str, Any]) -> str | None:
251
344
  # Sensitive data is a setting, whatever structure the project uses
252
345
  from framework._private import spec_sensitive
253
346
 
@@ -278,6 +371,9 @@ def _type_section(spec: dict[str, Any]) -> str:
278
371
  'fw.make_revealjs("backup-slides")\n'
279
372
  "```"
280
373
  )
374
+ # The guidelines point at the framework-workflow skill, so they need it
375
+ if is_app_type(spec.get("type")) or "framework-workflow" not in (spec.get("skills") or {}):
376
+ return None
281
377
  return (
282
378
  "## Workflow Guidelines\n\n"
283
379
  "Follow the standard Framework workflow (see the `framework-workflow` skill):\n"
@@ -286,22 +382,31 @@ def _type_section(spec: dict[str, Any]) -> str:
286
382
  )
287
383
 
288
384
 
289
- def agents_md(spec: dict[str, Any], skills_dir: str, restricted_notice: str | None) -> str:
385
+ def agents_md(
386
+ spec: dict[str, Any],
387
+ skills_dir: str,
388
+ restricted_notice: str | None,
389
+ root: Path | None = None,
390
+ ) -> str:
290
391
  """The full AGENTS.md for a new project.
291
392
 
292
393
  ``restricted_notice`` names the folders agents must stay out of. It goes
293
- right after the header in sensitive projects.
394
+ right after the header in sensitive projects. ``root`` is the project, for the
395
+ descriptions of skills already written there. An app (Shiny for Python or FastAPI)
396
+ has no Data Management or Workflow Guidelines section.
294
397
  """
295
- sections = [_header(spec["name"])]
398
+ skills = spec.get("skills") or {}
399
+ app = is_app_type(spec.get("type"))
400
+ sections: list[str | None] = [_header(spec["name"])]
296
401
  if restricted_notice:
297
402
  sections.append(restricted_notice)
298
403
  sections += [
299
- _skills(list(spec.get("skills") or {}), skills_dir),
404
+ _skills(list(skills), skills_dir, root, skills),
300
405
  _environment(spec),
301
406
  _packages(spec),
302
- _data(spec),
407
+ None if app else _data(spec),
303
408
  _type_section(spec),
304
409
  "## Project Notes\n\n*Add your project-specific notes, conventions, and documentation "
305
410
  "here.*",
306
411
  ]
307
- return "\n\n".join(section.rstrip("\n") for section in sections) + "\n"
412
+ return "\n\n".join(section.rstrip("\n") for section in sections if section) + "\n"
framework/_pages.py CHANGED
@@ -139,10 +139,11 @@ def _cloud_pages_url(root: Path) -> tuple[bool, str | None, str | None]:
139
139
  One call to ``/api/v1/me`` with the project token. Not known when there is
140
140
  no project token or the call fails.
141
141
  """
142
- from framework.cloud import CloudError, api, cloud_server, project_token
142
+ from framework.cloud import PROJECT_NOT_LINKED, CloudError, api, cloud_server, project_token
143
143
 
144
144
  token = project_token(root)
145
145
  if token is None:
146
+ inform(f"{PROJECT_NOT_LINKED} Using the GitHub Pages address from the git remote.")
146
147
  return False, None, None
147
148
  try:
148
149
  server = cloud_server(scope="project", project_dir=root).url
framework/ai.py CHANGED
@@ -122,11 +122,9 @@ def write_ai_files(root: Path, spec: dict[str, Any]) -> list[str]:
122
122
  folders, stubs = assistant_targets(spec)
123
123
  files = spec.get("files") or {}
124
124
 
125
- if spec.get("ai", {}).get("agents_md") == "stub" and "AGENTS.md" not in files:
126
- # The full guide, as R writes it; its skills table points at the first skills folder
127
- skills_dir = folders[0] if folders else ".agents/skills"
128
- _write(root, "AGENTS.md", agents_md(spec, skills_dir, restricted_notice(spec)))
129
- written.append("AGENTS.md")
125
+ guide = spec.get("ai", {}).get("agents_md") == "stub" and "AGENTS.md" not in files
126
+ if guide:
127
+ written.append("AGENTS.md") # Written after the skills, which it describes
130
128
  for stub in stubs:
131
129
  _write(root, stub, "@AGENTS.md\n" if stub == "CLAUDE.md" else pointer_stub(spec["name"]))
132
130
  written.append(stub)
@@ -139,6 +137,11 @@ def write_ai_files(root: Path, spec: dict[str, Any]) -> list[str]:
139
137
  # skill tracks, is left alone and not listed
140
138
  written += install_setup_skills(root, skills, folders)
141
139
 
140
+ if guide:
141
+ # The full guide, as R writes it; its skills table points at the first skills folder
142
+ skills_dir = folders[0] if folders else ".agents/skills"
143
+ _write(root, "AGENTS.md", agents_md(spec, skills_dir, restricted_notice(spec), root))
144
+
142
145
  if spec_sensitive(spec):
143
146
  guard = write_agent_guards(root, spec)
144
147
  if guard:
framework/bootstrap.py CHANGED
@@ -7,9 +7,11 @@ Every step is safe to repeat and none contacts the cloud:
7
7
  variables that are still empty and that the settings read with ``env()``.
8
8
  3. Create the project folders, which git does not carry when they are empty
9
9
  or ignored.
10
- 4. Create ``framework.db``, or add tables a newer version needs.
10
+ 4. Create ``framework.db``, or add tables a newer version needs. An app (Shiny for
11
+ Python or FastAPI) gets it only when something records to it.
11
12
  5. Install the packages from ``uv.lock`` (``uv sync``).
12
13
  6. Install the git hooks enabled in the settings.
14
+ 7. For a project made on Framework Cloud with no project token, say how to link it.
13
15
 
14
16
  R's ``bootstrap()`` follows the same contract, so ``fw bootstrap`` can call
15
17
  either language.
@@ -38,6 +40,7 @@ from framework.hooks import git_hooks_install
38
40
  from framework.project import _settings_in
39
41
  from framework.settings import settings_read
40
42
  from framework.spec.check import spec_check
43
+ from framework.spec.resolve import is_app_type
41
44
 
42
45
  _SECRET_NAME = re.compile(
43
46
  r"PASSWORD|SECRET|TOKEN|ACCESS_KEY|API_KEY|PRIVATE_KEY|CREDENTIAL", re.IGNORECASE
@@ -74,6 +77,21 @@ def _check_spec(root: Path) -> None:
74
77
  )
75
78
 
76
79
 
80
+ def _cloud_link(root: Path, result: BootstrapResult) -> None:
81
+ """A project made on Framework Cloud needs its token, which a clone lacks."""
82
+ from framework.cloud import PROJECT_NOT_LINKED, project_token
83
+
84
+ try:
85
+ spec = json.loads((root / ".framework" / "spec.json").read_text(encoding="utf-8"))
86
+ except (OSError, ValueError):
87
+ return
88
+ source = spec.get("source") if isinstance(spec, dict) else None
89
+ if not isinstance(source, dict) or source.get("origin") != "cloud":
90
+ return
91
+ if project_token(root) is None:
92
+ result.todo.append(PROJECT_NOT_LINKED)
93
+
94
+
77
95
  def _ask(prompt: str) -> str:
78
96
  """Ask on stderr, so stdout carries only results, such as the CLI's printed path."""
79
97
  sys.stderr.write(prompt)
@@ -241,13 +259,15 @@ def bootstrap(
241
259
  _prepare_env(root, settings_file, interactive, result)
242
260
  _create_folders(root, config, result)
243
261
  existed = db.db_path(root).exists()
244
- db.ensure_db(root)
245
- if not existed:
246
- result.done.append("Created framework.db")
262
+ if existed or not is_app_type(config.get("project_type")):
263
+ db.ensure_db(root)
264
+ if not existed:
265
+ result.done.append("Created framework.db")
247
266
  if packages:
248
267
  _restore_packages(root, result)
249
268
  if (root / ".git").exists() and git_hooks_install(settings_file, verbose=False):
250
269
  result.done.append("Installed git hooks")
270
+ _cloud_link(root, result)
251
271
 
252
272
  for step in result.done:
253
273
  inform(f"✓ {step}")
framework/cloud.py CHANGED
@@ -94,6 +94,18 @@ class ProjectServerMissingError(CloudError):
94
94
  """
95
95
 
96
96
 
97
+ class ProjectNotLinkedError(CloudError):
98
+ """A project call found no project token, in the environment or the project's ``.env``.
99
+
100
+ A cloned repository has no ``.env``, so it stays unlinked until ``fw project link``.
101
+ """
102
+
103
+
104
+ PROJECT_NOT_LINKED = (
105
+ "This project isn't linked to Framework Cloud (no FW_PROJECT_TOKEN in the environment "
106
+ "or .env). Link it with: fw project link --from SLUG. fw projects list shows the slugs."
107
+ )
108
+
97
109
  PROJECT_SERVER_MISSING = (
98
110
  "This project's .env has FW_PROJECT_TOKEN but no FW_CLOUD_URL, so it does not say which "
99
111
  "Framework Cloud server issued the token. Add FW_CLOUD_URL=<server> to .env, or pass "
@@ -376,10 +388,7 @@ def project_token(project_dir: str | Path | None = None) -> str | None:
376
388
  def _require_project_token() -> str:
377
389
  token = project_token()
378
390
  if token is None:
379
- raise CloudError(
380
- "No project token found (FW_PROJECT_TOKEN / .env). "
381
- "Create the project with framework.new() while logged in."
382
- )
391
+ raise ProjectNotLinkedError(PROJECT_NOT_LINKED)
383
392
  return token
384
393
 
385
394
 
framework/create.py CHANGED
@@ -31,6 +31,7 @@ from framework.spec.merge import SpecError
31
31
  from framework.spec.resolve import (
32
32
  TYPES,
33
33
  author_normalize,
34
+ is_app_type,
34
35
  spec_core_files,
35
36
  spec_resolve,
36
37
  spec_settings_layout,
@@ -136,7 +137,25 @@ def _sections(spec: Mapping[str, Any]) -> dict[str, Any]:
136
137
  scaffold = spec.get("scaffold") or {}
137
138
  git = spec.get("git") or {}
138
139
  ai = spec.get("ai") or {}
139
- return {
140
+ # An app doesn't call fw.scaffold(), so it gets no seed, theme, or function-folder keys,
141
+ # and no Quarto block
142
+ app = is_app_type(spec.get("type"))
143
+ scaffold_keys: dict[str, Any] = (
144
+ {}
145
+ if app
146
+ else {
147
+ "seed_on_scaffold": scaffold.get("seed_on_scaffold", False),
148
+ "seed": scaffold.get("seed", ""),
149
+ "source_all_functions": scaffold.get("source_all_functions", True),
150
+ # The plot style scaffold() applies, as R's ggplot2 theme
151
+ **{
152
+ k: scaffold[k]
153
+ for k in ("set_theme_on_scaffold", "matplotlib_style")
154
+ if scaffold.get(k) is not None
155
+ },
156
+ }
157
+ )
158
+ sections: dict[str, Any] = {
140
159
  "author": author_normalize(spec.get("author")),
141
160
  "git": {
142
161
  "enabled": git.get("use_git", True),
@@ -150,15 +169,7 @@ def _sections(spec: Mapping[str, Any]) -> dict[str, Any]:
150
169
  "assistants": list(ai.get("assistants") or {}),
151
170
  },
152
171
  "scaffold": {
153
- "seed_on_scaffold": scaffold.get("seed_on_scaffold", False),
154
- "seed": scaffold.get("seed", ""),
155
- "source_all_functions": scaffold.get("source_all_functions", True),
156
- # The plot style scaffold() applies, as R's ggplot2 theme
157
- **{
158
- k: scaffold[k]
159
- for k in ("set_theme_on_scaffold", "matplotlib_style")
160
- if scaffold.get(k) is not None
161
- },
172
+ **scaffold_keys,
162
173
  **({"workflow": scaffold["workflow"]} if scaffold.get("workflow") else {}),
163
174
  "notebook_format": scaffold.get("notebook_format")
164
175
  or ("quarto" if spec_tool_on(spec, "quarto") else "jupyter"),
@@ -166,6 +177,11 @@ def _sections(spec: Mapping[str, Any]) -> dict[str, Any]:
166
177
  "quarto": spec.get("quarto") or {},
167
178
  "connections": spec.get("connections") or {},
168
179
  }
180
+ # Nor does it use the framework database connection the defaults name
181
+ if app:
182
+ del sections["quarto"]
183
+ del sections["connections"]
184
+ return sections
169
185
 
170
186
 
171
187
  def _write_settings(root: Path, spec: Mapping[str, Any]) -> None:
@@ -188,17 +204,22 @@ def _write_settings(root: Path, spec: Mapping[str, Any]) -> None:
188
204
 
189
205
  if spec_settings_layout(spec) == "split":
190
206
  for section in ("author", "git", "ai", "scaffold", "quarto"):
207
+ if section not in sections:
208
+ continue
191
209
  main[section] = f"settings/{section}.yml"
192
210
  _yaml.write(root / "settings" / f"{section}.yml", {section: sections[section]})
193
- main["connections"] = "settings/connections.yml"
194
- _yaml.write(root / "settings/connections.yml", {"connections": sections["connections"]})
211
+ if "connections" in sections:
212
+ main["connections"] = "settings/connections.yml"
213
+ _yaml.write(root / "settings/connections.yml", {"connections": sections["connections"]})
195
214
  main["data"] = "settings/data.yml"
196
215
  _yaml.write(root / "settings/data.yml", {"data": catalog_nest(spec.get("data"))})
197
216
  else:
198
217
  for section in ("author", "quarto", "git", "ai", "scaffold"):
199
- main[section] = sections[section]
218
+ if section in sections:
219
+ main[section] = sections[section]
200
220
  main["data"] = catalog_nest(spec.get("data"))
201
- main["connections"] = sections["connections"]
221
+ if "connections" in sections:
222
+ main["connections"] = sections["connections"]
202
223
 
203
224
  if spec.get("publish") is not None:
204
225
  main["publish"] = spec["publish"]
@@ -382,14 +403,12 @@ def _pyproject(spec: Mapping[str, Any]) -> str:
382
403
  return "\n".join(lines)
383
404
 
384
405
 
385
- def _code_workspace() -> str:
386
- workspace = {
387
- "folders": [{"path": "."}],
388
- "settings": {
389
- "python.defaultInterpreterPath": ".venv/bin/python",
390
- "files.associations": {"*.qmd": "quarto"},
391
- },
392
- }
406
+ def _code_workspace(quarto: bool) -> str:
407
+ settings: dict[str, Any] = {"python.defaultInterpreterPath": ".venv/bin/python"}
408
+ # Quarto files only where the project uses Quarto
409
+ if quarto:
410
+ settings["files.associations"] = {"*.qmd": "quarto"}
411
+ workspace = {"folders": [{"path": "."}], "settings": settings}
393
412
  return json.dumps(workspace, indent=2) + "\n"
394
413
 
395
414
 
@@ -519,12 +538,18 @@ def project_create(
519
538
  _ignore_publish_folders(root, spec)
520
539
  if not bare and (spec.get("ai") or {}).get("enabled"):
521
540
  write_ai_files(root, dict(spec))
522
- if not bare:
541
+ # An app doesn't call fw.scaffold(), which runs scaffold.py
542
+ app = is_app_type(spec["type"])
543
+ if not bare and not app:
523
544
  _write(root, "scaffold.py", _scaffold_py(spec))
524
545
  _write(root, "pyproject.toml", _pyproject(spec))
525
546
  ide = str((spec.get("scaffold") or {}).get("ide") or "").lower()
526
547
  if not bare and ide in WORKSPACE_IDES:
527
- _write(root, f"{kebab_case(spec['name'])}.code-workspace", _code_workspace())
548
+ _write(
549
+ root,
550
+ f"{kebab_case(spec['name'])}.code-workspace",
551
+ _code_workspace(spec_tool_on(spec, "quarto")),
552
+ )
528
553
  if spec["type"] == "presentation":
529
554
  _write(root, "presentation.qmd", _presentation(spec))
530
555
 
@@ -541,7 +566,8 @@ def project_create(
541
566
  spec.get("quarto") or {},
542
567
  spec.get("directories") or {},
543
568
  )
544
- if not bare:
569
+ # An app gets framework.db when something first records to it
570
+ if not bare and not app:
545
571
  db.ensure_db(root)
546
572
  _keep_folders(root)
547
573
  _record(root, spec)
@@ -223,14 +223,16 @@ def _lock_write(root: Path, revision: str, server: str) -> None:
223
223
 
224
224
 
225
225
  def _connection(root: Path) -> tuple[str, str]:
226
- from framework.cloud import CloudError, cloud_server, project_token
226
+ from framework.cloud import (
227
+ PROJECT_NOT_LINKED,
228
+ ProjectNotLinkedError,
229
+ cloud_server,
230
+ project_token,
231
+ )
227
232
 
228
233
  token = project_token(root)
229
234
  if token is None:
230
- raise CloudError(
231
- "Framework Cloud not reached (no project token in FW_PROJECT_TOKEN or the "
232
- "project's .env). Nothing changed."
233
- )
235
+ raise ProjectNotLinkedError(f"{PROJECT_NOT_LINKED} Nothing changed.")
234
236
  return cloud_server(scope="project", project_dir=root).url, token
235
237
 
236
238
 
framework/skill_pull.py CHANGED
@@ -99,12 +99,19 @@ def _cloud_skills(root: Path, notes: list[str]) -> dict[str, Any]:
99
99
 
100
100
  Raises CloudError (or another error) when the setup can't be read.
101
101
  """
102
- from framework.cloud import CloudError, _request, cloud_server, project_token
102
+ from framework.cloud import (
103
+ PROJECT_NOT_LINKED,
104
+ CloudError,
105
+ ProjectNotLinkedError,
106
+ _request,
107
+ cloud_server,
108
+ project_token,
109
+ )
103
110
  from framework.spec.resolve import spec_resolve
104
111
 
105
112
  token = project_token(root)
106
113
  if token is None:
107
- raise CloudError("no project token")
114
+ raise ProjectNotLinkedError(PROJECT_NOT_LINKED)
108
115
  server = cloud_server(scope="project", project_dir=root).url
109
116
  envelope = _request("/api/v1/projects/pull", token, server).json()
110
117
  if not isinstance(envelope, dict) or envelope.get("spec_version") != 1:
@@ -222,7 +229,7 @@ def _pull_offer(root: Path, spec: dict[str, Any]) -> tuple[dict[str, Any], list[
222
229
  """What pull offers: the skills the project's Cloud setup lists (``source`` cloud),
223
230
  else, offline, the package skills for the project type (``source`` package)."""
224
231
  from framework._log import inform
225
- from framework.cloud import CloudError, ProjectServerMissingError
232
+ from framework.cloud import CloudError, ProjectNotLinkedError, ProjectServerMissingError
226
233
  from framework.spec.merge import SpecError
227
234
 
228
235
  notes: list[str] = []
@@ -232,11 +239,14 @@ def _pull_offer(root: Path, spec: dict[str, Any]) -> tuple[dict[str, Any], list[
232
239
  except ProjectServerMissingError:
233
240
  raise
234
241
  except (CloudError, SpecError) as error:
235
- reason = str(error).rstrip(".") or type(error).__name__
236
- inform(
237
- f"Framework Cloud not reached ({reason}); "
238
- "using the package skills for this project type."
239
- )
242
+ if isinstance(error, ProjectNotLinkedError):
243
+ inform(f"{error} Using the package skills for this project type.")
244
+ else:
245
+ reason = str(error).rstrip(".") or type(error).__name__
246
+ inform(
247
+ f"Framework Cloud not reached ({reason}); "
248
+ "using the package skills for this project type."
249
+ )
240
250
  wanted = _package_skills(spec)
241
251
  source = "package"
242
252
  notes = []
framework/spec/resolve.py CHANGED
@@ -79,6 +79,16 @@ def default_settings_layout(type: str) -> str:
79
79
  return "split" if type in ("project", "project_sensitive") else "flat"
80
80
 
81
81
 
82
+ # Framework Cloud app blueprints. Their code doesn't call fw.scaffold(), so they get no
83
+ # scaffold.py, no framework.db at creation, and no scaffold settings.
84
+ APP_PROJECT_TYPES = ("shiny_python", "fastapi")
85
+
86
+
87
+ def is_app_type(type: object) -> bool:
88
+ """Whether a project type is an app (Shiny for Python or FastAPI)."""
89
+ return type in APP_PROJECT_TYPES
90
+
91
+
82
92
  def spec_core_files(spec: Mapping[str, Any]) -> bool:
83
93
  """Whether the project gets .env, scaffold.py, framework.db, and the AI files.
84
94
 
framework/sync_all.py CHANGED
@@ -142,11 +142,16 @@ def _lock_write(root: Path, revision: str, server: str) -> None:
142
142
 
143
143
  def _connection(root: Path) -> tuple[str, str]:
144
144
  """The project's server and token, or CloudError when it has no token."""
145
- from framework.cloud import CloudError, cloud_server, project_token
145
+ from framework.cloud import (
146
+ PROJECT_NOT_LINKED,
147
+ ProjectNotLinkedError,
148
+ cloud_server,
149
+ project_token,
150
+ )
146
151
 
147
152
  token = project_token(root)
148
153
  if token is None:
149
- raise CloudError("no project token in FW_PROJECT_TOKEN or the project's .env")
154
+ raise ProjectNotLinkedError(f"{PROJECT_NOT_LINKED} Nothing changed.")
150
155
  return cloud_server(scope="project", project_dir=root).url, token
151
156
 
152
157
 
@@ -318,12 +323,17 @@ def _partial(function: str, done: str, outcome: dict[str, Any]) -> str:
318
323
 
319
324
  def _setup(root: Path) -> tuple[str, str, dict[str, Any]]:
320
325
  """The project's server, token, and package list; errors change nothing."""
321
- from framework.cloud import CloudError, ProjectServerMissingError, _request
326
+ from framework.cloud import (
327
+ CloudError,
328
+ ProjectNotLinkedError,
329
+ ProjectServerMissingError,
330
+ _request,
331
+ )
322
332
 
323
333
  try:
324
334
  server, token = _connection(root)
325
335
  setup = _request("/api/v1/projects/setup", token, server).json()
326
- except ProjectServerMissingError:
336
+ except (ProjectServerMissingError, ProjectNotLinkedError):
327
337
  raise
328
338
  except CloudError as error:
329
339
  raise _unreachable(error) from error
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: framework-py
3
- Version: 0.1.0.dev31
3
+ Version: 0.1.0.dev32
4
4
  Summary: Structured data science projects: a data catalog, integrity tracking, caching, outputs, and AI guardrails
5
5
  Project-URL: Homepage, https://framework.pub
6
6
  Project-URL: Source, https://github.com/frameworktools/framework-py
@@ -1,6 +1,6 @@
1
1
  framework/__init__.py,sha256=9nN8wRdlk8AgmpRqSk-bLpxXgr6Go42UnRMWQ6szP-A,6898
2
2
  framework/__main__.py,sha256=S0ChmRQnNa9W5_MPXhHnH61Kjr_pNthkeS41eJU1w0U,9093
3
- framework/_agents_md.py,sha256=PSWPJiCUTRirk81sz-Y33qHnqY16HOhHY8pH77ct1ik,11857
3
+ framework/_agents_md.py,sha256=yI_8YYF3D3zqNNZs5skzGQMLTgL9KH35L_Ben_vUY5I,15803
4
4
  framework/_artifacts.py,sha256=XjYOBQOQJuvztUyqwWsc3xc1qJ5o4O5XpCW49WN548k,55807
5
5
  framework/_backups.py,sha256=ra1DhGcIbIXB0zqDFVFJ3yPEjmXpYKFX-fjV01b9Rtg,1958
6
6
  framework/_bayesian.py,sha256=Yx8deM_LWsfPPM8n3rX7b1R9L1qcdeaDU2aUIZZyhB4,23675
@@ -11,7 +11,7 @@ framework/_gitignore.py,sha256=U4bkdGwXzt-IfGtoH2K5-Yg43I51w45rflRxQLcWqPQ,6628
11
11
  framework/_identifiers.py,sha256=1jarqO2hG9E-GAv8rCKfc-f27NKLJFtAligUj7beEak,5951
12
12
  framework/_keychain.py,sha256=9QW8dFDhgy0knWCCu9blttIe_nCG0UhdY77wrVa1h6M,2798
13
13
  framework/_log.py,sha256=ZgLaWbjiXK7Cybd_mWGURb4OOGaAAYsB6NkR15W3nnk,1160
14
- framework/_pages.py,sha256=DFVXarSAYu7V_O3o1hjzYvI5Qa59KqG4GPnDvNTztrA,12561
14
+ framework/_pages.py,sha256=gsab_wdBXTh_ctQnq1bgJYKCEBC1cbkUy6tDFyz1iWM,12673
15
15
  framework/_paths.py,sha256=tek8DAVJBkWHcumkabwMTp-APadaTzHe8IgHi2l7xpw,3456
16
16
  framework/_private.py,sha256=wc3W6WivkFsfGoR6AJFS4khy17nLzC9zQaPrW_kMVLE,14641
17
17
  framework/_secretservice.py,sha256=zv5UvEekQic466qRmVpLG_hfEkisikHfab8e6kyzS2k,2450
@@ -23,17 +23,17 @@ framework/_time.py,sha256=mv-BS3NjOo0hr6bwYRhUBY-3sG6SJmzaboaMD62QcJw,306
23
23
  framework/_wincred.py,sha256=oJGS37Dcw_PZVmiAGRu4H_lhcOC5-FqGGYfxVUGPPmU,3891
24
24
  framework/_yaml.py,sha256=eYqL4BsjyavrnJGxh88YziZtTgtWDzfeVAtA_Ru78wc,6200
25
25
  framework/adopt.py,sha256=oOfpfwo8ehTMDthctihGHi11sEg8StQ3R_85Bq-oq8Y,33441
26
- framework/ai.py,sha256=2v7XWN_B4En2PHFs83EikkQAfBrb6IH3lmxSQt7Cpr0,8753
27
- framework/bootstrap.py,sha256=mYlD1BG9KaG9PAIHlw3l6677fJYwQdtih95W9Rqmnho,9687
26
+ framework/ai.py,sha256=QTPbzGSGneRngZd9l7D7nJIUCraG7CWgz-v7BLbLiRg,8840
27
+ framework/bootstrap.py,sha256=1UaLpzui-wJ4D6-b8-YN2-e4eMPtavVKsmnj6scoWWQ,10606
28
28
  framework/cache.py,sha256=z8Zaem5Q7dsAghuX9CgK_j0vhX5dDlRw7fl9f-CF3eA,17440
29
29
  framework/catalog.py,sha256=sl4V1judSCVoa2LYLXeQdDhWdsONTC_5s2_fpyPylto,13202
30
- framework/cloud.py,sha256=y4w5euumzkNXOfC9q8v7FVW5yHEO7QORXC3D2BlirMI,67843
30
+ framework/cloud.py,sha256=juhTsfhiinvxwnpScEJoIDjw_Ytdk6njCk26WhLmqFk,68171
31
31
  framework/config_home.py,sha256=iSb0VuENgNOSnsZ_v53xFqjRiGgrB7OzZbHbyDOqKzs,8265
32
32
  framework/connections.py,sha256=99JqrNAi2zBpNYyxLV6SYj-NAJjh56pYh9jaMSYOHCU,32742
33
33
  framework/console.py,sha256=zQ0LuFDcxe1W1kuc5E1bJ03h8d3cvwFoqDT8dAJQyN0,1267
34
- framework/create.py,sha256=dkq5PsGNoqit0eYhvNO1-O3t0DUi9SFiawbVWdkZpIc,53696
34
+ framework/create.py,sha256=KSODHvnRFrSha79LH-0e4o1y_3e1ZjbTrjCDzQbhbYk,54728
35
35
  framework/data.py,sha256=HpiRl5qTk1o9G-XXNDgsWhNOgXlyYegv8-8KDz-HyPA,40853
36
- framework/data_registry.py,sha256=2hbXsoY9IF5Zj6lkiTE2RO2c5j2Z2vXKm2iTN7FdsQk,22499
36
+ framework/data_registry.py,sha256=QrFki_-zd7gF4afOesYPAn7xZEvnhYolhxtz_0bsaSA,22477
37
37
  framework/db.py,sha256=UYEUCvk4vGytBkmdNTUxRpYPtoFSDHwTpgpfWFw31aE,8522
38
38
  framework/display.py,sha256=0FuKUt67uf5h1WjD4bwzoruc2XAN4y_j3mz_f5FskhE,5334
39
39
  framework/dotenv.py,sha256=BYSF6YE92jXO7dqnaR-857XtZNYOx7FTuxCcCeIZ_yw,6172
@@ -53,11 +53,11 @@ framework/scaffold.py,sha256=ku_rFPcOcV77ZxCJSG1tdxAqJhriuTuA6j2jOmjBaIs,15958
53
53
  framework/scratch.py,sha256=idxthUR5BIMX7FIGS7KzIuhOrO3-HKLbBsV8It3EEE4,3890
54
54
  framework/security.py,sha256=-x66bSIIE_xOzkTf5Ojt7xIECKuAIpKVJZ5TtIGrwys,51147
55
55
  framework/settings.py,sha256=Sb2YyE53aYLWPj423P-pQVCvRpLsiHydgZh2K0luTQQ,23893
56
- framework/skill_pull.py,sha256=DRd2HVpIjCOIHEEhFBtJvhlKj5VrE4yGyIaWLScgANU,75664
56
+ framework/skill_pull.py,sha256=BsprrVhv4khrXQJupAChLi_s0qJLmA0KBrfrTD6A_9k,75964
57
57
  framework/skill_sync.py,sha256=2xPcEIN_ftjX4QpA4ZkRzjFHS9rkoIHcnKPO59eKr8U,35813
58
58
  framework/snippets.py,sha256=J8j36YqHgG-HhWlhJ9RmJK-qwVGOOSOOd1pNakJyuVE,26481
59
59
  framework/storage.py,sha256=Haz8CBXrz2CCqGHOVgHKC3mUUwobnod2SanU759lK7c,56115
60
- framework/sync_all.py,sha256=3Rz2hg7-HiIq8Vfb7Z8Opnlvi3OGnIvCUmPHz0pWpTE,36605
60
+ framework/sync_all.py,sha256=hcp-EYI8OVV9l40S4S8Iu0-2k7CUbF6faBcrRD3Up3M,36757
61
61
  framework/upgrade.py,sha256=vMtL9_04LgJ4AHj6EXg5PmV3n699XvFNj820Auqa0hM,66546
62
62
  framework/_assets/init.sql,sha256=-aIiuIcCmBniGKq-CHdRtUiV9e_CLXoqxxd05snmgOE,1156
63
63
  framework/_assets/adopt/rules.json,sha256=Ao_8reCfxohbF27hzVBjXJeMUP2E9MzlLMqrLutv41o,7603
@@ -113,7 +113,7 @@ framework/_assets/workflows/scripts.json,sha256=-Lep7gb3kws4F3uIgCtaqpUuKJREM3er
113
113
  framework/spec/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
114
  framework/spec/check.py,sha256=v4TPrpu_if2QYoyJLn7RLRwvobnxf8nnbFtYTQlJXeg,14463
115
115
  framework/spec/merge.py,sha256=gvauBNsFJYe_1J3sO9eF7PSt7mii8ONmnPe8qmyOaGg,6303
116
- framework/spec/resolve.py,sha256=gyAewGbMcdTbh4feUp6DEj_D9wPBDzRiDC8PTOpyp6Q,12590
116
+ framework/spec/resolve.py,sha256=UZe6f_21zD7_IoNVZqOkCr3DxG-Hqrr_E0RUXjVAS1k,12950
117
117
  framework/templates/defaults.yml,sha256=OPNe85BXmZ1G8CN-RZ62Ku-_uLtx5yC7nqltBL224kE,3933
118
118
  framework/templates/reader.html,sha256=SBw3I3rRMdAyoBosMVuZ9Yp177P11CoxIAaG0OOuvQg,19772
119
119
  framework/templates/skill-history.json,sha256=adHWF6I_ZGvocZs45DY55xH_OtLfBqjDs0muZcZ3NFM,2415
@@ -142,7 +142,7 @@ framework/templates/stubs/notebook-default.qmd,sha256=8Js1S2BcHYeQWmJS-kt31gBvIj
142
142
  framework/templates/stubs/notebook-minimal.qmd,sha256=2U2k8judffhrh_6m6r6OAbQBCYEtViAjeKRBqBYCJTM,178
143
143
  framework/templates/stubs/notebook-revealjs.qmd,sha256=_ztT_gHoudpB5DIjlbvtB5zQ8163DeV8xbWcT-HgJrI,409
144
144
  framework/templates/stubs/script-default.py,sha256=vbWqgW0_rHot17mQC3tYb92g_9L-cbTOeL3y99BRrSk,216
145
- framework_py-0.1.0.dev31.dist-info/METADATA,sha256=eFEtT2ubGRkRsSWYeh9C3Xe2_yLuSlcSG3HGCyl50BQ,5143
146
- framework_py-0.1.0.dev31.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
147
- framework_py-0.1.0.dev31.dist-info/licenses/LICENSE,sha256=giOOgSwALkZimC7uhLZQK8Untez641bLW1-2-Cjvmq0,1072
148
- framework_py-0.1.0.dev31.dist-info/RECORD,,
145
+ framework_py-0.1.0.dev32.dist-info/METADATA,sha256=CpgnkL5A1C0o0M_ttMUnoUp9mONllnbc3Hjq33-mbns,5143
146
+ framework_py-0.1.0.dev32.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
147
+ framework_py-0.1.0.dev32.dist-info/licenses/LICENSE,sha256=giOOgSwALkZimC7uhLZQK8Untez641bLW1-2-Cjvmq0,1072
148
+ framework_py-0.1.0.dev32.dist-info/RECORD,,