argsbarg 6.1.8 → 6.1.10
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/CHANGELOG.md +23 -1
- package/README.md +160 -68
- package/docs/README.md +1 -0
- package/docs/cli-program.md +2 -0
- package/docs/decisions.md +81 -25
- package/docs/developing.md +1 -1
- package/docs/distribution-homebrew.md +117 -104
- package/docs/http-server.md +3 -1
- package/docs/logging.md +149 -0
- package/examples/full-example/docs/cli-schema.json +18 -18
- package/examples/full-example/docs/cli.md +18 -18
- package/examples/full-example/docs/http.md +13 -1
- package/examples/full-example/justfile +20 -0
- package/index.d.ts +84 -14
- package/package.json +1 -1
- package/src/builtins/http.ts +1 -1
- package/src/builtins/mcp.ts +1 -1
- package/src/core/types.ts +17 -3
- package/src/docs/http-guide.ts +11 -1
- package/src/docs/save.ts +1 -1
- package/src/headless/tool-call.ts +1 -1
- package/src/hooks/run.ts +7 -2
- package/src/http/server.ts +19 -1
- package/src/index.ts +2 -0
- package/src/log/ecs.test.ts +68 -2
- package/src/log/ecs.ts +109 -14
- package/src/log/emitter.test.ts +95 -0
- package/src/log/emitter.ts +74 -11
- package/src/log/trace.test.ts +60 -0
- package/src/log/trace.ts +62 -0
- package/src/runtime/cli.ts +1 -1
|
@@ -1,159 +1,172 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Homebrew Distribution & Release Guide (Tap-from-Repo)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ArgsBarg provides native, first-class support for packaging, releasing, and distributing command-line binaries and shell autocomplete configurations through Homebrew via a standard **tap-from-repo** model. This is designed to serve as a secure, standard-compliant mechanism for internal enterprise distribution.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| Binary + completions | Formula `install` block |
|
|
10
|
-
| Skills + MCP | Formula `post_install` → `{key} configure --sync --yes` |
|
|
11
|
-
| App config file | Bootstrapped as `{}` on `post_install` via `--sync` (`~/.local/lib/<key>/config.json`) |
|
|
12
|
-
| App config values | User opt-in: `{key} configure` (interactive wizard when `program.appConfig` has entries) |
|
|
13
|
-
| App config cleanup | Formula `uninstall` → `{key} configure --remove-all --yes` |
|
|
7
|
+
## 1. Enterprise Distribution Model
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
ArgsBarg maps the lifecycle of your application directly to standard Homebrew hooks, separating binary installation from user-interactive environment setup.
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
| Layer | Mechanism | Role in Lifecycle |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| **Binary & Autocompletions** | Formula `install` block | Installs compiled binary and registers native shell autocompletions. |
|
|
14
|
+
| **Telemetry & Agent Synclinks** | Formula `post_install` | Automatically runs `{key} configure --sync --yes` to bootstrap configuration files and sync developer tools. |
|
|
15
|
+
| **Application Configuration** | User-facing `{key} configure` | Runs an interactive TTY setup wizard (only when `program.appConfig` defines required parameters). |
|
|
16
|
+
| **Clean Uninstall** | Formula `uninstall` | Automatically runs `{key} configure --remove-all --yes` to clean up local configurations and symlinks. |
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
*Note: This architecture explicitly separates non-interactive installation (safe for automation/CI) from interactive configuration (which requires a TTY).*
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
brew install gh # skip if already installed
|
|
23
|
-
gh auth login # skip if already authenticated
|
|
24
|
-
```
|
|
20
|
+
---
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
## 2. Distribution Strategies: Public vs. Private Taps
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
brew tap <org>/<repo> git@github.com:<org>/<repo>.git
|
|
30
|
-
brew install <tap>/{key}
|
|
31
|
-
{key} configure # when app config is required
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Upgrade:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
brew upgrade {key}
|
|
38
|
-
```
|
|
24
|
+
ArgsBarg supports both open-source public formulas and secure private enterprise distribution. You can configure your repository structure depending on your project type.
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
### Strategy A: Public Open-Source Taps (Default)
|
|
41
27
|
|
|
42
|
-
|
|
28
|
+
For open-source projects, Homebrew requires zero authentication. Users can tap your public repository and install your application with standard commands out of the box:
|
|
43
29
|
|
|
44
30
|
```bash
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
just reinstall-local # fast binary swap (`install -m 755` into Cellar; run install-local first)
|
|
48
|
-
just uninstall # undo formula + agent artifacts (app config removed by formula uninstall)
|
|
49
|
-
```
|
|
31
|
+
# Tap the public repository
|
|
32
|
+
brew tap <org>/<repo>
|
|
50
33
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
bun scripts/dev-formula.ts install # back up release formula, write file:// dev formula
|
|
55
|
-
brew install --formula <tap>/{key} # install from the dev formula
|
|
56
|
-
bun scripts/dev-formula.ts reset # restore release formula
|
|
34
|
+
# Install the application
|
|
35
|
+
brew install <tap>/{key}
|
|
57
36
|
```
|
|
58
37
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### Developer uninstall
|
|
38
|
+
The generated Homebrew formula points directly to your public GitHub release asset URL, allowing anyone to install and receive automatic updates securely.
|
|
62
39
|
|
|
63
|
-
|
|
64
|
-
| --- | --- |
|
|
65
|
-
| `just uninstall` | Formula `{key}` + tap symlink + skills/MCP + app config via formula `uninstall` |
|
|
66
|
-
| `just uninstall-config` | App config file only (`configure --remove-config --yes`) |
|
|
67
|
-
| `just uninstall-release` | Release formula from `{tap}` (keeps tap; agent artifacts via formula `uninstall`) |
|
|
68
|
-
| `just uninstall-release-tap` | Release formula + `brew untap {tap}` (agent artifacts via formula `uninstall`) |
|
|
69
|
-
| `just test-release` | Install release formula and run formula test |
|
|
40
|
+
### Strategy B: Private & Proprietary Corporate Taps
|
|
70
41
|
|
|
71
|
-
|
|
42
|
+
For proprietary, inner-source, or internal company tools, security is paramount. ArgsBarg provides a built-in strategy to distribute packages securely from private GitHub repositories without exposing sensitive personal tokens or raw download links in your formula code.
|
|
72
43
|
|
|
73
|
-
|
|
44
|
+
#### 1. End-User Authentication:
|
|
45
|
+
Users authenticate locally using the standard GitHub CLI (`gh`), which Homebrew natively integrates with to retrieve download credentials:
|
|
74
46
|
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
end
|
|
47
|
+
```bash
|
|
48
|
+
# 1. Install and authenticate with GitHub CLI (if not already done)
|
|
49
|
+
brew install gh
|
|
50
|
+
gh auth login
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
52
|
+
# 2. Tap and install your private corporate repository
|
|
53
|
+
brew tap <org>/<repo> git@github.com:<org>/<repo>.git
|
|
54
|
+
brew install <tap>/{key}
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
56
|
+
# 3. Perform interactive configuration (such as API tokens) if required
|
|
57
|
+
{key} configure
|
|
88
58
|
```
|
|
89
59
|
|
|
90
|
-
|
|
60
|
+
#### 2. The Private Release Strategy:
|
|
61
|
+
Release formulae generated by ArgsBarg's scripts utilize a custom **`GitHubPrivateReleaseDownloadStrategy`**. This strategy executes the secure asset download through standard GitHub API requests, leveraging the user's local `gh` login credentials securely under the hood:
|
|
91
62
|
|
|
92
63
|
```ruby
|
|
93
64
|
url "https://github.com/<org>/<repo>/releases/download/vX.Y.Z/{key}",
|
|
94
65
|
using: GitHubPrivateReleaseDownloadStrategy
|
|
95
66
|
```
|
|
96
67
|
|
|
97
|
-
|
|
68
|
+
---
|
|
98
69
|
|
|
99
|
-
|
|
70
|
+
## 3. Standardized Formula Pattern
|
|
100
71
|
|
|
101
|
-
|
|
72
|
+
ArgsBarg standardizes your Homebrew formulas. A typical generated formula (`Formula/{key}.rb`) is incredibly clean:
|
|
102
73
|
|
|
103
|
-
|
|
74
|
+
```ruby
|
|
75
|
+
class Myapp < Formula
|
|
76
|
+
desc "My application description"
|
|
77
|
+
homepage "https://github.com/org/myapp"
|
|
78
|
+
url "https://github.com/org/myapp/releases/download/v1.0.0/myapp.zip"
|
|
79
|
+
sha256 "a1b2c3d4e5f6g7h8..."
|
|
80
|
+
version "1.0.0"
|
|
81
|
+
|
|
82
|
+
def install
|
|
83
|
+
bin.install "myapp"
|
|
84
|
+
# Auto-generates shell completions for bash, zsh, and fish directly from the executable
|
|
85
|
+
generate_completions_from_executable(bin/"myapp", "completion", base_name: "myapp")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def post_install
|
|
89
|
+
# Non-interactive bootstrap of config files and developer links
|
|
90
|
+
system bin/"myapp", "configure", "--sync", "--yes"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def uninstall
|
|
94
|
+
# Graceful clean up of local files on uninstall
|
|
95
|
+
system bin/"myapp", "configure", "--remove-all", "--yes"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def caveats
|
|
99
|
+
<<~EOS
|
|
100
|
+
Interactive configuration is required. Please run:
|
|
101
|
+
myapp configure
|
|
102
|
+
EOS
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
```
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
---
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
## 4. Developer Iteration Workflow
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
bunx argsbarg create my-cli \
|
|
111
|
-
--key my-cli --class-name MyCli --tap org/my-cli \
|
|
112
|
-
--homepage https://github.com/org/my-cli --release-repo org/my-cli \
|
|
113
|
-
--yes
|
|
114
|
-
```
|
|
111
|
+
ArgsBarg provides an optimized workflow for developers to build, package, and test their Homebrew installer locally before pushing releases.
|
|
115
112
|
|
|
116
|
-
|
|
113
|
+
### Local Staging Commands:
|
|
117
114
|
|
|
118
115
|
```bash
|
|
119
|
-
|
|
116
|
+
# 1. Build the local release binary
|
|
117
|
+
just build
|
|
118
|
+
|
|
119
|
+
# 2. Stage and install the formula locally (bypasses GitHub, uses file://)
|
|
120
|
+
just install-local
|
|
121
|
+
|
|
122
|
+
# 3. Swap updated binaries quickly during tight edit cycles
|
|
123
|
+
just reinstall-local
|
|
124
|
+
|
|
125
|
+
# 4. Uninstall the binary and gracefully clean up all configurations
|
|
126
|
+
just uninstall
|
|
120
127
|
```
|
|
121
128
|
|
|
122
|
-
|
|
129
|
+
### Under the Hood:
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
To ensure you test the exact formula that will be shipped to production, `just install-local` runs:
|
|
125
132
|
|
|
126
|
-
|
|
133
|
+
1. `bun scripts/dev-formula.ts install` — Safely backs up your production formula and writes a temporary local dev formula using a `file://` URL pointing to your build directory.
|
|
134
|
+
2. `brew install --formula <tap>/{key}` — Installs the package locally using Homebrew.
|
|
135
|
+
3. `bun scripts/dev-formula.ts reset` — Automatically restores your production formula on disk.
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
2. `scripts/release.ts` → zips `dist/{key}` to `dist/{key}.zip`, writes `Formula/{key}.rb` (GitHub zip URL + archive sha256), commits, tags, uploads `dist/{key}.zip` to GitHub Releases
|
|
130
|
-
3. Users `brew upgrade {key}` from the tap
|
|
137
|
+
---
|
|
131
138
|
|
|
132
|
-
|
|
139
|
+
## 5. Automated Release Pipeline
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
ArgsBarg automates the release cycle. A production-ready release is performed using a single command:
|
|
135
142
|
|
|
136
143
|
```bash
|
|
137
|
-
|
|
138
|
-
just release
|
|
139
|
-
just release --purge --dry-run # list tags that would be deleted
|
|
140
|
-
just release patch --purge # release, then purge older releases
|
|
144
|
+
# Performs build, zips binary, updates Formula with new SHA-256, tags git, pushes, and uploads release asset
|
|
145
|
+
just release patch # or minor | major
|
|
141
146
|
```
|
|
142
147
|
|
|
143
|
-
|
|
148
|
+
### Release Pipeline Steps:
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
1. **Build**: Compiles the binary to `dist/{key}`.
|
|
151
|
+
2. **Archive**: Packages the binary into a compressed `dist/{key}.zip`.
|
|
152
|
+
3. **Integrity Check**: Calculates the cryptographically secure SHA-256 hash of the zip file.
|
|
153
|
+
4. **Formula Sync**: Updates the version number and `sha256` parameter in `Formula/{key}.rb`.
|
|
154
|
+
5. **Tag & Push**: Commits changes, tags the repository with the new version, pushes to GitHub, and publishes the compiled zip to GitHub Releases.
|
|
146
155
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
### Older Release Retention & Cleanup:
|
|
157
|
+
|
|
158
|
+
To keep your storage footprint clean, the pipeline supports purging stale historical release assets while preserving the git tags:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
just release --purge # Interactive tag purge of older release records
|
|
162
|
+
just release --purge --yes # Silent automated purge (useful in CI/CD)
|
|
163
|
+
just release --purge --dry-run # Preview list of tag deletions
|
|
164
|
+
```
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
---
|
|
156
167
|
|
|
157
|
-
|
|
168
|
+
## 6. Directory Defaults
|
|
158
169
|
|
|
159
|
-
|
|
170
|
+
Applications packaged via ArgsBarg adhere to standard system directories:
|
|
171
|
+
* **Resolved Configuration Path**: `~/.local/lib/<sanitized-key>/config.json`
|
|
172
|
+
* **Auto-Exports**: Developers can import `resolveAppConfigPath` or `displayAppConfigPath` directly from `argsbarg` to display helpful directories in help screens.
|
package/docs/http-server.md
CHANGED
|
@@ -49,7 +49,9 @@ Set `httpServer` on the **program root only**. Validation rejects `httpServer` o
|
|
|
49
49
|
|
|
50
50
|
`httpServer` and `mcpServer` are independent — enable either or both.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
## Logging
|
|
53
|
+
|
|
54
|
+
Server logs (access lines, errors, startup) go to **stderr** as JSON by default. See **[logging.md](logging.md)** for `program.log`, **`enrich`**, **`serialize`**, trace headers, and examples.
|
|
53
55
|
|
|
54
56
|
## REST routes
|
|
55
57
|
|
package/docs/logging.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Server logging
|
|
2
|
+
|
|
3
|
+
When you run `myapp http` or `myapp mcp`, Argsbarg writes **server logs to stderr** — not to stdout (handlers and CLI output stay on stdout).
|
|
4
|
+
|
|
5
|
+
By default each log line is **one JSON object** (NDJSON), shaped for the [ECS Logging](https://github.com/elastic/ecs-logging) convention. That plays nicely with Datadog, Elasticsearch, GCP Logging, and similar collectors.
|
|
6
|
+
|
|
7
|
+
For local development, switch to plain text with `--log-format text` or `program.log.format: "text"`.
|
|
8
|
+
|
|
9
|
+
## What gets logged
|
|
10
|
+
|
|
11
|
+
| Event | When | `event.action` |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| Server start | HTTP/MCP process listens | `http.server.start` / `server.start` |
|
|
14
|
+
| Access | After each HTTP request or MCP JSON-RPC message | `http.access` / `mcp.access` |
|
|
15
|
+
| Invoke error | After `formatError` → `onError`, before the client sees the error | `invoke.error` |
|
|
16
|
+
|
|
17
|
+
Toggle access or error lines with `program.log.access` and `program.log.errors` (both default to `true`).
|
|
18
|
+
|
|
19
|
+
## Example line (default JSON)
|
|
20
|
+
|
|
21
|
+
After `GET /workspaces` returns 200 in 45ms:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"@timestamp": "2026-07-27T14:00:00.000Z",
|
|
26
|
+
"log.level": "info",
|
|
27
|
+
"message": "GET /workspaces",
|
|
28
|
+
"ecs.version": "8.11.0",
|
|
29
|
+
"service.name": "myapp",
|
|
30
|
+
"service.version": "1.0.0",
|
|
31
|
+
"event.action": "http.access",
|
|
32
|
+
"http.request.method": "GET",
|
|
33
|
+
"url.path": "/workspaces",
|
|
34
|
+
"http.response.status_code": 200,
|
|
35
|
+
"event.duration": 45000000,
|
|
36
|
+
"labels": { "request_id": "…" }
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`event.duration` is in **nanoseconds** (ECS convention). Durations in hook callbacks (`durationMs`) stay in milliseconds.
|
|
41
|
+
|
|
42
|
+
When the client sends a W3C **`traceparent`** header, lines also include `trace.id` and `span.id`, and the response echoes an updated `traceparent`.
|
|
43
|
+
|
|
44
|
+
## `program.log` options
|
|
45
|
+
|
|
46
|
+
Set on the **program root** (same level as `httpServer` / `mcpServer`):
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const program = {
|
|
50
|
+
key: "myapp",
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
description: "…",
|
|
53
|
+
log: {
|
|
54
|
+
format: "json", // "text" for human-readable stderr
|
|
55
|
+
file: "server.log", // optional tee; relative paths → app config dir
|
|
56
|
+
access: true, // HTTP/MCP access lines
|
|
57
|
+
errors: true, // invoke error lines
|
|
58
|
+
},
|
|
59
|
+
// …
|
|
60
|
+
} satisfies CliProgram;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Field | Default | Purpose |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `format` | `"json"` | `"json"` = ECS Logging NDJSON; `"text"` = `INFO [http.access]: GET /path` |
|
|
66
|
+
| `file` | — | Append the same lines to this path |
|
|
67
|
+
| `access` | `true` | Emit one line per HTTP request / MCP message |
|
|
68
|
+
| `errors` | `true` | Emit when a user command fails on HTTP/MCP |
|
|
69
|
+
| `enrich` | — | Add custom fields to each JSON line (see below) |
|
|
70
|
+
| `serialize` | — | Replace the built-in formatter entirely (see below) |
|
|
71
|
+
|
|
72
|
+
CLI overrides on `myapp http` and `myapp mcp serve`: `--log-format`, `--log-file`, `--no-access-log` (HTTP only), `--dev` (print full stacks to stderr on errors).
|
|
73
|
+
|
|
74
|
+
## `program.log.enrich` — add fields
|
|
75
|
+
|
|
76
|
+
Use **`enrich`** when you want **extra JSON fields** on top of the default ECS line — for example a team label, deployment cell, or a shape your log pipeline expects.
|
|
77
|
+
|
|
78
|
+
`enrich` is **additive only**. It cannot change `@timestamp`, `log.level`, `message`, `ecs.version`, `service.name`, `service.version`, or any field Argsbarg already set on that line.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import type { LogEnrichContext } from "argsbarg";
|
|
82
|
+
|
|
83
|
+
const program = {
|
|
84
|
+
// …
|
|
85
|
+
log: {
|
|
86
|
+
format: "json",
|
|
87
|
+
enrich: (ctx: LogEnrichContext) => {
|
|
88
|
+
// Always available:
|
|
89
|
+
// ctx.level, ctx.message, ctx.action, ctx.service.name, ctx.service.version
|
|
90
|
+
// ctx.requestId, ctx.traceId, ctx.spanId (when present)
|
|
91
|
+
// ctx.labels, ctx.error (on error lines)
|
|
92
|
+
|
|
93
|
+
// On access logs (http.access / mcp.access):
|
|
94
|
+
// ctx.http.method, ctx.http.path, ctx.http.status, ctx.http.durationMs, ctx.http.clientIp
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
deployment: "prod",
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
} satisfies CliProgram;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Return a flat object of field names → values. Argsbarg merges each key onto the log line unless that key is already set. To add team metadata inside ECS `labels`, put it in `event.labels` via hooks rather than fighting merge order — or use `serialize` for full control.
|
|
105
|
+
|
|
106
|
+
## `program.log.serialize` — own the whole line
|
|
107
|
+
|
|
108
|
+
Use **`serialize`** when the default ECS line is not what you need — for example a legacy JSON schema used only in your organization.
|
|
109
|
+
|
|
110
|
+
When `serialize` is set, Argsbarg **does not** run the ECS formatter. Your function receives the same `LogEnrichContext` as `enrich` and must return the **full line text without a trailing newline** (Argsbarg adds `\n`).
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import type { LogEnrichContext } from "argsbarg";
|
|
114
|
+
|
|
115
|
+
const program = {
|
|
116
|
+
// …
|
|
117
|
+
log: {
|
|
118
|
+
format: "json",
|
|
119
|
+
serialize: (ctx: LogEnrichContext) =>
|
|
120
|
+
JSON.stringify({
|
|
121
|
+
message: ctx.message,
|
|
122
|
+
level: ctx.level.toUpperCase(),
|
|
123
|
+
contextMap: {
|
|
124
|
+
...(ctx.traceId ? { trace_id: ctx.traceId } : {}),
|
|
125
|
+
...(ctx.spanId ? { span_id: ctx.spanId } : {}),
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
} satisfies CliProgram;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Do **not** set both `enrich` and `serialize` expecting both to apply — `serialize` wins and `enrich` is ignored.
|
|
133
|
+
|
|
134
|
+
Prefer **`enrich`** when you only need a few extra fields. Reserve **`serialize`** for fully custom output.
|
|
135
|
+
|
|
136
|
+
## Trace correlation (HTTP)
|
|
137
|
+
|
|
138
|
+
If an upstream service (gateway, sidecar, mesh) sends a standard **`traceparent`** header:
|
|
139
|
+
|
|
140
|
+
1. Argsbarg parses it and logs `trace.id` / `span.id`.
|
|
141
|
+
2. The HTTP response includes an updated `traceparent` for this hop.
|
|
142
|
+
|
|
143
|
+
No configuration required. If the header is missing, Argsbarg does not invent a trace id.
|
|
144
|
+
|
|
145
|
+
## Related
|
|
146
|
+
|
|
147
|
+
- [http-server.md](http-server.md) — HTTP server setup and endpoints
|
|
148
|
+
- [mcp.md](mcp.md) — MCP server (same `program.log` applies)
|
|
149
|
+
- [decisions.md](decisions.md#structured-logging-ecs-logging) — why ECS Logging and hooks instead of a bundled observability SDK
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "log-format",
|
|
164
|
-
"description": "Log format: json (ECS) or text.",
|
|
164
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
165
165
|
"kind": "enum",
|
|
166
166
|
"choices": [
|
|
167
167
|
"json",
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
"name": "log-format",
|
|
218
|
-
"description": "Log format: json (ECS) or text.",
|
|
218
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
219
219
|
"kind": "enum",
|
|
220
220
|
"choices": [
|
|
221
221
|
"json",
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
"name": "log-format",
|
|
397
|
-
"description": "Log format: json (ECS) or text.",
|
|
397
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
398
398
|
"kind": "enum",
|
|
399
399
|
"choices": [
|
|
400
400
|
"json",
|
|
@@ -448,7 +448,7 @@
|
|
|
448
448
|
},
|
|
449
449
|
{
|
|
450
450
|
"name": "log-format",
|
|
451
|
-
"description": "Log format: json (ECS) or text.",
|
|
451
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
452
452
|
"kind": "enum",
|
|
453
453
|
"choices": [
|
|
454
454
|
"json",
|
|
@@ -649,7 +649,7 @@
|
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
651
|
"name": "log-format",
|
|
652
|
-
"description": "Log format: json (ECS) or text.",
|
|
652
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
653
653
|
"kind": "enum",
|
|
654
654
|
"choices": [
|
|
655
655
|
"json",
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
},
|
|
704
704
|
{
|
|
705
705
|
"name": "log-format",
|
|
706
|
-
"description": "Log format: json (ECS) or text.",
|
|
706
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
707
707
|
"kind": "enum",
|
|
708
708
|
"choices": [
|
|
709
709
|
"json",
|
|
@@ -886,7 +886,7 @@
|
|
|
886
886
|
},
|
|
887
887
|
{
|
|
888
888
|
"name": "log-format",
|
|
889
|
-
"description": "Log format: json (ECS) or text.",
|
|
889
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
890
890
|
"kind": "enum",
|
|
891
891
|
"choices": [
|
|
892
892
|
"json",
|
|
@@ -940,7 +940,7 @@
|
|
|
940
940
|
},
|
|
941
941
|
{
|
|
942
942
|
"name": "log-format",
|
|
943
|
-
"description": "Log format: json (ECS) or text.",
|
|
943
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
944
944
|
"kind": "enum",
|
|
945
945
|
"choices": [
|
|
946
946
|
"json",
|
|
@@ -1119,7 +1119,7 @@
|
|
|
1119
1119
|
},
|
|
1120
1120
|
{
|
|
1121
1121
|
"name": "log-format",
|
|
1122
|
-
"description": "Log format: json (ECS) or text.",
|
|
1122
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1123
1123
|
"kind": "enum",
|
|
1124
1124
|
"choices": [
|
|
1125
1125
|
"json",
|
|
@@ -1173,7 +1173,7 @@
|
|
|
1173
1173
|
},
|
|
1174
1174
|
{
|
|
1175
1175
|
"name": "log-format",
|
|
1176
|
-
"description": "Log format: json (ECS) or text.",
|
|
1176
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1177
1177
|
"kind": "enum",
|
|
1178
1178
|
"choices": [
|
|
1179
1179
|
"json",
|
|
@@ -1356,7 +1356,7 @@
|
|
|
1356
1356
|
},
|
|
1357
1357
|
{
|
|
1358
1358
|
"name": "log-format",
|
|
1359
|
-
"description": "Log format: json (ECS) or text.",
|
|
1359
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1360
1360
|
"kind": "enum",
|
|
1361
1361
|
"choices": [
|
|
1362
1362
|
"json",
|
|
@@ -1410,7 +1410,7 @@
|
|
|
1410
1410
|
},
|
|
1411
1411
|
{
|
|
1412
1412
|
"name": "log-format",
|
|
1413
|
-
"description": "Log format: json (ECS) or text.",
|
|
1413
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1414
1414
|
"kind": "enum",
|
|
1415
1415
|
"choices": [
|
|
1416
1416
|
"json",
|
|
@@ -1589,7 +1589,7 @@
|
|
|
1589
1589
|
},
|
|
1590
1590
|
{
|
|
1591
1591
|
"name": "log-format",
|
|
1592
|
-
"description": "Log format: json (ECS) or text.",
|
|
1592
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1593
1593
|
"kind": "enum",
|
|
1594
1594
|
"choices": [
|
|
1595
1595
|
"json",
|
|
@@ -1643,7 +1643,7 @@
|
|
|
1643
1643
|
},
|
|
1644
1644
|
{
|
|
1645
1645
|
"name": "log-format",
|
|
1646
|
-
"description": "Log format: json (ECS) or text.",
|
|
1646
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1647
1647
|
"kind": "enum",
|
|
1648
1648
|
"choices": [
|
|
1649
1649
|
"json",
|
|
@@ -1822,7 +1822,7 @@
|
|
|
1822
1822
|
},
|
|
1823
1823
|
{
|
|
1824
1824
|
"name": "log-format",
|
|
1825
|
-
"description": "Log format: json (ECS) or text.",
|
|
1825
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1826
1826
|
"kind": "enum",
|
|
1827
1827
|
"choices": [
|
|
1828
1828
|
"json",
|
|
@@ -1876,7 +1876,7 @@
|
|
|
1876
1876
|
},
|
|
1877
1877
|
{
|
|
1878
1878
|
"name": "log-format",
|
|
1879
|
-
"description": "Log format: json (ECS) or text.",
|
|
1879
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1880
1880
|
"kind": "enum",
|
|
1881
1881
|
"choices": [
|
|
1882
1882
|
"json",
|
|
@@ -2055,7 +2055,7 @@
|
|
|
2055
2055
|
},
|
|
2056
2056
|
{
|
|
2057
2057
|
"name": "log-format",
|
|
2058
|
-
"description": "Log format: json (ECS) or text.",
|
|
2058
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
2059
2059
|
"kind": "enum",
|
|
2060
2060
|
"choices": [
|
|
2061
2061
|
"json",
|
|
@@ -2109,7 +2109,7 @@
|
|
|
2109
2109
|
},
|
|
2110
2110
|
{
|
|
2111
2111
|
"name": "log-format",
|
|
2112
|
-
"description": "Log format: json (ECS) or text.",
|
|
2112
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
2113
2113
|
"kind": "enum",
|
|
2114
2114
|
"choices": [
|
|
2115
2115
|
"json",
|