@produck/agent-toolkit 0.1.5 → 0.2.1

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 (26) hide show
  1. package/README.md +39 -24
  2. package/bin/agent-toolkit.mjs +51 -459
  3. package/bin/build-publish-assets.mjs +105 -0
  4. package/bin/command/main/index.mjs +11 -0
  5. package/bin/command/preflight/index.mjs +58 -0
  6. package/bin/command/run-capture/index.mjs +100 -0
  7. package/bin/command/shared/args.mjs +45 -0
  8. package/bin/command/shared/text-resource.mjs +19 -0
  9. package/bin/command/summarize-log/index.mjs +64 -0
  10. package/bin/command/sync-instructions/help.txt +11 -0
  11. package/bin/command/sync-instructions/index.mjs +272 -0
  12. package/bin/command/sync-instructions/user-space-bootstrap.md +14 -0
  13. package/bin/command/validate-commit-msg/help.txt +8 -0
  14. package/bin/command/validate-commit-msg/index.mjs +152 -0
  15. package/package.json +7 -3
  16. package/publish-assets/instructions/produck/00-produck-base.instructions.md +331 -0
  17. package/publish-assets/instructions/produck/10-produck-node.instructions.md +152 -0
  18. package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +299 -0
  19. package/publish-assets/instructions/produck/20-produck-commit.instructions.md +178 -0
  20. package/templates/default.instructions.md +0 -21
  21. package/templates/help/sync-instructions.txt +0 -8
  22. package/templates/help/validate-commit-msg.txt +0 -7
  23. /package/{templates/help/main.txt → bin/command/main/help.txt} +0 -0
  24. /package/{templates/help/preflight.txt → bin/command/preflight/help.txt} +0 -0
  25. /package/{templates/help/run-capture.txt → bin/command/run-capture/help.txt} +0 -0
  26. /package/{templates/help/summarize-log.txt → bin/command/summarize-log/help.txt} +0 -0
@@ -0,0 +1,299 @@
1
+ ---
2
+ applyTo: '**'
3
+ ---
4
+
5
+ <!-- managed-by: @produck/agent-toolkit -->
6
+ <!-- source: .github/distribution/produck/15-produck-workspace.instructions.md -->
7
+
8
+ # Workspace Shared Configuration Guide
9
+
10
+ ## Overview
11
+
12
+ The Produck monorepo provides unified configuration across all packages for consistency and ease of maintenance.
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
+ ## Shared Configurations
22
+
23
+ ### 1. ESLint Configuration (`eslint.config.mjs`)
24
+
25
+ **Location:** Root `eslint.config.mjs`
26
+
27
+ **Applies to:** All JavaScript, TypeScript files
28
+
29
+ **Rules:**
30
+
31
+ - Indentation: 2 spaces (error)
32
+ - Quotes: Single quotes (error)
33
+ - Line endings: Unix (LF) (error)
34
+ - Semicolons: Always required (error)
35
+ - Trailing commas: Always in multiline (error)
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.
43
+
44
+ **Usage in packages:**
45
+
46
+ ```javascript
47
+ // packages/my-package/eslint.config.mjs
48
+ import rootConfig from '../../eslint.config.mjs';
49
+
50
+ export default [
51
+ ...rootConfig,
52
+ // Package-specific overrides here
53
+ ];
54
+ ```
55
+
56
+ ### 2. TypeScript Configuration (`tsconfig.json`)
57
+
58
+ **Location:** Root `tsconfig.json`
59
+
60
+ **Applies to:** All TypeScript packages
61
+
62
+ **Key settings:**
63
+
64
+ - Target: ES2022
65
+ - Strict mode: enabled
66
+ - Module resolution: node
67
+ - Source maps: enabled
68
+ - Declaration files: generated
69
+
70
+ **Usage in packages:**
71
+
72
+ ```json
73
+ {
74
+ "extends": "../../tsconfig.json",
75
+ "compilerOptions": {
76
+ "outDir": "./dist"
77
+ },
78
+ "include": ["src/**/*"],
79
+ "exclude": ["node_modules", "dist", "test"]
80
+ }
81
+ ```
82
+
83
+ ### 3. Prettier Configuration (`.prettierrc`)
84
+
85
+ **Location:** Root `.prettierrc`
86
+
87
+ **Applies to:** All source files
88
+
89
+ **Rules:**
90
+
91
+ - Print width: 100 characters
92
+ - Tab width: 2 spaces
93
+ - Single quotes: true
94
+ - Trailing commas: es5
95
+ - Arrow parens: always
96
+ - Semicolons: true
97
+
98
+ **Ignored files:** `.prettierignore`
99
+
100
+ ### 4. Git Ignore Configuration (`.gitignore`)
101
+
102
+ **Location:** Root `.gitignore` (centralized, no package-level overrides)
103
+
104
+ **Applies to:** All files in the monorepo
105
+
106
+ **Strategy:** Single source of truth at repository root per monorepo convention
107
+
108
+ **Rules:**
109
+
110
+ - Dependencies: `node_modules/`, npm logs
111
+ - Coverage: `coverage/`, `.nyc_output/`
112
+ - Environment: `.env`, `.env.local`, `.env.*.local`
113
+ - Build: `dist/`, `build/`, `out/`, `*.tsbuildinfo`
114
+ - OS/Editor: `.DS_Store`, `Thumbs.db`, `.vscode/settings.json`, `.idea/`
115
+ - Temporary: `logs/`, `tmp/`, `temp/`
116
+ - Generated: `*.gen`, `*.ign` (organization team extensions)
117
+
118
+ **Why centralized?**
119
+
120
+ - All packages automatically inherit root patterns
121
+ - Single maintenance point
122
+ - No package-level overrides allowed
123
+ - Per organization baseline: keep ignore rules centralized at repository root whenever possible
124
+
125
+ ## Root Workspace Scripts
126
+
127
+ ### Verification & Quality
128
+
129
+ ```bash
130
+ # Type check all packages
131
+ npm run type-check
132
+
133
+ # Format check without writing
134
+ npm run format:check
135
+
136
+ # Format and write
137
+ npm run format
138
+
139
+ # Lint (requires root eslint.config.mjs)
140
+ npm run lint
141
+
142
+ # Run all package tests
143
+ npm run test
144
+
145
+ # Check coverage across packages
146
+ npm run coverage
147
+ ```
148
+
149
+ ### Package-Specific Commands
150
+
151
+ ```bash
152
+ # Verify toolkit package
153
+ npm run toolkit:verify
154
+
155
+ # Verify eslint-rules package
156
+ npm run eslint-rules:verify
157
+
158
+ # Check package distributions
159
+ npm run toolkit:pack-check
160
+ npm run eslint-rules:pack-check
161
+ ```
162
+
163
+ ## Package Integration
164
+
165
+ ### Adding a New Package
166
+
167
+ 1. Create `packages/my-package/` directory
168
+ 2. Create `packages/my-package/package.json` with workspace configuration
169
+ 3. Inherit root configs:
170
+ - ESLint: extend `../../eslint.config.mjs`
171
+ - TypeScript: extend `../../tsconfig.json`
172
+ - Prettier: uses root `.prettierrc` automatically
173
+
174
+ ### Package-Level Overrides
175
+
176
+ Each package can extend/override shared config:
177
+
178
+ **ESLint example:**
179
+
180
+ ```javascript
181
+ import rootConfig from '../../eslint.config.mjs';
182
+ import onlyWarn from 'eslint-plugin-only-warn';
183
+
184
+ export default [
185
+ ...rootConfig,
186
+ {
187
+ plugins: { 'only-warn': onlyWarn },
188
+ rules: {
189
+ 'custom-rule': 'warn', // package-specific override
190
+ },
191
+ },
192
+ ];
193
+ ```
194
+
195
+ ## .editorconfig
196
+
197
+ **Location:** Root `.editorconfig`
198
+
199
+ Applies to all editors supporting EditorConfig (VSCode, Vim, Sublime, etc.):
200
+
201
+ - Charset: utf-8
202
+ - Indent: 2 spaces
203
+ - Line endings: Unix (LF)
204
+ - Trim trailing whitespace
205
+
206
+ ## Dependencies
207
+
208
+ ### Shared devDependencies (Root)
209
+
210
+ - `@eslint/config-helpers`: ESLint configuration utilities
211
+ - `@eslint/js`: ESLint recommended config for JavaScript
212
+ - `eslint`: Core linter
213
+ - `typescript-eslint`: TypeScript linting support
214
+ - `globals`: Global variables (browser, node)
215
+ - `prettier`: Code formatter
216
+ - `typescript`: TypeScript compiler
217
+ - `@types/node`: Node.js type definitions
218
+
219
+ ### Peer Dependencies (Packages)
220
+
221
+ Each package declares peer dependencies for features it uses:
222
+
223
+ ```json
224
+ {
225
+ "peerDependencies": {
226
+ "eslint": ">=10.3.0",
227
+ "@eslint/config-helpers": ">=0.6.0"
228
+ }
229
+ }
230
+ ```
231
+
232
+ ## CI/CD Integration
233
+
234
+ Root scripts are designed for CI pipelines:
235
+
236
+ ```bash
237
+ # Pre-commit checks
238
+ npm run format:check
239
+ npm run type-check
240
+ npm run lint
241
+
242
+ # Testing
243
+ npm run test
244
+ npm run coverage
245
+
246
+ # Package verification
247
+ npm run toolkit:verify
248
+ npm run eslint-rules:verify
249
+ ```
250
+
251
+ ## Best Practices
252
+
253
+ 1. **Always extend shared config** instead of duplicating
254
+ 2. **Use workspace lint/format scripts** for consistency
255
+ 3. **Keep package-level overrides minimal** - justify in comments
256
+ 4. **Update root config** when org-wide rule changes needed
257
+ 5. **Test configuration changes** with all packages before committing
258
+ 6. **Do NOT add package-level `.gitignore`** - only root `.gitignore` is allowed; all packages inherit from it
259
+
260
+ ## Troubleshooting
261
+
262
+ ### ESLint complains about missing peer deps
263
+
264
+ ```bash
265
+ # Install missing peer dependencies
266
+ npm install
267
+ ```
268
+
269
+ ### Prettier conflicts with ESLint
270
+
271
+ Root `.prettierrc` and `eslint.config.mjs` are synchronized. If conflict occurs:
272
+
273
+ 1. Check both configs have matching rules
274
+ 2. Run `npm run format` first, then `npm run lint`
275
+
276
+ ### TypeScript includes too many files
277
+
278
+ Update `tsconfig.json` `include` and `exclude` patterns:
279
+
280
+ ```json
281
+ {
282
+ "include": ["packages/*/src/**/*.ts"],
283
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
284
+ }
285
+ ```
286
+
287
+ ### Files are being tracked by git that should be ignored
288
+
289
+ Verify `.gitignore` patterns:
290
+
291
+ ```bash
292
+ # Check if file matches any gitignore pattern
293
+ git check-ignore -v <file-or-directory>
294
+
295
+ # Update only root .gitignore - no package-level .gitignore allowed
296
+ # All packages inherit patterns from root
297
+ ```
298
+
299
+ Do NOT create package-level `.gitignore` files - they will be removed per organization policy.
@@ -0,0 +1,178 @@
1
+ ---
2
+ applyTo: '**'
3
+ ---
4
+
5
+ <!-- managed-by: @produck/agent-toolkit -->
6
+ <!-- source: .github/distribution/produck/20-produck-commit.instructions.md -->
7
+
8
+ # Commit Convention
9
+
10
+ Repositories in the `produck` organization use a bracketed TAG style for commit
11
+ messages.
12
+
13
+ ## Format
14
+
15
+ Use this format:
16
+
17
+ - `[TAG] summary`
18
+
19
+ Multi-line commit message rule:
20
+
21
+ - Every non-empty line in the commit message must start with `[TAG]`.
22
+ - Empty lines are not allowed in commit message body.
23
+ - Do not use untagged bullet lines in commit message body.
24
+ - If body details are needed, repeat tagged lines instead of raw bullets.
25
+ - `summary` cannot appear as a standalone untagged line.
26
+
27
+ Monorepo format (required for multi-package repositories):
28
+
29
+ - Package/workspace labels appear as **section headers** followed by a colon
30
+ (format: `package-name:` or `@scope/package:`).
31
+ - All lines under a package header belong to that package.
32
+ - Every line under a package header must start with `[TAG]`.
33
+ - No empty lines between tagged lines within a package section.
34
+ - Multiple packages follow the same pattern (each with its own header).
35
+
36
+ Example monorepo format:
37
+
38
+ ```
39
+ foo:
40
+ [FIX] race condition in auth handler
41
+ [ADD] <test>: cover edge case for concurrent login
42
+ bar:
43
+ [REFACTOR] <docs>: rewrite installation guide
44
+ ```
45
+
46
+ Standalone repository format:
47
+
48
+ - Do not use package/workspace section headers.
49
+ - Write commit messages directly as `[TAG] summary`.
50
+ - All tagged lines belong to the repository globally.
51
+
52
+ Allowed tags (fixed whitelist):
53
+
54
+ - `[INIT]`
55
+ - `[ADD]`
56
+ - `[REMOVE]`
57
+ - `[FIX]`
58
+ - `[REFACTOR]`
59
+ - `[UPGRADE]`
60
+ - `[PUBLISH]`
61
+
62
+ Legacy-to-canonical mapping (for migration):
63
+
64
+ - `[ADDED]` -> `[ADD]`
65
+ - `[REMOVED]` -> `[REMOVE]`
66
+ - `[FIXED]` -> `[FIX]`
67
+
68
+ When using this style:
69
+
70
+ - `TAG` must be uppercase and must be one of the allowed tags above.
71
+ - Summary must be in English.
72
+ - Keep summaries specific and behavior-oriented.
73
+ - Summary may include a target noun prefix to express content domain.
74
+ - Mention concrete areas when useful (route, endpoint, helper, file, test,
75
+ constraint).
76
+ - Prefer one clear tagged change per line when writing grouped summaries.
77
+ - `[REFACTOR]` implies potentially breaking updates and should explicitly
78
+ describe impact.
79
+ - Special rule for `[UPGRADE]`: use `[UPGRADE] deps` for pure dependency
80
+ upgrades.
81
+ - If `[UPGRADE]` also includes IFF artifacts or IPC-related artifacts/calls, the
82
+ summary must explicitly name the updated artifact/call.
83
+ - Special rule for `[PUBLISH]`: use `[PUBLISH]` for release and package
84
+ publishing commits managed by lerna or similar tools. No target required.
85
+
86
+ Summary target extension (optional):
87
+
88
+ - Format: `[TAG] <target>: <summary>`
89
+ - Allowed targets (fixed whitelist):
90
+ - `docs`: documentation content, guides, comments, and usage notes
91
+ - `test`: test cases, fixtures, assertions, and test tooling
92
+ - `ci`: continuous integration workflows, pipeline steps, and automation jobs
93
+ - `deps`: dependency declarations, lockfiles, and dependency management scripts
94
+ - `api`: externally visible interfaces, route contracts, and client/server API
95
+ behavior
96
+ - `schema`: data model definitions, migration schemas, and validation schema
97
+ changes
98
+ - `infra`: infrastructure and environment provisioning/configuration
99
+ - `fmt`: code formatting, style, and linter configuration changes
100
+ - When target syntax is used, `target` must be one of the allowed values above.
101
+ - Target must be wrapped in angle brackets (`<target>`) to distinguish it from
102
+ namespace-like identifiers inside summary text.
103
+ - Targets are nouns in summary context, not tags.
104
+
105
+ ## Examples
106
+
107
+ - `[FIX] race conditions in createTeam/acceptInvitation/acceptRequest by
108
+ wrapping checks and writes in one transaction`
109
+ - `[FIX] <infra>: enforce node-first execution`
110
+ - `[FIX] <infra>: remove repo-local ignore for transient logs`
111
+ - `[FIX] <infra>: add policy-repo exception for local agent output`
112
+ - `[ADD] shared helper src/Web/Student/Router/Team/membership.mjs for
113
+ student-side team mutation routes`
114
+ - `[REFACTOR] remove c8 ignore on Screenshot.mjs response.ok (covered by
115
+ integration test)`
116
+ - `[INIT] initialize @tjuamt/eer-score-field-ai-kitchen debug tool`
117
+ - `[REMOVE] deprecated score-field prompt template`
118
+ - `[UPGRADE] deps`
119
+ - `[ADD] <docs>: onboarding section for monorepo mode`
120
+ - `[FIX] <test>: stabilize screenshot upload retry assertion`
121
+ - `[REFACTOR] <ci>: split lint and test jobs for faster feedback`
122
+
123
+ Monorepo examples:
124
+
125
+ ```
126
+ foo:
127
+ [FIX] a
128
+ [FIX] b
129
+ [FIX] c
130
+ ```
131
+
132
+ ```
133
+ core:
134
+ [ADD] <api>: new user authentication endpoint
135
+ [REFACTOR] <test>: restructure session management tests
136
+ utils:
137
+ [UPGRADE] <deps>: update lodash to v4.17.21
138
+ [FIX] <docs>: clarify error handling in README
139
+ ```
140
+
141
+ ## Avoid
142
+
143
+ Avoid vague or low-signal messages such as:
144
+
145
+ - `[ADD] update things`
146
+ - `[FIX] issue`
147
+ - `[UPGRADE] dependencies` when artifact/call updates exist but are not named
148
+ - `[ADD] docs: ...` (target syntax without angle brackets)
149
+ - `[ADD] <feature>: ...` (target outside allowed whitelist)
150
+ - `[added] ...` (non-uppercase tag)
151
+ - `[CHANGED] ...` (tag outside whitelist)
152
+ - `- remove old script` (untagged body line)
153
+ - `summary without tag` (untagged standalone line)
154
+ - empty lines between tagged lines
155
+ - Monorepo mistakes:
156
+ - `foo: [FIX] a` (package header and tag on same line)
157
+ - `@produck/foo: [FIX] a` (package name in every tag line instead of
158
+ section header)
159
+ - `foo:\n\n[FIX] a` (empty line after package header)
160
+ - `foo:` without any tagged lines below (orphaned section header)
161
+
162
+ ## Validation
163
+
164
+ Use the local validator before commit:
165
+
166
+ - Validation is required before both `git commit` and `git commit --amend`.
167
+ - Do not create or amend a commit when validation fails.
168
+
169
+ - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit
170
+ validate-commit-msg --file <message-file>`
171
+
172
+ If validation fails, fix the message and rerun until it passes.
173
+
174
+ ## Notes
175
+
176
+ - Keep the summary concise and specific.
177
+ - Prefer imperative phrasing.
178
+ - This document does not restrict PR title format.
@@ -1,21 +0,0 @@
1
- # Organization Collaboration Instructions
2
-
3
- This repository follows organization-level AI and engineering rules.
4
-
5
- ## Required Rules
6
-
7
- - Commit message format must follow bracketed TAG policy.
8
- - Keep root .editorconfig aligned with organization baseline:
9
- - If missing, create from organization sample.
10
- - If present, add missing required keys only (minimal merge).
11
- - Repository owners generate and own eslint.config.mjs.
12
- - AI must not rewrite full eslint config; only add missing
13
- @produck/eslint-rules integration as minimal patch.
14
- - Repository-specific ESLint overrides must layer on top of
15
- @produck/eslint-rules.
16
-
17
- ## References
18
-
19
- - docs/ai-collaboration.md
20
- - docs/commit-convention.md
21
- - docs/nodejs-initialization.md
@@ -1,8 +0,0 @@
1
- Usage:
2
- agent-toolkit sync-instructions [--cwd <dir>] [--out <file>]
3
- [--source <file>] [--force] [--dry-run]
4
-
5
- Behavior:
6
- - Writes organization instruction entrypoint template to target file.
7
- - Defaults to <cwd>/.instructions.md when --out is not provided.
8
- - If target exists, command fails unless --force is set.
@@ -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>