Skip to content

Commit 933f086

Browse files
IAM-marcoclaude
andcommitted
fix: tighten the claim-state types and the agent-contract example
Review follow-ups on the nudges. `ClaimState`'s `attached` variant made `claimed_at` optional even though `claimState` only ever produces that variant when both `claimed_at` and `team_id` are present, so the optionality described a state that cannot occur. Making it required lets the type say what the constructor guarantees, and the test that built an `attached` value without a timestamp now has to supply one. The doctor check declared `state` untyped, leaving it an evolving `any` and its `ClaimState` import unused. It is annotated now. The `attached` example in the agent contract was not valid JSON: it listed the key names with no values, which is the one thing a document aimed at agents should not do. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 09bca03 commit 933f086

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

apps/cli/SKILLS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ the CLI's help layer, not the envelope.
148148
`setup`, `status`, and `doctor` report whether a team is attached, reading
149149
`claimed_at`/`team_id` from `.zitadel/secret` (no platform call). `status`
150150
carries `data.project.claim` as `{"kind": "detached"}` or
151-
`{"kind": "attached", "team_id", "claimed_at"}`, and `doctor` reports a
151+
`{"kind": "attached", "team_id": "team_01H…", "claimed_at": "2026-08-01T09:00:00.000Z"}`,
152+
and `doctor` reports a
152153
`claim` check. A project with no team is only ever a **warning**, never a
153154
failure — it works exactly like one with a team, so `doctor` still exits 0
154155
and `--fix` deliberately does nothing (a claim needs a human in a browser).

apps/cli/src/commands/doctor/checks/claim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ClaimCheck implements SanityCheck {
2323
readonly path = ".zitadel/secret";
2424

2525
async run(ctx: CheckContext): Promise<CheckOutcome> {
26-
let state;
26+
let state: ClaimState;
2727
try {
2828
state = claimState({
2929
secret: await readZitadelSecret(ctx.cwd),

apps/cli/src/lib/claim-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { publicCliCommand } from "./public-cli";
1010
* opposite output: the first prints nothing at all, the second nudges.
1111
*/
1212
export type ClaimState =
13-
| { kind: "attached"; team_id: string; claimed_at?: string }
13+
| { kind: "attached"; team_id: string; claimed_at: string }
1414
| { kind: "detached" }
1515
| { kind: "not-applicable" };
1616

apps/cli/tests/unit/commands/status.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe("status command", () => {
118118

119119
const json = parseJson(res.stdout) as {
120120
data: {
121-
project: { claim?: { kind: string; team_id?: string } };
121+
project: { claim?: { kind: string; team_id?: string; claimed_at?: string } };
122122
next_actions: string[];
123123
next_commands: string[];
124124
};

apps/cli/tests/unit/lib/claim-state.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("claim state", () => {
5151

5252
describe("claim copy", () => {
5353
it("names the owning team once attached and nudges otherwise", () => {
54-
expect(claimSummary({ kind: "attached", team_id: "team-001" })).toBe(
54+
expect(claimSummary({ kind: "attached", team_id: "team-001", claimed_at: ATTACHED.claimed_at })).toBe(
5555
"attached to team team-001",
5656
);
5757
expect(claimSummary({ kind: "detached" })).toBe("temporary until you attach it to a team");
@@ -71,7 +71,7 @@ describe("claim copy", () => {
7171
for (const copy of [
7272
claimAction("0.1.0"),
7373
claimSummary({ kind: "detached" }) ?? "",
74-
claimSummary({ kind: "attached", team_id: "team-001" }) ?? "",
74+
claimSummary({ kind: "attached", team_id: "team-001", claimed_at: ATTACHED.claimed_at }) ?? "",
7575
]) {
7676
expect(copy).not.toMatch(/\bunclaimed\b/i);
7777
}

0 commit comments

Comments
 (0)