@produck/agent-toolkit 0.6.0 → 0.7.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/README.md +74 -43
- package/bin/agent-toolkit.mjs +26 -33
- package/bin/build-publish-assets.mjs +28 -0
- package/bin/command/enforce-node-baseline/help.txt +12 -10
- package/bin/command/enforce-node-baseline/index.mjs +23 -15
- package/bin/command/main/help.txt +6 -5
- package/bin/command/preflight/help.txt +1 -1
- package/bin/command/preflight/index.mjs +1 -1
- package/bin/command/{sync-coverage-script → sync-coverage}/help.txt +2 -1
- package/bin/command/{sync-coverage-script → sync-coverage}/index.mjs +116 -19
- package/bin/command/sync-editorconfig/index.mjs +10 -153
- package/bin/command/{sync-prettier-config → sync-format}/help.txt +2 -2
- package/bin/command/{sync-prettier-config → sync-format}/index.mjs +63 -9
- package/bin/command/{sync-workspace-config → sync-git}/help.txt +10 -6
- package/bin/command/sync-git/index.mjs +424 -0
- package/bin/command/sync-install/help.txt +14 -0
- package/bin/command/sync-install/index.mjs +106 -0
- package/bin/command/{sync-eslint-config → sync-lint}/help.txt +2 -2
- package/bin/command/{sync-eslint-config → sync-lint}/index.mjs +3 -4
- package/bin/command/sync-publish/help.txt +18 -0
- package/bin/command/sync-publish/index.mjs +157 -0
- package/bin/command/validate-commit-msg/index.mjs +30 -2
- package/package.json +3 -5
- package/publish-assets/gitattributes +5 -0
- package/publish-assets/gitignore +137 -0
- package/publish-assets/instructions/produck/10-produck-node.instructions.md +53 -40
- package/publish-assets/instructions/produck/15-produck-workspace.instructions.md +13 -16
- package/publish-assets/instructions/produck/20-produck-commit.instructions.md +2 -2
- package/publish-assets/instructions/produck/tooling-version-baseline.json +8 -1
- package/bin/command/sync-husky-hooks/help.txt +0 -14
- package/bin/command/sync-husky-hooks/index.mjs +0 -89
- package/bin/command/sync-workspace-config/index.mjs +0 -290
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
import { getSingle, hasFlag } from '../shared/args.mjs';
|
|
6
|
+
import { printTextResource } from '../shared/text-resource.mjs';
|
|
7
|
+
|
|
8
|
+
const COMMAND_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const HELP_FILE = path.resolve(COMMAND_DIR, 'help.txt');
|
|
10
|
+
const LERNA_CONFIG_FILE = 'lerna.json';
|
|
11
|
+
|
|
12
|
+
const REQUIRED_PUBLISH_CHECK_SCRIPT_KEY = 'produck:publish:check';
|
|
13
|
+
const REQUIRED_PUBLISH_CHECK_SCRIPT_VALUE =
|
|
14
|
+
'npm run produck:format && npm run produck:lint && npm run produck:coverage';
|
|
15
|
+
const USER_PUBLISH_SCRIPT_KEY = 'publish';
|
|
16
|
+
const REQUIRED_PUBLISH_SCRIPT_KEY = 'produck:publish';
|
|
17
|
+
const REQUIRED_PUBLISH_SCRIPT_FALLBACK_VALUE = 'npm run produck:publish:check && lerna publish';
|
|
18
|
+
|
|
19
|
+
const REQUIRED_LERNA_DEFAULT_CONFIG = `${JSON.stringify(
|
|
20
|
+
{
|
|
21
|
+
$schema: 'node_modules/lerna/schemas/lerna-schema.json',
|
|
22
|
+
version: 'independent',
|
|
23
|
+
},
|
|
24
|
+
null,
|
|
25
|
+
2,
|
|
26
|
+
)}\n`;
|
|
27
|
+
|
|
28
|
+
export function printSyncPublishHelp() {
|
|
29
|
+
printTextResource(HELP_FILE);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function parseJsonFile(filePath, label) {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
35
|
+
} catch {
|
|
36
|
+
console.error(`${label} is not valid JSON: ${filePath}`);
|
|
37
|
+
process.exit(2);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function buildRequiredPublishScriptValue(hasUserPublishScript) {
|
|
42
|
+
if (hasUserPublishScript) {
|
|
43
|
+
return 'npm run produck:publish:check && npm run publish --';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return REQUIRED_PUBLISH_SCRIPT_FALLBACK_VALUE;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function runSyncPublish(options) {
|
|
50
|
+
const cwd = path.resolve(getSingle(options, '--cwd', process.cwd()));
|
|
51
|
+
const check = hasFlag(options, '--check');
|
|
52
|
+
const dryRun = hasFlag(options, '--dry-run') && !check;
|
|
53
|
+
const jsonFile = getSingle(options, '--json', '');
|
|
54
|
+
const mode = check ? 'check' : dryRun ? 'dry-run' : 'sync';
|
|
55
|
+
|
|
56
|
+
if (!fs.existsSync(cwd)) {
|
|
57
|
+
console.error(`CWD does not exist: ${cwd}`);
|
|
58
|
+
process.exit(2);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const lernaConfigPath = path.resolve(cwd, LERNA_CONFIG_FILE);
|
|
62
|
+
const lernaExistedBefore = fs.existsSync(lernaConfigPath);
|
|
63
|
+
let lernaDefaultCreated = false;
|
|
64
|
+
|
|
65
|
+
if (!lernaExistedBefore) {
|
|
66
|
+
if (mode === 'sync') {
|
|
67
|
+
fs.writeFileSync(lernaConfigPath, REQUIRED_LERNA_DEFAULT_CONFIG, 'utf8');
|
|
68
|
+
lernaDefaultCreated = true;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const lernaConfig = parseJsonFile(lernaConfigPath, 'lerna.json');
|
|
72
|
+
|
|
73
|
+
if (typeof lernaConfig.version !== 'string') {
|
|
74
|
+
console.error(`lerna.json must have a "version" field: ${lernaConfigPath}`);
|
|
75
|
+
process.exit(2);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const rootPackageJsonPath = path.resolve(cwd, 'package.json');
|
|
80
|
+
if (!fs.existsSync(rootPackageJsonPath)) {
|
|
81
|
+
console.error(`Root package.json does not exist: ${rootPackageJsonPath}`);
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const pkg = parseJsonFile(rootPackageJsonPath, 'Root package.json');
|
|
86
|
+
const scripts =
|
|
87
|
+
pkg.scripts && typeof pkg.scripts === 'object' && !Array.isArray(pkg.scripts)
|
|
88
|
+
? { ...pkg.scripts }
|
|
89
|
+
: {};
|
|
90
|
+
const hasUserPublishScript =
|
|
91
|
+
typeof scripts[USER_PUBLISH_SCRIPT_KEY] === 'string' &&
|
|
92
|
+
scripts[USER_PUBLISH_SCRIPT_KEY].trim() !== '';
|
|
93
|
+
const requiredPublishScriptValue = buildRequiredPublishScriptValue(hasUserPublishScript);
|
|
94
|
+
|
|
95
|
+
const previousPublishCheck =
|
|
96
|
+
typeof scripts[REQUIRED_PUBLISH_CHECK_SCRIPT_KEY] === 'string'
|
|
97
|
+
? scripts[REQUIRED_PUBLISH_CHECK_SCRIPT_KEY]
|
|
98
|
+
: null;
|
|
99
|
+
const previousPublish =
|
|
100
|
+
typeof scripts[REQUIRED_PUBLISH_SCRIPT_KEY] === 'string'
|
|
101
|
+
? scripts[REQUIRED_PUBLISH_SCRIPT_KEY]
|
|
102
|
+
: null;
|
|
103
|
+
|
|
104
|
+
const matchesRequiredPublishCheck = previousPublishCheck === REQUIRED_PUBLISH_CHECK_SCRIPT_VALUE;
|
|
105
|
+
const matchesRequiredPublish = previousPublish === requiredPublishScriptValue;
|
|
106
|
+
const lernaRequiresCreation = !lernaExistedBefore && !lernaDefaultCreated;
|
|
107
|
+
const requiresUpdate =
|
|
108
|
+
!matchesRequiredPublishCheck || !matchesRequiredPublish || lernaRequiresCreation;
|
|
109
|
+
|
|
110
|
+
if (mode === 'sync' && (!matchesRequiredPublishCheck || !matchesRequiredPublish)) {
|
|
111
|
+
scripts[REQUIRED_PUBLISH_CHECK_SCRIPT_KEY] = REQUIRED_PUBLISH_CHECK_SCRIPT_VALUE;
|
|
112
|
+
scripts[REQUIRED_PUBLISH_SCRIPT_KEY] = requiredPublishScriptValue;
|
|
113
|
+
pkg.scripts = scripts;
|
|
114
|
+
fs.writeFileSync(rootPackageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf8');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const report = {
|
|
118
|
+
cwd,
|
|
119
|
+
mode,
|
|
120
|
+
ok: true,
|
|
121
|
+
lernaConfigPath,
|
|
122
|
+
rootPackageJsonPath,
|
|
123
|
+
required: {
|
|
124
|
+
publishCheckScriptKey: REQUIRED_PUBLISH_CHECK_SCRIPT_KEY,
|
|
125
|
+
publishCheckScriptValue: REQUIRED_PUBLISH_CHECK_SCRIPT_VALUE,
|
|
126
|
+
publishScriptKey: REQUIRED_PUBLISH_SCRIPT_KEY,
|
|
127
|
+
publishScriptValue: requiredPublishScriptValue,
|
|
128
|
+
},
|
|
129
|
+
status: {
|
|
130
|
+
hasUserPublishScript,
|
|
131
|
+
lernaExistedBefore,
|
|
132
|
+
lernaDefaultCreated,
|
|
133
|
+
matchesRequiredPublishCheckBefore: matchesRequiredPublishCheck,
|
|
134
|
+
matchesRequiredPublishCheckAfter:
|
|
135
|
+
!matchesRequiredPublishCheck && mode === 'sync' ? true : matchesRequiredPublishCheck,
|
|
136
|
+
matchesRequiredPublishBefore: matchesRequiredPublish,
|
|
137
|
+
matchesRequiredPublishAfter:
|
|
138
|
+
!matchesRequiredPublish && mode === 'sync' ? true : matchesRequiredPublish,
|
|
139
|
+
updated: requiresUpdate && mode === 'sync',
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (mode === 'check' && requiresUpdate) {
|
|
144
|
+
report.ok = false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (jsonFile) {
|
|
148
|
+
const outPath = path.resolve(cwd, jsonFile);
|
|
149
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
150
|
+
fs.writeFileSync(outPath, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
154
|
+
if (!report.ok) {
|
|
155
|
+
process.exit(2);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -13,6 +13,7 @@ const HELP_FILE = path.resolve(COMMAND_DIR, 'help.txt');
|
|
|
13
13
|
const ROOT_PACKAGE_FILE = path.resolve(COMMAND_DIR, '../../../../../package.json');
|
|
14
14
|
const WORKSPACE_SCOPE = 'workspace';
|
|
15
15
|
const WILDCARD_SCOPE = '*';
|
|
16
|
+
const DEFAULT_COMMENT_CHAR = '#';
|
|
16
17
|
|
|
17
18
|
export function printValidateCommitMsgHelp() {
|
|
18
19
|
printTextResource(HELP_FILE);
|
|
@@ -170,6 +171,33 @@ function validateSectionFormat(lines, allowedSectionScopes = null) {
|
|
|
170
171
|
return errors;
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
function getCommentCharFromConfig() {
|
|
175
|
+
const configured = String(process.env.GIT_COMMENT_CHAR || '').trim();
|
|
176
|
+
return configured || DEFAULT_COMMENT_CHAR;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function normalizeCommitMessageLines(raw, commentChar = DEFAULT_COMMENT_CHAR) {
|
|
180
|
+
const normalizedRaw = raw.replace(/\r\n/g, '\n');
|
|
181
|
+
const rawLines = normalizedRaw.split('\n');
|
|
182
|
+
const lines = [];
|
|
183
|
+
|
|
184
|
+
for (const line of rawLines) {
|
|
185
|
+
if (commentChar && line.startsWith(commentChar)) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
lines.push(line);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
while (lines.length > 0 && lines[0].trim() === '') {
|
|
192
|
+
lines.shift();
|
|
193
|
+
}
|
|
194
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === '') {
|
|
195
|
+
lines.pop();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return lines;
|
|
199
|
+
}
|
|
200
|
+
|
|
173
201
|
export function runValidateCommitMsg(options) {
|
|
174
202
|
const file = getSingle(options, '--file', '');
|
|
175
203
|
if (!file) {
|
|
@@ -183,8 +211,8 @@ export function runValidateCommitMsg(options) {
|
|
|
183
211
|
process.exit(2);
|
|
184
212
|
}
|
|
185
213
|
|
|
186
|
-
const raw = fs.readFileSync(filePath, 'utf8')
|
|
187
|
-
const lines =
|
|
214
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
215
|
+
const lines = normalizeCommitMessageLines(raw, getCommentCharFromConfig());
|
|
188
216
|
|
|
189
217
|
if (lines.length === 0 || (lines.length === 1 && lines[0].trim() === '')) {
|
|
190
218
|
console.error('Commit message is empty');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produck/agent-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Central CLI toolkit for organization AI execution workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prepack": "node ./bin/build-publish-assets.mjs",
|
|
16
|
-
"test": "node
|
|
17
|
-
"verify": "node ./bin/agent-toolkit.mjs --help && node ./bin/agent-toolkit.mjs preflight --cwd . --require package.json",
|
|
18
|
-
"pack:check": "npm pack --dry-run",
|
|
16
|
+
"test": "node test/index.mjs",
|
|
19
17
|
"produck:coverage": "c8 --reporter=lcov --reporter=html --reporter=text-summary npm test"
|
|
20
18
|
},
|
|
21
19
|
"files": [
|
|
@@ -32,5 +30,5 @@
|
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"c8": "11.0.0"
|
|
34
32
|
},
|
|
35
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "61467ec369911fde65adc21bcf0c507c24735d90"
|
|
36
34
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
lerna-debug.log*
|
|
8
|
+
.pnpm-debug.log*
|
|
9
|
+
|
|
10
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# Runtime data
|
|
14
|
+
pids
|
|
15
|
+
*.pid
|
|
16
|
+
*.seed
|
|
17
|
+
*.pid.lock
|
|
18
|
+
|
|
19
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
20
|
+
lib-cov
|
|
21
|
+
|
|
22
|
+
# Coverage directory used by tools like istanbul
|
|
23
|
+
coverage
|
|
24
|
+
*.lcov
|
|
25
|
+
|
|
26
|
+
# nyc test coverage
|
|
27
|
+
.nyc_output
|
|
28
|
+
|
|
29
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
30
|
+
.grunt
|
|
31
|
+
|
|
32
|
+
# Bower dependency directory (https://bower.io/)
|
|
33
|
+
bower_components
|
|
34
|
+
|
|
35
|
+
# node-waf configuration
|
|
36
|
+
.lock-wscript
|
|
37
|
+
|
|
38
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
39
|
+
build/Release
|
|
40
|
+
|
|
41
|
+
# Dependency directories
|
|
42
|
+
node_modules/
|
|
43
|
+
jspm_packages/
|
|
44
|
+
|
|
45
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
46
|
+
web_modules/
|
|
47
|
+
|
|
48
|
+
# TypeScript cache
|
|
49
|
+
*.tsbuildinfo
|
|
50
|
+
|
|
51
|
+
# Optional npm cache directory
|
|
52
|
+
.npm
|
|
53
|
+
|
|
54
|
+
# Optional eslint cache
|
|
55
|
+
.eslintcache
|
|
56
|
+
|
|
57
|
+
# Optional stylelint cache
|
|
58
|
+
.stylelintcache
|
|
59
|
+
|
|
60
|
+
# Microbundle cache
|
|
61
|
+
.rpt2_cache/
|
|
62
|
+
.rts2_cache_cjs/
|
|
63
|
+
.rts2_cache_es/
|
|
64
|
+
.rts2_cache_umd/
|
|
65
|
+
|
|
66
|
+
# Optional REPL history
|
|
67
|
+
.node_repl_history
|
|
68
|
+
|
|
69
|
+
# Output of 'npm pack'
|
|
70
|
+
*.tgz
|
|
71
|
+
|
|
72
|
+
# Yarn Integrity file
|
|
73
|
+
.yarn-integrity
|
|
74
|
+
|
|
75
|
+
# dotenv environment variable files
|
|
76
|
+
.env
|
|
77
|
+
.env.development.local
|
|
78
|
+
.env.test.local
|
|
79
|
+
.env.production.local
|
|
80
|
+
.env.local
|
|
81
|
+
|
|
82
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
83
|
+
.cache
|
|
84
|
+
.parcel-cache
|
|
85
|
+
|
|
86
|
+
# Next.js build output
|
|
87
|
+
.next
|
|
88
|
+
out
|
|
89
|
+
|
|
90
|
+
# Nuxt.js build / generate output
|
|
91
|
+
.nuxt
|
|
92
|
+
dist
|
|
93
|
+
|
|
94
|
+
# Gatsby files
|
|
95
|
+
.cache/
|
|
96
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
97
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
98
|
+
# public
|
|
99
|
+
|
|
100
|
+
# vuepress build output
|
|
101
|
+
.vuepress/dist
|
|
102
|
+
|
|
103
|
+
# vuepress v2.x temp and cache directory
|
|
104
|
+
.temp
|
|
105
|
+
.cache
|
|
106
|
+
|
|
107
|
+
# Docusaurus cache and generated files
|
|
108
|
+
.docusaurus
|
|
109
|
+
|
|
110
|
+
# Serverless directories
|
|
111
|
+
.serverless/
|
|
112
|
+
|
|
113
|
+
# FuseBox cache
|
|
114
|
+
.fusebox/
|
|
115
|
+
|
|
116
|
+
# DynamoDB Local files
|
|
117
|
+
.dynamodb/
|
|
118
|
+
|
|
119
|
+
# TernJS port file
|
|
120
|
+
.tern-port
|
|
121
|
+
|
|
122
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
123
|
+
.vscode-test
|
|
124
|
+
|
|
125
|
+
# yarn v2
|
|
126
|
+
.yarn/cache
|
|
127
|
+
.yarn/unplugged
|
|
128
|
+
.yarn/build-state.yml
|
|
129
|
+
.yarn/install-state.gz
|
|
130
|
+
.pnp.*
|
|
131
|
+
|
|
132
|
+
# Vscode
|
|
133
|
+
.vscode
|
|
134
|
+
|
|
135
|
+
# Specific ignored / generated.
|
|
136
|
+
*.ign*
|
|
137
|
+
*.gen*
|
|
@@ -19,15 +19,18 @@ applyTo: '**'
|
|
|
19
19
|
|
|
20
20
|
Required script keys:
|
|
21
21
|
|
|
22
|
-
- `
|
|
22
|
+
- `produck:install`
|
|
23
23
|
- `test`
|
|
24
24
|
- `produck:coverage`
|
|
25
|
-
- `lint`
|
|
25
|
+
- `produck:lint`
|
|
26
26
|
- `publish`
|
|
27
27
|
|
|
28
28
|
Notes:
|
|
29
29
|
|
|
30
30
|
- Script key names are fixed and must match exactly.
|
|
31
|
+
- Keep the script key name `produck:install` (organization-reserved key).
|
|
32
|
+
- Required root script value for `produck:install` is:
|
|
33
|
+
`npm -v && npm install`
|
|
31
34
|
- `publish` may be a no-op when repository-specific release workflow does not
|
|
32
35
|
use npm publishing.
|
|
33
36
|
- Coverage governance policy:
|
|
@@ -37,19 +40,18 @@ Notes:
|
|
|
37
40
|
baseline.
|
|
38
41
|
- Source of truth for tooling versions/template:
|
|
39
42
|
`.github/distribution/produck/tooling-version-baseline.json`.
|
|
43
|
+
- Use central remediation command to deploy root install script baseline:
|
|
44
|
+
`npm exec -- agent-toolkit sync-install --cwd .`.
|
|
40
45
|
- Use central remediation command to deploy coverage scripts:
|
|
41
|
-
`npm exec -- agent-toolkit sync-coverage
|
|
46
|
+
`npm exec -- agent-toolkit sync-coverage --cwd .`.
|
|
42
47
|
- Use central remediation command to deploy local anti-drift hook baseline:
|
|
43
|
-
`npm exec -- agent-toolkit sync-
|
|
48
|
+
`npm exec -- agent-toolkit sync-git --cwd .`.
|
|
44
49
|
- Use central remediation command to deploy root format script/config
|
|
45
50
|
baseline:
|
|
46
|
-
`npm exec -- agent-toolkit sync-
|
|
51
|
+
`npm exec -- agent-toolkit sync-format --cwd .`.
|
|
47
52
|
- Use central remediation command to deploy root lint script/config and
|
|
48
53
|
eslint integration baseline:
|
|
49
|
-
`npm exec -- agent-toolkit sync-
|
|
50
|
-
- Use central remediation command to deploy root shared scripts/dependencies
|
|
51
|
-
baseline:
|
|
52
|
-
`npm exec -- agent-toolkit sync-workspace-config --cwd .`.
|
|
54
|
+
`npm exec -- agent-toolkit sync-lint --cwd .`.
|
|
53
55
|
- `c8` execution baseline for deployed coverage scripts is fixed to the
|
|
54
56
|
version specified in `tooling-version-baseline.json`.
|
|
55
57
|
- Downstream repositories must not use unversioned `npx c8` or `c8@latest`
|
|
@@ -57,15 +59,15 @@ Notes:
|
|
|
57
59
|
- Root local governance must pin `devDependencies.c8`,
|
|
58
60
|
`devDependencies.husky`, `devDependencies.lerna`, and
|
|
59
61
|
`devDependencies.@produck/agent-toolkit` via
|
|
60
|
-
`agent-toolkit sync-
|
|
62
|
+
`agent-toolkit sync-git`.
|
|
61
63
|
- Root local governance must pin `devDependencies.@produck/eslint-rules`
|
|
62
|
-
via `agent-toolkit sync-
|
|
64
|
+
via `agent-toolkit sync-lint`.
|
|
63
65
|
|
|
64
66
|
- Testing strategy and framework are repository-defined.
|
|
65
67
|
- `verify` scripts are optional repository-local health checks and are not
|
|
66
68
|
organization-required script keys.
|
|
67
69
|
- `verify` is not part of organization commit gates; style gates remain
|
|
68
|
-
repository `format
|
|
70
|
+
repository `produck:format` and `produck:lint` policy.
|
|
69
71
|
- `test` script implementation is repository-defined and is not overwritten by
|
|
70
72
|
organization coverage remediation.
|
|
71
73
|
- Repositories should keep `npm run test` and `npm run produck:coverage`
|
|
@@ -73,7 +75,7 @@ Notes:
|
|
|
73
75
|
- For intermediate commits, temporary non-executable state or failing tests are
|
|
74
76
|
allowed.
|
|
75
77
|
- Commit prechecks still require passing repository style gates (for example
|
|
76
|
-
`format
|
|
78
|
+
`produck:format` and `produck:lint`).
|
|
77
79
|
|
|
78
80
|
Central toolkit command role model:
|
|
79
81
|
|
|
@@ -83,19 +85,20 @@ Central toolkit command role model:
|
|
|
83
85
|
but do not assume it can fully prevent AI hallucination or iterative drift.
|
|
84
86
|
- `agent-toolkit preflight` is the hard guard for organization engineering
|
|
85
87
|
baseline and is mandatory for required baseline checks.
|
|
86
|
-
- `agent-toolkit sync-
|
|
88
|
+
- `agent-toolkit sync-install` is the hard guard for root install script
|
|
89
|
+
governance and is mandatory in monorepo mode.
|
|
90
|
+
- `agent-toolkit sync-coverage` is the hard guard for monorepo coverage
|
|
87
91
|
governance and is mandatory in monorepo mode.
|
|
88
|
-
- `agent-toolkit sync-
|
|
92
|
+
- `agent-toolkit sync-git` is the hard guard for local anti-drift hook
|
|
89
93
|
governance and is mandatory in monorepo mode.
|
|
90
|
-
- `agent-toolkit sync-
|
|
94
|
+
- `agent-toolkit sync-format` is the hard guard for root format
|
|
91
95
|
script/config governance and is mandatory in monorepo mode.
|
|
92
|
-
- `agent-toolkit sync-
|
|
96
|
+
- `agent-toolkit sync-lint` is the hard guard for root lint
|
|
93
97
|
script/config and eslint integration governance and is mandatory in monorepo
|
|
94
98
|
mode.
|
|
95
|
-
- `agent-toolkit sync-
|
|
96
|
-
|
|
97
|
-
- For simplified downstream execution of mandatory flow (1 -> 2 ->
|
|
98
|
-
5 -> 6 -> 7),
|
|
99
|
+
- `agent-toolkit sync-publish` is the hard guard for root publish script
|
|
100
|
+
governance when `lerna.json` is present.
|
|
101
|
+
- For simplified downstream execution of mandatory flow (1 -> 2 -> ... -> 9),
|
|
99
102
|
use:
|
|
100
103
|
`npm exec -- agent-toolkit`.
|
|
101
104
|
- Equivalent explicit form:
|
|
@@ -114,8 +117,13 @@ Central toolkit command role model:
|
|
|
114
117
|
|
|
115
118
|
Test authoring baseline (required):
|
|
116
119
|
|
|
117
|
-
-
|
|
118
|
-
`it`.
|
|
120
|
+
- MUST use Node.js standard library test runner (`node:test`) with `describe`
|
|
121
|
+
and `it`.
|
|
122
|
+
- Execution MUST follow the **Single Entrypoint Rule**: always run tests via a
|
|
123
|
+
dedicated entrypoint (for example `test/index.mjs`) instead of targeting
|
|
124
|
+
individual files.
|
|
125
|
+
- Command-line execution MUST NOT use the `--test` flag. Use
|
|
126
|
+
`node <entrypoint>` directly.
|
|
119
127
|
- Each test case must be independently executable.
|
|
120
128
|
- Test cases must not depend on execution order or state from other cases.
|
|
121
129
|
- New test debugging should use local `only` mode for scoped regression.
|
|
@@ -125,7 +133,7 @@ Recommended local debug flow:
|
|
|
125
133
|
|
|
126
134
|
1. Add `{ only: true }` to the target `describe/it` and all ancestor
|
|
127
135
|
`describe` blocks.
|
|
128
|
-
2. Run `node --test
|
|
136
|
+
2. Run `node --test-only test/index.mjs`.
|
|
129
137
|
3. Remove all `only` markers.
|
|
130
138
|
4. Run full regression via repository standard test command.
|
|
131
139
|
|
|
@@ -178,42 +186,46 @@ Repository layout:
|
|
|
178
186
|
|
|
179
187
|
Script placement:
|
|
180
188
|
|
|
181
|
-
- Root `package.json` must provide `
|
|
182
|
-
and `lint` orchestration scripts.
|
|
183
|
-
- Root `package.json` must reserve `produck:
|
|
189
|
+
- Root `package.json` must provide `produck:install`, `test`, `produck:coverage`,
|
|
190
|
+
and `produck:lint` orchestration scripts.
|
|
191
|
+
- Root `package.json` must reserve `produck:commit:check` for organization
|
|
184
192
|
anti-drift gate with required value:
|
|
185
193
|
`npm run produck:format && npm run produck:lint`.
|
|
186
194
|
- Root `package.json` must reserve `prepare` for husky setup with required
|
|
187
195
|
value: `husky`.
|
|
188
196
|
- Root `package.json` must reserve `produck:format` and `produck:lint` for
|
|
189
197
|
organization-controlled format/lint gates.
|
|
198
|
+
- Root `package.json` must reserve `produck:publish` for organization-controlled
|
|
199
|
+
publish gate when `lerna.json` is present (governed by
|
|
200
|
+
`agent-toolkit sync-publish`).
|
|
190
201
|
- `publish` may be defined at root or package level based on release workflow.
|
|
191
202
|
- Workspace subpackage `produck:coverage` scripts must be synchronized by
|
|
192
|
-
`agent-toolkit sync-coverage
|
|
203
|
+
`agent-toolkit sync-coverage`.
|
|
193
204
|
- Root local hook governance must be synchronized by
|
|
194
|
-
`agent-toolkit sync-
|
|
205
|
+
`agent-toolkit sync-git`.
|
|
206
|
+
- Root local shared script governance must initialize
|
|
207
|
+
`scripts.produck:install` with required value `npm -v && npm install`
|
|
208
|
+
via `agent-toolkit sync-install`.
|
|
195
209
|
- Root local format governance must be synchronized by
|
|
196
|
-
`agent-toolkit sync-
|
|
210
|
+
`agent-toolkit sync-format`.
|
|
197
211
|
- Root local lint governance must be synchronized by
|
|
198
|
-
`agent-toolkit sync-
|
|
199
|
-
- Root local shared script/dependency governance must be synchronized by
|
|
200
|
-
`agent-toolkit sync-workspace-config`.
|
|
212
|
+
`agent-toolkit sync-lint`.
|
|
201
213
|
- Root local shared script/dependency governance must pin root
|
|
202
214
|
`devDependencies.c8`,
|
|
203
215
|
`devDependencies.husky`, `devDependencies.lerna`,
|
|
204
216
|
`devDependencies.@produck/agent-toolkit` via
|
|
205
|
-
`agent-toolkit sync-
|
|
217
|
+
`agent-toolkit sync-git`.
|
|
206
218
|
- Root local shared script/dependency governance must initialize
|
|
207
219
|
`scripts.produck:coverage` with workspace-level execution behavior:
|
|
208
220
|
attempt `test` on all workspace packages using `--workspaces --if-present`.
|
|
209
221
|
- Root local shared script/dependency governance must initialize `.c8rc.json`
|
|
210
|
-
via `agent-toolkit sync-
|
|
222
|
+
via `agent-toolkit sync-coverage`.
|
|
211
223
|
- Root local format governance must initialize `.prettierrc` and
|
|
212
|
-
`scripts.produck:format` via `agent-toolkit sync-
|
|
224
|
+
`scripts.produck:format` via `agent-toolkit sync-format`.
|
|
213
225
|
- Root local lint governance must initialize `eslint.config.mjs`,
|
|
214
226
|
`scripts.produck:lint`, and `devDependencies.@produck/eslint-rules`
|
|
215
227
|
(including append-mode integration for existing eslint config) via
|
|
216
|
-
`agent-toolkit sync-
|
|
228
|
+
`agent-toolkit sync-lint`.
|
|
217
229
|
- Root `package.json` must define a `produck:baseline` script for organization
|
|
218
230
|
baseline enforcement:
|
|
219
231
|
```json
|
|
@@ -240,7 +252,8 @@ Root workspace `package.json` minimal baseline (required):
|
|
|
240
252
|
|
|
241
253
|
- `private`: `true`
|
|
242
254
|
- `workspaces` (explicit package path list only)
|
|
243
|
-
- `scripts` with at least: `
|
|
255
|
+
- `scripts` with at least: `produck:install`, `test`, `produck:coverage`,
|
|
256
|
+
`produck:lint`
|
|
244
257
|
- `publish` script is optional at root when release is managed per package or
|
|
245
258
|
by external workflow.
|
|
246
259
|
|
|
@@ -276,8 +289,8 @@ Repository layout:
|
|
|
276
289
|
|
|
277
290
|
Script placement:
|
|
278
291
|
|
|
279
|
-
- The repository root `package.json` must define `
|
|
280
|
-
`produck:coverage`, `lint`, and `publish`.
|
|
292
|
+
- The repository root `package.json` must define `produck:install`, `test`,
|
|
293
|
+
`produck:coverage`, `produck:lint`, and `publish`.
|
|
281
294
|
- Root `package.json` must define a `produck:baseline` script for organization
|
|
282
295
|
baseline enforcement:
|
|
283
296
|
```json
|
|
@@ -137,20 +137,17 @@ export default [
|
|
|
137
137
|
# Type check all packages (optional: only when root tsconfig.json is present)
|
|
138
138
|
npm run type-check
|
|
139
139
|
|
|
140
|
-
# Format
|
|
141
|
-
npm run format
|
|
140
|
+
# Format and write using the organization format gate
|
|
141
|
+
npm run produck:format
|
|
142
142
|
|
|
143
|
-
#
|
|
144
|
-
npm run
|
|
145
|
-
|
|
146
|
-
# Lint (requires root eslint.config.mjs)
|
|
147
|
-
npm run lint
|
|
143
|
+
# Lint using the organization lint gate
|
|
144
|
+
npm run produck:lint
|
|
148
145
|
|
|
149
146
|
# Run all package tests
|
|
150
147
|
npm run test
|
|
151
148
|
|
|
152
149
|
# Check coverage across packages
|
|
153
|
-
npm run coverage
|
|
150
|
+
npm run produck:coverage
|
|
154
151
|
```
|
|
155
152
|
|
|
156
153
|
### Release & Coverage Tooling
|
|
@@ -168,10 +165,10 @@ npm run coverage
|
|
|
168
165
|
policy.
|
|
169
166
|
- Workspace subpackage coverage scripts are fully organization-governed.
|
|
170
167
|
- Deploy/repair coverage scripts via central remediation command:
|
|
171
|
-
`npm exec -- agent-toolkit sync-coverage
|
|
168
|
+
`npm exec -- agent-toolkit sync-coverage --cwd .`.
|
|
172
169
|
- Root anti-drift local hook baseline is organization-governed.
|
|
173
170
|
- Deploy/repair root local hooks via central remediation command:
|
|
174
|
-
`npm exec -- agent-toolkit sync-
|
|
171
|
+
`npm exec -- agent-toolkit sync-git --cwd .`.
|
|
175
172
|
- Deployed coverage scripts use the `c8` version specified in
|
|
176
173
|
`tooling-version-baseline.json` for each governed workspace package.
|
|
177
174
|
- Deployed local hook baseline uses the `husky` version specified in
|
|
@@ -181,9 +178,9 @@ npm run coverage
|
|
|
181
178
|
- Shared scripts/CI must not use unversioned `npx c8` or `c8@latest`.
|
|
182
179
|
- `test` script implementation remains repository-defined and is not overwritten
|
|
183
180
|
by coverage remediation.
|
|
184
|
-
- Root `devDependencies.c8` is pinned at root by `agent-toolkit sync-
|
|
181
|
+
- Root `devDependencies.c8` is pinned at root by `agent-toolkit sync-git`;
|
|
185
182
|
workspace package `devDependencies.c8` is pinned per package by
|
|
186
|
-
`agent-toolkit sync-coverage
|
|
183
|
+
`agent-toolkit sync-coverage`.
|
|
187
184
|
- Root local hooks may be bypassed intentionally by developers (for example via
|
|
188
185
|
`--no-verify`) and are treated as local strong guardrails rather than
|
|
189
186
|
immutable release gates.
|
|
@@ -264,14 +261,14 @@ Root scripts are designed for CI pipelines:
|
|
|
264
261
|
|
|
265
262
|
```bash
|
|
266
263
|
# Pre-commit checks
|
|
267
|
-
npm run format
|
|
264
|
+
npm run produck:format
|
|
265
|
+
npm run produck:lint
|
|
268
266
|
# Optional when root tsconfig.json is used
|
|
269
267
|
npm run type-check
|
|
270
|
-
npm run lint
|
|
271
268
|
|
|
272
269
|
# Testing
|
|
273
270
|
npm run test
|
|
274
|
-
npm run coverage
|
|
271
|
+
npm run produck:coverage
|
|
275
272
|
```
|
|
276
273
|
|
|
277
274
|
## Best Practices
|
|
@@ -297,7 +294,7 @@ npm install
|
|
|
297
294
|
Root `.prettierrc` and `eslint.config.mjs` are synchronized. If conflict occurs:
|
|
298
295
|
|
|
299
296
|
1. Check both configs have matching rules
|
|
300
|
-
2. Run `npm run format` first, then `npm run lint`
|
|
297
|
+
2. Run `npm run produck:format` first, then `npm run produck:lint`
|
|
301
298
|
|
|
302
299
|
### TypeScript includes too many files (when root tsconfig.json is used)
|
|
303
300
|
|
|
@@ -175,8 +175,8 @@ Use the local validator before commit:
|
|
|
175
175
|
Commit precheck gate (AI-agent required, human recommended):
|
|
176
176
|
|
|
177
177
|
- For AI-agent-authored operations, complete repository style gates before both
|
|
178
|
-
`git commit` and `git commit --amend` (for example `format
|
|
179
|
-
`lint`).
|
|
178
|
+
`git commit` and `git commit --amend` (for example `produck:format` and
|
|
179
|
+
`produck:lint`).
|
|
180
180
|
- For AI-agent-authored operations, `git commit --no-verify` and
|
|
181
181
|
`git commit --amend --no-verify` are forbidden.
|
|
182
182
|
- For human engineer-authored operations, style gates are recommended baseline
|