@dirgha/code 1.2.0 → 1.2.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.
- package/README.md +18 -17
- package/dist/dirgha.mjs +2 -2
- package/dist_v2/cli/flags.d.ts +5 -0
- package/dist_v2/cli/flags.js +21 -0
- package/dist_v2/providers/nvidia.js +3 -1
- package/dist_v2/tui/renderer.js +45 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dirgha Code
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**AI coding agent for your terminal. Your keys, your machine, any model.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@dirgha/code)
|
|
6
6
|
[](./LICENSE)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
```
|
|
13
|
-
◈ Dirgha Code · dirgha.ai ·
|
|
13
|
+
◈ Dirgha Code · dirgha.ai · 1.2.0 · nvidia/minimax-m2.7
|
|
14
14
|
──────────────────────────────────────────────────────────
|
|
15
15
|
❯ dirgha fleet launch "migrate auth to JWT + add rate limiter"
|
|
16
16
|
∇ decomposing goal into parallel streams…
|
|
@@ -89,9 +89,9 @@ Every command supports `--json` — parseable envelope with `data`, `text`,
|
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
## What's new in
|
|
92
|
+
## What's new in 1.2.0 — `fleet`
|
|
93
93
|
|
|
94
|
-
The headline feature of
|
|
94
|
+
The headline feature of 1.2.0 is **parallel multi-agent execution in git
|
|
95
95
|
worktrees**. One command decomposes a goal into independent streams,
|
|
96
96
|
spawns N agents concurrently, and lets you review their diffs before
|
|
97
97
|
anything touches your working tree.
|
|
@@ -139,7 +139,7 @@ You get the frontier tooling without the surrender.
|
|
|
139
139
|
│ ▼ ▼ │
|
|
140
140
|
│ ┌──────────────┐ pending-messages ┌───────────────┐ │
|
|
141
141
|
│ │ providers/ │◀ ─ mid-turn inject ─ │ tool exec │ │
|
|
142
|
-
│ │ dispatch │ │
|
|
142
|
+
│ │ dispatch │ │ 11 tools │ │
|
|
143
143
|
│ └──────┬───────┘ └───────┬──────┘ │
|
|
144
144
|
│ │ │ │
|
|
145
145
|
│ ▼ 429/502/timeout → next hop ▼ │
|
|
@@ -563,16 +563,17 @@ output to `dist/dirgha.mjs` (~7.3 MB minified).
|
|
|
563
563
|
|
|
564
564
|
## Sister projects in the Dirgha OS
|
|
565
565
|
|
|
566
|
-
This repo is one of
|
|
566
|
+
This repo is one of several products under the [Dirgha AI OS](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS) umbrella. Each repo stands on its own; together they compose a full stack for builders.
|
|
567
567
|
|
|
568
568
|
| Repo | What it does | License |
|
|
569
569
|
|---|---|---|
|
|
570
|
-
| [`
|
|
571
|
-
| [`writer-studio`](https://github.com/
|
|
572
|
-
| [`
|
|
573
|
-
| [`
|
|
570
|
+
| [`Rama-I-Dirgha-AI-OS`](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS) | Vision & roadmap for our agentic, sovereign AI operating system. | Apache-2.0 |
|
|
571
|
+
| [`writer-studio`](https://github.com/Dirgha-AI/writer-studio) | Long-form writing studio — science, fiction, screenplays, research. | Apache-2.0 |
|
|
572
|
+
| [`creator-studio`](https://github.com/Dirgha-AI/creator-studio) | Creator workspace — agents for production, posting, monetization. | Apache-2.0 |
|
|
573
|
+
| [`abundance-protocol`](https://github.com/Dirgha-AI/abundance-protocol) | Decentralized compute and labor network. Rent GPUs, run agents, settle on Bitcoin. | Apache-2.0 |
|
|
574
|
+
| [`arniko`](https://github.com/Dirgha-AI/arniko) | AI security scanner. Every tool, one unified report. | Apache-2.0 |
|
|
574
575
|
|
|
575
|
-
Visit the umbrella org at [github.com/
|
|
576
|
+
Visit the umbrella org at [github.com/Dirgha-AI](https://github.com/Dirgha-AI) or the product site at [dirgha.ai](https://dirgha.ai).
|
|
576
577
|
|
|
577
578
|
## License
|
|
578
579
|
|
|
@@ -659,12 +660,12 @@ Released under **FSL-1.1-MIT** · Copyright © 2026 Dirgha LLC · All third-part
|
|
|
659
660
|
|
|
660
661
|
| Repo | What it does |
|
|
661
662
|
|---|---|
|
|
662
|
-
| [Rama-I-Dirgha-AI-OS](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS) | Vision
|
|
663
|
-
| [
|
|
664
|
-
| [
|
|
665
|
-
| [
|
|
666
|
-
| [
|
|
667
|
-
| [
|
|
663
|
+
| [Rama-I-Dirgha-AI-OS](https://github.com/Dirgha-AI/Rama-I-Dirgha-AI-OS) | Vision & roadmap for our agentic, sovereign AI operating system |
|
|
664
|
+
| [dirgha-code](https://github.com/Dirgha-AI/dirgha-code) | AI coding agent for your terminal |
|
|
665
|
+
| [writer-studio](https://github.com/Dirgha-AI/writer-studio) | Long-form writing studio — science, fiction, screenplays, research |
|
|
666
|
+
| [creator-studio](https://github.com/Dirgha-AI/creator-studio) | Creator workspace — agents for production, posting, monetization |
|
|
667
|
+
| [abundance-protocol](https://github.com/Dirgha-AI/abundance-protocol) | Decentralized compute and labor network |
|
|
668
|
+
| [arniko](https://github.com/Dirgha-AI/arniko) | AI security scanner — every tool, one unified report |
|
|
668
669
|
| [.github](https://github.com/Dirgha-AI/.github) | Org profile and community configuration |
|
|
669
670
|
|
|
670
671
|
- **Live platform:** [dirgha.ai](https://dirgha.ai) — chat, IDE, writer, research, library, marketplace, creator, education, manufacturing
|
package/dist/dirgha.mjs
CHANGED
|
@@ -1920,7 +1920,7 @@ ${Cte(o.content)}`).join(`
|
|
|
1920
1920
|
${s}
|
|
1921
1921
|
`,"utf8")}console.log(p.green(` \u2713 Exported (${n}) \u2192 ${i}`))});function Cte(t){if(typeof t=="string"){try{let e=JSON.parse(t);if(Array.isArray(e))return e.filter(n=>n?.type==="text").map(n=>n.text??"").join(`
|
|
1922
1922
|
`)||t}catch{}return t}return Array.isArray(t)?t.filter(e=>e?.type==="text").map(e=>e.text??"").join(`
|
|
1923
|
-
`):JSON.stringify(t)}var TPe=CPe(import.meta.url);function IPe(){let t=[eT.join(process.cwd(),"node_modules","playwright-core"),eT.join(process.cwd(),"node_modules","playwright"),"/usr/lib/node_modules/@playwright/mcp/node_modules/playwright-core","/usr/local/lib/node_modules/playwright-core"];for(let e of t)try{return TPe(e)}catch{}return null}function xPe(t){let e=["/root/.cache/ms-playwright/chromium-1217/chrome-linux64/chrome","/root/.cache/ms-playwright/chromium-1216/chrome-linux64/chrome","/usr/bin/chromium-browser","/usr/bin/chromium","/usr/bin/google-chrome"];try{let n=t.chromium.executablePath?.();if(n&&kf.existsSync(n))return n}catch{}for(let n of e)if(kf.existsSync(n))return n;return null}ce();To();import UN from"path";import wPe from"os";import nT from"fs";var xte=18,lm=52,vPe=`\u250C${"\u2500".repeat(lm)}\u2510`,DPe=`\u2514${"\u2500".repeat(lm)}\u2518`,RPe=`\u251C${"\u2500".repeat(lm)}\u2524`;function pa(t,e,n){let r=e==="ok"?p.green("\u2713"):e==="warn"?p.yellow("\u26A0"):p.red("\u2717"),i=e==="ok"?p.green:e==="warn"?p.yellow:p.red,a=t.padEnd(28),s=n?p.dim(n.slice(0,lm-32)):"";console.log(`\u2502 ${r} ${i(a)}${s.padEnd(lm-32-s.replace(/\x1b\[[0-9;]*m/g,"").length+s.replace(/\x1b\[[0-9;]*m/g,"").length)} \u2502`)}function tT(t){let e=` ${t} `,n=lm-e.length,r=Math.floor(n/2),i=n-r;console.log(`\u251C${"\u2500".repeat(r)}${e}${"\u2500".repeat(i)}\u2524`)}async function NPe(){parseInt(process.version.slice(1))>=xte?pa("Node.js","ok",process.version):pa("Node.js","fail",`${process.version} \u2014 need \u2265 v${xte}`)}async function kPe(){let{isConfigured:t}=await Promise.resolve().then(()=>(Jn(),Sp)),{getActiveProvider:e}=await Promise.resolve().then(()=>(xo(),K5));if(t()){let n=e();pa("API key","ok",n??"configured")}else pa("API key","fail","run: dirgha auth or dirgha keys set ...")}async function OPe(){let{isLoggedIn:t,readCredentials:e}=await Promise.resolve().then(()=>(Jn(),Sp));if(t()){let r=e()?.email??"logged in";pa("Dirgha account","ok",r)}else pa("Dirgha account","warn","not logged in (run: dirgha login)")}async function BPe(){try{let{getDB:t}=await Promise.resolve().then(()=>(Cn(),vd));t().prepare("SELECT 1").get(),pa("SQLite DB","ok","~/.dirgha/dirgha.db")}catch(t){pa("SQLite DB","fail",t?.message?.slice(0,40)??"error")}}async function MPe(){try{let t=await fetch("https://api.dirgha.ai/health",{signal:AbortSignal.timeout(5e3)});t.ok?pa("Gateway","ok","api.dirgha.ai"):pa("Gateway","warn",`status ${t.status}`)}catch{pa("Gateway","warn","offline (local mode still works)")}}async function LPe(){let t=UN.join(wPe.homedir(),".dirgha");try{nT.mkdirSync(t,{recursive:!0});let e=UN.join(t,".write-test");nT.writeFileSync(e,"ok"),nT.unlinkSync(e),pa("Write access","ok",t)}catch{pa("Write access","fail",`cannot write to ${t}`)}}async function PPe(){let t=["/usr/lib/node_modules/@playwright/mcp/node_modules/playwright-core","/usr/local/lib/node_modules/playwright-core",UN.join(process.cwd(),"node_modules","playwright-core")];for(let e of t)if(nT.existsSync(e)){pa("Playwright","ok","dirgha capture ready");return}pa("Playwright","warn","install: npm i -g @playwright/mcp")}var wte=new yr("doctor").description("Run system health checks (API key, DB, gateway, tools)").action(async()=>{console.log(),console.log(vPe);let t=" DIRGHA DOCTOR ",e=lm-t.length;console.log(`\u2502${" ".repeat(Math.floor(e/2))}${p.bold(t)}${" ".repeat(Math.ceil(e/2))}\u2502`),console.log(RPe),tT("Environment"),await NPe(),await LPe(),tT("Authentication"),await kPe(),await OPe(),tT("Services"),await BPe(),await MPe(),tT("Tools"),await PPe(),console.log(DPe),console.log(),console.log(p.dim(" Run `dirgha auth` to configure a provider key.")),console.log(p.dim(" Run `dirgha login` to connect your Dirgha account.")),console.log()});To();ce();ap();var EA="@dirgha/code",QN="1.2.
|
|
1923
|
+
`):JSON.stringify(t)}var TPe=CPe(import.meta.url);function IPe(){let t=[eT.join(process.cwd(),"node_modules","playwright-core"),eT.join(process.cwd(),"node_modules","playwright"),"/usr/lib/node_modules/@playwright/mcp/node_modules/playwright-core","/usr/local/lib/node_modules/playwright-core"];for(let e of t)try{return TPe(e)}catch{}return null}function xPe(t){let e=["/root/.cache/ms-playwright/chromium-1217/chrome-linux64/chrome","/root/.cache/ms-playwright/chromium-1216/chrome-linux64/chrome","/usr/bin/chromium-browser","/usr/bin/chromium","/usr/bin/google-chrome"];try{let n=t.chromium.executablePath?.();if(n&&kf.existsSync(n))return n}catch{}for(let n of e)if(kf.existsSync(n))return n;return null}ce();To();import UN from"path";import wPe from"os";import nT from"fs";var xte=18,lm=52,vPe=`\u250C${"\u2500".repeat(lm)}\u2510`,DPe=`\u2514${"\u2500".repeat(lm)}\u2518`,RPe=`\u251C${"\u2500".repeat(lm)}\u2524`;function pa(t,e,n){let r=e==="ok"?p.green("\u2713"):e==="warn"?p.yellow("\u26A0"):p.red("\u2717"),i=e==="ok"?p.green:e==="warn"?p.yellow:p.red,a=t.padEnd(28),s=n?p.dim(n.slice(0,lm-32)):"";console.log(`\u2502 ${r} ${i(a)}${s.padEnd(lm-32-s.replace(/\x1b\[[0-9;]*m/g,"").length+s.replace(/\x1b\[[0-9;]*m/g,"").length)} \u2502`)}function tT(t){let e=` ${t} `,n=lm-e.length,r=Math.floor(n/2),i=n-r;console.log(`\u251C${"\u2500".repeat(r)}${e}${"\u2500".repeat(i)}\u2524`)}async function NPe(){parseInt(process.version.slice(1))>=xte?pa("Node.js","ok",process.version):pa("Node.js","fail",`${process.version} \u2014 need \u2265 v${xte}`)}async function kPe(){let{isConfigured:t}=await Promise.resolve().then(()=>(Jn(),Sp)),{getActiveProvider:e}=await Promise.resolve().then(()=>(xo(),K5));if(t()){let n=e();pa("API key","ok",n??"configured")}else pa("API key","fail","run: dirgha auth or dirgha keys set ...")}async function OPe(){let{isLoggedIn:t,readCredentials:e}=await Promise.resolve().then(()=>(Jn(),Sp));if(t()){let r=e()?.email??"logged in";pa("Dirgha account","ok",r)}else pa("Dirgha account","warn","not logged in (run: dirgha login)")}async function BPe(){try{let{getDB:t}=await Promise.resolve().then(()=>(Cn(),vd));t().prepare("SELECT 1").get(),pa("SQLite DB","ok","~/.dirgha/dirgha.db")}catch(t){pa("SQLite DB","fail",t?.message?.slice(0,40)??"error")}}async function MPe(){try{let t=await fetch("https://api.dirgha.ai/health",{signal:AbortSignal.timeout(5e3)});t.ok?pa("Gateway","ok","api.dirgha.ai"):pa("Gateway","warn",`status ${t.status}`)}catch{pa("Gateway","warn","offline (local mode still works)")}}async function LPe(){let t=UN.join(wPe.homedir(),".dirgha");try{nT.mkdirSync(t,{recursive:!0});let e=UN.join(t,".write-test");nT.writeFileSync(e,"ok"),nT.unlinkSync(e),pa("Write access","ok",t)}catch{pa("Write access","fail",`cannot write to ${t}`)}}async function PPe(){let t=["/usr/lib/node_modules/@playwright/mcp/node_modules/playwright-core","/usr/local/lib/node_modules/playwright-core",UN.join(process.cwd(),"node_modules","playwright-core")];for(let e of t)if(nT.existsSync(e)){pa("Playwright","ok","dirgha capture ready");return}pa("Playwright","warn","install: npm i -g @playwright/mcp")}var wte=new yr("doctor").description("Run system health checks (API key, DB, gateway, tools)").action(async()=>{console.log(),console.log(vPe);let t=" DIRGHA DOCTOR ",e=lm-t.length;console.log(`\u2502${" ".repeat(Math.floor(e/2))}${p.bold(t)}${" ".repeat(Math.ceil(e/2))}\u2502`),console.log(RPe),tT("Environment"),await NPe(),await LPe(),tT("Authentication"),await kPe(),await OPe(),tT("Services"),await BPe(),await MPe(),tT("Tools"),await PPe(),console.log(DPe),console.log(),console.log(p.dim(" Run `dirgha auth` to configure a provider key.")),console.log(p.dim(" Run `dirgha login` to connect your Dirgha account.")),console.log()});To();ce();ap();var EA="@dirgha/code",QN="1.2.1",vte=new yr("update").description("Check for updates and install the latest @dirgha/code").option("--check","Only check for updates, do not install").action(async t=>{console.log(p.dim(`
|
|
1924
1924
|
Checking for updates\u2026`));let e;try{e=sr("npm",["view",EA,"version","--json"]).replace(/"/g,"").trim()}catch{console.error(p.red(` \u2717 Could not reach npm registry. Are you online?
|
|
1925
1925
|
`)),process.exit(1)}if(e===QN){console.log(p.green(` \u2713 Already on latest (${QN})
|
|
1926
1926
|
`));return}if(console.log(` Current: ${p.dim(QN)} \u2192 Latest: ${p.cyan(e)}`),t.check){console.log(p.dim(`
|
|
@@ -2097,7 +2097,7 @@ Goal: ${i}
|
|
|
2097
2097
|
`),exitCode:c.failCount>0&&c.successCount===0?1:0,command:"fleet launch",timestamp:new Date().toISOString(),meta:{durationMs:c.durationMs}})}),e.command("list").description("List all fleet worktrees attached to this repo").action(async()=>{let n=ou(),r=LT(n).filter(a=>a.branch.startsWith("fleet/"));if(r.length===0){Xs({text:"No fleet worktrees found.",exitCode:0,command:"fleet list",timestamp:new Date().toISOString()});return}let i=[p.bold(`Fleet worktrees (${r.length}):`),"",...r.map(a=>` ${p.cyan(a.branch.padEnd(50))} ${p.dim(a.path)}`)];Xs({data:{worktrees:r},text:i.join(`
|
|
2098
2098
|
`),exitCode:0,command:"fleet list",timestamp:new Date().toISOString()})}),e.command("merge <agentId>").description("Apply an agent's diff back to main (3-way, unstaged)").option("--message <msg>","Transient commit message").action(async(n,r)=>{let i=ou(),a=LT(i).filter(c=>c.branch.includes(`/${n}`));if(a.length===0){Xs({text:`No fleet worktree found for agent "${n}". Try: dirgha fleet list`,exitCode:1,command:"fleet merge",timestamp:new Date().toISOString()});return}let s=a[0],o=UT(s.path,i,r.message??`fleet: ${n}`);if(!o.success){Xs({data:{result:o},text:`\u2717 Apply-back failed: ${o.error}
|
|
2099
2099
|
${o.conflicts.length?`Conflicts: ${o.conflicts.join(", ")}`:""}`,exitCode:1,command:"fleet merge",timestamp:new Date().toISOString(),suggestions:["Resolve conflicts manually, then run `git add`/`git commit`"]});return}Xs({data:{result:o},text:`\u2713 Applied ${o.appliedFiles.length} file change${o.appliedFiles.length===1?"":"s"} from ${p.cyan(n)} \u2014 review with \`git diff\``,exitCode:0,command:"fleet merge",timestamp:new Date().toISOString()})}),e.command("triple <goal...>").description("TripleShot: 3 parallel variants (conservative/balanced/bold) + judge picks winner").option("-m, --model <id>","Model for agents + judge").option("-n, --max-turns <n>","Max turns per agent","15").option("--auto-merge","Auto-apply the winner to main as unstaged").action(async(n,r)=>{let i=n.join(" ").trim();if(!i){Xs({text:"Usage: dirgha fleet triple <goal>",exitCode:1,command:"fleet triple",timestamp:new Date().toISOString()});return}let a=r.model??ur();Mr.emitLaunch(`[TripleShot] ${i}`,[]);let{winner:s,reason:o,agents:c}=await kie(i,{model:a,maxTurns:parseInt(r.maxTurns,10),concurrency:3,autoMerge:!!r.autoMerge,onEvent:m=>{let f=Mr.current.map(h=>h.id===m.id?m:h);f.find(h=>h.id===m.id)||f.push(m),Mr.emitState(f)}});Mr.emitDone(c);let u=["",p.bold("TripleShot complete"),`Winner: ${p.green(s||"(none)")}`,`Reason: ${p.dim(o)}`,"",...c.map(Yk)];Xs({data:{winner:s,reason:o,agents:c},text:u.join(`
|
|
2100
|
-
`),exitCode:s?0:1,command:"fleet triple",timestamp:new Date().toISOString()})}),e.command("cleanup").description("Remove all fleet worktrees and their branches").option("-f, --force","Force removal even with uncommitted changes").action(async n=>{let r=ou(),i=LT(r).filter(s=>s.branch.startsWith("fleet/"));if(i.length===0){Xs({text:"No fleet worktrees to clean up.",exitCode:0,command:"fleet cleanup",timestamp:new Date().toISOString()});return}let a=0;for(let s of i)try{Gk(s.path,r,!!n.force),a++}catch{}Xs({data:{removed:a,total:i.length},text:`Removed ${a}/${i.length} fleet worktrees.`,exitCode:0,command:"fleet cleanup",timestamp:new Date().toISOString()})})}var kP="1.2.
|
|
2100
|
+
`),exitCode:s?0:1,command:"fleet triple",timestamp:new Date().toISOString()})}),e.command("cleanup").description("Remove all fleet worktrees and their branches").option("-f, --force","Force removal even with uncommitted changes").action(async n=>{let r=ou(),i=LT(r).filter(s=>s.branch.startsWith("fleet/"));if(i.length===0){Xs({text:"No fleet worktrees to clean up.",exitCode:0,command:"fleet cleanup",timestamp:new Date().toISOString()});return}let a=0;for(let s of i)try{Gk(s.path,r,!!n.force),a++}catch{}Xs({data:{removed:a,total:i.length},text:`Removed ${a}/${i.length} fleet worktrees.`,exitCode:0,command:"fleet cleanup",timestamp:new Date().toISOString()})})}var kP="1.2.1",Wg;function Uot(t){let e=Wbe.homedir();return t.split(e).join("$HOME").replace(/\/Users\/[^/\s]+\//g,"$HOME/").replace(/\/home\/[^/\s]+\//g,"$HOME/").replace(/C:\\Users\\[^\\s]+\\/g,"%USERPROFILE%\\")}function Jbe(t){try{let e=jbe.join(Wbe.homedir(),".dirgha");Kbe.mkdirSync(e,{recursive:!0});let n=new Date().toISOString(),r=t instanceof Error?`${t.message}
|
|
2101
2101
|
${t.stack??""}`:String(t),i=Uot(sl(r));Kbe.appendFileSync(jbe.join(e,"crash.log"),`
|
|
2102
2102
|
[${n}]
|
|
2103
2103
|
${i}
|
package/dist_v2/cli/flags.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Flag parser. Minimal but strict: supports --long, -s short flags,
|
|
3
3
|
* --key=value and --key value. Unknown flags are returned as positionals
|
|
4
4
|
* so callers can detect and reject them.
|
|
5
|
+
*
|
|
6
|
+
* Boolean flags (listed in BOOLEAN_FLAGS) never consume the next argv
|
|
7
|
+
* token. This matters for `dirgha --json "prompt"` — without the
|
|
8
|
+
* allowlist, "prompt" would be treated as the value of --json and
|
|
9
|
+
* the actual prompt would be lost.
|
|
5
10
|
*/
|
|
6
11
|
export interface ParsedFlags {
|
|
7
12
|
flags: Record<string, string | boolean>;
|
package/dist_v2/cli/flags.js
CHANGED
|
@@ -2,7 +2,20 @@
|
|
|
2
2
|
* Flag parser. Minimal but strict: supports --long, -s short flags,
|
|
3
3
|
* --key=value and --key value. Unknown flags are returned as positionals
|
|
4
4
|
* so callers can detect and reject them.
|
|
5
|
+
*
|
|
6
|
+
* Boolean flags (listed in BOOLEAN_FLAGS) never consume the next argv
|
|
7
|
+
* token. This matters for `dirgha --json "prompt"` — without the
|
|
8
|
+
* allowlist, "prompt" would be treated as the value of --json and
|
|
9
|
+
* the actual prompt would be lost.
|
|
5
10
|
*/
|
|
11
|
+
const BOOLEAN_FLAGS = new Set([
|
|
12
|
+
'json',
|
|
13
|
+
'print',
|
|
14
|
+
'help',
|
|
15
|
+
'h',
|
|
16
|
+
'force',
|
|
17
|
+
'verbose',
|
|
18
|
+
]);
|
|
6
19
|
export function parseFlags(argv) {
|
|
7
20
|
const flags = {};
|
|
8
21
|
const positionals = [];
|
|
@@ -19,6 +32,10 @@ export function parseFlags(argv) {
|
|
|
19
32
|
}
|
|
20
33
|
else {
|
|
21
34
|
const key = arg.slice(2);
|
|
35
|
+
if (BOOLEAN_FLAGS.has(key)) {
|
|
36
|
+
flags[key] = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
22
39
|
const next = argv[i + 1];
|
|
23
40
|
if (next !== undefined && !next.startsWith('-')) {
|
|
24
41
|
flags[key] = next;
|
|
@@ -31,6 +48,10 @@ export function parseFlags(argv) {
|
|
|
31
48
|
}
|
|
32
49
|
else if (arg.startsWith('-') && arg.length > 1) {
|
|
33
50
|
const key = arg.slice(1);
|
|
51
|
+
if (BOOLEAN_FLAGS.has(key)) {
|
|
52
|
+
flags[key] = true;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
34
55
|
const next = argv[i + 1];
|
|
35
56
|
if (next !== undefined && !next.startsWith('-')) {
|
|
36
57
|
flags[key] = next;
|
|
@@ -56,7 +56,9 @@ export class NvidiaProvider {
|
|
|
56
56
|
throw new ProviderError('NVIDIA_API_KEY is required', this.id);
|
|
57
57
|
}
|
|
58
58
|
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE).replace(/\/+$/, '');
|
|
59
|
-
|
|
59
|
+
// NVIDIA NIM tool-followup latency p99 occasionally exceeds 60s; 120s
|
|
60
|
+
// absorbs the variance without making genuine hangs invisible.
|
|
61
|
+
this.timeoutMs = config.timeoutMs ?? 120_000;
|
|
60
62
|
}
|
|
61
63
|
supportsTools(modelId) {
|
|
62
64
|
return TOOLS_SUPPORTED.has(modelId);
|
package/dist_v2/tui/renderer.js
CHANGED
|
@@ -41,13 +41,19 @@ export function renderStreamingEvents(opts = {}) {
|
|
|
41
41
|
write('\n');
|
|
42
42
|
}
|
|
43
43
|
return;
|
|
44
|
-
case 'tool_exec_start':
|
|
45
|
-
|
|
44
|
+
case 'tool_exec_start': {
|
|
45
|
+
const summary = summarizeToolInput(event.name, event.input);
|
|
46
|
+
const head = summary ? `\n→ ${event.name} · ${summary}` : `\n→ ${event.name}`;
|
|
47
|
+
write(style(theme.tool, head));
|
|
46
48
|
return;
|
|
49
|
+
}
|
|
47
50
|
case 'tool_exec_end': {
|
|
48
51
|
const token = event.isError ? theme.toolError : theme.tool;
|
|
49
52
|
const verdict = event.isError ? 'error' : 'done';
|
|
50
53
|
write(style(token, ` (${verdict}, ${event.durationMs}ms)\n`));
|
|
54
|
+
const preview = summarizeToolOutput(event.output, event.isError);
|
|
55
|
+
if (preview)
|
|
56
|
+
write(style(token, ` ⎿ ${preview}\n`));
|
|
51
57
|
return;
|
|
52
58
|
}
|
|
53
59
|
case 'error':
|
|
@@ -61,4 +67,41 @@ export function renderStreamingEvents(opts = {}) {
|
|
|
61
67
|
}
|
|
62
68
|
};
|
|
63
69
|
}
|
|
70
|
+
const PREVIEW_MAX = 72;
|
|
71
|
+
function summarizeToolInput(name, input) {
|
|
72
|
+
if (!input || typeof input !== 'object')
|
|
73
|
+
return '';
|
|
74
|
+
const obj = input;
|
|
75
|
+
// Pick the most informative field for known tools first.
|
|
76
|
+
const candidates = ['command', 'path', 'file_path', 'pattern', 'query', 'url', 'cmd'];
|
|
77
|
+
for (const key of candidates) {
|
|
78
|
+
const value = obj[key];
|
|
79
|
+
if (typeof value === 'string' && value.length > 0)
|
|
80
|
+
return truncate(value, PREVIEW_MAX);
|
|
81
|
+
}
|
|
82
|
+
// Fall back to the first string field.
|
|
83
|
+
for (const value of Object.values(obj)) {
|
|
84
|
+
if (typeof value === 'string' && value.length > 0)
|
|
85
|
+
return truncate(value, PREVIEW_MAX);
|
|
86
|
+
}
|
|
87
|
+
void name;
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
function summarizeToolOutput(output, isError) {
|
|
91
|
+
if (!output)
|
|
92
|
+
return '';
|
|
93
|
+
const text = output.trim();
|
|
94
|
+
if (text.length === 0)
|
|
95
|
+
return '';
|
|
96
|
+
if (isError)
|
|
97
|
+
return truncate(text.split('\n')[0] ?? text, PREVIEW_MAX);
|
|
98
|
+
const lines = text.split('\n');
|
|
99
|
+
const first = lines[0] ?? '';
|
|
100
|
+
if (lines.length <= 1)
|
|
101
|
+
return truncate(first, PREVIEW_MAX);
|
|
102
|
+
return `${truncate(first, PREVIEW_MAX - 12)} (+${lines.length - 1} lines)`;
|
|
103
|
+
}
|
|
104
|
+
function truncate(s, n) {
|
|
105
|
+
return s.length > n ? `${s.slice(0, n - 1)}…` : s;
|
|
106
|
+
}
|
|
64
107
|
//# sourceMappingURL=renderer.js.map
|