@inneranimalmedia/agentsam-sdk 2.4.1 → 2.6.0

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 (233) hide show
  1. package/AGENTSAM.md +55 -0
  2. package/README.md +17 -12
  3. package/bin/agentsam +2 -0
  4. package/docs/AGENTSAM_ASTRA_OPENAI_INTEGRATION.md +1363 -0
  5. package/docs/AGENTSAM_WORKBENCH.md +30 -0
  6. package/docs/AUTH_IDENTITY_CONTRACT.md +52 -0
  7. package/docs/CAPABILITIES.md +5 -3
  8. package/docs/CLI_SHELL.md +167 -80
  9. package/docs/CMS_STUDIO.md +101 -0
  10. package/docs/CONTEXT.md +170 -0
  11. package/docs/LOCAL_OLLAMA.md +58 -0
  12. package/docs/MERKLE.md +19 -19
  13. package/docs/PORTABLE_CONTEXT.md +4 -3
  14. package/docs/PROJECT_CONFIG.md +72 -0
  15. package/docs/RELEASES.md +35 -2
  16. package/docs/REPOSITORY_INTELLIGENCE.md +1 -1
  17. package/docs/REPOSITORY_KNOWLEDGE.md +114 -0
  18. package/docs/SDK_WORKER.md +86 -0
  19. package/docs/SECURITY.md +59 -22
  20. package/docs/client-cms-editor.md +15 -0
  21. package/docs/local-studio/WORKMODE_DONOR_NOTES.md +485 -0
  22. package/package.json +35 -10
  23. package/packages/connectors/cloudflare/package.json +10 -0
  24. package/packages/connectors/cloudflare/src/index.js +127 -0
  25. package/packages/connectors/cloudflare/src/owner.js +76 -0
  26. package/packages/connectors/cloudflare/src/routes.js +223 -0
  27. package/packages/connectors/cloudflare/src/vault.js +80 -0
  28. package/packages/connectors/cloudflare/tests/connector.test.mjs +44 -0
  29. package/packages/identity/package.json +10 -1
  30. package/packages/identity/src/contracts/auth-config.js +109 -0
  31. package/packages/identity/src/index.js +1 -0
  32. package/packages/identity/src/oauth/README.md +2 -2
  33. package/packages/identity/src/oauth/credentials.js +11 -4
  34. package/packages/identity/src/oauth/iam-platform.js +3 -3
  35. package/packages/identity/src/providers/iam/index.js +7 -7
  36. package/packages/identity/src/providers/iam/oauth.js +6 -4
  37. package/packages/identity/src/providers/iam/profile.js +5 -5
  38. package/packages/identity/tests/auth-config.test.mjs +61 -0
  39. package/packages/identity/tests/oauth-credentials.test.mjs +13 -2
  40. package/protocol/FILEMETA_V1.md +95 -0
  41. package/protocol/INSPECT_VIEWS_V1.md +40 -0
  42. package/protocol/MERKLE_PERSISTENCE_V1.md +50 -0
  43. package/protocol/MERKLE_V1.md +3 -1
  44. package/protocol/README.md +1 -0
  45. package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +19 -0
  46. package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +13 -0
  47. package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +19 -0
  48. package/protocol/capabilities/manifest.json +79 -3
  49. package/protocol/capabilities/repository-snapshot.schema.json +1 -0
  50. package/protocol/context/context-budget.schema.json +36 -0
  51. package/protocol/context/context-item.schema.json +19 -0
  52. package/protocol/context/resolved-context-pack.schema.json +47 -0
  53. package/protocol/context/result-policy.schema.json +17 -0
  54. package/protocol/knowledge/context-pack.schema.json +33 -0
  55. package/protocol/knowledge/retrieval-query.schema.json +68 -13
  56. package/protocol/models/README.md +373 -0
  57. package/protocol/models/model-inventory-v2.schema.json +212 -0
  58. package/python/README.md +15 -7
  59. package/python/agentsam_sdk/cli.py +0 -21
  60. package/python/agentsam_sdk/tui/README.md +17 -12
  61. package/python/agentsam_sdk/tui/bootstrap.py +2 -2
  62. package/python/agentsam_sdk/tui/demo.py +25 -10
  63. package/python/agentsam_sdk/tui/onboarding.py +208 -0
  64. package/python/tests/test_tui_cli.py +7 -6
  65. package/skills/README.md +21 -0
  66. package/skills/agentsam-app-fundamentals/SKILL.md +165 -0
  67. package/skills/agentsam-app-fundamentals/references/graphs-contracts-ast-merkle.md +89 -0
  68. package/skills/agentsam-app-fundamentals/references/trust-credentials-and-destinations.md +99 -0
  69. package/skills/agentsam-cloudflare-workers/SKILL.md +53 -0
  70. package/skills/agentsam-cloudflare-workers/references/cpu-profiling.md +16 -0
  71. package/skills/agentsam-cloudflare-workers/references/errors-and-observability.md +29 -0
  72. package/skills/agentsam-cloudflare-workers/references/wrangler-native-map.md +28 -0
  73. package/skills/agentsam-jr-dev/SKILL.md +232 -0
  74. package/skills/agentsam-jr-dev/references/real-application-logic.md +156 -0
  75. package/skills/agentsam-jr-dev/references/web-application-fundamentals.md +240 -0
  76. package/skills/agentsam-progression-guard/SKILL.md +197 -0
  77. package/skills/agentsam-progression-guard/references/checkpoint-chain.md +111 -0
  78. package/skills/agentsam-progression-guard/references/hooks-operational-io.md +96 -0
  79. package/skills/catalog.json +71 -0
  80. package/src/agent/capability-adapter.js +25 -13
  81. package/src/agent/index.js +1 -0
  82. package/src/agent/responses-runner.js +325 -0
  83. package/src/capabilities/index.js +7 -0
  84. package/src/capabilities/repository-snapshot-view.js +238 -0
  85. package/src/capabilities/repository-snapshot.js +28 -14
  86. package/src/cli.js +198 -76
  87. package/src/cloudflare/cpu-profile.js +115 -0
  88. package/src/cloudflare/index.js +14 -0
  89. package/src/cloudflare/wrangler.js +132 -0
  90. package/src/commands/account-auth.js +47 -0
  91. package/src/commands/cloudflare.js +58 -0
  92. package/src/commands/connections.js +93 -0
  93. package/src/commands/context-economics.js +114 -0
  94. package/src/commands/context.js +14 -2
  95. package/src/commands/db.js +4 -7
  96. package/src/commands/deploy.js +54 -32
  97. package/src/commands/eval.js +63 -0
  98. package/src/commands/interactive.js +18 -0
  99. package/src/commands/knowledge.js +27 -4
  100. package/src/commands/merkle-persist.js +118 -0
  101. package/src/commands/merkle.js +32 -17
  102. package/src/commands/models.js +152 -0
  103. package/src/commands/ollama.js +259 -0
  104. package/src/commands/preferences.js +144 -0
  105. package/src/commands/product.js +86 -16
  106. package/src/commands/resume.js +67 -0
  107. package/src/commands/security.js +8 -6
  108. package/src/commands/shell.js +405 -100
  109. package/src/commands/skills.js +66 -0
  110. package/src/commands/start-local.js +1 -1
  111. package/src/commands/tunnel.js +5 -4
  112. package/src/commands/whoami.js +86 -0
  113. package/src/context/budget.js +120 -0
  114. package/src/context/compact.js +28 -0
  115. package/src/context/index.js +7 -0
  116. package/src/context/rehydrate.js +35 -0
  117. package/src/context/resolve.js +116 -0
  118. package/src/context/result-policy.js +66 -0
  119. package/src/errors/diagnostic.js +160 -0
  120. package/src/errors/index.js +9 -0
  121. package/src/eval/context.js +191 -0
  122. package/src/eval/index.js +1 -0
  123. package/src/index.js +70 -0
  124. package/src/indexing/execution-boundary.js +144 -0
  125. package/src/indexing/index.js +8 -0
  126. package/src/indexing/provider.js +41 -0
  127. package/src/knowledge/config.js +2 -2
  128. package/src/knowledge/context-pack.js +12 -1
  129. package/src/knowledge/contracts.js +9 -4
  130. package/src/knowledge/engine.js +7 -3
  131. package/src/knowledge/service/server.js +1 -1
  132. package/src/lib/account-session.js +98 -0
  133. package/src/lib/agent-instructions.js +73 -0
  134. package/src/lib/auth.js +4 -0
  135. package/src/lib/bridge-client.js +7 -5
  136. package/src/lib/cli-preferences.js +78 -0
  137. package/src/lib/core-client.js +8 -8
  138. package/src/lib/deploy/git-guard.js +69 -0
  139. package/src/lib/deploy/health.js +57 -0
  140. package/src/lib/deploy/local-studio.js +283 -0
  141. package/src/lib/deploy/secret-scan.js +65 -0
  142. package/src/lib/deploy-receipt/index.js +5 -2
  143. package/src/lib/detect-context.js +6 -5
  144. package/src/lib/execution-approvals.js +59 -0
  145. package/src/lib/identity-scaffold.js +1 -1
  146. package/src/lib/local-scaffold.js +35 -33
  147. package/src/lib/local-sessions.js +127 -0
  148. package/src/lib/local-status.js +9 -17
  149. package/src/lib/merkle/cloudflare-persistence.js +321 -0
  150. package/src/lib/merkle/filemeta.js +43 -0
  151. package/src/lib/merkle/git-ignore.js +24 -0
  152. package/src/lib/merkle/hash.js +1 -0
  153. package/src/lib/merkle/index.js +22 -0
  154. package/src/lib/merkle/persistence.js +72 -0
  155. package/src/lib/merkle/semantic.js +359 -0
  156. package/src/lib/merkle/snapshot.js +9 -3
  157. package/src/lib/merkle/tree.js +11 -6
  158. package/src/lib/project-config.js +227 -0
  159. package/src/lib/project-rules.js +68 -0
  160. package/src/lib/provider-credentials.js +83 -0
  161. package/src/lib/save-sdk-token.js +1 -1
  162. package/src/lib/scaffold/templates/worker-api/index.js +101 -20
  163. package/src/lib/scaffold/wizards/worker-api.js +27 -11
  164. package/src/lib/slash-commands.js +22 -15
  165. package/src/lib/tools.js +11 -5
  166. package/src/models/catalog.js +135 -0
  167. package/src/models/index.js +7 -0
  168. package/src/providers/index.js +5 -0
  169. package/src/providers/openai-responses.js +275 -0
  170. package/src/security/index.js +1 -0
  171. package/src/security/inventory.js +4 -1
  172. package/src/security/process.js +35 -9
  173. package/src/security/render.js +27 -5
  174. package/src/security/scan.js +24 -9
  175. package/src/security/trust-boundary.js +24 -0
  176. package/src/skills/index.js +64 -0
  177. package/src/telemetry/contracts.js +203 -0
  178. package/src/telemetry/events.js +48 -0
  179. package/src/telemetry/index.js +8 -0
  180. package/src/tools/hydrate.js +35 -0
  181. package/src/tools/index.js +2 -0
  182. package/src/tools/search.js +70 -0
  183. package/src/ui/ansi.js +1 -1
  184. package/src/ui/boot.js +54 -0
  185. package/src/ui/merkle/render.js +1 -0
  186. package/src/ui/runtime-activity.js +192 -0
  187. package/src/ui/theme.js +19 -18
  188. package/test/account-session.test.mjs +36 -0
  189. package/test/app-building-skills.test.mjs +61 -0
  190. package/test/apps-scaffold-contract.test.mjs +56 -0
  191. package/test/capabilities.test.mjs +53 -4
  192. package/test/cli-preferences.test.mjs +46 -0
  193. package/test/cloudflare-connector.test.mjs +96 -0
  194. package/test/cloudflare-runtime.test.mjs +75 -0
  195. package/test/context.test.mjs +144 -0
  196. package/test/deploy-health-scan.test.mjs +67 -0
  197. package/test/error-diagnostics.test.mjs +59 -0
  198. package/test/eval-context.test.mjs +37 -0
  199. package/test/execution-approvals.test.mjs +27 -0
  200. package/test/indexing-provider.test.mjs +29 -0
  201. package/test/jr-dev-skill.test.mjs +26 -0
  202. package/test/knowledge-context-pack.test.mjs +19 -0
  203. package/test/knowledge.test.mjs +1 -1
  204. package/test/local-sessions.test.mjs +42 -0
  205. package/test/local-studio-deploy.test.mjs +83 -0
  206. package/test/merkle-persistence.test.mjs +91 -0
  207. package/test/merkle.test.mjs +77 -3
  208. package/test/model-catalog.test.mjs +43 -0
  209. package/test/models.test.mjs +51 -0
  210. package/test/npm10-lock.test.mjs +29 -0
  211. package/test/ollama.test.mjs +94 -0
  212. package/test/openai-responses.test.mjs +95 -0
  213. package/test/project-config.test.mjs +81 -0
  214. package/test/project-rules.test.mjs +44 -0
  215. package/test/provider-credentials.test.mjs +52 -0
  216. package/test/rehydrate.test.mjs +25 -0
  217. package/test/release-hygiene.test.mjs +34 -0
  218. package/test/repository-snapshot-view.test.mjs +112 -0
  219. package/test/responses-runner.test.mjs +148 -0
  220. package/test/runtime-activity.test.mjs +98 -0
  221. package/test/sdk-worker-contract.test.mjs +68 -0
  222. package/test/security.test.mjs +46 -0
  223. package/test/shell.test.mjs +55 -21
  224. package/test/skills.test.mjs +22 -0
  225. package/test/smoke.mjs +5 -2
  226. package/test/telemetry.test.mjs +79 -0
  227. package/test/theme-portability.test.mjs +14 -0
  228. package/test/tools-search.test.mjs +40 -0
  229. package/test/whoami-resume.test.mjs +56 -0
  230. package/examples/agentsam-tui-ansi.mjs +0 -149
  231. package/src/commands/tui.js +0 -120
  232. package/src/ui/splash-xterm.js +0 -290
  233. package/src/ui/splash.js +0 -426
@@ -1,22 +1,27 @@
1
- # Agent Sam TUI
1
+ # Agent Sam Rich renderer lab
2
2
 
3
- Optional terminal presentation for the Python `agentsam` CLI.
3
+ Internal high-fidelity terminal presentation experiments for Agent Sam. This package is a renderer/design surface, not a public user command, tool registry, execution adapter, workflow, or permission boundary.
4
4
 
5
- **Ownership:** UI only. This package is not an Agent Sam tool, tool registry,
6
- execution adapter, workflow, or permission boundary. It renders state produced
7
- by real SDK commands.
5
+ The installed npm CLI owns the product lifecycle. Users type `agentsam`; they do not select ANSI versus Rich.
8
6
 
9
- Migrated from `inneranimalmedia/tools_py/agentsam_tui` so the product repo no
10
- longer presents a TUI prototype as a reusable runtime tool.
7
+ From the SDK repository, preview scenes with:
8
+
9
+ ```bash
10
+ npm run ui:preview -- tour
11
+ npm run ui:preview -- boot
12
+ npm run ui:preview -- setup
13
+ npm run ui:preview -- thinking
14
+ npm run ui:preview -- ready
15
+ ```
16
+
17
+ The Node script selects the renderer internally. For direct Python renderer work:
11
18
 
12
19
  ```bash
13
20
  cd python
14
21
  pip install -e '.[tui]'
15
- agentsam tui
16
- agentsam tui --scene dashboard
17
- agentsam tui --check
22
+ PYTHONPATH=. python -m agentsam_sdk.tui --scene dashboard --check
18
23
  ```
19
24
 
20
- The core Python SDK remains stdlib-only; `rich` is an optional extra.
25
+ The core Python SDK remains stdlib-only; `rich` is an optional extra. The intended product progression is small: **brand/boot → detect project context → first-run keyboard choices when needed → quiet ready prompt**.
21
26
 
22
- For a zero-dependency Node/ANSI rendering reference, see `../../../../examples/agentsam-tui-ansi.mjs`.
27
+ For the zero-dependency Node/ANSI animation lab, see `../../../../scripts/internal/ansi-ui-preview.mjs`.
@@ -2,9 +2,9 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  _MISSING = (
5
- "Python package 'rich' is required for the Agent Sam TUI.\n"
5
+ "Python package 'rich' is required for the internal Agent Sam Rich preview.\n"
6
6
  " pip install -e './python[tui]'\n"
7
- " agentsam tui\n"
7
+ " python -m agentsam_sdk.tui --scene boot\n"
8
8
  )
9
9
 
10
10
 
@@ -1,11 +1,15 @@
1
- """Agent Sam Rich TUI demos — six reusable terminal patterns.
1
+ """Internal Agent Sam Rich render previews.
2
2
 
3
- Run from repo root:
3
+ Run from repo root through the SDK design lane:
4
+
5
+ npm run ui:preview -- tour
6
+ npm run ui:preview -- boot
7
+ npm run ui:preview -- thinking
8
+
9
+ Or invoke the renderer module directly after installing the optional Rich extra:
4
10
 
5
11
  pip install -e './python[tui]'
6
- agentsam tui
7
- agentsam tui --scene dashboard
8
- agentsam tui --check
12
+ PYTHONPATH=python python -m agentsam_sdk.tui --scene dashboard --check
9
13
  """
10
14
 
11
15
  from __future__ import annotations
@@ -33,6 +37,7 @@ from rich.text import Text
33
37
 
34
38
  from .frames import COMET, THINK, WALKER
35
39
  from .theme import CYAN
40
+ from .onboarding import preview_boot, preview_ready, preview_setup, preview_thinking, preview_tour
36
41
  from .widgets import (
37
42
  IndexDashboard,
38
43
  IndexState,
@@ -45,7 +50,8 @@ from .widgets import (
45
50
  tty_hint,
46
51
  )
47
52
 
48
- SCENES = ("card", "progress", "dashboard", "events", "sprite", "logs", "ship")
53
+ SCENES = ("boot", "setup", "ready", "thinking", "card", "progress", "dashboard", "events", "sprite", "logs", "ship")
54
+ PREVIEW_SCENES = ("tour", *SCENES)
49
55
 
50
56
 
51
57
  def _sleep(seconds: float, *, fast: bool) -> None:
@@ -182,7 +188,7 @@ def demo_ship_lane(console, *, ticks: int = 24, fast: bool = False) -> None:
182
188
  steps = [
183
189
  ("validate", "python tests"),
184
190
  ("package", "agentsam-sdk"),
185
- ("cli", "agentsam tui"),
191
+ ("cli", "internal UI preview"),
186
192
  ("run", "operator action"),
187
193
  ("receipt", "status captured"),
188
194
  ("done", "command complete"),
@@ -219,6 +225,10 @@ def demo_ship_lane(console, *, ticks: int = 24, fast: bool = False) -> None:
219
225
 
220
226
 
221
227
  SCENE_FNS = {
228
+ "boot": preview_boot,
229
+ "setup": preview_setup,
230
+ "ready": preview_ready,
231
+ "thinking": preview_thinking,
222
232
  "card": demo_status_card,
223
233
  "progress": demo_progress,
224
234
  "dashboard": demo_live_dashboard,
@@ -230,11 +240,16 @@ SCENE_FNS = {
230
240
 
231
241
 
232
242
  def run_scene(name: str, console, *, ticks: int, fast: bool) -> None:
243
+ if name == "tour":
244
+ console.print()
245
+ console.print(Rule("[bold iam.cyan]guided CLI tour[/]"))
246
+ preview_tour(console, fast=fast, ticks=ticks)
247
+ return
233
248
  fn = SCENE_FNS[name]
234
249
  console.print()
235
250
  console.print(Rule(f"[bold iam.cyan]{name}[/]"))
236
251
  kwargs = {"fast": fast}
237
- if name in {"progress", "dashboard", "sprite", "ship"}:
252
+ if name in {"boot", "setup", "ready", "thinking", "progress", "dashboard", "sprite", "ship"}:
238
253
  kwargs["ticks"] = ticks
239
254
  fn(console, **kwargs)
240
255
 
@@ -246,7 +261,7 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
246
261
  )
247
262
  parser.add_argument(
248
263
  "--scene",
249
- choices=("all", *SCENES),
264
+ choices=("all", *PREVIEW_SCENES),
250
265
  default="all",
251
266
  help="Which demo to run (default: all)",
252
267
  )
@@ -283,7 +298,7 @@ def main(argv: list[str] | None = None) -> int:
283
298
  run_scene(name, console, ticks=ticks, fast=fast)
284
299
 
285
300
  console.print()
286
- console.print("[bold iam.green]Done.[/] Next: wire these renderables into real SDK CLI commands.")
301
+ console.print("[bold iam.green]Preview complete.[/] Internal renderer lab; bare `agentsam` owns the product boot flow.")
287
302
  return 0
288
303
 
289
304
 
@@ -0,0 +1,208 @@
1
+ """Preview-only startup and onboarding compositions for the Agent Sam CLI.
2
+
3
+ These scenes intentionally do not perform setup or mutate local state. They let us
4
+ judge the terminal UX before wiring the same presentation primitives into
5
+ `agentsam`, `agentsam init`, and `agentsam shell`.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import time
10
+ from dataclasses import dataclass
11
+
12
+ from .bootstrap import require_rich
13
+
14
+ require_rich()
15
+
16
+ from rich.align import Align
17
+ from rich.console import Group
18
+ from rich.live import Live
19
+ from rich.panel import Panel
20
+ from rich.table import Table
21
+ from rich.text import Text
22
+
23
+ from .frames import BRAILLE, MOON, THINK
24
+
25
+
26
+ @dataclass(frozen=True)
27
+ class PreviewContext:
28
+ project: str = "agentsam-sdk"
29
+ cwd: str = "~/agentsam-sdk"
30
+ shell: str = "zsh"
31
+ platform: str = "macOS"
32
+ version: str = "2.5.0"
33
+
34
+
35
+ def _sleep(seconds: float, *, fast: bool) -> None:
36
+ time.sleep(0.0 if fast else seconds)
37
+
38
+
39
+ def _brand_header(ctx: PreviewContext, *, tick: int = 0) -> Group:
40
+ pulse = MOON[tick % len(MOON)]
41
+ title = Text()
42
+ title.append(" Agent Sam", style="bold iam.heading")
43
+ title.append(f" {pulse}", style="bold iam.cyan")
44
+ meta = Text(
45
+ f" SDK {ctx.version} · {ctx.platform} · {ctx.shell}",
46
+ style="iam.muted",
47
+ )
48
+ return Group(title, meta)
49
+
50
+
51
+ def _boot_card(ctx: PreviewContext, *, tick: int, phase: int) -> Panel:
52
+ states = (
53
+ ("environment", "Detecting terminal", phase >= 1),
54
+ ("project", ctx.project, phase >= 2),
55
+ ("shell", f"{ctx.shell} · {ctx.cwd}", phase >= 3),
56
+ ("runtime", "Local-first", phase >= 4),
57
+ )
58
+ rows = Table.grid(padding=(0, 2))
59
+ rows.add_column(style="iam.muted", justify="right", min_width=12)
60
+ rows.add_column(min_width=34)
61
+ for index, (label, value, ready) in enumerate(states):
62
+ if ready:
63
+ mark = "[iam.green]✓[/]"
64
+ body = f"[iam.text]{value}[/]"
65
+ elif index == phase:
66
+ mark = f"[bold iam.cyan]{BRAILLE[tick % len(BRAILLE)]}[/]"
67
+ body = f"[iam.muted]{value}[/]"
68
+ else:
69
+ mark = "[dim]·[/]"
70
+ body = f"[dim]{value}[/]"
71
+ rows.add_row(label, f"{mark} {body}")
72
+ return Panel(
73
+ Group(_brand_header(ctx, tick=tick), Text(""), rows),
74
+ border_style="iam.cyan",
75
+ padding=(1, 2),
76
+ subtitle="[iam.muted]starting locally — no cloud required[/]",
77
+ width=62,
78
+ )
79
+
80
+
81
+ def preview_boot(console, *, fast: bool = False, ticks: int = 24) -> None:
82
+ """Compact cold-start sequence: identity, environment, cwd, then handoff."""
83
+ ctx = PreviewContext()
84
+ frames = max(8, min(ticks, 28))
85
+ with Live(console=console, refresh_per_second=18, transient=False) as live:
86
+ for i in range(frames):
87
+ phase = min(4, i // max(1, frames // 5))
88
+ live.update(_boot_card(ctx, tick=i, phase=phase))
89
+ _sleep(0.055, fast=fast)
90
+ live.update(_boot_card(ctx, tick=frames, phase=4))
91
+ console.print(" [iam.green]✓[/] Ready [iam.muted]· type [bold]/help[/] when you want the map[/]")
92
+
93
+
94
+ def _setup_panel(step: int, tick: int, ctx: PreviewContext) -> Panel:
95
+ steps = [
96
+ ("Project", "Use this folder", ctx.cwd),
97
+ ("Local runtime", "Keep execution on this machine", "recommended"),
98
+ ("Terminal", "Use your existing shell", ctx.shell),
99
+ ("Agent", "Enable Agent Sam when you need it", "optional"),
100
+ ("Done", "Open the guided shell", "agentsam shell"),
101
+ ]
102
+ grid = Table.grid(padding=(0, 2))
103
+ grid.add_column(width=3, justify="center")
104
+ grid.add_column(min_width=15)
105
+ grid.add_column(min_width=29)
106
+ for i, (label, description, answer) in enumerate(steps):
107
+ if i < step:
108
+ marker = "[iam.green]✓[/]"
109
+ label_style = "iam.text"
110
+ detail = f"[iam.muted]{answer}[/]"
111
+ elif i == step:
112
+ marker = f"[bold iam.cyan]{MOON[tick % len(MOON)]}[/]"
113
+ label_style = "bold iam.heading"
114
+ detail = f"[iam.cyan]{description}[/]\n[dim] {answer}[/]"
115
+ else:
116
+ marker = "[dim]○[/]"
117
+ label_style = "dim"
118
+ detail = f"[dim]{description}[/]"
119
+ grid.add_row(marker, f"[{label_style}]{label}[/]", detail)
120
+ footer = "Enter choose · ↑↓ move · Esc back" if step < len(steps) - 1 else "Enter open shell · setup can be changed later"
121
+ return Panel(
122
+ grid,
123
+ title="[bold iam.heading]Set up Agent Sam[/]",
124
+ subtitle=f"[iam.muted]{footer}[/]",
125
+ border_style="iam.cyan",
126
+ padding=(1, 2),
127
+ width=68,
128
+ )
129
+
130
+
131
+ def preview_setup(console, *, fast: bool = False, ticks: int = 30) -> None:
132
+ """Progressive-discovery wizard mock: one decision at a time, no wall of text."""
133
+ ctx = PreviewContext()
134
+ console.print(_brand_header(ctx))
135
+ console.print(" [iam.muted]First run · five small choices. Nothing is uploaded.[/]")
136
+ console.print()
137
+ steps = 5
138
+ with Live(console=console, refresh_per_second=12, transient=False) as live:
139
+ for step in range(steps):
140
+ loops = 1 if fast else max(2, min(5, ticks // steps))
141
+ for tick in range(loops):
142
+ live.update(_setup_panel(step, tick, ctx))
143
+ _sleep(0.12, fast=fast)
144
+ live.update(_setup_panel(steps - 1, 4, ctx))
145
+
146
+
147
+ def _ready_panel(ctx: PreviewContext, *, tick: int) -> Panel:
148
+ hint = Table.grid(padding=(0, 2))
149
+ hint.add_column(style="iam.cyan", min_width=14)
150
+ hint.add_column(style="iam.muted")
151
+ hint.add_row("/help", "show the command map")
152
+ hint.add_row("/status", "check project + local services")
153
+ hint.add_row("/agent <goal>", "ask Agent Sam to work with you")
154
+ hint.add_row("regular shell", "git, npm, python, etc. stay normal")
155
+
156
+ prompt = Text()
157
+ prompt.append("sam", style="bold iam.cyan")
158
+ prompt.append(f" {ctx.cwd}", style="iam.muted")
159
+ prompt.append(" › ", style="bold iam.heading")
160
+ prompt.append("_" if tick % 2 == 0 else " ", style="iam.cyan")
161
+
162
+ return Panel(
163
+ Group(_brand_header(ctx, tick=tick), Text(""), hint, Text(""), prompt),
164
+ title="[bold iam.heading]Ready[/]",
165
+ border_style="iam.green",
166
+ padding=(1, 2),
167
+ width=68,
168
+ )
169
+
170
+
171
+ def preview_ready(console, *, fast: bool = False, ticks: int = 12) -> None:
172
+ """The final quiet landing state: useful hints, then get out of the way."""
173
+ ctx = PreviewContext()
174
+ loops = 2 if fast else max(4, min(ticks, 16))
175
+ with Live(console=console, refresh_per_second=4, transient=False) as live:
176
+ for i in range(loops):
177
+ live.update(_ready_panel(ctx, tick=i))
178
+ _sleep(0.22, fast=fast)
179
+
180
+
181
+ def preview_thinking(console, *, fast: bool = False, ticks: int = 18) -> None:
182
+ """Small assistant activity animation intended for inline use, not a full screen."""
183
+ loops = 3 if fast else max(6, min(ticks, 24))
184
+ with Live(console=console, refresh_per_second=14, transient=False) as live:
185
+ for i in range(loops):
186
+ frame = THINK[i % len(THINK)]
187
+ body = Text(frame, style="bold iam.cyan", no_wrap=True)
188
+ live.update(
189
+ Panel(
190
+ Align.center(body),
191
+ title="[bold iam.heading]Agent Sam[/]",
192
+ subtitle="[iam.muted]thinking · working locally[/]",
193
+ border_style="iam.cyan",
194
+ width=34,
195
+ padding=(0, 1),
196
+ )
197
+ )
198
+ _sleep(0.09, fast=fast)
199
+
200
+
201
+ def preview_tour(console, *, fast: bool = False, ticks: int = 24) -> None:
202
+ preview_boot(console, fast=fast, ticks=ticks)
203
+ console.print()
204
+ preview_setup(console, fast=fast, ticks=ticks)
205
+ console.print()
206
+ preview_thinking(console, fast=fast, ticks=ticks)
207
+ console.print()
208
+ preview_ready(console, fast=fast, ticks=ticks)
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import contextlib
4
+ import io
3
5
  import unittest
4
6
 
5
7
  from agentsam_sdk.cli import build_parser
@@ -7,13 +9,12 @@ from agentsam_sdk.tui.frames import BRAILLE, COMET, MOON, THINK, WALKER
7
9
 
8
10
 
9
11
  class TuiCliTests(unittest.TestCase):
10
- def test_tui_command_is_registered_without_importing_rich(self):
11
- args = build_parser().parse_args(["tui", "--scene", "card", "--check"])
12
- self.assertEqual(args.group, "tui")
13
- self.assertEqual(args.scene, "card")
14
- self.assertTrue(args.check)
12
+ def test_tui_is_not_a_public_python_cli_command(self):
13
+ with contextlib.redirect_stderr(io.StringIO()):
14
+ with self.assertRaises(SystemExit):
15
+ build_parser().parse_args(["tui"])
15
16
 
16
- def test_animation_frames_are_available_without_rich(self):
17
+ def test_animation_frames_remain_available_to_internal_renderers(self):
17
18
  self.assertGreater(len(BRAILLE), 0)
18
19
  self.assertGreater(len(MOON), 0)
19
20
  self.assertGreater(len(WALKER), 0)
@@ -0,0 +1,21 @@
1
+ # AgentSam Skills
2
+
3
+ Portable, on-demand AgentSam behavior modules. Skills keep specialized guidance
4
+ out of the permanent system prompt and load deeper `references/` only when the
5
+ current task calls for them.
6
+
7
+ ## Canonical skills
8
+
9
+ - `agentsam-jr-dev/` — explain, inspect, build, and revise real software using
10
+ beginner-friendly language grounded in the actual repository and runtime.
11
+
12
+ - `agentsam-app-fundamentals/` — quick application-building laws for trust,
13
+ contracts, credentials, dependency graphs, AST evidence, and Merkle evidence.
14
+ - `agentsam-progression-guard/` — checkpoint/hook discipline for local work, CI,
15
+ deploy, postdeploy verification, promotion, runtime observation, and rollback.
16
+
17
+ List or open them with `agentsam skills`; aliases such as `quick-bytes` and
18
+ `no-regress` are intentionally short enough for terminal use.
19
+
20
+ Apps may contain host-specific skill directories of their own. Those do not
21
+ replace the portable SDK skills in this directory.
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: agentsam-app-fundamentals
3
+ description: >
4
+ Keep application-building work grounded in execution domains, contracts, credentials,
5
+ dependency graphs, AST evidence, Merkle evidence, and explicit I/O boundaries. Use when
6
+ adding or reviewing a feature, service, package, API, auth flow, secret, integration,
7
+ frontend/backend boundary, worker, webhook, or external credentialed destination. Also
8
+ use for quick reminders when a large codebase makes the underlying mechanics hard to
9
+ keep in working memory. Triggers on "app fundamentals", "quick bytes", "trust boundary",
10
+ "client secret", "redirect URI", "frontend/backend", "AST", "Merkle", "contract drift",
11
+ "service boundary", "credentialed destination", and "where should this logic live".
12
+ metadata:
13
+ short-description: "Application-building laws: ownership, contracts, credentials, graphs, AST, and Merkle evidence"
14
+ aliases:
15
+ - app-fundamentals
16
+ - application-fundamentals
17
+ - quick-bytes
18
+ user-invocable: true
19
+ ---
20
+
21
+ # AgentSam Application Fundamentals
22
+
23
+ Use this skill as a **small engineering compass**, not a giant textbook. A large
24
+ platform becomes manageable when every feature can answer a few mechanical
25
+ questions: who executes it, who owns authority, what contract crosses the boundary,
26
+ what credential is used, what it depends on, and what evidence proves the change.
27
+
28
+ ## Quick bytes
29
+
30
+ - **Execution domain:** trust follows who controls the machine/runtime, not the folder name.
31
+ - **Browser/client:** user-controlled and therefore observable/tamperable. Never make it the final authority for security or privileged state changes.
32
+ - **Server/backend:** operator-controlled execution. Re-verify identity, authorization, ownership, prices, permissions, and other invariants here.
33
+ - **Import:** a dependency edge. **Export:** a public contract another module may depend on.
34
+ - **AST:** parsed code structure. Use it to identify symbols, imports/exports, calls, environment access, and execution-domain contradictions without relying on text grep alone.
35
+ - **Dependency graph/DAG:** the map of what depends on what. It determines blast radius, build order, affected tests, and what can run in parallel.
36
+ - **Schema/contract:** the agreed shape at a boundary. Compile-time types help; runtime validation proves real external data matches the contract.
37
+ - **Merkle/content hash:** identity for observed bytes. A changed root proves something changed; an unchanged root proves the captured content is identical under the same policy.
38
+ - **Semantic metadata root:** identity for the indexed/classified view of those bytes. It can change when execution classification or parser-derived meaning changes even when content does not.
39
+ - **Client ID:** usually a public application identifier. **Client secret/API secret:** a credential proving authority; keep it out of browser code and public bundles.
40
+ - **Redirect URI:** an explicitly registered destination for an authorization flow. The provider returns to the callback; your backend verifies the flow, establishes your app session, then chooses the final in-app destination.
41
+ - **Firewall/WAF:** an ingress filter. It reduces hostile traffic; it does not replace authentication, authorization, ownership checks, runtime validation, or least privilege.
42
+ - **Hook:** code that runs automatically because a lifecycle event occurred. Treat hooks as explicit I/O contracts, not mystery scripts.
43
+
44
+ If one of those concepts is fuzzy for the current task, read the matching reference
45
+ before editing.
46
+
47
+ ## The six questions for every feature
48
+
49
+ Before changing code, be able to answer:
50
+
51
+ 1. **User behavior:** what can the user now do?
52
+ 2. **Execution owner:** which runtime is trusted to make the decision or perform the side effect?
53
+ 3. **Contract:** what request/event/type/schema crosses each boundary?
54
+ 4. **State:** what is ephemeral, browser-local, durable, cached, or externally owned?
55
+ 5. **Credentialed destinations:** which external systems are called, from which runtime, with which public IDs/secrets/scopes?
56
+ 6. **Proof:** which tests, AST/index evidence, Merkle receipt, runtime response, or observable metric proves it works?
57
+
58
+ If a feature cannot answer these, it is not ready to be called complete.
59
+
60
+ ## Build vertical slices, not disconnected layers
61
+
62
+ For application work, trace the real behavior end to end:
63
+
64
+ ```text
65
+ user action
66
+ -> client intent
67
+ -> validated boundary contract
68
+ -> trusted server/domain operation
69
+ -> database/service/provider side effect
70
+ -> response/event
71
+ -> client state/render
72
+ -> test + runtime proof
73
+ ```
74
+
75
+ A button without the trusted operation behind it is incomplete. A backend endpoint
76
+ without a real consumer may be dead surface area. A shared type without runtime
77
+ validation is not proof that an external system obeyed the type.
78
+
79
+ ## Credentialed-destination card
80
+
81
+ Whenever a feature talks to Google, GitHub, Cloudflare, Stripe, a model provider,
82
+ a database, another Worker/service, or any other privileged destination, write down
83
+ this card before wiring it:
84
+
85
+ ```text
86
+ Destination
87
+ provider/service:
88
+ purpose:
89
+ caller execution domain:
90
+ public identifier(s):
91
+ secret credential(s):
92
+ credential owner/runtime:
93
+ allowed origin/host:
94
+ callback/redirect/webhook URI(s):
95
+ scopes/permissions:
96
+ request contract:
97
+ response contract:
98
+ timeout/retry/idempotency:
99
+ failure behavior:
100
+ audit/observability:
101
+ rotation/revocation path:
102
+ ```
103
+
104
+ This turns "a pile of env vars" into an explicit relationship. Environment variable
105
+ names are configuration labels; the credential value is the sensitive authority.
106
+ Validate required configuration at boot or boundary entry and fail clearly.
107
+
108
+ Read `references/trust-credentials-and-destinations.md` for auth/OAuth and destination
109
+ mechanics.
110
+
111
+ ## Graph law for packages/services/apps
112
+
113
+ As a system grows, do not rely on remembering which file "goes with" another file.
114
+ Make coupling machine-visible:
115
+
116
+ ```text
117
+ package/service A
118
+ imports / calls / subscribes to
119
+ package/service B
120
+ implements contract C
121
+ owns state D
122
+ uses credential E
123
+ ```
124
+
125
+ Prefer a single contract authority for cross-surface behavior: a shared type/schema,
126
+ OpenAPI/GraphQL/Protobuf definition, event schema, or other versioned interface. Use
127
+ AST/import graphs and package metadata to determine affected dependents instead of
128
+ manually searching a million-line repository.
129
+
130
+ Read `references/graphs-contracts-ast-merkle.md` for the deeper model.
131
+
132
+ ## AgentSam evidence tools
133
+
134
+ Prefer deterministic evidence before broad model reasoning:
135
+
136
+ ```bash
137
+ agentsam inspect --json
138
+ agentsam inspect --execution-domain browser --view files --json
139
+ agentsam security scan --path .
140
+ agentsam merkle ...
141
+ agentsam index ...
142
+ agentsam search ...
143
+ ```
144
+
145
+ Use repository/index tools to narrow the relevant graph. Do not dump the whole repo
146
+ or all tool schemas into context.
147
+
148
+ ## Rules while building
149
+
150
+ 1. Never infer trust from `frontend/`, `backend/`, `worker/`, or `shared/` names alone; verify execution reality.
151
+ 2. Never put a long-lived secret into code delivered to a user-controlled runtime.
152
+ 3. Never let client-side validation be the only security or correctness check.
153
+ 4. Never introduce a second contract authority when an existing canonical schema/type can be extended.
154
+ 5. Never change a shared contract without identifying downstream dependents.
155
+ 6. Never treat a Merkle hash as proof of correctness; it proves observed identity/change, not behavior.
156
+ 7. Never treat AST/index output as infallible; account for parser coverage, generated/framework code, and explicit classification overrides.
157
+ 8. Never let a hook silently mutate unrelated state. Bound its inputs, outputs, permissions, timeout, and failure policy.
158
+ 9. Never call a credential "just an env var." Record who owns it, where it may exist, and what it authorizes.
159
+ 10. Never ship a cross-layer feature from screenshots alone. Exercise the real I/O path.
160
+
161
+ ## Handoff to progression guard
162
+
163
+ Once the feature's boundaries are coherent, use `agentsam-progression-guard` to decide
164
+ **when and where those invariants must be re-proven** during commit, CI, deploy, and
165
+ runtime promotion.
@@ -0,0 +1,89 @@
1
+ # Graphs, Contracts, AST, and Merkle Evidence
2
+
3
+ ## The codebase is a graph
4
+
5
+ A large application is easier to reason about when you stop treating it as a folder
6
+ maze and start treating it as a graph:
7
+
8
+ ```text
9
+ files -> symbols -> imports/calls -> packages -> services -> external destinations
10
+ ```
11
+
12
+ The graph answers questions humans should not have to remember:
13
+
14
+ - If package C changes, which apps depend on it?
15
+ - Which browser entrypoints can reach this server-only module?
16
+ - Which route consumes this schema?
17
+ - Which service owns a database write?
18
+ - Which packages can build/test in parallel?
19
+ - Which consumers must be revalidated after a contract change?
20
+
21
+ A DAG is especially useful for build/test ordering when cycles are absent or have been
22
+ made explicit.
23
+
24
+ ## AST is structure, not text coincidence
25
+
26
+ An Abstract Syntax Tree is the parsed structural representation of source code. It can
27
+ reliably distinguish function declarations, imports, calls, environment accesses,
28
+ and other syntax that a plain text search can only approximate.
29
+
30
+ AgentSam should use AST evidence to derive dependency and execution-boundary facts,
31
+ then preserve parser coverage/errors so an agent knows where certainty ends.
32
+
33
+ Useful AST-derived facts include:
34
+
35
+ - imports/exports and resolved local edges;
36
+ - symbol declarations and references;
37
+ - server/runtime-only dependency use;
38
+ - environment variable access names (never secret values);
39
+ - browser-reachable versus server-owned code;
40
+ - contract/schema ownership hints.
41
+
42
+ ## Contracts make coupling explicit
43
+
44
+ For a frontend/backend or service/service boundary, prefer one canonical contract
45
+ source. Depending on the system that can be a TypeScript package, runtime schema,
46
+ OpenAPI document, GraphQL schema, Protobuf definition, event schema, or equivalent.
47
+
48
+ Compile-time types catch code drift before build. Runtime validation catches real data
49
+ that violates the contract after types have been erased or when the caller is outside
50
+ the type system. Contract tests can prove independent producer/consumer systems still
51
+ agree.
52
+
53
+ ## Merkle is the evidence identity layer
54
+
55
+ Merkle hashing gives a deterministic identity to a captured file tree. If one included
56
+ file changes, the root changes. This makes before/after receipts cheap to compare and
57
+ lets CI/deploy systems cache or target work by content identity.
58
+
59
+ AgentSam separates two identities:
60
+
61
+ ```text
62
+ content root
63
+ observed included bytes/paths
64
+
65
+ semantic metadata root
66
+ classified/indexed meaning derived from those bytes
67
+ ```
68
+
69
+ The semantic root can change after a classifier/parser upgrade or execution-domain
70
+ classification change even when source bytes remain identical. That distinction is
71
+ important: source identity and interpretation identity answer different questions.
72
+
73
+ ## The repair proof loop
74
+
75
+ For structural repairs, prefer:
76
+
77
+ ```text
78
+ snapshot A
79
+ -> contradiction finding + evidence refs
80
+ -> isolated bounded repair
81
+ -> build/type/test/security checks
82
+ -> snapshot B
83
+ -> prove target contradiction disappeared
84
+ -> prove no disallowed new contradictions
85
+ -> emit receipt
86
+ ```
87
+
88
+ The model may propose the repair, but deterministic evidence should decide whether the
89
+ repair actually satisfied the invariant.