@produck/agent-toolkit 0.1.5 → 0.2.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.
@@ -0,0 +1,331 @@
1
+ ---
2
+ applyTo: '**'
3
+ ---
4
+
5
+ <!-- managed-by: @produck/agent-toolkit -->
6
+ <!-- source: .github/distribution/produck/00-produck-base.instructions.md -->
7
+
8
+ # AI Collaboration
9
+
10
+ This document defines a lightweight AI collaboration baseline for repositories
11
+ in the `produck` organization.
12
+
13
+ ## Goals
14
+
15
+ - Improve consistency when using AI tools across repositories
16
+ - Keep the baseline lightweight and easy to adopt
17
+ - Let repositories add stricter or more specific instructions when needed
18
+
19
+ ## Instruction source split
20
+
21
+ To separate organization-only governance from downstream-distributable
22
+ baseline, policy sources are split as follows:
23
+
24
+ - Downstream-distributable source:
25
+ `.github/distribution/produck/*.instructions.md`
26
+ - Organization-only source (not distributed):
27
+ `.github/instructions/produck/*.instructions.md`
28
+
29
+ Editing rule:
30
+
31
+ - Update downstream baseline rules directly in
32
+ `.github/distribution/produck/*.instructions.md`.
33
+ - Update organization-only workflow/governance in
34
+ `.github/instructions/produck/`.
35
+
36
+ ## Default expectations
37
+
38
+ - Default to Chinese for explanations and discussion unless the repository or
39
+ request requires another language.
40
+ - Prefer existing repository patterns over introducing new abstractions or
41
+ frameworks.
42
+ - Do not invent APIs, packages, configuration keys, commands, environment
43
+ variables, or files.
44
+ - Do not add new dependencies unless necessary and explicitly justified.
45
+ - When changing behavior, add or update tests when practical.
46
+ - Treat authentication, authorization, secrets, infrastructure, and production
47
+ configuration as high-risk areas that require human review.
48
+ - Repositories should include a root `.gitattributes` to normalize line endings
49
+ safely across platforms.
50
+
51
+ ## Git attributes conventions
52
+
53
+ - All repositories should include a root `.gitattributes`.
54
+ - Default text line ending policy is LF.
55
+ - Recommended minimum template:
56
+
57
+ ```gitattributes
58
+ * text=auto eol=lf
59
+
60
+ # Windows script entrypoints
61
+ *.bat text eol=crlf
62
+ *.cmd text eol=crlf
63
+ ```
64
+
65
+ - Repository-specific exceptions are allowed but must be documented in
66
+ repository instructions.
67
+
68
+ ## EditorConfig conventions
69
+
70
+ - All repositories should include a root `.editorconfig`.
71
+ - Recommended organization baseline:
72
+
73
+ ```editorconfig
74
+ root = true
75
+
76
+ [*]
77
+ charset = utf-8
78
+ indent_style = space
79
+ indent_size = 2
80
+ trim_trailing_whitespace = true
81
+
82
+ [*.yml]
83
+ indent_style = space
84
+ indent_size = 2
85
+
86
+ [*.yaml]
87
+ indent_style = space
88
+ indent_size = 2
89
+
90
+ [*.md]
91
+ trim_trailing_whitespace = false
92
+ max_line_length = 80
93
+ ```
94
+
95
+ - Repository-specific exceptions are allowed but must be documented in
96
+ repository instructions.
97
+ - Organization-wide requirement: all Markdown files should keep each line at 80
98
+ characters or fewer.
99
+
100
+ ### EditorConfig quick rule
101
+
102
+ - Default action: directly copy the `.editorconfig` sample in this document.
103
+ - If target repository has no root `.editorconfig`, create one from this sample
104
+ without modification.
105
+ - If target repository already has a root `.editorconfig`, do not replace the
106
+ whole file; add only missing required keys from this sample.
107
+ - Repository-documented exceptions override this sample.
108
+ - If an exception applies, keep the exception and record it in change notes.
109
+ - Do not include unrelated formatting-only changes in the same commit.
110
+
111
+ ## ESLint conventions
112
+
113
+ - Repository owners generate `eslint.config.mjs` first (for example via
114
+ framework scaffolding or ESLint official initialization flow).
115
+ - AI must not replace the existing config wholesale; it should only check the
116
+ current config and add missing `@produck/eslint-rules` integration.
117
+ - `@produck/eslint-rules` is the organization-wide style consensus and should
118
+ be present in repository lint configuration.
119
+ - Apply minimal patching only: keep existing repository/framework structure and
120
+ add the smallest necessary changes.
121
+ - Repository-specific overrides are allowed, but should layer on top of
122
+ `@produck/eslint-rules` instead of bypassing it.
123
+
124
+ ## Language conventions
125
+
126
+ - Explanations, discussion, and review communication default to Chinese unless
127
+ the repository or request requires another language.
128
+ - Commit messages keep the bracketed format and use English summaries.
129
+ - PR descriptions and issue comments may use Chinese or English, but keep one
130
+ language per section and keep terminology consistent.
131
+ - Code identifiers, filenames, and existing public API names should follow
132
+ existing repository conventions; do not translate existing symbols.
133
+ - User-facing copy should follow the target product locale of the
134
+ repository/module.
135
+
136
+ ## Commit and PR conventions
137
+
138
+ - Commit messages use bracketed tags: `[TAG] summary`.
139
+ - Every non-empty commit message line must start with `[TAG]`.
140
+ - Empty lines are not allowed between commit message lines.
141
+ - Do not use untagged bullet lines in commit message body.
142
+ - If details are needed, use additional tagged lines.
143
+ - Do not keep summary as an untagged standalone line.
144
+ - Recommended local validation:
145
+ `npm exec --package=@produck/agent-toolkit@latest agent-toolkit
146
+ validate-commit-msg --file <message-file>`.
147
+ - Use uppercase tags from this whitelist: `[INIT]`, `[ADD]`, `[REMOVE]`,
148
+ `[FIX]`, `[REFACTOR]`, `[UPGRADE]`.
149
+ - Legacy tag mapping for migration is `[ADDED]` -> `[ADD]`, `[REMOVED]` ->
150
+ `[REMOVE]`, and `[FIXED]` -> `[FIX]`.
151
+ - To express content domain, summary may use target syntax: `[TAG] <target>:
152
+ <summary>`.
153
+ - Allowed targets are `docs`, `test`, `ci`, `deps`, `api`, `schema`, and
154
+ `infra`.
155
+ - If target syntax is used, target must be wrapped in angle brackets and must be
156
+ from the allowed target list.
157
+ - For non-monorepo repositories, use `[TAG] summary` directly (no
158
+ package/workspace section headers).
159
+ - Bracketed commit summaries should be in English
160
+ - `[UPGRADE] deps` is allowed for pure dependency upgrades; if IFF artifacts or
161
+ IPC-related artifacts/calls are updated, the summary must name those updates
162
+ explicitly.
163
+ - PR title format is repository-defined; no organization-level title format
164
+ restriction
165
+ - In PR descriptions, summarize what changed, why it changed, how it was
166
+ validated, and any known risks or follow-up work
167
+
168
+ ## Terminal long-output protocol
169
+
170
+ When a command may produce large output (for example 10k+ lines), use a
171
+ two-phase flow instead of shell pipelines like `| grep` or `| tail`.
172
+
173
+ Node-first policy:
174
+
175
+ - MUST use Node scripts first for output processing, file processing, path
176
+ checks, and multi-step command orchestration.
177
+ - MAY use direct shell commands only for short, read-only, atomic checks (for
178
+ example status/list/current-directory checks).
179
+ - MUST avoid shell pipelines and stream redirection for long-output tasks.
180
+
181
+ - Phase 1 (capture): run command and write full output to a file first.
182
+ - Phase 2 (analyze): run a separate step to filter/summarize that file.
183
+
184
+ Recommended three-step flow:
185
+
186
+ 1. Preflight: verify required files/paths and create output directories.
187
+ 2. Capture: execute command and persist full output.
188
+ 3. Analyze: summarize or filter captured output.
189
+
190
+ Recommended local tools:
191
+
192
+ - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit preflight
193
+ --cwd . --require package.json --ensure-dir logs`
194
+ - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit run-capture
195
+ --out logs/run.log --cmd "<command>"`
196
+ - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit summarize-log
197
+ --file logs/run.log --last 120`
198
+ - `npm exec --package=@produck/agent-toolkit@latest agent-toolkit summarize-log
199
+ --file logs/run.log --match "FAIL|ERROR"`
200
+
201
+ Guardrails:
202
+
203
+ - Always create output directories before capture.
204
+ - Do not append fragile post-pipelines to the capture command.
205
+ - If filtering fails, keep the captured raw log as the source of truth.
206
+
207
+ Script placement and lifecycle policy:
208
+
209
+ - Reusable repository scripts MUST be stored in `scripts/`.
210
+ - Runtime outputs (logs, reports, captures) MUST be stored in `logs/` or
211
+ repository-defined output directories and ignored by git.
212
+ - For organization-level policy repositories (for example this `.github`
213
+ repository), do not add runtime-output `.gitignore` only for local agent
214
+ execution; use session memory paths or local temp locations instead.
215
+ - Temporary diagnostic scripts MUST NOT be committed and MUST use session
216
+ memory workspace paths when available.
217
+ - Do not place ad-hoc execution scripts in `.git/`, `.github/`, or random root
218
+ paths.
219
+ - `.github/` is reserved for GitHub platform config (workflows, templates,
220
+ issue forms), not for temporary run scripts.
221
+
222
+ ## Organization-level AI instruction scope
223
+
224
+ This repository is the policy source for organization-wide AI instructions.
225
+
226
+ What works across repositories:
227
+
228
+ - Organization-level AI instruction text can guide agent behavior in all
229
+ repositories when configured at organization settings.
230
+ - Rules in `.github/distribution/produck/` are the downstream-sync source.
231
+ - Repository-specific rules may still add stricter constraints.
232
+
233
+ What does not work automatically:
234
+
235
+ - Scripts stored in this repository are not auto-mounted into other
236
+ repositories.
237
+ - Agents in another repository cannot assume local file paths from this
238
+ repository exist.
239
+ - Cross-repository script execution requires an explicit bridge mechanism.
240
+
241
+ ### Manual instruction distribution workflow
242
+
243
+ When CI enforcement is deferred, use manual sync per repository:
244
+
245
+ 1. Sync organization downstream source
246
+ `.github/distribution/produck/*.instructions.md` into target repository
247
+ `.github/instructions/produck/`.
248
+ 2. Keep repository-specific exceptions in `.github/copilot-instructions.md`.
249
+ 3. Validate critical policies manually in each update cycle.
250
+
251
+ Recommended command:
252
+
253
+ - `npm exec --package=@produck/agent-toolkit@latest -- agent-toolkit sync-instructions --cwd . --source <path-to-org>/.github/distribution/produck --force --prune`
254
+
255
+ If the package has been published, `--source` can be omitted to use built-in
256
+ assets from `@produck/agent-toolkit`.
257
+
258
+ This keeps instruction entrypoints aligned without requiring submodule or
259
+ automatic PR rollout.
260
+
261
+ ### Central package execution policy
262
+
263
+ When bridge mechanism uses a central npm package, default execution strategy is
264
+ `@latest` to deliver new capabilities quickly.
265
+
266
+ Local implementation reference in this repository:
267
+
268
+ - `packages/agent-toolkit` stores the central CLI bridge package source.
269
+ - `packages/eslint-rules` stores the shared ESLint rule presets.
270
+ - This local path is the implementation source, not an automatic runtime mount
271
+ for other repositories.
272
+
273
+ Required safeguards for `@latest`:
274
+
275
+ - Print resolved package version before running high-impact commands.
276
+ - For high-risk operations, run dry-run/preview first, then execute.
277
+ - Keep an emergency fallback path to a pinned version for incident mitigation.
278
+ - Prefer `npm exec --package=<pkg>@latest <bin> ...` for predictable invocation.
279
+
280
+ Version observability (required before high-impact operations):
281
+
282
+ - `npm view @produck/agent-toolkit version`
283
+ - Record the observed version in task notes or PR description.
284
+
285
+ Post-release synchronization (required):
286
+
287
+ - Push release commit: `git push`
288
+ - Push release tag: `git push --tags`
289
+
290
+ Rollback runbook (minimum):
291
+
292
+ - Confirm latest published version:
293
+ `npm view @produck/agent-toolkit version`
294
+ - If rollback is needed, bump from current source and republish a fixed version.
295
+ - Do not republish an already-used version number.
296
+ - Push corresponding commit and tags after rollback publish.
297
+
298
+ ### Recommended organization AI instruction template
299
+
300
+ Use the following template text in organization AI instructions:
301
+
302
+ - Use Chinese for discussion unless repository rules require another language.
303
+ - Follow existing repository patterns; do not invent APIs, files, commands, or
304
+ config keys.
305
+ - Node-first execution policy:
306
+ - Use Node scripts first for file/path/output processing.
307
+ - For large output tasks, use two phases: capture full output, then analyze.
308
+ - Avoid fragile shell pipeline post-processing for long-output commands.
309
+ - Central package policy:
310
+ - Default to `<pkg>@latest` for organization tooling commands.
311
+ - Print resolved package version before high-impact execution.
312
+ - Use dry-run first for risky operations; keep rollback path to pinned version.
313
+ - Commit message policy:
314
+ - Every non-empty commit message line must start with `[TAG]`.
315
+ - Empty lines are not allowed between commit message lines.
316
+ - Use only allowed tags: `[INIT]`, `[ADD]`, `[REMOVE]`, `[FIX]`,
317
+ `[REFACTOR]`, `[UPGRADE]`.
318
+ - Optional target syntax is `[TAG] <target>: <summary>` with target in:
319
+ `docs`, `test`, `ci`, `deps`, `api`, `schema`, `infra`.
320
+ - Do not assume scripts from organization `.github` repository exist in target
321
+ repositories.
322
+ - If a repository provides stricter rules, repository rules override
323
+ organization defaults.
324
+
325
+ ## Precedence
326
+
327
+ If a repository provides more specific instructions, follow the repository
328
+ instructions over this organization baseline.
329
+
330
+ For Node.js repositories, also follow [Node.js Initialization
331
+ Baseline](10-produck-node.instructions.md).
@@ -0,0 +1,152 @@
1
+ ---
2
+ applyTo: '**/*.{js,cjs,mjs,ts,tsx,json,yaml,yml}'
3
+ ---
4
+
5
+ <!-- managed-by: @produck/agent-toolkit -->
6
+ <!-- source: .github/distribution/produck/10-produck-node.instructions.md -->
7
+
8
+ # Node.js Initialization Baseline
9
+
10
+ This document defines the organization-level initialization baseline for Node.js
11
+ repositories.
12
+
13
+ ## Scope
14
+
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`).
31
+ - Follow the organization `.gitattributes` baseline (LF default for text files).
32
+ - Follow the organization `.editorconfig` baseline.
33
+
34
+ Required script keys:
35
+
36
+ - `deps:install`
37
+ - `test`
38
+ - `coverage`
39
+ - `lint`
40
+ - `publish`
41
+
42
+ Notes:
43
+
44
+ - Script key names are fixed and must match exactly.
45
+ - `publish` may be a no-op when repository-specific release workflow does not
46
+ use npm publishing.
47
+
48
+ - Testing strategy and framework are repository-defined.
49
+ - Repositories must keep `npm run test` and `npm run coverage` executable.
50
+
51
+ Test authoring baseline (required):
52
+
53
+ - Prefer Node.js standard library test runner (`node:test`) with `describe` and
54
+ `it`.
55
+ - Each test case must be independently executable.
56
+ - Test cases must not depend on execution order or state from other cases.
57
+ - New test debugging should use local `only` mode for scoped regression.
58
+ - After debugging, remove all `only` markers before final validation.
59
+
60
+ Recommended local debug flow:
61
+
62
+ 1. Add `{ only: true }` to the target `describe/it` and all ancestor
63
+ `describe` blocks.
64
+ 2. Run `node --test --test-only test/index.mjs`.
65
+ 3. Remove all `only` markers.
66
+ 4. Run full regression via repository standard test command.
67
+
68
+ Script and output directory policy:
69
+
70
+ - Reusable project scripts should be committed under root `scripts/`.
71
+ - Organization-level shared tooling may use a central npm package bridge instead
72
+ of repository-local `scripts/` duplication.
73
+ - Runtime command outputs should be written under root `logs/` (or a documented
74
+ equivalent) and ignored by git.
75
+ - Temporary debug scripts should not be committed.
76
+ - `.github/` should not be used as a temporary script workspace.
77
+
78
+ Required ignore baseline:
79
+
80
+ - Each Node.js repository must include a root `.gitignore`.
81
+ - The root `.gitignore` must start from the GitHub default template for Node.js
82
+ projects (`Node.gitignore` from github/gitignore).
83
+ - Team-specific ignore conventions should be appended on top of that baseline
84
+ template, not used as a replacement.
85
+ - The root `.gitignore` should at minimum ignore:
86
+ - `node_modules/`
87
+ - `coverage/`
88
+ - `.env`
89
+ - `.env.*`
90
+ - npm logs (for example `npm-debug.log*`)
91
+ - OS/editor noise (for example `.DS_Store`, `Thumbs.db`, `.vscode/` when
92
+ workspace settings are not intended to be shared)
93
+
94
+ Team conventions for `.gitignore`:
95
+
96
+ - Keep organization-wide additions grouped under a dedicated comment block for
97
+ easy updates.
98
+ - Do not remove baseline entries from the GitHub template unless repository
99
+ owners document a justified exception.
100
+ - Organization-approved team extension entries are:
101
+ - `*.ign*` (manually created local directories/files that should not be
102
+ committed)
103
+ - `*.gen*` (generated artifacts created by program execution, for example
104
+ during tests)
105
+ - Append these team entries under a dedicated team block at the end of the root
106
+ `.gitignore`.
107
+
108
+ ## Monorepo mode
109
+
110
+ Repository layout:
111
+
112
+ - Root-level `docs/` is required.
113
+ - Each package/app should contain its own `src/` and `test/`.
114
+
115
+ Script placement:
116
+
117
+ - Root `package.json` must provide `deps:install`, `test`, `coverage`, and
118
+ `lint` orchestration scripts.
119
+ - `publish` may be defined at root or package level based on release workflow.
120
+
121
+ Ignore strategy:
122
+
123
+ - Keep ignore rules centralized at repository root whenever possible.
124
+ - Add package-level `.gitignore` only when a package has unique generated
125
+ artifacts.
126
+
127
+ ## Standalone mode
128
+
129
+ Repository layout:
130
+
131
+ - Top-level `src/`, `test/`, and `docs/` are required.
132
+
133
+ Script placement:
134
+
135
+ - The repository root `package.json` must define `deps:install`, `test`,
136
+ `coverage`, `lint`, and `publish`.
137
+
138
+ Ignore strategy:
139
+
140
+ - Keep project-specific generated files ignored in the repository root
141
+ `.gitignore`.
142
+
143
+ ## Enforcement strategy
144
+
145
+ - This baseline is enforced by documentation first.
146
+ - CI enforcement can be added later with repository checks.
147
+
148
+ ## Precedence
149
+
150
+ - Repository-specific rules may add stricter requirements.
151
+ - If repository-specific rules conflict with this document, repository owners
152
+ should explicitly document the exception.