@produck/agent-toolkit 0.9.2 → 0.11.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/bin/agent-toolkit.mjs +16 -0
- package/bin/build-publish-assets.mjs +28 -6
- package/bin/command/enforce-node-baseline/index.mjs +11 -0
- package/bin/command/main/help.txt +4 -2
- package/bin/command/sync-coverage/help.txt +6 -21
- package/bin/command/sync-coverage/index.mjs +31 -200
- package/bin/command/sync-coverage/required-c8-config.json +10 -5
- package/bin/command/sync-format/index.mjs +30 -3
- package/bin/command/sync-git/index.mjs +31 -2
- package/bin/command/sync-lint/index.mjs +29 -7
- package/bin/command/sync-publish/help.txt +1 -1
- package/bin/command/sync-publish/index.mjs +38 -15
- package/bin/command/sync-typescript/help.txt +14 -0
- package/bin/command/sync-typescript/index.mjs +154 -0
- package/bin/command/sync-workspace/help.txt +22 -0
- package/bin/command/sync-workspace/index.mjs +379 -0
- package/package.json +21 -21
- package/publish-assets/gitignore +3 -0
- package/publish-assets/instructions/produck/00-produck-base.instructions.md +3 -3
- package/publish-assets/instructions/produck/10-produck-node.instructions.md +151 -118
- package/publish-assets/instructions/produck/12-produck-test.instructions.md +92 -0
- package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +73 -39
- package/publish-assets/instructions/produck/20-produck-commit.instructions.md +12 -0
- package/publish-assets/instructions/produck/tooling-version-baseline.json +53 -48
- package/publish-assets/lerna.json +3 -3
- package/publish-assets/prettierrc +9 -1
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@produck/agent-toolkit",
|
|
3
|
-
"version": "0.9.2",
|
|
4
|
-
"description": "Central CLI toolkit for organization AI execution workflows",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/produck/.github.git",
|
|
9
|
-
"directory": "packages/agent-toolkit"
|
|
10
|
-
},
|
|
11
2
|
"bin": {
|
|
12
3
|
"agent-toolkit": "bin/agent-toolkit.mjs"
|
|
13
4
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
5
|
+
"description": "Central CLI toolkit for organization AI execution workflows",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@produck/eslint-rules": "^0.4.1",
|
|
8
|
+
"c8": "11.0.0"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.0.0"
|
|
19
12
|
},
|
|
20
13
|
"files": [
|
|
21
14
|
"bin",
|
|
22
15
|
"publish-assets"
|
|
23
16
|
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"name": "@produck/agent-toolkit",
|
|
24
19
|
"publishConfig": {
|
|
25
20
|
"access": "public"
|
|
26
21
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
22
|
+
"repository": {
|
|
23
|
+
"directory": "packages/agent-toolkit",
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/produck/.github.git"
|
|
29
26
|
},
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepack": "node ./bin/build-publish-assets.mjs",
|
|
29
|
+
"produck:coverage": "c8 --reporter=lcov --reporter=html --reporter=text-summary npm test",
|
|
30
|
+
"produck:lint": "eslint --fix . --max-warnings=0",
|
|
31
|
+
"test": "node test/index.mjs"
|
|
34
32
|
},
|
|
35
|
-
"
|
|
33
|
+
"type": "module",
|
|
34
|
+
"version": "0.11.0",
|
|
35
|
+
"gitHead": "736364d5debd737ee92440818c9d0671db1c6974"
|
|
36
36
|
}
|
package/publish-assets/gitignore
CHANGED
|
@@ -32,12 +32,12 @@ repositories:
|
|
|
32
32
|
- `.github/copilot-instructions.md` — repository-specific exceptions and
|
|
33
33
|
stricter local constraints.
|
|
34
34
|
|
|
35
|
-
Editing rule
|
|
35
|
+
Editing rule:
|
|
36
36
|
|
|
37
37
|
- Update downstream baseline rules directly in
|
|
38
38
|
`.github/distribution/produck/*.instructions.md`.
|
|
39
|
-
-
|
|
40
|
-
`.github/instructions/produck
|
|
39
|
+
- For internal-only governance (this repo only, not distributed), add files
|
|
40
|
+
under `.github/instructions/produck/`.
|
|
41
41
|
|
|
42
42
|
## Default expectations
|
|
43
43
|
|
|
@@ -53,16 +53,8 @@ Notes:
|
|
|
53
53
|
- Use central remediation command to deploy root lint script/config and
|
|
54
54
|
eslint integration baseline:
|
|
55
55
|
`npm exec -- agent-toolkit sync-lint --cwd .`.
|
|
56
|
-
- `c8` execution baseline for deployed coverage scripts is fixed to the
|
|
57
|
-
version specified in `tooling-version-baseline.json`.
|
|
58
56
|
- Downstream repositories must not use unversioned `npx c8` or `c8@latest`
|
|
59
57
|
in shared scripts/CI.
|
|
60
|
-
- Root local governance must pin `devDependencies.c8`,
|
|
61
|
-
`devDependencies.husky`, `devDependencies.lerna`, and
|
|
62
|
-
`devDependencies.@produck/agent-toolkit` via
|
|
63
|
-
`agent-toolkit sync-git`.
|
|
64
|
-
- Root local governance must pin `devDependencies.@produck/eslint-rules`
|
|
65
|
-
via `agent-toolkit sync-lint`.
|
|
66
58
|
|
|
67
59
|
- Testing strategy and framework are repository-defined.
|
|
68
60
|
- `verify` scripts are optional repository-local health checks and are not
|
|
@@ -78,43 +70,14 @@ Notes:
|
|
|
78
70
|
- Commit prechecks still require passing repository style gates (for example
|
|
79
71
|
`produck:format` and `produck:lint`).
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
organization baseline instructions.
|
|
85
|
-
- `sync-instructions` is not a hard gate; use it to reduce instruction drift,
|
|
86
|
-
but do not assume it can fully prevent AI hallucination or iterative drift.
|
|
87
|
-
- `agent-toolkit preflight` is the hard guard for organization engineering
|
|
88
|
-
baseline and is mandatory for required baseline checks.
|
|
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
|
|
92
|
-
governance and is mandatory in monorepo mode.
|
|
93
|
-
- `agent-toolkit sync-git` is the hard guard for local anti-drift hook
|
|
94
|
-
governance and is mandatory in monorepo mode.
|
|
95
|
-
- `agent-toolkit sync-format` is the hard guard for root format
|
|
96
|
-
script/config governance and is mandatory in monorepo mode.
|
|
97
|
-
- `agent-toolkit sync-lint` is the hard guard for root lint
|
|
98
|
-
script/config and eslint integration governance and is mandatory in monorepo
|
|
99
|
-
mode.
|
|
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),
|
|
103
|
-
use:
|
|
104
|
-
`npm exec -- agent-toolkit`.
|
|
105
|
-
- Equivalent explicit form:
|
|
73
|
+
Enforcement:
|
|
74
|
+
|
|
75
|
+
- For one-step execution of all mandatory checks, use:
|
|
106
76
|
`npm exec -- agent-toolkit enforce-node-baseline --cwd .`.
|
|
107
|
-
- `agent-toolkit validate-commit-msg` is
|
|
108
|
-
`git commit` and `git commit --amend
|
|
109
|
-
- For human engineers, commit-message validation is recommended
|
|
110
|
-
|
|
111
|
-
- Do not require retroactive rewrite/amend of historical commits solely to
|
|
112
|
-
satisfy commit-message validator rules.
|
|
113
|
-
- `agent-toolkit run-capture` and `agent-toolkit summarize-log` are AI-agent
|
|
114
|
-
execution guardrails.
|
|
115
|
-
- These guardrails pair with node-first execution policy: prefer Node.js
|
|
116
|
-
interpreter workflows for parsing/filtering over brittle OS-shell pipelines.
|
|
117
|
-
- For human engineers, `run-capture` and `summarize-log` are optional helpers.
|
|
77
|
+
- `agent-toolkit validate-commit-msg` is required for AI-agent-authored
|
|
78
|
+
`git commit` and `git commit --amend`.
|
|
79
|
+
- For human engineers, commit-message validation is recommended.
|
|
80
|
+
- Do not require retroactive rewrite/amend of historical commits.
|
|
118
81
|
|
|
119
82
|
Test authoring baseline:
|
|
120
83
|
|
|
@@ -143,67 +106,164 @@ Team conventions for `.gitignore`:
|
|
|
143
106
|
|
|
144
107
|
## Monorepo mode
|
|
145
108
|
|
|
146
|
-
Repository layout
|
|
109
|
+
### Repository layout
|
|
147
110
|
|
|
148
111
|
- Root-level `docs/` is required.
|
|
149
112
|
- Each package/app should contain its own `src/` and `test/`.
|
|
150
113
|
|
|
151
|
-
|
|
114
|
+
### Root `package.json` governance
|
|
115
|
+
|
|
116
|
+
The root `package.json` exists only for development orchestration. It is
|
|
117
|
+
never consumed as a downstream dependency, so runtime-oriented fields are
|
|
118
|
+
prohibited.
|
|
119
|
+
|
|
120
|
+
#### Required fields
|
|
121
|
+
|
|
122
|
+
- `name` — A fixed name stabilizes the `name` field in `package-lock.json`.
|
|
123
|
+
- `private`: `true` — Prevents accidental npm publish.
|
|
124
|
+
- `workspaces` — Explicit path list only; see constraints below.
|
|
125
|
+
- `scripts` — See [Required scripts](#required-scripts) section below.
|
|
126
|
+
- `devDependencies` — The development materials manifest. Root
|
|
127
|
+
`devDependencies` is the single source of truth for organization-level and
|
|
128
|
+
repository-level tooling.
|
|
129
|
+
|
|
130
|
+
#### Optional fields
|
|
131
|
+
|
|
132
|
+
- `version` — Root is not published; version is meaningless.
|
|
133
|
+
- `description` — Root is not published; description has no practical use.
|
|
134
|
+
- `engines` — Not required. Leave this to Node.js version managers if
|
|
135
|
+
needed.
|
|
136
|
+
|
|
137
|
+
#### Prohibited fields
|
|
138
|
+
|
|
139
|
+
The following fields must never appear in root `package.json`:
|
|
140
|
+
|
|
141
|
+
- `type`
|
|
142
|
+
- `main`
|
|
143
|
+
- `exports`
|
|
144
|
+
- `types`
|
|
145
|
+
- `files`
|
|
146
|
+
- `publishConfig`
|
|
147
|
+
- `dependencies`
|
|
148
|
+
|
|
149
|
+
#### `workspaces` field constraints
|
|
150
|
+
|
|
151
|
+
- Do not use wildcard/glob patterns (for example `packages/*`, `**`, `?`,
|
|
152
|
+
`{}` or `[]`).
|
|
153
|
+
- List each workspace package path explicitly.
|
|
154
|
+
|
|
155
|
+
### Required scripts
|
|
156
|
+
|
|
157
|
+
Root `package.json` must define:
|
|
158
|
+
|
|
159
|
+
| Script key | Required value |
|
|
160
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------- |
|
|
161
|
+
| `produck:install` | `npm -v && npm install` |
|
|
162
|
+
| `prepare` | `husky` |
|
|
163
|
+
| `test` | Repository-defined (may use `--workspaces --if-present`) |
|
|
164
|
+
| `produck:coverage` | Organization-defined via `agent-toolkit sync-coverage` |
|
|
165
|
+
| `produck:lint` | Organization-defined via `agent-toolkit sync-lint` |
|
|
166
|
+
| `produck:format` | Organization-defined via `agent-toolkit sync-format` |
|
|
167
|
+
| `produck:commit:check` | `npm run produck:format && npm run produck:lint` |
|
|
168
|
+
| `produck:baseline` | `npm exec --package=@produck/agent-toolkit@latest -- agent-toolkit enforce-node-baseline --cwd .` |
|
|
169
|
+
| `produck:publish` | Required when `lerna.json` is present; governed by `agent-toolkit sync-publish` |
|
|
170
|
+
| `produck:publish:check` | Required when `lerna.json` is present; governed by `agent-toolkit sync-publish` |
|
|
171
|
+
|
|
172
|
+
Notes:
|
|
152
173
|
|
|
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
|
|
156
|
-
anti-drift gate with required value:
|
|
157
|
-
`npm run produck:format && npm run produck:lint`.
|
|
158
|
-
- Root `package.json` must reserve `prepare` for husky setup with required
|
|
159
|
-
value: `husky`.
|
|
160
|
-
- Root `package.json` must reserve `produck:format` and `produck:lint` for
|
|
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`).
|
|
165
174
|
- `publish` may be defined at root or package level based on release workflow.
|
|
166
|
-
-
|
|
167
|
-
`agent-toolkit sync-
|
|
168
|
-
-
|
|
169
|
-
`agent-toolkit sync-git
|
|
170
|
-
-
|
|
171
|
-
`
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
|
|
175
|
+
- Remediation commands (run from root):
|
|
176
|
+
- `npm exec -- agent-toolkit sync-install --cwd .` — deploy root install script
|
|
177
|
+
- `npm exec -- agent-toolkit sync-coverage --cwd .` — deploy coverage scripts
|
|
178
|
+
- `npm exec -- agent-toolkit sync-git --cwd .` — deploy git hooks and deps
|
|
179
|
+
- `npm exec -- agent-toolkit sync-format --cwd .` — deploy format config
|
|
180
|
+
- `npm exec -- agent-toolkit sync-lint --cwd .` — deploy lint config
|
|
181
|
+
|
|
182
|
+
### Workspace `package.json` governance
|
|
183
|
+
|
|
184
|
+
#### Property restrictions
|
|
185
|
+
|
|
186
|
+
Workspace-level `package.json` must NOT contain:
|
|
187
|
+
|
|
188
|
+
- `private` — Package publication state is managed by the root workspace;
|
|
189
|
+
individual workspace packages should not declare it.
|
|
190
|
+
- `workspaces` — Only the root `package.json` defines workspace paths.
|
|
191
|
+
Nested declarations violate the centralization principle.
|
|
192
|
+
- Root orchestration scripts — These are the root `package.json`'s
|
|
193
|
+
responsibility and must not be duplicated in workspace packages:
|
|
194
|
+
`produck:install`, `produck:baseline`, `produck:commit:check`, `prepare`,
|
|
195
|
+
`produck:format`, `produck:publish`, `produck:publish:check`
|
|
196
|
+
|
|
197
|
+
#### Recommended structure
|
|
198
|
+
|
|
199
|
+
Workspace packages should keep their `package.json` lean, containing only:
|
|
200
|
+
|
|
201
|
+
- Package metadata: `name`, `version`, `type`, `main`, `exports`, etc.
|
|
202
|
+
- Dependencies: `dependencies`, `devDependencies`
|
|
203
|
+
- Package-level scripts: `test`, `produck:coverage`
|
|
204
|
+
|
|
205
|
+
#### Publish metadata governance
|
|
206
|
+
|
|
207
|
+
Workspace packages that are published to npm must correctly declare the
|
|
208
|
+
following fields. These control the package's npm registry page appearance and
|
|
209
|
+
link back to the git hosting platform.
|
|
210
|
+
|
|
211
|
+
**Required fields:**
|
|
212
|
+
|
|
213
|
+
- `description` — Short summary shown on npm search results and package page.
|
|
214
|
+
Must be meaningful and accurate.
|
|
215
|
+
- `license` — SPDX license identifier (for example `"MIT"`). Displayed on npm
|
|
216
|
+
package page.
|
|
217
|
+
|
|
218
|
+
**Repository linkage fields** (affect npm "repository", "bugs", "homepage"
|
|
219
|
+
links):
|
|
220
|
+
|
|
221
|
+
- `repository` — Must use the expanded object form with `directory` to
|
|
222
|
+
identify the subpackage location within the monorepo:
|
|
195
223
|
```json
|
|
196
|
-
"
|
|
224
|
+
"repository": {
|
|
225
|
+
"type": "git",
|
|
226
|
+
"url": "git+https://github.com/produck/<repo>.git",
|
|
227
|
+
"directory": "packages/<name>"
|
|
228
|
+
}
|
|
197
229
|
```
|
|
230
|
+
The `url` value must match the repository's canonical git remote. The
|
|
231
|
+
`directory` value must be the package's workspace-relative path from the
|
|
232
|
+
monorepo root.
|
|
233
|
+
- `bugs` — Must link to the GitHub issues page:
|
|
234
|
+
```json
|
|
235
|
+
"bugs": {
|
|
236
|
+
"url": "https://github.com/produck/<repo>/issues"
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
- `homepage` — Must point to the package's README on the default branch, using
|
|
240
|
+
the `directory` form to navigate to the subpackage:
|
|
241
|
+
```json
|
|
242
|
+
"homepage": "https://github.com/produck/<repo>/tree/main/packages/<name>#readme"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Recommended fields:**
|
|
246
|
+
|
|
247
|
+
- `keywords` — Array of strings that describe the package. Improves npm search
|
|
248
|
+
discoverability. Omit if the package has no meaningful keywords.
|
|
249
|
+
|
|
250
|
+
**Rationale:**
|
|
251
|
+
|
|
252
|
+
- Without `repository.directory`, npm links the repository field to the
|
|
253
|
+
monorepo root, which is not helpful for subpackage visitors.
|
|
254
|
+
- Without `bugs`, npm omits the "Report issues" link on the package page.
|
|
255
|
+
- Without `description`, npm shows "(not yet filled)" on the package page.
|
|
256
|
+
- Invalid or missing `license` causes npm warnings during publish.
|
|
198
257
|
|
|
199
|
-
Release tooling policy
|
|
258
|
+
### Release tooling policy
|
|
200
259
|
|
|
201
260
|
- Monorepo release workflow must use `lerna`.
|
|
202
261
|
- `lerna` execution version is governed at organization level, not per
|
|
203
262
|
repository.
|
|
204
263
|
- Source of truth for `lerna` version baseline:
|
|
205
264
|
`.github/distribution/produck/tooling-version-baseline.json`.
|
|
206
|
-
- Required execution baseline: version specified in
|
|
265
|
+
- Required execution baseline: version specified in the
|
|
266
|
+
`tooling-version-baseline.json`.
|
|
207
267
|
- Required invocation:
|
|
208
268
|
`npm exec -- lerna <subcommand>`.
|
|
209
269
|
- Downstream repositories must not use unversioned `npx lerna` or
|
|
@@ -212,34 +272,7 @@ Release tooling policy (required):
|
|
|
212
272
|
- Keep an emergency organization-level rollback path when baseline version is
|
|
213
273
|
updated.
|
|
214
274
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
- `private`: `true`
|
|
218
|
-
- `workspaces` (explicit package path list only)
|
|
219
|
-
- `scripts` with at least: `produck:install`, `test`, `produck:coverage`,
|
|
220
|
-
`produck:lint`
|
|
221
|
-
- `publish` script is optional at root when release is managed per package or
|
|
222
|
-
by external workflow.
|
|
223
|
-
|
|
224
|
-
`workspaces` field constraints (required):
|
|
225
|
-
|
|
226
|
-
- Do not use wildcard/glob patterns (for example `packages/*`, `**`, `?`,
|
|
227
|
-
`{}` or `[]`).
|
|
228
|
-
- List each workspace package path explicitly.
|
|
229
|
-
|
|
230
|
-
Avoid unused root runtime/publish fields by default:
|
|
231
|
-
|
|
232
|
-
- `type`
|
|
233
|
-
- `main`
|
|
234
|
-
- `exports`
|
|
235
|
-
- `types`
|
|
236
|
-
- `files`
|
|
237
|
-
- `publishConfig`
|
|
238
|
-
|
|
239
|
-
Add the fields above only when the monorepo root itself is an executable
|
|
240
|
-
runtime package or is intentionally published.
|
|
241
|
-
|
|
242
|
-
Ignore strategy:
|
|
275
|
+
### Ignore strategy
|
|
243
276
|
|
|
244
277
|
- Keep ignore rules centralized at repository root whenever possible.
|
|
245
278
|
- Add package-level `.gitignore` only when a package has unique generated
|
|
@@ -52,6 +52,35 @@ import './feature-b.test.mjs';
|
|
|
52
52
|
- Avoid global side effects that persist across test cases.
|
|
53
53
|
- Clean up resources (temp files, open handles) at the end of each test case.
|
|
54
54
|
|
|
55
|
+
## API usage conventions
|
|
56
|
+
|
|
57
|
+
- Callback functions for `describe` and `it` MUST use arrow functions. Do not
|
|
58
|
+
use `function` keyword or method shorthand syntax.
|
|
59
|
+
|
|
60
|
+
Correct:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
describe('my feature', () => {
|
|
64
|
+
it('should work', () => {
|
|
65
|
+
// assertions
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Wrong:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
describe('my feature', function () {
|
|
74
|
+
it('should work', function () {
|
|
75
|
+
// assertions
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- Deep nesting of `describe` blocks can make test output harder to read. When
|
|
81
|
+
nesting becomes excessive, split the test file and use `await import()` to
|
|
82
|
+
reorganize — this keeps the actual test code at shallow nesting levels.
|
|
83
|
+
|
|
55
84
|
## Naming conventions
|
|
56
85
|
|
|
57
86
|
- Test files use the `.test.mjs` suffix.
|
|
@@ -59,6 +88,69 @@ import './feature-b.test.mjs';
|
|
|
59
88
|
the module name or command name).
|
|
60
89
|
- `it` labels should describe the expected behavior in plain language.
|
|
61
90
|
|
|
91
|
+
### Suite name conventions
|
|
92
|
+
|
|
93
|
+
The `describe` suite name encodes the member type under test using a prefix
|
|
94
|
+
convention:
|
|
95
|
+
|
|
96
|
+
| Prefix | Meaning | Example |
|
|
97
|
+
| ------ | ---------------------------------------------------- | ------------------------- |
|
|
98
|
+
| `::` | Class static public member or namespace static | `describe('::parse()')` |
|
|
99
|
+
| `.` | Class instance member | `describe('.validate()')` |
|
|
100
|
+
| `()` | Marks the target as a function (composable) | `describe('::create()')` |
|
|
101
|
+
| `>` | Return-value testing, nested inside a function suite | `describe('>result')` |
|
|
102
|
+
| `#` | Event emitter — test event dispatch behavior | `describe('#error')` |
|
|
103
|
+
|
|
104
|
+
Prefixes and `()` compose freely. For example:
|
|
105
|
+
|
|
106
|
+
| Suite name | Meaning |
|
|
107
|
+
| ------------- | ----------------------------- |
|
|
108
|
+
| `::parse()` | Static function `parse` |
|
|
109
|
+
| `::VERSION` | Static property `VERSION` |
|
|
110
|
+
| `.validate()` | Instance method `validate` |
|
|
111
|
+
| `.name` | Instance property `name` |
|
|
112
|
+
| `validate()` | Standalone function (unbound) |
|
|
113
|
+
|
|
114
|
+
Examples:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
describe('::parse()', () => {
|
|
118
|
+
it('should parse valid input', () => {
|
|
119
|
+
/* ... */
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('::VERSION', () => {
|
|
124
|
+
it('should be a semver string', () => {
|
|
125
|
+
/* ... */
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('.validate()', () => {
|
|
130
|
+
it('should reject invalid data', () => {
|
|
131
|
+
/* ... */
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('>result', () => {
|
|
135
|
+
it('should be a boolean', () => {
|
|
136
|
+
/* ... */
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe('.name', () => {
|
|
142
|
+
it('should be non-empty', () => {
|
|
143
|
+
/* ... */
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('#error', () => {
|
|
148
|
+
it('should emit on failure', () => {
|
|
149
|
+
/* ... */
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
62
154
|
## Local debug workflow (recommended)
|
|
63
155
|
|
|
64
156
|
When debugging a failing test case:
|
|
@@ -34,17 +34,14 @@ The Produck monorepo provides unified configuration across all packages for cons
|
|
|
34
34
|
- If a repository overrides inherited rules, include only the deltas and
|
|
35
35
|
document the rationale.
|
|
36
36
|
|
|
37
|
-
**Usage
|
|
37
|
+
**Usage:**
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Package-specific overrides here
|
|
46
|
-
];
|
|
47
|
-
```
|
|
39
|
+
- Root `eslint.config.mjs` applies to all packages automatically via ESLint
|
|
40
|
+
flat config resolution — sub-packages are NOT required to create their own
|
|
41
|
+
`eslint.config.mjs`.
|
|
42
|
+
- Sub-packages may create a package-level `eslint.config.mjs` on demand for
|
|
43
|
+
workspace-specific overrides, but this is opt-in and not proactively
|
|
44
|
+
deployed.
|
|
48
45
|
|
|
49
46
|
### 2. TypeScript Configuration (`tsconfig.json`, conditional)
|
|
50
47
|
|
|
@@ -54,29 +51,49 @@ export default [
|
|
|
54
51
|
|
|
55
52
|
**Decision rule:**
|
|
56
53
|
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
Root-level `tsconfig.json` is **not** recommended for downstream repositories.
|
|
55
|
+
Prefer per-package `tsconfig.json` that stands alone.
|
|
56
|
+
|
|
57
|
+
- Do **not** create/deploy root `tsconfig.json` unless there is a clear,
|
|
58
|
+
unavoidable need for centralized TypeScript configuration (e.g., a shared
|
|
59
|
+
path alias map or compound project references).
|
|
60
|
+
- Each TypeScript package should manage its own `tsconfig.json` independently.
|
|
61
|
+
- Only introduce root `tsconfig.json` when per-package duplication becomes a
|
|
62
|
+
proven maintenance burden — not as a proactive measure.
|
|
63
|
+
|
|
64
|
+
**Governance (enforced by `agent-toolkit sync-typescript`):**
|
|
65
|
+
|
|
66
|
+
When root `tsconfig.json` exists, run
|
|
67
|
+
`agent-toolkit sync-typescript --package-root packages/<name> --cwd .`
|
|
68
|
+
to ensure a sub-package has a `tsconfig.json` that extends the root with the
|
|
69
|
+
correct relative path and uses standard compiler options. If the file already
|
|
70
|
+
exists, it is skipped without modification.
|
|
71
|
+
|
|
72
|
+
If no root `tsconfig.json` exists (the recommended default), each TypeScript
|
|
73
|
+
package maintains its own standalone `tsconfig.json` with its own compiler
|
|
74
|
+
options — no `extends` chain is needed.
|
|
61
75
|
|
|
62
|
-
**
|
|
76
|
+
**Enforced settings:**
|
|
63
77
|
|
|
64
78
|
- Target: ES2022
|
|
65
79
|
- Strict mode: enabled
|
|
66
|
-
- Module resolution:
|
|
80
|
+
- Module resolution: bundler
|
|
67
81
|
- Source maps: enabled
|
|
68
82
|
- Declaration files: generated
|
|
69
83
|
|
|
70
|
-
**Usage in TypeScript packages:**
|
|
84
|
+
**Usage in TypeScript packages (auto-generated by `--package-root`):**
|
|
71
85
|
|
|
72
86
|
```json
|
|
73
87
|
{
|
|
74
88
|
"extends": "../../tsconfig.json",
|
|
75
89
|
"compilerOptions": {
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
"lib": ["ESNext"],
|
|
91
|
+
"types": ["node"],
|
|
92
|
+
"strictNullChecks": true,
|
|
93
|
+
"allowJs": true,
|
|
94
|
+
"noEmit": true,
|
|
95
|
+
"module": "NodeNext"
|
|
96
|
+
}
|
|
80
97
|
}
|
|
81
98
|
```
|
|
82
99
|
|
|
@@ -88,7 +105,7 @@ export default [
|
|
|
88
105
|
|
|
89
106
|
**Rules:**
|
|
90
107
|
|
|
91
|
-
- Print width:
|
|
108
|
+
- Print width: 80 characters
|
|
92
109
|
- Tab width: 2 spaces
|
|
93
110
|
- Single quotes: true
|
|
94
111
|
- Trailing commas: es5
|
|
@@ -161,32 +178,49 @@ npm run produck:coverage
|
|
|
161
178
|
|
|
162
179
|
1. Create `packages/my-package/` directory
|
|
163
180
|
2. Create `packages/my-package/package.json` with workspace configuration
|
|
164
|
-
3.
|
|
165
|
-
- ESLint:
|
|
181
|
+
3. Config inheritance:
|
|
182
|
+
- ESLint: root `eslint.config.mjs` applies automatically — package-level
|
|
183
|
+
`eslint.config.mjs` is opt-in and not proactively deployed.
|
|
166
184
|
- TypeScript (when root `tsconfig.json` exists): extend
|
|
167
185
|
`../../tsconfig.json`
|
|
168
186
|
- Prettier: uses root `.prettierrc` automatically
|
|
169
187
|
|
|
170
188
|
### Package-Level Overrides
|
|
171
189
|
|
|
172
|
-
Each package
|
|
190
|
+
Each package's specific needs should be handled within the root shared config
|
|
191
|
+
whenever possible. Per-package ESLint config files are opt-in and not
|
|
192
|
+
proactively deployed; sub-packages may create one on demand.
|
|
173
193
|
|
|
174
|
-
|
|
194
|
+
For TypeScript configuration, packages may extend root `tsconfig.json` (see
|
|
195
|
+
[TypeScript Configuration](#2-typescript-configuration-tsconfigjson-conditional)
|
|
196
|
+
above).
|
|
175
197
|
|
|
176
|
-
|
|
177
|
-
import rootConfig from '../../eslint.config.mjs';
|
|
178
|
-
import onlyWarn from 'eslint-plugin-only-warn';
|
|
198
|
+
### Dependency Management in Downstream Repositories
|
|
179
199
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
200
|
+
When a monorepo policy is distributed to a downstream repository, sub-package
|
|
201
|
+
`devDependencies` must **not** duplicate workspace-level (root) devDependencies.
|
|
202
|
+
|
|
203
|
+
**Rationale:**
|
|
204
|
+
|
|
205
|
+
- Avoids version conflicts between root and sub-package declarations
|
|
206
|
+
- Eliminates ambiguity about which declaration is the source of truth
|
|
207
|
+
- Keeps sub-packages version-stable — root-level upgrades apply uniformly,
|
|
208
|
+
preventing drift across packages
|
|
209
|
+
- Reduces `npm install` deduplication overhead and `lockfile` churn
|
|
210
|
+
|
|
211
|
+
**Rule:**
|
|
212
|
+
|
|
213
|
+
- Shared tooling (ESLint, Prettier, TypeScript, c8, test runners, build tools)
|
|
214
|
+
belongs in root `devDependencies` only.
|
|
215
|
+
- Sub-packages may list only **package-specific** devDependencies that are not
|
|
216
|
+
already declared at root level.
|
|
217
|
+
- In the downstream repository, sub-packages that extend root configs (e.g.,
|
|
218
|
+
`extends` in `tsconfig.json` or `eslint.config.mjs`) inherit their tooling
|
|
219
|
+
from root and must **not** redeclare those tools in their own
|
|
220
|
+
`devDependencies`.
|
|
221
|
+
- When a downstream sub-package needs a different version of a root-level tool,
|
|
222
|
+
use root-level overrides (e.g., `overrides` or `resolutions` in root
|
|
223
|
+
`package.json`) rather than redeclaring in the sub-package.
|
|
190
224
|
|
|
191
225
|
## .editorconfig
|
|
192
226
|
|