@codeledger/cli 0.10.86 → 0.10.87
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/LICENSE +21 -0
- package/README.md +33 -0
- package/codeledger-mcp.cjs +7 -0
- package/codeledger-open.cjs +5 -0
- package/package.json +11 -8
- package/codeledger-standalone.cjs +0 -12132
- package/codeledger-standalone.cjs.LEGAL.txt +0 -238
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Intelligent Context AI, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# CodeLedger portable CLI
|
|
2
|
+
|
|
3
|
+
Use Node.js 20 or newer and Git. The CLI returns literal matches from committed
|
|
4
|
+
source, tests and docs in the selected worktree. Each match includes the Git
|
|
5
|
+
revision, relative path, line number and matching text.
|
|
6
|
+
|
|
7
|
+
For the ZIP, verify its SHA-256 against SHA256SUMS.txt before extracting it.
|
|
8
|
+
Run the following in a Git worktree with a committed HEAD.
|
|
9
|
+
|
|
10
|
+
node /path/to/codeledger-open.cjs activate --task "Find the HTTP 429 fallback" --query "Retry-After"
|
|
11
|
+
|
|
12
|
+
For npm, use codeledger in place of node and the CJS path.
|
|
13
|
+
To search one supported repository-relative file, add --file src/retry.ts.
|
|
14
|
+
If it is absent from committed HEAD, the response includes
|
|
15
|
+
requested_context_missing. An existing file can return zero literal matches.
|
|
16
|
+
Save the lookup JSON with shell redirection, then recheck the cited evidence
|
|
17
|
+
in the same Git worktree before reusing it in a handoff.
|
|
18
|
+
|
|
19
|
+
codeledger activate --task "Find the retry fallback" --query "Retry-After" > context.json
|
|
20
|
+
codeledger activate --check < context.json
|
|
21
|
+
|
|
22
|
+
The check fails if Git HEAD moved, the lookup differs, or there were no citations.
|
|
23
|
+
It validates committed Git citations only. It does not execute tests.
|
|
24
|
+
|
|
25
|
+
For npm MCP, configure Claude Code or Codex to run codeledger-mcp with
|
|
26
|
+
arguments --repo /absolute/path/to/worktree. The equivalent explicit command
|
|
27
|
+
is codeledger mcp start --repo /absolute/path/to/worktree. For a ZIP
|
|
28
|
+
installation, put the absolute CJS path after node and before mcp start.
|
|
29
|
+
The get_activation_payload tool takes task, query and an optional file. Authorize the host to
|
|
30
|
+
receive excerpts from that worktree before configuring the server.
|
|
31
|
+
|
|
32
|
+
Use the host's regular discovery for uncommitted changes. The portable CLI's
|
|
33
|
+
scope is read-only committed context and local stdio MCP.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const cliFlags = ['--version', '-v', 'version', '--help', '-h', 'help'];
|
|
4
|
+
if (process.argv.length !== 3 || !cliFlags.includes(process.argv[2])) {
|
|
5
|
+
process.argv.splice(2, 0, 'mcp', 'start');
|
|
6
|
+
}
|
|
7
|
+
require('./codeledger-open.cjs');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* CodeLedger portable CLI */
|
|
3
|
+
"use strict";var v=require("node:util");var P=require("node:events");var N=require("node:child_process"),I=require("node:fs"),k=20,b=360,L=["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","cs","cpp","c","h","rb","php","swift","md"],C=[".*","node_modules","vendor","dist","build","coverage"],M=[...L.map(e=>`:(glob)**/*.${e}`),...C.map(e=>`:(exclude,glob)**/${e}/**`),":(exclude,glob)**/.*"],j=Object.fromEntries(Object.entries(process.env).filter(([e])=>!/^git_/i.test(e)));function y(e,o){return(0,N.spawnSync)("git",["--no-replace-objects","-c","protocol.allow=never","-c","core.fsmonitor=false",...o],{cwd:e,encoding:"utf8",env:{...j,GIT_ALLOW_PROTOCOL:"",GIT_NO_LAZY_FETCH:"1",GIT_TERMINAL_PROMPT:"0"},maxBuffer:64*1024,timeout:5e3,windowsHide:!0})}function m(e,o=!1){let t=y(e,["rev-parse",o?"--show-prefix":"--show-toplevel"]);if(t.status!==0)throw new Error("Choose a local Git worktree with Git on PATH.");let r=t.stdout.replace(/\r?\n$/,"");if(o&&r!=="")throw new Error("--repo must point to the root of the intended Git worktree.");return I.realpathSync.native(o?e:r)}function S(e){let o=y(e,["rev-parse","--verify","HEAD^{commit}"]),t=o.stdout?.trim();if(o.status!==0||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(t))throw new Error("The selected worktree needs a committed HEAD.");return t}function G(e,o){let t=[],r=o+":",n=/([^\0]+)\0([1-9]\d*)\0([^\n]*)\n/gy;for(;n.lastIndex<e.length&&t.length<=k;){let i=n.exec(e);if(!i||!i[1].startsWith(r)||i[1].includes("\uFFFD"))throw new Error("Unsupported Git match format.");let a=i[3].replace(/\r$/,"");t.push({path:i[1].slice(r.length),line:Number(i[2]),excerpt:a.slice(0,b),excerpt_truncated:a.length>b})}return t}function V(e){if(e===void 0)return;if(typeof e!="string"||e.length>512||/[\\:\x00-\x1f\x7f]/.test(e))throw new Error("Choose a supported file path relative to the worktree root.");let o=e.split("/"),t=o.pop();if(o.some(r=>!r||r.startsWith(".")||C.includes(r))||t.startsWith(".")||!L.some(r=>t.endsWith("."+r)))throw new Error("Choose a supported file path relative to the worktree root.");return e}function H(e,o,t){let r=y(e,["ls-tree","-z","--full-tree",o,"--",":(literal)"+t]);if(r.status!==0)throw new Error("Could not check the requested file in committed HEAD.");let n=r.stdout.indexOf(" ");return/^100(?:644|755) blob [a-f0-9]{40,64}$/.test(r.stdout.slice(0,n))&&r.stdout.slice(n+1)===t+"\0"}function g(e,o,t,r){if(typeof o!="string"||!o.trim()||o.length>1e3||typeof t!="string"||t.trim().length<3||t.length>100||/[\x00-\x1f\x7f]/.test(t))throw new Error("Provide a task of 1\u20131000 characters and a literal search term of 3\u2013100 characters.");if(m(e,!0)!==e)throw new Error("The selected worktree changed. Reconnect to it.");let n=S(e),i=V(r),a=i!==void 0&&!H(e,n,i),s=[];if(!a){let l=y(e,["grep","--full-name","--no-recurse-submodules","--no-textconv","--no-color","--no-column","--threads=1","-IzFn","-m","21","-e",t.trim(),n,"--",...i===void 0?M:[":(literal)"+i]]);if(l.error||l.status!==0&&l.status!==1)throw new Error("Git search failed or exceeded its limit. Try a more specific literal.");s=G(l.stdout,n)}if(S(e)!==n)throw new Error("Git HEAD moved during lookup. Run activation again.");return{source_revision:n,source_scope:"committed HEAD in the selected worktree",selection:"literal Git search",status:s.length>k?"truncated":s.length>0?"matched":"no_matches",query:t.trim(),matches:s.slice(0,k),...i!==void 0&&{requested_file:i,warnings:a?[{code:"requested_context_missing",path:i,reason:"not_a_committed_file"}]:[]},transaction_id:null,session_id:null,context_status:"stateless open activation"}}var F=new Set(["bundle","ensure-session"]),K=new Set(["help","--help","-h","version","--version","-v","init","doctor","vendor","validate","features","upgrade","update","license","enable","about","stats","setup-github-action","commands","capabilities","activate","mcp",...F]),E="get_activation_payload";var R=require("node:module"),A=require("node:url"),J={};function B(){return"0.10.87"}var w=B();var T=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],q={name:E,description:"Find a literal symbol or phrase in committed source, tests and docs for this task. Returns Git revision, path, line and matching text. Optionally name one repository-relative file to restrict the search and report when it is missing. Search the working tree separately for uncommitted changes.",inputSchema:{type:"object",properties:{task:{type:"string",minLength:1,maxLength:1e3},query:{type:"string",minLength:3,maxLength:100},file:{type:"string",minLength:1,maxLength:512}},required:["task","query"],additionalProperties:!1},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};function O(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function D(e){let o=m(e,!0),t=!1,r=!1;async function n(l,c){process.stdout.write(JSON.stringify({jsonrpc:"2.0",id:l,...c})+`
|
|
4
|
+
`)||await(0,P.once)(process.stdout,"drain")}async function i(l){let c;try{c=O(JSON.parse(l))}catch{await n(null,{error:{code:-32700,message:"Invalid JSON"}});return}let{id:f,method:p}=c;if(c.jsonrpc!=="2.0"||typeof p!="string"||f!==void 0&&typeof f!="string"&&!Number.isSafeInteger(f)){await n(null,{error:{code:-32600,message:"Invalid request"}});return}if(f===void 0){p==="notifications/initialized"&&t&&(r=!0);return}let u=f,h=O(c.params);if(p==="initialize"&&!t&&typeof h.protocolVersion=="string"){t=!0;let d=T.includes(h.protocolVersion)?h.protocolVersion:T[0];await n(u,{result:{protocolVersion:d,capabilities:{tools:{}},serverInfo:{name:"codeledger-open",version:w}}})}else if(p==="ping")await n(u,{result:{}});else if(!r)await n(u,{error:{code:-32600,message:"Initialize the CodeLedger MCP session first"}});else if(p==="tools/list")await n(u,{result:{tools:[q]}});else if(p==="tools/call"){if(h.name!==q.name){await n(u,{error:{code:-32602,message:"Unknown CodeLedger tool"}});return}try{let d=O(h.arguments);if(Object.keys(d).some(x=>x!=="task"&&x!=="query"&&x!=="file"))throw new Error("Only task, query and file are accepted.");let _=g(o,d.task,d.query,d.file);await n(u,{result:{content:[{type:"text",text:JSON.stringify(_)}],structuredContent:_}})}catch(d){let _=d instanceof Error?d.message:"CodeLedger lookup failed";await n(u,{result:{isError:!0,content:[{type:"text",text:_}]}})}}else await n(u,{error:{code:-32601,message:"Method not supported"}})}let a=16*1024,s=Buffer.alloc(0);for await(let l of process.stdin){s=Buffer.concat([s,l]);let c;for(;(c=s.indexOf(10))!==-1;){if(c>a)throw new Error("MCP message exceeded 16 KiB.");await i(s.subarray(0,c).toString("utf8")),s=s.subarray(c+1)}if(s.length>a)throw new Error("MCP message exceeded 16 KiB.")}}var U=["CodeLedger portable CLI",' codeledger activate --task "<question>" --query "<literal>" [--repo <worktree-root>] [--file <relative-path>]'," codeledger activate --check [--repo <worktree-root>] < saved-context.json"," codeledger mcp start --repo <worktree-root> [--profile core]"," codeledger capabilities --json"," codeledger --version"].join(`
|
|
5
|
+
`);async function $(e){if(process.stdin.isTTY)throw new Error("Pass saved activation JSON on stdin.");let o=[],t=0;for await(let a of process.stdin){if(t+=a.length,t>512*1024)throw new Error("Saved activation exceeds 512 KiB.");o.push(a)}let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(Buffer.concat(o)))}catch{throw new Error("Expected valid UTF-8 activation JSON.")}if(typeof r?.source_revision!="string"||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(r.source_revision)||typeof r.query!="string"||!Array.isArray(r.matches))throw new Error("Expected the saved output from codeledger activate.");let n=g(e,"Recheck saved committed Git citations",r.query,r.requested_file),i="verified";r.source_revision!==n.source_revision?i="stale":(0,v.isDeepStrictEqual)(r,n)?n.matches.length===0&&(i="not_evaluable"):i="mismatch",console.log(JSON.stringify({status:i,scope:"saved committed Git citations",saved_revision:r.source_revision,current_revision:n.source_revision,verified_citations:i==="verified"?n.matches.length:0},null,2)),i!=="verified"&&(process.exitCode=1)}async function z([e,...o]){if(!e||["help","--help","-h"].includes(e)||o.includes("--help")){console.log(U);return}if(["version","--version","-v"].includes(e)&&o.length===0){console.log(`codeledger v${w}`);return}if(e==="capabilities"&&o.length===1&&o[0]==="--json"){console.log(JSON.stringify({schema:"codeledger/capabilities/v1",runtime_version:w,distribution:"open",commands:["activate","capabilities","help","mcp","version"],activation_options:["lookup","check_saved_context"],mcp:{transports:["stdio"],default_profile:"core",profiles:{core:[E]}}}));return}if(e==="activate"){let{values:t}=(0,v.parseArgs)({args:o,options:{repo:{type:"string"},task:{type:"string"},query:{type:"string"},file:{type:"string"},check:{type:"boolean"}}}),r=m(t.repo??process.cwd(),t.repo!==void 0);if(t.check){if(t.task!==void 0||t.query!==void 0||t.file!==void 0)throw new Error("--check replays the saved query; supply only --repo when needed.");await $(r);return}console.log(JSON.stringify(g(r,t.task,t.query,t.file),null,2));return}if(e==="mcp"&&o[0]==="start"){let{values:t}=(0,v.parseArgs)({args:o.slice(1),options:{repo:{type:"string"},profile:{type:"string",default:"core"}}});if(!t.repo||t.profile!=="core")throw new Error("Supply --repo <worktree-root> and the core profile.");await D(t.repo);return}throw new Error("Unsupported portable command. Run codeledger --help.")}z(process.argv.slice(2)).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeledger/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.87",
|
|
4
|
+
"description": "CodeLedger portable Git context and MCP CLI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20"
|
|
8
|
+
},
|
|
4
9
|
"bin": {
|
|
5
|
-
"codeledger": "codeledger-
|
|
10
|
+
"codeledger": "codeledger-open.cjs",
|
|
11
|
+
"codeledger-mcp": "codeledger-mcp.cjs"
|
|
6
12
|
},
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"codeledger
|
|
10
|
-
],
|
|
11
|
-
"engines": {
|
|
12
|
-
"node": ">=22"
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/codeledgerECF/codeledger.git"
|
|
13
16
|
}
|
|
14
17
|
}
|