@produck/agent-toolkit 0.4.0 → 0.6.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.
@@ -3,7 +3,8 @@ Usage:
3
3
 
4
4
  Rules:
5
5
  - In monorepo mode, a section header is required before tagged lines
6
- - Non-empty lines must be either a section header (for example workspace: or @scope/pkg:) or start with [TAG]
6
+ - In monorepo mode, section headers must use one of: workspace:, *:, or a workspace package name section (for example @produck/agent-toolkit:)
7
+ - Non-empty lines must be either a section header or start with [TAG]
7
8
  - If section headers are used, each section header must be followed by at least one tagged line
8
9
  - No empty lines are allowed
9
10
  - Optional target form: [TAG] <target>: <summary>
@@ -7,10 +7,12 @@ import { printTextResource } from '../shared/text-resource.mjs';
7
7
 
8
8
  const ALLOWED_TAGS = ['INIT', 'ADD', 'REMOVE', 'FIX', 'REFACTOR', 'UPGRADE', 'PUBLISH'];
9
9
  const ALLOWED_TARGETS = ['docs', 'test', 'ci', 'deps', 'api', 'schema', 'infra', 'fmt'];
10
- const SECTION_HEADER_RE = /^(?:@[\w.-]+\/)?[\w.-]+:$/;
10
+ const SECTION_HEADER_RE = /^(?:\*|(?:@[\w.-]+\/)?[\w.-]+):$/;
11
11
  const COMMAND_DIR = path.dirname(fileURLToPath(import.meta.url));
12
12
  const HELP_FILE = path.resolve(COMMAND_DIR, 'help.txt');
13
13
  const ROOT_PACKAGE_FILE = path.resolve(COMMAND_DIR, '../../../../../package.json');
14
+ const WORKSPACE_SCOPE = 'workspace';
15
+ const WILDCARD_SCOPE = '*';
14
16
 
15
17
  export function printValidateCommitMsgHelp() {
16
18
  printTextResource(HELP_FILE);
@@ -68,7 +70,47 @@ function isMonorepoRoot() {
68
70
  }
69
71
  }
70
72
 
71
- function validateSectionFormat(lines) {
73
+ function getMonorepoAllowedSectionScopes() {
74
+ if (!fs.existsSync(ROOT_PACKAGE_FILE)) {
75
+ return null;
76
+ }
77
+
78
+ let rootPackage;
79
+ try {
80
+ rootPackage = JSON.parse(fs.readFileSync(ROOT_PACKAGE_FILE, 'utf8'));
81
+ } catch {
82
+ return null;
83
+ }
84
+
85
+ if (!Array.isArray(rootPackage.workspaces) || rootPackage.workspaces.length === 0) {
86
+ return null;
87
+ }
88
+
89
+ const rootDir = path.dirname(ROOT_PACKAGE_FILE);
90
+ const allowedScopes = new Set([WORKSPACE_SCOPE, WILDCARD_SCOPE]);
91
+
92
+ for (const workspaceEntry of rootPackage.workspaces) {
93
+ const workspacePath = path.resolve(rootDir, String(workspaceEntry));
94
+ const workspacePackageJsonPath = path.resolve(workspacePath, 'package.json');
95
+
96
+ if (!fs.existsSync(workspacePackageJsonPath)) {
97
+ continue;
98
+ }
99
+
100
+ try {
101
+ const workspacePackage = JSON.parse(fs.readFileSync(workspacePackageJsonPath, 'utf8'));
102
+ if (typeof workspacePackage.name === 'string' && workspacePackage.name.trim() !== '') {
103
+ allowedScopes.add(workspacePackage.name.trim());
104
+ }
105
+ } catch {
106
+ continue;
107
+ }
108
+ }
109
+
110
+ return allowedScopes;
111
+ }
112
+
113
+ function validateSectionFormat(lines, allowedSectionScopes = null) {
72
114
  const errors = [];
73
115
  let currentSection = '';
74
116
  let currentSectionLineNo = 0;
@@ -90,6 +132,13 @@ function validateSectionFormat(lines) {
90
132
  );
91
133
  }
92
134
 
135
+ const sectionName = line.trim().slice(0, -1);
136
+ if (allowedSectionScopes && !allowedSectionScopes.has(sectionName)) {
137
+ errors.push(
138
+ `Line ${lineNo}: section header "${line.trim()}" is not allowed in monorepo mode`,
139
+ );
140
+ }
141
+
93
142
  currentSection = line.trim();
94
143
  currentSectionLineNo = lineNo;
95
144
  currentSectionHasTaggedLine = false;
@@ -143,6 +192,7 @@ export function runValidateCommitMsg(options) {
143
192
  }
144
193
 
145
194
  const mustUseSectionHeaders = isMonorepoRoot();
195
+ const allowedSectionScopes = mustUseSectionHeaders ? getMonorepoAllowedSectionScopes() : null;
146
196
  const hasSectionHeaders = lines.some((line) => isSectionHeaderLine(line));
147
197
 
148
198
  // [PUBLISH] is generated by lerna and is always a repo-wide tag.
@@ -161,7 +211,7 @@ export function runValidateCommitMsg(options) {
161
211
  process.exit(1);
162
212
  }
163
213
 
164
- const errors = hasSectionHeaders ? validateSectionFormat(lines) : [];
214
+ const errors = hasSectionHeaders ? validateSectionFormat(lines, allowedSectionScopes) : [];
165
215
  if (!hasSectionHeaders) {
166
216
  for (let i = 0; i < lines.length; i += 1) {
167
217
  const err = validateCommitLine(lines[i], i + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produck/agent-toolkit",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Central CLI toolkit for organization AI execution workflows",
5
5
  "type": "module",
6
6
  "repository": {
@@ -13,12 +13,10 @@
13
13
  },
14
14
  "scripts": {
15
15
  "prepack": "node ./bin/build-publish-assets.mjs",
16
- "coverage": "npm exec --yes -- c8 --reporter=lcov --reporter=html --reporter=text-summary node --test test/index.mjs",
17
- "coverage:check": "npm exec --yes -- c8 --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 node --test test/index.mjs",
18
16
  "test": "node --test test/index.mjs",
19
17
  "verify": "node ./bin/agent-toolkit.mjs --help && node ./bin/agent-toolkit.mjs preflight --cwd . --require package.json",
20
18
  "pack:check": "npm pack --dry-run",
21
- "produck:coverage": "c8@11.0.0 --reporter=lcov --reporter=html --reporter=text-summary npm test"
19
+ "produck:coverage": "c8 --reporter=lcov --reporter=html --reporter=text-summary npm test"
22
20
  },
23
21
  "files": [
24
22
  "bin",
@@ -31,8 +29,8 @@
31
29
  "node": ">=18.0.0"
32
30
  },
33
31
  "license": "MIT",
34
- "gitHead": "c0aabcec12d70234cfc15cb741fe4ffcf5e4601e",
35
32
  "devDependencies": {
36
33
  "c8": "11.0.0"
37
- }
34
+ },
35
+ "gitHead": "8618167ffe15e39c5a7b350903f0fd8861902a62"
38
36
  }
@@ -41,14 +41,31 @@ Notes:
41
41
  `npm exec -- agent-toolkit sync-coverage-script --cwd .`.
42
42
  - Use central remediation command to deploy local anti-drift hook baseline:
43
43
  `npm exec -- agent-toolkit sync-husky-hooks --cwd .`.
44
+ - Use central remediation command to deploy root format script/config
45
+ baseline:
46
+ `npm exec -- agent-toolkit sync-prettier-config --cwd .`.
47
+ - Use central remediation command to deploy root lint script/config and
48
+ eslint integration baseline:
49
+ `npm exec -- agent-toolkit sync-eslint-config --cwd .`.
50
+ - Use central remediation command to deploy root shared scripts/dependencies
51
+ baseline:
52
+ `npm exec -- agent-toolkit sync-workspace-config --cwd .`.
44
53
  - `c8` execution baseline for deployed coverage scripts is fixed to the
45
54
  version specified in `tooling-version-baseline.json`.
46
55
  - Downstream repositories must not use unversioned `npx c8` or `c8@latest`
47
56
  in shared scripts/CI.
48
- - Root `devDependencies.c8` and root `devDependencies.lerna` must be pinned
49
- to organization baseline fixed versions via `agent-toolkit sync-husky-hooks`.
57
+ - Root local governance must pin `devDependencies.c8`,
58
+ `devDependencies.husky`, `devDependencies.lerna`, and
59
+ `devDependencies.@produck/agent-toolkit` via
60
+ `agent-toolkit sync-workspace-config`.
61
+ - Root local governance must pin `devDependencies.@produck/eslint-rules`
62
+ via `agent-toolkit sync-eslint-config`.
50
63
 
51
64
  - Testing strategy and framework are repository-defined.
65
+ - `verify` scripts are optional repository-local health checks and are not
66
+ organization-required script keys.
67
+ - `verify` is not part of organization commit gates; style gates remain
68
+ repository `format:check` and `lint` policy.
52
69
  - `test` script implementation is repository-defined and is not overwritten by
53
70
  organization coverage remediation.
54
71
  - Repositories should keep `npm run test` and `npm run produck:coverage`
@@ -70,7 +87,15 @@ Central toolkit command role model:
70
87
  governance and is mandatory in monorepo mode.
71
88
  - `agent-toolkit sync-husky-hooks` is the hard guard for local anti-drift hook
72
89
  governance and is mandatory in monorepo mode.
73
- - For simplified downstream execution of mandatory flow (1 -> 2 -> 3 -> 4),
90
+ - `agent-toolkit sync-prettier-config` is the hard guard for root format
91
+ script/config governance and is mandatory in monorepo mode.
92
+ - `agent-toolkit sync-eslint-config` is the hard guard for root lint
93
+ script/config and eslint integration governance and is mandatory in monorepo
94
+ mode.
95
+ - `agent-toolkit sync-workspace-config` is the hard guard for root shared
96
+ scripts/dependencies governance and is mandatory in monorepo mode.
97
+ - For simplified downstream execution of mandatory flow (1 -> 2 -> 3 -> 4 ->
98
+ 5 -> 6 -> 7),
74
99
  use:
75
100
  `npm exec -- agent-toolkit`.
76
101
  - Equivalent explicit form:
@@ -157,18 +182,38 @@ Script placement:
157
182
  and `lint` orchestration scripts.
158
183
  - Root `package.json` must reserve `produck:precommit-check` for organization
159
184
  anti-drift gate with required value:
160
- `npm run format:check && npm run lint`.
185
+ `npm run produck:format && npm run produck:lint`.
161
186
  - Root `package.json` must reserve `prepare` for husky setup with required
162
187
  value: `husky`.
188
+ - Root `package.json` must reserve `produck:format` and `produck:lint` for
189
+ organization-controlled format/lint gates.
163
190
  - `publish` may be defined at root or package level based on release workflow.
164
191
  - Workspace subpackage `produck:coverage` scripts must be synchronized by
165
192
  `agent-toolkit sync-coverage-script`.
166
193
  - Root local hook governance must be synchronized by
167
194
  `agent-toolkit sync-husky-hooks`.
168
- - Root local hook governance must pin root `devDependencies.c8`,
169
- `devDependencies.husky`, `devDependencies.lerna`, and
195
+ - Root local format governance must be synchronized by
196
+ `agent-toolkit sync-prettier-config`.
197
+ - Root local lint governance must be synchronized by
198
+ `agent-toolkit sync-eslint-config`.
199
+ - Root local shared script/dependency governance must be synchronized by
200
+ `agent-toolkit sync-workspace-config`.
201
+ - Root local shared script/dependency governance must pin root
202
+ `devDependencies.c8`,
203
+ `devDependencies.husky`, `devDependencies.lerna`,
170
204
  `devDependencies.@produck/agent-toolkit` via
171
- `agent-toolkit sync-husky-hooks`.
205
+ `agent-toolkit sync-workspace-config`.
206
+ - Root local shared script/dependency governance must initialize
207
+ `scripts.produck:coverage` with workspace-level execution behavior:
208
+ attempt `test` on all workspace packages using `--workspaces --if-present`.
209
+ - Root local shared script/dependency governance must initialize `.c8rc.json`
210
+ via `agent-toolkit sync-workspace-config`.
211
+ - Root local format governance must initialize `.prettierrc` and
212
+ `scripts.produck:format` via `agent-toolkit sync-prettier-config`.
213
+ - Root local lint governance must initialize `eslint.config.mjs`,
214
+ `scripts.produck:lint`, and `devDependencies.@produck/eslint-rules`
215
+ (including append-mode integration for existing eslint config) via
216
+ `agent-toolkit sync-eslint-config`.
172
217
  - Root `package.json` must define a `produck:baseline` script for organization
173
218
  baseline enforcement:
174
219
  ```json
@@ -28,6 +28,11 @@ Monorepo format (required for multi-package repositories):
28
28
 
29
29
  - Package/workspace labels appear as **section headers** followed by a colon
30
30
  (format: `package-name:` or `@scope/package:`).
31
+ - Section scope naming convention:
32
+ - For subpackage changes, use the package `name` as section header
33
+ (for example `@produck/agent-toolkit:`).
34
+ - For non-subpackage or root-level changes, use `workspace:`.
35
+ - For complex mixed commits across multiple scopes, `*:` is allowed.
31
36
  - All lines under a package header belong to that package.
32
37
  - Every line under a package header must start with `[TAG]`.
33
38
  - No empty lines between tagged lines within a package section.
@@ -172,6 +177,8 @@ Commit precheck gate (AI-agent required, human recommended):
172
177
  - For AI-agent-authored operations, complete repository style gates before both
173
178
  `git commit` and `git commit --amend` (for example `format:check` and
174
179
  `lint`).
180
+ - For AI-agent-authored operations, `git commit --no-verify` and
181
+ `git commit --amend --no-verify` are forbidden.
175
182
  - For human engineer-authored operations, style gates are recommended baseline
176
183
  practice unless repository-specific hooks/CI enforce them.
177
184
  - Temporary non-executable state or failing tests are allowed for