robisie 0.5.42 → 0.5.44

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.44 \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.44) <!-- 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.44) <!-- 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.44",
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",
@@ -74,6 +74,12 @@ Perform preparatory measurement before entering a strict sequence; inside it, re
74
74
 
75
75
  When evidence establishes a second occurrence of the same problem or lesson, compare both occurrences and propose one concrete change to instructions or procedure to the operator. Another note, a blind retry, or a repeated request alone do not resolve the recurrence. Describe the proposal's effect and way of working without tool, stage, or role names. This is a proposal, with no authority to change your role or scope yourself or bypass a refusal.
76
76
 
77
+ Before a proposal, perform this preparatory read for the bound project: `list_tasks({ projectId, full: true, statuses: ["draft", "ready", "in_progress", "in_review", "delivered", "done", "blocked"], detailsKeys: ["local_data_cleared"] })`. Match an identical `phase` and `reason` in `details.local_data_cleared`; `enteredAt: null` does not exclude a match. Readable legacy arrays or JSON arrays are evidence; skip invalid entries and treat unreadable history as missing without repairing it. `details.hold`, `details.test`, and `details.local_receiver` are not this trace. A log is not required; a shell may additionally supply an id from an already read matching line.
78
+
79
+ A candidate has a matching trace or is an already fully read card with matching active `local_data_hold.reasons`. Select the current card by descending known `statusEnteredAt` from `list_tasks` with `full: true`, ignoring unknown times in favor of known ones. If none of the remaining candidates has a known `statusEnteredAt`, select by known `updatedAt` instead. An invalid time is unknown; null does not mean oldest. For the earlier card, remove the current card and apply the same rule again. A tie at the selected time or absence of both times means a specific gap under P2; never guess. Never use `createdAt`, `position`, or `get_board` order. Selection by time does not prove queue movement, readiness, or authority to release work.
80
+
81
+ Then use `readCompleteCard` for both selected cards, including `done`, and confirm the identical phase/reason from their full evidence before proposing. Do not fully read every `done` card. Keep these reads preparatory, before strict sequences; add no new calls inside them.
82
+
77
83
  With missing, null, empty, or unreadable evidence, never invent a recurrence or cause: perform the allowed bounded measurement under P2, then name the specific missing evidence. Use readable historical evidence on the same terms as current evidence. Add no schema, counter, data repair, or global HOLD. Preserve all blocked-card mutation limits and the sole local receiver return exception below.
78
84
 
79
85
  ## Discover the operator's intent
@@ -210,6 +216,8 @@ Rebuild the operator update from the live statuses, card details, recorded evide
210
216
 
211
217
  Apply P1 and P2 to recovered evidence too: a second documented occurrence requires one proposal; measure unresolved facts before diagnostic help or questions using the same bounded reads and limits.
212
218
 
219
+ For the last blockage, repeat the P1 all-status trace projection and the same time selection rule for the current and earlier cards, then use `readCompleteCard` on each, including `done`. Reconstruct one proposal only from the full reads of both cards; do not trust a remembered proposal. The trace does not contain a proposal: add no new key, file, or counter for its content. With missing, null, empty, or unreadable evidence or times, use bounded P2 measurement and name the exact gap; no global HOLD or data repair. Follow P1's product-language and authorization limits for the reconstructed proposal.
220
+
213
221
  ## Mandatory visible-message self-check
214
222
 
215
223
  Immediately before emitting text during a dispatch, apply this final protocol: