@klok-integration/cli 0.6.235 → 0.7.248

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
@@ -48,6 +48,7 @@ Credentials are written to `~/.config/klok/credentials.json` with mode 0600.
48
48
  | `klok agents update [--check] [--global]` | Fetch what moved in the platform and tenant catalogs; `--check` writes nothing and exits 5 when something is outdated. |
49
49
  | `klok agents status` | Per file and per catalog: current, outdated, missing or unreachable. |
50
50
  | `klok bead list\|show\|report` | Progress beads in the current repository. |
51
+ | `klok docs list` | The documentation projects on docs.klok.dev you may read, by doc id. |
51
52
  | `klok docs read <doc-id>` | Print a documentation project's `llm.txt` from docs.klok.dev, read with your GitLab token and cached. |
52
53
  | `klok docs id [path]` | The doc id of a repository path. |
53
54
  | `klok docs publish` | Build this repository's znai documentation and upload it to the docs portal. |
@@ -12,6 +12,8 @@ needs. Read `klok docs read klok-framework-klok-quarkus-extension` before writin
12
12
  ./gradlew updateKlokLibsToml # refresh gradle/klok-libs.versions.toml from the dependency catalog
13
13
  ./gradlew quarkusDev # run locally against the configured broker
14
14
  ./gradlew initDocsGeneration # route facts to build/klokRoutes/docs.json
15
+ ./gradlew klokTopics # the broker topics the service needs, to build/klok-topics/topics.json
16
+ ./gradlew klokTopicCheck --report # asks klok.dev whether each topic exists and is granted (KLOK_INTEGRATION_CONTEXT_TOKEN)
15
17
  ```
16
18
 
17
19
  ### Rules
@@ -25,6 +27,10 @@ needs. Read `klok docs read klok-framework-klok-quarkus-extension` before writin
25
27
  matches it, and both projects' `klok-docs/` write it down. A topic has at most one purpose; a reader is its
26
28
  subscription (its route id), never a suffix. Never consume a shared topic and discard the other flows' messages.
27
29
  The `klok-route` skill has the details.
30
+ * The broker creates no topics. After adding or changing a route, a purpose or an override, run
31
+ `./gradlew klokTopics`, resolve its warnings, and make sure every topic it lists exists: request a missing one (or
32
+ a grant) in klok.dev, or add it to the tenant's Pulsar file in a merge request, and list it as a manual step. The
33
+ service fails at startup with `TOPIC_MISSING` or `TOPIC_ACCESS_DENIED` and the fix when one is missing.
28
34
  * Errors: throw `Klok4XXException` for caller errors (no retry) and `Klok5XXException` or plain exceptions for
29
35
  retryable failures; the framework retries, republishes to `_DLQ` and emits the failure event. Do not add
30
36
  `onException` blocks unless the route owns the failure (`failureHandled()`).
@@ -12,11 +12,18 @@ Before anything else, run `klok agents update --check`. Exit 5 means the install
12
12
  run `klok agents update` and read the refreshed files. Exit 0 means they are current, and any other code names
13
13
  what went wrong (no token, no network); say so instead of guessing.
14
14
 
15
+ On a workstation, `klok sync pull` then brings the workspace current before you read it: it fast-forwards every
16
+ canonical checkout under the workspace root, never merges or resets one, and skips `<root>/worktrees`. It is the one
17
+ sanctioned update of a canonical checkout. A service never clones a repository just to read it: klok.dev and the agent
18
+ read through the GitLab API, docs.klok.dev and the integration context. The `klok-cli` skill says which klok command
19
+ does what.
20
+
15
21
  The platform documentation is published at https://docs.klok.dev, one documentation project per repository, each
16
22
  exposing its whole content as one markdown file. Read it with klok-cli, which sends your GitLab token and caches
17
- the answer:
23
+ the answer. `klok docs list` comes first when you do not know the doc id:
18
24
 
19
25
  ```
26
+ klok docs list # the documentation projects you may read, by doc id
20
27
  klok docs read <doc-id> # the markdown on stdout, one status line on stderr; --json adds fetchedAt
21
28
  klok docs id [tenant/group/.../repo] # the doc id of a repository, this one by default
22
29
  ```
@@ -46,7 +53,7 @@ The `klok-docs` skill describes the lookup in detail. Cite the doc id you relied
46
53
 
47
54
  ## Tenant skills
48
55
 
49
- Next to the platform skills (`klok-docs`, `klok-solution`, `klok-route`, `klok-datamodel`, `klok-release`,
56
+ Next to the platform skills (`klok-docs`, `klok-cli`, `klok-solution`, `klok-route`, `klok-datamodel`, `klok-release`,
50
57
  `klok-worktree`) the skill directories hold your tenant's own skills, generated by KlokDocumentationEgress from the
51
58
  tenant's documentation publishes and served from the tenant's private catalog. The egress reads only tenant klok's
52
59
  publishes today, so another tenant has no tenant skills yet:
@@ -124,8 +131,9 @@ step by step procedure; the contract every agent follows is:
124
131
  exists, use a new id; never delete, reset or force reuse it.
125
132
  * Leave the canonical checkout's branch, files and uncommitted changes exactly as found. Never run `checkout`,
126
133
  `switch`, `pull`, `reset`, `clean`, `stash`, rebase or merge in the canonical checkout or in another session's
127
- worktree. Dirty canonical files are not a blocker: a worktree starts from committed history and does not copy
128
- uncommitted or ignored files; if the task needs them, ask for an explicit handoff.
134
+ worktree. The one exception is `klok sync pull`, which only fast-forwards a canonical checkout and reports one it
135
+ cannot fast-forward. Dirty canonical files are not a blocker: a worktree starts from committed history and does
136
+ not copy uncommitted or ignored files; if the task needs them, ask for an explicit handoff.
129
137
  * Do every edit, build and test in the task worktree, with explicit working directories or `git -C`. Recreate
130
138
  dependencies there; do not copy or symlink `.env`, credentials, `node_modules` or build output from another
131
139
  checkout. A worktree is not a sandbox: use isolated ports, containers and output directories where parallel
@@ -338,9 +346,17 @@ access, Keycloak broker clients or a service that serves several tenants.
338
346
  * **Who applies it:** Ansible (`klok/environment/klok-environment-setup`, `keycloak.yml` and `pulsar.yml`) applies
339
347
  what those files declare: today the platform and tenant klok's services, plus any entries a person adds there for
340
348
  another tenant's service (a playbook per tenant: klok/environment/klok-environment-setup#35). Broker access (a
341
- tenant, a namespace, a topic created in advance, a grant) changes only through a merge request to those Pulsar
342
- files, applied by Ansible run by a person. klok.dev provisions no broker clients or grants yet
343
- (klok/application/frontend-klok-dev#51). A grant made only in the broker's admin API is drift.
349
+ tenant, a namespace, a topic, a grant) changes only through a merge request to those Pulsar files. klok.dev merges
350
+ what needs no approval (the generic topic of every datamodel) and what an owner approved in klok.dev, and applies
351
+ topics and grants from the files; Ansible, run by a person, applies the same files and alone creates namespaces and
352
+ revokes grants. klok.dev provisions no broker clients yet (klok/application/frontend-klok-dev#51). A topic or grant
353
+ made only in the broker's admin API is drift.
354
+ * **Topics are provisioned, never created by the broker.** A topic exists when its tenant's Pulsar file lists it and
355
+ the file is applied; its `_DLQ`, and the `_Response` of a `_Request` topic, come with it. `./gradlew klokTopics`
356
+ lists what a project needs, and a missing topic or grant fails the deploy (`klokTopicCheck`) and the service's start
357
+ with `TOPIC_MISSING` or `TOPIC_ACCESS_DENIED` and the fix. Follow the message: request the topic or access in
358
+ klok.dev, or add the line it names in a merge request, and hand that to a person. Never ask for automatic topic
359
+ creation and never create a topic through the broker's admin API.
344
360
 
345
361
  ## Documentation is part of every change
346
362
 
@@ -93,6 +93,25 @@ documentation or the dependency catalog can give you.
93
93
  for reading across tenants.
94
94
  * Request/reply: `ReqRes_<Request>_<Reply>[_<purpose>]_Request` and `_Response`. Dead letters: `<topic>_DLQ`.
95
95
  * One datamodel per topic. A breaking change is a new major version and therefore a new topic.
96
+ * Topics are provisioned from Git; the broker never creates one by itself. A topic exists when its owning tenant's
97
+ Pulsar file in `klok/environment/klok-environment-setup`
98
+ (`ansible-master/playbooks/group_vars/all/pulsar_tenant_<tenant>.yml`) lists it and the file has been applied. A
99
+ producer or consumer on any other topic is refused. Subscriptions are still created by their consumer.
100
+ * Companions come with every topic and are never requested or listed on their own: `<topic>_DLQ` for every topic, and
101
+ for a `_Request` topic its `_Response` (with that topic's `_DLQ`).
102
+ * klok.dev declares the generic topic `<Model>` of every datamodel, and the ODL's change event topics. Every other
103
+ topic (a purpose, a request/reply pair) and every grant is requested in klok.dev and approved by the owner (a
104
+ TenantAdmin of the tenant or a DomainAdmin of the namespace), or added to the Pulsar file in a merge request.
105
+ * `./gradlew klokTopics` lists the topics a project needs (`build/klok-topics/topics.json`, with a warning for every
106
+ topic the scan cannot resolve) and `./gradlew klokTopicCheck` asks klok.dev whether each exists and is granted to
107
+ the service; in CI it blocks the deploy. A service checks the same at startup and does not start without them.
108
+ * A missing topic or grant is `TOPIC_MISSING` or `TOPIC_ACCESS_DENIED`, never retried. The message names the topic,
109
+ the role, the operation, who approves, the klok.dev request link (`https://klok.dev/monitoring/broker/request?...`)
110
+ and the line to add by hand. Follow it: hand the request link or the merge request to a person. Never create a topic
111
+ or a grant through the broker's admin API, never ask for automatic topic creation, and never turn the startup check
112
+ (`klok.broker.verify-topics`) off in a deployed service.
113
+ * A route that consumes another tenant's topic cannot write its `_DLQ`; where such dead letters go is open
114
+ (klok/framework/klok-common#11).
96
115
  * Every broker message is a CloudEvent in binary content mode: the attributes are message properties, the payload
97
116
  is the typed datamodel. `ce-source` is `urn:klok:<tenant>:<solutionId>:<routeId>`; `ce-type` says what happened
98
117
  (default `dev.klok.<tenant>.<domain>.<Model>.published`).
@@ -135,9 +154,10 @@ whether a model may travel on a topic; it decides how widely the model is shared
135
154
  (`persistent://<tenant>[_<env>]/common/<Model>`), the service is granted `consume` on exactly those topics, and
136
155
  what the platform writes back lives in klok's namespace, one topic per tenant
137
156
  (`persistent://klok[_<env>]/<domain>/<Model>_<tenant>`).
138
- * Broker access (a tenant, a namespace, a topic created in advance, a grant) changes only through a merge request to
139
- the Pulsar variables in `klok/environment/klok-environment-setup`, applied by Ansible run by a person. A grant made
140
- only in the broker's admin API is drift.
157
+ * Broker access (a tenant, a namespace, a topic, a grant) changes only in Git, in the owning tenant's Pulsar file in
158
+ `klok/environment/klok-environment-setup`. klok.dev applies topics and grants from the file (merging what needs no
159
+ approval and what an owner approved); Ansible, run by a person, applies the same files and alone creates namespaces
160
+ and revokes. A topic or grant made only in the broker's admin API is drift.
141
161
  * One Keycloak client per running deployment, never shared and never used by a person. Broker rights are called
142
162
  `publish` and `consume`; *ingress* and *egress* say what a service is and are never permissions.
143
163
 
@@ -27,6 +27,13 @@ topic-dlq # dead letters are <topic>_DLQ
27
27
  (?i)last purpose segment # a topic has one optional purpose set by the publisher; a reader is its subscription (route id)
28
28
  (?i)_<reader> # a topic has one optional purpose set by the publisher; a reader is its subscription (route id)
29
29
  (?i)\breader (as|after) the (last )?purpose # a topic has one optional purpose set by the publisher; a reader is its subscription
30
+ # Topics are provisioned from Git and never created by the broker (2026-10-08): a topic exists when its tenant's
31
+ # Pulsar file lists it and the file is applied; its _DLQ and a _Request topic's _Response come with it.
32
+ (?i)\btopics? (is|are) (auto-?)?created (automatically )?(by|on|with|at) (the |its )?first (producer|publisher|consumer|publish|send|use|message) # topics are provisioned from Git, never created on first use
33
+ (?i)created automatically by (the|its) first (producer|publisher|consumer) # topics are provisioned from Git, never created on first use
34
+ (?i)\btopics? (appears?|comes? into existence) (with|on|at) (the |its )?first (producer|publisher|consumer|publish|use|message) # topics are provisioned from Git, never created on first use
35
+ (?i)\ba topic created in advance # every topic is listed in its tenant's Pulsar file before it is used; "in advance" is the only way
36
+ (?i)\b(enable|turn on|switch on) (automatic|auto-?)[ -]?topic[ -]creation # the Klok broker runs with allowAutoTopicCreation=false; request the topic in klok.dev
30
37
  #
31
38
  # Framework classes that do not exist in the Quarkus extension 2.0 and later.
32
39
  KlokSoapApi # removed in 2.0; SOAP is a KlokCustomRoute with camel-cxf
@@ -206,6 +206,14 @@ blindly. `klok-mock-*` headers are for test and staging and are stripped in prod
206
206
  authentication: alert and dead letter), the tests.
207
207
  5. **Code and review.** Check the transform, the dead letter path, the CloudEvent attributes, logging through the
208
208
  framework (never `System.out`), and the service's broker client and grants.
209
+ 6. **Topics.** The broker never creates a topic. A datamodel's generic topic `<Model>` and every companion (`_DLQ`,
210
+ the `_Response` of a `_Request`) come by themselves; a purpose topic, a request/reply pair and every grant outside
211
+ the service's own namespaces are requested. Run `./gradlew klokTopics`, then have each missing topic or grant
212
+ requested in klok.dev (`/monitoring/broker/request`) or proposed as a merge request to the tenant's Pulsar file,
213
+ approved by the namespace's Domain Admin or the Tenant Admin. When `klokTopicCheck`, the pipeline's
214
+ `klok_topic_check` or the startup report names a `TOPIC_MISSING` or `TOPIC_ACCESS_DENIED`, follow the message:
215
+ it holds the request link, the approver and the line to add. Never suggest automatic topic creation. The whole
216
+ way is the user guide page *Topics On The Klok Broker* (`klok docs read klok-user-guide`).
209
217
 
210
218
  ## Documentation, tests and delivery
211
219
 
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: klok-cli
3
+ description: Which klok command does what on the Klok platform (klok-cli, `@klok/cli`), with the full reference of every command and option in reference.md. Use before running a klok command you have not run in this task, when a task needs the local workspace current (`klok sync pull`), a list of the documentation (`klok docs list`), an answer about the integration landscape (`klok agent ask`), or a check of the solution registry, the deployed fleet, the catalog, a CI job, a deploy manifest, a pin, a bead or a datamodel.
4
+ ---
5
+
6
+ # The klok command line
7
+
8
+ `klok` is the Klok platform's command line tool. It reads with your GitLab token (`KLOK_GIT_APIKEY`, or `--token`)
9
+ and your Keycloak login (`klok login`), and every command takes `--json` for one machine-readable document on stdout.
10
+ This page says which command to reach for. `reference.md` next to it lists every command, option and example of this
11
+ CLI version, generated from the program itself; when it is missing (an installer that copies `SKILL.md` only), run
12
+ `klok --help` and `klok <command> --help`.
13
+
14
+ ## When to use what
15
+
16
+ | You need | Run |
17
+ |---|---|
18
+ | to know the agent instructions and skills are current, at the start of a task | `klok agents update --check` (exit 5: run `klok agents update`) |
19
+ | the local workspace current before you read it | `klok sync pull` |
20
+ | a repository you can see in GitLab but do not have locally | `klok sync clone --dry-run`, then `klok sync clone` |
21
+ | what is dirty, unpushed or behind in the workspace | `klok sync status` (`--fetch` for a current "behind") |
22
+ | the documentation projects you may read | `klok docs list` |
23
+ | one project's documentation | `klok docs read <doc-id>`; `klok docs id <tenant/group/.../repo>` derives a doc id |
24
+ | an answer about the integration landscape, with links | `klok agent ask "<question>"`; `--session <first task id>` for a follow-up |
25
+ | the impact of a datamodel change | `klok agent impact <datamodel> --change minor\|major\|remove` |
26
+ | the solution registry checked against its contract, or against the code | `klok solutions validate`, `klok solutions check` |
27
+ | whether the deployed services run what `main` and the catalog say | `klok fleet status` |
28
+ | the platform catalog's agent assets or its dependents | `klok catalog publish-agents`, `klok catalog release-dependents` (both run in CI) |
29
+ | what a CI job is, whether a change is documentation only, where CI time goes | `klok ci env`, `klok ci docs-only`, `klok ci timings` |
30
+ | a pipeline's image in its deploy manifest | `klok manifest update --dry-run` (CI runs it without) |
31
+ | a release pinned in an infrastructure repository | `klok pin update ... --dry-run` |
32
+ | the beads of the current repository | `klok bead list`, `klok bead show <id>`, `klok bead report <id>` |
33
+ | the repository, root element and namespace a datamodel's class and name give | `klok datamodel names` |
34
+ | an XSD checked the way the datamodel pipeline checks it | `klok datamodel validate` |
35
+ | this repository's `klok-docs/` checked before the merge request | `klok docs build`, `klok docs verify` |
36
+
37
+ ## The workspace
38
+
39
+ `klok sync pull` brings the workspace current before you read it: every repository under the workspace root (config
40
+ key `workspace`, `KLOK_GIT_LOCAL_WORKSPACE`, default `~/devklok`) is fetched and fast-forwarded (`git pull
41
+ --ff-only`). It never merges, rebases or resets, so a checkout with local commits or a diverged branch is reported,
42
+ not changed, and `<root>/worktrees` (the task worktrees) is skipped. It is the one sanctioned update of a canonical
43
+ checkout, made on a workstation. Edits still happen in a task worktree (the `klok-worktree` skill). A service never
44
+ clones a repository just to read it: klok.dev and the agent read through the GitLab API, docs.klok.dev and the
45
+ integration context.
46
+
47
+ ## Reading
48
+
49
+ `klok docs list`, then `klok docs read <doc-id>`, is how to read the platform's documentation; the `klok-docs` skill
50
+ has the doc ids that matter most and what a 401, 403 or 404 means. `klok agent ask` asks Kloker, which reads the
51
+ solution registry, the integration context and the documentation you may read, and answers with links; it is the
52
+ quickest way to find which project, leg or topic handles something.
53
+
54
+ ## Exit codes
55
+
56
+ `0` ok, `1` error, `2` a task waits for input, `3` denied by policy, `4` not authenticated, `5` outdated (instructions,
57
+ or a deployed service). With `--json`, the document says what happened; messages go to stderr.