@produck/agent-toolkit 0.2.0 → 0.3.3

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 (32) hide show
  1. package/README.md +53 -9
  2. package/bin/agent-toolkit.mjs +76 -654
  3. package/bin/build-publish-assets.mjs +49 -0
  4. package/bin/command/enforce-node-baseline/help.txt +19 -0
  5. package/bin/command/enforce-node-baseline/index.mjs +155 -0
  6. package/{templates/help/main.txt → bin/command/main/help.txt} +7 -0
  7. package/bin/command/main/index.mjs +11 -0
  8. package/bin/command/preflight/help.txt +9 -0
  9. package/bin/command/preflight/index.mjs +147 -0
  10. package/bin/command/run-capture/index.mjs +100 -0
  11. package/bin/command/shared/args.mjs +45 -0
  12. package/bin/command/shared/text-resource.mjs +19 -0
  13. package/bin/command/summarize-log/index.mjs +64 -0
  14. package/bin/command/sync-coverage-script/help.txt +22 -0
  15. package/bin/command/sync-coverage-script/index.mjs +275 -0
  16. package/bin/command/sync-husky-hooks/help.txt +22 -0
  17. package/bin/command/sync-husky-hooks/index.mjs +267 -0
  18. package/bin/command/sync-instructions/index.mjs +272 -0
  19. package/bin/command/validate-commit-msg/help.txt +9 -0
  20. package/bin/command/validate-commit-msg/index.mjs +183 -0
  21. package/package.json +5 -3
  22. package/publish-assets/instructions/produck/00-produck-base.instructions.md +37 -39
  23. package/publish-assets/instructions/produck/10-produck-node.instructions.md +130 -26
  24. package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +59 -27
  25. package/publish-assets/instructions/produck/20-produck-commit.instructions.md +24 -8
  26. package/publish-assets/instructions/produck/tooling-version-baseline.json +32 -0
  27. package/templates/help/preflight.txt +0 -3
  28. package/templates/help/validate-commit-msg.txt +0 -7
  29. /package/{templates/help/run-capture.txt → bin/command/run-capture/help.txt} +0 -0
  30. /package/{templates/help/summarize-log.txt → bin/command/summarize-log/help.txt} +0 -0
  31. /package/{templates/help/sync-instructions.txt → bin/command/sync-instructions/help.txt} +0 -0
  32. /package/{templates → bin/command/sync-instructions}/user-space-bootstrap.md +0 -0
@@ -1,33 +1,19 @@
1
1
  ---
2
- applyTo: '**/*.{js,cjs,mjs,ts,tsx,json,yaml,yml}'
2
+ applyTo: '**'
3
3
  ---
4
4
 
5
5
  <!-- managed-by: @produck/agent-toolkit -->
6
6
  <!-- source: .github/distribution/produck/10-produck-node.instructions.md -->
7
7
 
8
- # Node.js Initialization Baseline
9
-
10
- This document defines the organization-level initialization baseline for Node.js
11
- repositories.
8
+ # Node.js Baseline (Monorepo + Standalone)
12
9
 
13
10
  ## Scope
14
11
 
15
- - Applies to all Node.js repositories in the `produck` organization, including
16
- services, CLI tools, and script/tooling repositories.
17
- - Supports two repository modes: monorepo and standalone.
18
-
19
- ## Mode selection
20
-
21
- - Monorepo mode: one repository contains multiple Node.js packages/apps.
22
- - Standalone mode: one repository represents one Node.js package/app.
23
- - Repository owners should declare the selected mode in the repository README.
24
-
25
- ## Common baseline (all modes)
26
-
27
- - Node.js version policy: LTS required (no fixed major version at organization
28
- level).
29
- - Package manager: npm only.
30
- - Module system: ESM by default (`"type": "module"` in `package.json`).
12
+ - Applies to Node.js repositories in the organization.
13
+ - Default package manager: npm.
14
+ - Default language level: modern stable Node.js for current LTS.
15
+ - Module system: ESM by default for executable/publishable Node.js packages
16
+ (`"type": "module"` in package-level `package.json`).
31
17
  - Follow the organization `.gitattributes` baseline (LF default for text files).
32
18
  - Follow the organization `.editorconfig` baseline.
33
19
 
@@ -35,7 +21,7 @@ Required script keys:
35
21
 
36
22
  - `deps:install`
37
23
  - `test`
38
- - `coverage`
24
+ - `produck:coverage`
39
25
  - `lint`
40
26
  - `publish`
41
27
 
@@ -44,9 +30,62 @@ Notes:
44
30
  - Script key names are fixed and must match exactly.
45
31
  - `publish` may be a no-op when repository-specific release workflow does not
46
32
  use npm publishing.
33
+ - Coverage governance policy:
34
+ - Keep the script key name `produck:coverage` (organization-reserved key).
35
+ - In monorepo mode, workspace subpackage `scripts.produck:coverage` and
36
+ workspace `devDependencies.c8` are fully governed by organization
37
+ baseline.
38
+ - Source of truth for tooling versions/template:
39
+ `.github/distribution/produck/tooling-version-baseline.json`.
40
+ - Use central remediation command to deploy coverage scripts:
41
+ `npm exec -- agent-toolkit sync-coverage-script --cwd .`.
42
+ - Use central remediation command to deploy local anti-drift hook baseline:
43
+ `npm exec -- agent-toolkit sync-husky-hooks --cwd .`.
44
+ - `c8` execution baseline for deployed coverage scripts is fixed to the
45
+ version specified in `tooling-version-baseline.json`.
46
+ - Downstream repositories must not use unversioned `npx c8` or `c8@latest`
47
+ 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`.
47
50
 
48
51
  - Testing strategy and framework are repository-defined.
49
- - Repositories must keep `npm run test` and `npm run coverage` executable.
52
+ - `test` script implementation is repository-defined and is not overwritten by
53
+ organization coverage remediation.
54
+ - Repositories should keep `npm run test` and `npm run produck:coverage`
55
+ executable in steady state.
56
+ - For intermediate commits, temporary non-executable state or failing tests are
57
+ allowed.
58
+ - Commit prechecks still require passing repository style gates (for example
59
+ `format:check` and `lint`).
60
+
61
+ Central toolkit command role model:
62
+
63
+ - `agent-toolkit sync-instructions` is guidance-first distribution for
64
+ organization baseline instructions.
65
+ - `sync-instructions` is not a hard gate; use it to reduce instruction drift,
66
+ but do not assume it can fully prevent AI hallucination or iterative drift.
67
+ - `agent-toolkit preflight` is the hard guard for organization engineering
68
+ baseline and is mandatory for required baseline checks.
69
+ - `agent-toolkit sync-coverage-script` is the hard guard for monorepo coverage
70
+ governance and is mandatory in monorepo mode.
71
+ - `agent-toolkit sync-husky-hooks` is the hard guard for local anti-drift hook
72
+ governance and is mandatory in monorepo mode.
73
+ - For simplified downstream execution of mandatory flow (1 -> 2 -> 3 -> 4),
74
+ use:
75
+ `npm exec -- agent-toolkit`.
76
+ - Equivalent explicit form:
77
+ `npm exec -- agent-toolkit enforce-node-baseline --cwd .`.
78
+ - `agent-toolkit validate-commit-msg` is a hard guard for AI-agent-authored
79
+ `git commit` and `git commit --amend` operations.
80
+ - For human engineers, commit-message validation is recommended rather than
81
+ mandatory unless repository-specific hooks/CI enforce it.
82
+ - Do not require retroactive rewrite/amend of historical commits solely to
83
+ satisfy commit-message validator rules.
84
+ - `agent-toolkit run-capture` and `agent-toolkit summarize-log` are AI-agent
85
+ execution guardrails.
86
+ - These guardrails pair with node-first execution policy: prefer Node.js
87
+ interpreter workflows for parsing/filtering over brittle OS-shell pipelines.
88
+ - For human engineers, `run-capture` and `summarize-log` are optional helpers.
50
89
 
51
90
  Test authoring baseline (required):
52
91
 
@@ -114,9 +153,69 @@ Repository layout:
114
153
 
115
154
  Script placement:
116
155
 
117
- - Root `package.json` must provide `deps:install`, `test`, `coverage`, and
118
- `lint` orchestration scripts.
156
+ - Root `package.json` must provide `deps:install`, `test`, `produck:coverage`,
157
+ and `lint` orchestration scripts.
158
+ - Root `package.json` must reserve `produck:precommit-check` for organization
159
+ anti-drift gate with required value:
160
+ `npm run format:check && npm run lint`.
161
+ - Root `package.json` must reserve `prepare` for husky setup with required
162
+ value: `husky`.
119
163
  - `publish` may be defined at root or package level based on release workflow.
164
+ - Workspace subpackage `produck:coverage` scripts must be synchronized by
165
+ `agent-toolkit sync-coverage-script`.
166
+ - Root local hook governance must be synchronized by
167
+ `agent-toolkit sync-husky-hooks`.
168
+ - Root local hook governance must pin root `devDependencies.c8`,
169
+ `devDependencies.husky`, `devDependencies.lerna`, and
170
+ `devDependencies.@produck/agent-toolkit` via
171
+ `agent-toolkit sync-husky-hooks`.
172
+ - Root `package.json` must define a `produck:baseline` script for organization
173
+ baseline enforcement:
174
+ ```json
175
+ "produck:baseline": "npm exec --package=@produck/agent-toolkit@latest -- agent-toolkit enforce-node-baseline --cwd ."
176
+ ```
177
+
178
+ Release tooling policy (required):
179
+
180
+ - Monorepo release workflow must use `lerna`.
181
+ - `lerna` execution version is governed at organization level, not per
182
+ repository.
183
+ - Source of truth for `lerna` version baseline:
184
+ `.github/distribution/produck/tooling-version-baseline.json`.
185
+ - Required execution baseline: version specified in `tooling-version-baseline.json`.
186
+ - Required invocation:
187
+ `npm exec -- lerna <subcommand>`.
188
+ - Downstream repositories must not use unversioned `npx lerna` or
189
+ `lerna@latest` in shared scripts/CI.
190
+ - For high-impact release commands, run dry-run/preview before publish.
191
+ - Keep an emergency organization-level rollback path when baseline version is
192
+ updated.
193
+
194
+ Root workspace `package.json` minimal baseline (required):
195
+
196
+ - `private`: `true`
197
+ - `workspaces` (explicit package path list only)
198
+ - `scripts` with at least: `deps:install`, `test`, `produck:coverage`, `lint`
199
+ - `publish` script is optional at root when release is managed per package or
200
+ by external workflow.
201
+
202
+ `workspaces` field constraints (required):
203
+
204
+ - Do not use wildcard/glob patterns (for example `packages/*`, `**`, `?`,
205
+ `{}` or `[]`).
206
+ - List each workspace package path explicitly.
207
+
208
+ Avoid unused root runtime/publish fields by default:
209
+
210
+ - `type`
211
+ - `main`
212
+ - `exports`
213
+ - `types`
214
+ - `files`
215
+ - `publishConfig`
216
+
217
+ Add the fields above only when the monorepo root itself is an executable
218
+ runtime package or is intentionally published.
120
219
 
121
220
  Ignore strategy:
122
221
 
@@ -133,7 +232,12 @@ Repository layout:
133
232
  Script placement:
134
233
 
135
234
  - The repository root `package.json` must define `deps:install`, `test`,
136
- `coverage`, `lint`, and `publish`.
235
+ `produck:coverage`, `lint`, and `publish`.
236
+ - Root `package.json` must define a `produck:baseline` script for organization
237
+ baseline enforcement:
238
+ ```json
239
+ "produck:baseline": "npm exec --package=@produck/agent-toolkit@latest -- agent-toolkit enforce-node-baseline --cwd ."
240
+ ```
137
241
 
138
242
  Ignore strategy:
139
243
 
@@ -34,6 +34,12 @@ This document is maintained directly as a downstream-distributable source.
34
34
  - Semicolons: Always required (error)
35
35
  - Trailing commas: Always in multiline (error)
36
36
  - No inline config allowed: `noInlineConfig: true`
37
+ - The listed ESLint rules can be satisfied either by explicit local
38
+ declarations or by inherited shared presets.
39
+ - Repositories are not required to redeclare rules locally when those rules are
40
+ already provided by inherited presets.
41
+ - If a repository overrides inherited rules, include only the deltas and
42
+ document the rationale.
37
43
 
38
44
  **Usage in packages:**
39
45
 
@@ -47,13 +53,20 @@ export default [
47
53
  ];
48
54
  ```
49
55
 
50
- ### 2. TypeScript Configuration (`tsconfig.json`)
56
+ ### 2. TypeScript Configuration (`tsconfig.json`, conditional)
51
57
 
52
- **Location:** Root `tsconfig.json`
58
+ **Location:** Root `tsconfig.json` (only when needed)
53
59
 
54
- **Applies to:** All TypeScript packages
60
+ **Applies to:** TypeScript packages that opt in
55
61
 
56
- **Key settings:**
62
+ **Decision rule:**
63
+
64
+ - If the workspace has no TypeScript source files and no package-level need for
65
+ shared TypeScript options, do not create/deploy root `tsconfig.json`.
66
+ - If any package uses TypeScript source files or needs centralized strict/type
67
+ options, create root `tsconfig.json` and let TypeScript packages extend it.
68
+
69
+ **Recommended key settings when present:**
57
70
 
58
71
  - Target: ES2022
59
72
  - Strict mode: enabled
@@ -61,7 +74,7 @@ export default [
61
74
  - Source maps: enabled
62
75
  - Declaration files: generated
63
76
 
64
- **Usage in packages:**
77
+ **Usage in TypeScript packages:**
65
78
 
66
79
  ```json
67
80
  {
@@ -121,7 +134,7 @@ export default [
121
134
  ### Verification & Quality
122
135
 
123
136
  ```bash
124
- # Type check all packages
137
+ # Type check all packages (optional: only when root tsconfig.json is present)
125
138
  npm run type-check
126
139
 
127
140
  # Format check without writing
@@ -140,19 +153,40 @@ npm run test
140
153
  npm run coverage
141
154
  ```
142
155
 
143
- ### Package-Specific Commands
144
-
145
- ```bash
146
- # Verify toolkit package
147
- npm run toolkit:verify
148
-
149
- # Verify eslint-rules package
150
- npm run eslint-rules:verify
151
-
152
- # Check package distributions
153
- npm run toolkit:pack-check
154
- npm run eslint-rules:pack-check
155
- ```
156
+ ### Release & Coverage Tooling
157
+
158
+ - Monorepo release workflow is `lerna`-based and required.
159
+ - Source of truth for `lerna`/`c8` versions and coverage script template:
160
+ `.github/distribution/produck/tooling-version-baseline.json`.
161
+ - `lerna` execution version is governed at organization level, not per
162
+ repository.
163
+ - Required execution baseline: version specified in `tooling-version-baseline.json`.
164
+ - Required `lerna` invocation:
165
+ `npm exec -- lerna <subcommand>`.
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.
156
190
 
157
191
  ## Package Integration
158
192
 
@@ -162,7 +196,8 @@ npm run eslint-rules:pack-check
162
196
  2. Create `packages/my-package/package.json` with workspace configuration
163
197
  3. Inherit root configs:
164
198
  - ESLint: extend `../../eslint.config.mjs`
165
- - TypeScript: extend `../../tsconfig.json`
199
+ - TypeScript (when root `tsconfig.json` exists): extend
200
+ `../../tsconfig.json`
166
201
  - Prettier: uses root `.prettierrc` automatically
167
202
 
168
203
  ### Package-Level Overrides
@@ -207,8 +242,8 @@ Applies to all editors supporting EditorConfig (VSCode, Vim, Sublime, etc.):
207
242
  - `typescript-eslint`: TypeScript linting support
208
243
  - `globals`: Global variables (browser, node)
209
244
  - `prettier`: Code formatter
210
- - `typescript`: TypeScript compiler
211
- - `@types/node`: Node.js type definitions
245
+ - `typescript`: TypeScript compiler (when TypeScript is used)
246
+ - `@types/node`: Node.js type definitions (when TypeScript is used)
212
247
 
213
248
  ### Peer Dependencies (Packages)
214
249
 
@@ -230,16 +265,13 @@ Root scripts are designed for CI pipelines:
230
265
  ```bash
231
266
  # Pre-commit checks
232
267
  npm run format:check
268
+ # Optional when root tsconfig.json is used
233
269
  npm run type-check
234
270
  npm run lint
235
271
 
236
272
  # Testing
237
273
  npm run test
238
274
  npm run coverage
239
-
240
- # Package verification
241
- npm run toolkit:verify
242
- npm run eslint-rules:verify
243
275
  ```
244
276
 
245
277
  ## Best Practices
@@ -267,7 +299,7 @@ Root `.prettierrc` and `eslint.config.mjs` are synchronized. If conflict occurs:
267
299
  1. Check both configs have matching rules
268
300
  2. Run `npm run format` first, then `npm run lint`
269
301
 
270
- ### TypeScript includes too many files
302
+ ### TypeScript includes too many files (when root tsconfig.json is used)
271
303
 
272
304
  Update `tsconfig.json` `include` and `exclude` patterns:
273
305
 
@@ -59,12 +59,6 @@ Allowed tags (fixed whitelist):
59
59
  - `[UPGRADE]`
60
60
  - `[PUBLISH]`
61
61
 
62
- Legacy-to-canonical mapping (for migration):
63
-
64
- - `[ADDED]` -> `[ADD]`
65
- - `[REMOVED]` -> `[REMOVE]`
66
- - `[FIXED]` -> `[FIX]`
67
-
68
62
  When using this style:
69
63
 
70
64
  - `TAG` must be uppercase and must be one of the allowed tags above.
@@ -163,8 +157,30 @@ Avoid vague or low-signal messages such as:
163
157
 
164
158
  Use the local validator before commit:
165
159
 
166
- - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit
167
- validate-commit-msg --file <message-file>`
160
+ - AI-agent-authored commits/amends:
161
+ validation is required before both `git commit` and `git commit --amend`.
162
+ - For AI-agent-authored operations, do not create or amend a commit when
163
+ validation fails.
164
+ - Human engineer-authored commits/amends:
165
+ validation is recommended by default and may be enforced by
166
+ repository-specific hooks/CI.
167
+ - Do not require retroactive rewrite/amend of historical commits solely for
168
+ commit-message style compliance.
169
+
170
+ Commit precheck gate (AI-agent required, human recommended):
171
+
172
+ - For AI-agent-authored operations, complete repository style gates before both
173
+ `git commit` and `git commit --amend` (for example `format:check` and
174
+ `lint`).
175
+ - For human engineer-authored operations, style gates are recommended baseline
176
+ practice unless repository-specific hooks/CI enforce them.
177
+ - Temporary non-executable state or failing tests are allowed for
178
+ intermediate commits.
179
+ - Test/coverage pass status is not a hard blocker at commit time.
180
+ - Before merge or release, restore executable test commands and fix failing
181
+ tests.
182
+
183
+ - `npm exec -- agent-toolkit validate-commit-msg --file <message-file>`
168
184
 
169
185
  If validation fails, fix the message and rerun until it passes.
170
186
 
@@ -0,0 +1,32 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "updatedAt": "2026-05-12",
4
+ "tools": {
5
+ "c8": {
6
+ "version": "11.0.0",
7
+ "policy": "pinned",
8
+ "allowLatest": false
9
+ },
10
+ "husky": {
11
+ "version": "9.1.7",
12
+ "policy": "pinned",
13
+ "allowLatest": false
14
+ },
15
+ "lerna": {
16
+ "version": "9.0.7",
17
+ "policy": "pinned",
18
+ "allowLatest": false
19
+ }
20
+ },
21
+ "coverage": {
22
+ "scriptTemplate": "c8@{c8.version} --reporter=lcov --reporter=html --reporter=text-summary npm test"
23
+ },
24
+ "enforce": {
25
+ "sharedScriptsDisallow": [
26
+ "npx c8",
27
+ "c8@latest",
28
+ "npx lerna",
29
+ "lerna@latest"
30
+ ]
31
+ }
32
+ }
@@ -1,3 +0,0 @@
1
- Usage:
2
- agent-toolkit preflight [--cwd <dir>] [--require <path>] ...
3
- [--ensure-dir <path>] ... [--json <file>]
@@ -1,7 +0,0 @@
1
- Usage:
2
- agent-toolkit validate-commit-msg --file <message-file>
3
-
4
- Rules:
5
- - Every line must start with [TAG]
6
- - No empty lines are allowed
7
- - Optional target form: [TAG] <target>: <summary>