@telpin-sistemas/orqen 0.1.13 → 0.1.15
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/dist/commands/bots.js +65 -0
- package/dist/commands/eval.js +137 -7
- package/dist/commands/workflow.js +179 -16
- package/dist/connectors/asana.js +13 -2
- package/dist/connectors/github.js +12 -3
- package/dist/connectors/jira.js +17 -2
- package/dist/index.js +11 -1
- package/dist/lib/bots.js +72 -0
- package/dist/lib/config-keys.js +1 -1
- package/dist/lib/config.js +6 -0
- package/dist/lib/connectors-edit.js +28 -2
- package/dist/lib/mcp.js +73 -0
- package/dist/practice/practice.js +6 -0
- package/dist/template/.agents/commands/new_worq.md +2 -0
- package/dist/workflow/board.js +14 -0
- package/dist/workflow/config.js +2 -1
- package/dist/workflow/dry-run-commands.js +2 -0
- package/dist/workflow/dry-run.js +20 -3
- package/dist/workflow/openspec.js +4 -1
- package/dist/workflow/process.js +267 -24
- package/dist/workflow/store.js +28 -2
- package/dist/workflow/workspace.js +4 -0
- package/package.json +1 -1
package/dist/connectors/jira.js
CHANGED
|
@@ -54,8 +54,23 @@ export class JiraTracker {
|
|
|
54
54
|
labelled(label) { return this.search(`${this.s.project ? `project = "${this.s.project}" AND ` : ""}labels = "${label}" AND statusCategory != Done`); }
|
|
55
55
|
async search(jql) {
|
|
56
56
|
const path = this.s.deployment === "cloud" ? "/rest/api/3/search/jql" : "/rest/api/2/search";
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// every page: with more than 100 results the rest would never be seen (a request past the first 100 would wait forever)
|
|
58
|
+
const keys = [];
|
|
59
|
+
const cloud = this.s.deployment === "cloud";
|
|
60
|
+
let token;
|
|
61
|
+
for (let page = 0; page < 100; page++) {
|
|
62
|
+
const r = await this.req("GET", path, undefined, {
|
|
63
|
+
jql, fields: "key", maxResults: 100,
|
|
64
|
+
...(cloud ? (token ? { nextPageToken: token } : {}) : { startAt: keys.length }),
|
|
65
|
+
});
|
|
66
|
+
const issues = r.issues ?? [];
|
|
67
|
+
keys.push(...issues.map((i) => this.alias(i.key)));
|
|
68
|
+
token = r.nextPageToken;
|
|
69
|
+
const more = cloud ? !!token && r.isLast !== true : issues.length > 0 && keys.length < (r.total ?? 0);
|
|
70
|
+
if (!more)
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return keys;
|
|
59
74
|
}
|
|
60
75
|
async ticket(key) {
|
|
61
76
|
const r = await this.req("GET", `/rest/api/2/issue/${this.native(key)}`, undefined, {
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,10 @@ import { lang, tutorial } from "./commands/tutorial.js";
|
|
|
10
10
|
import { VERSION_CLI } from "./lib/system.js";
|
|
11
11
|
import { mostrarLogo } from "./ui/logo.js";
|
|
12
12
|
import { usageCommand } from "./lib/usage.js";
|
|
13
|
-
import { EVAL_HELP, evalCommand, learnCommand } from "./commands/eval.js";
|
|
13
|
+
import { EVAL_HELP, evalCommand, learnCommand, runCommand, feedbackCommand } from "./commands/eval.js";
|
|
14
14
|
import { SPEC_HELP, specCommand } from "./commands/spec.js";
|
|
15
15
|
import { practice } from "./practice/practice.js";
|
|
16
|
+
import { BOTS_HELP, botsCommand, mcpCommand } from "./commands/bots.js";
|
|
16
17
|
const AYUDA = `
|
|
17
18
|
Usage: orqen <command> [options]
|
|
18
19
|
orqen This help (the desktop app is a separate project: github.com/sistemas-telpin/orqen-studio)
|
|
@@ -43,6 +44,7 @@ Commands:
|
|
|
43
44
|
${SWARM_HELP}
|
|
44
45
|
${EVAL_HELP}
|
|
45
46
|
${SPEC_HELP}
|
|
47
|
+
${BOTS_HELP}
|
|
46
48
|
--version, -v Show version
|
|
47
49
|
--help, -h Show this help · orqen help internal: agent-only commands and JSON for tools
|
|
48
50
|
|
|
@@ -73,10 +75,18 @@ async function main() {
|
|
|
73
75
|
return desktopRelease(crudos[1] ?? "");
|
|
74
76
|
if (crudos[0] === "learn")
|
|
75
77
|
return learnCommand(crudos.slice(1));
|
|
78
|
+
if (crudos[0] === "run")
|
|
79
|
+
return runCommand(crudos.slice(1));
|
|
80
|
+
if (crudos[0] === "feedback")
|
|
81
|
+
return feedbackCommand(crudos.slice(1));
|
|
76
82
|
if (crudos[0] === "spec")
|
|
77
83
|
return specCommand(crudos.slice(1));
|
|
78
84
|
if (crudos[0] === "practice")
|
|
79
85
|
return practice(crudos.slice(1));
|
|
86
|
+
if (crudos[0] === "bots")
|
|
87
|
+
return botsCommand(crudos.slice(1));
|
|
88
|
+
if (crudos[0] === "mcp")
|
|
89
|
+
return mcpCommand(crudos.slice(1));
|
|
80
90
|
// `orqen env test e2e -- <args>`: everything after `--` goes to the test command untouched
|
|
81
91
|
const sep = crudos.indexOf("--");
|
|
82
92
|
const extra = sep >= 0 ? crudos.slice(sep + 1) : [];
|
package/dist/lib/bots.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bot profiles: specialist guidance the Worq agent applies in the stages a project assigns them, with the MCP servers it may
|
|
3
|
+
* use while it does. Personal (each person keeps their own), in ~/.orqen/bots.json; each bot says, per repository, in which
|
|
4
|
+
* stages it is available. `orqen bots` lists them, `orqen bots set -` saves them, and `orqen status KEY --json` gives the
|
|
5
|
+
* agent the ones of the Worq's current stage, so any agent (Studio's or one started in a terminal) gets the same guidance.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { claudeTool, samePath } from "./mcp.js";
|
|
12
|
+
export const STAGES = [
|
|
13
|
+
"NEW", "SUPPORT", "ANALYSIS", "WAITING_CLIENT", "DEVELOPMENT", "TESTING", "QA_REVIEW", "CODE_REVIEW", "DELIVERY",
|
|
14
|
+
"ACCEPTANCE", "EXECUTION", "EXECUTION_APPROVAL", "APPLICATION", "VERIFICATION", "BLOCKED",
|
|
15
|
+
];
|
|
16
|
+
export const Bot = z.object({
|
|
17
|
+
name: z.string().trim().min(1),
|
|
18
|
+
prompt: z.string(),
|
|
19
|
+
/** repository path → stages where the bot is available there. */
|
|
20
|
+
projects: z.record(z.string(), z.array(z.enum(STAGES))).default({}),
|
|
21
|
+
/** MCP servers (names, as `orqen mcp` lists them) the bot may use. */
|
|
22
|
+
connectors: z.array(z.string()).default([]),
|
|
23
|
+
/** How Studio draws it; kept as it comes. */
|
|
24
|
+
face: z.unknown().optional(),
|
|
25
|
+
});
|
|
26
|
+
export const Bots = z.array(Bot).superRefine((bots, ctx) => {
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
for (const [i, b] of bots.entries()) {
|
|
29
|
+
const k = b.name.toLowerCase();
|
|
30
|
+
if (seen.has(k))
|
|
31
|
+
ctx.addIssue({ code: "custom", path: [i, "name"], message: `two bots are called "${b.name}"` });
|
|
32
|
+
seen.add(k);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export const botsFile = () => join(process.env.ORQEN_USER_CONFIG_DIR || join(homedir(), ".orqen"), "bots.json");
|
|
36
|
+
export function readBots(file = botsFile()) {
|
|
37
|
+
if (!existsSync(file))
|
|
38
|
+
return [];
|
|
39
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
40
|
+
return Bots.parse(Array.isArray(raw) ? raw : raw.bots ?? []);
|
|
41
|
+
}
|
|
42
|
+
/** Validates and writes (temporary file + rename, so a reader never sees half a file). */
|
|
43
|
+
export function writeBots(input, file = botsFile()) {
|
|
44
|
+
const bots = Bots.parse(Array.isArray(input) ? input : input?.bots);
|
|
45
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
46
|
+
const tmp = `${file}.tmp`;
|
|
47
|
+
writeFileSync(tmp, JSON.stringify({ bots }, null, 2) + "\n");
|
|
48
|
+
renameSync(tmp, file);
|
|
49
|
+
return bots;
|
|
50
|
+
}
|
|
51
|
+
/** Stages of a bot in this repository ([] = not used here). */
|
|
52
|
+
export function stagesIn(bot, repo) {
|
|
53
|
+
return Object.entries(bot.projects).find(([k]) => samePath(k, repo))?.[1] ?? [];
|
|
54
|
+
}
|
|
55
|
+
/** What the agent gets for a Worq in `stage`: the bots assigned to it here, with their guidance and servers. */
|
|
56
|
+
export function botsFor(bots, repo, stage) {
|
|
57
|
+
return bots.filter((b) => stagesIn(b, repo).includes(stage)).map((b) => ({ name: b.name, prompt: b.prompt, connectors: b.connectors }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The tools to allow in one agent run of this repository: the servers of every bot assigned to any stage here. A run can go
|
|
61
|
+
* through several stages (it checks `orqen status` after each one), so they are granted for the run; which bot applies in
|
|
62
|
+
* each stage comes from `orqen status`.
|
|
63
|
+
*/
|
|
64
|
+
export function toolsIn(bots, repo) {
|
|
65
|
+
const out = [];
|
|
66
|
+
for (const b of bots)
|
|
67
|
+
if (stagesIn(b, repo).length)
|
|
68
|
+
for (const c of b.connectors)
|
|
69
|
+
if (!out.includes(claudeTool(c)))
|
|
70
|
+
out.push(claudeTool(c));
|
|
71
|
+
return out;
|
|
72
|
+
}
|
package/dist/lib/config-keys.js
CHANGED
|
@@ -46,7 +46,7 @@ export const CONFIG_KEYS = {
|
|
|
46
46
|
support: "soporte",
|
|
47
47
|
approvers: { as: "aprobadores", keys: { analysis: "analisis", qa: "qa", code: "codigo", client: "cliente", execution: "ejecucion" } },
|
|
48
48
|
code_review: { as: "code_review", keys: { gate: "gate", reviewers: "revisores" } },
|
|
49
|
-
devel_branch: "rama_desarrollo", pr_command: "comando_pr", test_command: "comando_tests",
|
|
49
|
+
devel_branch: "rama_desarrollo", pr_command: "comando_pr", test_command: "comando_tests", people: "personas",
|
|
50
50
|
lock_minutes: "lock_min", interval_seconds: "intervalo_seg",
|
|
51
51
|
},
|
|
52
52
|
},
|
package/dist/lib/config.js
CHANGED
|
@@ -43,6 +43,12 @@ export const Flujo = z.object({
|
|
|
43
43
|
comando_pr: z.string().nullish(),
|
|
44
44
|
/** Full test suite run in TESTING (TEST_COMMAND). */
|
|
45
45
|
comando_tests: z.string().nullish(),
|
|
46
|
+
/**
|
|
47
|
+
* Who does what on this team: the name of each person (their git user.name) → their roles (support, analyst, developer, qa,
|
|
48
|
+
* senior), as a YAML list or "a, b". Studio and `orqen whoami` use it to show each person what waits for them. Absent = everyone
|
|
49
|
+
* does everything (a small team).
|
|
50
|
+
*/
|
|
51
|
+
personas: z.record(z.string(), z.preprocess((v) => typeof v === "string" ? v.split(",").map((s) => s.trim()).filter(Boolean) : v ?? [], z.array(z.enum(["support", "analyst", "developer", "qa", "senior"])))).optional(),
|
|
46
52
|
/** Minutes a taken request stays reserved (ORQEN_LOCK_MIN) and seconds between rounds of `orqen cycle --loop` (ORQEN_INTERVAL_SEC). */
|
|
47
53
|
lock_min: z.number().int().positive().nullish(),
|
|
48
54
|
intervalo_seg: z.number().int().positive().nullish(),
|
|
@@ -44,6 +44,29 @@ export function parseDraft(input) {
|
|
|
44
44
|
const env = Object.fromEntries(Object.entries(raw.env ?? {}).filter(([, v]) => typeof v === "string" && v.trim() !== "").map(([k, v]) => [k, v.trim()]));
|
|
45
45
|
return { conectores: parsed.data, env };
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The requests the flow would pick up with this connector: the same `pending()` the flow uses (its filter), counted, with the
|
|
49
|
+
* first few titles. Lets a person try a filter before saving it.
|
|
50
|
+
*/
|
|
51
|
+
async function requestMatches(t, n = 3) {
|
|
52
|
+
try {
|
|
53
|
+
const keys = await t.pending();
|
|
54
|
+
const sample = [];
|
|
55
|
+
for (const key of keys.slice(0, n)) {
|
|
56
|
+
try {
|
|
57
|
+
const x = await t.ticket(key);
|
|
58
|
+
sample.push({ key: x.key, title: x.title, ...(x.status ? { status: x.status } : {}) });
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
sample.push({ key, title: "" });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { count: keys.length, sample };
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return { count: 0, sample: [], error: e.message.split("\n")[0] };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
47
70
|
/** Lists choices using draft credentials, without requiring a repository or saving the draft. */
|
|
48
71
|
export async function githubChoices(draft, current, role, resource) {
|
|
49
72
|
role = role === "external" ? "requests" : role === "internal" ? "issues" : role; // names used by earlier versions of the app
|
|
@@ -67,13 +90,16 @@ export async function githubChoices(draft, current, role, resource) {
|
|
|
67
90
|
}
|
|
68
91
|
}
|
|
69
92
|
/** Checks each connector of the draft against the tool, with the draft secrets over the current ones. Saves nothing. */
|
|
70
|
-
export async function checkDraft(draft, current) {
|
|
93
|
+
export async function checkDraft(draft, current, opts = {}) {
|
|
71
94
|
const env = { ...current, ...draft.env };
|
|
72
95
|
const one = async (role, c) => {
|
|
73
96
|
if (!c)
|
|
74
97
|
return { role, configured: false };
|
|
75
98
|
const t = trackerFor(connectorSettings(c, env));
|
|
76
|
-
|
|
99
|
+
const r = { role, configured: true, kind: t.kind, label: t.label, ...(await t.check()) };
|
|
100
|
+
if (opts.matches && role === "requests" && r.ok)
|
|
101
|
+
r.matches = await requestMatches(t);
|
|
102
|
+
return r;
|
|
77
103
|
};
|
|
78
104
|
return [await one("requests", draft.conectores.requests), await one("issues", draft.conectores.issues)];
|
|
79
105
|
}
|
package/dist/lib/mcp.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP servers the agents of this machine can reach, read from where each agent keeps them: the project's `.mcp.json`
|
|
3
|
+
* and `.gemini/settings.json`, Claude Code's ~/.claude.json (this project's and the global ones), Codex's
|
|
4
|
+
* ~/.codex/config.toml and Gemini's ~/.gemini/settings.json. orqen only reads them: they are added in each agent.
|
|
5
|
+
* `orqen mcp --json` (orqen-studio lists them to pick the ones a bot may use).
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
function json(file) {
|
|
11
|
+
try {
|
|
12
|
+
return existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : undefined;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const servers = (v) => {
|
|
19
|
+
const o = v?.mcpServers;
|
|
20
|
+
return o && typeof o === "object" ? Object.keys(o) : [];
|
|
21
|
+
};
|
|
22
|
+
/** `[mcp_servers.<name>]` tables of a Codex config (not their sub-tables such as `.env`). */
|
|
23
|
+
export function tomlServers(text) {
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
26
|
+
const m = /^\[mcp_servers\.(.+)\]$/.exec(raw.trim());
|
|
27
|
+
if (!m)
|
|
28
|
+
continue;
|
|
29
|
+
const name = m[1].replace(/^"|"$/g, "");
|
|
30
|
+
if (name && !name.includes("."))
|
|
31
|
+
out.push(name);
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/** Repository paths compare without caring for slashes, case (Windows) or a trailing slash. */
|
|
36
|
+
export const samePath = (a, b) => {
|
|
37
|
+
const n = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
38
|
+
return n(a) === n(b);
|
|
39
|
+
};
|
|
40
|
+
/** Every server found, each name once (the first source wins), in a stable order. */
|
|
41
|
+
export function mcpServers(repo, home = homedir()) {
|
|
42
|
+
const out = [];
|
|
43
|
+
const add = (names, source, file) => {
|
|
44
|
+
for (const name of names)
|
|
45
|
+
if (!out.some((s) => s.name === name))
|
|
46
|
+
out.push({ name, source, file });
|
|
47
|
+
};
|
|
48
|
+
if (repo) {
|
|
49
|
+
add(servers(json(join(repo, ".mcp.json"))), "project", join(repo, ".mcp.json"));
|
|
50
|
+
add(servers(json(join(repo, ".gemini", "settings.json"))), "gemini", join(repo, ".gemini", "settings.json"));
|
|
51
|
+
}
|
|
52
|
+
const claudeFile = join(home, ".claude.json");
|
|
53
|
+
const claude = json(claudeFile);
|
|
54
|
+
if (claude) {
|
|
55
|
+
if (repo) {
|
|
56
|
+
const projects = (claude.projects ?? {});
|
|
57
|
+
const mine = Object.entries(projects).find(([k]) => samePath(k, repo));
|
|
58
|
+
add(servers(mine?.[1]), "claude", claudeFile);
|
|
59
|
+
}
|
|
60
|
+
add(servers(claude), "claude", claudeFile);
|
|
61
|
+
}
|
|
62
|
+
const codex = join(home, ".codex", "config.toml");
|
|
63
|
+
try {
|
|
64
|
+
if (existsSync(codex))
|
|
65
|
+
add(tomlServers(readFileSync(codex, "utf8")), "codex", codex);
|
|
66
|
+
}
|
|
67
|
+
catch { /* unreadable: skipped */ }
|
|
68
|
+
const gemini = join(home, ".gemini", "settings.json");
|
|
69
|
+
add(servers(json(gemini)), "gemini", gemini);
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** The Claude Code tool pattern that allows every tool of a server. */
|
|
73
|
+
export const claudeTool = (name) => `mcp__${name}`;
|
|
@@ -144,6 +144,9 @@ export function clientTurn(key) {
|
|
|
144
144
|
return { key, replied: false, reason: "nothing new from the team" };
|
|
145
145
|
if (ticket.clientSeen === last.id)
|
|
146
146
|
return { key, replied: false, reason: "already read" };
|
|
147
|
+
// it failed on this comment a moment ago (no Claude Code, no session…): wait before spawning the client again
|
|
148
|
+
if (ticket.clientFailed?.id === last.id && Date.now() - Date.parse(ticket.clientFailed.at) < 90_000)
|
|
149
|
+
return { key, replied: false, reason: "failed recently" };
|
|
147
150
|
// one answer at a time per ticket (the app asks every few seconds)
|
|
148
151
|
const lock = join(tmpdir(), `orqen-practice-${ticket.key}.lock`);
|
|
149
152
|
try {
|
|
@@ -166,6 +169,9 @@ export function clientTurn(key) {
|
|
|
166
169
|
const [bin, ...args] = partirComando(cmd);
|
|
167
170
|
const r = ejecutar(bin, args, { cwd: tmpdir(), entrada: prompt, timeoutMs: 180_000 });
|
|
168
171
|
if (r.codigo !== 0 || r.error) {
|
|
172
|
+
const failed = t.read(ticket.key);
|
|
173
|
+
failed.clientFailed = { id: last.id, at: new Date().toISOString() };
|
|
174
|
+
t.write(failed);
|
|
169
175
|
const why = r.error ? r.error.code === "ENOENT" ? `${bin} is not installed or not in the PATH` : r.error.message : (r.stderr || r.stdout).trim().slice(0, 300);
|
|
170
176
|
throw new Error(`${bin}: ${why || `exit code ${r.codigo}`}`);
|
|
171
177
|
}
|
|
@@ -6,6 +6,8 @@ allowed-tools: Bash(orqen:*), AskUserQuestion
|
|
|
6
6
|
|
|
7
7
|
`$ARGUMENTS` is the title of the work, or the key of an issue that already exists (e.g. `GH-12`, `DEV-34`). If it is missing, ask the person for it. This is work the team starts itself: there is no client or request, so support and analysis are skipped. orqen creates the issue in the connector the project uses (the issues connector, or the requests one when there is none), or takes the existing one.
|
|
8
8
|
|
|
9
|
+
**Short path (only a title and a description).** If the person just wants to describe the work in their own words and let the analysis work out the rest, do not build the brief: run `orqen new_worq <brief.json>` with `{ "title": "...", "description": "..." }` (the description as they wrote it, at least 20 characters). The worq is born in ANALYSIS with the person as its analyst and requester; continue with `/orqen:analyze <KEY>`, which asks them what is missing, picks the lane and writes the spec. orqen studio's "Nuevo Worq" does exactly this.
|
|
10
|
+
|
|
9
11
|
If it is an existing issue, read it first (`orqen comments <KEY>` shows its title, description and comments) and start the brief from what it says.
|
|
10
12
|
|
|
11
13
|
Talk with the person briefly, in their language, until you have what `orqen new_worq` needs. Ask only what you cannot infer, one question at a time with your recommendation:
|
package/dist/workflow/board.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/** The roles a person can have on the team (workflow.people in orqen/config.yaml). */
|
|
2
|
+
export const PERSON_ROLES = ["support", "analyst", "developer", "qa", "senior"];
|
|
3
|
+
/**
|
|
4
|
+
* Who a person is on the team: their roles from workflow.people (the name as in git user.name, case and accents ignored).
|
|
5
|
+
* With no people configured everyone does everything (configured: false); a name that is not listed has no roles.
|
|
6
|
+
*/
|
|
7
|
+
export function whoIs(people, name) {
|
|
8
|
+
const norm = (s) => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLowerCase();
|
|
9
|
+
const entries = Object.entries(people ?? {});
|
|
10
|
+
if (!entries.length)
|
|
11
|
+
return { name, roles: [...PERSON_ROLES], configured: false, listed: false };
|
|
12
|
+
const hit = name ? entries.find(([n]) => norm(n) === norm(name)) : undefined;
|
|
13
|
+
return { name: hit?.[0] ?? name, roles: hit ? hit[1].filter((r) => PERSON_ROLES.includes(r)) : [], configured: true, listed: !!hit };
|
|
14
|
+
}
|
|
1
15
|
/** The key a developer works with: the issue when there is one. */
|
|
2
16
|
export const workKey = (item) => item.issue ?? item.key;
|
|
3
17
|
/** The full lane goes through QA (QA_REVIEW, after TESTING) before the senior. */
|
package/dist/workflow/config.js
CHANGED
|
@@ -12,7 +12,7 @@ const env = (k, d = "") => process.env[k] ?? d;
|
|
|
12
12
|
const split = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
13
13
|
/** New variable name, falling back to the one used by earlier versions. */
|
|
14
14
|
const envL = (k, legacy, d = "") => envWithLegacy(process.env, k, legacy, d);
|
|
15
|
-
function repoRoot() {
|
|
15
|
+
export function repoRoot() {
|
|
16
16
|
try {
|
|
17
17
|
return execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd: process.cwd(), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
18
18
|
}
|
|
@@ -77,6 +77,7 @@ export function loadConfig(over = {}) {
|
|
|
77
77
|
// "jira" is the name used by earlier versions for "ticket"
|
|
78
78
|
codeReviewGate: ["ticket", "jira"].includes(env("CODE_REVIEW_GATE") || f?.code_review.gate || "github") ? "ticket" : "github",
|
|
79
79
|
githubReviewers: list("GITHUB_REVIEWERS", f?.code_review.revisores),
|
|
80
|
+
people: f?.personas ?? {},
|
|
80
81
|
openspecCmd: env("OPENSPEC_CMD") && env("OPENSPEC_CMD") !== "openspec" ? env("OPENSPEC_CMD") : existsSync(localOpenSpec) ? localOpenSpec : "openspec",
|
|
81
82
|
stateDir: envL("ORQEN_STATE_DIR", "REC_STATE_DIR") || (existsSync(localState) || !project ? localState : join(main, "orqen", "state")),
|
|
82
83
|
stagesDir: stages ?? join(TEMPLATES_DIR, "stages"),
|
package/dist/workflow/dry-run.js
CHANGED
|
@@ -12,7 +12,7 @@ import { join, relative } from "node:path";
|
|
|
12
12
|
import { Process } from "./process.js";
|
|
13
13
|
import { Store } from "./store.js";
|
|
14
14
|
import { branchFor } from "./workspace.js";
|
|
15
|
-
export
|
|
15
|
+
export { DRY_RUN_COMMANDS } from "./dry-run-commands.js";
|
|
16
16
|
const oneLine = (s, n = 110) => {
|
|
17
17
|
const first = s.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
|
|
18
18
|
return first.length > n || s.trim().includes("\n") ? `${first.slice(0, n)}…` : first;
|
|
@@ -41,6 +41,7 @@ export class DryRun {
|
|
|
41
41
|
state;
|
|
42
42
|
worqs;
|
|
43
43
|
fakeTickets = new Map();
|
|
44
|
+
fakeReviews = [];
|
|
44
45
|
constructor(cfg, connectors, ws, os, realStore, key) {
|
|
45
46
|
this.cfg = cfg;
|
|
46
47
|
this.state = join(this.dir, "state");
|
|
@@ -99,9 +100,14 @@ export class DryRun {
|
|
|
99
100
|
workspace(ws) {
|
|
100
101
|
const git = (text) => this.plan.push({ kind: "git", text });
|
|
101
102
|
const pr = (text) => this.plan.push({ kind: "pr", text });
|
|
102
|
-
|
|
103
|
+
const g = guard(ws, ["currentBranch", "remoteBranchExists", "prState", "prChecks", "prReviews", "snapshotOf"], {
|
|
103
104
|
prepareBranch: (k) => branchFor(k), commit: () => true, push: () => { }, openPr: (v) => `https://dry-run.invalid/pr/${v.key}`,
|
|
104
|
-
closePr: () => { },
|
|
105
|
+
closePr: () => { },
|
|
106
|
+
// the review that would be posted: the gate reads the PR's reviews right after posting, so it has to find this one there
|
|
107
|
+
reviewPr: (_url, action, body) => {
|
|
108
|
+
this.fakeReviews.push({ id: `dry-${this.fakeReviews.length + 1}`, author: this.cfg.githubReviewers[0] ?? "dry-run", state: action === "approve" ? "APPROVED" : "CHANGES_REQUESTED", commit: "", body });
|
|
109
|
+
},
|
|
110
|
+
runTests: () => ({ ok: true, output: "(dry run)" }), startEnvironment: async () => ({ ok: true, detail: "dry run" }), stopEnvironment: () => { },
|
|
105
111
|
}, (n, a) => {
|
|
106
112
|
switch (n) {
|
|
107
113
|
case "commit": return git(`commit "${oneLine(String(a[1]), 100)}" (if there is something to commit)`);
|
|
@@ -112,6 +118,17 @@ export class DryRun {
|
|
|
112
118
|
default: return undefined; // prepareBranch, runTests, environment: nothing to report
|
|
113
119
|
}
|
|
114
120
|
});
|
|
121
|
+
// the PR's reviews are the real ones plus the one this run would post, on the PR's current head
|
|
122
|
+
return new Proxy(g, {
|
|
123
|
+
get: (t, prop) => {
|
|
124
|
+
if (prop === "prReviews" && ws.prReviews)
|
|
125
|
+
return (url) => {
|
|
126
|
+
const snap = ws.prReviews(url);
|
|
127
|
+
return { head: snap.head, reviews: [...snap.reviews, ...this.fakeReviews.map((r) => ({ ...r, commit: snap.head }))] };
|
|
128
|
+
};
|
|
129
|
+
return t[prop];
|
|
130
|
+
},
|
|
131
|
+
});
|
|
115
132
|
}
|
|
116
133
|
openspec(os) {
|
|
117
134
|
return guard(os, ["exists", "dir", "validate", "planningComplete", "tasks", "scenarios"], {
|
|
@@ -19,7 +19,10 @@ export class OpenSpecCli {
|
|
|
19
19
|
run(args) {
|
|
20
20
|
const win = process.platform === "win32"; // with a shell (cmd) arguments containing spaces must be quoted
|
|
21
21
|
const a = win ? args.map((x) => (/[\s"]/.test(x) ? `"${x.replace(/"/g, '\\"')}"` : x)) : args;
|
|
22
|
-
|
|
22
|
+
// the same for the program: a path like C:\Program Files\nodejs\openspec.cmd breaks at its first space in cmd
|
|
23
|
+
// (only when it is a path that exists: OPENSPEC_CMD may also be a command with arguments, like `npx openspec`)
|
|
24
|
+
const cmd = win && /\s/.test(this.cmd) && existsSync(this.cmd) ? `"${this.cmd}"` : this.cmd;
|
|
25
|
+
const p = spawnSync(cmd, a, { cwd: this.repoPath, encoding: "utf8", shell: win });
|
|
23
26
|
if (p.error)
|
|
24
27
|
throw new Error(`Could not run "${this.cmd}": ${p.error.message}. Is OpenSpec installed? (npm i -g @fission-ai/openspec)`);
|
|
25
28
|
try {
|