robisie 0.2.1 → 0.3.0
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 +34 -0
- package/README.md +6 -2
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +65 -8
- package/dist/commands.d.ts +8 -0
- package/dist/commands.js +95 -8
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/delivery-local.d.ts +2 -2
- package/dist/delivery-local.js +26 -5
- package/dist/device-login.d.ts +48 -0
- package/dist/device-login.js +523 -0
- package/dist/engine/bundle-report.json +13 -7
- package/dist/engine/tick.cjs +269 -119
- package/dist/engine-inputs.d.ts +13 -0
- package/dist/engine-inputs.js +193 -0
- package/dist/git-commit.d.ts +5 -0
- package/dist/git-commit.js +23 -0
- package/dist/helpers.js +1 -1
- package/dist/login.d.ts +29 -0
- package/dist/login.js +153 -0
- package/dist/manifest.d.ts +6 -0
- package/dist/manifest.js +9 -0
- package/dist/role-registry.d.ts +1 -1
- package/dist/role-registry.js +11 -8
- package/dist/roles.d.ts +1 -1
- package/docs/ENGINE-CONFIG.md +8 -0
- package/docs/README.en.md +24 -5
- package/docs/README.md +25 -6
- package/docs/RELEASE-0.1.0.md +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Ctx } from "./context.js";
|
|
2
|
+
import { type EngineConfig } from "./engine-config.js";
|
|
3
|
+
/** MCP-only installs have no engine; explicit selection never silently falls back. */
|
|
4
|
+
export declare function selectInputDirectory(ctx: Ctx, explicit?: string | null): {
|
|
5
|
+
directory: string;
|
|
6
|
+
configPath?: string;
|
|
7
|
+
} | null;
|
|
8
|
+
export declare function inputDirectory(config: EngineConfig): string;
|
|
9
|
+
export declare function preflightInputs(directory: string, configPath?: string): void;
|
|
10
|
+
/** Inputs belong to the client, not the role manifest or uninstall. */
|
|
11
|
+
export declare function createInputs(directory: string, configPath?: string): void;
|
|
12
|
+
export declare function checkInputs(directory: string, configPath?: string): void;
|
|
13
|
+
export declare const INPUTS_OK = "\u2713 Wej\u015Bcia instalacji: cel projektu i lista ochrony testera s\u0105 gotowe.";
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { accessSync, constants, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
+
import { RobisieError, shellQuote } from "./context.js";
|
|
4
|
+
import { CONFIG_FILE, loadEngineConfig } from "./engine-config.js";
|
|
5
|
+
// Every category uses the same segment boundary; fixed extensions stay exact.
|
|
6
|
+
function pathSegment(name, extension = String.raw `(\.[^/\r\n]*)?`) {
|
|
7
|
+
return String.raw `(^|/)(${name})${extension}(/|$)`;
|
|
8
|
+
}
|
|
9
|
+
const DEFAULT_INPUTS = {
|
|
10
|
+
"NORTH-STAR.md": "Dostarczaj sprawdzone zmiany w zakresie kart projektu.\n",
|
|
11
|
+
"tester-safety-v1.txt": [
|
|
12
|
+
"# Chronione ścieżki: zmiany wymagają odbioru.",
|
|
13
|
+
pathSegment("secrets?|credentials?"),
|
|
14
|
+
pathSegment("migrations"),
|
|
15
|
+
pathSegment("drizzle"),
|
|
16
|
+
pathSegment("src/lib/auth"),
|
|
17
|
+
pathSegment("src/lib/payments"),
|
|
18
|
+
pathSegment("src/app/api/auth"),
|
|
19
|
+
pathSegment("src/app/api/webhooks"),
|
|
20
|
+
pathSegment(String.raw `\.github/workflows`),
|
|
21
|
+
pathSegment("deploy", String.raw `\.ya?ml`),
|
|
22
|
+
pathSegment("wrangler", String.raw `\.(toml|jsonc?)`),
|
|
23
|
+
pathSegment(String.raw `\.git`),
|
|
24
|
+
pathSegment(String.raw `\.env[^/\r\n]*`), "",
|
|
25
|
+
].join("\n"),
|
|
26
|
+
};
|
|
27
|
+
function problem(path, configPath) {
|
|
28
|
+
return new RobisieError(`Nie mogę potwierdzić wejść instalacji: ${path}.`, `Sprawdź wskazany plik i jego uprawnienia, potem uruchom \`npx robisie init${configPath ? ` --engine-config ${shellQuote(configPath)}` : ""}\` w katalogu projektu.`);
|
|
29
|
+
}
|
|
30
|
+
function missing(error) { return error?.code === "ENOENT"; }
|
|
31
|
+
/** MCP-only installs have no engine; explicit selection never silently falls back. */
|
|
32
|
+
export function selectInputDirectory(ctx, explicit) {
|
|
33
|
+
const env = ctx.env.ROBISIE_ENGINE_CONFIG;
|
|
34
|
+
const selected = explicit ?? (env?.trim() ? env : undefined);
|
|
35
|
+
const path = resolve(ctx.cwd, selected ?? CONFIG_FILE);
|
|
36
|
+
const configPath = selected === undefined ? undefined : path;
|
|
37
|
+
try {
|
|
38
|
+
if (selected === undefined) {
|
|
39
|
+
try {
|
|
40
|
+
lstatSync(path);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (missing(error))
|
|
44
|
+
return null;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
const raw = JSON.parse(readFileSync(path, "utf8").replace(/^\uFEFF/, ""));
|
|
48
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
49
|
+
throw problem(path);
|
|
50
|
+
if (!Object.hasOwn(raw, "engine"))
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
let config;
|
|
54
|
+
try {
|
|
55
|
+
config = loadEngineConfig(path);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof RobisieError)
|
|
59
|
+
throw error;
|
|
60
|
+
if (!(error instanceof Error))
|
|
61
|
+
throw error;
|
|
62
|
+
throw new RobisieError(error.message, `Popraw wskazane pole w pliku konfiguracji, potem sprawdź go offline: npx robisie doctor --engine-config ${shellQuote(path)}`);
|
|
63
|
+
}
|
|
64
|
+
return config.engine.delivery === "local" ? { directory: inputDirectory(config), configPath } : null;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof RobisieError)
|
|
68
|
+
throw error;
|
|
69
|
+
throw problem(path, configPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function inputDirectory(config) {
|
|
73
|
+
try {
|
|
74
|
+
if (config.engine.delivery !== "local")
|
|
75
|
+
throw problem(config.configPath);
|
|
76
|
+
// Resolve the client environment, never links in inputs or its contents.
|
|
77
|
+
let existing = resolve(config.stateDir);
|
|
78
|
+
const suffix = ["inputs"];
|
|
79
|
+
while (true) {
|
|
80
|
+
try {
|
|
81
|
+
lstatSync(existing);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (!missing(error))
|
|
86
|
+
throw error;
|
|
87
|
+
suffix.unshift(basename(existing));
|
|
88
|
+
existing = dirname(existing);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return join(realpathSync(existing), ...suffix);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof RobisieError)
|
|
95
|
+
throw error;
|
|
96
|
+
throw problem(config.stateDir, config.configPath);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Reject links along the write path; do not change modes on user-owned directories. */
|
|
100
|
+
function checkDirectory(directory, writing, configPath) {
|
|
101
|
+
try {
|
|
102
|
+
let existing = directory;
|
|
103
|
+
let stat;
|
|
104
|
+
while (true) {
|
|
105
|
+
try {
|
|
106
|
+
stat = lstatSync(existing);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (!missing(error) || dirname(existing) === existing)
|
|
111
|
+
throw error;
|
|
112
|
+
existing = dirname(existing);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// inputDirectory canonicalizes stateDir; a changed realpath here means a link in the write path.
|
|
116
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || realpathSync(existing) !== existing)
|
|
117
|
+
throw problem(directory, configPath);
|
|
118
|
+
if (existing === directory)
|
|
119
|
+
accessSync(directory, constants.R_OK | constants.X_OK | (writing ? constants.W_OK : 0));
|
|
120
|
+
else if (writing)
|
|
121
|
+
accessSync(existing, constants.W_OK | constants.X_OK);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error instanceof RobisieError)
|
|
125
|
+
throw error;
|
|
126
|
+
throw problem(directory, configPath);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function readInput(directory, name, configPath) {
|
|
130
|
+
const file = join(directory, name);
|
|
131
|
+
try {
|
|
132
|
+
const stat = lstatSync(file);
|
|
133
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
134
|
+
throw problem(file, configPath);
|
|
135
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(readFileSync(file));
|
|
136
|
+
if (!text.trim())
|
|
137
|
+
throw problem(file, configPath);
|
|
138
|
+
if (name === "tester-safety-v1.txt") {
|
|
139
|
+
const rules = text.split(/\r?\n/).map(line => line.trim()).filter(line => line && !line.startsWith("#"));
|
|
140
|
+
if (!rules.length)
|
|
141
|
+
throw problem(file, configPath);
|
|
142
|
+
for (const rule of rules)
|
|
143
|
+
new RegExp(rule, "mi");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
throw problem(file, configPath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function preflightInputs(directory, configPath) {
|
|
151
|
+
checkDirectory(directory, true, configPath);
|
|
152
|
+
for (const name of Object.keys(DEFAULT_INPUTS)) {
|
|
153
|
+
try {
|
|
154
|
+
lstatSync(join(directory, name));
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
if (missing(error))
|
|
158
|
+
continue;
|
|
159
|
+
throw problem(join(directory, name), configPath);
|
|
160
|
+
}
|
|
161
|
+
readInput(directory, name, configPath);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Inputs belong to the client, not the role manifest or uninstall. */
|
|
165
|
+
export function createInputs(directory, configPath) {
|
|
166
|
+
checkDirectory(directory, true, configPath);
|
|
167
|
+
try {
|
|
168
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
169
|
+
const stat = lstatSync(directory);
|
|
170
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
171
|
+
throw problem(directory, configPath);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
throw problem(directory, configPath);
|
|
175
|
+
}
|
|
176
|
+
for (const [name, content] of Object.entries(DEFAULT_INPUTS)) {
|
|
177
|
+
const file = join(directory, name);
|
|
178
|
+
try {
|
|
179
|
+
writeFileSync(file, content, { flag: "wx", mode: 0o600 });
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error?.code !== "EEXIST")
|
|
183
|
+
throw problem(file, configPath);
|
|
184
|
+
}
|
|
185
|
+
readInput(directory, name, configPath);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export function checkInputs(directory, configPath) {
|
|
189
|
+
checkDirectory(directory, false, configPath);
|
|
190
|
+
for (const name of Object.keys(DEFAULT_INPUTS))
|
|
191
|
+
readInput(directory, name, configPath);
|
|
192
|
+
}
|
|
193
|
+
export const INPUTS_OK = "✓ Wejścia instalacji: cel projektu i lista ochrony testera są gotowe.";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
/** Per-command identity only: never persist factory defaults in the client's config. */
|
|
3
|
+
export function gitCommitOptions(args, cwd, timeout = 5_000) {
|
|
4
|
+
const configured = (key) => {
|
|
5
|
+
try {
|
|
6
|
+
return execFileSync("git", ["config", "--get", key], { cwd, encoding: "utf8", timeout, stdio: "pipe" }).trim();
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
if (error.status === 1)
|
|
10
|
+
return ""; // Config key absent.
|
|
11
|
+
throw new Error(`Nie można odczytać git ${key}`, { cause: error });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const name = configured("user.name"), email = configured("user.email");
|
|
15
|
+
const env = { ...process.env };
|
|
16
|
+
const complete = [env.GIT_AUTHOR_NAME ?? name, env.GIT_AUTHOR_EMAIL ?? email,
|
|
17
|
+
env.GIT_COMMITTER_NAME ?? name, env.GIT_COMMITTER_EMAIL ?? email].every(value => value.trim() !== "");
|
|
18
|
+
if (!complete) {
|
|
19
|
+
env.GIT_AUTHOR_NAME = env.GIT_COMMITTER_NAME = "robisie";
|
|
20
|
+
env.GIT_AUTHOR_EMAIL = env.GIT_COMMITTER_EMAIL = "robisie@localhost";
|
|
21
|
+
}
|
|
22
|
+
return { args: ["-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false", ...args], env };
|
|
23
|
+
}
|
package/dist/helpers.js
CHANGED
|
@@ -26,7 +26,7 @@ export function runHelper(name) {
|
|
|
26
26
|
return Promise.reject(new RobisieError(`Brak pomocnika ${name} w paczce.`, "W katalogu projektu wykonaj `npm uninstall robisie`, potem `npm i robisie@<wersja-zgodna-z-kontraktem-serwera>` (zastąp placeholder numerem zgodnego wydania), potem lokalne `npx robisie init` i `npx robisie doctor`."));
|
|
27
27
|
}
|
|
28
28
|
return new Promise((resolve, reject) => {
|
|
29
|
-
const failure = (stage) => new RobisieError(`Nie mogę uruchomić lub zakończyć pomocnika ${name}: ${stage}.`, "Sprawdź instalację Node.js (wymagany
|
|
29
|
+
const failure = (stage) => new RobisieError(`Nie mogę uruchomić lub zakończyć pomocnika ${name}: ${stage}.`, "Sprawdź instalację Node.js (wymagany 24+).");
|
|
30
30
|
const detached = process.platform === "darwin" || process.platform === "linux";
|
|
31
31
|
let child;
|
|
32
32
|
try {
|
package/dist/login.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Ctx } from "./context.js";
|
|
2
|
+
import { type LoginIo, type PairCopies } from "./device-login.js";
|
|
3
|
+
/** Replaceable like commands.ts `loginIo`: tests swap the clock and sleep, never the protocol. */
|
|
4
|
+
export declare const loginRuntime: {
|
|
5
|
+
io: Partial<LoginIo>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* J5 copies of A: the header in `~/.claude.json` (only where init installed it and it is still there) and the
|
|
9
|
+
* manifest login fields. `restore` writes back exactly the captured state and throws when the read-back differs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function pairCopies(ctx: Ctx): PairCopies;
|
|
12
|
+
/** `npx robisie login`; the manifest's installation_id is only a claim the server checks (§5.2). */
|
|
13
|
+
export declare function login(ctx: Ctx, options: {
|
|
14
|
+
wait: boolean;
|
|
15
|
+
timeoutSeconds?: number;
|
|
16
|
+
}): Promise<0 | 1 | 2>;
|
|
17
|
+
/** init without any key and without a terminal pairs instead of stopping at „Brak klucza” (§7.6). */
|
|
18
|
+
export declare function initNeedsLogin(ctx: Ctx, keyStdin: boolean): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Takes the installation lock, finishes an interrupted pair journal, and for a login installation hands the
|
|
21
|
+
* command A and B from the files instead of the environment (§7.3, §7.6). Installations never paired by
|
|
22
|
+
* login have no mutex file: creating one here would turn doctor into a writer of manual installations.
|
|
23
|
+
*/
|
|
24
|
+
export declare function openInstallation(ctx: Ctx, command: "init" | "doctor" | "factory run"): Promise<{
|
|
25
|
+
ctx: Ctx;
|
|
26
|
+
release: (() => void) | null;
|
|
27
|
+
}>;
|
|
28
|
+
/** Releases the lock after the command; a failure is reported, the command's own result stands. */
|
|
29
|
+
export declare function closeInstallation(ctx: Ctx, release: () => void): void;
|
package/dist/login.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { existsSync, rmSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
4
|
+
import { agentPaths, planAgent } from "./agents.js";
|
|
5
|
+
import { KEY_ENV, KEY_PATTERN } from "./constants.js";
|
|
6
|
+
import { RobisieError } from "./context.js";
|
|
7
|
+
import { acquireInstallationLock, deviceLogin, resumePairJournal } from "./device-login.js";
|
|
8
|
+
import { applyOp, capture } from "./fsops.js";
|
|
9
|
+
import { clientPaths, readKey, readManifest, refuseSymlink, writeManifest, writePrivate } from "./manifest.js";
|
|
10
|
+
/**
|
|
11
|
+
* CLI side of `npx robisie login` (CONTRACT.md §7.3 J5, §7.6): the copies of A outside the key files, the
|
|
12
|
+
* installation lock with journal recovery for init/doctor/factory run, and which keys those commands use.
|
|
13
|
+
*/
|
|
14
|
+
const REVIEW_KEY_ENV = "ROBISIE_REVIEW_KEY";
|
|
15
|
+
/** Replaceable like commands.ts `loginIo`: tests swap the clock and sleep, never the protocol. */
|
|
16
|
+
export const loginRuntime = { io: {} };
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
/** The `~/.claude.json` entry init writes; Codex and OpenCode read A from ENV and keep no copy. */
|
|
21
|
+
function claudeOp(ctx, key) {
|
|
22
|
+
const [op] = planAgent(ctx, "claude", [], key);
|
|
23
|
+
if (!op || op.kind !== "json")
|
|
24
|
+
throw new Error("Plan instalacji Claude Code nie ma wpisu MCP.");
|
|
25
|
+
return op;
|
|
26
|
+
}
|
|
27
|
+
function recorded(manifest, op) {
|
|
28
|
+
return manifest?.entries.find((entry) => entry.kind === "json" && entry.path === op.path && isDeepStrictEqual(entry.keyPath, [...op.keyPath]));
|
|
29
|
+
}
|
|
30
|
+
function jsonValue(op) {
|
|
31
|
+
const bytes = capture(op.path).bytes;
|
|
32
|
+
if (bytes === null)
|
|
33
|
+
return null;
|
|
34
|
+
let cursor = JSON.parse(bytes.toString("utf8"));
|
|
35
|
+
for (const key of op.keyPath)
|
|
36
|
+
cursor = isRecord(cursor) && Object.hasOwn(cursor, key) ? cursor[key] : null;
|
|
37
|
+
return cursor ?? null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* J5 copies of A: the header in `~/.claude.json` (only where init installed it and it is still there) and the
|
|
41
|
+
* manifest login fields. `restore` writes back exactly the captured state and throws when the read-back differs.
|
|
42
|
+
*/
|
|
43
|
+
export function pairCopies(ctx) {
|
|
44
|
+
const paths = clientPaths(agentPaths(ctx).clientDir);
|
|
45
|
+
const manifestText = () => {
|
|
46
|
+
refuseSymlink(paths.manifest);
|
|
47
|
+
return capture(paths.manifest).bytes?.toString("utf8") ?? null;
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
capture: () => {
|
|
51
|
+
const op = claudeOp(ctx, "");
|
|
52
|
+
const state = { manifest: manifestText(), claude: null };
|
|
53
|
+
if (recorded(readManifest(paths.manifest), op))
|
|
54
|
+
state.claude = jsonValue(op);
|
|
55
|
+
return state;
|
|
56
|
+
},
|
|
57
|
+
apply: ({ key, installationId, pairId }) => {
|
|
58
|
+
const manifest = readManifest(paths.manifest);
|
|
59
|
+
const op = claudeOp(ctx, key);
|
|
60
|
+
const entries = [...(manifest?.entries ?? [])];
|
|
61
|
+
const prior = recorded(manifest, op);
|
|
62
|
+
if (prior && jsonValue(op) !== null)
|
|
63
|
+
entries[entries.indexOf(prior)] = Object.assign({}, prior, applyOp(op, prior, { backupDir: paths.backups }).entry);
|
|
64
|
+
writeManifest(paths.dir, {
|
|
65
|
+
agents: manifest?.agents ?? [], roleProviders: manifest?.roleProviders ?? null, entries,
|
|
66
|
+
installation_id: installationId, pair_id: pairId, credentialSource: "login",
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
restore: (captured) => {
|
|
70
|
+
// A journal written without copies never had them applied.
|
|
71
|
+
if (captured === null)
|
|
72
|
+
return;
|
|
73
|
+
const unknownState = new Error("Dziennik ma nieznany zapis kopii klucza A.");
|
|
74
|
+
if (!isRecord(captured) || !("claude" in captured))
|
|
75
|
+
throw unknownState;
|
|
76
|
+
const { manifest, claude } = captured;
|
|
77
|
+
if (manifest !== null && typeof manifest !== "string")
|
|
78
|
+
throw unknownState;
|
|
79
|
+
const op = claudeOp(ctx, "");
|
|
80
|
+
if (claude !== null)
|
|
81
|
+
applyOp({ ...op, value: claude }, recorded(readManifest(paths.manifest), op), { backupDir: paths.backups });
|
|
82
|
+
if (manifest === null) {
|
|
83
|
+
refuseSymlink(paths.manifest);
|
|
84
|
+
rmSync(paths.manifest, { force: true });
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
writePrivate(paths.dir, paths.manifest, manifest);
|
|
88
|
+
if (manifestText() !== manifest || (claude !== null && !isDeepStrictEqual(jsonValue(op), claude))) {
|
|
89
|
+
throw new Error("Odczyt kontrolny kopii klucza A nie zgadza się z dziennikiem.");
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** `npx robisie login`; the manifest's installation_id is only a claim the server checks (§5.2). */
|
|
95
|
+
export async function login(ctx, options) {
|
|
96
|
+
const installationHint = readManifest(clientPaths(agentPaths(ctx).clientDir).manifest)?.installation_id ?? null;
|
|
97
|
+
return deviceLogin(ctx, { ...options, installationHint, copies: pairCopies(ctx), io: loginRuntime.io });
|
|
98
|
+
}
|
|
99
|
+
/** init without any key and without a terminal pairs instead of stopping at „Brak klucza” (§7.6). */
|
|
100
|
+
export function initNeedsLogin(ctx, keyStdin) {
|
|
101
|
+
if (keyStdin || ctx.askSecret !== null || ctx.env[KEY_ENV]?.trim())
|
|
102
|
+
return false;
|
|
103
|
+
const dir = agentPaths(ctx).clientDir;
|
|
104
|
+
return !(readManifest(clientPaths(dir).manifest) && readKey(dir));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Takes the installation lock, finishes an interrupted pair journal, and for a login installation hands the
|
|
108
|
+
* command A and B from the files instead of the environment (§7.3, §7.6). Installations never paired by
|
|
109
|
+
* login have no mutex file: creating one here would turn doctor into a writer of manual installations.
|
|
110
|
+
*/
|
|
111
|
+
export async function openInstallation(ctx, command) {
|
|
112
|
+
const dir = agentPaths(ctx).clientDir;
|
|
113
|
+
if (!existsSync(join(dir, "robisie.lock.sqlite")) && !existsSync(join(dir, "pair-journal.json")))
|
|
114
|
+
return { ctx, release: null };
|
|
115
|
+
const release = acquireInstallationLock(dir, command);
|
|
116
|
+
try {
|
|
117
|
+
await resumePairJournal(ctx, dir, pairCopies(ctx));
|
|
118
|
+
if (readManifest(clientPaths(dir).manifest)?.credentialSource !== "login")
|
|
119
|
+
return { ctx, release };
|
|
120
|
+
const key = readKey(dir);
|
|
121
|
+
const reviewKey = readKey(dir, "review-key");
|
|
122
|
+
if (!key || !reviewKey || !KEY_PATTERN.test(key) || !KEY_PATTERN.test(reviewKey)) {
|
|
123
|
+
throw new RobisieError("Klucze A i B tej instalacji są niekompletne albo uszkodzone.", "Uruchom `npx robisie login`.");
|
|
124
|
+
}
|
|
125
|
+
for (const [name, value] of [[KEY_ENV, key], [REVIEW_KEY_ENV, reviewKey]]) {
|
|
126
|
+
const stale = ctx.env[name]?.trim();
|
|
127
|
+
if (stale && stale !== value)
|
|
128
|
+
ctx.err(`Stara wartość ${name} w środowisku jest ignorowana — otwórz nowy terminal.`);
|
|
129
|
+
}
|
|
130
|
+
return { ctx: { ...ctx, env: { ...ctx.env, [KEY_ENV]: key, [REVIEW_KEY_ENV]: reviewKey } }, release };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
try {
|
|
134
|
+
release();
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// The SQLite handle closes with the process; the first error is the one to act on.
|
|
138
|
+
}
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** Releases the lock after the command; a failure is reported, the command's own result stands. */
|
|
143
|
+
export function closeInstallation(ctx, release) {
|
|
144
|
+
try {
|
|
145
|
+
release();
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (!(error instanceof RobisieError))
|
|
149
|
+
throw error;
|
|
150
|
+
ctx.err(`✗ ${error.message}`);
|
|
151
|
+
ctx.err(`Następny krok: ${error.nextStep}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ export interface Manifest {
|
|
|
12
12
|
entries: Entry[];
|
|
13
13
|
/** Kept raw so doctor and uninstall can still inspect entries when the map is damaged. */
|
|
14
14
|
roleProviders?: unknown;
|
|
15
|
+
/** Set by `npx robisie login` (CONTRACT §7.3 J5, §7.6): A and B then come from the key files, never from ENV. */
|
|
16
|
+
installation_id?: string;
|
|
17
|
+
pair_id?: string;
|
|
18
|
+
credentialSource?: "login";
|
|
15
19
|
}
|
|
20
|
+
/** The login fields a rewrite of the manifest must carry forward. */
|
|
21
|
+
export declare function loginFields(manifest: Manifest | null): Pick<Manifest, "installation_id" | "pair_id" | "credentialSource">;
|
|
16
22
|
export declare const ROLE_IDS: readonly ["ceo", "builder", "quality"];
|
|
17
23
|
export type RoleProviders = Record<RoleKind, AgentId>;
|
|
18
24
|
export declare const ROLE_STEP = "U\u017Cyj pe\u0142nej jednolitej mapy: `npx robisie init --agent codex --role ceo=codex --role builder=codex --role quality=codex` (role: ceo, builder, quality; dostawcy: claude, codex, opencode).";
|
package/dist/manifest.js
CHANGED
|
@@ -5,6 +5,12 @@ import { PACKAGE_VERSION } from "./constants.js";
|
|
|
5
5
|
import { RobisieError, errorMessage, shellQuote } from "./context.js";
|
|
6
6
|
import { isAgentId } from "./agents.js";
|
|
7
7
|
import { freeCopyPath } from "./fsops.js";
|
|
8
|
+
/** The login fields a rewrite of the manifest must carry forward. */
|
|
9
|
+
export function loginFields(manifest) {
|
|
10
|
+
return manifest?.credentialSource === "login"
|
|
11
|
+
? { installation_id: manifest.installation_id, pair_id: manifest.pair_id, credentialSource: "login" }
|
|
12
|
+
: {};
|
|
13
|
+
}
|
|
8
14
|
export const ROLE_IDS = ["ceo", "builder", "quality"];
|
|
9
15
|
export const ROLE_STEP = "Użyj pełnej jednolitej mapy: `npx robisie init --agent codex --role ceo=codex --role builder=codex --role quality=codex` (role: ceo, builder, quality; dostawcy: claude, codex, opencode).";
|
|
10
16
|
/** Legacy single-provider installs have one unambiguous assignment; explicit null stays null. */
|
|
@@ -173,6 +179,9 @@ export function readManifest(path) {
|
|
|
173
179
|
throw new Error("brak pól");
|
|
174
180
|
const manifest = { packageVersion: String(parsed.packageVersion ?? "?"), agents: parsed.agents, entries: parsed.entries };
|
|
175
181
|
manifest.roleProviders = Object.hasOwn(parsed, "roleProviders") ? parsed.roleProviders : roleProviders(manifest);
|
|
182
|
+
if (parsed.credentialSource === "login" && typeof parsed.installation_id === "string" && typeof parsed.pair_id === "string") {
|
|
183
|
+
Object.assign(manifest, { installation_id: parsed.installation_id, pair_id: parsed.pair_id, credentialSource: "login" });
|
|
184
|
+
}
|
|
176
185
|
return manifest;
|
|
177
186
|
}
|
|
178
187
|
catch {
|
package/dist/role-registry.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export declare function loadRoleRegistryConfig(path: string): {
|
|
|
21
21
|
config: EngineConfig;
|
|
22
22
|
roleRegistry: EngineRoleRegistry;
|
|
23
23
|
};
|
|
24
|
-
export declare function doctorEngineConfig(ctx: Ctx, path: string): number;
|
|
24
|
+
export declare function doctorEngineConfig(ctx: Ctx, path: string, afterLoad?: (config: EngineConfig) => void): number;
|
|
25
25
|
export {};
|
package/dist/role-registry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { RobisieError, errorMessage } from "./context.js";
|
|
4
4
|
import { CONFIG_FILE, parseEngineConfig } from "./engine-config.js";
|
|
@@ -55,10 +55,12 @@ export function resolveRoleExecution(registry, role) {
|
|
|
55
55
|
}
|
|
56
56
|
/** One read and one JSON object shared by the K2 and registry validators. */
|
|
57
57
|
export function loadRoleRegistryConfig(path) {
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const file = resolve(path);
|
|
59
|
+
let configPath = file;
|
|
60
|
+
const retry = `Popraw plik „${file}” (${CONFIG_FILE}) i ponów \`npx robisie doctor --engine-config <path>\` z tą ścieżką.`;
|
|
60
61
|
let contents;
|
|
61
62
|
try {
|
|
63
|
+
configPath = realpathSync(configPath);
|
|
62
64
|
contents = readFileSync(configPath, "utf8");
|
|
63
65
|
}
|
|
64
66
|
catch {
|
|
@@ -69,19 +71,20 @@ export function loadRoleRegistryConfig(path) {
|
|
|
69
71
|
raw = JSON.parse(contents.replace(/^\uFEFF/, ""));
|
|
70
72
|
}
|
|
71
73
|
catch {
|
|
72
|
-
throw new RobisieError(`${
|
|
74
|
+
throw new RobisieError(`${file}: niepoprawny JSON.`, retry);
|
|
73
75
|
}
|
|
74
76
|
let config;
|
|
75
77
|
try {
|
|
76
78
|
config = parseEngineConfig(raw, configPath);
|
|
77
79
|
}
|
|
78
80
|
catch (error) {
|
|
79
|
-
throw new RobisieError(errorMessage(error), retry);
|
|
81
|
+
throw new RobisieError(errorMessage(error).replaceAll(`${configPath}:`, () => `${file}:`), retry);
|
|
80
82
|
}
|
|
81
|
-
return { config, roleRegistry: parseRoleRegistry(raw,
|
|
83
|
+
return { config, roleRegistry: parseRoleRegistry(raw, file) };
|
|
82
84
|
}
|
|
83
|
-
export function doctorEngineConfig(ctx, path) {
|
|
84
|
-
const { roleRegistry } = loadRoleRegistryConfig(resolve(ctx.cwd, path));
|
|
85
|
+
export function doctorEngineConfig(ctx, path, afterLoad) {
|
|
86
|
+
const { roleRegistry, config } = loadRoleRegistryConfig(resolve(ctx.cwd, path));
|
|
87
|
+
afterLoad?.(config);
|
|
85
88
|
for (const role of ROLES) {
|
|
86
89
|
const { name, provider, model, effort } = roleRegistry[role];
|
|
87
90
|
ctx.out(`${role} → ${name} / ${provider} / ${model} / ${effort}`);
|
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.
|
|
20
|
+
export declare const MANAGED_LINE = "<!-- robisie:managed 0.3.0 \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/docs/ENGINE-CONFIG.md
CHANGED
|
@@ -111,3 +111,11 @@ odczyt z niezerowym exit i komunikatem na stderr. Na przykład brak `test`
|
|
|
111
111
|
w `engine.commands` daje błąd zawierający `engine.commands.test`, a
|
|
112
112
|
`delivery: "invalid"` — `engine.delivery`. Odczyt nie dopisuje brakujących
|
|
113
113
|
komend ani nie zastępuje błędnego sposobu dostarczenia wartością domyślną.
|
|
114
|
+
|
|
115
|
+
## Wejścia instalacji lokalnej
|
|
116
|
+
|
|
117
|
+
W katalogu projektu z plikiem `robisie.config.json` zawierającym `engine.delivery: "local"` uruchom `npx robisie init`, potem `npx robisie doctor`. Init tworzy brakujące `NORTH-STAR.md` i `tester-safety-v1.txt` w `<stateDir>/inputs`; zachowuje istniejącą treść. Pliki należą do projektu: ponowne init ich nie nadpisuje, a uninstall ich nie usuwa.
|
|
118
|
+
|
|
119
|
+
Domyślny cel brzmi „Dostarczaj sprawdzone zmiany w zakresie kart projektu.” Możesz zastąpić go własnym celem. Lista testera zawiera po jednym wyrażeniu regularnym JavaScript na linię; puste linie i komentarze zaczynające się od `#` są pomijane. Domyślna lista chroni pliki repozytorium i sekretów, migracje, kod uwierzytelniania i płatności oraz konfigurację wdrożeń. Lista klasyfikuje zmiany do odbioru; nie nadaje uprawnień.
|
|
120
|
+
|
|
121
|
+
Dla konfiguracji w innym miejscu użyj `npx robisie init --engine-config /ścieżka/robisie.config.json`. Kolejność wyboru to jawna flaga, `ROBISIE_ENGINE_CONFIG`, następnie plik w bieżącym katalogu. Ścieżki stanu są liczone względem rzeczywistego pliku konfiguracji. Bez konfiguracji silnika zwykłe init nadal instaluje same role i MCP. Jawne `doctor --engine-config <ścieżka>` sprawdza konfigurację i wejścia offline, bez sprawdzania kluczy, uruchamiania dostawców ani wykonywania komend.
|
package/docs/README.en.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
# robisie — from account to accepted card (package 0.
|
|
1
|
+
# robisie — from account to accepted card (package 0.3.0)
|
|
2
|
+
|
|
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.
|
|
2
4
|
|
|
3
5
|
Polski: [README.md](README.md).
|
|
4
6
|
|
|
5
7
|
<!-- sekcja: dostepnosc -->
|
|
6
8
|
## Availability
|
|
7
9
|
|
|
8
|
-
An account and key are needed for init and the roles. Offline configuration validation is a separate entry point when the CLI is available: it does not check the installation, start providers or require a project UUID from you. Separately, `npx robisie doctor --engine-config ./robisie.config.json` checks
|
|
10
|
+
An account and key are needed for init and the roles. Offline configuration validation is a separate entry point when the CLI is available: it does not check the installation, start providers or require a project UUID from you. Separately, `npx robisie doctor --engine-config ./robisie.config.json` checks configuration structure and local installation inputs offline: it does not confirm project UUID, repo, models or provider execution. The guides shipped in this package are local at `node_modules/robisie/docs/README.md` and `node_modules/robisie/docs/README.en.md`; no website fetch is needed.
|
|
9
11
|
|
|
10
12
|
Install robisie from npm in the prepared directory; run subsequent commands and agent sessions there. [Preparation](#wymagania) → [account](#konto) → [key](#klucz) → [installation](#instalacja) → [acceptance](#recenzja-i-odbior).
|
|
11
13
|
|
|
@@ -55,6 +57,16 @@ Every doctor result includes `! Polityka enforced: NIE SPRAWDZONO — klient nie
|
|
|
55
57
|
|
|
56
58
|
Polish CLI messages: `Brak klucza odbioru ROBISIE_REVIEW_KEY.` — Missing acceptance key ROBISIE_REVIEW_KEY.; `Klucz odbioru B jest tym samym tokenem co klucz A.` — Acceptance key B is the same token as key A.; `ROBISIE_REVIEW_KEY ma niepoprawny format.` — ROBISIE_REVIEW_KEY has an invalid format.; `Nie potwierdzono dostępu B do tablicy.` — Board access with key B could not be confirmed.; `Klucz B uwierzytelnia odczyt projektów.` — Key B authenticates project reads.
|
|
57
59
|
|
|
60
|
+
### Sign in with a code: npx robisie login
|
|
61
|
+
|
|
62
|
+
Instead of copying keys from Connect you can pair the installation with one command in the installation directory: `npx robisie login`. It prints a code and a link to https://robisie.app/dashboard/connect/device. You or your agent, signed in to this account in the browser, compare the code with the terminal, confirm the sign-in again and approve both keys at once: A (worker) and B (owner_validator — full permissions, including deletion). The server always issues the A+B pair. The keys go straight into the installation's `key` and `review-key` files (0600, directory 0700): they never pass through the screen, the clipboard, chat or command history.
|
|
63
|
+
|
|
64
|
+
Exit code 0 means the pair is saved and confirmed. Exit code 2 means the pairing is waiting for approval — you are not signed in yet; resume it with the same `npx robisie login` before the code expires (10 minutes). Exit code 1 is an error with one next step. `npx robisie login --no-wait` only prints the code and link; `--timeout` sets how many seconds to wait (default 540). Without keys, without a terminal and without `--key-stdin`, init starts with this sign-in itself.
|
|
65
|
+
|
|
66
|
+
After sign-in, init, doctor and `npx robisie factory run` take A and B from the installation files. An old ROBISIE_KEY or ROBISIE_REVIEW_KEY value in the environment is then ignored with a warning that never prints the value — open a new terminal. Doctor does not require ROBISIE_REVIEW_KEY in the environment of such an installation. One robisie command runs at a time: a second one refuses with „Inna operacja robisie trwa” (another robisie operation is running). An interrupted pair write (for example a full disk) is finished by the next command; until then no command uses the keys in the files. Installations with keys pasted from Connect keep working as before.
|
|
67
|
+
|
|
68
|
+
The tester release is a single trust zone: on this computer the agent executing tasks technically also has access to the acceptance key (B). Run only agents you trust as yourself on it.
|
|
69
|
+
|
|
58
70
|
<!-- sekcja: instalacja -->
|
|
59
71
|
<a id="instalacja"></a>
|
|
60
72
|
## Install from npm
|
|
@@ -216,7 +228,7 @@ The human runs this in a terminal with the correct environment, in the installat
|
|
|
216
228
|
npx robisie doctor
|
|
217
229
|
```
|
|
218
230
|
|
|
219
|
-
Doctor checks the contract, project reads, configuration, roles, helper startup, `ROBISIE_KEY`, and free disk on the installation volume. For disk it prints HOLD below 15 GiB and unblock hysteresis from 18 GiB; below 15 GiB it exits 1. It shows the map: null or mixed assignments give exit 1; return to the complete shared-provider assignment in init. “
|
|
231
|
+
Doctor checks the contract, project reads, configuration, roles, helper startup, `ROBISIE_KEY`, and free disk on the installation volume. For disk it prints HOLD below 15 GiB and unblock hysteresis from 18 GiB; below 15 GiB it exits 1. It shows the map: null or mixed assignments give exit 1; return to the complete shared-provider assignment in init. “Powyższe kontrole przeszły” means those checks passed, without proving the whole work loop. The “Gotowość wykonawców Codex–Grok” line says separately whether the Codex login (`codex login status`) and Grok login (`grok models`, so only “prawdopodobnie zalogowany”) were checked.
|
|
220
232
|
|
|
221
233
|
Doctor runs the helper file via node, the agent via npx. `ROBISIE_PROJECT_CONTEXT` selects context later and does not change cwd for package lookup. Start the agent in the installation directory and ask it to list available tools from BOTH servers: `client-launch-context` (`get_launch_context`, `get_project_context`, `run_project_check`, `prepare_review`, `create_review_receipt`, `verify_stored_review`) and `ceo-client-launcher` (`spawn_builder`, `verify_review_receipt`). Result: both servers available with all these tools in that session. Do not call spawn_builder just as a probe. If a helper is missing, return to the installation cwd, check the local version and configuration, run init/doctor, then start a fresh agent session. Doctor alone does not confirm provider tool availability.
|
|
222
234
|
|
|
@@ -255,6 +267,13 @@ In other CEO sessions, including Codex, moving to delivered requires independent
|
|
|
255
267
|
|
|
256
268
|
The project owner can use Dashboard → Planer → card → Etap → “Zrobione” to move `delivered` to `done`, including when the agent uses a `worker` key. For the first card described here, the server does not enforce stored acceptance or evidence before a change to `done`: the dashboard lets the owner select “Zrobione” even without them. Do this only after checking and explicitly accepting the result. The dashboard cannot edit `details`; review and evidence are recorded through the supported board tool flow. This guide alone does not prove a customer has completed that flow.
|
|
257
269
|
|
|
270
|
+
### Blocked card: retry or abandon
|
|
271
|
+
|
|
272
|
+
A card in the “Blocked” stage waits for the owner's decision. The scope protection is intentional: the worker key A cannot close the card — setting `done` with key A is refused with 403. `done` is reserved for accepting a result with evidence, not for releasing scope. Do not broaden key A or change roles to bypass the refusal.
|
|
273
|
+
|
|
274
|
+
- **Retry:** open the Planner in the Dashboard (`https://robisie.app/dashboard/plugins/planer`) (“Projects” section), choose a project and card, then select “Ready” (`ready`) under “Stage”. The card returns to the agent's queue.
|
|
275
|
+
- **Abandon:** in the same card window, click “Delete”; at “Are you sure you want to delete this?” choose “Yes, delete”. **Deletion is irreversible — it cannot be undone.** The `masz-<first 8 characters of the card id>` branch with the agent's work remains in the repository.
|
|
276
|
+
|
|
258
277
|
<!-- sekcja: aktualizacja -->
|
|
259
278
|
## Update and private backup
|
|
260
279
|
|
|
@@ -444,12 +463,12 @@ Without an installation, begin with the account and Connect → init; repeating
|
|
|
444
463
|
CLI messages remain in Polish. Match the message, then follow the English explanation:
|
|
445
464
|
|
|
446
465
|
- **brak-klucza** — `Brak klucza robisie.`
|
|
447
|
-
No key: generate one in Connect and supply it to init
|
|
466
|
+
No key: generate one in Connect and supply it to init, or pair the installation: `npx robisie login`.
|
|
448
467
|
- **odrzucony-klucz** — `Serwer robisie odrzucił klucz (nieważny albo unieważniony).`
|
|
449
468
|
Generate a new worker key; in zsh/bash run `unset ROBISIE_KEY`, then init with the hidden prompt.
|
|
450
469
|
- **brak-odczytu** — `Ten klucz nie ma uprawnień do odczytu tablicy (np. rola seeder).`
|
|
451
470
|
Select worker in Connect; `unset ROBISIE_KEY`, then init with the hidden prompt.
|
|
452
|
-
- **major** — `Wersja kontraktu serwera (2.0.0) nie pasuje do paczki robisie 0.
|
|
471
|
+
- **major** — `Wersja kontraktu serwera (2.0.0) nie pasuje do paczki robisie 0.3.0 (obsługuje 1.x).`
|
|
453
472
|
Example of a MAJOR mismatch: install a release compatible with the server contract.
|
|
454
473
|
- **brak-env** — `Zmienna ROBISIE_KEY nie jest ustawiona — role i agenci jej potrzebują.`
|
|
455
474
|
Check profile support; with --no-shell/another shell load the key file into the session environment as shown in init, then doctor.
|