@produck/agent-toolkit 0.6.0 → 0.8.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/README.md +74 -43
- package/bin/agent-toolkit.mjs +26 -33
- package/bin/build-publish-assets.mjs +54 -5
- package/bin/command/enforce-node-baseline/help.txt +12 -10
- package/bin/command/enforce-node-baseline/index.mjs +23 -15
- package/bin/command/main/help.txt +6 -5
- package/bin/command/preflight/help.txt +1 -1
- package/bin/command/preflight/index.mjs +1 -1
- package/bin/command/{sync-coverage-script → sync-coverage}/help.txt +2 -1
- package/bin/command/{sync-coverage-script → sync-coverage}/index.mjs +116 -19
- package/bin/command/sync-editorconfig/index.mjs +10 -153
- package/bin/command/{sync-prettier-config → sync-format}/help.txt +4 -2
- package/bin/command/sync-format/index.mjs +222 -0
- package/bin/command/{sync-workspace-config → sync-git}/help.txt +10 -6
- package/bin/command/sync-git/index.mjs +424 -0
- package/bin/command/sync-install/help.txt +14 -0
- package/bin/command/{sync-prettier-config → sync-install}/index.mjs +26 -50
- package/bin/command/sync-instructions/index.mjs +2 -22
- package/bin/command/{sync-eslint-config → sync-lint}/help.txt +2 -2
- package/bin/command/{sync-eslint-config → sync-lint}/index.mjs +3 -4
- package/bin/command/sync-publish/help.txt +18 -0
- package/bin/command/sync-publish/index.mjs +157 -0
- package/bin/command/validate-commit-msg/index.mjs +30 -2
- package/package.json +3 -5
- package/publish-assets/gitattributes +5 -0
- package/publish-assets/gitignore +137 -0
- package/publish-assets/instructions/produck/00-produck-base.instructions.md +44 -58
- package/publish-assets/instructions/produck/10-produck-node.instructions.md +59 -82
- package/publish-assets/instructions/produck/12-produck-test.instructions.md +94 -0
- package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +17 -50
- package/publish-assets/instructions/produck/20-produck-commit.instructions.md +2 -2
- package/publish-assets/instructions/produck/tooling-version-baseline.json +14 -2
- package/publish-assets/prettierignore +2 -0
- package/bin/command/sync-husky-hooks/help.txt +0 -14
- package/bin/command/sync-husky-hooks/index.mjs +0 -89
- package/bin/command/sync-workspace-config/index.mjs +0 -290
|
@@ -19,15 +19,19 @@ applyTo: '**'
|
|
|
19
19
|
|
|
20
20
|
Required script keys:
|
|
21
21
|
|
|
22
|
-
- `
|
|
22
|
+
- `produck:install`
|
|
23
23
|
- `test`
|
|
24
24
|
- `produck:coverage`
|
|
25
|
-
- `lint`
|
|
25
|
+
- `produck:lint`
|
|
26
26
|
- `publish`
|
|
27
27
|
|
|
28
28
|
Notes:
|
|
29
29
|
|
|
30
30
|
- Script key names are fixed and must match exactly.
|
|
31
|
+
- Keep the script key name `produck:install` (organization-reserved key).
|
|
32
|
+
- The required value for `produck:install` is governed by
|
|
33
|
+
`agent-toolkit sync-install`; see the Monorepo mode section below for the
|
|
34
|
+
canonical value.
|
|
31
35
|
- `publish` may be a no-op when repository-specific release workflow does not
|
|
32
36
|
use npm publishing.
|
|
33
37
|
- Coverage governance policy:
|
|
@@ -37,19 +41,18 @@ Notes:
|
|
|
37
41
|
baseline.
|
|
38
42
|
- Source of truth for tooling versions/template:
|
|
39
43
|
`.github/distribution/produck/tooling-version-baseline.json`.
|
|
44
|
+
- Use central remediation command to deploy root install script baseline:
|
|
45
|
+
`npm exec -- agent-toolkit sync-install --cwd .`.
|
|
40
46
|
- Use central remediation command to deploy coverage scripts:
|
|
41
|
-
`npm exec -- agent-toolkit sync-coverage
|
|
47
|
+
`npm exec -- agent-toolkit sync-coverage --cwd .`.
|
|
42
48
|
- Use central remediation command to deploy local anti-drift hook baseline:
|
|
43
|
-
`npm exec -- agent-toolkit sync-
|
|
49
|
+
`npm exec -- agent-toolkit sync-git --cwd .`.
|
|
44
50
|
- Use central remediation command to deploy root format script/config
|
|
45
51
|
baseline:
|
|
46
|
-
`npm exec -- agent-toolkit sync-
|
|
52
|
+
`npm exec -- agent-toolkit sync-format --cwd .`.
|
|
47
53
|
- Use central remediation command to deploy root lint script/config and
|
|
48
54
|
eslint integration baseline:
|
|
49
|
-
`npm exec -- agent-toolkit sync-
|
|
50
|
-
- Use central remediation command to deploy root shared scripts/dependencies
|
|
51
|
-
baseline:
|
|
52
|
-
`npm exec -- agent-toolkit sync-workspace-config --cwd .`.
|
|
55
|
+
`npm exec -- agent-toolkit sync-lint --cwd .`.
|
|
53
56
|
- `c8` execution baseline for deployed coverage scripts is fixed to the
|
|
54
57
|
version specified in `tooling-version-baseline.json`.
|
|
55
58
|
- Downstream repositories must not use unversioned `npx c8` or `c8@latest`
|
|
@@ -57,15 +60,15 @@ Notes:
|
|
|
57
60
|
- Root local governance must pin `devDependencies.c8`,
|
|
58
61
|
`devDependencies.husky`, `devDependencies.lerna`, and
|
|
59
62
|
`devDependencies.@produck/agent-toolkit` via
|
|
60
|
-
`agent-toolkit sync-
|
|
63
|
+
`agent-toolkit sync-git`.
|
|
61
64
|
- Root local governance must pin `devDependencies.@produck/eslint-rules`
|
|
62
|
-
via `agent-toolkit sync-
|
|
65
|
+
via `agent-toolkit sync-lint`.
|
|
63
66
|
|
|
64
67
|
- Testing strategy and framework are repository-defined.
|
|
65
68
|
- `verify` scripts are optional repository-local health checks and are not
|
|
66
69
|
organization-required script keys.
|
|
67
70
|
- `verify` is not part of organization commit gates; style gates remain
|
|
68
|
-
repository `format
|
|
71
|
+
repository `produck:format` and `produck:lint` policy.
|
|
69
72
|
- `test` script implementation is repository-defined and is not overwritten by
|
|
70
73
|
organization coverage remediation.
|
|
71
74
|
- Repositories should keep `npm run test` and `npm run produck:coverage`
|
|
@@ -73,7 +76,7 @@ Notes:
|
|
|
73
76
|
- For intermediate commits, temporary non-executable state or failing tests are
|
|
74
77
|
allowed.
|
|
75
78
|
- Commit prechecks still require passing repository style gates (for example
|
|
76
|
-
`format
|
|
79
|
+
`produck:format` and `produck:lint`).
|
|
77
80
|
|
|
78
81
|
Central toolkit command role model:
|
|
79
82
|
|
|
@@ -83,19 +86,20 @@ Central toolkit command role model:
|
|
|
83
86
|
but do not assume it can fully prevent AI hallucination or iterative drift.
|
|
84
87
|
- `agent-toolkit preflight` is the hard guard for organization engineering
|
|
85
88
|
baseline and is mandatory for required baseline checks.
|
|
86
|
-
- `agent-toolkit sync-
|
|
89
|
+
- `agent-toolkit sync-install` is the hard guard for root install script
|
|
90
|
+
governance and is mandatory in monorepo mode.
|
|
91
|
+
- `agent-toolkit sync-coverage` is the hard guard for monorepo coverage
|
|
87
92
|
governance and is mandatory in monorepo mode.
|
|
88
|
-
- `agent-toolkit sync-
|
|
93
|
+
- `agent-toolkit sync-git` is the hard guard for local anti-drift hook
|
|
89
94
|
governance and is mandatory in monorepo mode.
|
|
90
|
-
- `agent-toolkit sync-
|
|
95
|
+
- `agent-toolkit sync-format` is the hard guard for root format
|
|
91
96
|
script/config governance and is mandatory in monorepo mode.
|
|
92
|
-
- `agent-toolkit sync-
|
|
97
|
+
- `agent-toolkit sync-lint` is the hard guard for root lint
|
|
93
98
|
script/config and eslint integration governance and is mandatory in monorepo
|
|
94
99
|
mode.
|
|
95
|
-
- `agent-toolkit sync-
|
|
96
|
-
|
|
97
|
-
- For simplified downstream execution of mandatory flow (1 -> 2 ->
|
|
98
|
-
5 -> 6 -> 7),
|
|
100
|
+
- `agent-toolkit sync-publish` is the hard guard for root publish script
|
|
101
|
+
governance when `lerna.json` is present.
|
|
102
|
+
- For simplified downstream execution of mandatory flow (1 -> 2 -> ... -> 9),
|
|
99
103
|
use:
|
|
100
104
|
`npm exec -- agent-toolkit`.
|
|
101
105
|
- Equivalent explicit form:
|
|
@@ -112,62 +116,30 @@ Central toolkit command role model:
|
|
|
112
116
|
interpreter workflows for parsing/filtering over brittle OS-shell pipelines.
|
|
113
117
|
- For human engineers, `run-capture` and `summarize-log` are optional helpers.
|
|
114
118
|
|
|
115
|
-
Test authoring baseline
|
|
116
|
-
|
|
117
|
-
- Prefer Node.js standard library test runner (`node:test`) with `describe` and
|
|
118
|
-
`it`.
|
|
119
|
-
- Each test case must be independently executable.
|
|
120
|
-
- Test cases must not depend on execution order or state from other cases.
|
|
121
|
-
- New test debugging should use local `only` mode for scoped regression.
|
|
122
|
-
- After debugging, remove all `only` markers before final validation.
|
|
119
|
+
Test authoring baseline:
|
|
123
120
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
1. Add `{ only: true }` to the target `describe/it` and all ancestor
|
|
127
|
-
`describe` blocks.
|
|
128
|
-
2. Run `node --test --test-only test/index.mjs`.
|
|
129
|
-
3. Remove all `only` markers.
|
|
130
|
-
4. Run full regression via repository standard test command.
|
|
121
|
+
- See [Test Authoring Baseline](12-produck-test.instructions.md) for the full
|
|
122
|
+
test writing, structure, debug, and coverage workflow rules.
|
|
131
123
|
|
|
132
124
|
Script and output directory policy:
|
|
133
125
|
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
equivalent) and ignored by git.
|
|
139
|
-
- Temporary debug scripts should not be committed.
|
|
140
|
-
- `.github/` should not be used as a temporary script workspace.
|
|
126
|
+
- Follow script/output placement and lifecycle policy from
|
|
127
|
+
`00-produck-base.instructions.md`.
|
|
128
|
+
- For monorepo shared configuration and root workspace practices, follow
|
|
129
|
+
`15-produck-workspace.instructions.md`.
|
|
141
130
|
|
|
142
131
|
Required ignore baseline:
|
|
143
132
|
|
|
144
133
|
- Each Node.js repository must include a root `.gitignore`.
|
|
145
|
-
-
|
|
146
|
-
|
|
147
|
-
-
|
|
148
|
-
|
|
149
|
-
- The root `.gitignore` should at minimum ignore:
|
|
150
|
-
- `node_modules/`
|
|
151
|
-
- `coverage/`
|
|
152
|
-
- `.env`
|
|
153
|
-
- `.env.*`
|
|
154
|
-
- npm logs (for example `npm-debug.log*`)
|
|
155
|
-
- OS/editor noise (for example `.DS_Store`, `Thumbs.db`, `.vscode/` when
|
|
156
|
-
workspace settings are not intended to be shared)
|
|
134
|
+
- Baseline template and required minimum entries follow
|
|
135
|
+
`00-produck-base.instructions.md`.
|
|
136
|
+
- Monorepo centralization policy and workspace-specific ignore guidance follow
|
|
137
|
+
`15-produck-workspace.instructions.md`.
|
|
157
138
|
|
|
158
139
|
Team conventions for `.gitignore`:
|
|
159
140
|
|
|
160
|
-
-
|
|
161
|
-
|
|
162
|
-
- Do not remove baseline entries from the GitHub template unless repository
|
|
163
|
-
owners document a justified exception.
|
|
164
|
-
- Organization-approved team extension entries are:
|
|
165
|
-
- `*.ign*` (manually created local directories/files that should not be
|
|
166
|
-
committed)
|
|
167
|
-
- `*.gen*` (generated artifacts created by program execution, for example
|
|
168
|
-
during tests)
|
|
169
|
-
- Append these team entries under a dedicated team block at the end of the root
|
|
170
|
-
`.gitignore`.
|
|
141
|
+
- Team extension entries and placement rules follow
|
|
142
|
+
`00-produck-base.instructions.md`.
|
|
171
143
|
|
|
172
144
|
## Monorepo mode
|
|
173
145
|
|
|
@@ -178,42 +150,46 @@ Repository layout:
|
|
|
178
150
|
|
|
179
151
|
Script placement:
|
|
180
152
|
|
|
181
|
-
- Root `package.json` must provide `
|
|
182
|
-
and `lint` orchestration scripts.
|
|
183
|
-
- Root `package.json` must reserve `produck:
|
|
153
|
+
- Root `package.json` must provide `produck:install`, `test`, `produck:coverage`,
|
|
154
|
+
and `produck:lint` orchestration scripts.
|
|
155
|
+
- Root `package.json` must reserve `produck:commit:check` for organization
|
|
184
156
|
anti-drift gate with required value:
|
|
185
157
|
`npm run produck:format && npm run produck:lint`.
|
|
186
158
|
- Root `package.json` must reserve `prepare` for husky setup with required
|
|
187
159
|
value: `husky`.
|
|
188
160
|
- Root `package.json` must reserve `produck:format` and `produck:lint` for
|
|
189
161
|
organization-controlled format/lint gates.
|
|
162
|
+
- Root `package.json` must reserve `produck:publish` for organization-controlled
|
|
163
|
+
publish gate when `lerna.json` is present (governed by
|
|
164
|
+
`agent-toolkit sync-publish`).
|
|
190
165
|
- `publish` may be defined at root or package level based on release workflow.
|
|
191
166
|
- Workspace subpackage `produck:coverage` scripts must be synchronized by
|
|
192
|
-
`agent-toolkit sync-coverage
|
|
167
|
+
`agent-toolkit sync-coverage`.
|
|
193
168
|
- Root local hook governance must be synchronized by
|
|
194
|
-
`agent-toolkit sync-
|
|
169
|
+
`agent-toolkit sync-git`.
|
|
170
|
+
- Root local shared script governance must initialize
|
|
171
|
+
`scripts.produck:install` with required value `npm -v && npm install`
|
|
172
|
+
via `agent-toolkit sync-install`.
|
|
195
173
|
- Root local format governance must be synchronized by
|
|
196
|
-
`agent-toolkit sync-
|
|
174
|
+
`agent-toolkit sync-format`.
|
|
197
175
|
- Root local lint governance must be synchronized by
|
|
198
|
-
`agent-toolkit sync-
|
|
199
|
-
- Root local shared script/dependency governance must be synchronized by
|
|
200
|
-
`agent-toolkit sync-workspace-config`.
|
|
176
|
+
`agent-toolkit sync-lint`.
|
|
201
177
|
- Root local shared script/dependency governance must pin root
|
|
202
178
|
`devDependencies.c8`,
|
|
203
179
|
`devDependencies.husky`, `devDependencies.lerna`,
|
|
204
180
|
`devDependencies.@produck/agent-toolkit` via
|
|
205
|
-
`agent-toolkit sync-
|
|
181
|
+
`agent-toolkit sync-git`.
|
|
206
182
|
- Root local shared script/dependency governance must initialize
|
|
207
183
|
`scripts.produck:coverage` with workspace-level execution behavior:
|
|
208
184
|
attempt `test` on all workspace packages using `--workspaces --if-present`.
|
|
209
185
|
- Root local shared script/dependency governance must initialize `.c8rc.json`
|
|
210
|
-
via `agent-toolkit sync-
|
|
186
|
+
via `agent-toolkit sync-coverage`.
|
|
211
187
|
- Root local format governance must initialize `.prettierrc` and
|
|
212
|
-
`scripts.produck:format` via `agent-toolkit sync-
|
|
188
|
+
`scripts.produck:format` via `agent-toolkit sync-format`.
|
|
213
189
|
- Root local lint governance must initialize `eslint.config.mjs`,
|
|
214
190
|
`scripts.produck:lint`, and `devDependencies.@produck/eslint-rules`
|
|
215
191
|
(including append-mode integration for existing eslint config) via
|
|
216
|
-
`agent-toolkit sync-
|
|
192
|
+
`agent-toolkit sync-lint`.
|
|
217
193
|
- Root `package.json` must define a `produck:baseline` script for organization
|
|
218
194
|
baseline enforcement:
|
|
219
195
|
```json
|
|
@@ -240,7 +216,8 @@ Root workspace `package.json` minimal baseline (required):
|
|
|
240
216
|
|
|
241
217
|
- `private`: `true`
|
|
242
218
|
- `workspaces` (explicit package path list only)
|
|
243
|
-
- `scripts` with at least: `
|
|
219
|
+
- `scripts` with at least: `produck:install`, `test`, `produck:coverage`,
|
|
220
|
+
`produck:lint`
|
|
244
221
|
- `publish` script is optional at root when release is managed per package or
|
|
245
222
|
by external workflow.
|
|
246
223
|
|
|
@@ -276,8 +253,8 @@ Repository layout:
|
|
|
276
253
|
|
|
277
254
|
Script placement:
|
|
278
255
|
|
|
279
|
-
- The repository root `package.json` must define `
|
|
280
|
-
`produck:coverage`, `lint`, and `publish`.
|
|
256
|
+
- The repository root `package.json` must define `produck:install`, `test`,
|
|
257
|
+
`produck:coverage`, `produck:lint`, and `publish`.
|
|
281
258
|
- Root `package.json` must define a `produck:baseline` script for organization
|
|
282
259
|
baseline enforcement:
|
|
283
260
|
```json
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- managed-by: @produck/agent-toolkit -->
|
|
6
|
+
<!-- source: .github/distribution/produck/12-produck-test.instructions.md -->
|
|
7
|
+
|
|
8
|
+
# Test Authoring Baseline
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
- Applies to Node.js repositories in the organization.
|
|
13
|
+
- This document governs how tests are authored, structured, and executed.
|
|
14
|
+
- Repository-specific rules may add stricter requirements; they override this
|
|
15
|
+
baseline when they conflict.
|
|
16
|
+
|
|
17
|
+
## Framework
|
|
18
|
+
|
|
19
|
+
- MUST use Node.js standard library test runner (`node:test`) with `describe`
|
|
20
|
+
and `it`.
|
|
21
|
+
- Do not introduce a third-party test framework unless repository owners
|
|
22
|
+
explicitly document the justification.
|
|
23
|
+
|
|
24
|
+
## File structure
|
|
25
|
+
|
|
26
|
+
- Each package must have a dedicated test directory: `test/`.
|
|
27
|
+
- Tests are organized in individual files per subject area under `test/`.
|
|
28
|
+
- Each package MUST provide a single entrypoint file: `test/index.mjs`.
|
|
29
|
+
- The entrypoint imports all test files to be executed.
|
|
30
|
+
|
|
31
|
+
Example entrypoint:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import './feature-a.test.mjs';
|
|
35
|
+
import './feature-b.test.mjs';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Single Entrypoint Rule (required)
|
|
39
|
+
|
|
40
|
+
- Execution MUST always go through the entrypoint file.
|
|
41
|
+
- Command-line execution MUST NOT use the `--test` flag. Use
|
|
42
|
+
`node <entrypoint>` directly.
|
|
43
|
+
- Correct: `node test/index.mjs`
|
|
44
|
+
- Wrong: `node --test` or `node --test test/feature-a.test.mjs`
|
|
45
|
+
- All tooling (scripts, CI, coverage) must target the entrypoint only.
|
|
46
|
+
|
|
47
|
+
## Test case rules
|
|
48
|
+
|
|
49
|
+
- Each test case must be independently executable.
|
|
50
|
+
- Test cases must not depend on execution order or shared mutable state from
|
|
51
|
+
other cases.
|
|
52
|
+
- Avoid global side effects that persist across test cases.
|
|
53
|
+
- Clean up resources (temp files, open handles) at the end of each test case.
|
|
54
|
+
|
|
55
|
+
## Naming conventions
|
|
56
|
+
|
|
57
|
+
- Test files use the `.test.mjs` suffix.
|
|
58
|
+
- Top-level `describe` label should match the subject being tested (for example
|
|
59
|
+
the module name or command name).
|
|
60
|
+
- `it` labels should describe the expected behavior in plain language.
|
|
61
|
+
|
|
62
|
+
## Local debug workflow (recommended)
|
|
63
|
+
|
|
64
|
+
When debugging a failing test case:
|
|
65
|
+
|
|
66
|
+
1. Add `{ only: true }` to the target `it` and all ancestor `describe` blocks.
|
|
67
|
+
2. Run `node --test-only test/index.mjs`.
|
|
68
|
+
3. Verify the issue is isolated.
|
|
69
|
+
4. Remove all `only` markers.
|
|
70
|
+
5. Run full regression: `node test/index.mjs`.
|
|
71
|
+
|
|
72
|
+
Rules for `only` mode:
|
|
73
|
+
|
|
74
|
+
- `--test-name-pattern` does NOT match tests nested inside `describe()` blocks
|
|
75
|
+
— it may silently run zero tests. Do not use it for focused runs.
|
|
76
|
+
- Always remove `only` markers before committing.
|
|
77
|
+
- Never commit a test file with `{ only: true }` present.
|
|
78
|
+
|
|
79
|
+
## Coverage
|
|
80
|
+
|
|
81
|
+
- Coverage is governed by `produck:coverage` script and `c8`.
|
|
82
|
+
- Scoped coverage (for partial branch verification during development):
|
|
83
|
+
`npm exec -- c8 --reporter=lcov --reporter=html --reporter=text-summary node --test-only test/index.mjs`
|
|
84
|
+
- Before merge or release, run full coverage via `npm run produck:coverage`.
|
|
85
|
+
- See [Node.js Baseline](10-produck-node.instructions.md) for coverage script
|
|
86
|
+
governance details.
|
|
87
|
+
|
|
88
|
+
## Regression discipline
|
|
89
|
+
|
|
90
|
+
- Before merge or release: restore executable test commands and fix all failing
|
|
91
|
+
tests.
|
|
92
|
+
- Temporary non-executable state or failing tests are allowed for intermediate
|
|
93
|
+
commits.
|
|
94
|
+
- Full regression MUST pass before a release commit is made.
|
|
@@ -11,13 +11,6 @@ applyTo: '**'
|
|
|
11
11
|
|
|
12
12
|
The Produck monorepo provides unified configuration across all packages for consistency and ease of maintenance.
|
|
13
13
|
|
|
14
|
-
## Distribution classification
|
|
15
|
-
|
|
16
|
-
This document is maintained directly as a downstream-distributable source.
|
|
17
|
-
|
|
18
|
-
- Authoritative path:
|
|
19
|
-
`.github/distribution/produck/15-produck-workspace.instructions.md`
|
|
20
|
-
|
|
21
14
|
## Shared Configurations
|
|
22
15
|
|
|
23
16
|
### 1. ESLint Configuration (`eslint.config.mjs`)
|
|
@@ -137,56 +130,30 @@ export default [
|
|
|
137
130
|
# Type check all packages (optional: only when root tsconfig.json is present)
|
|
138
131
|
npm run type-check
|
|
139
132
|
|
|
140
|
-
# Format
|
|
141
|
-
npm run format
|
|
142
|
-
|
|
143
|
-
# Format and write
|
|
144
|
-
npm run format
|
|
133
|
+
# Format and write using the organization format gate
|
|
134
|
+
npm run produck:format
|
|
145
135
|
|
|
146
|
-
# Lint
|
|
147
|
-
npm run lint
|
|
136
|
+
# Lint using the organization lint gate
|
|
137
|
+
npm run produck:lint
|
|
148
138
|
|
|
149
139
|
# Run all package tests
|
|
150
140
|
npm run test
|
|
151
141
|
|
|
152
142
|
# Check coverage across packages
|
|
153
|
-
npm run coverage
|
|
143
|
+
npm run produck:coverage
|
|
154
144
|
```
|
|
155
145
|
|
|
156
146
|
### Release & Coverage Tooling
|
|
157
147
|
|
|
158
|
-
-
|
|
159
|
-
-
|
|
148
|
+
- Release and coverage governance follows
|
|
149
|
+
`10-produck-node.instructions.md`.
|
|
150
|
+
- Source of truth for version pinning and script templates remains
|
|
160
151
|
`.github/distribution/produck/tooling-version-baseline.json`.
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
|
|
166
|
-
- Shared scripts/CI must not use unversioned `npx lerna` or `lerna@latest`.
|
|
167
|
-
- Wrapper scripts are allowed, but should keep parity with organization version
|
|
168
|
-
policy.
|
|
169
|
-
- Workspace subpackage coverage scripts are fully organization-governed.
|
|
170
|
-
- Deploy/repair coverage scripts via central remediation command:
|
|
171
|
-
`npm exec -- agent-toolkit sync-coverage-script --cwd .`.
|
|
172
|
-
- Root anti-drift local hook baseline is organization-governed.
|
|
173
|
-
- Deploy/repair root local hooks via central remediation command:
|
|
174
|
-
`npm exec -- agent-toolkit sync-husky-hooks --cwd .`.
|
|
175
|
-
- Deployed coverage scripts use the `c8` version specified in
|
|
176
|
-
`tooling-version-baseline.json` for each governed workspace package.
|
|
177
|
-
- Deployed local hook baseline uses the `husky` version specified in
|
|
178
|
-
`tooling-version-baseline.json` for root `devDependencies.husky`.
|
|
179
|
-
- Deployed local hook baseline also pins root
|
|
180
|
-
`devDependencies.@produck/agent-toolkit` to the fixed version managed by the organization baseline.
|
|
181
|
-
- Shared scripts/CI must not use unversioned `npx c8` or `c8@latest`.
|
|
182
|
-
- `test` script implementation remains repository-defined and is not overwritten
|
|
183
|
-
by coverage remediation.
|
|
184
|
-
- Root `devDependencies.c8` is pinned at root by `agent-toolkit sync-husky-hooks`;
|
|
185
|
-
workspace package `devDependencies.c8` is pinned per package by
|
|
186
|
-
`agent-toolkit sync-coverage-script`.
|
|
187
|
-
- Root local hooks may be bypassed intentionally by developers (for example via
|
|
188
|
-
`--no-verify`) and are treated as local strong guardrails rather than
|
|
189
|
-
immutable release gates.
|
|
152
|
+
- For monorepo remediation, use:
|
|
153
|
+
- `npm exec -- agent-toolkit sync-coverage --cwd .`
|
|
154
|
+
- `npm exec -- agent-toolkit sync-git --cwd .`
|
|
155
|
+
- Keep workspace wrappers and local scripts consistent with Node baseline
|
|
156
|
+
execution policy.
|
|
190
157
|
|
|
191
158
|
## Package Integration
|
|
192
159
|
|
|
@@ -264,14 +231,14 @@ Root scripts are designed for CI pipelines:
|
|
|
264
231
|
|
|
265
232
|
```bash
|
|
266
233
|
# Pre-commit checks
|
|
267
|
-
npm run format
|
|
234
|
+
npm run produck:format
|
|
235
|
+
npm run produck:lint
|
|
268
236
|
# Optional when root tsconfig.json is used
|
|
269
237
|
npm run type-check
|
|
270
|
-
npm run lint
|
|
271
238
|
|
|
272
239
|
# Testing
|
|
273
240
|
npm run test
|
|
274
|
-
npm run coverage
|
|
241
|
+
npm run produck:coverage
|
|
275
242
|
```
|
|
276
243
|
|
|
277
244
|
## Best Practices
|
|
@@ -297,7 +264,7 @@ npm install
|
|
|
297
264
|
Root `.prettierrc` and `eslint.config.mjs` are synchronized. If conflict occurs:
|
|
298
265
|
|
|
299
266
|
1. Check both configs have matching rules
|
|
300
|
-
2. Run `npm run format` first, then `npm run lint`
|
|
267
|
+
2. Run `npm run produck:format` first, then `npm run produck:lint`
|
|
301
268
|
|
|
302
269
|
### TypeScript includes too many files (when root tsconfig.json is used)
|
|
303
270
|
|
|
@@ -175,8 +175,8 @@ Use the local validator before commit:
|
|
|
175
175
|
Commit precheck gate (AI-agent required, human recommended):
|
|
176
176
|
|
|
177
177
|
- For AI-agent-authored operations, complete repository style gates before both
|
|
178
|
-
`git commit` and `git commit --amend` (for example `format
|
|
179
|
-
`lint`).
|
|
178
|
+
`git commit` and `git commit --amend` (for example `produck:format` and
|
|
179
|
+
`produck:lint`).
|
|
180
180
|
- For AI-agent-authored operations, `git commit --no-verify` and
|
|
181
181
|
`git commit --amend --no-verify` are forbidden.
|
|
182
182
|
- For human engineer-authored operations, style gates are recommended baseline
|
|
@@ -16,17 +16,29 @@
|
|
|
16
16
|
"version": "9.0.7",
|
|
17
17
|
"policy": "pinned",
|
|
18
18
|
"allowLatest": false
|
|
19
|
+
},
|
|
20
|
+
"prettier": {
|
|
21
|
+
"version": "3.8.3",
|
|
22
|
+
"policy": "pinned",
|
|
23
|
+
"allowLatest": false
|
|
24
|
+
},
|
|
25
|
+
"@produck/eslint-rules": {
|
|
26
|
+
"version": "0.3.5",
|
|
27
|
+
"policy": "pinned",
|
|
28
|
+
"allowLatest": false
|
|
19
29
|
}
|
|
20
30
|
},
|
|
21
31
|
"coverage": {
|
|
22
|
-
"scriptTemplate": "c8
|
|
32
|
+
"scriptTemplate": "c8 --reporter=lcov --reporter=html --reporter=text-summary npm test"
|
|
23
33
|
},
|
|
24
34
|
"enforce": {
|
|
25
35
|
"sharedScriptsDisallow": [
|
|
26
36
|
"npx c8",
|
|
27
37
|
"c8@latest",
|
|
28
38
|
"npx lerna",
|
|
29
|
-
"lerna@latest"
|
|
39
|
+
"lerna@latest",
|
|
40
|
+
"npx prettier",
|
|
41
|
+
"prettier@latest"
|
|
30
42
|
]
|
|
31
43
|
}
|
|
32
44
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Usage:
|
|
2
|
-
agent-toolkit sync-husky-hooks [--cwd <dir>] [--check] [--dry-run]
|
|
3
|
-
[--json <file>]
|
|
4
|
-
|
|
5
|
-
Behavior:
|
|
6
|
-
- Applies organization-required hook files only:
|
|
7
|
-
- .husky/pre-commit
|
|
8
|
-
- .husky/commit-msg
|
|
9
|
-
- commit-msg hook validates message via local node_modules toolkit path
|
|
10
|
-
|
|
11
|
-
Rules:
|
|
12
|
-
- --check validates without writing and exits non-zero on mismatch
|
|
13
|
-
- --dry-run prints planned changes without writing
|
|
14
|
-
- --check takes precedence over --dry-run
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import { getSingle, hasFlag } from '../shared/args.mjs';
|
|
6
|
-
import { printTextResource } from '../shared/text-resource.mjs';
|
|
7
|
-
|
|
8
|
-
const COMMAND_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const HELP_FILE = path.resolve(COMMAND_DIR, 'help.txt');
|
|
10
|
-
|
|
11
|
-
const REQUIRED_PRE_COMMIT_HOOK = '#!/usr/bin/env sh\nnpm run produck:precommit-check\n';
|
|
12
|
-
const REQUIRED_COMMIT_MSG_HOOK =
|
|
13
|
-
'#!/usr/bin/env sh\nnode ./node_modules/@produck/agent-toolkit/bin/agent-toolkit.mjs validate-commit-msg --file "$1"\n';
|
|
14
|
-
|
|
15
|
-
export function printSyncHuskyHooksHelp() {
|
|
16
|
-
printTextResource(HELP_FILE);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function readFileIfExists(filePath) {
|
|
20
|
-
if (!fs.existsSync(filePath)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function runSyncHuskyHooks(options) {
|
|
28
|
-
const cwd = path.resolve(getSingle(options, '--cwd', process.cwd()));
|
|
29
|
-
const check = hasFlag(options, '--check');
|
|
30
|
-
const dryRun = hasFlag(options, '--dry-run') && !check;
|
|
31
|
-
const jsonFile = getSingle(options, '--json', '');
|
|
32
|
-
const mode = check ? 'check' : dryRun ? 'dry-run' : 'sync';
|
|
33
|
-
|
|
34
|
-
if (!fs.existsSync(cwd)) {
|
|
35
|
-
console.error(`CWD does not exist: ${cwd}`);
|
|
36
|
-
process.exit(2);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const huskyDir = path.resolve(cwd, '.husky');
|
|
40
|
-
const preCommitHookPath = path.resolve(huskyDir, 'pre-commit');
|
|
41
|
-
const commitMsgHookPath = path.resolve(huskyDir, 'commit-msg');
|
|
42
|
-
|
|
43
|
-
const previousPreCommitHook = readFileIfExists(preCommitHookPath);
|
|
44
|
-
const previousCommitMsgHook = readFileIfExists(commitMsgHookPath);
|
|
45
|
-
|
|
46
|
-
const matchesRequiredPreCommitHook = previousPreCommitHook === REQUIRED_PRE_COMMIT_HOOK;
|
|
47
|
-
const matchesRequiredCommitMsgHook = previousCommitMsgHook === REQUIRED_COMMIT_MSG_HOOK;
|
|
48
|
-
const requiresUpdate = !matchesRequiredPreCommitHook || !matchesRequiredCommitMsgHook;
|
|
49
|
-
|
|
50
|
-
if (mode === 'sync' && requiresUpdate) {
|
|
51
|
-
fs.mkdirSync(huskyDir, { recursive: true });
|
|
52
|
-
fs.writeFileSync(preCommitHookPath, REQUIRED_PRE_COMMIT_HOOK, 'utf8');
|
|
53
|
-
fs.writeFileSync(commitMsgHookPath, REQUIRED_COMMIT_MSG_HOOK, 'utf8');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const report = {
|
|
57
|
-
cwd,
|
|
58
|
-
mode,
|
|
59
|
-
ok: true,
|
|
60
|
-
required: {
|
|
61
|
-
preCommitHookPath: path.relative(cwd, preCommitHookPath),
|
|
62
|
-
commitMsgHookPath: path.relative(cwd, commitMsgHookPath),
|
|
63
|
-
},
|
|
64
|
-
status: {
|
|
65
|
-
matchesRequiredPreCommitHookBefore: matchesRequiredPreCommitHook,
|
|
66
|
-
matchesRequiredCommitMsgHookBefore: matchesRequiredCommitMsgHook,
|
|
67
|
-
matchesRequiredPreCommitHookAfter:
|
|
68
|
-
requiresUpdate && mode === 'sync' ? true : matchesRequiredPreCommitHook,
|
|
69
|
-
matchesRequiredCommitMsgHookAfter:
|
|
70
|
-
requiresUpdate && mode === 'sync' ? true : matchesRequiredCommitMsgHook,
|
|
71
|
-
updated: requiresUpdate && mode === 'sync',
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
if (mode === 'check' && requiresUpdate) {
|
|
76
|
-
report.ok = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (jsonFile) {
|
|
80
|
-
const outPath = path.resolve(cwd, jsonFile);
|
|
81
|
-
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
82
|
-
fs.writeFileSync(outPath, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
86
|
-
if (!report.ok) {
|
|
87
|
-
process.exit(2);
|
|
88
|
-
}
|
|
89
|
-
}
|