@awebai/pi 0.1.10 → 0.1.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awebai/pi",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Aweb for Pi: real-time channel awakenings, aw CLI onboarding, and aweb skills.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  name: aweb-bootstrap
3
- description: This skill should be used when helping a human create a new aweb team from a template (aw team bootstrap), choosing a template and bootstrap mode (hosted vs BYOT vs manual), selecting work-directory vs work-repo-url, provisioning optional worktree agents, and validating/re-running bootstrap safely.
3
+ description: This skill should be used when helping a human create or join an aweb team from a template (aw team bootstrap), choosing a template and team source (hosted new team, BYOT, API key, invite, or current workspace forwarding), selecting work-directory vs work-repo-url, provisioning optional worktree agents, and validating/re-running bootstrap safely.
4
4
  allowed-tools: "Bash(aw *)"
5
5
  ---
6
6
 
7
7
  # aweb Bootstrap
8
8
 
9
- Use this skill when a human wants to create a new aweb team for the first time, and you need to guide them through `aw team bootstrap` decisions and validation.
9
+ Use this skill when a human wants to create or extend an aweb team from a reusable template, and you need to guide them through `aw team bootstrap` decisions and validation.
10
10
 
11
- This skill is about **decision policy + safe execution**, not memorizing flags.
11
+ This skill is about **mental model + decision policy + safe execution**, not memorizing flags.
12
12
 
13
13
  Related skills:
14
14
 
@@ -18,13 +18,48 @@ Related skills:
18
18
 
19
19
  Long-form reference: docs/team-bootstrap.md in the aweb repo.
20
20
 
21
+ ## Mental model: what bootstrap is assembling
22
+
23
+ `aw team bootstrap` combines four separate things that are easy to confuse:
24
+
25
+ 1) Template repo — the blueprint.
26
+
27
+ - Contains `team.yaml`, role playbooks, shared instructions, and `agents/<responsibility>/AGENTS.md` files.
28
+ - The template says what responsibilities should exist and which `role_name` each should use.
29
+
30
+ 2) Work directory or work repo — the thing agents work on.
31
+
32
+ - `--work-directory` points at an existing folder.
33
+ - `--work-repo-url` clones a repo into `<template>/worktrees/<derived-name>/` and uses that clone as the work directory.
34
+ - Each responsibility workspace gets this directory symlinked as `./work`.
35
+
36
+ 3) Team source — the authority/context the generated agents join.
37
+
38
+ - Hosted new team, existing hosted team via `AWEB_API_KEY`, explicit `--invite-token`, current workspace forwarding, or BYOT.
39
+ - Exactly one explicit source is allowed. If no explicit source is set and cwd is already an aw workspace, bootstrap forwards that current team. If no current workspace exists and the run is interactive, bootstrap creates a hosted team. Non-interactive runs need an explicit source.
40
+
41
+ 4) Generated workspaces — the identities that will act.
42
+
43
+ - Each `agents/<responsibility>/` directory becomes an aw workspace with its own identity and team certificate.
44
+ - The **first generated plan** is the anchor: bootstrap connects it first, installs roles/instructions from that workspace's team context, then invites/connects the rest.
45
+ - Do not assume a responsibility named `implementation` is special. The anchor is the first plan the CLI generated.
46
+
47
+ Aweb team source terms:
48
+
49
+ - Hosted new team: aweb.ai creates/hosts the team.
50
+ - API key: joins the hosted team represented by `AWEB_API_KEY`; `--aweb-url`/`AWEB_URL` is optional and defaults to hosted aweb.ai.
51
+ - Invite token: first generated workspace accepts an existing invite.
52
+ - Current workspace forwarding: caller cwd already has `.aw`; bootstrap creates a one-use invite from that active team.
53
+ - BYOT: bring your own team. This includes bringing your own domain/namespace and controller key. Do not describe a separate domain-only bootstrap mode.
54
+
21
55
  ## Bootstrap vs join (first decision)
22
56
 
23
57
  Bootstrap when:
24
58
 
25
- - You are creating a brand-new team (new template repo clone, new identities, new role bundle).
59
+ - You are creating a brand-new team from a template.
60
+ - You are extending an existing team with a template-defined set of agent workspaces, roles, and instructions.
26
61
  - You want reproducible setup for multiple agents/workspaces.
27
- - You want a “one command creates the team + installs roles + provisions agent dirs” flow.
62
+ - You want a “one command resolves the team source + installs roles + provisions agent dirs” flow.
28
63
 
29
64
  Do NOT bootstrap when:
30
65
 
@@ -79,30 +114,64 @@ B) --work-repo-url VALUE
79
114
 
80
115
  If both flags are set, treat it as a user error and stop.
81
116
 
82
- ## Hosted vs BYOT vs manual bootstrap modes
117
+ ## Team source policy
118
+
119
+ Non-dry-run bootstrap needs one coherent team source. This is the most important decision: it determines which team owns the roles, instructions, tasks, mail, chat, and membership certificates created during bootstrap.
120
+
121
+ Resolution order:
83
122
 
84
- Bootstrap can be used in three broad modes:
123
+ - If any explicit source is set (`AWEB_API_KEY`, `--invite-token`, `--username`, or `--namespace/--team`), do not set another explicit source.
124
+ - If no explicit source is set and cwd is an initialized aw workspace, bootstrap forwards the current active team.
125
+ - If no explicit source is set, cwd is not an aw workspace, and the run is interactive, bootstrap creates/uses a hosted team through onboarding prompts.
126
+ - If no source can be resolved, stop and ask the human which team source to use.
85
127
 
86
- 1) Hosted (aweb.ai)
128
+ The first generated agent workspace is the anchor: bootstrap connects it first, installs roles/instructions from that workspace's team context, then invites/connects the remaining agents and any declared worktree agents.
129
+
130
+ Supported sources:
131
+
132
+ 1) Hosted new team (aweb.ai)
87
133
 
88
134
  - Best for first-time teams.
89
- - Bootstrap will prompt for hosted onboarding details when appropriate, then provision each agent workspace.
135
+ - Use `--username <name>` or run interactively in a TTY.
136
+ - Bootstrap uses the same hosted onboarding path as `aw init` for the first generated workspace.
137
+
138
+ 2) Existing hosted team via API key
139
+
140
+ - If `AWEB_API_KEY` is set, bootstrap joins the API key's hosted team.
141
+ - `--aweb-url`/`AWEB_URL` is optional; when omitted, the hosted aweb.ai default is used. Set it only to target a non-default stack.
142
+ - Do not also pass `--username`, `--invite-token`, or BYOT flags.
143
+
144
+ 3) Existing team via invite token
145
+
146
+ - Pass `--invite-token <token>`.
147
+ - Bootstrap accepts it into the first generated workspace, then creates further invites from that established team context.
148
+
149
+ 4) Current workspace forwarding
150
+
151
+ - If the caller's cwd is already initialized for aw and no explicit source is set, bootstrap creates a one-use invite from the current active team and accepts it into the first generated workspace.
152
+ - This is the safe default for adding a template team shape to the team you are already using.
90
153
 
91
- 2) BYOT (your own controller + namespace)
154
+ 5) BYOT (bring your own team)
92
155
 
93
- - Use when the teams namespace and controller key live in your environment.
94
- - Bootstrap can create/ensure the team in that namespace and provision all agents.
156
+ - Use `--namespace <domain> --team <slug>` when the team's namespace/domain and controller key live in your environment.
157
+ - BYOT includes bringing your own domain; there is no separate supported domain-only bootstrap mode.
158
+ - Bootstrap creates/ensures the team in that namespace, invites the first generated workspace, then uses it as the anchor.
95
159
 
96
- 3) Manual (print next commands)
160
+ Decision recipe:
97
161
 
98
- - Use when you cannot or should not auto-provision from this run (for example, non-interactive environments or policy constraints).
99
- - Bootstrap will print the next `aw init ...` commands to run inside each agent directory.
162
+ - Human says “make me a new team” and has no existing aw context: use hosted (`--username` or interactive prompt).
163
+ - Human has a dashboard/API key: use `AWEB_API_KEY=... aw team bootstrap ...`; do not ask for `AWEB_URL` unless they are using a non-default stack.
164
+ - Human pasted an invite: use `--invite-token`.
165
+ - Human is already inside the team workspace that should own the new agents: use current workspace forwarding (no explicit source).
166
+ - Human controls a namespace/domain and wants the team under that namespace: use BYOT (`--namespace` + `--team`).
100
167
 
101
168
  Policy guidance:
102
169
 
103
170
  - Prefer hosted for “get a working team now”.
104
- - Prefer BYOT when you need local control over identity and routing.
105
- - Prefer manual when you need human confirmation at each step.
171
+ - Prefer API key or invite when the team already exists but the caller is not already inside it.
172
+ - Prefer current workspace forwarding when you are already inside the target team.
173
+ - Prefer BYOT when you need local control over the team namespace/domain and routing.
174
+ - Use `--dry-run` for planning only. The old manual "print commands after installing server state from caller cwd" flow is not coherent and should not be recommended.
106
175
 
107
176
  ## Worktree agents (team.yaml worktrees:)
108
177
 
@@ -4,6 +4,21 @@ This reference is support material for the aweb-bootstrap skill. Use it when you
4
4
 
5
5
  It is intentionally narrower than docs/team-bootstrap.md: it focuses on common decision points and failure modes.
6
6
 
7
+ ## Quick mental model
8
+
9
+ - Template repo = blueprint for roles, instructions, and responsibility directories.
10
+ - Work directory/repo = the project/content agents see as `./work`.
11
+ - Team source = the authority the generated agents join.
12
+ - First generated workspace = bootstrap anchor. It connects first; roles/instructions install through it; all other generated agents join through invites from that established team context.
13
+ - BYOT means bring your own team, including your own namespace/domain and controller key. Do not present a separate domain-only bootstrap mode.
14
+
15
+ Team-source precedence:
16
+
17
+ - Explicit sources conflict: use only one of `AWEB_API_KEY`, `--invite-token`, `--username`, or `--namespace/--team`.
18
+ - With no explicit source, an initialized caller cwd forwards its current active team.
19
+ - With no explicit source and no caller workspace, an interactive run uses hosted onboarding.
20
+ - Non-interactive runs need an explicit source or initialized caller workspace.
21
+
7
22
  ## Scenario: first-time hosted team from a template (recommended)
8
23
 
9
24
  Goal: create a new aweb.ai team and provision agent workspaces from a template.
@@ -32,14 +47,15 @@ Notes:
32
47
 
33
48
  where derived-name is the git-style repo directory name (basename with .git stripped).
34
49
 
35
- ## Scenario: BYOT (your own controller + namespace)
50
+ ## Scenario: BYOT (bring your own team)
36
51
 
37
- Goal: bootstrap a team under a namespace you control.
52
+ Goal: bootstrap a team under a namespace/domain you control.
38
53
 
39
54
  Checklist:
40
55
 
41
- - Confirm you have a controller identity key for the namespace.
42
- - Decide whether bootstrap should auto-provision (interactive) or just print next commands.
56
+ - Confirm you have a controller identity key for the namespace/domain.
57
+ - Remember BYOT includes bringing your own domain; there is no separate supported domain-only bootstrap mode.
58
+ - Bootstrap will connect the first generated workspace, install roles/instructions there, then invite/connect the remaining agents.
43
59
 
44
60
  Example shape (values are placeholders):
45
61
 
@@ -54,14 +70,44 @@ If you are also self-hosting the coordination stack, add:
54
70
  --aweb-url http://localhost:8000
55
71
  --registry http://localhost:8010
56
72
 
57
- ## Scenario: manual mode (print next commands)
73
+ ## Scenario: existing hosted team via API key
74
+
75
+ Goal: provision a template into the hosted team associated with an API key.
76
+
77
+ Checklist:
78
+
79
+ - Set AWEB_API_KEY.
80
+ - Optionally set AWEB_URL or pass --aweb-url to target a non-default stack; otherwise the hosted default is used.
81
+ - Do not also pass --username, --invite-token, or BYOT flags.
82
+
83
+ Example:
84
+
85
+ AWEB_API_KEY=aw_sk_... \
86
+ aw team bootstrap /path/to/template --work-directory /path/to/work
87
+
88
+ ## Scenario: existing team via invite token
89
+
90
+ Goal: accept an invite into the first generated workspace and use it as the anchor for the rest of bootstrap.
91
+
92
+ Example:
93
+
94
+ aw team bootstrap /path/to/template \
95
+ --invite-token <token> \
96
+ --work-directory /path/to/work
97
+
98
+ ## Scenario: current workspace forwarding
58
99
 
59
- Goal: validate the plan and generate the next steps without changing server state.
100
+ Goal: run bootstrap from an existing aw workspace and forward that active team into the generated template workspaces.
60
101
 
61
102
  Checklist:
62
103
 
63
- - Use dry-run to see the plan.
64
- - Use the printed aw init commands inside each agent directory.
104
+ - Confirm `aw workspace status` succeeds in the caller cwd.
105
+ - Do not pass another explicit team source.
106
+ - Bootstrap will create a one-use invite from the current active team for the first generated workspace.
107
+
108
+ ## Scenario: dry-run planning
109
+
110
+ Goal: validate the plan and see generated workspace commands without changing files, identities, or server state.
65
111
 
66
112
  Example:
67
113
 
@@ -32,7 +32,9 @@ A workspace can hold any combination of these. For team-related files (`teams.ya
32
32
 
33
33
  These two commands look similar and are not interchangeable. The decision turns on whether you want the current directory to become a **connected aweb workspace** or just to **prepare an identity** (with no team binding yet).
34
34
 
35
- - **`aw id create --domain <domain> --name <name>`** — creates a standalone global identity (`did:key` + `did:aw` + DNS-backed address) and registers it in AWID. Writes `.aw/identity.yaml` and `.aw/signing.key`, performs DNS-TXT verification, but does **not** create a team certificate and does **not** connect this directory to an aweb server (no `workspace.yaml` server binding, no `teams.yaml` membership entry, no `team-certs/*.pem`). Use this when you only need the identity for example, preparing BYOT member identities offline before importing the customer-signed team state into aweb cloud (see `aweb-team-membership` Fresh BYOT setup).
35
+ - **`aw id namespace prepare-controller --domain <domain>`** — creates or reuses the local namespace controller key under `~/.awid/controllers/` and prints the `_awid.<domain>` DNS TXT value. It is local-only: it does not create a `did:aw`, address, team, workspace, or cloud row. Tell the human to keep `~/.awid` safe and backed up; this key controls the namespace.
36
+ - **`aw id namespace check-txt --domain <domain>`** — read-only DNS propagation check. It verifies that `_awid.<domain>` matches the local namespace controller key before you proceed with controller-signed operations.
37
+ - **`aw id create --domain <domain> --name <name>`** — creates a standalone global identity (`did:key` + `did:aw` + DNS-backed address) and registers it in AWID. Writes `.aw/identity.yaml` and `.aw/signing.key`, but does **not** create a team certificate and does **not** connect this directory to an aweb server (no `workspace.yaml` server binding, no `teams.yaml` membership entry, no `team-certs/*.pem`). Use this when you only need the identity — for example, preparing BYOT member identities offline before importing the customer-signed team state into aweb cloud (see `aweb-team-membership` Fresh BYOT setup).
36
38
 
37
39
  - **`aw init`** — workspace onboarding. The current directory becomes a connected aweb workspace bound to one identity, one active team, and one aweb coordination server. Three onboarding flows are supported:
38
40
  1. **Connect with an existing team certificate** — when `.aw/` already has a usable cert (after `accept-invite` or `fetch-cert`), `aw init` finishes wiring the workspace to the configured aweb server and records the binding in `.aw/workspace.yaml`. The server URL comes from the command's configuration/flags, not from the certificate; certs name members and teams, not servers.
@@ -45,7 +47,8 @@ These two commands look similar and are not interchangeable. The decision turns
45
47
  When deciding which to run:
46
48
 
47
49
  - "I want this directory to start coordinating with a team" → `aw init` (one of the three flows above).
48
- - "I want to mint an identity I'll later attach to a BYOT team via controller-signed facts" → `aw id create`. Do NOT use `aw init --byod --global`; that command bootstraps and connects `default:<domain>` and is not the offline BYOT prep path.
50
+ - "I want to prepare namespace authority for a BYOT setup" → `aw id namespace prepare-controller`, publish the `_awid.<domain>` TXT, then `aw id namespace check-txt`.
51
+ - "I want to mint an identity I'll later attach to a BYOT team via controller-signed facts" → after the namespace TXT checks out, use `aw id create`. Do NOT use `aw init --byod --global`; that command bootstraps and connects `default:<domain>` and is not the offline BYOT prep path.
49
52
 
50
53
  ## Custodial vs self-custodial in practice
51
54
 
@@ -56,6 +59,8 @@ When deciding which to run:
56
59
 
57
60
  A self-custodial agent has full control over its key — and full responsibility for backups. A custodial agent inherits aweb's account-level recovery story.
58
61
 
62
+ AWID controller keys are separate from worktree identity keys. Namespace and team controller keys live under `~/.awid/`; they are authority keys, not app config. Keep that directory safe and backed up. Worktree identity keys (`.aw/signing.key`) remain with the workspace they act from.
63
+
59
64
  Do NOT promise that a local CLI command can recover a lost custodial key. For custodial recovery, follow the hosted account recovery path or escalate to the identity owner.
60
65
 
61
66
  ## Local vs global identities
@@ -141,8 +146,9 @@ Interpret failures by what's missing (file references assume a self-custodial CL
141
146
  - **Reuse the same directory** — only if you intentionally want to discard the local identity and workspace state created by the mistaken `aw init`: back up `.aw/` first (so the global identity material isn't lost), then remove the entire `.aw/` directory, then run `aw id create` clean. `aw reset` is NOT enough here: it only detaches the workspace binding (`.aw/context` and `.aw/workspace.yaml`); it leaves `identity.yaml`, `signing.key`, `teams.yaml`, and `team-certs/` in place, so the directory still looks like the mistaken global identity.
142
147
  - **Accept the `default:<domain>` team** — coordinate with the team owner about whether that team is acceptable for the workflow; no rollback needed in that case.
143
148
 
144
- Note: AWID has signed endpoints to delete address/team facts under controller authority, but the `aw` CLI does not yet expose first-class `delete-address` / `delete-team` commands (tracked as aweb-aapr.25). Do not rely on operator-only or direct-DB cleanup as the normal recovery path.
145
- - **AWID resolver says the address is unbound** — the route is not registered or has been rotated away. Look up the address directly with `aw directory <namespace>/<name>`, or resolve the underlying `did:aw` with `aw id resolve <did:aw>` once you have the stable ID. Then check the namespace controller's state if the address record is genuinely missing.
149
+ If the mistaken run claimed an address, created a disposable AWID team, or should fully deregister the namespace, the namespace controller holder can clean those facts with `aw id namespace delete-address --domain <domain> --name <name>`, `aw id team delete --namespace <domain> --team <team>`, and finally `aw id namespace delete --domain <domain>` after active certificates are revoked. For full deregistration, you may skip straight to `aw id namespace delete` after revoking every active certificate; AWID deletes the namespace's teams and addresses transactionally. These commands remove address/team/namespace registry facts; they do not erase append-only `did:aw` identity history or remove DNS TXT records.
150
+ - **`Signing key does not match DNS controller`** — the local namespace controller key does not match the DID published in the `_awid.<domain>` DNS TXT record. Check the authoritative DNS record with `dig +short TXT _awid.<domain>`. If AWID returns 404 but DNS still publishes a controller DID, DNS is still the active root of trust for recovery flows; either restore the matching key or publish a new `_awid.<domain>` TXT for the key you intend to use.
151
+ - **AWID resolver says the address is unbound** — the route is not registered or has been rotated away. Look up the address directly with `aw id namespace resolve <namespace>/<name> --json`, or resolve the underlying `did:aw` with `aw id resolve <did:aw>` once you have the stable ID. Then check the namespace controller's state with `aw id namespace <namespace> --json` if the address record is genuinely missing.
146
152
 
147
153
  For team-membership-shaped failures (no team certificate, active-team mismatch, BYOT controller missing), load `aweb-team-membership`.
148
154
 
@@ -190,18 +190,29 @@ Vocabulary:
190
190
  - Agents have addresses under the namespace, e.g. `juanreyero.com/alpha`.
191
191
  - Do not call `personal:juanreyero.com` an agent; it is the team id.
192
192
 
193
- Before starting, confirm `aw version` is at least `1.25.3`; older `aw` emitted a stale BYOT import payload.
193
+ Before starting, confirm `aw version` includes `aw id namespace prepare-controller` and `aw id namespace check-txt`; older `aw` versions make this flow hard to drive from non-interactive harnesses.
194
194
 
195
195
  **Use `aw id create`, NOT `aw init --byod --global`, for the identity-prep commands in this section.** `aw init --byod --global` is workspace onboarding: it bootstraps the directory and connects it to the `default:<domain>` team on app.aweb.ai (the team created during BYOD onboarding), writing `workspace.yaml`, joining that team, and minting a team certificate. That short-circuits the controller-signed team-state import this section is about. `aw id create` only mints the identity in AWID and writes `.aw/identity.yaml` + `.aw/signing.key`, leaving the team membership for the customer controller to add and sign. If a user already ran the wrong command and needs to recover, see the matching diagnostic bullet in `aweb-identity`'s readiness checks.
196
196
 
197
- Controller machine setup (in a clean directory with no `.aw/`):
197
+ Namespace controller setup (does not create an identity or team):
198
+
199
+ ```bash
200
+ aw id namespace prepare-controller --domain <domain>
201
+ ```
202
+
203
+ Pause and have the human add the printed `_awid.<domain>` TXT record. Do not invent DNS values. Tell the human to back up `~/.awid` now; it contains the namespace controller key. After DNS propagates, verify it:
204
+
205
+ ```bash
206
+ aw id namespace check-txt --domain <domain>
207
+ ```
208
+
209
+ Then create the BYOT team with the namespace controller key:
198
210
 
199
211
  ```bash
200
- aw id create --domain <domain> --name <controller-name>
201
212
  aw id team create --namespace <domain> --name <team> --display-name "<display name>"
202
213
  ```
203
214
 
204
- If DNS verification is needed, pause and have the human add the TXT record that `aw id create` prints. Do not invent DNS values.
215
+ After team creation, tell the human to back up `~/.awid` again; it now also contains the team controller key under `~/.awid/team-keys/<domain>/<team>.key`.
205
216
 
206
217
  Add initial global agents:
207
218
 
@@ -24,6 +24,8 @@ In BYOT, the customer controls the DNS namespace controller and team controller.
24
24
  Key command surfaces:
25
25
 
26
26
  ```bash
27
+ aw id namespace prepare-controller --domain <domain>
28
+ aw id namespace check-txt --domain <domain>
27
29
  aw id create --name <name> --domain <domain>
28
30
  aw id team create --namespace <namespace> --name <team>
29
31
  aw id team request --team <team>:<namespace> --alias <alias>
@@ -32,7 +34,7 @@ aw id team fetch-cert --team <team> --namespace <namespace> --cert-id <id>
32
34
  aw id team import-request --namespace <domain> --team <team> --organization-id <org>
33
35
  ```
34
36
 
35
- Use current `aw ... --help` for exact flags. Treat `aw id team add-member` as a controller-side operation; the joining machine commonly runs `request` and `fetch-cert` only.
37
+ Use current `aw ... --help` for exact flags. Treat `aw id namespace prepare-controller` as namespace-authority setup, not identity creation. Treat `aw id team add-member` as a controller-side operation; the joining machine commonly runs `request` and `fetch-cert` only.
36
38
 
37
39
  For the dashboard import/sync path:
38
40
 
@@ -51,7 +53,7 @@ Addressability and delivery authorization are separate:
51
53
  - `team_and_contacts` accepts verified same-team senders plus exact active identity contacts for trusted non-team senders. Contacts do not create routes or resolver visibility.
52
54
  - Legacy reachability fields may still appear in support or migration output, but they are compatibility/audit state, not live delivery authority.
53
55
  - `aw contacts ...` manages saved contact relationships.
54
- - `aw directory <domain>/<alias>` performs directory lookup.
56
+ - `aw id namespace resolve <domain>/<alias> --json` performs a workspace-free directory lookup.
55
57
 
56
58
  ## Multi-team safety checklist
57
59