robisie 0.5.42 → 0.5.43

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.
@@ -6,7 +6,9 @@ import { z } from "zod";
6
6
  const text = z.string().trim().min(1), at = z.iso.datetime({ offset: true });
7
7
  const eventSchema = z.strictObject({ id: text, at, sha: z.string().regex(/^[a-f0-9]{40}$/), ref: text, operation: text, result: text });
8
8
  const digest = (v) => createHash("sha256").update(v).digest("hex");
9
- const failure = (e) => e instanceof z.ZodError ? "Niepoprawny kontrakt JSON" : String(e);
9
+ const failure = (e) => e instanceof z.ZodError ? "Niepoprawny kontrakt JSON"
10
+ : e instanceof Error && "code" in e && e.code ? `${String(e.code)}: ${e.message}` : String(e);
11
+ const cleanExit = (r) => r.status === 0 && r.signal === null;
10
12
  export function relative(ref) {
11
13
  if (path.isAbsolute(ref) || ref.split(/[\\/]/).some(p => p === ".." || p === "") || ref.includes("\0"))
12
14
  throw new Error("Obca ścieżka dowodu");
@@ -115,8 +117,8 @@ export function runLocalUsage(input) {
115
117
  const env = { PATH: "/usr/bin:/bin", LANG: "C.UTF-8" };
116
118
  const git = (cwd, args, input) => {
117
119
  const r = spawnSync("git", args, { cwd, env, input, encoding: "utf8", shell: false });
118
- if (r.error || r.status !== 0 || r.signal)
119
- throw new Error(`git ${args[0]}: status=${r.status}, signal=${r.signal}: ${r.stderr ?? ""}`, { cause: r.error });
120
+ if (!cleanExit(r))
121
+ throw new Error(`git ${args[0]}: status=${r.status}, signal=${r.signal}: ${r.stderr ?? ""}${r.error ? `; error=${failure(r.error)}` : ""}`, { cause: r.error });
120
122
  return r.stdout.trim();
121
123
  };
122
124
  try {
@@ -158,8 +160,8 @@ export function runLocalUsage(input) {
158
160
  git(input.repo, ["archive", "--format=tar", `--output=${archive}`, sha]);
159
161
  mkdirSync(copy, { mode: 0o700 });
160
162
  const extracted = spawnSync("tar", ["-xf", archive, "-C", copy], { cwd: run, env, encoding: "utf8", shell: false });
161
- if (extracted.error || extracted.status !== 0 || extracted.signal)
162
- throw new Error(`tar: status=${extracted.status}, signal=${extracted.signal}: ${extracted.stderr ?? ""}`, { cause: extracted.error });
163
+ if (!cleanExit(extracted))
164
+ throw new Error(`tar: status=${extracted.status}, signal=${extracted.signal}: ${extracted.stderr ?? ""}${extracted.error ? `; error=${failure(extracted.error)}` : ""}`, { cause: extracted.error });
163
165
  stage = "drzewo";
164
166
  const tree = new Map();
165
167
  for (const record of git(input.repo, ["ls-tree", "-r", "-z", "--full-tree", sha]).split("\0").filter(Boolean)) {
@@ -205,8 +207,8 @@ export function runLocalUsage(input) {
205
207
  stage = "proces";
206
208
  const executed = spawnSync(process.execPath, [entry, ...input.program.args], { cwd: copy, env, encoding: "utf8", shell: false });
207
209
  const finishedAt = new Date().toISOString();
208
- if (executed.error || executed.status !== 0 || executed.signal)
209
- throw new Error(`Proces użycia: status=${executed.status}, signal=${executed.signal}; stdout=${executed.stdout ?? ""}; stderr=${executed.stderr ?? ""}`, { cause: executed.error });
210
+ if (!cleanExit(executed))
211
+ throw new Error(`Proces użycia: status=${executed.status}, signal=${executed.signal}; stdout=${executed.stdout ?? ""}; stderr=${executed.stderr ?? ""}${executed.error ? `; error=${failure(executed.error)}` : ""}`, { cause: executed.error });
210
212
  stage = "weryfikacja po wykonaniu";
211
213
  verify();
212
214
  stage = "SHA po wykonaniu";
package/dist/mcp.d.ts CHANGED
@@ -14,5 +14,5 @@ export interface Connection {
14
14
  contractVersion: string | null;
15
15
  projectCount: number;
16
16
  }
17
- /** initialize + list_projects: proves the key works end-to-end and reads the board. */
17
+ /** Initialize, discover tools, then prove the key can read the board. */
18
18
  export declare function checkConnection(ctx: Ctx, key: string): Promise<Connection>;
package/dist/mcp.js CHANGED
@@ -150,6 +150,9 @@ async function rpc(ctx, key, id, method, params) {
150
150
  throw new RobisieError("Za dużo zapytań z tym kluczem.", `Odczekaj ${res.headers.get("retry-after") ?? "60"} s i uruchom polecenie ponownie.`);
151
151
  if (!res.ok)
152
152
  throw new RobisieError(`Serwer robisie odpowiedział błędem ${res.status}.`, "Spróbuj ponownie za kilka minut; jeśli błąd zostaje, napisz do robisie.");
153
+ // Notifications have no RPC response; an empty HTTP 202 is successful.
154
+ if (id === undefined)
155
+ return { result: undefined, contractVersion };
153
156
  const message = await readRpc(res, id);
154
157
  if (!message || message.jsonrpc !== "2.0" || ("result" in message) === ("error" in message))
155
158
  throw formatError();
@@ -160,7 +163,7 @@ async function rpc(ctx, key, id, method, params) {
160
163
  }
161
164
  return { result: message.result, contractVersion };
162
165
  }
163
- /** initialize + list_projects: proves the key works end-to-end and reads the board. */
166
+ /** Initialize, discover tools, then prove the key can read the board. */
164
167
  export async function checkConnection(ctx, key) {
165
168
  const init = await rpc(ctx, key, 1, "initialize", {
166
169
  protocolVersion: "2025-06-18",
@@ -171,7 +174,18 @@ export async function checkConnection(ctx, key) {
171
174
  || !nonEmptyString(init.result.protocolVersion) || !isRecord(init.result.capabilities))
172
175
  throw formatError();
173
176
  const serverName = init.result.serverInfo.name;
174
- const list = await rpc(ctx, key, 2, "tools/call", { name: "list_projects", arguments: {} });
177
+ const initialized = await rpc(ctx, key, undefined, "notifications/initialized");
178
+ if (initialized.contractVersion !== null)
179
+ assertCompatible(initialized.contractVersion);
180
+ const tools = await rpc(ctx, key, 2, "tools/list", {});
181
+ if (tools.contractVersion !== null)
182
+ assertCompatible(tools.contractVersion);
183
+ if (!isRecord(tools.result) || !Array.isArray(tools.result.tools)
184
+ || !tools.result.tools.every((tool) => isRecord(tool) && nonEmptyString(tool.name)
185
+ && isRecord(tool.inputSchema) && tool.inputSchema.type === "object")
186
+ || !tools.result.tools.some((tool) => tool.name === "list_projects"))
187
+ throw formatError();
188
+ const list = await rpc(ctx, key, 3, "tools/call", { name: "list_projects", arguments: {} });
175
189
  const result = list.result;
176
190
  if (!isRecord(result) || (result.isError !== undefined && typeof result.isError !== "boolean"))
177
191
  throw formatError();
@@ -198,7 +212,7 @@ export async function checkConnection(ctx, key) {
198
212
  assertCompatible(list.contractVersion);
199
213
  return {
200
214
  serverName,
201
- contractVersion: init.contractVersion ?? list.contractVersion,
215
+ contractVersion: init.contractVersion ?? initialized.contractVersion ?? tools.contractVersion ?? list.contractVersion,
202
216
  projectCount: parsed.length,
203
217
  };
204
218
  }
package/dist/roles.d.ts CHANGED
@@ -17,7 +17,7 @@ export interface Role {
17
17
  export declare function rolesDir(): string;
18
18
  export declare function parseRole(file: Role["file"], text: string): Role;
19
19
  export declare function loadRoles(dir?: string): Role[];
20
- export declare const MANAGED_LINE = "<!-- robisie:managed 0.5.42 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.5.43 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
21
21
  export type AgentFlavor = "claude" | "codex" | "opencode";
22
22
  /** How the operator starts the Builder for one card in its own session (the card id is not a secret). */
23
23
  export declare function builderStartCommand(flavor: AgentFlavor, codexRolePath?: string): string;
package/dist/roles.js CHANGED
@@ -77,6 +77,7 @@ export function adapterSection(flavor, codexRolePath) {
77
77
  "- Use `spawn_builder` to launch the Builder with the launcher shipped in this package; no project-local scripts are required. It selects the Builder provider saved by `npx robisie init` (claude, codex or opencode), keeps the project cwd/environment and confirms the card is `in_progress` with an assignee before reporting success. This does not establish support for mixed-provider review; keep the doctor checks and independent-review requirements.",
78
78
  `- If \`spawn_builder\` fails, report its error and resolve the cause before retrying. Only if the operator explicitly chooses manual startup, give this command for a new terminal in the project directory, with the real card id: \`${builderStartCommand(flavor, codexRolePath)}\`. After the operator says it is running, do the one post-launch \`get_task\` read the contract requires.`,
79
79
  "- Every role runs in its own session. Never act as two roles in one session.",
80
+ ...(flavor === "codex" ? ["- Przed pracą sprawdź dostępność narzędzi serwera `robisie` w tej sesji. Gdy ich brak, zgłoś blokadę z dokładnym komunikatem: „serwer robisie niedostępny w tej sesji — uruchom nową sesję po init”; bez cichego sukcesu, obchodzenia MCP i zmiany statusu karty. Gdy narzędzia są dostępne, kontynuuj zgodnie z kontraktem roli bez restartu sesji. Doctor nie naprawia narzędzi w już otwartej sesji."] : []),
80
81
  ...(flavor === "opencode" ? ["- OpenCode: brak wspieranego protokołu recenzji. Lokalny plugin `plugins/robisie-review-guard.js` odmawia wywołań `robisie_create_task` i `robisie_update_task` ze statusem `delivered` przed wysłaniem do MCP; taka próba nie zmienia karty. Wynik `task` z accept/VERIFIED, nazwa quality-officer-client, opis Agent ani JSON receiptu nie odblokowują przejścia. Hash receiptu nie dowodzi niezależnej sesji recenzenta."] : []),
81
82
  "- The credential comes from the `ROBISIE_KEY` environment variable. Never ask for it in chat and never write it into a card, a file or a command line.",
82
83
  "",
@@ -4,6 +4,12 @@ export type CardLike = {
4
4
  status?: string | null;
5
5
  details?: Record<string, unknown> | null;
6
6
  };
7
+ export type TesterEnvironment = {
8
+ kind: "local-docker";
9
+ episode: string;
10
+ owner: "control-room" | "installation-manager";
11
+ };
12
+ export declare function testerEnvironment(value: unknown): value is TesterEnvironment;
7
13
  export type TesterExecution = {
8
14
  sha: string;
9
15
  at: string;
@@ -20,6 +26,7 @@ export type TesterExecution = {
20
26
  timeoutPaths: string[];
21
27
  skippedTests: string[];
22
28
  transcript: string;
29
+ environment?: TesterEnvironment;
23
30
  retest?: TesterRetestGrant | null;
24
31
  baselineFailures?: {
25
32
  command: string;
@@ -1,6 +1,11 @@
1
1
  import { readFileSync, existsSync } from "node:fs";
2
2
  import { isDeepStrictEqual } from "node:util";
3
3
  import path from "node:path";
4
+ export function testerEnvironment(value) {
5
+ const e = value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
6
+ return e.kind === "local-docker" && typeof e.episode === "string" && /^[a-f0-9]{64}$/.test(e.episode)
7
+ && ["control-room", "installation-manager"].includes(String(e.owner));
8
+ }
4
9
  export function validTestSha(value) {
5
10
  return typeof value === "string" && /^[a-f0-9]{7,40}$/i.test(value);
6
11
  }
@@ -82,6 +87,8 @@ export function execution(value, input) {
82
87
  || !(r.base === null || validTestSha(r.base)) || !(r.testedHead === "UNKNOWN" || validTestSha(r.testedHead))
83
88
  || !(r.failed === null || (typeof failed.command === "string" && typeof failed.output === "string")))
84
89
  throw new Error("Niepoprawny wynik joba testera");
90
+ if (r.environment != null && r.environment !== "" && (!testerEnvironment(r.environment) || !r.failed || failed.command !== "PREPARATION_ERROR"))
91
+ throw new Error("Niepoprawny dowód środowiska testera");
85
92
  if (r.retest !== undefined)
86
93
  retestGrant(r.retest, { ...input.card, details: { ...input.card.details, test: { at: r.at } } });
87
94
  return value;
package/docs/README.en.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — from account to accepted card (package 0.5.42) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.5.43) <!-- x-release-please-version -->
2
2
 
3
3
  In the project directory with its engine configuration, run `npx robisie init`, then `npx robisie doctor`: init prepares the project goal and tester protection list, and doctor checks both inputs.
4
4
 
package/docs/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — od konta do odebranej karty (paczka 0.5.42) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.5.43) <!-- x-release-please-version -->
2
2
 
3
3
  W katalogu projektu z konfiguracją silnika uruchom `npx robisie init`, potem `npx robisie doctor`: init przygotuje cel projektu i listę ochrony testera, a doctor sprawdzi oba wejścia.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robisie",
3
- "version": "0.5.42",
3
+ "version": "0.5.43",
4
4
  "description": "Instalator klienta robisie: łączy agenta (Claude Code, Codex CLI, OpenCode) z tablicą robisie i instaluje role klienta.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",