@trops/dash-check 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +104 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -150,16 +150,7 @@ check("the work is ready for review", async (ctx) => {
150
150
  });
151
151
  ```
152
152
 
153
- | Group | Helpers |
154
- |---|---|
155
- | handoff | `has({ keys })`, `status({ is })`, `eachHas({ list, keys })` |
156
- | plan | `hasSections({ key, sections })`, `acceptanceEachHasTest({ acceptance, tests })`, `evidenceForAcceptance({ key, acceptanceKey, requireSearch, when })`, `noOpenDecisions({ key, when })` (see below) |
157
- | git | `onBranch({ branch })`, `committedSince({ base, min })`, `clean()`, `changedOnly({ globs, base })`, `noChangesTo({ globs, base })`, and the factory checks below |
158
- | files | `exist({ paths })`, `contain({ path, text })`, `noneMatch({ glob, pattern })`, `maxGrowth(…)` |
159
- | commands | `passes({ command, timeoutSec })`, `outputMatches({ command, pattern })` |
160
- | node | `testsPass({ command })`, `lintPasses({ command })`, `noNewDependencies({ base, allow })`, `lockfileExplained(…)`, `testScriptIsReal(…)`, `newTestsAreRun(…)` |
161
- | github | `prOpen({ prKey })`, `ciPassed({ prKey, timeoutSec, noChecksAfterSec, ifNoChecks })` |
162
- | tracker | `ticketExists({ provider, tool, idArg, id })`, `ticketHasLabel({ label, … })` (these need Dash's `ctx.tool`) |
153
+ There are 33, in eight groups: `handoff`, `plan`, `git`, `files`, `commands`, `node`, `github` and `tracker`. The [helper reference](#helper-reference) lists every one with its params, defaults and an example step.
163
154
 
164
155
  `npx dash-check --list-helpers` lists each one with its params and defaults.
165
156
 
@@ -183,6 +174,26 @@ Checks on a planning bot's handoff, before anyone writes code. They read only th
183
174
  { "use": "plan.noOpenDecisions", "with": { "when": "ok, split" } }
184
175
  ```
185
176
 
177
+ A handoff both pass:
178
+
179
+ ```json
180
+ {
181
+ "status": "ok",
182
+ "acceptance": ["Links look clickable"],
183
+ "notYetDone": {
184
+ "searchedDone": "Done tickets about link styles: none. safeMarkdown.js sets only rel and target on links.",
185
+ "missing": [
186
+ { "acceptance": "Links look clickable",
187
+ "read": "src/utils/safeMarkdown.js ensureLinkHook",
188
+ "why": "It adds no class, so links render as plain text" }
189
+ ]
190
+ },
191
+ "openDecisions": []
192
+ }
193
+ ```
194
+
195
+ With a question in `openDecisions` (`["Which colour?"]`), `plan.noOpenDecisions` fails: "The plan leaves decisions open: Which colour?. Don't plan: answer status ask with the question for the user." With no `searchedDone` or no `missing` entry for an item, `plan.evidenceForAcceptance` fails saying what to add.
196
+
186
197
  ### Factory checks: did the bot do only what it planned?
187
198
 
188
199
  Checks for a code factory, where a planning bot names the files and a coding bot changes them. Each works on any repo: all it needs is git and, for the plan checks, a handoff that lists files. Every one compares with `base` (default `{repo.baseBranch}`; empty means the repo's default branch, through `origin/` when the remote has it), and every one judges only **what the work changed**, so existing debt in the repo doesn't fail it.
@@ -294,6 +305,88 @@ explain(recipe); // ["Work is committed: at least 1 commit(s) p
294
305
 
295
306
  `recipeToCode` gives a file that produces the same result as the recipe. The tests check this.
296
307
 
308
+ ## Helper reference
309
+
310
+ Every helper in `@trops/dash-check/helpers`, from `dash-check --list-helpers --json` (the same data Dash's check composer shows). In a recipe, a step is `{ "use": "<id>", "with": { …params } }`; in code, `await <group>.<name>(ctx, { …params })`. Every helper also takes `message`, which replaces its failure text.
311
+
312
+ - A param with no default is optional unless it says *required*.
313
+ - A `list` takes `"a, b"` or `["a", "b"]`. A glob's `{a,b}` stays whole.
314
+ - `{placeholders}` are filled from the job: `{repo.baseBranch}` from the picked row, `{item.id}` from the work item, `{workRoot}` (any name) from the team's settings, `{workspace.branch}` from the job's workspace. A placeholder with no value counts as empty, so `base` falls back to the repo's default branch.
315
+ - `tracker.*` call `ctx.tool`, which only Dash answers.
316
+
317
+ ### handoff
318
+
319
+ | Helper | Checks | Params (default) | Example step |
320
+ |---|---|---|---|
321
+ | `handoff.has` | The bot's handoff includes these, not empty | `keys` list (required) | `{"use":"handoff.has","with":{"keys":"prUrl, plan.cause"}}` |
322
+ | `handoff.status` | The handoff's status (ok, none, ask or split) | `is` select (`ok`): `ok` or `none` or `ask` or `split` | `{"use":"handoff.status","with":{"is":"ok"}}` |
323
+ | `handoff.eachHas` | Every entry of a handoff list has these, not empty | `list` text (required); `keys` list (required) | `{"use":"handoff.eachHas","with":{"list":"tests","keys":"acceptance, file"}}` |
324
+
325
+ ### plan
326
+
327
+ | Helper | Checks | Params (default) | Example step |
328
+ |---|---|---|---|
329
+ | `plan.hasSections` | The handoff's plan has each section, not empty | `key` text (`plan`); `sections` list (`cause, fix, test`) | `{"use":"plan.hasSections","with":{"sections":"cause, fix, test"}}` |
330
+ | `plan.acceptanceEachHasTest` | Plan: every item is tested | `acceptance` text (`acceptance`); `tests` text (`tests`) | `{"use":"plan.acceptanceEachHasTest"}` |
331
+ | `plan.evidenceForAcceptance` | Plan: it searched for finished work, and for each acceptance item says what it read and why it's still missing | `key` text (`notYetDone`); `acceptanceKey` text (`acceptance`); `requireSearch` boolean (`true`); `when` list (`ok`) | `{"use":"plan.evidenceForAcceptance"}` |
332
+ | `plan.noOpenDecisions` | Plan: it lists the decisions still open, and there are none | `key` text (`openDecisions`); `when` list (`ok`) | `{"use":"plan.noOpenDecisions","with":{"when":"ok, split"}}` |
333
+
334
+ ### git
335
+
336
+ | Helper | Checks | Params (default) | Example step |
337
+ |---|---|---|---|
338
+ | `git.onBranch` | The workspace is on workspace.branch | `branch` text (`{workspace.branch}`) | `{"use":"git.onBranch"}` |
339
+ | `git.committedSince` | Commits past the base, nothing uncommitted | `base` text (`{repo.baseBranch}`); `min` number (`1`) | `{"use":"git.committedSince","with":{"base":"{repo.baseBranch}","min":1}}` |
340
+ | `git.clean` | No staged, unstaged or untracked changes | none | `{"use":"git.clean"}` |
341
+ | `git.changedOnly` | Changed files match globs | `globs` list (required); `base` text (`{repo.baseBranch}`) | `{"use":"git.changedOnly","with":{"globs":"src/**, test/**"}}` |
342
+ | `git.noChangesTo` | No changed file matches the globs | `globs` list (required); `base` text (`{repo.baseBranch}`) | `{"use":"git.noChangesTo","with":{"globs":".github/workflows/**, .dash/checks/**"}}` |
343
+ | `git.changesMatchPlan` | Every changed file is named in the handoff's plan | `base` text (`{repo.baseBranch}`); `planKeys` list (`files, newFiles, tests`); `alsoAllow` list; `lockfiles` list (`package-lock.json, npm-shrinkwrap.json, yarn.lock, pnpm-lock.yaml`) | `{"use":"git.changesMatchPlan","with":{"alsoAllow":"CHANGELOG.md"}}` |
344
+ | `git.commitsScoped` | Every commit touches only planned files and names the item | `base` text (`{repo.baseBranch}`); `planKeys` list (`files, newFiles, tests`); `alsoAllow` list; `lockfiles` list (`package-lock.json, npm-shrinkwrap.json, yarn.lock, pnpm-lock.yaml`); `mentions` text (`{item.id}`) | `{"use":"git.commitsScoped","with":{"mentions":"{item.id}"}}` |
345
+ | `git.sourceHasTests` | Each changed source file has a changed test (paired by name, or any) | `sources` list (`src/**/*.{js,jsx,ts,tsx,mjs,cjs}, lib/**/*.{js,jsx,ts,tsx,mjs,cjs}, !**/*.{test,spec}.*, !**/__tests__/**, !**/*.stories.*, !**/*.d.ts`); `tests` list (`**/*.{test,spec}.*, **/__tests__/**, test/**, tests/**`); `testPattern` list (`<dir>/<name>.{test,spec}.*, <dir>/__tests__/<name>.*, {test,tests}/**/<name>.{test,spec}.*, {test,tests}/**/<name>.*`); `mode` select (`paired`): `paired` or `any`; `exempt` list; `base` text (`{repo.baseBranch}`) | `{"use":"git.sourceHasTests","with":{"mode":"paired","exempt":"**/index.js"}}` |
346
+ | `git.noNewMatches` | e.g. no new TODO or console.log; lines already there don't count | `glob` list (required); `pattern` regex (required); `base` text (`{repo.baseBranch}`) | `{"use":"git.noNewMatches","with":{"glob":"src/**, !**/*.test.*","pattern":"console\\.log\\("}}` |
347
+ | `git.validateLeavesTreeClean` | Running the validate command leaves no file changed (no formatter --write, no npm install --save) | `command` text (`npm test`); `timeoutSec` number (`1800`); `allowDirtyBefore` boolean (`false`) | `{"use":"git.validateLeavesTreeClean","with":{"command":"npm run ci"}}` |
348
+
349
+ ### files
350
+
351
+ | Helper | Checks | Params (default) | Example step |
352
+ |---|---|---|---|
353
+ | `files.exist` | Paths in the workspace | `paths` list (required) | `{"use":"files.exist","with":{"paths":"README.md, src/index.js"}}` |
354
+ | `files.contain` | A file has some text in it | `path` path (required); `text` text (required) | `{"use":"files.contain","with":{"path":"CHANGELOG.md","text":"{item.id}"}}` |
355
+ | `files.noneMatch` | e.g. no console.log in src | `glob` glob (required); `pattern` regex (required) | `{"use":"files.noneMatch","with":{"glob":"src/**/*.js","pattern":"debugger"}}` |
356
+ | `files.maxGrowth` | A changed file stays under a size, and a big file doesn't grow much | `glob` list (`**/*.{js,jsx,ts,tsx,mjs,cjs}`); `maxLines` number (`800`); `maxAdded` number (`50`); `exempt` list; `base` text (`{repo.baseBranch}`) | `{"use":"files.maxGrowth","with":{"maxLines":800,"maxAdded":50}}` |
357
+
358
+ ### commands
359
+
360
+ | Helper | Checks | Params (default) | Example step |
361
+ |---|---|---|---|
362
+ | `commands.passes` | Exit 0 | `command` text (required); `timeoutSec` number (`120`) | `{"use":"commands.passes","with":{"command":"npm run build","timeoutSec":300}}` |
363
+ | `commands.outputMatches` | Its output matches a pattern | `command` text (required); `pattern` regex (required); `timeoutSec` number (`120`) | `{"use":"commands.outputMatches","with":{"command":"node --version","pattern":"^v(18\|20\|22)\\."}}` |
364
+
365
+ ### node
366
+
367
+ | Helper | Checks | Params (default) | Example step |
368
+ |---|---|---|---|
369
+ | `node.testsPass` | npm test, or a command | `command` text (`npm test`); `timeoutSec` number (`900`) | `{"use":"node.testsPass","with":{"command":"npm test"}}` |
370
+ | `node.lintPasses` | npm run lint, or a command | `command` text (`npm run lint`); `timeoutSec` number (`300`) | `{"use":"node.lintPasses"}` |
371
+ | `node.noNewDependencies` | package.json adds none since the base | `base` text (`{repo.baseBranch}`); `allow` list | `{"use":"node.noNewDependencies","with":{"allow":"@trops/dash-check"}}` |
372
+ | `node.lockfileExplained` | The lockfile changed only with a dependency (or only its version) | `base` text (`{repo.baseBranch}`); `lockfile` path (`package-lock.json`); `manifest` path | `{"use":"node.lockfileExplained"}` |
373
+ | `node.testScriptIsReal` | package.json's test script isn't a no-op, and can run tests | `script` text (`test`); `run` boolean (`false`); `minTests` number (`1`); `timeoutSec` number (`900`) | `{"use":"node.testScriptIsReal","with":{"run":true,"minTests":1}}` |
374
+ | `node.newTestsAreRun` | Every new test file is picked up by a test runner | `base` text (`{repo.baseBranch}`); `tests` list (`**/*.{test,spec}.{js,cjs,mjs,jsx,ts,tsx}`); `runnerFiles` list (`package.json`); `autoGlobs` list | `{"use":"node.newTestsAreRun","with":{"runnerFiles":"package.json, scripts/ci.sh","autoGlobs":"src/**/*.test.js"}}` |
375
+
376
+ ### github
377
+
378
+ | Helper | Checks | Params (default) | Example step |
379
+ |---|---|---|---|
380
+ | `github.prOpen` | The handoff's PR is open on GitHub | `prKey` text (`prUrl`) | `{"use":"github.prOpen"}` |
381
+ | `github.ciPassed` | Waits, with a deadline | `prKey` text (`prUrl`); `timeoutSec` number (`1200`); `noChecksAfterSec` number (`180`); `ifNoChecks` select (`fail`): `fail` or `pass` | `{"use":"github.ciPassed","with":{"timeoutSec":1200,"ifNoChecks":"fail"}}` |
382
+
383
+ ### tracker
384
+
385
+ | Helper | Checks | Params (default) | Example step |
386
+ |---|---|---|---|
387
+ | `tracker.ticketExists` | The work item is in the tracker | `provider` text (`jira`); `tool` text (`getJiraIssue`); `idArg` text (`issueIdOrKey`); `id` text (`{item.id}`) | `{"use":"tracker.ticketExists"}` |
388
+ | `tracker.ticketHasLabel` | The work item carries a label | `label` text (required); `provider` text (`jira`); `tool` text (`getJiraIssue`); `idArg` text (`issueIdOrKey`); `id` text (`{item.id}`) | `{"use":"tracker.ticketHasLabel","with":{"label":"factory"}}` |
389
+
297
390
  ## The CLI
298
391
 
299
392
  | Command | What it does |
@@ -331,6 +424,7 @@ A `.check.js` file also runs by itself, `node .dash/checks/validate.check.js`, t
331
424
  ## Use in Dash
332
425
 
333
426
  - **A repo check.** Commit `.dash/checks/<name>.check.js` (or `.check.json`) in a PR. A bot step `{ "kind": "repo", "name": "<name>" }` runs it from the repo's **base branch**, so a bot working on a branch can't change the check that judges it.
427
+ - **One helper on a bot.** A step `{ "kind": "helper", "use": "git.changesMatchPlan", "with": { … }, "handoffFrom": "handed" }` runs one helper with no file. `handoffFrom: "handed"` reads the handoff the bot was handed (a Coder's check reads the Planner's plan). Bots › Checks offers the factory and plan helpers; any other helper works too. Several helpers on a bot: `{ "kind": "recipe", "recipe": { … } }`.
334
428
  - **What the check sees.** Dash passes the job's item, workspace, picked rows and settings in the input. Those are `ctx.item`, `ctx.workspace`, `ctx.row` and `ctx.settings`.
335
429
  - **`ctx.tool`.** Dash answers `ctx.tool` through `DASH_TOOL_SOCKET`, a local socket that takes one JSON line `{ "id", "provider", "tool", "args" }` and answers `{ "id", "result" }` or `{ "id", "error" }`.
336
430
  - **The composer.** Dash's composer lists the palette from `dash-check --list-helpers --json`. It runs a recipe on a sample with `runRecipe` (Try it), and shows it as code with `recipeToCode` (View as code).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trops/dash-check",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Compose deterministic checks from small, described building blocks: Jest-style files, JSON recipes and helpers. Runs in Dash, in CI and on a laptop.",
5
5
  "license": "MIT",
6
6
  "author": "trops",