@qameleon-ai/qameleon 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,17 @@ never turns the suite red. To catch up, add the new lines and move the commit to
14
14
 
15
15
  ## Reviewing tickets
16
16
 
17
+ - 0.1.1: `qameleon shortcut` puts a QAmeleon icon on your desktop (and in the Start menu on Windows; a Desktop file on a Mac; a launcher on Linux) that opens the review console for that folder in your browser, so after setup nobody needs a terminal. `--remove` takes it away. Setup ends by pointing to it, and `qameleon console --open` opens the browser by itself. [T-0405]
18
+ - 0.1.1: the console reads like a person talks: dates such as Tue 24 Nov, 13:58; a review state in words (waiting for your approval); ticket keys that open the ticket on the board; no empty Labels column; bigger verdict chips; ticket keys that never split over two lines. [T-0406]
19
+ - 0.1.1: a ClickUp or Shortcut board no longer times out when QAmeleon holds requests back to stay under the vendor's per-minute limit: a request's 30 second timeout now starts when it is sent, not while it waits its turn. The docs site's search box fits a phone screen with the text at twice the size. [T-0407]
20
+ - 0.1.1: setup on Windows now fills in the npm integrity for the workflows it writes. It ran `npm view`, which Windows cannot start that way (npm is a .cmd script), so it said "npm gave no integrity" for a published version and the workflows stopped at install. When npm cannot be started, setup now reads the same value from the npm registry. [T-0396]
21
+ - 0.1.1: the review console no longer shows "Model key NOT SET" as a problem when the review runs on your Claude Code subscription: Settings and Connections show the route instead and say no key is needed. [T-0404]
22
+ - 0.1.1: a JSON file saved by Notepad or Windows PowerShell (which add an invisible byte-order mark at the start) is read like any other: the config, setup's answers file, file-board tickets and import bundles. [T-0395]
23
+ - 0.1.1: the review console speaks plainly. Today opens with what waits for you ("8 results are waiting for you to read and approve", with a link), and says what GREEN, AMBER and RED mean. The words people trip on are gone: Kill switch is Stop everything, incidents are safety stops, "Held by the guard" is "Stopped by the safety guard", a check that is not set up says so and who to ask instead of naming a config setting, and the pause banners say to press Resume on Controls instead of giving a terminal command. [T-0402, T-0403]
24
+ - 0.1.1: in the review console, Read the draft now shows the draft as a report, not as raw text: the verdict as a coloured label, the steps as a table with a label for each result, the bugs and notes as lists, and quotes set apart. The Approve button is above the draft as well as below it. The exact plain text is one click away under Show the plain text. [T-0398]
25
+ - 0.1.1: the review console has two buttons, **Check my tickets now** and **Run the morning checks**, on Today, Morning report and Waiting for you, so a person can run QAmeleon without a terminal. Each runs the same dry-run command in the project folder (one at a time), shows that it is running, then a short result with a link to what it made. Nothing is posted from them. [T-0321]
26
+ - 0.1.1: the review and the morning run now sign in the way your app does. A new `product.signIn` setting in `qa.config.json`, written by setup, names a sign-in that takes JSON (`apiPath`, for example `/api/auth/login`) and the sign-in page (`loginPath`). A token in the answer is used as a bearer token, otherwise the cookies it sets are kept; when the JSON path is not there, the sign-in page's form is sent with its hidden fields. A failed sign-in now says why in one sentence (for example "the app refused the email and password at /api/auth/login (401)") instead of "are its credential secrets set?". Before this, any app without the demo's `/api/session` got no session and every signed-in step came back NOT VERIFIED. [T-0397]
27
+ - 0.1.1: the setup page's buttons inside each step work again with plain `qameleon setup`. Skip, "List the repositories I can push to", "Show me the files" and the Board step all answered "not found" and the page showed nothing; the page now also shows a plain message when setup gives an answer it cannot read. [T-0394]
17
28
  - `qameleon doctor` no longer says `ok` on the `Own comments` line when `board.accountId` is still a placeholder. A value such as `YOUR_ACCOUNT_ID`, text in angle brackets, `changeme`, one character repeated, the all-zero id or the `0123456789abcdef` counting string is now FIX on every board type (Jira, Linear, Trello, Notion, Shortcut, ClickUp, Azure DevOps and the file board). The line names the board and the setting, says what to put there and never prints the value. `qameleon validate` warns about the same values (a warning, because our own docs show example ids), and the setup page refuses to take one. Ids a board really issues are never flagged. [T-0290]
18
29
  - A draft that still trips the secret scan no longer ends the whole review with "guard denied: outbound draft text contained a secret" and no drafts folder. That draft alone is held back and not written; the other drafts are written, and `summary.md` and `index.json` list the held one. The message names the ticket key and the field (for example `QAF-3: field "actual"`), never the text. Everything still pauses until a person resumes, and `qameleon review` exits with the new code 6 (documented in `docs/errors.md` and `docs/commands.md`). [T-0289]
19
30
  - A review no longer stops with "guard denied: outbound draft text contained a secret" when a ticket, a step, a finding or a reason mentions one of the run's own logins (for example the demo username or password). Only the ticket text was cleaned before; the verdict reasons, unconfirmed notes, the cross-organisation reason, the signed-out wording, the duplicate-search note, step text, finding details, repro steps and every other text of a draft now go through the same redactor, in one pass at the end of the review that walks every string field of every draft (so a field added later is covered too). A login in any of them is written as `[redacted]`, the comment is rendered from the cleaned fields, and the drafts are written. Tests plant the demo logins, built at run time, in the ticket, plan and finding, check every draft field and file, check that `qameleon review` exits 0, and walk the draft fields so one that skips the redactor fails. How a held draft is shown and the wording of the guard's error are not changed here. [T-0287]
package/README.md CHANGED
@@ -130,7 +130,7 @@ A key is a line of text that proves you have a licence. It is signed, so QAmeleo
130
130
 
131
131
  | Key | What runs |
132
132
  | --- | --- |
133
- | none, garbage, tampered, signed by someone else, or expired | The commands that need no key (`clean`, `demo`, `doctor`, `drafts`, `feedback`, `help`, `history`, `licence`, `migrate`, `pause`, `report`, `resume`, `status`, `usage`, `validate`) and explicit `--dry-run` runs only. `pause` and `resume` always work: they are the safety stop, so you can always halt QAmeleon. Everything else is refused. |
133
+ | none, garbage, tampered, signed by someone else, or expired | The commands that need no key (`clean`, `demo`, `doctor`, `drafts`, `feedback`, `help`, `history`, `licence`, `migrate`, `pause`, `report`, `resume`, `shortcut`, `status`, `usage`, `validate`) and explicit `--dry-run` runs only. `pause` and `resume` always work: they are the safety stop, so you can always halt QAmeleon. Everything else is refused. |
134
134
  | Trial | Dry runs only (runs that change nothing): `review --dry-run`, `run ... --dry-run`, `publish --dry-run`, plus `setup`, `drafts` and `approve`, which post nothing. `publish`, `review` and `run` without `--dry-run` are refused. One product and one board, and 10 reviewed tickets. Refused entirely once the 14 days are over (dry runs included). Once the 10 tickets are used, `review` still reviews a ticket it has already counted. It lists any new ticket as not reviewed. The commands that review no ticket go on until the 14 days end. |
135
135
  | Team / Business | Everything, up to the plan's limits: Team 3 products and 1 board, Business 10 products and 3 boards. |
136
136
 
@@ -164,7 +164,7 @@ $env:QAMELEON_LICENCE = 'QAM-TRIAL-FREE-14D' # or put it in ./qameleon.licenc
164
164
  qameleon licence show
165
165
  ```
166
166
 
167
- Set it first: every command except `clean`, `demo`, `doctor`, `drafts`, `feedback`, `help`, `history`, `licence`, `migrate`, `pause`, `report`, `resume`, `status`, `usage` and `validate` needs a key, or an explicit `--dry-run`. Those commands only read or tidy local files, or are the safety stop. There is one exception: the folder that `qameleon demo` wrote. There, `approve` and `publish` run with no key, because the demo's board and app are local and nothing leaves your computer. Point that config at a real app or board and they need a key again.
167
+ Set it first: every command except `clean`, `demo`, `doctor`, `drafts`, `feedback`, `help`, `history`, `licence`, `migrate`, `pause`, `report`, `resume`, `shortcut`, `status`, `usage` and `validate` needs a key, or an explicit `--dry-run`. Those commands only read or tidy local files, or are the safety stop. There is one exception: the folder that `qameleon demo` wrote. There, `approve` and `publish` run with no key, because the demo's board and app are local and nothing leaves your computer. Point that config at a real app or board and they need a key again.
168
168
 
169
169
  The trial runs for 14 days from the first time you use it in a project. It covers 10 tickets: `qameleon review` counts each ticket it reviews once (a ticket you review again is not counted again, even after the 10th). It does not take an 11th new ticket and lists it as not reviewed. The trial is limited to one product and one board, and to dry runs only. It writes reports and drafts on your computer and posts nothing. A paid tier lifts the limits. `qameleon licence show` prints the days and the tickets left. The key is public on purpose and holds no secret, and it never unlocks anything a paid key sells. The code is in `src/licence/trial.js`.
170
170
 
@@ -665,6 +665,10 @@ The console is a local page for the person who lives with QAmeleon after setup.
665
665
 
666
666
  The console reads the board named in the config and the files under `.qameleon/` (drafts, audit log, reports, pause file). It works while paused. `--demo` prepares the Stockroom demo board, drafts, a run report and an audit log in a temporary folder. That takes about ten seconds and uses the same scripted review as `qameleon review --demo`. The console removes the folder when it exits.
667
667
 
668
+ **An icon on your desktop.** Run `qameleon shortcut` once in the folder where you ran setup. It puts a QAmeleon icon on your desktop (and in the Start menu on Windows). Double-clicking it opens a small window that starts the console and opens it in your browser (`qameleon console --open`); close that window to stop it. `qameleon shortcut --remove` takes the icon away. It writes only to your own Desktop and menu folders and needs no admin rights.
669
+
670
+ **Running QAmeleon from the page.** Today, Morning report and Waiting for you each have two buttons, so nobody needs a terminal for the daily work. **Check my tickets now** runs `qameleon review --dry-run` on the QA column. It uses the model route from `review.modelRoute` in the config; with none set, it uses your Anthropic key if one is set, and otherwise your Claude Code subscription. **Run the morning checks** runs `qameleon run morning --dry-run`. Each is the command itself, run in the project folder, so the licence, the guard, the pause switch and the state lock apply as they do in a terminal. Both are dry runs: nothing is posted or moved, so they need no approver's name. One runs at a time. The page shows that it is running, then a short result with a link to what it made.
671
+
668
672
  **Acting from the page.** Under Waiting for you, a person can approve a draft and publish it:
669
673
 
670
674
  - The **Approver** box in the header starts as your `git config user.name`, and you can change it; the browser remembers it. Every action needs a real person's name, as `approve --by` and `resume --by` do. No name, or a program's name such as `bot`, is refused.
@@ -20,13 +20,13 @@ qameleon --version
20
20
  qameleon --version
21
21
  ```
22
22
 
23
- The new copy prints `0.1.0` and nothing else. Before you have installed anything, "command not found" is the right answer. Go on to the next part. Run the same line again once `npm link` has finished, and it must then print `0.1.0`.
23
+ The new copy prints `0.1.1` and nothing else. Before you have installed anything, "command not found" is the right answer. Go on to the next part. Run the same line again once `npm link` has finished, and it must then print `0.1.1`.
24
24
 
25
25
  If it opens a web page, or prints a different version, an older copy of QAmeleon is installed on this computer. It was called qa-autopilot, and it hides the new one. Do this:
26
26
 
27
27
  1. Find which copy your computer uses. On Mac or Linux run `which qameleon`. On Windows PowerShell run `where.exe qameleon`. To see what is installed globally, run `npm ls -g` on either.
28
28
  2. Remove the old copy with `npm uninstall -g qameleon`.
29
- 3. Link or install the new one again, then run `qameleon --version` again. It must print `0.1.0`.
29
+ 3. Link or install the new one again, then run `qameleon --version` again. It must print `0.1.1`.
30
30
 
31
31
  The old copy writes a `.qa` folder. The new one writes a `.qameleon` folder. So a `.qa` folder that you did not make means the old command ran.
32
32
 
package/docs/errors.md CHANGED
@@ -633,6 +633,16 @@ The exit code of an error that code throws is the code of the command that print
633
633
  [exit 1] setup failed
634
634
  ```
635
635
 
636
+ ### command: shortcut
637
+
638
+ ```
639
+ # src/cli/commands/shortcut.js
640
+ [exit 1] this folder has no qa.config.json, so the icon would open a console with nothing to show
641
+ fix: run qameleon setup in this folder first, then run qameleon shortcut again
642
+ [exit 1] could not <...> the icon (<message>)
643
+ fix: check that you can write to your Desktop folder, then run qameleon shortcut again; you can always open the console with qameleon console
644
+ ```
645
+
636
646
  ### command: smoke
637
647
 
638
648
  ```
@@ -657,6 +667,8 @@ The exit code of an error that code throws is the code of the command that print
657
667
  # src/config/validate.js
658
668
  [exit 1] unknown key (allowed: <...>)
659
669
  [exit 1] is required and must be an object
670
+ [exit 1] must be an object such as { "apiPath": "/api/auth/login" } or { "loginPath": "/login" }
671
+ [exit 1] must be a path on the dev app that starts with one slash, such as /api/auth/login or /login
660
672
  [exit 1] must be a time zone name such as Europe/Dublin or America/New_York (remove it to use <DEFAULT_TIME_ZONE>)
661
673
  [exit 1] must be a non-empty string
662
674
  [exit 1] must be "dev" (QAmeleon only runs against dev)
@@ -773,6 +785,7 @@ The exit code of an error that code throws is the code of the command that print
773
785
  [console] the free trial only does dry runs, so <id> is not published from the console. Use the dry run to see what would be posted, or upgrade to a paid plan: <PLANS_TEXT>
774
786
  [console] <id> is not published: <why>; fix that, then publish it again
775
787
  [console] the config is invalid: change these lines in qa.config.json: <...>
788
+ [console] could not start it: <message>
776
789
  # src/console/server.js
777
790
  [exit 1] the request was not sent as JSON (a plain data file): reload the page and try again
778
791
  [exit 1] the request body is too large: send less than the page allows
@@ -803,6 +816,8 @@ The exit code of an error that code throws is the code of the command that print
803
816
  [exit 1] <what> <...> is too long to name a file (<length> characters once encoded, at most <MAX_SEGMENT>). <FIX>
804
817
  [exit 1] <what> <...> is not a plain id (letters, digits, "-" and "_", at most <MAX_SEGMENT>), so it cannot name a file. <FIX>
805
818
  [exit 1] <...> would be written outside <root>. Names built from board data must go through safeSegment (src/safe-path.js) first
819
+ # src/shortcut.js
820
+ [exit 1] <...>PowerShell could not make the icon (code <code>); run qameleon shortcut again
806
821
  # src/state-folder.js
807
822
  [exit 1] <shown> is not a QAmeleon state folder. It holds none of the files QAmeleon keeps there (drafts/approvals.json, pause.json, a draft in drafts/, a run report in reports/ and the like). Nothing in or beside it was touched
808
823
  [exit 1] --force names <...>, which is not the folder --dir names (<root>)
@@ -1011,6 +1026,7 @@ The exit code of an error that code throws is the code of the command that print
1011
1026
  [exit 1] reviewColumn needs the guard
1012
1027
  # src/review/sessions.js
1013
1028
  [exit 1] the sign-in address is outside the configured dev base URLs: add its address to product.baseUrls in the config
1029
+ [exit 1] the sign-in page is outside the configured dev base URLs: product.signIn.loginPath must be a path on the dev app
1014
1030
  # src/review/spend-cap.js
1015
1031
  [exit 1] the next model call could take the review past its <...> spend cap (<...> spent so far). Run it again with a higher --max-cost to go further
1016
1032
  # src/review/untrusted.js
package/docs/setup.md CHANGED
@@ -104,11 +104,23 @@ A typed value lives in one local variable of one action. Setup sends it to CI se
104
104
  | Connection | Questions | Detected from |
105
105
  | --- | --- | --- |
106
106
  | Git | GitHub repository (`owner/name`) | `git remote get-url origin` (a token in the URL is never kept) |
107
- | Product | name, dev URL, sign-in page path | existing `qa.config.json`, `.env.example` URL keys, `package.json` name and dev script (explicit port, then framework default), `/login` |
107
+ | Product | name, dev URL, sign-in page path, and the sign-in API path if your app has one | existing `qa.config.json`, `.env.example` URL keys, `package.json` name and dev script (explicit port, then framework default), `/login` |
108
108
  | Accounts | full and look-only users, each with the names of two CI secrets | existing config, else `<product>-admin` (full) and `<product>-viewer` (look-only) |
109
109
  | Board | adapter, QA column, triage column, hold label, board account id, and optionally where a passed and a failed ticket go. It also asks for the folder, or the board's own key or id (the Jira project key, for example) | These settings in your terminal's environment: `JIRA_*`, `LINEAR_API_KEY` (with `LINEAR_TEAM_KEY`, or a linear.app team URL for the team key), `TRELLO_*`, `SHORTCUT_API_TOKEN`, `CLICKUP_API_TOKEN`, `AZURE_DEVOPS_*` or `NOTION_TOKEN`. Then board URLs in `package.json`, README and `.env.example`. Failing that, a local file board. Only built adapters (file, jira, linear, trello, notion, shortcut, clickup, azuredevops) are offered. A board in use that is not built yet falls back to the file board |
110
110
  | Chat | where the summary goes (`slack`, `teams` or `none`), summary channel (Slack only), webhook secret name | existing config (a Teams destination counts), else Slack and names from the product |
111
111
 
112
+ **How QAmeleon signs in to your app.** Setup writes the sign-in it found to `product.signIn` in `qa.config.json`. The review and the morning run (the daily set of checks) sign in the same way:
113
+
114
+ - `"apiPath"`: a sign-in that takes JSON (a plain data file), for example `"/api/auth/login"`. QAmeleon sends `{ "email": ..., "password": ... }` there. If the answer holds a `token`, it is sent as a bearer token; otherwise the cookies the answer sets are kept as the session.
115
+ - `"loginPath"`: the sign-in page, for example `"/login"`. Used when there is no JSON sign-in (the API path answers 404). QAmeleon reads the page's form, sends it with its hidden fields, and keeps the cookies it sets. A form that only your page's script sends (no `method="post"`) cannot be sent this way: set `apiPath` to the address that script calls.
116
+ - Neither set: QAmeleon tries `/api/session`, as the demo app uses.
117
+
118
+ Both are paths on the dev app; anything else is refused. When a sign-in fails, QAmeleon says why in one sentence, never with the password. For example: "the app refused the email and password at /api/auth/login (401)".
119
+
120
+ ```json
121
+ { "product": { "name": "Shop", "baseUrls": ["http://localhost:3000"], "environment": "dev", "signIn": { "apiPath": "/api/auth/login", "loginPath": "/login" } } }
122
+ ```
123
+
112
124
  **Which repository wins.** Setup can take the repository from three places, and uses the first it finds:
113
125
 
114
126
  1. What you give: `git.repo` in an `--answers` file, or what you type on the page.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qameleon-ai/qameleon",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "QAmeleon tests the tickets waiting in your board's QA column on your dev app, writes up what it found, and posts nothing until a named person approves it.",
5
5
  "keywords": [
6
6
  "qa",
@@ -6,6 +6,7 @@ import { FILE_BOARD_AUTHOR_ID } from '../own-comment.js';
6
6
  import { insideDir } from '../../safe-path.js';
7
7
  import { writeFileAtomic } from '../../atomic-write.js';
8
8
  import { ensureDir } from '../../state-perms.js';
9
+ import { stripBom } from '../../json-text.js';
9
10
 
10
11
  const KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
11
12
 
@@ -85,7 +86,7 @@ export function createFileBoard({ dir, keyPrefix = 'TKT', columns, people, autho
85
86
  if (err.code === 'ENOENT') throw new TicketNotFoundError(key);
86
87
  throw err;
87
88
  }
88
- return hydrate(JSON.parse(text), key);
89
+ return hydrate(JSON.parse(stripBom(text)), key);
89
90
  }
90
91
 
91
92
  async function write(ticket) {
@@ -124,7 +125,7 @@ export function createFileBoard({ dir, keyPrefix = 'TKT', columns, people, autho
124
125
  let raw = people;
125
126
  if (raw === undefined) {
126
127
  try {
127
- raw = JSON.parse(await readFile(path.join(dir, PEOPLE_FILE), 'utf8'));
128
+ raw = JSON.parse(stripBom(await readFile(path.join(dir, PEOPLE_FILE), 'utf8')));
128
129
  } catch (err) {
129
130
  if (err.code === 'ENOENT') return [];
130
131
  throw err;
@@ -13,6 +13,7 @@
13
13
  //
14
14
  // Waits are exponential with jitter, or what Retry-After asks for (seconds or an HTTP date). The clock, the
15
15
  // sleep and the random source are injectable, so tests do not wait.
16
+ import { REQUEST_TIMEOUT } from './throttle.js';
16
17
  import { BoardError } from './contract.js';
17
18
  import { createPacer } from './limits.js';
18
19
 
@@ -214,7 +215,7 @@ export function createRetrier({ name, fetch: fetchImpl, retry = {}, pacing }) {
214
215
  if (pace) await pace();
215
216
  const sent = now();
216
217
  try {
217
- res = await sameOriginFetch(fetchImpl, url, { ...init, signal: AbortSignal.timeout(policy.requestTimeoutMs) });
218
+ res = await sameOriginFetch(fetchImpl, url, { ...init, signal: AbortSignal.timeout(policy.requestTimeoutMs), [REQUEST_TIMEOUT]: policy.requestTimeoutMs });
218
219
  } catch (err) {
219
220
  await note(url, init, kind, attempt, sent, { err });
220
221
  const ms = waitAfterError(err, kind, attempt, started);
@@ -35,6 +35,11 @@ export function createWindowLimiter({ max, windowMs, now = Date.now, sleep = sle
35
35
  };
36
36
  }
37
37
 
38
+ // The retrier puts its per-request timeout on the request under this key, beside the signal it made. A request held back
39
+ // here can wait most of a minute for its turn, so its timeout starts again when it is sent: the wait is ours, not the
40
+ // vendor's slowness, and must not count against it.
41
+ export const REQUEST_TIMEOUT = Symbol('qameleon.requestTimeoutMs');
42
+
38
43
  /**
39
44
  * A fetch that waits its turn before every request, retries included (each attempt counts against the vendor's cap).
40
45
  * `rateLimit` is { max, windowMs, now, sleep }, or false for no spacing.
@@ -44,6 +49,7 @@ export function limitedFetch(fetchImpl, rateLimit) {
44
49
  const acquire = createWindowLimiter(rateLimit);
45
50
  return async (url, init) => {
46
51
  await acquire();
47
- return fetchImpl(url, init);
52
+ const ms = init?.[REQUEST_TIMEOUT];
53
+ return fetchImpl(url, Number.isFinite(ms) && ms > 0 ? { ...init, signal: AbortSignal.timeout(ms) } : init);
48
54
  };
49
55
  }
@@ -12,6 +12,7 @@ import { parseOptions } from '../options.js';
12
12
  import { buildBoard } from '../board.js';
13
13
  import { loadCommands } from '../index.js';
14
14
  import { failConfig, failUsage, failWith } from '../fail.js';
15
+ import { openInBrowser } from '../../shortcut.js';
15
16
 
16
17
  const USAGE = [
17
18
  'Usage: qameleon console [options]',
@@ -42,10 +43,11 @@ const USAGE = [
42
43
  ' --demo the same page on sample data: the bundled demo board and drafts. No config,',
43
44
  ' no licence and no key; the data lives in a temporary folder removed on exit',
44
45
  ' --port <n> port for the page (default: a random free one)',
46
+ ' --open open the page in your default browser too (the desktop icon uses this)',
45
47
  '',
46
48
  ].join('\n');
47
49
 
48
- const OPTIONS = { flags: ['--demo'], values: ['--config', '--port'] };
50
+ const OPTIONS = { flags: ['--demo', '--open'], values: ['--config', '--port'] };
49
51
 
50
52
  function problemWith({ opts, rest, error }) {
51
53
  if (error) return error;
@@ -132,6 +134,7 @@ export default {
132
134
  const server = await startConsoleServer({ view: connected.view, actions: connected.actions, port: Number(opts.port ?? 0) });
133
135
  try {
134
136
  io.out(`Console: ${server.url}\nOpen it in your browser. It listens on this machine only. Press Ctrl+C to stop.\n`);
137
+ if (opts.open && !(io.openInBrowser ?? openInBrowser)(server.url)) io.out('Could not open your browser by itself: copy the address above into it.\n');
135
138
  await untilStopped(io.signal);
136
139
  return 0;
137
140
  } finally {
@@ -5,6 +5,7 @@ import { createGhSecrets, defaultExec, readHidden } from '../../setup/secrets.js
5
5
  import { runSetup } from '../../setup/run.js';
6
6
  import { DEMO_DIR } from '../../setup/demo.js';
7
7
  import { fail, failUsage, failWith } from '../fail.js';
8
+ import { stripBom } from '../../json-text.js';
8
9
 
9
10
  const USAGE = [
10
11
  'Usage: qameleon setup [options]',
@@ -64,7 +65,7 @@ function problemWith({ opts, rest, error }) {
64
65
  async function readAnswers(file, cwd) {
65
66
  if (!file) return undefined;
66
67
  try {
67
- return JSON.parse(await readFile(path.resolve(cwd, file), 'utf8'));
68
+ return JSON.parse(stripBom(await readFile(path.resolve(cwd, file), 'utf8')));
68
69
  } catch {
69
70
  return null;
70
71
  }
@@ -0,0 +1,54 @@
1
+ import { access } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { makeShortcut, shortcutName } from '../../shortcut.js';
4
+ import { fail, failUsage } from '../fail.js';
5
+
6
+ const USAGE = [
7
+ 'Usage: qameleon shortcut [--remove]',
8
+ '',
9
+ 'Puts a QAmeleon icon on your desktop for this project folder, so you can open the review console by',
10
+ 'double-clicking it instead of typing a command. The icon opens a small window that starts the console',
11
+ 'and opens it in your browser; close that window to stop the console.',
12
+ '',
13
+ 'Windows: an icon on the Desktop and in the Start menu. Mac: a QAmeleon file on the Desktop. Linux: a',
14
+ 'launcher on the Desktop and in your applications menu. Only your own folders are written; no admin rights.',
15
+ '',
16
+ 'Run it in the folder where you ran qameleon setup (the one with qa.config.json).',
17
+ '',
18
+ 'Options:',
19
+ ' --remove take the icon away again (only the files this command made)',
20
+ '',
21
+ ].join('\n');
22
+
23
+ export default {
24
+ name: 'shortcut',
25
+ licence: 'free',
26
+ usage: USAGE,
27
+ summary: 'Put a QAmeleon icon on your desktop that opens the review console for this folder',
28
+ allowWhilePaused: true,
29
+ async run(args, io) {
30
+ const remove = args.length === 1 && args[0] === '--remove';
31
+ if (args.length > 0 && !remove) {
32
+ failUsage(io, `unexpected argument '${args[0]}'`, 'shortcut', USAGE, 2);
33
+ return 2;
34
+ }
35
+ const cwd = path.resolve(io.cwd ?? '.');
36
+ if (!remove) {
37
+ try {
38
+ await access(path.join(cwd, 'qa.config.json'));
39
+ } catch {
40
+ fail(io, `this folder has no qa.config.json, so the icon would open a console with nothing to show`, 'run qameleon setup in this folder first, then run qameleon shortcut again');
41
+ return 1;
42
+ }
43
+ }
44
+ try {
45
+ const result = await makeShortcut({ projectDir: cwd, remove, ...(io.shortcutDeps ?? {}) });
46
+ if (remove) io.out(`Removed the ${shortcutName(cwd)} icon.\n`);
47
+ else io.out(`Made the ${shortcutName(cwd)} icon:\n${result.made.map((f) => ` ${f}\n`).join('')}Double-click it to open the review console. Close the window it opens to stop the console.\n`);
48
+ return 0;
49
+ } catch (e) {
50
+ fail(io, `could not ${remove ? 'remove' : 'make'} the icon (${e.message})`, 'check that you can write to your Desktop folder, then run qameleon shortcut again; you can always open the console with qameleon console');
51
+ return 1;
52
+ }
53
+ },
54
+ };
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { validateConfig } from './validate.js';
3
3
  import { locateJsonError } from './json-position.js';
4
+ import { stripBom } from '../json-text.js';
4
5
 
5
6
  export const DEFAULT_CONFIG_PATH = 'qa.config.json';
6
7
 
@@ -13,7 +14,7 @@ const READ_PROBLEMS = { ENOENT: 'no such file', EACCES: 'not allowed to read it'
13
14
  export async function loadConfig(path = DEFAULT_CONFIG_PATH) {
14
15
  let text;
15
16
  try {
16
- text = await readFile(path, 'utf8');
17
+ text = stripBom(await readFile(path, 'utf8'));
17
18
  } catch (e) {
18
19
  return { ok: false, unreadable: true, errors: [{ path: '', message: `cannot read file: ${READ_PROBLEMS[e.code] ?? `error ${e.code ?? 'unknown'}`}` }] };
19
20
  }
@@ -94,7 +94,18 @@ class Report {
94
94
  function checkProduct(product, r) {
95
95
  const path = ['product'];
96
96
  if (!isObject(product)) return r.add(path, 'is required and must be an object');
97
- r.closed(product, ['name', 'baseUrls', 'environment', 'timeZone'], path);
97
+ r.closed(product, ['name', 'baseUrls', 'environment', 'timeZone', 'signIn'], path);
98
+ if (product.signIn !== undefined) {
99
+ const at = [...path, 'signIn'];
100
+ if (!isObject(product.signIn)) r.add(at, 'must be an object such as { "apiPath": "/api/auth/login" } or { "loginPath": "/login" }');
101
+ else {
102
+ r.closed(product.signIn, ['apiPath', 'loginPath'], at);
103
+ for (const key of ['apiPath', 'loginPath']) {
104
+ const v = product.signIn[key];
105
+ if (v !== undefined && (typeof v !== 'string' || !/^\/(?!\/)[^\s\\]{0,199}$/.test(v))) r.add([...at, key], 'must be a path on the dev app that starts with one slash, such as /api/auth/login or /login');
106
+ }
107
+ }
108
+ }
98
109
  if (product.timeZone !== undefined && !isTimeZone(product.timeZone)) r.add([...path, 'timeZone'], `must be a time zone name such as Europe/Dublin or America/New_York (remove it to use ${DEFAULT_TIME_ZONE})`);
99
110
  if (product.name !== undefined && !isText(product.name)) r.add([...path, 'name'], 'must be a non-empty string');
100
111
  if (!ENVIRONMENTS.includes(product.environment)) r.add([...path, 'environment'], `must be "dev" (QAmeleon only runs against dev)`);
@@ -23,6 +23,7 @@ import { tripWire } from '../guard/tripwire.js';
23
23
  import { PLANS_TEXT } from '../licence/index.js';
24
24
  import { readUsage, seatOf, withIdentities, writeUsage } from '../licence/usage.js';
25
25
  import { DEFAULT_DRAFTS_DIR } from '../review/drafts.js';
26
+ import { createConsoleJobs } from './jobs.js';
26
27
 
27
28
  const HASH = /^[0-9a-f]{8,64}$/i;
28
29
 
@@ -65,7 +66,7 @@ const resultOf = (info, r) => ({ id: info.id, hash: info.hash.slice(0, 12), outc
65
66
  * @param {object} [options.licence] the licence the console runs under (the gate's): a plan that only does dry runs (the trial) may not publish
66
67
  * @param {(record: object) => void} [options.log] receives the guard's log lines
67
68
  */
68
- export function createConsoleActions({ config, adapter, root, env = process.env, log = () => {}, licence }) {
69
+ export function createConsoleActions({ config, adapter, root, env = process.env, log = () => {}, licence, jobs = createConsoleJobs({ root, config, env }) }) {
69
70
  const pauseStore = openPauseStore(root);
70
71
  // The kill switch must never depend on the publisher (a misconfigured destination): it and the audit use the stores alone.
71
72
  const auditStore = () => openDraftStore(path.resolve(root, DEFAULT_DRAFTS_DIR));
@@ -150,5 +151,14 @@ export function createConsoleActions({ config, adapter, root, env = process.env,
150
151
  return { ...resultOf(info, results[0]), paused };
151
152
  }
152
153
 
153
- return { pause: guarded(pause), resume: guarded(resume), read: guarded(read, { locks: false }), approve: guarded(approve), preview: guarded(preview, { locks: false }), publish: guarded(publish) };
154
+ // The Run buttons (T-0321): a dry-run review or morning run, started as the command itself in the project folder. They
155
+ // post nothing, so no approver's name is needed; the command takes the state lock and honours the pause switch itself.
156
+ const startJob = (kind) => async () => {
157
+ try { return jobs.start(kind); } catch (e) { throw e.status ? e : refusal(`could not start it: ${e.message}`, 500); }
158
+ };
159
+
160
+ return {
161
+ pause: guarded(pause), resume: guarded(resume), read: guarded(read, { locks: false }), approve: guarded(approve), preview: guarded(preview, { locks: false }), publish: guarded(publish),
162
+ 'check-tickets': startJob('review'), 'run-morning': startJob('morning'), job: async () => jobs.status(),
163
+ };
154
164
  }
@@ -3,6 +3,7 @@
3
3
  // file: a value is never read into anything this returns, so no page can show one.
4
4
  import { REFERENCE_NAME } from '../config/secrets.js';
5
5
  import { nudgeSettings } from '../nudge/config.js';
6
+ import { routeFor } from './jobs.js';
6
7
 
7
8
  const MODEL_KEY = 'ANTHROPIC_API_KEY';
8
9
 
@@ -36,7 +37,10 @@ export function connectionsOf(config, env) {
36
37
  chat: chat && { provider: chat.provider ?? 'slack', secrets: named([ref(chat.webhookRef)]) },
37
38
  destinations: (config.report?.destinations ?? []).map((d) => ({ type: d.type, secrets: named(DESTINATION_SECRETS[d.type]?.(d) ?? [d.urlRef].map(ref)) })),
38
39
  nudge: nudge && { secrets: named([ref(nudge.botTokenSecret)]) },
39
- model: { secrets: [secret(env, MODEL_KEY)] },
40
+ // Bug 104: on the Claude Code subscription route the review needs no key, so the key is not asked for.
41
+ model: routeFor(config, env) === 'subscription'
42
+ ? { route: 'subscription', secrets: [], note: 'The review runs on your Claude Code subscription, so no Anthropic key is needed.' }
43
+ : { route: 'api', secrets: [secret(env, MODEL_KEY)], note: null },
40
44
  accounts: (config.accounts ?? []).map((a) => ({ name: a.name, role: a.role, secrets: Object.entries(a.credentialRefs ?? {}).map(([purpose, name]) => ({ purpose, ...secret(env, ref(name) ?? '') })) })),
41
45
  };
42
46
  }
@@ -51,10 +55,10 @@ export function settingsOf(config, env, { approver = '' } = {}) {
51
55
  product: { name: config.product?.name ?? null, environment: config.product?.environment ?? null, baseUrls: config.product?.baseUrls ?? [] },
52
56
  connected: [
53
57
  line('Board', `${c.board.adapter}: QA column ${c.board.qaColumn}`, c.board.secrets),
54
- line('Accounts', `${c.accounts.length} account(s)`, c.accounts.flatMap((a) => a.secrets)),
58
+ line('Accounts', `${c.accounts.length} ${c.accounts.length === 1 ? 'account' : 'accounts'}`, c.accounts.flatMap((a) => a.secrets)),
55
59
  line('Chat', c.chat ? c.chat.provider : 'not set up', c.chat?.secrets ?? []),
56
60
  ...c.destinations.map((d) => line('Report destination', d.type, d.secrets)),
57
- line('Model key', MODEL_KEY, c.model.secrets),
61
+ c.model.route === 'subscription' ? line('Model', 'your Claude Code subscription (no key needed)') : line('Model key', MODEL_KEY, c.model.secrets),
58
62
  ],
59
63
  setup: { command: 'qameleon setup', changes: 'the repository, app, accounts or board' },
60
64
  };
@@ -0,0 +1,81 @@
1
+ // The console's Run buttons (T-0321, bug 101): a person who never opens a terminal can start a dry-run
2
+ // review of the QA column or the morning checks from the page. Each runs the same qameleon command a
3
+ // person would type, in the project folder, as a child process, so the licence gate, the guard, the
4
+ // state lock and the dry-run rules are exactly the command's own. Only dry runs: nothing is posted,
5
+ // approved or moved from here. One at a time; the page asks for the status every few seconds.
6
+ import { spawn as nodeSpawn } from 'node:child_process';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const CLI = fileURLToPath(new URL('../../bin/qameleon.js', import.meta.url));
10
+ const KEEP = 6000;
11
+
12
+ // forwards: the message is the caller's own sentence
13
+ const refusal = (message, status) => Object.assign(new Error(message), { status });
14
+
15
+ // The review's model route: the config's, else the Anthropic key when one is set, else the Claude Code subscription.
16
+ export function routeFor(config, env) {
17
+ const set = config?.review?.modelRoute;
18
+ if (typeof set === 'string' && set !== '') return set;
19
+ return env.ANTHROPIC_API_KEY ? 'api' : 'subscription';
20
+ }
21
+
22
+ const JOBS = {
23
+ review: { label: 'Checking the tickets in the QA column (a dry run: nothing is posted)', args: (config, env) => ['review', '--dry-run', '--model-route', routeFor(config, env)], page: 'waiting' },
24
+ morning: { label: 'Running the morning checks (a dry run: nothing is posted)', args: () => ['run', 'morning', '--dry-run'], page: 'morning' },
25
+ };
26
+
27
+ // The last lines a person can read: no colour codes, no blank lines, no guard log records (JSON).
28
+ function lastLines(text, count = 8) {
29
+ return text.replace(/\u001b\[[0-9;]*[A-Za-z]/g, '').split(/\r?\n/).map((l) => l.trimEnd()).filter((l) => l.trim() !== '' && !l.startsWith('{')).slice(-count);
30
+ }
31
+
32
+ /**
33
+ * @param {object} options
34
+ * @param {string} options.root the project folder (the command runs there)
35
+ * @param {object} options.config the validated config (for the review's model route)
36
+ * @param {object} [options.env] the environment the command gets (the secrets it names live here)
37
+ * @param {Function} [options.spawn] child_process.spawn, for tests
38
+ * @param {() => Date} [options.now]
39
+ */
40
+ export function createConsoleJobs({ root, config, env = process.env, spawn = nodeSpawn, now = () => new Date(), cli = CLI }) {
41
+ let running = null;
42
+ let last = null;
43
+
44
+ function start(kind) {
45
+ const job = JOBS[kind];
46
+ if (!job) throw refusal('there is no such run', 404);
47
+ if (running) throw refusal(`${JOBS[running.kind].label.split(' (')[0]} is still going: wait for it to finish, then start the next one`, 409);
48
+ const args = job.args(config, env);
49
+ const child = spawn(process.execPath, [cli, ...args], { cwd: root, env: { ...env, NO_COLOR: '1', FORCE_COLOR: '0' }, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
50
+ const out = { stdout: '', stderr: '' };
51
+ const keep = (which) => (chunk) => { out[which] = (out[which] + chunk.toString('utf8')).slice(-KEEP); };
52
+ child.stdout?.on('data', keep('stdout'));
53
+ child.stderr?.on('data', keep('stderr'));
54
+ running = { kind, startedAt: now() };
55
+ const finish = (code) => {
56
+ if (!running || running.child !== child) return;
57
+ const lines = lastLines(out.stdout);
58
+ const problems = lastLines(out.stderr, 4).filter((l) => /^qameleon:|^fix:|refused|error/i.test(l));
59
+ const all = lastLines(out.stdout, 200);
60
+ const summary = all.filter((l) => /^(Morning run:|Dry run|Nothing was posted|Since the last run)/.test(l)).map((l) => l.replace(/\s*\(RUN-[^)]*\)/, ''));
61
+ last = { kind, code, ok: code === 0, startedAt: running.startedAt.toISOString(), endedAt: now().toISOString(), lines, summary: summary.length ? summary : lines.slice(-1), problems, page: job.page };
62
+ running = null;
63
+ };
64
+ running.child = child;
65
+ child.on('error', () => finish(127));
66
+ child.on('close', (code) => finish(code ?? 1));
67
+ return { started: kind, label: job.label };
68
+ }
69
+
70
+ function status() {
71
+ return {
72
+ running: running ? { kind: running.kind, label: JOBS[running.kind].label, seconds: Math.round((now() - running.startedAt) / 1000) } : null,
73
+ last,
74
+ };
75
+ }
76
+
77
+ // Stops a run still going when the console closes, so no child is left behind.
78
+ function stop() { running?.child?.kill(); }
79
+
80
+ return { start, status, stop };
81
+ }