architecture-harness 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +14 -4
  2. package/src/cli/bash-command-guard.mjs +25 -8
  3. package/src/cli/bash-command-guard.test.mjs +44 -0
  4. package/src/cli/branch-name.test.mjs +31 -0
  5. package/src/cli/check.mjs +5 -0
  6. package/src/cli/commit-msg.mjs +94 -0
  7. package/src/cli/commit-msg.test.mjs +60 -0
  8. package/src/cli/dispatch-guard.mjs +78 -0
  9. package/src/cli/dispatch-guard.test.mjs +160 -0
  10. package/src/cli/dispatch-reminder.mjs +43 -0
  11. package/src/cli/dispatch-reminder.test.mjs +78 -0
  12. package/src/cli/dispatch-slot.mjs +70 -0
  13. package/src/cli/dispatch-slot.test.mjs +80 -0
  14. package/src/cli/dispatch.mjs +84 -0
  15. package/src/cli/dispatch.test.mjs +90 -0
  16. package/src/cli/doctor.mjs +39 -5
  17. package/src/cli/doctor.test.mjs +18 -1
  18. package/src/cli/edit-batch-state.mjs +5 -2
  19. package/src/cli/git-hooks.mjs +67 -0
  20. package/src/cli/git-hooks.test.mjs +85 -0
  21. package/src/cli/plugin-agents.test.mjs +54 -0
  22. package/src/cli/post-edit-gate.test.mjs +10 -0
  23. package/src/cli/powershell-command.mjs +3 -0
  24. package/src/cli/pr-check.mjs +74 -0
  25. package/src/cli/pr-check.test.mjs +59 -0
  26. package/src/cli/qc.mjs +8 -6
  27. package/src/cli/stop-gate.test.mjs +113 -0
  28. package/src/cli/templates.test.mjs +9 -0
  29. package/src/cli/work-order-guard.mjs +25 -1
  30. package/src/config.mjs +31 -7
  31. package/src/gates/config-floor.mjs +23 -8
  32. package/src/gates/config-floor.test.mjs +10 -0
  33. package/src/gates/english-source.mjs +1 -1
  34. package/templates/githooks/commit-msg +2 -1
  35. package/templates/github/workflows/ci.yml +7 -0
  36. package/src/cli/commit-attribution.mjs +0 -68
  37. package/src/cli/commit-attribution.test.mjs +0 -47
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # A tool is not an author. Checked here because a trailer is added at commit time and nowhere else.
2
+ # Conventional, English, and the attribution trailer when qc.config.json asks for it. Checked here,
3
+ # because a message is written at commit time and nowhere else.
3
4
  set -euo pipefail
4
5
  npx qc commit-msg "$1" || exit 1
@@ -5,7 +5,9 @@ jobs:
5
5
  gates:
6
6
  runs-on: ubuntu-latest
7
7
  steps:
8
+ # Full history: the threshold ratchet compares the registry with the merge base.
8
9
  - uses: actions/checkout@v5
10
+ with: { fetch-depth: 0 }
9
11
  - uses: actions/setup-node@v5
10
12
  with: { node-version-file: package.json }
11
13
  - run: corepack enable
@@ -14,6 +16,11 @@ jobs:
14
16
  # The structural gates. This step needs no package script of its own.
15
17
  - run: npx qc check
16
18
 
19
+ # A pull request names the issue it closes, and the issue predates it.
20
+ - if: github.event_name == 'pull_request'
21
+ run: npx qc pr-check
22
+ env: { GH_TOKEN: "${{ github.token }}" }
23
+
17
24
  # Uncomment each as the repository grows the thing it checks.
18
25
  # - run: pnpm typecheck
19
26
  # - run: pnpm lint
@@ -1,68 +0,0 @@
1
- // A commit message records who is accountable for a change. A tool is not, and a trailer naming
2
- // one adds a co-author who cannot answer a question about the code. The rule is widely stated and
3
- // widely ignored, because nothing checks it -- so this checks it, at the one moment it is cheap.
4
-
5
- const TRAILER = /^\s*(?:co-authored-by|signed-off-by|assisted-by|generated-by)\s*:\s*(.+)$/i;
6
-
7
- const DEFAULT_TOOLS = [
8
- "claude",
9
- "anthropic",
10
- "copilot",
11
- "chatgpt",
12
- "openai",
13
- "gpt-4",
14
- "gpt-5",
15
- "gemini",
16
- "cursor",
17
- "codeium",
18
- "devin",
19
- "aider",
20
- "windsurf",
21
- "bot@",
22
- "noreply@anthropic.com",
23
- ];
24
-
25
- // A marketing footer is the other half of the same habit.
26
- const DEFAULT_FOOTERS = [/generated with .*claude/i, /co-?authored by .*(claude|copilot|chatgpt)/i, /šŸ¤–/u];
27
-
28
- /**
29
- * @param {string} message the full commit message
30
- * @param {{tools?: string[], footers?: RegExp[]}} [options]
31
- * @returns {{path: string, rule: string, detail: string}[]}
32
- */
33
- export function checkCommitAttribution(message, options = {}) {
34
- const tools = (options.tools ?? DEFAULT_TOOLS).map((name) => name.toLowerCase());
35
- const footers = options.footers ?? DEFAULT_FOOTERS;
36
- const problems = [];
37
-
38
- message.split("\n").forEach((line, index) => {
39
- const trailer = TRAILER.exec(line);
40
- if (trailer) {
41
- const value = trailer[1].toLowerCase();
42
- const tool = tools.find((name) => value.includes(name));
43
- if (tool) {
44
- problems.push({
45
- path: "COMMIT_MSG",
46
- rule: "tool-as-author",
47
- detail: `line ${index + 1} credits "${trailer[1].trim()}". A tool is not an author — the committer is accountable for the change.`,
48
- });
49
- }
50
- return;
51
- }
52
- if (footers.some((pattern) => pattern.test(line))) {
53
- problems.push({
54
- path: "COMMIT_MSG",
55
- rule: "tool-footer",
56
- detail: `line ${index + 1} advertises the tool that wrote the change. The message says what changed and why, nothing else.`,
57
- });
58
- }
59
- });
60
- return problems;
61
- }
62
-
63
- /** Strips every line the check would reject, for `--fix` and for rewriting an unpushed branch. */
64
- export function withoutAttribution(message, options = {}) {
65
- const rejected = new Set(checkCommitAttribution(message, options).map((problem) => problem.detail.match(/^line (\d+)/)[1]));
66
- const kept = message.split("\n").filter((_, index) => !rejected.has(String(index + 1)));
67
- return `${kept.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd()}\n`;
68
- }
@@ -1,47 +0,0 @@
1
- import { strict as assert } from "node:assert";
2
- import { test } from "node:test";
3
- import { checkCommitAttribution, withoutAttribution } from "./commit-attribution.mjs";
4
-
5
- const plain = "fix(photos): the timeline rests groups below the sticky header\n\nThe seek landed under it.\n";
6
-
7
- test("an ordinary message passes", () => {
8
- assert.deepEqual(checkCommitAttribution(plain), []);
9
- });
10
-
11
- test("a Claude co-author trailer is refused", () => {
12
- const [problem] = checkCommitAttribution(`${plain}\nCo-Authored-By: Claude Opus 5 <noreply@anthropic.com>\n`);
13
- assert.equal(problem.rule, "tool-as-author");
14
- assert.match(problem.detail, /A tool is not an author/);
15
- });
16
-
17
- test("other assistants are refused by the same rule", () => {
18
- for (const tool of ["Copilot <bot@github.com>", "ChatGPT <x@openai.com>", "Cursor <a@cursor.sh>", "Devin <d@cognition.ai>"]) {
19
- assert.equal(checkCommitAttribution(`${plain}\nCo-Authored-By: ${tool}\n`).length, 1, tool);
20
- }
21
- });
22
-
23
- test("a human co-author is never refused", () => {
24
- assert.deepEqual(checkCommitAttribution(`${plain}\nCo-Authored-By: Hieu Nguyen <hieu.nguyen@arent3d.com>\n`), []);
25
- });
26
-
27
- test("the marketing footer is refused too, trailer or not", () => {
28
- const [problem] = checkCommitAttribution(`${plain}\nšŸ¤– Generated with Claude Code\n`);
29
- assert.equal(problem.rule, "tool-footer");
30
- });
31
-
32
- test("stripping leaves the message intact and the trailers gone", () => {
33
- const dirty = `${plain}\nCo-Authored-By: Claude <noreply@anthropic.com>\nšŸ¤– Generated with Claude Code\n`;
34
- const clean = withoutAttribution(dirty);
35
- assert.deepEqual(checkCommitAttribution(clean), []);
36
- assert.match(clean, /timeline rests groups/);
37
- assert.doesNotMatch(clean, /Claude/);
38
- });
39
-
40
- test("stripping a message that needs nothing changes nothing but the trailing newline", () => {
41
- assert.equal(withoutAttribution(plain).trim(), plain.trim());
42
- });
43
-
44
- test("a Signed-off-by from a person survives, from a tool does not", () => {
45
- assert.deepEqual(checkCommitAttribution(`${plain}\nSigned-off-by: Hieu <h@arent3d.com>\n`), []);
46
- assert.equal(checkCommitAttribution(`${plain}\nSigned-off-by: Claude <noreply@anthropic.com>\n`).length, 1);
47
- });