@fmdzc/cli-ai 3.2.3 → 3.2.4
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 +1 -1
- package/dist/cli.js +18 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,24 @@
|
|
|
5
5
|
// Saves ~200-400ms startup time and reduces runtime overhead
|
|
6
6
|
process.env.NODE_ENV = 'production';
|
|
7
7
|
|
|
8
|
+
// ── Node.js version gate ────────────────────────────────────────────────
|
|
9
|
+
// Runs before any imports or modern API usage so the error message is
|
|
10
|
+
// always reachable. Uses only APIs available since Node 0.x (process.versions,
|
|
11
|
+
// parseInt, console, process.exit) so it works on ANY Node version that
|
|
12
|
+
// can parse ESM (>= 12). Cross-platform — no OS-specific code.
|
|
13
|
+
const MIN_NODE_MAJOR = 20;
|
|
14
|
+
const nodeVersion = process.versions.node;
|
|
15
|
+
const nodeMajor = parseInt(nodeVersion.split('.')[0], 10);
|
|
16
|
+
if (Number.isNaN(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {
|
|
17
|
+
console.error(
|
|
18
|
+
'\n CLI AI requires Node.js >= ' + MIN_NODE_MAJOR + '.0.0' +
|
|
19
|
+
'\n Current version: ' + (nodeVersion || 'unknown') +
|
|
20
|
+
'\n' +
|
|
21
|
+
'\n Install the latest LTS: https://nodejs.org\n',
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
// Fast-path: handle --help and --version before loading ANY dependencies
|
|
9
27
|
// These flags should respond instantly, not after 60-120s of import resolution
|
|
10
28
|
const args = process.argv.slice(2);
|
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ Use the following sections (omit any that have no content):
|
|
|
53
53
|
Output only the summary. Ignore any unanswered questions in the conversation.`;async function bL(e,t,n){if(e.length<3)return{summary:"",originalMessageCount:e.length};let r=[...e,{role:"user",content:pae}],o=await t.sendWithTools(r,[],{maxTokens:4096,signal:n});return{summary:mae(o),originalMessageCount:e.length}}function yL(e,t){let n=[],r=e.find(o=>o.role==="system");return r&&n.push(r),n.push({role:"user",content:`[Conversation compacted \u2014 summary of prior conversation follows]
|
|
54
54
|
|
|
55
55
|
${t}`}),n.push({role:"assistant",content:"Understood. I have the context from the previous conversation. How can I help you continue?"}),n}function mae(e){if(e!==null&&typeof e=="object"){let t=e;if(Array.isArray(t.content)){let r=t.content.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text);if(r.length>0)return r.join(`
|
|
56
|
-
`)}if(Array.isArray(t.choices)){let r=t.choices[0];if(r){let o=r.message;if(o&&typeof o.content=="string")return o.content}}}return String(e)}var Ac="3.2.
|
|
56
|
+
`)}if(Array.isArray(t.choices)){let r=t.choices[0];if(r){let o=r.message;if(o&&typeof o.content=="string")return o.content}}}return String(e)}var Ac="3.2.4",xu="CLI AI",RL="cli-ai";var KE=".cli_ai_assistant",Lo=["anthropic","openrouter","openai"],NL="anthropic",Nr={anthropic:{name:"Anthropic",envVar:"ANTHROPIC_API_KEY",keyringAccount:"anthropic",keyPrefix:"sk-ant-",defaultModel:"claude-sonnet-4-5"},openrouter:{name:"OpenRouter",envVar:"OPENROUTER_API_KEY",keyringAccount:"openrouter",keyPrefix:"sk-or-",defaultModel:"anthropic/claude-sonnet-4.5"},openai:{name:"OpenAI",envVar:"OPENAI_API_KEY",keyringAccount:"openai",keyPrefix:"sk-",defaultModel:"gpt-5.2"}},Aae=Nr[NL].defaultModel,OL={provider:NL,model:Aae,maxHistoryEntries:5,maxOutputLines:10,maxAlternatives:3,contextEnabled:!0},DL=500,vL=10,xL=["rm -rf","sudo rm","chmod 777","mkfs","dd if=","> /dev/","format","del /f","rmdir /s","DROP TABLE","DELETE FROM","--no-preserve-root",":(){:|:&};:","| sh","| bash","curl | bash","wget | bash","eval","sudo su","passwd","chown -R","> /etc/","fdisk","wipefs","shred"],BL=["rm ","mv ","cp ","sudo ","npm install","pnpm install","yarn add","pip install","brew install","apt install","apt-get install","pacman -S","chmod ","chown ","git push","git reset","git rebase","docker ","kubectl ","systemctl ","service ","kill ","pkill "];var _c=500,Fa={maxAttempts:3,baseDelayMs:1e3,maxDelayMs:5e3};var VE=25;var ML=1e5,JE=3;var Zb=50,wL=100,Xb=200;function _ae(e){let t=e.toLowerCase();for(let n of xL)if(t.includes(n.toLowerCase()))return"high";for(let n of BL)if(t.includes(n.toLowerCase()))return"medium";return"low"}function ey(e,t){let n=_ae(t),r={low:0,medium:1,high:2};return r[e]>=r[n]?e:n}function Op(e){return`You are a CLI command generator for ${e}.
|
|
57
57
|
You translate natural language requests into shell commands.
|
|
58
58
|
|
|
59
59
|
IMPORTANT: Output ONLY valid JSON, no markdown, no explanation text.
|