claude-dev-env 8.106.4 → 8.107.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.
Files changed (35) hide show
  1. package/_shared/pr-loop/scripts/code_rules_gate_parts/tests/test_gate_running.py +1 -1
  2. package/bin/codex-trimmed-sol.test.mjs +1 -0
  3. package/bin/install-pele-package.mjs +161 -0
  4. package/bin/install-pele-package.test.mjs +269 -0
  5. package/bin/install-pstack-plugin.mjs +5 -3
  6. package/bin/install.agents-home.test.mjs +1 -0
  7. package/bin/install.codex-rules.test.mjs +2 -0
  8. package/bin/install.cursor-rules.test.mjs +1 -0
  9. package/bin/install.mjs +18 -0
  10. package/bin/install.pr-visual.test.mjs +1 -1
  11. package/bin/install.profile-settings.test.mjs +1 -0
  12. package/bin/install.prune.test.mjs +1 -0
  13. package/bin/install.question-presentation.test.mjs +4 -0
  14. package/bin/install.settings-defaults.test.mjs +1 -0
  15. package/bin/install.shared-settings.test.mjs +1 -0
  16. package/bin/install.test.mjs +8 -0
  17. package/bin/install.transaction.test.mjs +8 -0
  18. package/bin/install.uninstall-transaction.test.mjs +2 -0
  19. package/bin/install.update-keeps-hooks.test.mjs +1 -0
  20. package/docs/CODE_RULES.md +2 -2
  21. package/docs/code-rules/core-principles-and-config.md +2 -1
  22. package/hooks/blocking/code_rules_magic_values.py +134 -1
  23. package/hooks/blocking/test_code_rules_enforcer_stage.py +1 -1
  24. package/hooks/blocking/test_code_rules_enforcer_string_magic.py +1 -1
  25. package/hooks/blocking/test_code_rules_magic_values.py +162 -0
  26. package/hooks/blocking/test_code_rules_validation_phase.py +1 -1
  27. package/hooks/validators/magic_value_checks.py +77 -12
  28. package/hooks/validators/test_magic_value_checks.py +88 -4
  29. package/hooks/validators/test_run_all_validators_pretooluse.py +1 -1
  30. package/hooks/validators/test_todo_checks.py +13 -1
  31. package/hooks/validators/test_validator_base.py +19 -1
  32. package/hooks/validators/todo_checks.py +2 -12
  33. package/hooks/validators/validator_base.py +33 -2
  34. package/package.json +1 -1
  35. package/scripts/ci/scratch-home-install.test.mjs +1 -1
@@ -119,7 +119,7 @@ def test_gate_caller_scans_staged_content_with_commit_stage_scope(
119
119
  init_repository(repository_root)
120
120
  committed_source = "def calculate_total() -> int:\n return 0\n"
121
121
  staged_source = (
122
- "def calculate_total() -> int:\n total = 9999\n return total\n"
122
+ "def calculate_total() -> int:\n total = abs(9999)\n return total\n"
123
123
  )
124
124
  file_path = write_commit_and_stage_change(
125
125
  repository_root,
@@ -33,6 +33,7 @@ function installInScratchHome(homeDirectory, argumentsList = [], environment = {
33
33
  LLM_SETTINGS_PROFILES_ROOT: undefined,
34
34
  CDE_INSTALL_PSTACK: '0',
35
35
  CDE_INSTALL_DEEPSTACK: '0',
36
+ CDE_INSTALL_PELE: '0',
36
37
  CDE_INSTALL_USAGE_WRAPUP: '0',
37
38
  CDE_INSTALL_SUBAGENT_MODELS: '0',
38
39
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -0,0 +1,161 @@
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { namesAnAbsentCommand, runHostCommand, singleLineDetail } from './install-pstack-plugin.mjs';
4
+
5
+ export const PELE_PACKAGE_NAME = 'pele';
6
+ export const PELE_PACKAGE_OPT_OUT_FLAG = '--no-pele';
7
+ export const PELE_PACKAGE_OPT_OUT_VARIABLE = 'CDE_INSTALL_PELE';
8
+ export const PELE_TOOLS_DIRECTORY_NAME = 'tools';
9
+ const PELE_HOST_PACKAGE_NAME = 'claude-dev-env-pele-host';
10
+ const NPM_COMMAND_TIMEOUT_MILLISECONDS = 120000;
11
+ const PELE_REMOVAL_RETRIES = 3;
12
+ const VERSION_PATTERN = /^(\d+)\.(\d+)\.(\d+)/;
13
+ const PLAIN_VERSION_PATTERN = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
14
+
15
+ export const PELE_PACKAGE_SPEC = Object.freeze({
16
+ optOutFlag: PELE_PACKAGE_OPT_OUT_FLAG,
17
+ optOutVariable: PELE_PACKAGE_OPT_OUT_VARIABLE,
18
+ });
19
+
20
+ /**
21
+ * Name the folder one managed root keeps its Pele install in.
22
+ *
23
+ * @param {string} managedRoot The managed Claude root.
24
+ * @returns {string} `<managedRoot>/tools/pele`.
25
+ */
26
+ export function peleInstallDirectory(managedRoot) {
27
+ return join(managedRoot, PELE_TOOLS_DIRECTORY_NAME, PELE_PACKAGE_NAME);
28
+ }
29
+
30
+ /**
31
+ * Read the Pele version an install folder holds.
32
+ *
33
+ * @param {string} installDirectory The folder `npm install` ran in.
34
+ * @returns {string|null} The version, or null when Pele is absent or its manifest is unreadable.
35
+ */
36
+ export function installedPeleVersion(installDirectory) {
37
+ const manifestPath = join(installDirectory, 'node_modules', PELE_PACKAGE_NAME, 'package.json');
38
+ if (!existsSync(manifestPath)) return null;
39
+ try {
40
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
41
+ return typeof manifest.version === 'string' ? manifest.version : null;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ function versionParts(versionText) {
48
+ const match = VERSION_PATTERN.exec(versionText ?? '');
49
+ return match ? match.slice(1).map(Number) : null;
50
+ }
51
+
52
+ function isNewerVersion(candidateVersion, baselineVersion) {
53
+ const candidateParts = versionParts(candidateVersion);
54
+ const baselineParts = versionParts(baselineVersion);
55
+ if (!candidateParts || !baselineParts) return candidateVersion !== baselineVersion;
56
+ for (let index = 0; index < candidateParts.length; index += 1) {
57
+ if (candidateParts[index] !== baselineParts[index]) return candidateParts[index] > baselineParts[index];
58
+ }
59
+ return false;
60
+ }
61
+
62
+ function nearestExistingDirectory(directory) {
63
+ let candidate = directory;
64
+ while (!existsSync(candidate) && dirname(candidate) !== candidate) candidate = dirname(candidate);
65
+ return candidate;
66
+ }
67
+
68
+ function runNpm(commandArguments, options = {}) {
69
+ return runHostCommand('npm', commandArguments, {
70
+ cwd: options.cwd,
71
+ timeoutMilliseconds: NPM_COMMAND_TIMEOUT_MILLISECONDS,
72
+ });
73
+ }
74
+
75
+ function failureDetail(outcome, fallback) {
76
+ const cause = outcome.error?.code === 'ETIMEDOUT'
77
+ ? `timed out after ${NPM_COMMAND_TIMEOUT_MILLISECONDS} ms`
78
+ : outcome.error?.message;
79
+ return singleLineDetail([cause, outcome.stderr].filter(Boolean).join(' ') || fallback);
80
+ }
81
+
82
+ function prepareInstallDirectory(installDirectory) {
83
+ mkdirSync(installDirectory, { recursive: true });
84
+ const hostManifestPath = join(installDirectory, 'package.json');
85
+ if (!existsSync(hostManifestPath)) {
86
+ writeFileSync(hostManifestPath, `${JSON.stringify({ name: PELE_HOST_PACKAGE_NAME, private: true }, null, 2)}\n`);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Install Pele from the npm registry, or move an older copy to the latest version.
92
+ *
93
+ * Pele is a JavaScript library, so it lands in a private folder under the managed
94
+ * root instead of the global npm prefix. A newer local copy stays as it is. A
95
+ * registry or install failure leaves any existing copy in place and reports a
96
+ * warning, so the rest of the install still completes.
97
+ *
98
+ * @param {{installDirectory: string, run?: (commandArguments: string[], options?: {cwd?: string}) => {status: number|null, stdout: string, stderr: string, error?: Error}}} options
99
+ * The install folder and an optional npm runner.
100
+ * @returns {{status: 'installed'|'updated'|'current'|'skipped'|'failed', installedVersion: string|null, previousVersion: string|null, warning: string|null}} The outcome.
101
+ */
102
+ export function installPelePackage({ installDirectory, run = runNpm }) {
103
+ const previousVersion = installedPeleVersion(installDirectory);
104
+ const outcome = (status, installedVersion, warning = null) => ({
105
+ status,
106
+ installedVersion,
107
+ previousVersion,
108
+ warning,
109
+ });
110
+ const lookup = run(['view', PELE_PACKAGE_NAME, 'version'], {
111
+ cwd: nearestExistingDirectory(installDirectory),
112
+ });
113
+ if (namesAnAbsentCommand(lookup)) {
114
+ return outcome('skipped', previousVersion, 'npm was not found on PATH');
115
+ }
116
+ const latestVersion = lookup.status === 0 ? lookup.stdout.trim() : '';
117
+ if (!PLAIN_VERSION_PATTERN.test(latestVersion)) {
118
+ const detail = lookup.status === 0
119
+ ? `npm view ${PELE_PACKAGE_NAME} returned something that is not a version`
120
+ : `npm view ${PELE_PACKAGE_NAME} failed: ${failureDetail(lookup, 'no version returned')}`;
121
+ return previousVersion
122
+ ? outcome('current', previousVersion, detail)
123
+ : outcome('failed', null, detail);
124
+ }
125
+ if (previousVersion && !isNewerVersion(latestVersion, previousVersion)) {
126
+ return outcome('current', previousVersion);
127
+ }
128
+ prepareInstallDirectory(installDirectory);
129
+ const installation = run(
130
+ ['install', '--ignore-scripts', '--no-audit', '--no-fund', '--loglevel=error', `${PELE_PACKAGE_NAME}@${latestVersion}`],
131
+ { cwd: installDirectory },
132
+ );
133
+ if (installation.status !== 0) {
134
+ return outcome(
135
+ 'failed',
136
+ previousVersion,
137
+ `npm install ${PELE_PACKAGE_NAME}@${latestVersion} failed: ${failureDetail(installation, 'no output')}`,
138
+ );
139
+ }
140
+ const installedVersion = installedPeleVersion(installDirectory);
141
+ if (installedVersion !== latestVersion) {
142
+ return outcome(
143
+ 'failed',
144
+ installedVersion,
145
+ `npm install finished but ${PELE_PACKAGE_NAME} ${latestVersion} is not in ${installDirectory}`,
146
+ );
147
+ }
148
+ return outcome(previousVersion ? 'updated' : 'installed', installedVersion);
149
+ }
150
+
151
+ /**
152
+ * Delete the Pele install directory an earlier install created.
153
+ *
154
+ * @param {string} installDirectory The folder `installPelePackage` filled.
155
+ * @returns {boolean} True when a folder was removed.
156
+ */
157
+ export function removePelePackage(installDirectory) {
158
+ if (!existsSync(installDirectory)) return false;
159
+ rmSync(installDirectory, { recursive: true, force: true, maxRetries: PELE_REMOVAL_RETRIES });
160
+ return true;
161
+ }
@@ -0,0 +1,269 @@
1
+ import { test } from 'node:test';
2
+ import { strict as assert } from 'node:assert';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import {
9
+ PELE_PACKAGE_NAME,
10
+ PELE_PACKAGE_SPEC,
11
+ installPelePackage,
12
+ installedPeleVersion,
13
+ peleInstallDirectory,
14
+ removePelePackage,
15
+ } from './install-pele-package.mjs';
16
+ import { shouldInstallMarketplacePlugin } from './install-pstack-plugin.mjs';
17
+
18
+ function writeInstalledPele(installDirectory, version) {
19
+ const packageDirectory = join(installDirectory, 'node_modules', PELE_PACKAGE_NAME);
20
+ mkdirSync(packageDirectory, { recursive: true });
21
+ writeFileSync(join(packageDirectory, 'package.json'), JSON.stringify({ name: PELE_PACKAGE_NAME, version }));
22
+ }
23
+
24
+ function fakeNpm({ latestVersion, installedAfterInstall, failOn }) {
25
+ const recordedCalls = [];
26
+ const recordedOptions = [];
27
+ const run = (commandArguments, options) => {
28
+ recordedCalls.push(commandArguments);
29
+ recordedOptions.push(options);
30
+ if (failOn === commandArguments[0]) return { status: 1, stdout: '', stderr: `${failOn} exploded` };
31
+ if (commandArguments[0] === 'view') return { status: 0, stdout: `${latestVersion}\n`, stderr: '' };
32
+ writeInstalledPele(options.cwd, installedAfterInstall ?? latestVersion);
33
+ return { status: 0, stdout: '', stderr: '' };
34
+ };
35
+ return { run, recordedCalls, recordedOptions };
36
+ }
37
+
38
+ function withInstallDirectory(body) {
39
+ const managedRoot = mkdtempSync(join(tmpdir(), 'cde-pele-'));
40
+ try {
41
+ body(peleInstallDirectory(managedRoot));
42
+ } finally {
43
+ rmSync(managedRoot, { recursive: true, force: true });
44
+ }
45
+ }
46
+
47
+ test('the install directory sits under the managed root and the package is named pele', () => {
48
+ assert.equal(PELE_PACKAGE_NAME, 'pele');
49
+ assert.match(peleInstallDirectory('/home/dev/.claude').replaceAll('\\', '/'), /\/home\/dev\/\.claude\/tools\/pele$/);
50
+ });
51
+
52
+ test('the registry lookup runs beside the install folder, not in the caller directory', () => {
53
+ const managedRoot = mkdtempSync(join(tmpdir(), 'cde-pele-'));
54
+ try {
55
+ const installDirectory = peleInstallDirectory(managedRoot);
56
+ const { run, recordedOptions } = fakeNpm({ latestVersion: '1.2.0' });
57
+ installPelePackage({ installDirectory, run });
58
+ assert.equal(recordedOptions[0].cwd, managedRoot);
59
+ assert.equal(recordedOptions[1].cwd, installDirectory);
60
+ } finally {
61
+ rmSync(managedRoot, { recursive: true, force: true });
62
+ }
63
+ });
64
+
65
+ test('a timed out npm call names the limit and keeps the partial output', () => {
66
+ withInstallDirectory(installDirectory => {
67
+ const timedOut = () => ({
68
+ status: null,
69
+ stdout: '',
70
+ stderr: 'npm warn config old setting',
71
+ error: Object.assign(new Error('spawnSync npm ETIMEDOUT'), { code: 'ETIMEDOUT' }),
72
+ });
73
+ const outcome = installPelePackage({ installDirectory, run: timedOut });
74
+ assert.equal(outcome.status, 'failed');
75
+ assert.match(outcome.warning, /timed out after 120000 ms npm warn config old setting/);
76
+ });
77
+ });
78
+
79
+ test('a missing install is installed at the latest registry version', () => {
80
+ withInstallDirectory(installDirectory => {
81
+ const { run, recordedCalls } = fakeNpm({ latestVersion: '1.2.0' });
82
+ const outcome = installPelePackage({ installDirectory, run });
83
+ assert.equal(outcome.status, 'installed');
84
+ assert.equal(outcome.installedVersion, '1.2.0');
85
+ assert.equal(installedPeleVersion(installDirectory), '1.2.0');
86
+ assert.deepEqual(recordedCalls[1], ['install', '--ignore-scripts', '--no-audit', '--no-fund', '--loglevel=error', 'pele@1.2.0']);
87
+ });
88
+ });
89
+
90
+ test('an outdated install is updated and reports both versions', () => {
91
+ withInstallDirectory(installDirectory => {
92
+ writeInstalledPele(installDirectory, '1.0.0');
93
+ const { run } = fakeNpm({ latestVersion: '1.2.0' });
94
+ const outcome = installPelePackage({ installDirectory, run });
95
+ assert.equal(outcome.status, 'updated');
96
+ assert.equal(outcome.previousVersion, '1.0.0');
97
+ assert.equal(outcome.installedVersion, '1.2.0');
98
+ });
99
+ });
100
+
101
+ test('a current install runs no install command', () => {
102
+ withInstallDirectory(installDirectory => {
103
+ writeInstalledPele(installDirectory, '1.2.0');
104
+ const { run, recordedCalls } = fakeNpm({ latestVersion: '1.2.0' });
105
+ const outcome = installPelePackage({ installDirectory, run });
106
+ assert.equal(outcome.status, 'current');
107
+ assert.deepEqual(recordedCalls.map(eachCall => eachCall[0]), ['view']);
108
+ });
109
+ });
110
+
111
+ test('a registry lookup failure keeps an existing install and fails a missing one', () => {
112
+ withInstallDirectory(installDirectory => {
113
+ const missing = installPelePackage({ installDirectory, run: fakeNpm({ failOn: 'view' }).run });
114
+ assert.equal(missing.status, 'failed');
115
+ assert.match(missing.warning, /view exploded/);
116
+ writeInstalledPele(installDirectory, '1.0.0');
117
+ const kept = installPelePackage({ installDirectory, run: fakeNpm({ failOn: 'view' }).run });
118
+ assert.equal(kept.status, 'current');
119
+ assert.equal(kept.installedVersion, '1.0.0');
120
+ assert.match(kept.warning, /view exploded/);
121
+ });
122
+ });
123
+
124
+ test('a registry answer that is not a plain version never reaches the install command', () => {
125
+ for (const hostileAnswer of ['1.2.0 & echo pwned', '1.2.0\n&& calc', '^1.2.0', 'latest', '1.2', '1.2.0;rm']) {
126
+ withInstallDirectory(installDirectory => {
127
+ const { run, recordedCalls } = fakeNpm({ latestVersion: hostileAnswer });
128
+ const outcome = installPelePackage({ installDirectory, run });
129
+ assert.equal(outcome.status, 'failed', hostileAnswer);
130
+ assert.match(outcome.warning, /not a version/);
131
+ assert.deepEqual(recordedCalls.map(eachCall => eachCall[0]), ['view'], hostileAnswer);
132
+ assert.equal(existsSync(join(installDirectory, 'package.json')), false);
133
+ });
134
+ }
135
+ });
136
+
137
+ test('a failing install command is reported and leaves the older version in place', () => {
138
+ withInstallDirectory(installDirectory => {
139
+ writeInstalledPele(installDirectory, '1.0.0');
140
+ const outcome = installPelePackage({ installDirectory, run: fakeNpm({ latestVersion: '1.2.0', failOn: 'install' }).run });
141
+ assert.equal(outcome.status, 'failed');
142
+ assert.match(outcome.warning, /install exploded/);
143
+ assert.equal(installedPeleVersion(installDirectory), '1.0.0');
144
+ });
145
+ });
146
+
147
+ test('an install that does not land the requested version is reported as failed', () => {
148
+ withInstallDirectory(installDirectory => {
149
+ const outcome = installPelePackage({
150
+ installDirectory,
151
+ run: fakeNpm({ latestVersion: '1.2.0', installedAfterInstall: '0.9.0' }).run,
152
+ });
153
+ assert.equal(outcome.status, 'failed');
154
+ assert.match(outcome.warning, /1\.2\.0/);
155
+ });
156
+ });
157
+
158
+ test('a newer local copy is kept and never downgraded', () => {
159
+ withInstallDirectory(installDirectory => {
160
+ writeInstalledPele(installDirectory, '1.10.0');
161
+ const { run, recordedCalls } = fakeNpm({ latestVersion: '1.9.3' });
162
+ const outcome = installPelePackage({ installDirectory, run });
163
+ assert.equal(outcome.status, 'current');
164
+ assert.equal(outcome.installedVersion, '1.10.0');
165
+ assert.deepEqual(recordedCalls.map(eachCall => eachCall[0]), ['view']);
166
+ });
167
+ });
168
+
169
+ test('a missing npm skips the step and a fresh install writes its own host manifest', () => {
170
+ withInstallDirectory(installDirectory => {
171
+ const absentNpm = () => ({ status: null, stdout: '', stderr: '', error: Object.assign(new Error('spawn npm ENOENT'), { code: 'ENOENT' }) });
172
+ const skipped = installPelePackage({ installDirectory, run: absentNpm });
173
+ assert.equal(skipped.status, 'skipped');
174
+ assert.equal(existsSync(join(installDirectory, 'package.json')), false);
175
+ installPelePackage({ installDirectory, run: fakeNpm({ latestVersion: '1.2.0' }).run });
176
+ const hostManifest = JSON.parse(readFileSync(join(installDirectory, 'package.json'), 'utf8'));
177
+ assert.equal(hostManifest.private, true);
178
+ });
179
+ });
180
+
181
+ test('removing the install folder deletes it once and reports an absent folder', () => {
182
+ withInstallDirectory(installDirectory => {
183
+ writeInstalledPele(installDirectory, '1.2.0');
184
+ assert.equal(removePelePackage(installDirectory), true);
185
+ assert.equal(existsSync(installDirectory), false);
186
+ assert.equal(removePelePackage(installDirectory), false);
187
+ });
188
+ });
189
+
190
+ test('a corrupt installed package.json reads as not installed', () => {
191
+ withInstallDirectory(installDirectory => {
192
+ const packageDirectory = join(installDirectory, 'node_modules', PELE_PACKAGE_NAME);
193
+ mkdirSync(packageDirectory, { recursive: true });
194
+ writeFileSync(join(packageDirectory, 'package.json'), '{not json');
195
+ assert.equal(installedPeleVersion(installDirectory), null);
196
+ assert.equal(existsSync(join(packageDirectory, 'package.json')), true);
197
+ assert.equal(readFileSync(join(packageDirectory, 'package.json'), 'utf8'), '{not json');
198
+ });
199
+ });
200
+
201
+ test('--no-pele and CDE_INSTALL_PELE=0 skip the step', () => {
202
+ assert.equal(shouldInstallMarketplacePlugin(PELE_PACKAGE_SPEC, [], {}), true);
203
+ assert.equal(shouldInstallMarketplacePlugin(PELE_PACKAGE_SPEC, ['--no-pele'], {}), false);
204
+ assert.equal(shouldInstallMarketplacePlugin(PELE_PACKAGE_SPEC, [], { CDE_INSTALL_PELE: '0' }), false);
205
+ });
206
+
207
+ const INSTALLER_PATH = fileURLToPath(new URL('./install.mjs', import.meta.url));
208
+ const STUB_NPM_SOURCE = `#!/usr/bin/env node
209
+ const fs = require('node:fs');
210
+ const path = require('node:path');
211
+ fs.appendFileSync(process.env.STUB_NPM_LOG, process.argv.slice(2).join(' ') + '\\n');
212
+ fs.appendFileSync(process.env.STUB_NPM_CWD_LOG, process.argv[2] + ' ' + process.cwd() + '\\n');
213
+ if (process.argv[2] === 'view') { process.stdout.write('3.4.5\\n'); process.exit(0); }
214
+ const packageDirectory = path.join(process.cwd(), 'node_modules', 'pele');
215
+ fs.mkdirSync(packageDirectory, { recursive: true });
216
+ fs.writeFileSync(path.join(packageDirectory, 'package.json'), JSON.stringify({ name: 'pele', version: '3.4.5' }));
217
+ `;
218
+
219
+ test('a full install adds Pele once, skips it on a rerun, and --uninstall removes it', { skip: process.platform === 'win32' }, () => {
220
+ const scratchRoot = mkdtempSync(join(tmpdir(), 'cde-pele-full-'));
221
+ try {
222
+ const stubDirectory = join(scratchRoot, 'stub-bin');
223
+ const homeDirectory = join(scratchRoot, 'home');
224
+ const callLog = join(scratchRoot, 'npm-calls.log');
225
+ const cwdLog = join(scratchRoot, 'npm-cwds.log');
226
+ mkdirSync(stubDirectory, { recursive: true });
227
+ mkdirSync(homeDirectory, { recursive: true });
228
+ writeFileSync(join(stubDirectory, 'npm'), STUB_NPM_SOURCE);
229
+ chmodSync(join(stubDirectory, 'npm'), 0o755);
230
+ writeFileSync(join(homeDirectory, '.gitconfig'), '');
231
+ const environment = {
232
+ ...process.env,
233
+ PATH: `${stubDirectory}:${process.env.PATH}`,
234
+ STUB_NPM_LOG: callLog,
235
+ STUB_NPM_CWD_LOG: cwdLog,
236
+ LLM_SETTINGS_PROFILES_ROOT: undefined,
237
+ HOME: homeDirectory,
238
+ USERPROFILE: homeDirectory,
239
+ CLAUDE_CONFIG_DIR: '',
240
+ GIT_CONFIG_GLOBAL: join(homeDirectory, '.gitconfig'),
241
+ CDE_INSTALL_PSTACK: '0',
242
+ CDE_INSTALL_DEEPSTACK: '0',
243
+ CDE_INSTALL_USAGE_WRAPUP: '0',
244
+ CDE_INSTALL_SUBAGENT_MODELS: '0',
245
+ CDE_INSTALL_SECURITY_GUIDANCE: '0',
246
+ };
247
+ const peleDirectory = join(homeDirectory, '.claude', 'tools', 'pele');
248
+ const firstRun = spawnSync(process.execPath, [INSTALLER_PATH], { encoding: 'utf8', env: environment });
249
+ assert.equal(firstRun.status, 0, firstRun.stdout + firstRun.stderr);
250
+ assert.match(firstRun.stdout, /Pele 3\.4\.5: installed/);
251
+ assert.equal(installedPeleVersion(peleDirectory), '3.4.5');
252
+ const secondRun = spawnSync(process.execPath, [INSTALLER_PATH], { encoding: 'utf8', env: environment });
253
+ assert.equal(secondRun.status, 0, secondRun.stdout + secondRun.stderr);
254
+ assert.match(secondRun.stdout, /Pele 3\.4\.5: current/);
255
+ const installCalls = readFileSync(callLog, 'utf8').split('\n').filter(eachLine => eachLine.startsWith('install '));
256
+ assert.equal(installCalls.length, 1);
257
+ const viewLine = readFileSync(cwdLog, 'utf8').split('\n').find(eachLine => eachLine.startsWith('view '));
258
+ assert.ok(viewLine, 'the installer never ran npm view');
259
+ assert.equal(viewLine.slice('view '.length), realpathSync(join(homeDirectory, '.claude')));
260
+ const optedOut = spawnSync(process.execPath, [INSTALLER_PATH, '--no-pele'], { encoding: 'utf8', env: environment });
261
+ assert.equal(optedOut.status, 0, optedOut.stdout + optedOut.stderr);
262
+ assert.doesNotMatch(optedOut.stdout, /Pele/);
263
+ const uninstall = spawnSync(process.execPath, [INSTALLER_PATH, '--uninstall'], { encoding: 'utf8', env: environment });
264
+ assert.equal(uninstall.status, 0, uninstall.stdout + uninstall.stderr);
265
+ assert.equal(existsSync(peleDirectory), false);
266
+ } finally {
267
+ rmSync(scratchRoot, { recursive: true, force: true });
268
+ }
269
+ });
@@ -234,11 +234,13 @@ export function hostCommandInvocation(
234
234
  };
235
235
  }
236
236
 
237
- function runHostCommand(executable, commandArguments, options) {
237
+ export function runHostCommand(executable, commandArguments, options = {}) {
238
238
  const invocation = hostCommandInvocation(executable, commandArguments);
239
239
  const spawned = spawnSync(invocation.file, invocation.args, {
240
240
  encoding: 'utf8',
241
241
  env: { ...process.env, ...options.environment },
242
+ cwd: options.cwd,
243
+ timeout: options.timeoutMilliseconds,
242
244
  windowsVerbatimArguments: invocation.windowsVerbatimArguments,
243
245
  });
244
246
  return {
@@ -252,13 +254,13 @@ function runHostCommand(executable, commandArguments, options) {
252
254
  const COMMAND_NOT_FOUND_EXIT_CODE = 9009;
253
255
  const COMMAND_NOT_FOUND_PATTERN = /is not recognized as an internal or external command/;
254
256
 
255
- function namesAnAbsentCommand(outcome) {
257
+ export function namesAnAbsentCommand(outcome) {
256
258
  if (outcome.error?.code === 'ENOENT') return true;
257
259
  return outcome.status === COMMAND_NOT_FOUND_EXIT_CODE
258
260
  && COMMAND_NOT_FOUND_PATTERN.test(outcome.stderr ?? '');
259
261
  }
260
262
 
261
- function singleLineDetail(text) {
263
+ export function singleLineDetail(text) {
262
264
  return (text ?? '').split(/\r?\n/).map(eachLine => eachLine.trim()).filter(Boolean).join(' ');
263
265
  }
264
266
 
@@ -54,6 +54,7 @@ function runInstaller(homeDirectory, extraArguments, environmentOverrides = {})
54
54
  LLM_SETTINGS_PROFILES_ROOT: undefined,
55
55
  CDE_INSTALL_PSTACK: '0',
56
56
  CDE_INSTALL_DEEPSTACK: '0',
57
+ CDE_INSTALL_PELE: '0',
57
58
  CDE_INSTALL_USAGE_WRAPUP: '0',
58
59
  CDE_INSTALL_SUBAGENT_MODELS: '0',
59
60
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -60,6 +60,7 @@ function runInstaller(homeDirectory, extraArguments) {
60
60
  LLM_SETTINGS_PROFILES_ROOT: undefined,
61
61
  CDE_INSTALL_PSTACK: '0',
62
62
  CDE_INSTALL_DEEPSTACK: '0',
63
+ CDE_INSTALL_PELE: '0',
63
64
  CDE_INSTALL_USAGE_WRAPUP: '0',
64
65
  CDE_INSTALL_SUBAGENT_MODELS: '0',
65
66
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -94,6 +95,7 @@ function scanTextWithProductionPiiScanner(scannedText) {
94
95
  LLM_SETTINGS_PROFILES_ROOT: undefined,
95
96
  CDE_INSTALL_PSTACK: '0',
96
97
  CDE_INSTALL_DEEPSTACK: '0',
98
+ CDE_INSTALL_PELE: '0',
97
99
  CDE_INSTALL_USAGE_WRAPUP: '0',
98
100
  CDE_INSTALL_SUBAGENT_MODELS: '0',
99
101
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -34,6 +34,7 @@ function runInstaller(homeDirectory, extraArguments, environmentOverrides = {})
34
34
  LLM_SETTINGS_PROFILES_ROOT: undefined,
35
35
  CDE_INSTALL_PSTACK: '0',
36
36
  CDE_INSTALL_DEEPSTACK: '0',
37
+ CDE_INSTALL_PELE: '0',
37
38
  CDE_INSTALL_USAGE_WRAPUP: '0',
38
39
  CDE_INSTALL_SUBAGENT_MODELS: '0',
39
40
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
package/bin/install.mjs CHANGED
@@ -71,6 +71,12 @@ import {
71
71
  removeDeepStackCursorHooks,
72
72
  removeRetiredCursorFirstTaskHook,
73
73
  } from './install-deepstack-plugin.mjs';
74
+ import {
75
+ PELE_PACKAGE_SPEC,
76
+ installPelePackage,
77
+ peleInstallDirectory,
78
+ removePelePackage,
79
+ } from './install-pele-package.mjs';
74
80
  import { seedCodexPstackModels } from './seed-codex-pstack-models.mjs';
75
81
  import {
76
82
  removeCursorAgentsGuidanceHooks,
@@ -3110,6 +3116,16 @@ function executeInstallPlanMutations(plan, transactionHelpers) {
3110
3116
  allActionNeededLines.push(`DeepStack (cursor): failed — ${cursorOutcome.warning}`);
3111
3117
  }
3112
3118
  }
3119
+ if (!selectedGroups && shouldInstallMarketplacePlugin(PELE_PACKAGE_SPEC)) {
3120
+ const pelePackage = installPelePackage({ installDirectory: peleInstallDirectory(CLAUDE_HOME) });
3121
+ summary.pelePackage = pelePackage;
3122
+ const peleVersionText = pelePackage.installedVersion ? ` ${pelePackage.installedVersion}` : '';
3123
+ const peleLine = pelePackage.warning
3124
+ ? `Pele${peleVersionText}: ${pelePackage.status} — ${pelePackage.warning}`
3125
+ : `Pele${peleVersionText}: ${pelePackage.status}`;
3126
+ console.log(` ${peleLine}`);
3127
+ if (pelePackage.status === 'failed') allActionNeededLines.push(peleLine);
3128
+ }
3113
3129
  if (!selectedGroups) {
3114
3130
  const retiredCursorHooksPath = removeRetiredCursorFirstTaskHook(
3115
3131
  INSTALL_ROOT_RESOLUTION.cursorInstallDirectory,
@@ -3667,6 +3683,7 @@ function uninstall() {
3667
3683
  faultPhase,
3668
3684
  runMutations: ({ throwIfFault }) => {
3669
3685
  executeUninstallPlan(plan, { throwIfFault, allProfileSettingsPaths: gateRemoval.allReadablePaths });
3686
+ if (removePelePackage(peleInstallDirectory(CLAUDE_HOME))) console.log(' Pele: install directory removed');
3670
3687
  },
3671
3688
  });
3672
3689
  } catch (mutationError) {
@@ -3712,6 +3729,7 @@ Usage:
3712
3729
  npx ${PACKAGE_NAME} --no-usage-wrapup Full install without the usage-wrapup plugin (also CDE_INSTALL_USAGE_WRAPUP=0)
3713
3730
  npx ${PACKAGE_NAME} --no-subagent-models Full install without the subagent-models plugin (also CDE_INSTALL_SUBAGENT_MODELS=0)
3714
3731
  npx ${PACKAGE_NAME} --no-security-guidance Full install without Anthropic's security-guidance plugin (also CDE_INSTALL_SECURITY_GUIDANCE=0)
3732
+ npx ${PACKAGE_NAME} --no-pele Full install without the Pele Mermaid renderer npm package (also CDE_INSTALL_PELE=0)
3715
3733
  npx ${PACKAGE_NAME} --uninstall Remove installed files from the selected root
3716
3734
  npx ${PACKAGE_NAME} --help Show this help
3717
3735
 
@@ -22,7 +22,7 @@ test('packed full and core installs ship the runnable PR visual skill to the sha
22
22
  const homeDirectory = join(sandbox, `home-${eachIndex}`);
23
23
  execFileSync(process.execPath, [join(packaged, 'bin/install.mjs'), ...eachArguments], {
24
24
  encoding: 'utf8',
25
- env: { ...process.env, CLAUDE_CONFIG_DIR: undefined, LLM_SETTINGS_PROFILES_ROOT: undefined, HOME: homeDirectory, USERPROFILE: homeDirectory, CODEX_HOME: join(homeDirectory, '.codex'), GIT_CONFIG_GLOBAL: join(homeDirectory, '.gitconfig'), CDE_INSTALL_PSTACK: '0', CDE_INSTALL_DEEPSTACK: '0', CDE_INSTALL_USAGE_WRAPUP: '0', CDE_INSTALL_SUBAGENT_MODELS: '0', CDE_INSTALL_SECURITY_GUIDANCE: '0', CDE_INSTALL_DEEPEN_FIRST_PROMPT: '0' },
25
+ env: { ...process.env, CLAUDE_CONFIG_DIR: undefined, LLM_SETTINGS_PROFILES_ROOT: undefined, HOME: homeDirectory, USERPROFILE: homeDirectory, CODEX_HOME: join(homeDirectory, '.codex'), GIT_CONFIG_GLOBAL: join(homeDirectory, '.gitconfig'), CDE_INSTALL_PSTACK: '0', CDE_INSTALL_DEEPSTACK: '0', CDE_INSTALL_PELE: '0', CDE_INSTALL_USAGE_WRAPUP: '0', CDE_INSTALL_SUBAGENT_MODELS: '0', CDE_INSTALL_SECURITY_GUIDANCE: '0', CDE_INSTALL_DEEPEN_FIRST_PROMPT: '0' },
26
26
  });
27
27
  const installed = join(homeDirectory, ...SKILL_PATH_SEGMENTS);
28
28
  for (const eachFile of REQUIRED_FILES) assert.deepEqual(readFileSync(join(installed, eachFile)), readFileSync(join(packaged, ...SKILL_PATH_SEGMENTS, eachFile)));
@@ -32,6 +32,7 @@ function installEnvironment(homeDirectory) {
32
32
  CODEX_HOME: join(homeDirectory, '.codex'),
33
33
  CDE_INSTALL_PSTACK: '0',
34
34
  CDE_INSTALL_DEEPSTACK: '0',
35
+ CDE_INSTALL_PELE: '0',
35
36
  CDE_INSTALL_USAGE_WRAPUP: '0',
36
37
  };
37
38
  }
@@ -266,6 +266,7 @@ function resolveInstallerInvocation(homeDirectory) {
266
266
  LLM_SETTINGS_PROFILES_ROOT: undefined,
267
267
  CDE_INSTALL_PSTACK: '0',
268
268
  CDE_INSTALL_DEEPSTACK: '0',
269
+ CDE_INSTALL_PELE: '0',
269
270
  CDE_INSTALL_USAGE_WRAPUP: '0',
270
271
  CDE_INSTALL_SUBAGENT_MODELS: '0',
271
272
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -26,6 +26,7 @@ function installInScratchHome(homeDirectory, argumentsList = [], extraEnvironmen
26
26
  LLM_SETTINGS_PROFILES_ROOT: undefined,
27
27
  CDE_INSTALL_PSTACK: '0',
28
28
  CDE_INSTALL_DEEPSTACK: '0',
29
+ CDE_INSTALL_PELE: '0',
29
30
  CDE_INSTALL_USAGE_WRAPUP: '0',
30
31
  CDE_INSTALL_SUBAGENT_MODELS: '0',
31
32
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -184,6 +185,7 @@ test('a successful pstack install omits the retired skill block and gains the qu
184
185
  const installation = installInScratchHome(homeDirectory, [], {
185
186
  CDE_INSTALL_PSTACK: '1',
186
187
  CDE_INSTALL_DEEPSTACK: '0',
188
+ CDE_INSTALL_PELE: '0',
187
189
  CDE_INSTALL_USAGE_WRAPUP: '0',
188
190
  CDE_INSTALL_SUBAGENT_MODELS: '0',
189
191
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -214,6 +216,7 @@ test('enabling pstack after a pstack-off install preserves question guidance', (
214
216
  const secondInstallation = installInScratchHome(homeDirectory, [], {
215
217
  CDE_INSTALL_PSTACK: '1',
216
218
  CDE_INSTALL_DEEPSTACK: '0',
219
+ CDE_INSTALL_PELE: '0',
217
220
  CDE_INSTALL_USAGE_WRAPUP: '0',
218
221
  CDE_INSTALL_SUBAGENT_MODELS: '0',
219
222
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -245,6 +248,7 @@ test('a failed pstack transition restores question-only guidance and removes its
245
248
  const failedInstallation = installInScratchHome(homeDirectory, [], {
246
249
  CDE_INSTALL_PSTACK: '1',
247
250
  CDE_INSTALL_DEEPSTACK: '0',
251
+ CDE_INSTALL_PELE: '0',
248
252
  CDE_INSTALL_USAGE_WRAPUP: '0',
249
253
  CDE_INSTALL_SUBAGENT_MODELS: '0',
250
254
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -72,6 +72,7 @@ function runInstallerInSandbox(sandboxHome, installerArguments = []) {
72
72
  LLM_SETTINGS_PROFILES_ROOT: undefined,
73
73
  CDE_INSTALL_PSTACK: '0',
74
74
  CDE_INSTALL_DEEPSTACK: '0',
75
+ CDE_INSTALL_PELE: '0',
75
76
  CDE_INSTALL_USAGE_WRAPUP: '0',
76
77
  CDE_INSTALL_SUBAGENT_MODELS: '0',
77
78
  CDE_INSTALL_SECURITY_GUIDANCE: '0',
@@ -32,6 +32,7 @@ function installEnvironment(homeDirectory) {
32
32
  GIT_CONFIG_GLOBAL: join(homeDirectory, '.gitconfig'),
33
33
  CDE_INSTALL_PSTACK: '0',
34
34
  CDE_INSTALL_DEEPSTACK: '0',
35
+ CDE_INSTALL_PELE: '0',
35
36
  CDE_INSTALL_USAGE_WRAPUP: '0',
36
37
  CDE_INSTALL_SUBAGENT_MODELS: '0',
37
38
  CDE_INSTALL_SECURITY_GUIDANCE: '0',