@codeledger/cli 0.10.80 → 0.10.81
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 +22 -2
- package/bin/codeledger.js +23 -40
- package/package.json +1 -1
- package/scripts/postinstall.js +48 -67
package/README.md
CHANGED
|
@@ -72,8 +72,28 @@ runner situation to stabilize in a later release.
|
|
|
72
72
|
|
|
73
73
|
Other platforms fall through `postinstall` softly — `npm install`
|
|
74
74
|
succeeds, but running `codeledger` will either use a repo-local vendored
|
|
75
|
-
runtime if the
|
|
76
|
-
|
|
75
|
+
runtime if the selected repo has `.codeledger/bin/`, or report the unavailable
|
|
76
|
+
native route. Skipping postinstall does not create a runtime for a fresh repo;
|
|
77
|
+
`codeledger init` cannot bootstrap through that missing-runtime loop. Intel Macs
|
|
78
|
+
cannot run Apple Silicon binaries through Rosetta. Use a supported host or
|
|
79
|
+
review the source-build prerequisites, without assuming untested OS support.
|
|
80
|
+
|
|
81
|
+
## MCP First Use
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
codeledger ready --cwd /absolute/path/to/repo --task "Inspect this repository"
|
|
85
|
+
codeledger license status --cwd /absolute/path/to/repo
|
|
86
|
+
codeledger mcp status --cwd /absolute/path/to/repo --json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use the printed repository-bound config. The launcher must include `mcp start`,
|
|
90
|
+
for example `npx -y @codeledger/cli@latest mcp start --cwd /absolute/path/to/repo`.
|
|
91
|
+
Published MCP access requires an activated Team or Enterprise license. Install
|
|
92
|
+
and configuration success do not establish a connection: reconnect, require
|
|
93
|
+
initialize and tools/list, then call `get_active_context` with `{}` to read the
|
|
94
|
+
prepared bundle. Missing activation is degraded context. Verify cold and warm
|
|
95
|
+
cache behavior; diagnostics must stay on stderr. See
|
|
96
|
+
[MCP First Use](https://github.com/codeledgerECF/codeledger/blob/main/docs/MCP.md).
|
|
77
97
|
|
|
78
98
|
## Usage
|
|
79
99
|
|
package/bin/codeledger.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
const { spawnSync } = require('node:child_process');
|
|
21
|
-
const { existsSync } = require('node:fs');
|
|
21
|
+
const { existsSync, realpathSync, statSync } = require('node:fs');
|
|
22
22
|
const { dirname, join, resolve } = require('node:path');
|
|
23
23
|
const { homedir, platform } = require('node:os');
|
|
24
24
|
|
|
@@ -88,9 +88,28 @@ function runRepoLocal(runtime) {
|
|
|
88
88
|
// install step.
|
|
89
89
|
const ON_DEMAND_DEADLINE_MS = 30_000;
|
|
90
90
|
|
|
91
|
+
function launchDirectory() {
|
|
92
|
+
const args = process.argv.slice(2);
|
|
93
|
+
let target;
|
|
94
|
+
for (let i = 0; i < args.length && args[i] !== '--'; i++) {
|
|
95
|
+
if (args[i].startsWith('--cwd=')) target = args[i].slice(6);
|
|
96
|
+
else if (args[i] === '--cwd') {
|
|
97
|
+
target = args[++i];
|
|
98
|
+
if (!target || target.startsWith('--')) die('--cwd requires a repository directory.', 2);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (target === undefined && args[0] === 'mcp') target = process.env.CODELEDGER_REPO_ROOT;
|
|
102
|
+
if (target !== undefined && !target.trim()) die('Repository target cannot be empty.', 2);
|
|
103
|
+
try {
|
|
104
|
+
const root = realpathSync(resolve(target ?? process.cwd()));
|
|
105
|
+
if (!statSync(root).isDirectory()) throw new Error('Not a directory');
|
|
106
|
+
return root;
|
|
107
|
+
} catch { die('Repository target must be an existing directory. Check --cwd or CODELEDGER_REPO_ROOT.', 2); }
|
|
108
|
+
}
|
|
109
|
+
|
|
91
110
|
async function main() {
|
|
92
111
|
if (!existsSync(BINARY_PATH)) {
|
|
93
|
-
const repoLocal = findRepoLocalRuntime(
|
|
112
|
+
const repoLocal = findRepoLocalRuntime(launchDirectory());
|
|
94
113
|
if (repoLocal) {
|
|
95
114
|
runRepoLocal(repoLocal);
|
|
96
115
|
}
|
|
@@ -99,49 +118,13 @@ async function main() {
|
|
|
99
118
|
const platformKey = `${platform()}-${arch()}`;
|
|
100
119
|
const installerPath = join(__dirname, '..', 'scripts', 'postinstall.js');
|
|
101
120
|
|
|
102
|
-
|
|
103
|
-
die(
|
|
104
|
-
[
|
|
105
|
-
`ContextECF CodeLedger hardened binary for v${version} not found at ${BINARY_PATH}.`,
|
|
106
|
-
'',
|
|
107
|
-
'You are on an Intel Mac (darwin-x64). Pre-built binaries are',
|
|
108
|
-
'available for Apple Silicon (darwin-arm64) only.',
|
|
109
|
-
'',
|
|
110
|
-
'Options:',
|
|
111
|
-
' 1. Use Rosetta 2 (recommended):',
|
|
112
|
-
' arch -arm64 npm install -g @codeledger/cli@latest',
|
|
113
|
-
' 2. If this repo was already initialized, use the vendored CLI:',
|
|
114
|
-
' ./.codeledger/bin/codeledger ready',
|
|
115
|
-
' node .codeledger/bin/codeledger-standalone.cjs ready',
|
|
116
|
-
' 3. Update CodeLedger, then use the vendored standalone CLI:',
|
|
117
|
-
' npm install -g @codeledger/cli@latest',
|
|
118
|
-
' codeledger init # in your repo, sets up vendored Node.js-based CLI',
|
|
119
|
-
' ./.codeledger/bin/codeledger --version',
|
|
120
|
-
' 4. Download a binary manually from:',
|
|
121
|
-
` https://github.com/codeledgerECF/codeledger/releases/tag/v${version}`,
|
|
122
|
-
].join('\n'),
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const { PLATFORM_MAP, downloadAndVerifyBinary } = require('../scripts/postinstall.js');
|
|
121
|
+
const { PLATFORM_MAP, downloadAndVerifyBinary, unsupportedPlatformMessage } = require('../scripts/postinstall.js');
|
|
127
122
|
if (!PLATFORM_MAP[platformKey]) {
|
|
128
123
|
// Don't waste time on a download attempt that can only ever fail —
|
|
129
124
|
// getBinaryPaths() would reject this platformKey immediately anyway.
|
|
130
125
|
// See postinstall.js's matching message for why this is "no
|
|
131
126
|
// committed timeline", not "try again later".
|
|
132
|
-
die(
|
|
133
|
-
[
|
|
134
|
-
`${platformKey} is not currently supported by the hardened binary.`,
|
|
135
|
-
`Supported: ${Object.keys(PLATFORM_MAP).join(', ')}. No committed timeline for ${platformKey} support.`,
|
|
136
|
-
'',
|
|
137
|
-
'Use the vendored standalone CLI instead (pure Node.js, no native binary):',
|
|
138
|
-
' CODELEDGER_SKIP_POSTINSTALL=1 npm install -g @codeledger/cli@latest',
|
|
139
|
-
' codeledger init # sets up the vendored Node.js-based CLI',
|
|
140
|
-
' ./.codeledger/bin/codeledger --version',
|
|
141
|
-
'',
|
|
142
|
-
`Track or request ${platformKey} support: https://github.com/codeledgerECF/codeledger/issues`,
|
|
143
|
-
].join('\n'),
|
|
144
|
-
);
|
|
127
|
+
die(unsupportedPlatformMessage(platformKey));
|
|
145
128
|
}
|
|
146
129
|
|
|
147
130
|
process.stderr.write(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeledger/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.81",
|
|
4
4
|
"mcpName": "io.github.codeledgerECF/codeledger",
|
|
5
5
|
"description": "Official ContextECF CodeLedger CLI wrapper. Installs the hardened binary from GitHub Releases; zero engine code ships in this package.",
|
|
6
6
|
"type": "commonjs",
|
package/scripts/postinstall.js
CHANGED
|
@@ -50,14 +50,26 @@ const { version } = require('../package.json');
|
|
|
50
50
|
|
|
51
51
|
// ─── platform / path resolution (pure — no I/O, no process.exit) ──────────
|
|
52
52
|
|
|
53
|
-
//
|
|
54
|
-
// release CI plan as of 2026-04-09. Re-add when a working Intel Mac binary
|
|
55
|
-
// is available.
|
|
53
|
+
// Only these native asset names are wired into this installer.
|
|
56
54
|
const PLATFORM_MAP = {
|
|
57
55
|
'darwin-arm64': 'darwin-arm64',
|
|
58
56
|
'linux-x64': 'linux-x64',
|
|
59
57
|
};
|
|
60
58
|
|
|
59
|
+
function unsupportedPlatformMessage(platformKey) {
|
|
60
|
+
return [
|
|
61
|
+
`${platformKey} has no pre-built CodeLedger hardened binary.`,
|
|
62
|
+
`Supported native routes: ${Object.keys(PLATFORM_MAP).join(', ')}.`,
|
|
63
|
+
'A successful npm install does not establish a working runtime or MCP connection.',
|
|
64
|
+
'For an already initialized repository with a trusted vendored runtime:',
|
|
65
|
+
' node .codeledger/bin/codeledger-standalone.cjs ready',
|
|
66
|
+
'For a fresh repository, use a supported host or a supported linux-x64 environment.',
|
|
67
|
+
'Skipping postinstall does not bootstrap a missing runtime; codeledger init cannot fix that loop.',
|
|
68
|
+
'Intel Macs cannot run an Apple Silicon binary through Rosetta.',
|
|
69
|
+
'Source-build prerequisites and limitations: https://github.com/codeledgerECF/codeledger/blob/main/docs/security/ENTERPRISE_ASSURANCE.md',
|
|
70
|
+
].join('\n');
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
function getPlatformKey() {
|
|
62
74
|
return `${platform()}-${arch()}`;
|
|
63
75
|
}
|
|
@@ -98,11 +110,13 @@ function isBinaryCached() {
|
|
|
98
110
|
|
|
99
111
|
const FETCH_TIMEOUT_MS = 60_000;
|
|
100
112
|
|
|
101
|
-
function fetchBufferOnce(url, redirectDepth = 0) {
|
|
113
|
+
function fetchBufferOnce(url, redirectDepth = 0, expiresAt = Date.now() + FETCH_TIMEOUT_MS) {
|
|
102
114
|
if (redirectDepth > 5) {
|
|
103
115
|
return Promise.reject(new Error(`too many redirects fetching ${url}`));
|
|
104
116
|
}
|
|
105
117
|
return new Promise((resolve, reject) => {
|
|
118
|
+
const remaining = Math.min(FETCH_TIMEOUT_MS, expiresAt - Date.now());
|
|
119
|
+
if (remaining <= 0) { reject(new Error('Binary download deadline exceeded.')); return; }
|
|
106
120
|
const req = https.get(
|
|
107
121
|
url,
|
|
108
122
|
{
|
|
@@ -122,7 +136,7 @@ function fetchBufferOnce(url, redirectDepth = 0) {
|
|
|
122
136
|
) {
|
|
123
137
|
res.resume();
|
|
124
138
|
const next = new URL(res.headers.location, url).toString();
|
|
125
|
-
fetchBufferOnce(next, redirectDepth + 1).then(resolve, reject);
|
|
139
|
+
fetchBufferOnce(next, redirectDepth + 1, expiresAt).then(resolve, reject);
|
|
126
140
|
return;
|
|
127
141
|
}
|
|
128
142
|
if (res.statusCode !== 200) {
|
|
@@ -138,10 +152,13 @@ function fetchBufferOnce(url, redirectDepth = 0) {
|
|
|
138
152
|
res.on('error', reject);
|
|
139
153
|
},
|
|
140
154
|
);
|
|
155
|
+
const timer = setTimeout(() => {
|
|
156
|
+
const error = new Error('Binary download deadline exceeded.');
|
|
157
|
+
req.destroy(error);
|
|
158
|
+
reject(error);
|
|
159
|
+
}, remaining);
|
|
141
160
|
req.on('error', reject);
|
|
142
|
-
req.
|
|
143
|
-
req.destroy(new Error(`timeout fetching ${url}`));
|
|
144
|
-
});
|
|
161
|
+
req.once('close', () => clearTimeout(timer));
|
|
145
162
|
});
|
|
146
163
|
}
|
|
147
164
|
|
|
@@ -165,7 +182,7 @@ async function fetchBuffer(url, deadlineMs = DEFAULT_DEADLINE_MS) {
|
|
|
165
182
|
let lastErr;
|
|
166
183
|
for (;;) {
|
|
167
184
|
try {
|
|
168
|
-
return await fetchBufferOnce(url);
|
|
185
|
+
return await fetchBufferOnce(url, 0, start + deadlineMs);
|
|
169
186
|
} catch (err) {
|
|
170
187
|
lastErr = err;
|
|
171
188
|
// Only retry on 404 — everything else is a hard failure.
|
|
@@ -175,7 +192,7 @@ async function fetchBuffer(url, deadlineMs = DEFAULT_DEADLINE_MS) {
|
|
|
175
192
|
if (elapsed + wait >= deadlineMs) break;
|
|
176
193
|
attempt += 1;
|
|
177
194
|
const remainingSec = Math.round((deadlineMs - elapsed) / 1000);
|
|
178
|
-
console.
|
|
195
|
+
console.error(
|
|
179
196
|
`codeledger: Binary pending — retrying in ${Math.round(wait / 1000)}s ` +
|
|
180
197
|
`(${remainingSec}s left in propagation window).`,
|
|
181
198
|
);
|
|
@@ -219,8 +236,8 @@ async function downloadAndVerifyBinary({ deadlineMs = DEFAULT_DEADLINE_MS } = {}
|
|
|
219
236
|
throw new Error(`unsupported platform ${platformKey}`);
|
|
220
237
|
}
|
|
221
238
|
|
|
222
|
-
console.
|
|
223
|
-
console.
|
|
239
|
+
console.error(`codeledger: installing v${version} hardened binary for ${platformKey}`);
|
|
240
|
+
console.error(` source: ${paths.binaryUrl}`);
|
|
224
241
|
|
|
225
242
|
const [checksumsBuf, binary] = await Promise.all([
|
|
226
243
|
fetchBuffer(paths.checksumsUrl, deadlineMs),
|
|
@@ -252,8 +269,8 @@ async function downloadAndVerifyBinary({ deadlineMs = DEFAULT_DEADLINE_MS } = {}
|
|
|
252
269
|
if (existsSync(paths.binaryLocalPath)) unlinkSync(paths.binaryLocalPath);
|
|
253
270
|
require('node:fs').renameSync(tmpPath, paths.binaryLocalPath);
|
|
254
271
|
|
|
255
|
-
console.
|
|
256
|
-
console.
|
|
272
|
+
console.error(`codeledger: installed ${paths.binaryLocalPath}`);
|
|
273
|
+
console.error(` sha256: ${actualSha}`);
|
|
257
274
|
|
|
258
275
|
return paths.binaryLocalPath;
|
|
259
276
|
}
|
|
@@ -271,16 +288,16 @@ function maybeRunUpgrade() {
|
|
|
271
288
|
const homeCwd = process.env['HOME'] ?? process.env['USERPROFILE'] ?? process.cwd();
|
|
272
289
|
const upgradeCwd =
|
|
273
290
|
initCwd && fs.existsSync(path.join(initCwd, '.codeledger')) ? initCwd : homeCwd;
|
|
274
|
-
console.
|
|
291
|
+
console.error('codeledger: CODELEDGER_RUN_UPGRADE=1 set, running upgrade...');
|
|
275
292
|
const upgradeResult = spawnSync(process.execPath, [codeledgerBin, 'upgrade'], {
|
|
276
293
|
stdio: 'inherit',
|
|
277
294
|
cwd: upgradeCwd,
|
|
278
295
|
env: { ...process.env, CODELEDGER_SKIP_AMBIENT_ACTIVATION: '1' },
|
|
279
296
|
});
|
|
280
297
|
if ((upgradeResult.status ?? 0) !== 0) {
|
|
281
|
-
console.
|
|
282
|
-
console.
|
|
283
|
-
console.
|
|
298
|
+
console.error('');
|
|
299
|
+
console.error('codeledger: upgrade step encountered an issue. Run manually:');
|
|
300
|
+
console.error(' codeledger upgrade');
|
|
284
301
|
}
|
|
285
302
|
}
|
|
286
303
|
}
|
|
@@ -293,7 +310,7 @@ function maybeRunUpgrade() {
|
|
|
293
310
|
|
|
294
311
|
async function runPostinstall() {
|
|
295
312
|
if (process.env.CODELEDGER_SKIP_POSTINSTALL === '1') {
|
|
296
|
-
console.
|
|
313
|
+
console.error(
|
|
297
314
|
'codeledger: CODELEDGER_SKIP_POSTINSTALL=1 set, skipping ContextECF CodeLedger hardened binary download.',
|
|
298
315
|
);
|
|
299
316
|
return;
|
|
@@ -308,7 +325,7 @@ async function runPostinstall() {
|
|
|
308
325
|
const fs = require('node:fs');
|
|
309
326
|
const workspaceRoot = path.resolve(__dirname, '..', '..', '..');
|
|
310
327
|
if (fs.existsSync(path.join(workspaceRoot, 'pnpm-workspace.yaml'))) {
|
|
311
|
-
console.
|
|
328
|
+
console.error(
|
|
312
329
|
'codeledger: in-workspace dev install detected, skipping ContextECF CodeLedger hardened binary download.',
|
|
313
330
|
);
|
|
314
331
|
return;
|
|
@@ -319,56 +336,19 @@ async function runPostinstall() {
|
|
|
319
336
|
|
|
320
337
|
const platformKey = getPlatformKey();
|
|
321
338
|
|
|
322
|
-
if (platformKey === 'darwin-x64') {
|
|
323
|
-
console.log('');
|
|
324
|
-
console.log('codeledger: ContextECF CodeLedger Intel Mac (darwin-x64) detected.');
|
|
325
|
-
console.log('codeledger: Pre-built binaries are available for Apple Silicon (darwin-arm64) only.');
|
|
326
|
-
console.log('');
|
|
327
|
-
console.log('Options:');
|
|
328
|
-
console.log(' Official package: @codeledger/cli. Avoid unrelated unscoped package: codeledger.');
|
|
329
|
-
console.log(' 1. Use Rosetta 2 (recommended):');
|
|
330
|
-
console.log(' arch -arm64 npm install -g @codeledger/cli@latest');
|
|
331
|
-
console.log(' 2. If this repo was already initialized, use the vendored CLI:');
|
|
332
|
-
console.log(' ./.codeledger/bin/codeledger ready');
|
|
333
|
-
console.log(' node .codeledger/bin/codeledger-standalone.cjs ready');
|
|
334
|
-
console.log(' 3. Use the vendored standalone CLI after init:');
|
|
335
|
-
console.log(' CODELEDGER_SKIP_POSTINSTALL=1 npm install -g @codeledger/cli@latest');
|
|
336
|
-
console.log(' codeledger init # sets up vendored Node.js-based CLI');
|
|
337
|
-
console.log(' 4. Download a binary manually from:');
|
|
338
|
-
console.log(` https://github.com/codeledgerECF/codeledger/releases/tag/v${version}`);
|
|
339
|
-
console.log('');
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
339
|
if (!PLATFORM_MAP[platformKey]) {
|
|
344
|
-
//
|
|
345
|
-
|
|
346
|
-
// in the release pipeline at all and no committed timeline to add one.
|
|
347
|
-
// Say that plainly rather than implying support is imminent — the
|
|
348
|
-
// vendored standalone CLI (pure Node.js, no native binary) works on any
|
|
349
|
-
// platform Node itself runs on, so there IS a real path forward, just
|
|
350
|
-
// not the hardened-binary one.
|
|
351
|
-
console.error('');
|
|
352
|
-
console.error(`codeledger: ${platformKey} is not currently supported by the hardened binary.`);
|
|
353
|
-
console.error(`codeledger: Supported: ${Object.keys(PLATFORM_MAP).join(', ')}. No committed timeline for ${platformKey} support.`);
|
|
354
|
-
console.error('codeledger: this installer is for ContextECF CodeLedger (@codeledger/cli).');
|
|
355
|
-
console.error('');
|
|
356
|
-
console.error('Use the vendored standalone CLI instead (pure Node.js, no native binary):');
|
|
357
|
-
console.error(' CODELEDGER_SKIP_POSTINSTALL=1 npm install -g @codeledger/cli@latest');
|
|
358
|
-
console.error(' codeledger init # sets up the vendored Node.js-based CLI');
|
|
359
|
-
console.error(' ./.codeledger/bin/codeledger --version');
|
|
360
|
-
console.error('');
|
|
361
|
-
console.error(`Track or request ${platformKey} support: https://github.com/codeledgerECF/codeledger/issues`);
|
|
340
|
+
// Soft install failure does not create a fresh runtime on this platform.
|
|
341
|
+
console.error(`codeledger: ${unsupportedPlatformMessage(platformKey)}`);
|
|
362
342
|
return;
|
|
363
343
|
}
|
|
364
344
|
|
|
365
345
|
try {
|
|
366
346
|
await downloadAndVerifyBinary();
|
|
367
|
-
console.
|
|
368
|
-
console.
|
|
369
|
-
console.
|
|
370
|
-
console.
|
|
371
|
-
console.
|
|
347
|
+
console.error('');
|
|
348
|
+
console.error('codeledger: install complete.');
|
|
349
|
+
console.error(' Next: cd your-repo && codeledger ready');
|
|
350
|
+
console.error(' Existing repos can refresh ambient hooks/runtime with: codeledger upgrade');
|
|
351
|
+
console.error('codeledger: ready initializes, scans, and prepares ambient task context.');
|
|
372
352
|
maybeRunUpgrade();
|
|
373
353
|
} catch (err) {
|
|
374
354
|
// Soft-fail, deliberately: exit 0 either way. A failed postinstall
|
|
@@ -376,9 +356,9 @@ async function runPostinstall() {
|
|
|
376
356
|
// existing working install (the exact incident this is designed
|
|
377
357
|
// around). bin/codeledger.js retries this same download on-demand,
|
|
378
358
|
// synchronously, the first time it's actually needed.
|
|
379
|
-
console.
|
|
380
|
-
console.
|
|
381
|
-
console.
|
|
359
|
+
console.error(`codeledger: could not pre-fetch the hardened binary — ${err.message}`);
|
|
360
|
+
console.error('codeledger: not fatal — it will download automatically on first "codeledger" invocation.');
|
|
361
|
+
console.error('codeledger: or, in an initialized repo, use: ./.codeledger/bin/codeledger ready');
|
|
382
362
|
}
|
|
383
363
|
}
|
|
384
364
|
|
|
@@ -397,4 +377,5 @@ module.exports = {
|
|
|
397
377
|
getPlatformKey,
|
|
398
378
|
getBinaryPaths,
|
|
399
379
|
isBinaryCached,
|
|
380
|
+
unsupportedPlatformMessage,
|
|
400
381
|
};
|