@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.
- package/README.md +39 -24
- package/bin/agent-toolkit.mjs +51 -459
- package/bin/build-publish-assets.mjs +105 -0
- package/bin/command/main/index.mjs +11 -0
- package/bin/command/preflight/index.mjs +58 -0
- package/bin/command/run-capture/index.mjs +100 -0
- package/bin/command/shared/args.mjs +45 -0
- package/bin/command/shared/text-resource.mjs +19 -0
- package/bin/command/summarize-log/index.mjs +64 -0
- package/bin/command/sync-instructions/help.txt +11 -0
- package/bin/command/sync-instructions/index.mjs +272 -0
- package/bin/command/sync-instructions/user-space-bootstrap.md +14 -0
- package/bin/command/validate-commit-msg/help.txt +8 -0
- package/bin/command/validate-commit-msg/index.mjs +152 -0
- package/package.json +7 -3
- package/publish-assets/instructions/produck/00-produck-base.instructions.md +331 -0
- package/publish-assets/instructions/produck/10-produck-node.instructions.md +152 -0
- package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +299 -0
- package/publish-assets/instructions/produck/20-produck-commit.instructions.md +178 -0
- package/templates/default.instructions.md +0 -21
- package/templates/help/sync-instructions.txt +0 -8
- package/templates/help/validate-commit-msg.txt +0 -7
- /package/{templates/help/main.txt → bin/command/main/help.txt} +0 -0
- /package/{templates/help/preflight.txt → bin/command/preflight/help.txt} +0 -0
- /package/{templates/help/run-capture.txt → bin/command/run-capture/help.txt} +0 -0
- /package/{templates/help/summarize-log.txt → bin/command/summarize-log/help.txt} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Repository AI Instructions
|
|
2
|
+
|
|
3
|
+
This repository uses organization baseline instructions from:
|
|
4
|
+
|
|
5
|
+
- {{NAMESPACE_GLOB}}
|
|
6
|
+
|
|
7
|
+
Repository-specific rules should be written in this file.
|
|
8
|
+
Keep organization baseline rules in the produck namespace files above.
|
|
9
|
+
|
|
10
|
+
Recommended usage:
|
|
11
|
+
|
|
12
|
+
- Add local constraints and exceptions here.
|
|
13
|
+
- Do not copy organization baseline content into this file.
|
|
14
|
+
- Keep this file focused on repository-only behavior.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Usage:
|
|
2
|
+
agent-toolkit validate-commit-msg --file <message-file>
|
|
3
|
+
|
|
4
|
+
Rules:
|
|
5
|
+
- Non-empty lines must be either a section header (for example workspace: or @scope/pkg:) or start with [TAG]
|
|
6
|
+
- If section headers are used, each section header must be followed by at least one tagged line
|
|
7
|
+
- No empty lines are allowed
|
|
8
|
+
- Optional target form: [TAG] <target>: <summary>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
import { getSingle } from '../shared/args.mjs';
|
|
6
|
+
import { printTextResource } from '../shared/text-resource.mjs';
|
|
7
|
+
|
|
8
|
+
const ALLOWED_TAGS = ['INIT', 'ADD', 'REMOVE', 'FIX', 'REFACTOR', 'UPGRADE', 'PUBLISH'];
|
|
9
|
+
const ALLOWED_TARGETS = ['docs', 'test', 'ci', 'deps', 'api', 'schema', 'infra', 'fmt'];
|
|
10
|
+
const SECTION_HEADER_RE = /^(?:@[\w.-]+\/)?[\w.-]+:$/;
|
|
11
|
+
const COMMAND_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const HELP_FILE = path.resolve(COMMAND_DIR, 'help.txt');
|
|
13
|
+
|
|
14
|
+
export function printValidateCommitMsgHelp() {
|
|
15
|
+
printTextResource(HELP_FILE);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function validateCommitLine(line, lineNo) {
|
|
19
|
+
if (line.trim() === '') {
|
|
20
|
+
return `Line ${lineNo}: empty line is not allowed`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const head = line.match(/^\[([A-Z]+)\]\s+/);
|
|
24
|
+
if (!head) {
|
|
25
|
+
return `Line ${lineNo}: must start with [TAG] followed by a space`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const tag = head[1];
|
|
29
|
+
if (!ALLOWED_TAGS.includes(tag)) {
|
|
30
|
+
return `Line ${lineNo}: tag [${tag}] is not allowed`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const rest = line.slice(head[0].length);
|
|
34
|
+
if (rest.trim() === '') {
|
|
35
|
+
return `Line ${lineNo}: summary is required after tag`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const targetMatch = rest.match(/^<([^>]+)>:\s+(.+)$/);
|
|
39
|
+
if (targetMatch) {
|
|
40
|
+
const target = targetMatch[1];
|
|
41
|
+
const summary = targetMatch[2];
|
|
42
|
+
if (!ALLOWED_TARGETS.includes(target)) {
|
|
43
|
+
return `Line ${lineNo}: target <${target}> is not allowed`;
|
|
44
|
+
}
|
|
45
|
+
if (summary.trim() === '') {
|
|
46
|
+
return `Line ${lineNo}: summary is required after target`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isSectionHeaderLine(line) {
|
|
54
|
+
return SECTION_HEADER_RE.test(line.trim());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function validateSectionFormat(lines) {
|
|
58
|
+
const errors = [];
|
|
59
|
+
let currentSection = '';
|
|
60
|
+
let currentSectionLineNo = 0;
|
|
61
|
+
let currentSectionHasTaggedLine = false;
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
64
|
+
const lineNo = i + 1;
|
|
65
|
+
const line = lines[i];
|
|
66
|
+
|
|
67
|
+
if (line.trim() === '') {
|
|
68
|
+
errors.push(`Line ${lineNo}: empty line is not allowed`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (isSectionHeaderLine(line)) {
|
|
73
|
+
if (currentSection && !currentSectionHasTaggedLine) {
|
|
74
|
+
errors.push(
|
|
75
|
+
`Line ${currentSectionLineNo}: section header "${currentSection}" must be followed by at least one tagged line`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
currentSection = line.trim();
|
|
80
|
+
currentSectionLineNo = lineNo;
|
|
81
|
+
currentSectionHasTaggedLine = false;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!currentSection) {
|
|
86
|
+
errors.push(
|
|
87
|
+
`Line ${lineNo}: section header is required before tagged lines when package/workspace sections are used`,
|
|
88
|
+
);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const err = validateCommitLine(line, lineNo);
|
|
93
|
+
if (err) {
|
|
94
|
+
errors.push(err);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
currentSectionHasTaggedLine = true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (currentSection && !currentSectionHasTaggedLine) {
|
|
102
|
+
errors.push(
|
|
103
|
+
`Line ${currentSectionLineNo}: section header "${currentSection}" must be followed by at least one tagged line`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return errors;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function runValidateCommitMsg(options) {
|
|
111
|
+
const file = getSingle(options, '--file', '');
|
|
112
|
+
if (!file) {
|
|
113
|
+
printValidateCommitMsgHelp();
|
|
114
|
+
process.exit(2);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const filePath = path.resolve(file);
|
|
118
|
+
if (!fs.existsSync(filePath)) {
|
|
119
|
+
console.error(`Message file not found: ${filePath}`);
|
|
120
|
+
process.exit(2);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const raw = fs.readFileSync(filePath, 'utf8').replace(/\r\n/g, '\n');
|
|
124
|
+
const lines = raw.endsWith('\n') ? raw.slice(0, -1).split('\n') : raw.split('\n');
|
|
125
|
+
|
|
126
|
+
if (lines.length === 0 || (lines.length === 1 && lines[0].trim() === '')) {
|
|
127
|
+
console.error('Commit message is empty');
|
|
128
|
+
process.exit(2);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const hasSectionHeaders = lines.some((line) => isSectionHeaderLine(line));
|
|
132
|
+
|
|
133
|
+
const errors = hasSectionHeaders ? validateSectionFormat(lines) : [];
|
|
134
|
+
if (!hasSectionHeaders) {
|
|
135
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
136
|
+
const err = validateCommitLine(lines[i], i + 1);
|
|
137
|
+
if (err) {
|
|
138
|
+
errors.push(err);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (errors.length > 0) {
|
|
144
|
+
console.error('Commit message validation failed:');
|
|
145
|
+
for (const err of errors) {
|
|
146
|
+
console.error(`- ${err}`);
|
|
147
|
+
}
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
console.log('Commit message validation passed');
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produck/agent-toolkit",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Central CLI toolkit for organization AI execution workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
"agent-toolkit": "bin/agent-toolkit.mjs"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
+
"prepack": "node ./bin/build-publish-assets.mjs",
|
|
16
|
+
"coverage": "npm exec --yes -- c8 --reporter=lcov --reporter=html --reporter=text-summary node --test test/index.mjs",
|
|
17
|
+
"coverage:check": "npm exec --yes -- c8 --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 node --test test/index.mjs",
|
|
18
|
+
"test": "node --test test/index.mjs",
|
|
15
19
|
"verify": "node ./bin/agent-toolkit.mjs --help && node ./bin/agent-toolkit.mjs preflight --cwd . --require package.json",
|
|
16
20
|
"pack:check": "npm pack --dry-run"
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
19
23
|
"bin",
|
|
20
|
-
"
|
|
24
|
+
"publish-assets"
|
|
21
25
|
],
|
|
22
26
|
"publishConfig": {
|
|
23
27
|
"access": "public"
|
|
@@ -26,5 +30,5 @@
|
|
|
26
30
|
"node": ">=18.0.0"
|
|
27
31
|
},
|
|
28
32
|
"license": "MIT",
|
|
29
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "555d39b0f0ed95f59d457230f784c9dafe7b84d2"
|
|
30
34
|
}
|
|
@@ -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 optional and should be added only when
|
|
122
|
+
behavior intentionally differs from shared presets.
|
|
123
|
+
- In ESLint flat config, "layer on top" means local override items must appear
|
|
124
|
+
after shared preset items in exported order.
|
|
125
|
+
- No-op overrides that repeat inherited values should be avoided.
|
|
126
|
+
|
|
127
|
+
## Language conventions
|
|
128
|
+
|
|
129
|
+
- Explanations, discussion, and review communication default to Chinese unless
|
|
130
|
+
the repository or request requires another language.
|
|
131
|
+
- Commit messages keep the bracketed format and use English summaries.
|
|
132
|
+
- PR descriptions and issue comments may use Chinese or English, but keep one
|
|
133
|
+
language per section and keep terminology consistent.
|
|
134
|
+
- Code identifiers, filenames, and existing public API names should follow
|
|
135
|
+
existing repository conventions; do not translate existing symbols.
|
|
136
|
+
- User-facing copy should follow the target product locale of the
|
|
137
|
+
repository/module.
|
|
138
|
+
|
|
139
|
+
## Commit and PR conventions
|
|
140
|
+
|
|
141
|
+
- Commit messages use bracketed tags: `[TAG] summary`.
|
|
142
|
+
- Every non-empty commit message line must start with `[TAG]`.
|
|
143
|
+
- Empty lines are not allowed between commit message lines.
|
|
144
|
+
- Do not use untagged bullet lines in commit message body.
|
|
145
|
+
- If details are needed, use additional tagged lines.
|
|
146
|
+
- Do not keep summary as an untagged standalone line.
|
|
147
|
+
- Recommended local validation:
|
|
148
|
+
`npm exec --package=@produck/agent-toolkit@latest agent-toolkit
|
|
149
|
+
validate-commit-msg --file <message-file>`.
|
|
150
|
+
- Canonical source for commit tag/target whitelists, legacy mapping, and
|
|
151
|
+
target syntax is
|
|
152
|
+
`.github/distribution/produck/20-produck-commit.instructions.md`.
|
|
153
|
+
- Do not redefine commit tag or target whitelists in other instruction files.
|
|
154
|
+
- For non-monorepo repositories, use `[TAG] summary` directly (no
|
|
155
|
+
package/workspace section headers).
|
|
156
|
+
- Bracketed commit summaries should be in English
|
|
157
|
+
- `[UPGRADE] deps` is allowed for pure dependency upgrades; if IFF artifacts or
|
|
158
|
+
IPC-related artifacts/calls are updated, the summary must name those updates
|
|
159
|
+
explicitly.
|
|
160
|
+
- PR title format is repository-defined; no organization-level title format
|
|
161
|
+
restriction
|
|
162
|
+
- In PR descriptions, summarize what changed, why it changed, how it was
|
|
163
|
+
validated, and any known risks or follow-up work
|
|
164
|
+
|
|
165
|
+
## Terminal long-output protocol
|
|
166
|
+
|
|
167
|
+
When a command may produce large output (for example 10k+ lines), use a
|
|
168
|
+
two-phase flow instead of shell pipelines like `| grep` or `| tail`.
|
|
169
|
+
|
|
170
|
+
Node-first policy:
|
|
171
|
+
|
|
172
|
+
- MUST use Node scripts first for output processing, file processing, path
|
|
173
|
+
checks, and multi-step command orchestration.
|
|
174
|
+
- MAY use direct shell commands only for short, read-only, atomic checks (for
|
|
175
|
+
example status/list/current-directory checks).
|
|
176
|
+
- MUST avoid shell pipelines and stream redirection for long-output tasks.
|
|
177
|
+
|
|
178
|
+
- Phase 1 (capture): run command and write full output to a file first.
|
|
179
|
+
- Phase 2 (analyze): run a separate step to filter/summarize that file.
|
|
180
|
+
|
|
181
|
+
Recommended three-step flow:
|
|
182
|
+
|
|
183
|
+
1. Preflight: verify required files/paths and create output directories.
|
|
184
|
+
2. Capture: execute command and persist full output.
|
|
185
|
+
3. Analyze: summarize or filter captured output.
|
|
186
|
+
|
|
187
|
+
Recommended local tools:
|
|
188
|
+
|
|
189
|
+
- `npm exec --package=@produck/agent-toolkit@latest agent-toolkit preflight
|
|
190
|
+
--cwd . --require package.json --ensure-dir logs`
|
|
191
|
+
- `npm exec --package=@produck/agent-toolkit@latest agent-toolkit run-capture
|
|
192
|
+
--out logs/run.log --cmd "<command>"`
|
|
193
|
+
- `npm exec --package=@produck/agent-toolkit@latest agent-toolkit summarize-log
|
|
194
|
+
--file logs/run.log --last 120`
|
|
195
|
+
- `npm exec --package=@produck/agent-toolkit@latest agent-toolkit summarize-log
|
|
196
|
+
--file logs/run.log --match "FAIL|ERROR"`
|
|
197
|
+
|
|
198
|
+
Guardrails:
|
|
199
|
+
|
|
200
|
+
- Always create output directories before capture.
|
|
201
|
+
- Do not append fragile post-pipelines to the capture command.
|
|
202
|
+
- If filtering fails, keep the captured raw log as the source of truth.
|
|
203
|
+
|
|
204
|
+
Script placement and lifecycle policy:
|
|
205
|
+
|
|
206
|
+
- Reusable repository scripts MUST be stored in `scripts/`.
|
|
207
|
+
- Runtime outputs (logs, reports, captures) MUST be stored in `logs/` or
|
|
208
|
+
repository-defined output directories and ignored by git.
|
|
209
|
+
- For organization-level policy repositories (for example this `.github`
|
|
210
|
+
repository), do not add runtime-output `.gitignore` only for local agent
|
|
211
|
+
execution; use session memory paths or local temp locations instead.
|
|
212
|
+
- Temporary diagnostic scripts MUST NOT be committed and MUST use session
|
|
213
|
+
memory workspace paths when available.
|
|
214
|
+
- Do not place ad-hoc execution scripts in `.git/`, `.github/`, or random root
|
|
215
|
+
paths.
|
|
216
|
+
- `.github/` is reserved for GitHub platform config (workflows, templates,
|
|
217
|
+
issue forms), not for temporary run scripts.
|
|
218
|
+
|
|
219
|
+
## Organization-level AI instruction scope
|
|
220
|
+
|
|
221
|
+
This repository is the policy source for organization-wide AI instructions.
|
|
222
|
+
|
|
223
|
+
What works across repositories:
|
|
224
|
+
|
|
225
|
+
- Organization-level AI instruction text can guide agent behavior in all
|
|
226
|
+
repositories when configured at organization settings.
|
|
227
|
+
- Rules in `.github/distribution/produck/` are the downstream-sync source.
|
|
228
|
+
- Repository-specific rules may still add stricter constraints.
|
|
229
|
+
|
|
230
|
+
What does not work automatically:
|
|
231
|
+
|
|
232
|
+
- Scripts stored in this repository are not auto-mounted into other
|
|
233
|
+
repositories.
|
|
234
|
+
- Agents in another repository cannot assume local file paths from this
|
|
235
|
+
repository exist.
|
|
236
|
+
- Cross-repository script execution requires an explicit bridge mechanism.
|
|
237
|
+
|
|
238
|
+
### Manual instruction distribution workflow
|
|
239
|
+
|
|
240
|
+
When CI enforcement is deferred, use manual sync per repository:
|
|
241
|
+
|
|
242
|
+
1. Sync organization downstream source
|
|
243
|
+
`.github/distribution/produck/*.instructions.md` into target repository
|
|
244
|
+
`.github/instructions/produck/`.
|
|
245
|
+
2. Keep repository-specific exceptions in `.github/copilot-instructions.md`.
|
|
246
|
+
3. Validate critical policies manually in each update cycle.
|
|
247
|
+
4. After instruction sync, validate duplicated policy sections remain
|
|
248
|
+
consistent across instruction files, especially commit tag and target
|
|
249
|
+
whitelists.
|
|
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.
|