@produck/agent-toolkit 0.9.0 → 0.9.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.
@@ -54,16 +54,27 @@ function readFileIfExists(filePath) {
54
54
  return fs.readFileSync(filePath, 'utf8');
55
55
  }
56
56
 
57
- function getRequiredEslintRulesDevDependency() {
58
- // Prefer the in-tree source of truth: when sync-lint runs from inside the
59
- // monorepo, the eslint-rules package.json is the authoritative version. When
60
- // sync-lint runs as an installed dependency, fall back to the publish-assets
61
- // tooling baseline (which build-publish-assets injects at prepack time from
62
- // the same package.json).
57
+ const ESLINT_TOOLING_PACKAGE_NAMES = [
58
+ 'eslint',
59
+ '@eslint/js',
60
+ '@eslint/json',
61
+ '@eslint/markdown',
62
+ '@eslint/config-helpers',
63
+ 'typescript-eslint',
64
+ 'globals',
65
+ ];
66
+
67
+ function getRequiredEslintDevDependencies() {
68
+ // Prefer the in-tree source of truth for @produck/eslint-rules: when
69
+ // sync-lint runs inside the monorepo, eslint-rules/package.json is
70
+ // authoritative. When running as an installed dependency, fall back to the
71
+ // publish-assets tooling baseline.
63
72
  const inTreeEslintRulesPkgPath = path.resolve(
64
73
  REPO_ROOT,
65
74
  'packages/eslint-rules/package.json',
66
75
  );
76
+
77
+ let eslintRulesVersion = '';
67
78
  if (fs.existsSync(inTreeEslintRulesPkgPath)) {
68
79
  const eslintRulesPkg = parseJsonFile(
69
80
  inTreeEslintRulesPkgPath,
@@ -71,13 +82,13 @@ function getRequiredEslintRulesDevDependency() {
71
82
  );
72
83
  // The '' fallback is for when the in-tree package.json has a non-string
73
84
  // version field, which never occurs for this package.
74
- const version =
85
+ const v =
75
86
  typeof eslintRulesPkg.version === 'string'
76
87
  ? eslintRulesPkg.version.trim()
77
88
  : /* c8 ignore next */
78
89
  '';
79
- if (version) {
80
- return version;
90
+ if (v) {
91
+ eslintRulesVersion = v;
81
92
  }
82
93
  }
83
94
 
@@ -87,9 +98,9 @@ function getRequiredEslintRulesDevDependency() {
87
98
  },
88
99
  );
89
100
 
101
+ /* c8 ignore next 7 */
90
102
  if (!toolingBaselinePath) {
91
- console.error('Cannot resolve @produck/eslint-rules version. Looked at:');
92
- console.error(`- ${inTreeEslintRulesPkgPath}`);
103
+ console.error('Cannot resolve ESLint tooling versions. Looked at:');
93
104
  for (const candidatePath of TOOLING_BASELINE_CANDIDATE_PATHS) {
94
105
  console.error(`- ${candidatePath}`);
95
106
  }
@@ -97,21 +108,40 @@ function getRequiredEslintRulesDevDependency() {
97
108
  }
98
109
 
99
110
  const baseline = parseJsonFile(toolingBaselinePath, 'Tooling baseline file');
100
- const entry = baseline?.tools?.[ESLINT_RULES_PACKAGE_NAME];
101
- // The '' fallback is for when the tooling baseline lacks a string version entry
102
- // for the eslint-rules package, which the repository always provides.
103
- /* c8 ignore next 2 */
104
- const version =
105
- typeof entry?.version === 'string' ? entry.version.trim() : '';
106
-
107
- if (!version) {
108
- console.error(
109
- `Tooling baseline tools["${ESLINT_RULES_PACKAGE_NAME}"].version must be a non-empty string: ${toolingBaselinePath}`,
110
- );
111
- process.exit(2);
111
+
112
+ /* c8 ignore next 12 */
113
+ if (!eslintRulesVersion) {
114
+ const entry = baseline?.tools?.[ESLINT_RULES_PACKAGE_NAME];
115
+ const v = typeof entry?.version === 'string' ? entry.version.trim() : '';
116
+ if (!v) {
117
+ console.error(
118
+ `Tooling baseline tools["${ESLINT_RULES_PACKAGE_NAME}"].version must be a non-empty string: ${toolingBaselinePath}`,
119
+ );
120
+ process.exit(2);
121
+ }
122
+ eslintRulesVersion = v;
112
123
  }
113
124
 
114
- return version;
125
+ const deps = { [ESLINT_RULES_PACKAGE_NAME]: eslintRulesVersion };
126
+
127
+ for (const name of ESLINT_TOOLING_PACKAGE_NAMES) {
128
+ const entry = baseline?.tools?.[name];
129
+ const v =
130
+ typeof entry?.version === 'string'
131
+ ? entry.version.trim()
132
+ : /* c8 ignore next */
133
+ '';
134
+ /* c8 ignore next 6 */
135
+ if (!v) {
136
+ console.error(
137
+ `Tooling baseline tools["${name}"].version must be a non-empty string: ${toolingBaselinePath}`,
138
+ );
139
+ process.exit(2);
140
+ }
141
+ deps[name] = v;
142
+ }
143
+
144
+ return deps;
115
145
  }
116
146
 
117
147
  function patchEslintConfig(existing) {
@@ -186,19 +216,15 @@ export function runSyncLint(options) {
186
216
  typeof scripts[REQUIRED_LINT_SCRIPT_KEY] === 'string'
187
217
  ? scripts[REQUIRED_LINT_SCRIPT_KEY]
188
218
  : null;
189
- const previousEslintRules =
190
- typeof devDependencies['@produck/eslint-rules'] === 'string'
191
- ? devDependencies['@produck/eslint-rules']
192
- : null;
193
-
194
- const requiredEslintRulesDependency = getRequiredEslintRulesDevDependency();
219
+ const requiredEslintDevDeps = getRequiredEslintDevDependencies();
195
220
 
196
221
  const eslintConfigPath = path.resolve(cwd, ESLINT_CONFIG_FILE);
197
222
  const previousEslintConfig = readFileIfExists(eslintConfigPath);
198
223
 
199
224
  const matchesRequiredLint = previousLint === REQUIRED_LINT_SCRIPT_VALUE;
200
- const matchesRequiredEslintRules =
201
- previousEslintRules === requiredEslintRulesDependency;
225
+ const matchesRequiredEslintDeps = Object.entries(requiredEslintDevDeps).every(
226
+ ([name, version]) => devDependencies[name] === version,
227
+ );
202
228
 
203
229
  let eslintConfigAction = 'unchanged';
204
230
  let matchesRequiredEslintConfig = false;
@@ -223,7 +249,7 @@ export function runSyncLint(options) {
223
249
 
224
250
  const requiresUpdate =
225
251
  !matchesRequiredLint ||
226
- !matchesRequiredEslintRules ||
252
+ !matchesRequiredEslintDeps ||
227
253
  !matchesRequiredEslintConfig;
228
254
  const hasUnpatchableEslintConfig = eslintConfigAction === 'unpatchable';
229
255
 
@@ -231,7 +257,9 @@ export function runSyncLint(options) {
231
257
  scripts[REQUIRED_LINT_SCRIPT_KEY] = REQUIRED_LINT_SCRIPT_VALUE;
232
258
  pkg.scripts = scripts;
233
259
 
234
- devDependencies['@produck/eslint-rules'] = requiredEslintRulesDependency;
260
+ for (const [name, version] of Object.entries(requiredEslintDevDeps)) {
261
+ devDependencies[name] = version;
262
+ }
235
263
  pkg.devDependencies = devDependencies;
236
264
 
237
265
  fs.writeFileSync(
@@ -257,22 +285,22 @@ export function runSyncLint(options) {
257
285
  required: {
258
286
  lintScriptKey: REQUIRED_LINT_SCRIPT_KEY,
259
287
  lintScriptValue: REQUIRED_LINT_SCRIPT_VALUE,
260
- eslintRulesVersion: requiredEslintRulesDependency,
288
+ eslintDevDependencies: requiredEslintDevDeps,
261
289
  eslintConfigPath: path.relative(cwd, eslintConfigPath),
262
290
  eslintConfigAction,
263
291
  },
264
292
  status: {
265
293
  matchesRequiredLintBefore: matchesRequiredLint,
266
- matchesRequiredEslintRulesBefore: matchesRequiredEslintRules,
294
+ matchesRequiredEslintDepsBefore: matchesRequiredEslintDeps,
267
295
  matchesRequiredEslintConfigBefore: matchesRequiredEslintConfig,
268
296
  matchesRequiredLintAfter:
269
297
  requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
270
298
  ? true
271
299
  : matchesRequiredLint,
272
- matchesRequiredEslintRulesAfter:
300
+ matchesRequiredEslintDepsAfter:
273
301
  requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
274
302
  ? true
275
- : matchesRequiredEslintRules,
303
+ : matchesRequiredEslintDeps,
276
304
  matchesRequiredEslintConfigAfter:
277
305
  requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
278
306
  ? true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produck/agent-toolkit",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Central CLI toolkit for organization AI execution workflows",
5
5
  "type": "module",
6
6
  "repository": {
@@ -32,5 +32,5 @@
32
32
  "@produck/eslint-rules": "^0.3.6",
33
33
  "c8": "11.0.0"
34
34
  },
35
- "gitHead": "d13162976bfbf23756e678027aaffe464b7c8177"
35
+ "gitHead": "053cbbf05ab8e6713cd6144766b9e734443c35c9"
36
36
  }