architecture-harness 0.12.0 ā 0.13.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.
- package/package.json +14 -4
- package/src/cli/bash-command-guard.mjs +25 -8
- package/src/cli/bash-command-guard.test.mjs +44 -0
- package/src/cli/branch-name.test.mjs +31 -0
- package/src/cli/check.mjs +5 -0
- package/src/cli/commit-msg.mjs +94 -0
- package/src/cli/commit-msg.test.mjs +60 -0
- package/src/cli/doctor.mjs +39 -5
- package/src/cli/doctor.test.mjs +18 -1
- package/src/cli/git-hooks.mjs +67 -0
- package/src/cli/git-hooks.test.mjs +85 -0
- package/src/cli/post-edit-gate.test.mjs +10 -0
- package/src/cli/powershell-command.mjs +3 -0
- package/src/cli/pr-check.mjs +74 -0
- package/src/cli/pr-check.test.mjs +59 -0
- package/src/cli/qc.mjs +8 -6
- package/src/cli/stop-gate.test.mjs +113 -0
- package/src/cli/templates.test.mjs +9 -0
- package/src/cli/work-order-guard.mjs +25 -1
- package/src/config.mjs +10 -7
- package/src/gates/config-floor.mjs +23 -8
- package/src/gates/config-floor.test.mjs +10 -0
- package/src/gates/english-source.mjs +1 -1
- package/templates/githooks/commit-msg +2 -1
- package/templates/github/workflows/ci.yml +7 -0
- package/src/cli/commit-attribution.mjs +0 -68
- package/src/cli/commit-attribution.test.mjs +0 -47
|
@@ -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
|
-
});
|