@telpin-sistemas/orqen 0.1.5 → 0.1.7

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.
Files changed (36) hide show
  1. package/README.md +4 -3
  2. package/dist/commands/update.js +79 -15
  3. package/dist/commands/workflow.js +81 -1
  4. package/dist/connectors/asana.js +14 -4
  5. package/dist/connectors/jira.js +12 -6
  6. package/dist/eval/fake-jira.js +1 -1
  7. package/dist/eval/run.js +3 -3
  8. package/dist/index.js +10 -6
  9. package/dist/lib/agent.js +2 -2
  10. package/dist/lib/kit.js +3 -3
  11. package/dist/lib/proc.js +2 -2
  12. package/dist/lib/provider-credentials.js +1 -1
  13. package/dist/lib/worqs.js +51 -0
  14. package/dist/swarm/plan.js +1 -1
  15. package/dist/swarm/run.js +2 -2
  16. package/dist/template/.agents/commands/analyze.md +2 -2
  17. package/dist/template/.agents/commands/approve.md +2 -2
  18. package/dist/template/.agents/commands/ask.md +11 -0
  19. package/dist/template/.agents/commands/implement.md +1 -1
  20. package/dist/template/.agents/commands/review.md +2 -2
  21. package/dist/template/.agents/commands/support.md +1 -1
  22. package/dist/template/.agents/skills/grilling/SKILL.md +1 -1
  23. package/dist/template/AGENTS.md +10 -4
  24. package/dist/template/orqen/worqs/README.md +9 -0
  25. package/dist/template/stages/analysis.md +1 -1
  26. package/dist/template/stages/delivery.md +1 -1
  27. package/dist/template/stages/development.md +2 -2
  28. package/dist/template/stages/support.md +1 -1
  29. package/dist/tutorial/content.js +1 -1
  30. package/dist/ui/logo.js +4 -4
  31. package/dist/workflow/config.js +18 -2
  32. package/dist/workflow/factory.js +7 -2
  33. package/dist/workflow/process.js +58 -12
  34. package/dist/workflow/workspace.js +13 -6
  35. package/package.json +2 -2
  36. package/dist/template/orqen/work/README.md +0 -3
package/README.md CHANGED
@@ -9,7 +9,7 @@ orqen init # Run from the repository you want to initialize
9
9
 
10
10
  `orqen init [dir]` runs the following setup:
11
11
 
12
- 1. Displays the ORQEN logo and checks Node (20.12 or later), Git, and a package manager. The animation needs a terminal with at least 92 columns and 23 rows. Press Enter to continue. Non-interactive terminals, CI, `--yes`, and `--no-animation` use the static logo.
12
+ 1. Displays the orqen logo and checks Node (20.12 or later), Git, and a package manager. The animation needs a terminal with at least 92 columns and 23 rows. Press Enter to continue. Non-interactive terminals, CI, `--yes`, and `--no-animation` use the static logo.
13
13
  2. Detects components and services from manifests such as `package.json`, `pom.xml`, and `pyproject.toml`, as well as Prisma and `.env.example`, including the command that starts each part (`npm run dev`, `npm start`…).
14
14
  3. Uses an installed AI agent to review a short repository summary in the background. It validates the proposal with Zod. Use `--deep` to let the agent explore the repository or `--no-ai` to use automatic detection only.
15
15
  4. Lets you confirm or edit components, the command that starts each part, tests, migrations, and seed commands.
@@ -40,7 +40,7 @@ For non-interactive first use of `bootstrap`, pass `--tools-repo @company/tools`
40
40
 
41
41
  ## Update an installation
42
42
 
43
- Run `orqen update` from any directory to update the CLI. In an ORQEN project, the same command continues with OpenSpec and the kit using the newly installed CLI. Use `--cli-only` to update just the CLI from inside a project, or `orqen update --desktop` to update the global npm desktop app.
43
+ Run `orqen update` from any directory to update the CLI. In an orqen project, the same command continues with OpenSpec and the kit using the newly installed CLI. Use `--cli-only` to update just the CLI from inside a project, or `orqen update --desktop` to update the global npm desktop app.
44
44
 
45
45
  The kit updates files that still match the manifest. For edited files, you can keep the existing version, replace it, or write a copy with the `.orqen-new` suffix.
46
46
 
@@ -74,6 +74,7 @@ A planner model (default Opus) splits the task into a dependency graph of small
74
74
  orqen list requests
75
75
  orqen analyze SOP-1234
76
76
  orqen status DEV-442
77
+ orqen worqs # the worqs on this machine: orqen's unit of work, one per request (orqen/worqs/)
77
78
  orqen take DEV-442
78
79
  orqen complete DEV-442 output.json
79
80
  orqen cycle --loop
@@ -83,7 +84,7 @@ orqen cycle --loop
83
84
 
84
85
  In `TESTING`, taking the stage starts the full environment, runs the configured suite, and shuts everything down. `orqen cycle --loop` dispatches eligible requests using `AGENT_CMD`. Analysis always requires an analyst.
85
86
 
86
- In the full lane, QA runs `/orqen:review <KEY>` in `QA_REVIEW` and records the decision with `orqen review <KEY> approve|reject`; the direct and light lanes skip QA. Run `orqen pr <KEY>` to inspect the integration target or add an explanation file to open the PR to `DEVEL_BRANCH`; testing opens no PR, so this is the PR the senior reviews. In `CODE_REVIEW`, the senior runs `/orqen:code-review <KEY>`, and `orqen code-review <KEY> <report.md> --verdict <approve|minor|reject>` records the report under `orqen/work/<KEY>/round-N/` and comments it on the internal ticket (or the external one) without changing the stage.
87
+ In the full lane, QA runs `/orqen:review <KEY>` in `QA_REVIEW` and records the decision with `orqen review <KEY> approve|reject`; the direct and light lanes skip QA. Run `orqen pr <KEY>` to inspect the integration target or add an explanation file to open the PR to `DEVEL_BRANCH`; testing opens no PR, so this is the PR the senior reviews. In `CODE_REVIEW`, the senior runs `/orqen:code-review <KEY>`, and `orqen code-review <KEY> <report.md> --verdict <approve|minor|reject>` records the report under `orqen/worqs/<KEY>/round-N/` and comments it on the internal ticket (or the external one) without changing the stage.
87
88
 
88
89
  For an existing checkout, the CLI also reads `cli/.env` and its local state under `cli/.state/`. The flow settings (approvers, code review gate, integration branch) live under `workflow` in `orqen/config.yaml` (English keys; the Spanish ones of earlier versions are still read); a variable such as `APPROVERS_CODE` or `DEVEL_BRANCH` in `.env` or the environment overrides them.
89
90
 
@@ -1,4 +1,4 @@
1
- /** Update the CLI or desktop app, and refresh OpenSpec and managed kit files in an ORQEN project. */
1
+ /** Update the CLI or desktop app, and refresh OpenSpec and managed kit files in an orqen project. */
2
2
  import { existsSync, readFileSync, realpathSync } from "node:fs";
3
3
  import { join, resolve } from "node:path";
4
4
  import semver from "semver";
@@ -13,15 +13,17 @@ import { resumenStack } from "../lib/stack.js";
13
13
  import { mostrarLogo } from "../ui/logo.js";
14
14
  import { azul, confirmar, gris, interactivo, magenta, p, pc } from "../ui/console.js";
15
15
  import { resolverConflicto } from "./init.js";
16
+ import { moveWorkToWorqs } from "../lib/worqs.js";
16
17
  const PAQUETE_DESKTOP = "@telpin-sistemas/orqen-desktop";
18
+ const DESKTOP_REPO = "sistemas-telpin/orqen-gui";
17
19
  function paqueteGlobal(gestor, paquete) {
18
20
  const r = ejecutar(gestor, ["root", "-g"], { timeoutMs: 20_000 });
19
21
  if (r.codigo !== 0 || !r.stdout.trim())
20
22
  throw new Error(r.stderr.trim() || r.error?.message || `Could not locate global packages for ${gestor}.`);
21
23
  return join(r.stdout.trim(), paquete);
22
24
  }
23
- async function actualizarPaquete(gestor, paquete, actual, yes) {
24
- const ultima = ultimaVersionPaquete(gestor, paquete);
25
+ async function actualizarPaquete(gestor, paquete, actual, yes, objetivo) {
26
+ const ultima = objetivo ?? ultimaVersionPaquete(gestor, paquete);
25
27
  if (!ultima)
26
28
  return { status: "unavailable", version: actual };
27
29
  if (!semver.gt(ultima, actual))
@@ -33,25 +35,76 @@ async function actualizarPaquete(gestor, paquete, actual, yes) {
33
35
  throw new Error(`Update failed for ${paquete}: ${(r.stderr || r.stdout || r.error?.message || `exit code ${r.codigo}`).trim().slice(-1500)}`);
34
36
  return { status: "installed", version: ultima };
35
37
  }
38
+ function versionDesktop() {
39
+ const manifest = join(paqueteGlobal("npm", PAQUETE_DESKTOP), "package.json");
40
+ if (!existsSync(manifest))
41
+ throw new Error("Install orqen Desktop globally with npm before updating it.");
42
+ const launcher = process.env.ORQEN_DESKTOP_NPM_MANIFEST;
43
+ if (launcher && realpathSync(launcher) !== realpathSync(manifest)) {
44
+ throw new Error("The running desktop app is outside the active global npm installation.");
45
+ }
46
+ const { version } = JSON.parse(readFileSync(manifest, "utf8"));
47
+ if (typeof version !== "string" || !semver.valid(version))
48
+ throw new Error("Invalid installed desktop version.");
49
+ return version;
50
+ }
51
+ async function githubDesktop(path) {
52
+ const api = `repos/${DESKTOP_REPO}/${path}`;
53
+ try {
54
+ const response = await fetch(`https://api.github.com/${api}`, {
55
+ headers: { Accept: "application/vnd.github+json" },
56
+ signal: AbortSignal.timeout(5_000),
57
+ });
58
+ if (response.ok)
59
+ return await response.json();
60
+ }
61
+ catch { /* Try the locally authenticated GitHub CLI. */ }
62
+ const authenticated = await ejecutarAsync("gh", ["api", api], {
63
+ timeoutMs: 5_000, env: { ...process.env, GH_PROMPT_DISABLED: "1" },
64
+ });
65
+ if (authenticated.codigo !== 0)
66
+ throw new Error("Desktop release metadata is unavailable.");
67
+ return JSON.parse(authenticated.stdout);
68
+ }
69
+ /** Read-only discovery for the desktop app. Installation is a separate, pinned action. */
70
+ export async function desktopRelease(installed) {
71
+ if (!semver.valid(installed))
72
+ throw new Error("Invalid running desktop version.");
73
+ const actual = versionDesktop();
74
+ if (semver.gt(actual, installed)) {
75
+ return console.log(JSON.stringify({ status: "installed", version: actual }));
76
+ }
77
+ const version = ultimaVersionPaquete("npm", PAQUETE_DESKTOP);
78
+ if (!version)
79
+ throw new Error("Could not check npm for orqen Desktop updates.");
80
+ if (!semver.gt(version, installed))
81
+ return console.log(JSON.stringify({ status: "current", version: installed }));
82
+ const range = `v${installed}...v${version}`;
83
+ const [release, comparison] = await Promise.allSettled([
84
+ githubDesktop(`releases/tags/v${version}`), githubDesktop(`compare/${range}?per_page=100`),
85
+ ]);
86
+ const notes = release.status === "fulfilled" && typeof release.value.body === "string" ? release.value.body.trim() : "";
87
+ const commits = comparison.status === "fulfilled" && Array.isArray(comparison.value.commits)
88
+ ? comparison.value.commits.map((c) => c.commit?.message?.split("\n")[0]).filter(Boolean)
89
+ : [];
90
+ console.log(JSON.stringify({
91
+ status: "available", version, notes, commits, url: `https://github.com/${DESKTOP_REPO}/compare/${range}`,
92
+ }));
93
+ }
36
94
  export async function update(o) {
95
+ if (o.target !== undefined && (!o.desktop || !semver.valid(o.target)))
96
+ throw new Error("--target requires --desktop and a valid version.");
37
97
  if (o.desktop) {
38
- const manifest = join(paqueteGlobal("npm", PAQUETE_DESKTOP), "package.json");
39
- if (!existsSync(manifest))
40
- throw new Error("Install ORQEN Desktop globally with npm before updating it.");
41
- const launcher = process.env.ORQEN_DESKTOP_NPM_MANIFEST;
42
- if (launcher && realpathSync(launcher) !== realpathSync(manifest)) {
43
- throw new Error("The running desktop app is outside the active global npm installation.");
44
- }
45
- const { version: actual } = JSON.parse(readFileSync(manifest, "utf8"));
46
- const result = await actualizarPaquete("npm", PAQUETE_DESKTOP, actual, !!o.yes || !interactivo());
98
+ const actual = versionDesktop();
99
+ const result = await actualizarPaquete("npm", PAQUETE_DESKTOP, actual, !!o.yes || !interactivo(), o.target);
47
100
  if (result.status === "unavailable")
48
- throw new Error("Could not check npm for ORQEN Desktop updates.");
101
+ throw new Error("Could not check npm for orqen Desktop updates.");
49
102
  if (o.json)
50
103
  console.log(JSON.stringify(result));
51
104
  else if (result.status === "installed")
52
- console.log(`ORQEN Desktop ${result.version} installed. Restart the app to use it.`);
105
+ console.log(`orqen Desktop ${result.version} installed. Restart the app to use it.`);
53
106
  else if (result.status === "current")
54
- console.log(`ORQEN Desktop ${result.version} is up to date.`);
107
+ console.log(`orqen Desktop ${result.version} is up to date.`);
55
108
  return;
56
109
  }
57
110
  const repo = resolve(o.dir ?? process.cwd());
@@ -127,6 +180,17 @@ export async function update(o) {
127
180
  }
128
181
  }
129
182
  }
183
+ // 2b. The worqs (the record of each request): orqen/work/ of earlier versions → orqen/worqs/
184
+ if (existsSync(join(repo, "orqen", "work")) && !existsSync(join(repo, "orqen", "worqs"))) {
185
+ p.log.info("The worqs (orqen's unit of work: one folder per request) are now in orqen/worqs/; this repository still has them in orqen/work/.");
186
+ if (await confirmar("Move orqen/work/ to orqen/worqs/ (git mv)? Branches of requests in progress keep their old path and are still read", true, yes)) {
187
+ const m = moveWorkToWorqs(repo);
188
+ if (m.moved)
189
+ p.log.success(`${m.detail} ${gris("(commit the move with the rest of the update)")}`);
190
+ else
191
+ p.log.warn(m.detail);
192
+ }
193
+ }
130
194
  // 3. Kit
131
195
  if (!o.sinKit) {
132
196
  const manifest = leerManifest(repo);
@@ -16,7 +16,7 @@ import { OpenSpecCli } from "../workflow/openspec.js";
16
16
  import { Process } from "../workflow/process.js";
17
17
  import { Store } from "../workflow/store.js";
18
18
  import { GitWorkspace } from "../workflow/workspace.js";
19
- export const WORKFLOW_COMMANDS = ["list", "qa", "approve", "merged", "cancel", "pending", "support", "analyze", "lane", "take", "complete", "pr", "review", "code-review", "schema", "block", "release", "search", "status", "cycle", "connectors", "comments", "comment"];
19
+ export const WORKFLOW_COMMANDS = ["list", "qa", "approve", "merged", "cancel", "pending", "support", "analyze", "ask", "conversation", "lane", "take", "complete", "pr", "review", "code-review", "schema", "block", "release", "search", "status", "worqs", "worq", "cycle", "connectors", "comments", "comment"];
20
20
  /** What people run: the 9 steps (as /orqen:* commands in their agent) and the CLI commands meant for a person. */
21
21
  export const WORKFLOW_HELP = `The 9 steps (run the /orqen:* commands in your agent: it calls the CLI for you):
22
22
  1 /orqen:list requests orqen list requests [--json] [--all] Everyone's work list, by role (takes nothing)
@@ -30,7 +30,11 @@ export const WORKFLOW_HELP = `The 9 steps (run the /orqen:* commands in your age
30
30
  9 /orqen:approve <KEY> Senior: approve the PR or request changes; after the hand merge, run it again to deliver
31
31
 
32
32
  Request commands for people:
33
+ ask <KEY> <question> Ask the requester on their ticket from any stage (/orqen:ask in the agent)
34
+ conversation <KEY> Refresh and show the request comments saved in the worq's conversation.json
33
35
  status [KEY] [--json] Where a request is, who acts and what comes next (no KEY: all of them)
36
+ worqs [--all] [--json] The worqs on this machine: orqen's unit of work, one per request (request + issue + branch + PR + record)
37
+ worq <KEY> [--json] One worq: state, request, issue, branch, PR and the files of its record in orqen/worqs/<KEY>/
34
38
  merged <KEY> [--person N] Confirm the hand merge of an approved PR when orqen cannot read it from GitHub
35
39
  cancel <KEY> --reason T Close the request without delivering it: closes the PR unmerged, comments both tickets (CANCELLED)
36
40
  release <KEY> Free a request held by an agent that is no longer working on it
@@ -171,6 +175,23 @@ export async function runWorkflow(cmd, rest) {
171
175
  }
172
176
  async function dispatch() {
173
177
  switch (cmd) {
178
+ case "ask":
179
+ case "conversation": {
180
+ if (!/^[\w-][\w.-]*$/.test(rest[0] ?? "") || (cmd === "conversation" && rest.length !== 1)) {
181
+ throw new Error(`Usage: orqen ${cmd} <KEY>${cmd === "ask" ? " <question>" : ""}`);
182
+ }
183
+ const key = toKey(rest[0]);
184
+ if (cmd === "conversation") {
185
+ console.log(JSON.stringify(await flow.conversation(key), null, 2));
186
+ }
187
+ else {
188
+ const { warning } = await flow.ask(key, rest.slice(1).join(" "));
189
+ console.log(`Question posted to ${key}. Conversation saved in ${flow.worqRel(key)}/conversation.json`);
190
+ if (warning)
191
+ console.log(`⚠ ${warning}`);
192
+ }
193
+ return;
194
+ }
174
195
  case "list": {
175
196
  const what = (rest[0] ?? "requests").toLowerCase();
176
197
  const json = has("json"), all = has("all");
@@ -468,6 +489,65 @@ export async function runWorkflow(cmd, rest) {
468
489
  }));
469
490
  return console.log(JSON.stringify(out, null, 2));
470
491
  }
492
+ case "worqs": {
493
+ const { isFinal } = await import("../workflow/states.js");
494
+ const all = has("all"), json = has("json");
495
+ const list = store.all().filter((r) => all || !isFinal(r.state)).map((r) => flow.worq(r));
496
+ if (json)
497
+ return console.log(JSON.stringify(list, null, 2));
498
+ if (!list.length)
499
+ return console.log("No worqs on this machine. `orqen list requests` shows the open requests (a worq starts when orqen takes one).");
500
+ console.log(`Worqs (orqen's unit of work), ${all ? "all" : "open"}:`);
501
+ for (const w of list)
502
+ console.log(` ${w.key.padEnd(10)} ${(w.issue ?? "").padEnd(10)} ${w.state.padEnd(15)} ${(w.lane ?? "").padEnd(7)} ${w.dir}${w.pr ? ` PR ${w.pr}` : w.branch ? ` ${w.branch}` : ""}`);
503
+ return;
504
+ }
505
+ case "worq": {
506
+ try {
507
+ const key = toKey(rest[0]);
508
+ const json = has("json");
509
+ if (!key)
510
+ throw new Error("Usage: orqen worq <KEY> [--json]");
511
+ const item = flow.item(key) ?? await flow.peek(key);
512
+ if (!item)
513
+ throw new Error(`${key} is not a worq on this machine. \`orqen list requests\` shows the open requests; a worq starts when orqen takes one.`);
514
+ const { worqFiles } = await import("../lib/worqs.js");
515
+ const w = flow.worq(item);
516
+ const files = item.recovered ? [] : worqFiles(join(cfg.factoryDir, item.key));
517
+ const events = store.events(item.key);
518
+ if (json)
519
+ return console.log(JSON.stringify({ ...w, files, events: events.slice(-10) }, null, 2));
520
+ console.log(`Worq ${w.key}${w.title ? ` — ${w.title}` : ""}`);
521
+ console.log(` State: ${w.state}${w.round > 1 ? ` (round ${w.round})` : ""}${w.lane ? ` · lane ${w.lane}` : ""}${w.route && w.route !== "development" ? ` · ${w.route}` : ""}`);
522
+ if (w.next[0])
523
+ console.log(` Next: ${w.next[0].command} (${w.role}: ${w.next[0].what})`);
524
+ console.log(` Request: ${w.key} ${w.request_url}`);
525
+ if (w.issue)
526
+ console.log(` Issue: ${w.issue}${w.issue_url ? ` ${w.issue_url}` : ""}`);
527
+ if (w.branch)
528
+ console.log(` Branch: ${w.branch}`);
529
+ if (w.pr)
530
+ console.log(` PR: ${w.pr}${w.merged ? " (merged)" : ""}`);
531
+ if (w.supporter || w.analyst)
532
+ console.log(` People: ${[w.supporter && `support ${w.supporter}`, w.analyst && `analyst ${w.analyst}`].filter(Boolean).join(" · ")}`);
533
+ if (item.recovered)
534
+ console.log(" The state is read from the ticket's label: this machine has no record. Fetch its branch to recover the worq (git fetch origin " + (w.branch ?? `orqen/${key.toLowerCase()}`) + ").");
535
+ else {
536
+ console.log(` Folder: ${w.dir}/`);
537
+ for (const f of files)
538
+ console.log(` ${f}`);
539
+ if (!files.length)
540
+ console.log(` (no files in this checkout${w.branch ? `: they are in the branch ${w.branch}` : ""})`);
541
+ }
542
+ for (const ev of events.slice(-5))
543
+ console.log(` ${ev.ts.slice(0, 16).replace("T", " ")} ${ev.from} → ${ev.to} ${ev.detail}`);
544
+ }
545
+ catch (e) {
546
+ console.error(`✘ ${e.message}`);
547
+ process.exitCode = 1;
548
+ }
549
+ return;
550
+ }
471
551
  case "status": {
472
552
  if (has("json")) {
473
553
  if (rest[0]) {
@@ -16,7 +16,7 @@ export class AsanaTracker {
16
16
  this.api = api;
17
17
  }
18
18
  get label() { return `Asana project ${this.s.project || "(none)"}`; }
19
- async req(method, path, body) {
19
+ async requestPage(method, path, body) {
20
20
  if (!this.s.token)
21
21
  throw new Error("Asana connector without token: set ASANA_TOKEN in orqen/.env");
22
22
  const r = await fetch(this.api + path, {
@@ -27,7 +27,10 @@ export class AsanaTracker {
27
27
  if (!r.ok)
28
28
  throw new Error(`Asana ${method} ${path}: ${r.status} ${await r.text()}`);
29
29
  const t = await r.text();
30
- return t ? JSON.parse(t).data : {};
30
+ return t ? JSON.parse(t) : { data: {} };
31
+ }
32
+ async req(method, path, body) {
33
+ return (await this.requestPage(method, path, body)).data;
31
34
  }
32
35
  gid = (key) => idOf(this.s.prefix, key);
33
36
  needProject() { if (!this.s.project)
@@ -52,8 +55,15 @@ export class AsanaTracker {
52
55
  };
53
56
  }
54
57
  async comments(key) {
55
- const s = await this.req("GET", `/tasks/${this.gid(key)}/stories?opt_fields=type,text,created_by.gid,created_by.name,created_at`);
56
- return s.filter((x) => x.type === "comment").map((x) => ({
58
+ const path = `/tasks/${this.gid(key)}/stories?limit=100&opt_fields=type,text,created_by.gid,created_by.name,created_at`;
59
+ const stories = [];
60
+ let offset;
61
+ do {
62
+ const page = await this.requestPage("GET", offset ? `${path}&offset=${encodeURIComponent(offset)}` : path);
63
+ stories.push(...page.data);
64
+ offset = page.next_page?.offset;
65
+ } while (offset);
66
+ return stories.filter((x) => x.type === "comment").map((x) => ({
57
67
  id: x.gid, author: x.created_by?.gid ?? "", authorName: x.created_by?.name ?? "", body: x.text ?? "", created: x.created_at ?? "",
58
68
  }));
59
69
  }
@@ -18,7 +18,7 @@ export class JiraTracker {
18
18
  return "not configured";
19
19
  return `Jira${this.s.project ? ` ${this.s.project}` : ""} (${this.base.replace(/^https?:\/\//, "") || "no URL"})`;
20
20
  }
21
- /** ORQEN role prefixes are independent of the native Jira project key. */
21
+ /** orqen role prefixes are independent of the native Jira project key. */
22
22
  native(key) {
23
23
  if (!this.s.prefix || !key.toUpperCase().startsWith(`${this.s.prefix}-`))
24
24
  return key;
@@ -70,11 +70,17 @@ export class JiraTracker {
70
70
  };
71
71
  }
72
72
  async comments(key) {
73
- const r = await this.req("GET", `/rest/api/2/issue/${this.native(key)}/comment`, undefined, { maxResults: 500, orderBy: "created" });
74
- return (r.comments ?? []).map((c) => ({
75
- id: String(c.id), author: c.author?.accountId ?? c.author?.name ?? "",
76
- authorName: c.author?.displayName ?? "", body: c.body ?? "", created: c.created ?? "",
77
- }));
73
+ const comments = [];
74
+ for (;;) {
75
+ const r = await this.req("GET", `/rest/api/2/issue/${this.native(key)}/comment`, undefined, { startAt: comments.length, maxResults: 500, orderBy: "created" });
76
+ for (const c of r.comments ?? [])
77
+ comments.push({
78
+ id: String(c.id), author: c.author?.accountId ?? c.author?.name ?? "",
79
+ authorName: c.author?.displayName ?? "", body: c.body ?? "", created: c.created ?? "",
80
+ });
81
+ if (!r.comments?.length || r.total == null || comments.length >= r.total)
82
+ return comments;
83
+ }
78
84
  }
79
85
  async comment(key, text) {
80
86
  await this.req("POST", `/rest/api/2/issue/${this.native(key)}/comment`, { body: `${BOT_MARK} ${text}` });
@@ -36,7 +36,7 @@ export class FakeJira {
36
36
  raw += part;
37
37
  const body = raw ? JSON.parse(raw) : {};
38
38
  if (path === "/rest/api/2/myself")
39
- return send(200, { name: "orqen-eval", displayName: "ORQEN eval" });
39
+ return send(200, { name: "orqen-eval", displayName: "orqen eval" });
40
40
  if (path.startsWith("/rest/api/2/project/"))
41
41
  return send(200, { key: path.split("/").pop() });
42
42
  if (req.method === "GET" && ["/rest/api/2/search", "/rest/api/3/search/jql"].includes(path)) {
package/dist/eval/run.js CHANGED
@@ -42,7 +42,7 @@ export function expandCommand(repo, command, args) {
42
42
  if (cur.trim())
43
43
  tools.push(cur.trim());
44
44
  return {
45
- prompt: `Run the ORQEN command /orqen:${command} ${args}. Its instructions follow, with $ARGUMENTS = "${args}".\n\n${body.replaceAll("$ARGUMENTS", args).trim()}`,
45
+ prompt: `Run the orqen command /orqen:${command} ${args}. Its instructions follow, with $ARGUMENTS = "${args}".\n\n${body.replaceAll("$ARGUMENTS", args).trim()}`,
46
46
  tools: tools.filter((t) => t && t !== "AskUserQuestion"),
47
47
  };
48
48
  }
@@ -123,7 +123,7 @@ export async function runCase(c, o) {
123
123
  delete env[k];
124
124
  const git = (...args) => execFileSync("git", args, { cwd: repo, env, stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" });
125
125
  git("init", "-qb", "main");
126
- git("config", "user.name", "ORQEN eval");
126
+ git("config", "user.name", "orqen eval");
127
127
  git("config", "user.email", "eval@orqen.invalid");
128
128
  writeFileSync(join(repo, "README.md"), "# Test project\n\nA small business application used by `orqen eval`.\n");
129
129
  for (const [p, content] of Object.entries(c.files ?? {})) {
@@ -143,7 +143,7 @@ export async function runCase(c, o) {
143
143
  if (o.knowledge && existsSync(o.knowledge))
144
144
  cpSync(o.knowledge, join(repo, "orqen", "knowledge"), { recursive: true });
145
145
  git("add", "-A");
146
- git("commit", "-qm", "Test project with ORQEN");
146
+ git("commit", "-qm", "Test project with orqen");
147
147
  const { command } = EVAL_STEPS[c.step];
148
148
  const { prompt, tools } = expandCommand(repo, command, EVAL_KEY);
149
149
  const run = agentArgs(o.agentCmd, `${PREAMBLE}\n\n${prompt}`, tools);
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- /** ORQEN command-line entry point. */
2
+ /** orqen command-line entry point. */
3
3
  import { parseArgs } from "node:util";
4
4
  import { entorno } from "./commands/environment.js";
5
5
  import { bootstrap } from "./commands/bootstrap.js";
6
6
  import { init } from "./commands/init.js";
7
7
  import { WORKFLOW_HELP, WORKFLOW_INTERNAL_HELP, WORKFLOW_COMMANDS, runWorkflow } from "./commands/workflow.js";
8
- import { update } from "./commands/update.js";
8
+ import { desktopRelease, update } from "./commands/update.js";
9
9
  import { SWARM_HELP, swarm } from "./commands/swarm.js";
10
10
  import { lang, tutorial } from "./commands/tutorial.js";
11
11
  import { VERSION_CLI } from "./lib/system.js";
@@ -19,7 +19,7 @@ Usage: orqen <command> [options]
19
19
  orqen This help (the desktop app is a separate project: github.com/sistemas-telpin/orqen-gui)
20
20
 
21
21
  Commands:
22
- init [dir] Initialize ORQEN in a repository (default: current directory)
22
+ init [dir] Initialize orqen in a repository (default: current directory)
23
23
  --yes, -y Use defaults and write conflicts alongside the originals
24
24
  --no-ai Use automatic detection only
25
25
  --deep Let the agent explore the repository in depth
@@ -36,9 +36,10 @@ Commands:
36
36
  --stack <id> Stack from your private catalog (orqen bootstrap --list lists them)
37
37
  --dir <folder> Where to create it (default: ./<name>)
38
38
  --params '<json>' Parameter values, e.g. '{"PORT":"8081"}' (the rest use their defaults)
39
- update [dir] Update the CLI and, in an ORQEN project, OpenSpec and the kit
39
+ update [dir] Update the CLI and, in an orqen project, OpenSpec and the kit
40
40
  --cli-only Update only the CLI
41
- --desktop Update the global npm install of ORQEN Desktop
41
+ --desktop Update the global npm install of orqen Desktop
42
+ --target <version> Install this exact desktop version
42
43
  --yes, -y --no-cli --no-openspec --no-kit
43
44
  env <cmd> setup | up [--all] | test [type...] | status | down
44
45
  tutorial [step] Step-by-step tour for newcomers, in your system language (es/en)
@@ -75,6 +76,8 @@ async function main() {
75
76
  return usageCommand(crudos.slice(1));
76
77
  if (crudos[0] === "eval")
77
78
  return evalCommand(crudos.slice(1));
79
+ if (crudos[0] === "desktop-release")
80
+ return desktopRelease(crudos[1] ?? "");
78
81
  if (crudos[0] === "learn")
79
82
  return learnCommand(crudos.slice(1));
80
83
  if (crudos[0] === "spec")
@@ -105,6 +108,7 @@ async function main() {
105
108
  "no-cli": { type: "boolean" },
106
109
  "cli-only": { type: "boolean" },
107
110
  desktop: { type: "boolean" },
111
+ target: { type: "string" },
108
112
  "no-kit": { type: "boolean" },
109
113
  all: { type: "boolean" },
110
114
  dir: { type: "string" },
@@ -151,7 +155,7 @@ async function main() {
151
155
  return update({
152
156
  dir: v.dir ?? resto[0], yes: !!v.yes, sinCli: !!v["no-cli"],
153
157
  sinOpenspec: !!v["no-openspec"], sinKit: !!v["no-kit"], sinAnimacion: !!v["no-animation"],
154
- cliOnly: !!v["cli-only"], desktop: !!v.desktop, json: !!v.json,
158
+ cliOnly: !!v["cli-only"], desktop: !!v.desktop, json: !!v.json, target: v.target,
155
159
  });
156
160
  case "env":
157
161
  return entorno(resto[0], resto.slice(1), { dir: v.dir, todos: !!v.all, json: !!v.json, extra });
package/dist/lib/agent.js CHANGED
@@ -30,7 +30,7 @@ export function agentesInstalados() {
30
30
  export const RUTA_PROPUESTA = "orqen/tmp/stack-proposal.json";
31
31
  export function promptExploracion(deteccion, errores) {
32
32
  return [
33
- "You are the ORQEN setup agent.",
33
+ "You are the orqen setup agent.",
34
34
  "Inspect this repository from its root and propose its stack and environments",
35
35
  "so other agents can start it and run all tests (unit, integration,",
36
36
  "end-to-end, and visual) without manual setup. Each part runs on the host with its own command",
@@ -133,7 +133,7 @@ export function comandoRapido(comando) {
133
133
  }
134
134
  export function promptRapido(repo, deteccion, errores) {
135
135
  return [
136
- "You are the ORQEN setup agent. Use only the information below. Do not call tools,",
136
+ "You are the orqen setup agent. Use only the information below. Do not call tools,",
137
137
  "read files, or run commands. In one response, propose a stack and environments so",
138
138
  "other agents can start the project and run its unit, integration, end-to-end, and visual tests.",
139
139
  "Each part runs on the host with its own command (npm run dev, npm start, mvn spring-boot:run…): set `comandos.dev`",
package/dist/lib/kit.js CHANGED
@@ -21,7 +21,7 @@ export const DIR_ORQEN = "orqen";
21
21
  export const ARCHIVO_MANIFEST = "orqen/manifest.json";
22
22
  export const INICIO_BLOQUE = "<!-- orqen:inicio — managed by orqen (edit outside this block; `orqen update` refreshes it) -->";
23
23
  export const FIN_BLOQUE = "<!-- orqen:fin -->";
24
- export const IGNORAR_GIT = ["orqen/state/", "orqen/tmp/", "orqen/.env"];
24
+ export const IGNORAR_GIT = ["orqen/state/", "orqen/tmp/", "orqen/.env", "orqen/worqs/*/conversation.json"];
25
25
  export const normalizar = (s) => s.replace(/\r\n/g, "\n");
26
26
  export const hash = (s) => createHash("sha256").update(normalizar(s)).digest("hex").slice(0, 16);
27
27
  const leer = (p) => (existsSync(p) ? readFileSync(p, "utf8") : undefined);
@@ -62,7 +62,7 @@ export function archivosDelKit(vars, repo) {
62
62
  out[`${DIR_ORQEN}/stages/${stageGuideFile(join(repo, DIR_ORQEN, "stages"), f)}`] = render(readFileSync(join(TEMPLATES_DIR, "stages", f), "utf8"), vars);
63
63
  for (const f of listar(join(TEMPLATES_DIR, ".agents")))
64
64
  out[`${DIR_ORQEN}/plugin/${f}`] = render(readFileSync(join(TEMPLATES_DIR, ".agents", f), "utf8"), vars);
65
- out[`${DIR_ORQEN}/work/README.md`] = render(readFileSync(join(TEMPLATES_DIR, "orqen", "work", "README.md"), "utf8"), vars);
65
+ out[`${DIR_ORQEN}/worqs/README.md`] = render(readFileSync(join(TEMPLATES_DIR, "orqen", "worqs", "README.md"), "utf8"), vars);
66
66
  return out;
67
67
  }
68
68
  export function bloqueAgents(vars) {
@@ -114,7 +114,7 @@ export function marketplace(actual) {
114
114
  j.plugins = Array.isArray(j.plugins) ? j.plugins : [];
115
115
  const entrada = {
116
116
  name: "orqen", source: `./${DIR_ORQEN}/plugin`,
117
- description: "ORQEN: /orqen:support (first-line answer or escalation), /orqen:analyze (analyst interview, lane, spec, and issue) and /orqen:implement",
117
+ description: "orqen: /orqen:support (first-line answer or escalation), /orqen:analyze (analyst interview, lane, spec, and issue) and /orqen:implement",
118
118
  };
119
119
  const i = j.plugins.findIndex((p) => p?.name === "orqen");
120
120
  if (i >= 0)
package/dist/lib/proc.js CHANGED
@@ -34,8 +34,8 @@ export function ejecutarAsync(cmd, args, o = {}) {
34
34
  stderr += "\n[timeout]";
35
35
  hijo.kill();
36
36
  } }, o.timeoutMs) : undefined;
37
- hijo.stdout?.on("data", (d) => (stdout += d));
38
- hijo.stderr?.on("data", (d) => (stderr += d));
37
+ hijo.stdout?.setEncoding("utf8").on("data", (d) => (stdout += d));
38
+ hijo.stderr?.setEncoding("utf8").on("data", (d) => (stderr += d));
39
39
  hijo.on("error", (error) => { terminado = true; clearTimeout(timer); resolve({ codigo: 127, stdout, stderr, error }); });
40
40
  hijo.on("close", (codigo) => { terminado = true; clearTimeout(timer); resolve({ codigo: codigo ?? 1, stdout, stderr }); });
41
41
  if (o.entrada !== undefined)
@@ -40,7 +40,7 @@ export function saveProviders(connectors, draft, current) {
40
40
  }
41
41
  const file = providerFile();
42
42
  mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
43
- writeFileSync(file + ".tmp", completarEnv("# ORQEN provider accounts for this user. Never commit this file.\n", values), { mode: 0o600 });
43
+ writeFileSync(file + ".tmp", completarEnv("# orqen provider accounts for this user. Never commit this file.\n", values), { mode: 0o600 });
44
44
  renameSync(file + ".tmp", file);
45
45
  chmodSync(file, 0o600);
46
46
  rmSync(legacyFile(), { force: true }); // everything it had is now in credentials.env
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A worq is orqen's unit of work: what orqen carries for each request of the client (the request, its issue, the branch, the spec,
3
+ * the PR and the record of every stage). It is identified by the key of the request and lives in orqen/worqs/<KEY>/.
4
+ * Earlier versions called that folder orqen/work/: `orqen update` moves it.
5
+ */
6
+ import { execFileSync } from "node:child_process";
7
+ import { existsSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
8
+ import { join, relative } from "node:path";
9
+ import { ARCHIVO_MANIFEST, leerManifest } from "./kit.js";
10
+ /** Files of a worq (relative to its folder, with forward slashes), sorted. */
11
+ export function worqFiles(dir) {
12
+ const out = [];
13
+ const walk = (d) => {
14
+ for (const name of readdirSync(d).sort()) {
15
+ const p = join(d, name);
16
+ if (statSync(p).isDirectory())
17
+ walk(p);
18
+ else
19
+ out.push(relative(dir, p).replaceAll("\\", "/"));
20
+ }
21
+ };
22
+ if (existsSync(dir))
23
+ walk(dir);
24
+ return out;
25
+ }
26
+ /**
27
+ * Moves orqen/work/ (earlier versions) to orqen/worqs/ with `git mv` (plain rename when git cannot), and renames its README in the
28
+ * manifest so `orqen update` still sees it as a kit file nobody edited. Does nothing when there is nothing to move or the new
29
+ * folder already exists.
30
+ */
31
+ export function moveWorkToWorqs(repo) {
32
+ const old = join(repo, "orqen", "work"), neu = join(repo, "orqen", "worqs");
33
+ if (!existsSync(old))
34
+ return { moved: false, detail: "there is no orqen/work/" };
35
+ if (existsSync(neu))
36
+ return { moved: false, detail: "orqen/worqs/ already exists: move the contents of orqen/work/ by hand" };
37
+ try {
38
+ execFileSync("git", ["mv", "orqen/work", "orqen/worqs"], { cwd: repo, stdio: "pipe" });
39
+ }
40
+ catch {
41
+ renameSync(old, neu);
42
+ }
43
+ const manifest = leerManifest(repo);
44
+ const a = manifest.archivos;
45
+ if (a["orqen/work/README.md"] !== undefined) {
46
+ a["orqen/worqs/README.md"] = a["orqen/work/README.md"];
47
+ delete a["orqen/work/README.md"];
48
+ writeFileSync(join(repo, ARCHIVO_MANIFEST), JSON.stringify(manifest, null, 2) + "\n");
49
+ }
50
+ return { moved: true, detail: "orqen/work/ → orqen/worqs/" };
51
+ }
@@ -101,7 +101,7 @@ export function topologicalOrder(plan) {
101
101
  }
102
102
  export function plannerPrompt(task, o = {}) {
103
103
  return [
104
- "You are the ORQEN swarm planner. Break the task below into small subtasks that cheap, fast models",
104
+ "You are the orqen swarm planner. Break the task below into small subtasks that cheap, fast models",
105
105
  "(e.g. Claude Haiku) will solve in parallel, each in its own git worktree, without talking to each other.",
106
106
  "Read the repository as needed to plan well, but do not modify any file.",
107
107
  "",
package/dist/swarm/run.js CHANGED
@@ -19,7 +19,7 @@ const tail = (s, n = 4000) => (s.length > n ? `…${s.slice(-n)}` : s);
19
19
  export function workerPrompt(task, plan, st, o) {
20
20
  const others = plan.subtasks.filter((x) => x.id !== st.id && !o.done.includes(x.id) && x.files.length);
21
21
  return [
22
- "You are an ORQEN swarm worker. You are in a git worktree of the repository and must complete ONE small",
22
+ "You are an orqen swarm worker. You are in a git worktree of the repository and must complete ONE small",
23
23
  "subtask of a larger task. Other workers handle the other subtasks in parallel in their own worktrees.",
24
24
  "",
25
25
  "Overall task (context only, do not do all of it):",
@@ -45,7 +45,7 @@ export function workerPrompt(task, plan, st, o) {
45
45
  }
46
46
  export function fixerPrompt(task, plan, command, output) {
47
47
  return [
48
- "You are the ORQEN swarm integrator. Several workers completed the subtasks below and their work was merged",
48
+ "You are the orqen swarm integrator. Several workers completed the subtasks below and their work was merged",
49
49
  "into this worktree, but the final verification fails. Fix the integration problems with minimal changes.",
50
50
  "Do not commit, create branches, or push.",
51
51
  "",
@@ -11,7 +11,7 @@ Analyze the customer request in `$ARGUMENTS` with the analyst who invoked this c
11
11
  - **Talk to the person in their system language.** Run `orqen lang` once at the start (`es` = Spanish, `en` = English; the stage context also has it as `language`) and use it for every message, question, and option. Keep commands, state names, and paths as they are. Files and texts posted on the tickets follow their own rules.
12
12
  - **Work with the person who invoked this command.** Before each important step, tell them what you are about to do and wait for their OK. When in doubt, ask them (with `AskUserQuestion` when available: concrete options plus your recommendation); never assume what you can ask. After each step, report what you did and what comes next.
13
13
  - Read the tickets read-only (an MCP for the ticket tool, or `orqen search`). orqen creates and links the issue and posts comments.
14
- - Leave Git operations, OpenSpec archiving, and writes to `orqen/state/` and `orqen/work/` to orqen.
14
+ - Leave Git operations, OpenSpec archiving, and writes to `orqen/state/` and `orqen/worqs/` to orqen.
15
15
  - Require the analyst's explicit approval of the analysis and lane. Record unknowns as open questions or labeled assumptions.
16
16
 
17
17
  ## Steps
@@ -30,6 +30,6 @@ Analyze the customer request in `$ARGUMENTS` with the analyst who invoked this c
30
30
  orqen complete <KEY> <output.json> --agent analyst
31
31
  ```
32
32
  Correct validation errors and retry until the command reports success.
33
- 7. Report the lane, the linked issue key (if any), `orqen/work/<KEY>/` record, and next stage. Stop after completing analysis.
33
+ 7. Report the lane, the linked issue key (if any), `orqen/worqs/<KEY>/` record, and next stage. Stop after completing analysis.
34
34
 
35
35
  If you cannot proceed, run `orqen block <KEY> "<specific reason>"`.
@@ -26,11 +26,11 @@ Help the senior who invoked this command decide on the integration PR of `$ARGUM
26
26
  2. Run `orqen pr <KEY>` (branch, base, lane, analysis, spec change, PR URL). Ask the senior whether they want a report before deciding (recommended when nobody reviewed the diff yet).
27
27
  3. **Report (optional).** If the senior wants it, review the PR read-only:
28
28
  - Run `git fetch origin` and review the remote branch, so the senior does not need to switch branches: `git log origin/<base>..origin/<branch> --oneline`, `git diff origin/<base>...origin/<branch> --stat`, and the diff of each relevant file. Use `gh pr view` and `gh pr diff` when available to confirm you are reviewing what the PR contains. If the local branch has unpushed changes, say that the review covers the PR only.
29
- - Review the diff against the analysis (summary, acceptance criteria, grilling decisions, and risks) and, for the light and full lanes, `proposal.md`, `design.md`, and the spec scenarios; for the direct lane, the plan. Check the PR explanation in `orqen/work/<KEY>/round-<N>/devel-pr.md` against the diff, and the repository conventions (`AGENTS.md`, `CLAUDE.md`, linters, neighboring code).
29
+ - Review the diff against the analysis (summary, acceptance criteria, grilling decisions, and risks) and, for the light and full lanes, `proposal.md`, `design.md`, and the spec scenarios; for the direct lane, the plan. Check the PR explanation in `orqen/worqs/<KEY>/round-<N>/devel-pr.md` against the diff, and the repository conventions (`AGENTS.md`, `CLAUDE.md`, linters, neighboring code).
30
30
  - Look for, in this order: **correctness** (missed scenarios or criteria, edge cases, swallowed errors, regressions); **security and data** (injection, missing permission checks or validation, secrets, migrations that cannot be rolled back); **scope** (changes outside the request, unexplained deviations); **tests** (scenarios without a test, tests that do not check the THEN, fragile tests; run `orqen env test` when you need it to back a claim); **maintainability**, only when the impact is real.
31
31
  - Verify each finding: re-read the code in context and describe the concrete failing scenario (input or state → wrong result). If you cannot build it, mark it `to verify` or drop it.
32
32
  - Give the senior the **verdict** in one line (`Approvable`, `Approvable with minor changes`, or `Reject`, with the reason), a short **summary** (what the PR does, whether it meets the request, test coverage), and the **findings**, most severe first: `#N` · severity (`blocking` · `important` · `minor` · `to verify`) · `file:line`; what happens; why it matters (the failing scenario or the criterion it breaks); one to three possible solutions with their trade-off, the recommended one first. If there are no findings, say so plainly.
33
- - Stay available while the senior digs into a finding, drops one, or asks for another area, and update the report. When they accept it, record it once (it does not change the stage; orqen saves it as `orqen/work/<KEY>/round-<N>/code-review-<n>.md` and comments it on the tickets):
33
+ - Stay available while the senior digs into a finding, drops one, or asks for another area, and update the report. When they accept it, record it once (it does not change the stage; orqen saves it as `orqen/worqs/<KEY>/round-<N>/code-review-<n>.md` and comments it on the tickets):
34
34
  ```sh
35
35
  orqen code-review <KEY> <report.md> --verdict <approve|minor|reject> --agent code-review
36
36
  ```
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Ask the requester a question on their ticket from any worq stage
3
+ argument-hint: <KEY> <question>
4
+ allowed-tools: Bash(orqen:*), AskUserQuestion
5
+ ---
6
+
7
+ Use the request or linked issue key and the question in `$ARGUMENTS`. If either is missing, ask the person for it. Preserve their wording. If you draft or revise the question, show the exact text and get their approval before posting.
8
+
9
+ Run `orqen ask <KEY> "<question>"` from the repository root. Pass the question as a single, safely quoted literal argument. Report which request received it. The requester replies with an ordinary comment on that ticket. Run `orqen conversation <KEY>` to read replies and refresh the worq's conversation.json.
10
+
11
+ If orqen answers with a warning that the worq is waiting for the client's answers (`WAITING_CLIENT`), tell the person: the requester's next comment, also a reply to this question, will count as that answer and send the worq back to analysis. `conversation.json` keeps the requester's replies, so it stays out of git: never add or commit it.
@@ -12,7 +12,7 @@ Implement the request identified by `$ARGUMENTS` from the repository root. It ca
12
12
  - **Work with the person who invoked this command.** Before each important step, tell them what you are about to do and wait for their OK. When in doubt, ask them (with `AskUserQuestion` when available: concrete options plus your recommendation); never assume what you can ask. After each step, report what you did and what comes next.
13
13
  - **Use `orqen swarm` internally for implementation.** Do not ask the person to run it, announce the engine, or request a separate approval for choosing it. Discuss the scope, plan, decisions and results in normal terms. Capture its JSON output instead of forwarding worker logs. Never silently replace a failed run with manual implementation.
14
14
  - Read the tickets read-only. orqen posts comments and moves the tickets.
15
- - Leave Git operations, branch changes, OpenSpec archiving, and writes to `orqen/state/`, `orqen/work/`, and orqen configuration to orqen.
15
+ - Leave Git operations, branch changes, OpenSpec archiving, and writes to `orqen/state/`, `orqen/worqs/`, and orqen configuration to orqen.
16
16
  - Follow the approved scope, specifications or plan, and acceptance criteria. Ask the user or block the request if you need a decision to proceed.
17
17
  - **Testing is your job, not the person's.** When development closes, the request moves to `TESTING`: run that stage yourself right away (step 6), without asking for an OK at each step, and report the result. The human review of the e2e is QA's, later, in `QA_REVIEW` (full lane).
18
18
  - Stop once `TESTING` advances the request, or when it sends the request back to development and the person decides how to continue.
@@ -19,7 +19,7 @@ Run the QA review of `$ARGUMENTS` with the QA person who invoked this command. O
19
19
 
20
20
  1. Validate the key (request or issue) and run `orqen status <KEY>`. Continue only for a request in `QA_REVIEW`. If it is in another state, report it and stop: the direct and light lanes skip QA, and a full-lane request reaches QA after `TESTING`. Record the branch, lane, change, and round.
21
21
  2. Check that the current branch matches the request branch. If it differs, ask QA to switch and stop. Report pending changes unrelated to the end-to-end tests.
22
- 3. List the OpenSpec scenarios of the change and read the `TESTING` result in the work record (`orqen/work/<KEY>/`).
22
+ 3. List the OpenSpec scenarios of the change and read the `TESTING` result in the work record (`orqen/worqs/<KEY>/`).
23
23
  4. Detect the project's test runner and find the end-to-end tests this change added or modified. Match each scenario to a test by file and name, and check its assertions against the expected behavior (the THEN).
24
24
  5. Start the project with `orqen env up --all` (it starts every process in `orqen/environment.yaml`, including the frontend, waits until they respond, and runs migrations and seed; `orqen env status` shows each log). Do not ask QA to start anything by hand. Run the end-to-end tests of the change with `orqen env test e2e -- <files or filter>`, in the runner's headed mode, with traces, screenshots, or video, and record the commands and artifact paths.
25
25
  6. Give QA a table of scenarios, tests, commands, and expected screen behavior. Flag scenarios without a test, missing assertions, fragile selectors, fixed waits, and order-dependent tests. Ask QA to make any corrections directly on the branch.
@@ -28,5 +28,5 @@ Run the QA review of `$ARGUMENTS` with the QA person who invoked this command. O
28
28
  - Approve (only with a passing run): `orqen review <KEY> approve --report <report.md> --person "<QA name>" --agent qa`. The request moves to `CODE_REVIEW`, where the senior reviews the PR.
29
29
  - Request changes: `orqen review <KEY> reject --reason "<what development must fix>" --report <report.md> --person "<QA name>" --agent qa`. The request returns to `DEVELOPMENT` with the reason as feedback.
30
30
 
31
- orqen saves the report as `orqen/work/<KEY>/round-<N>/qa-review-<n>.md` and comments the decision on the request and on its issue (when there is one). QA can also decide by commenting `/approve` or `/reject <reason>` on the request (limited to `workflow.approvers.qa` in `orqen/config.yaml`).
31
+ orqen saves the report as `orqen/worqs/<KEY>/round-<N>/qa-review-<n>.md` and comments the decision on the request and on its issue (when there is one). QA can also decide by commenting `/approve` or `/reject <reason>` on the request (limited to `workflow.approvers.qa` in `orqen/config.yaml`).
32
32
  9. Stop the processes with `orqen env down` if they are still running and report the next step: approved → the senior, with `/orqen:approve <KEY>`; changes requested → development, with `/orqen:implement <KEY>`.
@@ -11,7 +11,7 @@ Handle the customer request in `$ARGUMENTS` with the support person who invoked
11
11
  - **Talk to the person in their system language.** Run `orqen lang` once at the start (`es` = Spanish, `en` = English; the stage context also has it as `language`) and use it for every message, question, and option. Keep commands, state names, and paths as they are. Files and texts posted on the tickets follow their own rules.
12
12
  - **Work with the person who invoked this command.** Before each important step, tell them what you are about to do and wait for their OK. When in doubt, ask them (with `AskUserQuestion` when available: concrete options plus your recommendation); never assume what you can ask. After each step, report what you did and what comes next.
13
13
  - Read-only on code and tickets (an MCP for the ticket tool, or `orqen search`). orqen posts the comment on the request. Do not edit code, tests, specs, or configuration.
14
- - Leave Git operations and writes to `orqen/state/` and `orqen/work/` to orqen.
14
+ - Leave Git operations and writes to `orqen/state/` and `orqen/worqs/` to orqen.
15
15
  - Never promise dates, scope, or changes to the customer. Require the person's explicit approval of the outcome and of the exact text that reaches the customer.
16
16
 
17
17
  ## Steps
@@ -21,7 +21,7 @@ The analyst makes the decisions. Ask questions that uncover ambiguities affectin
21
21
  - Data, migrations, integrations, performance, auditing, and security.
22
22
  - Whether an operational change can resolve the issue, plus risks and rollback.
23
23
  5. Record up to five design-blocking questions only the customer can answer. Do not invent answers.
24
- 6. Record decisions as question-and-answer pairs in `decisions` for `orqen/work/<KEY>/`.
24
+ 6. Record decisions as question-and-answer pairs in `decisions` for `orqen/worqs/<KEY>/`.
25
25
  7. Summarize the scope, exclusions, risks, assumptions, and Given/When/Then acceptance criteria. Ask for explicit approval before proposing a lane or creating the issue.
26
26
 
27
27
  Use clear, direct English and closed questions where possible. If the analyst delegates a decision, record the recommended answer as an assumption. Resolve open design decisions before proposing the lane.
@@ -10,6 +10,10 @@ A **request** is the client's ticket in the requests system; its **issue** is th
10
10
  issues system when the analysis closes (optional). Each system can be any supported tool (Jira, GitHub, or Asana, set in
11
11
  `connectors` in `orqen/config.yaml`). Commands accept either key.
12
12
 
13
+ A **worq** is orqen's unit of work: everything orqen carries for one request (the request, its issue, the branch, the spec, the PR and the
14
+ record of every stage). It is identified by the request key and lives in `orqen/worqs/<KEY>/`. `orqen worqs` lists the worqs on this machine and
15
+ `orqen worq <KEY>` shows one.
16
+
13
17
  The 9 steps, one command each (the person runs it; you follow it):
14
18
 
15
19
  | # | Role | Command | What it does |
@@ -26,6 +30,8 @@ The 9 steps, one command each (the person runs it; you follow it):
26
30
 
27
31
  ### Working with the person
28
32
 
33
+ In any stage, use `/orqen:ask <KEY> <question>` to ask the requester directly on the original request. The requester can reply with an ordinary comment. To read the replies and refresh `orqen/worqs/<KEY>/conversation.json`, run `orqen conversation <KEY>`. Both commands accept the request key or its linked issue key and preserve the current stage.
34
+
29
35
  orqen works alongside the person; it does not replace them. While someone is on the other side (they invoked
30
36
  `/orqen:support`, `/orqen:analyze`, `/orqen:implement`, `/orqen:pr`, `/orqen:review`, `/orqen:approve`, a review command, or asked you directly; `human_present: true` in the context):
31
37
 
@@ -70,7 +76,7 @@ The analyst can still take a `NEW` request directly with `orqen analyze`, and ca
70
76
  | `full` | Broader changes involving architecture, data, integrations, security, or billing | Full OpenSpec proposal, specs, design, and tasks |
71
77
 
72
78
  With `light` or `full`, `orqen lane <KEY> <lane>` prepares a branch and change. Write the spec with the analyst under `openspec/changes/`.
73
- 4. Run `orqen complete <KEY> <output.json>`. Once validation passes, orqen creates the issue (when `connectors.issues` is configured), links it to the request, and writes the record under `orqen/work/<KEY>/`. The request is the conversation with the customer; the issue tracks implementation (`connectors.issues.transitions`). Rejected customer acceptance starts a new analysis round and a new issue.
79
+ 4. Run `orqen complete <KEY> <output.json>`. Once validation passes, orqen creates the issue (when `connectors.issues` is configured), links it to the request, and writes the record under `orqen/worqs/<KEY>/`. The request is the conversation with the customer; the issue tracks implementation (`connectors.issues.transitions`). Rejected customer acceptance starts a new analysis round and a new issue.
74
80
 
75
81
  ### Operational work
76
82
 
@@ -88,11 +94,11 @@ Propose the steps, rollback, and read-only verification. A person authorized by
88
94
  - `orqen take <KEY>` claims an agent stage and prints its instructions, request context, feedback, and JSON output schema. Use `orqen support` for support and `orqen analyze` for analysis.
89
95
  - Run `orqen complete <KEY> <output.json>` when the output is ready. Correct validation errors and retry until the command reports success. Stop after completing the stage.
90
96
  - If you cannot proceed, run `orqen block <KEY> "<specific reason>"`. Human reviewers use `/approve` or `/reject <reason>` on the ticket.
91
- - orqen writes `state.json`, `log.md`, and `round-N/analysis.md` and `.json` under `orqen/work/<KEY>/`. Operational rounds also record execution details under `execution/`. The authoritative workflow state is stored under `orqen/state/` or `cli/.state/`, depending on how the project is configured.
97
+ - orqen writes `state.json`, `log.md`, and `round-N/analysis.md` and `.json` under `orqen/worqs/<KEY>/`. Operational rounds also record execution details under `execution/`. The authoritative workflow state is stored under `orqen/state/` or `cli/.state/`, depending on how the project is configured.
92
98
 
93
99
  ### Implementation execution
94
100
 
95
- `/orqen:implement <KEY>` runs `orqen swarm --file <task> --yes --json --apply` internally after the person approves the implementation plan. Supply the approved analysis, scope, criteria, spec or direct plan, and feedback as task context. ORQEN integrates a verified result into the request branch. Do not ask the person to run the engine or show its worker logs; report scope, progress, decisions and results. A failed run or integration must not advance the stage. Keep the existing approval before `orqen complete`.
101
+ `/orqen:implement <KEY>` runs `orqen swarm --file <task> --yes --json --apply` internally after the person approves the implementation plan. Supply the approved analysis, scope, criteria, spec or direct plan, and feedback as task context. orqen integrates a verified result into the request branch. Do not ask the person to run the engine or show its worker logs; report scope, progress, decisions and results. A failed run or integration must not advance the stage. Keep the existing approval before `orqen complete`.
96
102
 
97
103
  ### Integration PR, QA, and code review
98
104
 
@@ -110,7 +116,7 @@ Propose the steps, rollback, and read-only verification. A person authorized by
110
116
  ### Rules
111
117
 
112
118
  - Read the tickets read-only. orqen handles ticket writes, Git commits, branch changes, pushes, and OpenSpec archiving. Do not run `git commit/push/checkout/reset/rebase` or `openspec archive`.
113
- - Do not edit `orqen/state/`, `orqen/work/`, or orqen configuration as part of a request.
119
+ - Do not edit `orqen/state/`, `orqen/worqs/`, or orqen configuration as part of a request.
114
120
  - Obtain explicit analyst approval before closing analysis, including approval of the selected lane.
115
121
  - Record unanswered questions and label assumptions. Read `openspec/specs/` for current behavior before proposing changes.
116
122
  - Write in clear, professional English (this is for artifacts; talk to the person in their system language). Follow OpenSpec's structural headings and use SHALL/MUST where required.
@@ -0,0 +1,9 @@
1
+ # orqen/worqs
2
+
3
+ A **worq** is orqen's unit of work: what orqen carries for each request of the client (the request, its linked issue, the branch, the spec,
4
+ the PR and the record of every stage). It is identified by the key of the request and lives in a folder named after it, such as `SOP-1234/`.
5
+
6
+ The folder includes `state.json` (a snapshot of the whole worq, which orqen uses to recover it on another machine), `log.md`, and the
7
+ output of each stage by round (`round-1/analysis.md`, `support.md`, `devel-pr.md`, the reviews…). orqen writes it and commits it with the request branch.
8
+
9
+ `orqen worqs` lists the worqs on this machine and `orqen worq <KEY>` shows one.
@@ -38,4 +38,4 @@ When unsure, recommend the more rigorous lane and explain why. Once the analyst
38
38
  - Set `ready: true` and `analyst_ok: true` and provide `route`, `lane`, and `lane_rationale` once confirmed. For operational work, use `lane: "direct"`.
39
39
  - For direct development, include the ordered `plan` and `estimated_hours`. For a spec change, include `spec` with its assigned `change`, `summary`, and `assumptions`.
40
40
 
41
- `orqen complete` validates the JSON and any spec and task estimates, then creates and links the issue (if configured), records the analysis in `orqen/work/<KEY>/`, and advances the request. Leave `orqen/state/` and Git operations to orqen.
41
+ `orqen complete` validates the JSON and any spec and task estimates, then creates and links the issue (if configured), records the analysis in `orqen/worqs/<KEY>/`, and advances the request. Leave `orqen/state/` and Git operations to orqen.
@@ -2,7 +2,7 @@
2
2
 
3
3
  > If `human_present` is `true`, tell the person what you are about to do, wait for their OK at each important step, and ask them about any doubt (see "Working with the person" in AGENTS.md). If it is `false`, run `orqen block` for any doubt that changes the outcome.
4
4
 
5
- For the lightweight and full lanes, orqen has archived the change and merged its deltas into `openspec/specs/`. The context identifies the archived change in `openspec.dir`. For the direct lane, refer to `orqen/work/<KEY>/` and `previous_stages.ANALYSIS`.
5
+ For the lightweight and full lanes, orqen has archived the change and merged its deltas into `openspec/specs/`. The context identifies the archived change in `openspec.dir`. For the direct lane, refer to `orqen/worqs/<KEY>/` and `previous_stages.ANALYSIS`.
6
6
 
7
7
  1. Read the development summary in `previous_stages` and any archived proposal, specs, and tasks.
8
8
  2. In `release_notes`, give the team technical release notes covering changes, migrations, flags, and risks.
@@ -4,11 +4,11 @@
4
4
 
5
5
  The analysis is approved. The context includes the branch (`branch`), lane (`lane`), linked issue (`issue`), and tasks (`tasks`).
6
6
 
7
- 1. Read `previous_stages.ANALYSIS` and consult `orqen/work/<KEY>/` for details.
7
+ 1. Read `previous_stages.ANALYSIS` and consult `orqen/worqs/<KEY>/` for details.
8
8
  2. For `light` or `full`, follow OpenSpec's apply workflow using `openspec-apply-change`, `/opsx:apply`, or `openspec instructions apply --change <change> --json`. Read the proposal, design, specs, and tasks, and check off each completed task in `tasks.md`. `orqen complete` rejects incomplete tasks.
9
9
  3. For `direct`, implement the analysis `plan` in order. Follow the repository conventions and its `AGENTS.md` and `CLAUDE.md`.
10
10
  4. Write **unit tests** for the code you change, and **end-to-end tests for the Scenarios or acceptance criteria this change adds or modifies**. Each criterion or Scenario needs a test that checks its THEN. Name tests so their coverage is recognizable.
11
11
  5. `orqen take` prepared the environment. Read `environment.variables` for connection details and `environment.commands` for test commands. If `environment.ok` is false, read `environment.detail` and `environment.output`. Fix code issues or block the request if infrastructure prevents progress.
12
12
  6. Address failed `test_result`, feedback in `previous_stages.TESTING`, or a rejection in `human_feedback` first. Before completing the stage, run **only the tests for this change**: `orqen env test unit` and the e2e you wrote or modified with `orqen env test e2e -- <files or filter>` (start the apps first with `orqen env up --all`), plus the project linters. Do not run the full e2e regression: `TESTING` runs every test type.
13
- 7. Leave Git operations, OpenSpec archiving, and writes to `orqen/state/` and `orqen/work/` to orqen. It shuts down the development environment when the stage completes.
13
+ 7. Leave Git operations, OpenSpec archiving, and writes to `orqen/state/` and `orqen/worqs/` to orqen. It shuts down the development environment when the stage completes.
14
14
  8. If an issue prevents progress, such as missing access or contradictory requirements, return `completed: false` with `blocker`.
@@ -31,4 +31,4 @@ A person from support leads this stage (first line). The goal is to answer the c
31
31
 
32
32
  Show the person the outcome and the exact text that will reach the customer, and ask for their explicit approval. Only then set `support_ok: true`. Include `summary`, `checked`, `outcome`, `client_response`, and `escalation_summary` as required by the JSON schema.
33
33
 
34
- `orqen complete` validates the JSON, comments on the request, records `support.md` under `orqen/work/<KEY>/`, and advances it: `resolved` waits for the customer's `/approve` or `/reject <reason>`, and `escalate` moves to the analyst. A resolved request creates no issue. Leave `orqen/state/` and Git operations to orqen.
34
+ `orqen complete` validates the JSON, comments on the request, records `support.md` under `orqen/worqs/<KEY>/`, and advances it: `resolved` waits for the customer's `/approve` or `/reject <reason>`, and `escalate` moves to the analyst. A resolved request creates no issue. Leave `orqen/state/` and Git operations to orqen.
@@ -205,7 +205,7 @@ export function pasosTutorial(d, i) {
205
205
  tx("git diff # los cambios, línea por línea", "git diff # the changes, line by line"),
206
206
  ] },
207
207
  { t: "ul", items: [
208
- tx(`El historial del pedido también queda en el archivo orqen/work/${recNum}/log.md.`, `The request history is also in the file orqen/work/${recNum}/log.md.`),
208
+ tx(`El historial del pedido también queda en el archivo orqen/worqs/${recNum}/log.md (el worq: la unidad de trabajo de orqen).`, `The request history is also in the file orqen/worqs/${recNum}/log.md (the worq: orqen's unit of work).`),
209
209
  tx("Si el carril es light o full, en openspec/changes/<nombre>/tasks.md ves qué tareas ya tildó.", "With the light or full lane, openspec/changes/<name>/tasks.md shows which tasks it has checked off."),
210
210
  tx("En modo automático (orqen cycle --loop), lo que hace el agente se ve en la terminal donde corre ese comando.", "In automatic mode (orqen cycle --loop), what the agent does shows up in the terminal where that command runs."),
211
211
  ] },
package/dist/ui/logo.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ORQEN terminal logo and animated welcome screen.
2
+ * orqen terminal logo and animated welcome screen.
3
3
  *
4
4
  * Draw the hexagon and wordmark on a pixel canvas using two pixels per
5
5
  * terminal cell, with foreground and background colors on the upper half block (▀).
@@ -56,7 +56,7 @@ const ANCHO_PALABRA = PASO * 4 + LETRA_W; // 58
56
56
  const Y_SUBRAYADO = 19; // px
57
57
  const FILA_SUBTITULO = 10;
58
58
  const COL_SUBTITULO = X0 + Math.floor((ANCHO_PALABRA - SUBTITULO.length) / 2);
59
- /** Pixel font for ORQEN (10 × 12 with a 3-pixel stroke). */
59
+ /** Pixel font for orqen (10 × 12 with a 3-pixel stroke). */
60
60
  const FUENTE = [
61
61
  ["..######..", ".########.", "##########", "###....###", "###....###", "###....###", "###....###", "###....###", "###....###", "##########", ".########.", "..######.."],
62
62
  ["########..", "#########.", "##########", "###....###", "###....###", "#########.", "########..", "###.###...", "###..###..", "###...###.", "###....###", "###....###"],
@@ -231,7 +231,7 @@ function pixeles(t) {
231
231
  }
232
232
  }
233
233
  dibujarSatelites(true);
234
- // ── Waves light the ORQEN letters with a chromatic shift ──
234
+ // ── Waves light the orqen letters with a chromatic shift ──
235
235
  for (let py = Y0 - 4; py < Y0 + LETRA_H + 4; py++)
236
236
  for (let px = X0 - 6; px < X0 + ANCHO_PALABRA + 6; px++) {
237
237
  if (px < 0 || px >= W || py < 0 || py >= H)
@@ -412,7 +412,7 @@ function logoCompacto(color, columnas) {
412
412
  const filas = LETRAS.map((l, i) => ` ${color ? pintar(i === LETRAS.length - 1 ? GRIS : mezclar(AZUL, MAGENTA, i / LETRAS.length), l) + RESET : l}`);
413
413
  return ["", ...filas, ""].join("\n");
414
414
  }
415
- return color ? `\n \x1b[1m${pintar(AZUL, "OR")}${pintar(mezclar(AZUL, MAGENTA, 0.5), "Q")}${pintar(MAGENTA, "EN")}${RESET} ${pintar(GRIS, LEMA)}${RESET}\n` : `\n ORQEN ${LEMA}\n`;
415
+ return color ? `\n \x1b[1m${pintar(AZUL, "OR")}${pintar(mezclar(AZUL, MAGENTA, 0.5), "Q")}${pintar(MAGENTA, "EN")}${RESET} ${pintar(GRIS, LEMA)}${RESET}\n` : `\n orqen ${LEMA}\n`;
416
416
  }
417
417
  /**
418
418
  * Render the frame at time t as rows of one-based column positions and text.
@@ -49,6 +49,8 @@ export function loadConfig(over = {}) {
49
49
  const localOpenSpec = join(repoPath, "node_modules", ".bin", process.platform === "win32" ? "openspec.cmd" : "openspec");
50
50
  const localState = join(main, "cli", ".state");
51
51
  const baseBranch = env("BASE_BRANCH", project?.proyecto.rama_base ?? "main");
52
+ // WORQS_DIR (or FACTORY_DIR, its old name) wins; then orqen/worqs/; a repository that only has orqen/work/ keeps using it
53
+ const worqsDir = worqsDirOf(repoPath, env("WORQS_DIR") || env("FACTORY_DIR"));
52
54
  const credentials = providerEnv(existsSync(join(repoPath, "orqen", ".env")) ? repoPath : main);
53
55
  // orqen/config.yaml (workflow) is the shared configuration; a variable in orqen/.env or the environment overrides it
54
56
  const f = project?.flujo;
@@ -65,7 +67,8 @@ export function loadConfig(over = {}) {
65
67
  client: list("APPROVERS_CLIENT", f?.aprobadores.cliente),
66
68
  execution: list("APPROVERS_EXECUTION", f?.aprobadores.ejecucion),
67
69
  },
68
- factoryDir: env("FACTORY_DIR") || join(repoPath, "orqen", "work"),
70
+ factoryDir: worqsDir.dir,
71
+ ...(worqsDir.legacy ? { legacyWorkDir: true } : {}),
69
72
  repoPath,
70
73
  baseBranch,
71
74
  testCommand: env("TEST_COMMAND") || f?.comando_tests || "npm test",
@@ -85,9 +88,22 @@ export function loadConfig(over = {}) {
85
88
  ...over,
86
89
  };
87
90
  }
91
+ /** Folder of the worqs: the explicit one, orqen/worqs/, or (earlier versions) orqen/work/ when only that exists. */
92
+ export function worqsDirOf(repoPath, explicit = "") {
93
+ if (explicit)
94
+ return { dir: explicit, legacy: false };
95
+ const dir = join(repoPath, "orqen", "worqs"), old = join(repoPath, "orqen", "work");
96
+ return !existsSync(dir) && existsSync(old) ? { dir: old, legacy: true } : { dir, legacy: false };
97
+ }
98
+ let warnedWork = false;
88
99
  let warned = false;
89
- /** Warns once when orqen/.env still uses the variables of earlier versions. */
100
+ /** Warns once when orqen/.env still uses the variables of earlier versions, or the worqs are still in orqen/work/. */
90
101
  export function warnLegacy(cfg) {
102
+ if (cfg.legacyWorkDir && !warnedWork) {
103
+ warnedWork = true;
104
+ console.error("[orqen] The worqs are now in orqen/worqs/ and this repository still has them in orqen/work/. It keeps working; " +
105
+ "run `orqen update` to move them.");
106
+ }
91
107
  const used = cfg.connectors.legacy ?? [];
92
108
  if (warned || !used.length)
93
109
  return;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Process record inside the repo: orqen/work/<KEY>/
2
+ * The worq of a request (orqen's unit of work) inside the repo: orqen/worqs/<KEY>/
3
3
  *
4
4
  * state.json snapshot of the whole request at its last transition: what orqen recovers from when another
5
5
  * machine (or a deleted orqen/state) has no record of it
@@ -23,12 +23,17 @@ export class Factory {
23
23
  }
24
24
  dirOf = (key) => join(this.dir, key);
25
25
  roundDir = (key, round) => join(this.dir, key, `round-${round}`);
26
+ conversation(key, comments) {
27
+ const dir = this.dirOf(key);
28
+ mkdirSync(dir, { recursive: true });
29
+ writeFileSync(join(dir, "conversation.json"), JSON.stringify({ request: key, comments }, null, 2) + "\n");
30
+ }
26
31
  safe(fn) {
27
32
  try {
28
33
  fn();
29
34
  }
30
35
  catch (e) {
31
- console.error(`[orqen] warning: could not write to orqen/work/: ${e.message}`);
36
+ console.error(`[orqen] warning: could not write to the worqs folder: ${e.message}`);
32
37
  }
33
38
  }
34
39
  /** Writes `round-N/<file>` (creates the directories). */
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * The request is what the client sees (requests system); the issue (optional) is the team's (issues system). Both are reached through connectors/.
12
12
  */
13
- import { join } from "node:path";
13
+ import { join, relative } from "node:path";
14
14
  import { detectarIdioma } from "../lib/lang.js";
15
15
  import { SCHEMAS } from "./schemas.js";
16
16
  import { LANES, State, GATES, isAgentState, isFinal, isGate, nextStateAfterStage, } from "./states.js";
@@ -47,7 +47,7 @@ export class Process {
47
47
  // ================================================================ the record of a request on this machine
48
48
  /**
49
49
  * The request as this machine knows it. The source of truth is orqen/state (ignored by git, one per machine); when it has no
50
- * record, the full snapshot that orqen commits with the request branch (orqen/work/<KEY>/state.json) is used and saved here.
50
+ * record, the full snapshot that orqen commits with the request branch (orqen/worqs/<KEY>/state.json) is used and saved here.
51
51
  * The snapshot is read from the working tree or from a local or fetched branch: `git fetch origin orqen/<key>` is enough.
52
52
  */
53
53
  item(key) {
@@ -98,10 +98,56 @@ export class Process {
98
98
  this.fromLabels.set(key, item);
99
99
  return item;
100
100
  }
101
+ /** The worq of a request, as `orqen worq` and `orqen worqs` show it: orqen's unit of work (request + issue + branch + PR + record). */
102
+ worq(item) {
103
+ const b = this.boardItem(item);
104
+ return {
105
+ key: item.key, title: item.title ?? item.artifacts.ANALYSIS?.summary?.slice(0, 90), issue: item.issue,
106
+ state: item.state, role: b.role, lane: item.lane, route: item.route, round: item.round, branch: item.branch || undefined,
107
+ pr: item.artifacts.devel_pr, merged: item.artifacts.devel_pr_merged ? true : undefined,
108
+ analyst: item.analyst, supporter: item.supporter, request_url: this.requests.url(item.key),
109
+ issue_url: item.issue && this.issues ? this.issues.url(item.issue) : undefined,
110
+ dir: this.worqRel(item.key), updated: this.store.events(item.key).at(-1)?.ts, next: b.next,
111
+ };
112
+ }
113
+ /** Folder of a worq inside the repository, as written in tickets and messages (orqen/worqs/<KEY>); the default when the folder is elsewhere. */
114
+ worqRel(key) {
115
+ const rel = relative(this.cfg.repoPath, join(this.cfg.factoryDir, key)).replaceAll("\\", "/");
116
+ return rel.startsWith("..") || /^[a-zA-Z]:/.test(rel) ? `orqen/worqs/${key}` : rel;
117
+ }
101
118
  fetchHint(key) {
102
- return `If someone worked on it elsewhere, fetch its branch (git fetch origin ${branchFor(key)}) so orqen can recover it from orqen/work/${key}/state.json.`;
119
+ return `If someone worked on it elsewhere, fetch its branch (git fetch origin ${branchFor(key)}) so orqen can recover its worq from ${this.worqRel(key)}/state.json.`;
103
120
  }
104
121
  unknownMsg(key) { return `${key} is unknown to orqen on this machine. ${this.fetchHint(key)}`; }
122
+ async conversation(key) {
123
+ if (!this.item(key))
124
+ throw new Error(this.unknownMsg(key));
125
+ const comments = await this.requests.comments(key);
126
+ this.fac.conversation(key, comments);
127
+ return comments;
128
+ }
129
+ /**
130
+ * Asks the requester on their ticket, from any stage, without moving the worq. Returns a warning when a reply will move it anyway:
131
+ * in WAITING_CLIENT (the analysis is waiting for the client) any comment of the client counts as their answer.
132
+ */
133
+ async ask(key, question) {
134
+ if (!question.trim())
135
+ throw new Error("A question for the requester is required.");
136
+ const item = this.item(key);
137
+ if (!item)
138
+ throw new Error(this.unknownMsg(key));
139
+ const ticket = await this.requests.ticket(key);
140
+ await this.requests.comment(key, `Question for ${ticket.reportedBy || "the requester"}:\n\n${question.trim()}`);
141
+ try {
142
+ await this.conversation(key);
143
+ }
144
+ catch (e) {
145
+ throw new Error(`Question posted to ${key}. Run orqen conversation ${key} to refresh the local copy: ${e.message}`);
146
+ }
147
+ return item.state === "WAITING_CLIENT"
148
+ ? { warning: `${key} is waiting for the client's answers: their next comment, also a reply to this question, will count as that answer and send it back to ANALYSIS.` }
149
+ : {};
150
+ }
105
151
  // ================================================================ review
106
152
  async review() {
107
153
  const pending = [];
@@ -379,7 +425,7 @@ export class Process {
379
425
  human_present: agent !== "cycle",
380
426
  // The person's language, from the operating system: talk to them in it (artifacts keep their own rules).
381
427
  language: detectarIdioma(),
382
- supporter: item.supporter, analyst: item.analyst, lane: item.lane, factory: `orqen/work/${key}/round-${item.round}`,
428
+ supporter: item.supporter, analyst: item.analyst, lane: item.lane, worq: `${this.worqRel(key)}/round-${item.round}`, factory: `${this.worqRel(key)}/round-${item.round}`, // factory: old name of worq
383
429
  request: ticket, issue: item.issue, comments, environment,
384
430
  openspec,
385
431
  ...(["DEVELOPMENT", "TESTING"].includes(state) ? { tasks: this.tasksOf(item) } : {}),
@@ -402,7 +448,7 @@ export class Process {
402
448
  throw new Error(`${key} is in ${item.state}: the PR to ${this.cfg.develBranch} is opened once development is done (TESTING or later).`);
403
449
  return {
404
450
  key, state: item.state, branch: item.branch, base: this.cfg.develBranch, lane: item.lane, issue: item.issue,
405
- analysis: `orqen/work/${key}/round-${item.round}/analysis.md`,
451
+ analysis: `${this.worqRel(key)}/round-${item.round}/analysis.md`,
406
452
  change: item.change ? `openspec/changes/${item.change}` : undefined,
407
453
  existing: item.artifacts.devel_pr,
408
454
  };
@@ -420,7 +466,7 @@ export class Process {
420
466
  const current = this.ws.currentBranch();
421
467
  if (current !== item.branch)
422
468
  throw new Error(`The repo is on "${current}", not on the request branch "${item.branch}": switch to it (git checkout ${item.branch}) and run again.`);
423
- const bodyFile = `orqen/work/${key}/round-${item.round}/devel-pr.md`;
469
+ const bodyFile = `${this.worqRel(key)}/round-${item.round}/devel-pr.md`;
424
470
  this.fac.write(item, "devel-pr.md", body.trim() + "\n");
425
471
  this.ws.commit(key, `PR explanation for ${info.base}`, { branch: item.branch });
426
472
  this.ws.push(item.branch);
@@ -462,7 +508,7 @@ export class Process {
462
508
  const reviews = (item.artifacts.code_reviews ??= []);
463
509
  const n = reviews.filter((r) => r.round === item.round).length + 1;
464
510
  const file = `code-review-${n}.md`;
465
- const path = `orqen/work/${key}/round-${item.round}/${file}`;
511
+ const path = `${this.worqRel(key)}/round-${item.round}/${file}`;
466
512
  this.fac.write(item, file, body.trim() + "\n");
467
513
  reviews.push({ round: item.round, n, verdict, file: path, ts: new Date().toISOString() });
468
514
  this.store.save(item);
@@ -503,7 +549,7 @@ export class Process {
503
549
  const n = reviews.filter((r) => r.round === item.round).length + 1;
504
550
  let path;
505
551
  if (report.trim()) {
506
- path = `orqen/work/${key}/round-${item.round}/qa-review-${n}.md`;
552
+ path = `${this.worqRel(key)}/round-${item.round}/qa-review-${n}.md`;
507
553
  this.fac.write(item, `qa-review-${n}.md`, report.trim() + "\n");
508
554
  }
509
555
  reviews.push({ round: item.round, n, decision, by, file: path, ts: new Date().toISOString() });
@@ -637,7 +683,7 @@ export class Process {
637
683
  .map((c) => ({ capability: "-", requirement: "Acceptance criterion", scenario: c }));
638
684
  }
639
685
  // ================================================================ analysis closing
640
- /** With the analyst's OK: estimate, record in orqen/work/, spec commit (if any) and issue linked to the request. */
686
+ /** With the analyst's OK: estimate, record in orqen/worqs/, spec commit (if any) and issue linked to the request. */
641
687
  async closeAnalysis(item, s) {
642
688
  item.artifacts.estimated_hours = item.change
643
689
  ? this.os.tasks(item.change).reduce((a, t) => a + (t.hours ?? 0), 0)
@@ -911,7 +957,7 @@ export class Process {
911
957
  `*Acceptance criteria:*\n${bullets(a.acceptance_criteria ?? [])}\n\nThe execution stage prepares the script, rollback, and verification and posts them on the request.`
912
958
  : `Development for request ${item.key}. *Lane:* ${a.lane} — ${a.lane_rationale}\n${this.requests.url(item.key)}\n\n` +
913
959
  `*Summary:* ${item.artifacts.ANALYSIS?.spec?.summary ?? a.summary}\n\n` +
914
- `*Branch:* ${item.branch || branchFor(item.key)}\n` + (item.change ? `*OpenSpec change:* openspec/changes/${item.change}/\n` : `*Direct-lane analysis:* orqen/work/${item.key}/round-${item.round}/analysis.md\n`) +
960
+ `*Branch:* ${item.branch || branchFor(item.key)}\n` + (item.change ? `*OpenSpec change:* openspec/changes/${item.change}/\n` : `*Direct-lane analysis:* ${this.worqRel(item.key)}/round-${item.round}/analysis.md\n`) +
915
961
  `*Estimate:* ${item.artifacts.estimated_hours ?? "?"} h\n\n` +
916
962
  `*${item.change ? "Tasks" : "Plan"}:*\n${bullets(tasks.map((t) => t.description))}\n\n` +
917
963
  `*${item.change ? "Acceptance scenarios" : "Acceptance criteria"}:*\n${bullets(sc.map((e) => item.change ? `${e.requirement} › ${e.scenario}` : e.scenario))}`,
@@ -924,7 +970,7 @@ export class Process {
924
970
  await this.issues.link(item.issue, item.key);
925
971
  const where = native ? item.issue : `${item.issue} (${this.issues.url(item.issue)})`;
926
972
  await this.requests.comment(item.key, `Analysis complete${item.analyst ? ` with ${item.analyst}` : ""}. Track implementation in ${where} (${lane} lane). Milestones will also be posted on this request.`);
927
- await this.issues.comment(item.issue, `Created from ${item.key}${native ? "" : ` (${this.requests.url(item.key)})`} after analysis. Request record: orqen/work/${item.key}/.`);
973
+ await this.issues.comment(item.issue, `Created from ${item.key}${native ? "" : ` (${this.requests.url(item.key)})`} after analysis. Worq: ${this.worqRel(item.key)}/`);
928
974
  item.artifacts.issue_linked = true;
929
975
  this.store.save(item);
930
976
  }
@@ -1089,7 +1135,7 @@ export class Process {
1089
1135
  this.store.log(item.key, { ts: new Date().toISOString(), from, to, detail, agent });
1090
1136
  this.fac.record(item, from, to, detail, agent);
1091
1137
  if (item.branch)
1092
- this.attempt(() => this.ws.commit(item.key, `registro ${from} → ${to}`, { path: this.cfg.factoryDir, branch: item.branch }));
1138
+ this.attempt(() => this.ws.commit(item.key, `registro ${from} → ${to}`, { path: join(this.cfg.factoryDir, item.key), branch: item.branch }));
1093
1139
  try {
1094
1140
  await this.requests.setStateLabel(item.key, to);
1095
1141
  // CANCELLED falls back to the CLOSED destination when the connector has no own "CANCELLED" transition
@@ -80,7 +80,7 @@ export class GitWorkspace {
80
80
  return false;
81
81
  }
82
82
  }
83
- /** Pathspec that excludes orqen/work/ (the process record must not prevent switching branches). */
83
+ /** Pathspec that excludes orqen/worqs/ (the process record must not prevent switching branches). */
84
84
  excludeFactory() {
85
85
  const r = relative(this.cfg.repoPath, this.cfg.factoryDir).replaceAll("\\", "/");
86
86
  return r && !r.startsWith("..") ? ["--", ".", `:(exclude)${r}`] : [];
@@ -95,7 +95,8 @@ export class GitWorkspace {
95
95
  const path = opts.path ? this.relativePath(opts.path) : undefined;
96
96
  if (opts.path && path === undefined)
97
97
  return false;
98
- const scope = path ? ["--", path] : [];
98
+ // conversation.json (`orqen ask` / `orqen conversation`) keeps the client's replies, which do not belong in the repository
99
+ const scope = path ? ["--", path, `:(exclude,glob)${path}/conversation.json`, `:(exclude,glob)${path}/**/conversation.json`] : [];
99
100
  this.git("add", "-A", ...scope);
100
101
  if (!this.git("status", "--porcelain", ...scope))
101
102
  return false;
@@ -181,7 +182,9 @@ export class GitWorkspace {
181
182
  const file = join(this.cfg.factoryDir, key, "state.json");
182
183
  const rel = relative(this.cfg.repoPath, file).split(sep).join("/");
183
184
  if (rel.startsWith(".."))
184
- return undefined; // orqen/work outside the repository: nothing to read from git
185
+ return undefined; // the worqs folder is outside the repository: nothing to read from git
186
+ // where the worq can be: the configured folder, orqen/worqs/ and (branches of earlier versions) orqen/work/
187
+ const rels = [...new Set([rel, `orqen/worqs/${key}/state.json`, `orqen/work/${key}/state.json`])];
185
188
  const found = [];
186
189
  const add = (source, text) => {
187
190
  try {
@@ -189,11 +192,15 @@ export class GitWorkspace {
189
192
  }
190
193
  catch { /* not there, or not valid */ }
191
194
  };
192
- if (existsSync(file))
193
- add(rel, () => readFileSync(file, "utf8"));
195
+ for (const p of rels) {
196
+ const disk = join(this.cfg.repoPath, p);
197
+ if (existsSync(disk))
198
+ add(p, () => readFileSync(disk, "utf8"));
199
+ }
194
200
  for (const ref of [branchFor(key), legacyBranchFor(key)])
195
201
  for (const r of [ref, `origin/${ref}`])
196
- add(`${r}:${rel}`, () => this.git("show", `${r}:${rel}`));
202
+ for (const p of rels)
203
+ add(`${r}:${p}`, () => this.git("show", `${r}:${p}`));
197
204
  const time = (x) => Date.parse(x.snapshot?.updated ?? "") || 0;
198
205
  return found.sort((a, b) => time(b) - time(a))[0];
199
206
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@telpin-sistemas/orqen",
3
- "version": "0.1.5",
4
- "description": "ORQEN multi-agent orchestration on OpenSpec, from customer request to production.",
3
+ "version": "0.1.7",
4
+ "description": "orqen multi-agent orchestration on OpenSpec, from customer request to production.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "orqen": "dist/index.js"
@@ -1,3 +0,0 @@
1
- # orqen/work
2
-
3
- orqen records each customer request and its linked issue in a folder named after the request key, such as `SOP-1234/`. It includes `state.json`, `log.md`, and the analysis from each round. orqen writes and commits the record with the request branch.