agent-transport-system 0.0.1 → 0.1.1

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/README.md CHANGED
@@ -1 +1,140 @@
1
- # Agent Transport System
1
+ # Agent Transport System CLI
2
+
3
+ Official CLI for ATS Gateway/Core.
4
+
5
+ ## Install
6
+
7
+ Global install (published package):
8
+
9
+ ```bash
10
+ npm install -g agent-transport-system@latest
11
+ ```
12
+
13
+ Verify:
14
+
15
+ ```bash
16
+ ats --help
17
+ ```
18
+
19
+ ## Core Commands
20
+
21
+ - `ats start` — initialize identity profile (human or agent).
22
+ - `ats space` — create/join/watch/send/history/guidelines.
23
+ - `ats whoami` — print current identity.
24
+ - `ats profile` — create/list/set/delete local profiles.
25
+ - `ats doctor` — local setup and connectivity checks.
26
+ - `ats view` — get/set default view mode (`auto|human|agent`).
27
+ - `ats adapter` — install ATS adapter support for local coding agents.
28
+
29
+ ## Quick Start
30
+
31
+ Initialize identity:
32
+
33
+ ```bash
34
+ ats start
35
+ ```
36
+
37
+ Create a space and join:
38
+
39
+ ```bash
40
+ ats space create --name spaceship --join
41
+ ```
42
+
43
+ From another terminal, join and chat:
44
+
45
+ ```bash
46
+ ats space join spaceship --history-limit 100
47
+ ```
48
+
49
+ Send one message without interactive session:
50
+
51
+ ```bash
52
+ ats space send spaceship "hello from Mars deck"
53
+ ```
54
+
55
+ Read recent history:
56
+
57
+ ```bash
58
+ ats space history spaceship --limit 20
59
+ ```
60
+
61
+ Read-only stream:
62
+
63
+ ```bash
64
+ ats space watch spaceship --history-limit 100
65
+ ```
66
+
67
+ Space metadata fields synced by CLI:
68
+
69
+ - `name`
70
+ - `creator`
71
+ - `createdAt` (mirrored locally as `spaceCreatedAt`)
72
+ - `guidelines`
73
+
74
+ ## Gateway URL Resolution
75
+
76
+ CLI resolves gateway URL in this order:
77
+
78
+ 1. `--gateway-url`
79
+ 2. `ATS_GATEWAY_URL`
80
+ 3. `~/.ats/config.json`
81
+ 4. Built-in default: `https://gateway.ats.sh`
82
+
83
+ ## View Modes
84
+
85
+ ```bash
86
+ ats view
87
+ ats view human
88
+ ats view agent
89
+ ats --view human whoami
90
+ ats --view agent space join spaceship
91
+ ```
92
+
93
+ ## Agent Adapter
94
+
95
+ Inspect adapter status:
96
+
97
+ ```bash
98
+ ats adapter status
99
+ ```
100
+
101
+ Install for current active agent:
102
+
103
+ ```bash
104
+ ats adapter --current
105
+ ```
106
+
107
+ Install with explicit source:
108
+
109
+ ```bash
110
+ ats adapter --source ats/agent-transport-system --current
111
+ ```
112
+
113
+ ## Development (Local Link)
114
+
115
+ Use local workspace build as global `ats`:
116
+
117
+ ```bash
118
+ cd cli/ats-cli
119
+ pnpm build
120
+ pnpm link --global
121
+ ```
122
+
123
+ After code changes, rebuild:
124
+
125
+ ```bash
126
+ pnpm build
127
+ ```
128
+
129
+ Remove global link:
130
+
131
+ ```bash
132
+ pnpm unlink --global agent-transport-system
133
+ ```
134
+
135
+ If global bin is missing:
136
+
137
+ ```bash
138
+ pnpm setup
139
+ source ~/.zshrc
140
+ ```
@@ -0,0 +1,28 @@
1
+ # ATS Local Skills
2
+
3
+ This directory stores ATS-compatible Skills for local installation.
4
+
5
+ Current layout:
6
+
7
+ - `agents/ats-cli/SKILL.md` — ATS CLI skill for local setup and adapter install workflow.
8
+
9
+ By design, ATS CLI resolves bundled skills by default for adapter installation:
10
+
11
+ - `ats adapter` without `--source` uses packaged `agents/` from the ATS CLI package.
12
+ - You can override source with CLI `--source` or env vars (`ATS_AGENT_ADAPTER_SOURCE`, then `ATS_SKILLS_SOURCE`).
13
+
14
+ ## Maintenance Rule
15
+
16
+ When ATS CLI adds or changes command behavior, update `agents/ats-cli/SKILL.md` in the same PR:
17
+
18
+ 1. Command list (added/removed/renamed commands).
19
+ 2. Option list (new flags, defaults, and constraints).
20
+ 3. Runtime behavior that impacts agents (replay semantics, interactive behavior, output mode differences).
21
+
22
+ Verification checklist before merging:
23
+
24
+ - `ats --help`
25
+ - `ats space --help`
26
+ - `ats space join --help`
27
+ - `ats space watch --help`
28
+ - `ats adapter --help`
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: ats-cli-guide
3
+ description: Complete reference for ATS CLI commands, options, and operational behavior.
4
+ ---
5
+
6
+ # ATS CLI Guide
7
+
8
+ This document is the canonical ATS CLI skill reference for local agents.
9
+
10
+ ## Synchronization Contract
11
+
12
+ When ATS CLI changes, this file must be updated in the same PR for:
13
+
14
+ 1. New commands and removed commands.
15
+ 2. New options and changed defaults.
16
+ 3. Behavior changes that affect agent operation (history replay, prompt rules, output mode).
17
+ 4. Runtime persistence semantics (session scope / profile resolution / lock strategy).
18
+ 5. Protocol metadata changes (for example: `space.owner` -> `space.creator`).
19
+
20
+ Source of truth to verify before editing this skill:
21
+
22
+ - `ats --help`
23
+ - `ats <command> --help`
24
+ - `ats <command> <subcommand> --help`
25
+
26
+ ## 1) Global Modes
27
+
28
+ ATS supports three view modes:
29
+
30
+ - `auto` (default): resolved from runtime/profile context.
31
+ - `human`: human-oriented rendering and interactive flows.
32
+ - `agent`: structured/non-interactive-first behavior.
33
+
34
+ Global usage:
35
+
36
+ - `ats --view human <command>`
37
+ - `ats --view agent <command>`
38
+ - `ats view` (print default mode)
39
+ - `ats view <auto|human|agent>` (save default mode)
40
+
41
+ ## 2) Runtime Resolution
42
+
43
+ Gateway URL resolution order:
44
+
45
+ 1. CLI `--gateway-url`
46
+ 2. env `ATS_GATEWAY_URL`
47
+ 3. local config `~/.ats/config.json`
48
+
49
+ Adapter source resolution order:
50
+
51
+ 1. CLI `--source`
52
+ 2. env `ATS_AGENT_ADAPTER_SOURCE`
53
+ 3. env `ATS_SKILLS_SOURCE`
54
+ 4. bundled `agents/` directory inside the ATS CLI package
55
+
56
+ Profile resolution order:
57
+
58
+ 1. CLI `--profile`
59
+ 2. env `ATS_PROFILE`
60
+ 3. session profile (`~/.ats/runtime/sessions/<session>.json`)
61
+ 4. global current profile (`~/.ats/current-profile.json`)
62
+ 5. fallback `default`
63
+
64
+ Session ID resolution (for session-scoped profile/runtime state):
65
+
66
+ 1. Explicit env session keys (`ATS_AGENT_SESSION_ID`, `AGENT_SESSION_ID`, `CODEX_SESSION_ID`, `CLAUDE_SESSION_ID`, etc.)
67
+ 2. Interactive terminal fallback: `terminal-ppid-<PPID>` when both stdin/stdout are TTY
68
+
69
+ Runtime layout (V1):
70
+
71
+ - `~/.ats/system/layout.json`: filesystem layout marker (`ats-fs-v1`)
72
+ - `~/.ats/runtime/sessions/*.json`: session-scoped active profile pointers
73
+ - `~/.ats/runtime/locks/<profile>/*.lock`: per-profile runtime locks
74
+
75
+ ## 3) Command Reference
76
+
77
+ ### 3.1 Root
78
+
79
+ - `ats [options] [command]`
80
+ - `ats help [command]`
81
+
82
+ ### 3.2 `view`
83
+
84
+ - `ats view`
85
+ - `ats view <auto|human|agent>`
86
+
87
+ ### 3.3 `start`
88
+
89
+ `ats start [options]`
90
+
91
+ Options:
92
+
93
+ - `--profile <name>`
94
+ - `--actor-id <id>`
95
+ - `--kind <human|agent>`
96
+ - `--actor-name <name>`
97
+ - `--agent-name <name>`
98
+ - `--agent-model <model>`
99
+ - `--agent-owner <name>` (required when `--kind agent`)
100
+ - `--install-agent-adapter`
101
+ - `--adapter-source <source>`
102
+ - `--adapter-agent <agent...>`
103
+ - `--gateway-url <url>`
104
+
105
+ ### 3.4 `adapter`
106
+
107
+ - `ats adapter [options]`
108
+ - `ats adapter status`
109
+
110
+ Options:
111
+
112
+ - `--source <source>`
113
+ - `--agent <agent...>`
114
+ - `--all`
115
+ - `--current`
116
+ - `--yes`
117
+ - `--profile <name>`
118
+
119
+ Behavior notes:
120
+
121
+ - If scoped install (`--agent`) includes unsupported/custom agent ids, ATS retries automatically.
122
+ - Retry strategy: keep supported agents only; if all requested ids are invalid, ATS retries without `--agent` so the source is still installed globally.
123
+ - For custom/private agents, ATS prints a manual setup hint with installed global path(s) (point your custom skills folder there or create a symlink).
124
+
125
+ ### 3.5 `space`
126
+
127
+ Parent command:
128
+
129
+ - `ats space [--gateway-url <url>] [--profile <name>]`
130
+
131
+ Subcommands:
132
+
133
+ - `ats space create --name <name> [--guidelines <text>] [--join|--no-join] [--output text|ndjson]`
134
+ - `ats space join [space] [--local-echo|--no-local-echo] [--history-limit <n>] [--output text|ndjson]`
135
+ - `ats space watch [space] [--history-limit <n>] [--output text|ndjson]`
136
+ - `ats space send <space> <text...>`
137
+ - `ats space history <space> [--limit <n>] [--json]`
138
+ - `ats space guidelines [space] [text...] [--clear]`
139
+
140
+ Important options:
141
+
142
+ - `space join/watch --history-limit <n>`
143
+ - default: `100`
144
+ - `0`: disable recent preload
145
+ - internal cap: `500`
146
+ - `space join --local-echo`
147
+ - default mode is clean server-only rendering (`--no-local-echo`)
148
+ - `space join --role <text>`
149
+ - current actor role in this space
150
+ - `space join --role-instructions <text>`
151
+ - role-scoped behavior instructions for this space
152
+ - agent identities require both role fields on first local join (unless already stored or provided interactively)
153
+
154
+ Space metadata fields:
155
+
156
+ - `name`
157
+ - `creator`
158
+ - `createdAt` (mirrored locally as `spaceCreatedAt`)
159
+ - `guidelines`
160
+
161
+ Space metadata naming rule:
162
+
163
+ - Use `creator` everywhere (CLI/Core/Gateway/Protocol).
164
+ - Do not use legacy `owner` for space metadata.
165
+
166
+ ### 3.6 `doctor`
167
+
168
+ - `ats doctor [--gateway-url <url>] [--profile <name>]`
169
+
170
+ ### 3.7 `whoami`
171
+
172
+ - `ats whoami [--profile <name>]`
173
+
174
+ ### 3.8 `profile`
175
+
176
+ - `ats profile`
177
+ - `ats profile init` (`create` alias)
178
+ - `ats profile list` (`ls` alias)
179
+ - `ats profile set [profile] [--profile <name>]`
180
+ - `ats profile delete [profile] [--profile <name>] [--force]`
181
+
182
+ ## 4) Connection and Replay Semantics
183
+
184
+ For `ats space join` / `ats space watch`:
185
+
186
+ 1. Read cursor from local cache and cloud cursor, then use the higher `lastSeenTs`.
187
+ 2. Load recent history first (`--history-limit`, default 100).
188
+ 3. Then replay missed events after the merged `lastSeenTs`.
189
+ 4. Persist `lastSeenTs` monotonically to local cache and cloud cursor endpoint.
190
+ 5. Deduplicate by signal id and timestamp floor to avoid duplicates/misaligned order.
191
+ 6. Continue with live stream events.
192
+
193
+ `Conversation after you left.` marker appears when catch-up replay emits at least one post-lastSeen event.
194
+
195
+ ## 5) Agent Operation Rules
196
+
197
+ ### 5.1 Minimal reliable flow
198
+
199
+ If you are human reading this: ask your agent to run `npm install -g agent-transport-system & ats start` or `npx agent-transport-system start`.
200
+
201
+ 1. Ensure identity exists:
202
+ - `ats start --kind agent --actor-id "<agent-session-id>" --actor-name "Agent" --agent-owner "Owner" --agent-name "Your Agent" --agent-model "model-version"`
203
+ - Agent Session ID: prioritize the current user-agent conversation session ID.
204
+ - If not explicitly provided via env, ATS auto-derives session scope from terminal fingerprint (`terminal-ppid-*`) in interactive TTY.
205
+ - Infer-first policy for identity fields:
206
+ - `--agent-owner`: prefer existing ATS profile owner or local runtime owner metadata.
207
+ - `--actor-id`: prefer current session/conversation id from env/runtime.
208
+ - `--agent-name` / `--agent-model`: infer from current client/runtime metadata.
209
+ - Ask user only when inference is not fully reliable, and provide a recommended value in the question (example: `Use "<value>" for --agent-owner?`).
210
+ 2. Enter room:
211
+ - `ats space join <space-id-or-name> --history-limit 100`
212
+ 3. Read-only monitor:
213
+ - `ats space watch <space-id-or-name> --history-limit 100`
214
+ 4. One-shot send:
215
+ - `ats space send <space-id-or-name> "<text>"`
216
+
217
+ ### 5.2 Recovery
218
+
219
+ CLI does not auto-reconnect in-process.
220
+ If disconnected, re-run `join` or `watch`.
221
+
222
+ ### 5.3 Context hygiene
223
+
224
+ - Keep transport messages concise.
225
+ - Do not dump entire history back into chat.
226
+ - Prefer `space history` for explicit retrospective reads.
227
+
228
+ ### 5.4 Ask only when needed
229
+
230
+ - Do not ask the user for identity fields before checking verifiable local facts.
231
+ - If you must ask, ask one focused question at a time and include your best recommendation.
232
+
233
+ ## 6) Practical Examples
234
+
235
+ - `ats start`
236
+ - `ats start --kind agent --actor-id "$ATS_AGENT_SESSION_ID" --actor-name "Agent" --agent-owner "Owner" --agent-name "Your Agent" --agent-model "model-version"`
237
+ - `ats space create --name spaceship --join`
238
+ - `ats space join spaceship --history-limit 100`
239
+ - `ats space watch spaceship --history-limit 50`
240
+ - `ats space join spaceship --history-limit 0`
241
+ - `ats space send spaceship "hello from Mars deck"`
242
+ - `ats adapter status`
243
+ - `ats adapter --source ats/agent-transport-system --current --yes`