dirac-cli 0.2.8 β 0.2.9
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 +74 -58
- package/dist/cli.mjs +1 -1
- package/dist/lib.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
# Dirac
|
|
1
|
+
# Dirac - Accurate & Highly Token Efficient Open Source AI Agent
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img src="https://github.com/
|
|
4
|
+
<img src="https://github.com/dirac-run/dirac/blob/master/assets/media/diraccli.png?raw=true" width="70%" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
</td>
|
|
13
|
-
<td align="center">
|
|
14
|
-
<a href="https://discord.gg/dirac" target="_blank"><strong>Discord</strong></a>
|
|
15
|
-
</td>
|
|
16
|
-
<td align="center">
|
|
17
|
-
<a href="https://www.reddit.com/r/dirac/" target="_blank"><strong>r/dirac</strong></a>
|
|
18
|
-
</td>
|
|
19
|
-
<td align="center">
|
|
20
|
-
<a href="https://github.com/dirac-run/dirac/discussions/categories/feature-requests?discussions_q=is%3Aopen+category%3A%22Feature+Requests%22+sort%3Atop" target="_blank"><strong>Feature Requests</strong></a>
|
|
21
|
-
</td>
|
|
22
|
-
<td align="center">
|
|
23
|
-
<a href="https://docs.dirac.run/getting-started/for-new-coders" target="_blank"><strong>Getting Started</strong></a>
|
|
24
|
-
</td>
|
|
25
|
-
</tbody>
|
|
26
|
-
</table>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
Meet Dirac, an AI assistant that lives in your terminal.
|
|
30
|
-
|
|
31
|
-
Dirac can handle complex software development tasks step-by-step. With tools that let him create & edit files, explore large projects, use the browser, and execute terminal commands (after you grant permission), he can assist you in ways that go beyond code completion or tech support.
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm i -g dirac-cli
|
|
35
|
-
|
|
36
|
-
# cd into your project and run:
|
|
37
|
-
dirac
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
> Move your mouse around under the Dirac icon for a surprise!
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/dirac-run/dirac"><strong>GitHub</strong></a> |
|
|
9
|
+
<a href="https://www.npmjs.com/package/dirac-cli"><strong>NPM</strong></a> |
|
|
10
|
+
<a href="https://discord.gg/dirac"><strong>Discord</strong></a>
|
|
11
|
+
</p>
|
|
41
12
|
|
|
42
|
-
---
|
|
43
13
|
|
|
44
|
-
<img align="right" width="340" src="https://github.com/user-attachments/assets/ceb74224-08aa-4b8b-a3e7-b438ac3d160a">
|
|
45
14
|
|
|
46
|
-
|
|
15
|
+
It is a well studied phenomenon that any given model's reasoning ability degrades with the context length. If we can keep context tightly curated, we improve both accuracy and cost while making larger changes tractable in a single task.
|
|
47
16
|
|
|
48
|
-
Dirac
|
|
17
|
+
Dirac is an open-source coding agent built with this in mind. It reduces API costs by **64.8%** on average while producing better and faster work. Using hash-anchored parallel edits, AST manipulation, and a suite of advanced optimizations. Oh, and no MCP.
|
|
49
18
|
|
|
50
|
-
|
|
19
|
+
Our goal: Optimize for bang-for-the-buck on tooling with bare minimum prompting instead of going blindly minimalistic.
|
|
51
20
|
|
|
52
|
-
|
|
21
|
+
## π Evals
|
|
53
22
|
|
|
54
|
-
|
|
23
|
+
Dirac is benchmarked against other leading open-source agents on complex, real-world refactoring tasks. Dirac consistently achieves 100% accuracy at a fraction of the cost. These evals are run on public github repos and should be reproducible by anyone.
|
|
55
24
|
|
|
56
|
-
|
|
25
|
+
| Task (Repo) | Files* | Cline | Kilo | Ohmypi | Opencode | Pimono | Roo | **Dirac** |
|
|
26
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
27
|
+
| Task1 ([transformers](https://github.com/huggingface/transformers)) | 8 | π’ [$0.37] | π΄ [N/A] | π‘ [$0.24] | π’ [$0.20] | π’ [$0.34] | π’ [$0.49] | **π’ [$0.13]** |
|
|
28
|
+
| Task2 ([vscode](https://github.com/microsoft/vscode)) | 21 | π’ [$0.67] | π‘ [$0.78] | π’ [$0.63] | π’ [$0.40] | π’ [$0.48] | π‘ [$0.58] | **π’ [$0.23]** |
|
|
29
|
+
| Task3 ([vscode](https://github.com/microsoft/vscode)) | 12 | π‘ [$0.42] | π’ [$0.70] | π’ [$0.64] | π’ [$0.32] | π’ [$0.25] | π‘ [$0.45] | **π’ [$0.16]** |
|
|
30
|
+
| Task4 ([django](https://github.com/django/django)) | 14 | π’ [$0.36] | π’ [$0.42] | π‘ [$0.32] | π’ [$0.24] | π‘ [$0.24] | π’ [$0.17] | **π’ [$0.08]** |
|
|
31
|
+
| Task5 ([vscode](https://github.com/microsoft/vscode)) | 3 | π΄ [N/A] | π’ [$0.71] | π’ [$0.43] | π’ [$0.53] | π’ [$0.50] | π’ [$0.36] | **π’ [$0.17]** |
|
|
32
|
+
| Task6 ([transformers](https://github.com/huggingface/transformers)) | 25 | π’ [$0.87] | π‘ [$1.51] | π’ [$0.94] | π’ [$0.90] | π’ [$0.52] | π’ [$1.44] | **π’ [$0.34]** |
|
|
33
|
+
| Task7 ([vscode](https://github.com/microsoft/vscode)) | 13 | π‘ [$0.51] | π’ [$0.77] | π’ [$0.74] | π’ [$0.67] | π‘ [$0.45] | π’ [$1.05] | **π’ [$0.25]** |
|
|
34
|
+
| Task8 ([transformers](https://github.com/huggingface/transformers)) | 3 | π’ [$0.25] | π’ [$0.19] | π’ [$0.17] | π’ [$0.26] | π’ [$0.23] | π’ [$0.29] | **π’ [$0.12]** |
|
|
35
|
+
| **Total Correct** | | 5/8 | 5/8 | 6/8 | 8/8 | 6/8 | 6/8 | **8/8** |
|
|
36
|
+
| **Avg Cost** | | $0.49 | $0.73 | $0.51 | $0.44 | $0.38 | $0.60 | **$0.18** |
|
|
57
37
|
|
|
58
|
-
|
|
38
|
+
> π’ Success | π‘ Incomplete | π΄ Failure
|
|
39
|
+
> **Cost Comparison**: Dirac is **64.8% cheaper** than the competition (a **2.8x** cost reduction).
|
|
40
|
+
> \* Expected number of files to be modified/created to complete the task.
|
|
41
|
+
> See [evals/README.md](https://github.com/dirac-run/dirac/blob/master/evals/README.md) for detailed task descriptions and methodology.
|
|
59
42
|
|
|
60
|
-
|
|
43
|
+
## π Key Features
|
|
61
44
|
|
|
62
|
-
|
|
45
|
+
- **Hash-Anchored Edits**: Dirac uses stable line hashes to target edits with extreme precision, avoiding the "lost in translation" issues of traditional line-number based editing.
|
|
46
|
+

|
|
47
|
+
- **AST-Native Precision**: Built-in understanding of language syntax (TypeScript, Python, C++, etc.) allows Dirac to perform structural manipulations like function extraction or class refactoring with 100% accuracy.
|
|
48
|
+

|
|
49
|
+
- **Multi-File Batching**: Dirac can process and edit multiple files in a single LLM roundtrip, significantly reducing latency and API costs.
|
|
50
|
+

|
|
51
|
+
- **High-Bandwidth Context**: Optimized context curation keeps the agent lean and fast, ensuring the LLM always has the most relevant information without wasting tokens.
|
|
52
|
+
- **Autonomous Tool Use**: Dirac can read/write files, execute terminal commands, use a headless browser, and more - all while keeping you in control with an approval-based workflow.
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
## π¦ Installation
|
|
65
55
|
|
|
66
|
-
|
|
56
|
+
Install the Dirac CLI globally using npm:
|
|
67
57
|
|
|
68
|
-
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g dirac-cli
|
|
60
|
+
```
|
|
69
61
|
|
|
70
|
-
|
|
62
|
+
Alternatively, use our official installation script (macOS/Linux):
|
|
71
63
|
|
|
72
|
-
|
|
64
|
+
```bash
|
|
65
|
+
curl -fsSL https://raw.githubusercontent.com/dirac-run/dirac/master/scripts/install.sh | bash
|
|
66
|
+
```
|
|
73
67
|
|
|
68
|
+
## π Quick Start
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
1. **Authenticate**:
|
|
71
|
+
```bash
|
|
72
|
+
dirac auth
|
|
73
|
+
```
|
|
74
|
+
2. **Run your first task**:
|
|
75
|
+
```bash
|
|
76
|
+
dirac "Analyze the architecture of this project"
|
|
77
|
+
```
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
### Configuration (Environment Variables)
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
You can also provide API keys via environment variables to skip the `dirac auth` step:
|
|
81
|
+
You can provide API keys via environment variables to skip the `dirac auth` step. This is ideal for CI/CD or non-persistent environments:
|
|
81
82
|
|
|
82
83
|
- `ANTHROPIC_API_KEY`
|
|
83
84
|
- `OPENAI_API_KEY`
|
|
@@ -89,7 +90,22 @@ You can also provide API keys via environment variables to skip the `dirac auth`
|
|
|
89
90
|
- `HF_TOKEN` (HuggingFace)
|
|
90
91
|
- ... and others (see `src/shared/storage/env-config.ts` for the full list).
|
|
91
92
|
|
|
93
|
+
### Common Commands
|
|
94
|
+
|
|
95
|
+
- `dirac "prompt"`: Start an interactive task.
|
|
96
|
+
- `dirac -p "prompt"`: Run in **Plan Mode** to see the strategy before executing.
|
|
97
|
+
- `dirac -y "prompt"`: **Yolo Mode** (auto-approve all actions, great for simple fixes).
|
|
98
|
+
- `git diff | dirac "Review these changes"`: Pipe context directly into Dirac.
|
|
99
|
+
- `dirac history`: View and resume previous tasks.
|
|
100
|
+
|
|
101
|
+
## π License
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+
Dirac is **open source** and licensed under the [Apache License 2.0](LICENSE).
|
|
104
|
+
|
|
105
|
+
## π€ Acknowledgments
|
|
106
|
+
|
|
107
|
+
Dirac is a fork of the excellent [Cline](https://github.com/cline/cline) project. We are grateful to the Cline team and contributors for their foundational work.
|
|
108
|
+
|
|
109
|
+
---
|
|
94
110
|
|
|
95
|
-
[
|
|
111
|
+
Built with β€οΈ by [Max Trivedi](https://www.linkedin.com/in/max-trivedi-49993aab/) at [Dirac Delta Labs](https://dirac.run)
|
package/dist/cli.mjs
CHANGED
|
@@ -28,7 +28,7 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
28
28
|
`),this.outputHelp({error:!0}));let i=r||{},a=i.exitCode||1,o=i.code||"commander.error";this._exit(a,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Mg.env){let r=e.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,Mg.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new zic(this.options),r=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&r(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(a=>!r(a)).forEach(a=>{this.setOptionValueWithSource(a,i.implied[a],"implied")})})}missingArgument(e){let r=`error: missing required argument '${e}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(e){let r=`error: option '${e.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let r=`error: required option '${e.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,r){let i=n=>{let s=n.attributeName(),u=this.getOptionValue(s),d=this.options.find(p=>p.negate&&s===p.attributeName()),f=this.options.find(p=>!p.negate&&s===p.attributeName());return d&&(d.presetArg===void 0&&u===!1||d.presetArg!==void 0&&u===d.presetArg)?d:f||n},a=n=>{let s=i(n),u=s.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${s.envVar}'`:`option '${s.flags}'`},o=`error: ${a(e)} cannot be used with ${a(r)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let r="";if(e.startsWith("--")&&this._showSuggestionAfterError){let a=[],o=this;do{let n=o.createHelp().visibleOptions(o).filter(s=>s.long).map(s=>s.long);a=a.concat(n),o=o.parent}while(o&&!o._enablePositionalOptions);r=Xdi(e,a)}let i=`error: unknown option '${e}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,i=r===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${i} but got ${e.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],r="";if(this._showSuggestionAfterError){let a=[];this.createHelp().visibleCommands(this).forEach(o=>{a.push(o.name()),o.alias()&&a.push(o.alias())}),r=Xdi(e,a)}let i=`error: unknown command '${e}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(e,r,i){if(e===void 0)return this._version;this._version=e,r=r||"-V, --version",i=i||"output the version number";let a=this.createOption(r,i);return this._versionOptionName=a.attributeName(),this._registerOption(a),this.on("option:"+a.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
29
29
|
`),this._exit(0,"commander.version",e)}),this}description(e,r){return e===void 0&&r===void 0?this._description:(this._description=e,r&&(this._argsDescription=r),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),e===r._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let a=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${a}'`)}return r._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(r=>this.alias(r)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(i=>Vic(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=SQ.basename(e,SQ.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let r=this.createHelp();return r.helpWidth===void 0&&(r.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),r.formatHelp(this,r)}_getHelpContext(e){e=e||{};let r={error:!!e.error},i;return r.error?i=a=>this._outputConfiguration.writeErr(a):i=a=>this._outputConfiguration.writeOut(a),r.write=e.write||i,r.command=this,r}outputHelp(e){let r;typeof e=="function"&&(r=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let a=this.helpInformation(i);if(r&&(a=r(a),typeof a!="string"&&!Buffer.isBuffer(a)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(a),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,r){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",r=r??"display help for command",this._helpOption=this.createOption(e,r),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let r=Mg.exitCode||0;r===0&&e&&typeof e!="function"&&e.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(e,r){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
30
30
|
Expecting one of '${i.join("', '")}'`);let a=`${e}Help`;return this.on(a,o=>{let n;typeof r=="function"?n=r({error:o.error,command:o.command}):n=r,n&&o.write(`${n}
|
|
31
|
-
`)}),this}_outputHelpIfRequested(e){let r=this._getHelpOption();r&&e.find(a=>r.is(a))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Zdi(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let r,i="127.0.0.1",a="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?r=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=o[1],/^\d+$/.test(o[3])?a=o[3]:i=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=o[1],i=o[3],a=o[4]),r&&a!=="0"?`${r}=${i}:${parseInt(a)+1}`:e})}efi.Command=_1r});var afi=X(lD=>{"use strict";var{Argument:rfi}=npt(),{Command:T1r}=tfi(),{CommanderError:Kic,InvalidArgumentError:nfi}=iFe(),{Help:jic}=E1r(),{Option:ifi}=b1r();lD.program=new T1r;lD.createCommand=t=>new T1r(t);lD.createOption=(t,e)=>new ifi(t,e);lD.createArgument=(t,e)=>new rfi(t,e);lD.Command=T1r;lD.Option=ifi;lD.Argument=rfi;lD.Help=jic;lD.CommanderError=Kic;lD.InvalidArgumentError=nfi;lD.InvalidOptionArgumentError=nfi});var dD,aFe=$(()=>{dD="0.2.
|
|
31
|
+
`)}),this}_outputHelpIfRequested(e){let r=this._getHelpOption();r&&e.find(a=>r.is(a))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Zdi(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let r,i="127.0.0.1",a="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?r=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=o[1],/^\d+$/.test(o[3])?a=o[3]:i=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=o[1],i=o[3],a=o[4]),r&&a!=="0"?`${r}=${i}:${parseInt(a)+1}`:e})}efi.Command=_1r});var afi=X(lD=>{"use strict";var{Argument:rfi}=npt(),{Command:T1r}=tfi(),{CommanderError:Kic,InvalidArgumentError:nfi}=iFe(),{Help:jic}=E1r(),{Option:ifi}=b1r();lD.program=new T1r;lD.createCommand=t=>new T1r(t);lD.createOption=(t,e)=>new ifi(t,e);lD.createArgument=(t,e)=>new rfi(t,e);lD.Command=T1r;lD.Option=ifi;lD.Argument=rfi;lD.Help=jic;lD.CommanderError=Kic;lD.InvalidArgumentError=nfi;lD.InvalidOptionArgumentError=nfi});var dD,aFe=$(()=>{dD="0.2.9"});var R1r={};ni(R1r,{originalConsoleDebug:()=>lfi,originalConsoleError:()=>ipt,originalConsoleInfo:()=>cfi,originalConsoleLog:()=>xQ,originalConsoleWarn:()=>ufi,restoreConsole:()=>Yic,suppressConsoleUnlessVerbose:()=>w1r});function w1r(t=process.argv){t.includes("-v")||t.includes("--verbose")||(console.log=()=>{},console.warn=()=>{},console.error=()=>{},console.debug=()=>{},console.info=()=>{})}function Yic(){console.log=xQ,console.error=ipt,console.warn=ufi,console.info=cfi,console.debug=lfi}var xQ,ipt,ufi,cfi,lfi,N1e=$(()=>{"use strict";xQ=console.log.bind(console),ipt=console.error.bind(console),ufi=console.warn.bind(console),cfi=console.info.bind(console),lfi=console.debug.bind(console)});var D2={};ni(D2,{Spinner:()=>D1r,clearLine:()=>tac,colorize:()=>ES,cursorUp:()=>rac,formatMessage:()=>ffi,formatState:()=>eac,formatTimestamp:()=>dfi,print:()=>F1e,printError:()=>oFe,printInfo:()=>Qd,printSuccess:()=>nac,printWarning:()=>s3,promptConfirmation:()=>iac,promptUser:()=>hfi,separator:()=>B1r,setTerminalTitle:()=>apt,style:()=>hu,taskHeader:()=>pfi});function ES(t,...e){return e.join("")+t+OE.reset}function dfi(t){return new Date(t).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Jic(t){if(t.type==="ask")switch(t.ask){case"followup":return"\u2753";case"command":case"command_output":return"\u2699\uFE0F ";case"tool":return"\u{1F527}";case"completion_result":return"\u2705";case"api_req_failed":return"\u274C";case"resume_task":case"resume_completed_task":return"\u25B6\uFE0F ";case"browser_action_launch":return"\u{1F310}";default:return"\u2754"}switch(t.say){case"task":return"\u{1F4CB}";case"error":return"\u274C";case"text":return"\u{1F4AC}";case"reasoning":return"\u{1F9E0}";case"completion_result":return"\u2705";case"user_feedback":return"\u{1F464}";case"command":case"command_output":return"\u2699\uFE0F ";case"tool":return"\u{1F527}";case"browser_action":case"browser_action_launch":case"browser_action_result":return"\u{1F310}";case"api_req_started":case"api_req_finished":return"\u{1F504}";case"checkpoint_created":return"\u{1F4BE}";case"info":return"\u2139\uFE0F ";default:return" "}}function ffi(t,e=!1){let r=Jic(t),i=dfi(t.ts),a=[],o=`${hu.dim(i)} ${r}`;return t.type==="ask"?a.push(Xic(t,o,e)):a.push(Zic(t,o,e)),a.filter(Boolean).join(`
|
|
32
32
|
`)}function Xic(t,e,r){let i=t.ask;switch(i){case"followup":{let a=t.text||"";try{a=JSON.parse(t.text||"{}").question||a}catch{a=t.text||""}return`${e} ${hu.info("Question:")} ${a}`}case"command":return`${e} ${hu.command("Execute command?")} ${hu.code(t.text||"")}`;case"tool":return`${e} ${hu.tool("Use tool?")} ${t.text||""}`;case"completion_result":return`${e} ${hu.success("Task completed")} ${t.text?`- ${t.text}`:""}`;case"api_req_failed":return`${e} ${hu.error("API request failed")} ${t.text||""}`;case"resume_task":case"resume_completed_task":return`${e} ${hu.info("Resume task?")} ${t.text||""}`;case"browser_action_launch":return`${e} ${hu.info("Launch browser?")} ${t.text||""}`;case"plan_mode_respond":return`${e} ${hu.info("Plan mode response:")} ${t.text||""}`;default:return r?`${e} [ASK:${i}] ${t.text||""}`:""}}function Zic(t,e,r){let i=t.say;switch(i){case"task":return`${e} ${hu.task("Task:")} ${t.text||""}`;case"text":return`${e} ${hu.assistant(t.text||"")}`;case"reasoning":return`${e} ${hu.dim("Thinking:")} ${hu.italic(t.text||"")}`;case"error":return`${e} ${hu.error("Error:")} ${t.text||""}`;case"completion_result":return`${e} ${hu.success("\u2713 Completed:")} ${t.text||""}`;case"user_feedback":return`${e} ${hu.user("User:")} ${t.text||""}`;case"command":return`${e} ${hu.command("Command:")} ${hu.code(t.text||"")}`;case"command_output":let a=t.text||"",o=a.length>500?a.substring(0,500)+"...":a;return`${e} ${hu.dim("Output:")} ${o}`;case"tool":return`${e} ${hu.tool("Tool:")} ${t.text||""}`;case"browser_action":case"browser_action_launch":return`${e} ${hu.info("Browser:")} ${t.text||""}`;case"browser_action_result":return`${e} ${hu.dim("Browser result")} ${t.text?`- ${t.text.substring(0,100)}...`:""}`;case"api_req_started":{if(r)return`${e} ${hu.api("API request started")}`;try{let n=JSON.parse(t.text||"{}");if(n.cost!==void 0||n.tokensIn!==void 0){let s=n.cost!==void 0?`Cost: $${n.cost.toFixed(4)}`:"",u=n.tokensIn!==void 0?`Tokens: ${n.tokensIn.toLocaleString()} in, ${n.tokensOut.toLocaleString()} out`:"",d=n.cacheReadTokens!==void 0||n.cacheWriteTokens!==void 0?` (Cache: ${(n.cacheReadTokens||0).toLocaleString()} read, ${(n.cacheWriteTokens||0).toLocaleString()} write)`:"",f=n.contextWindow!==void 0?` | Context: ${n.contextUsagePercentage}% of ${(n.contextWindow/1e3).toFixed(0)}K`:"";return`${e} ${hu.api("API request finished")} ${hu.dim(`[${u}${d}${f} | ${s}]`)}`}}catch{return`${t.text||""}`}return""}case"api_req_finished":return r?`${e} ${hu.api("API request finished")}`:"";case"checkpoint_created":return`${e} ${hu.success("Checkpoint created")} ${t.text||""}`;case"info":return`${e} ${hu.info(t.text||"")}`;case"hook_status":return`${e} ${hu.dim("Hook:")} ${t.text||""}`;default:return r?`${e} [SAY:${i}] ${t.text||""}`:""}}function B1r(t="\u2500",e=60){return hu.dim(t.repeat(e))}function pfi(t,e){return[B1r("\u2550"),hu.bold(` Task: ${t}`),e?` ${hu.dim(e.substring(0,80))}${e.length>80?"...":""}`:"",B1r("\u2550")].filter(Boolean).join(`
|
|
33
33
|
`)}function eac(t,e=!1){let r=[];if(t.currentTaskItem&&r.push(pfi(t.currentTaskItem.id,t.currentTaskItem.task)),t.diracMessages&&t.diracMessages.length>0){let i=e?t.diracMessages:t.diracMessages.filter(a=>!0);for(let a of i){let o=ffi(a,e);o&&r.push(o)}}return r.join(`
|
|
34
34
|
`)}function tac(){process.stdout.write("\r\x1B[K")}function rac(t=1){process.stdout.write(`\x1B[${t}A`)}function F1e(t){xQ(t)}function oFe(t){ipt(hu.error(t))}function nac(t){xQ(hu.success(t))}function Qd(t){xQ(hu.info(t))}function s3(t){xQ(hu.warning(t))}async function hfi(t){let r=(await import("readline")).createInterface({input:process.stdin,output:process.stdout});return new Promise(i=>{r.question(hu.info(t)+" ",a=>{r.close(),i(a.trim())})})}async function iac(t){let e=await hfi(`${t} ${hu.dim("(y/n)")}`);return e.toLowerCase()==="y"||e.toLowerCase()==="yes"}function apt(t){if(process.stdout.isTTY){let r=t.length>80?t.slice(0,80)+"...":t;process.stdout.write(`\x1B]0;${r}\x07`)}}var OE,hu,D1r,V1=$(()=>{"use strict";N1e();OE={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m"};hu={bold:t=>ES(t,OE.bold),dim:t=>ES(t,OE.dim),italic:t=>ES(t,OE.italic),error:t=>ES(t,OE.red,OE.bold),warning:t=>ES(t,OE.yellow),success:t=>ES(t,OE.green),info:t=>ES(t,OE.cyan),task:t=>ES(t,OE.brightWhite,OE.bold),tool:t=>ES(t,OE.blue),command:t=>ES(t,OE.magenta),api:t=>ES(t,OE.brightBlack),user:t=>ES(t,OE.green),assistant:t=>ES(t,OE.cyan),path:t=>ES(t,OE.underline,OE.blue),code:t=>ES(t,OE.bgBlack,OE.brightWhite)};D1r=class{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];frameIndex=0;interval=null;message="";start(e){this.message=e,this.interval=setInterval(()=>{let r=this.frames[this.frameIndex];process.stdout.write(`\r${hu.info(r)} ${this.message}`),this.frameIndex=(this.frameIndex+1)%this.frames.length},80)}update(e){this.message=e}stop(e){this.interval&&(clearInterval(this.interval),this.interval=null),e?process.stdout.write(`\r${hu.success("\u2713")} ${e}
|
package/dist/lib.mjs
CHANGED
|
@@ -5843,7 +5843,7 @@ Speak in ${h}.`:"",{globalToggles:p,localToggles:A}=await aFt(this.controller,th
|
|
|
5843
5843
|
<div class="countdown">Feel free to close this window and continue in your ${r}</div>
|
|
5844
5844
|
</div>
|
|
5845
5845
|
</body>
|
|
5846
|
-
</html>`}var iar=class{};var aar=class extends iar{setOnReplyCallback(e){}async ensureCommentsViewDisabled(){}addReviewComment(e){}startStreamingComment(e,r,i,a,o,n){}appendToStreamingComment(e){}endStreamingComment(){}addReviewComments(e){}clearAllComments(){}clearCommentsForFile(e){}getThreadCount(){return 0}async closeDiffViews(){}dispose(){}};var oar=class extends Aee{RESOURCE_HOSTNAME="internal.resources";getWebviewUrl(e){let r=new URL(`https://${this.RESOURCE_HOSTNAME}/`);return r.pathname=e,r.toString()}getCspSource(){return`'self' https://${this.RESOURCE_HOSTNAME}`}isVisible(){return!0}};io();Or();var wLn="0.2.8";n0();Pc();ru();var Tnu=Pt(Hfe(),1);io();import*as Srt from"fs/promises";gv();Or();var sar=class extends Pee{connection;clientCapabilities;sessionIdResolver;constructor(e,r,i){super(),this.connection=e,this.clientCapabilities=r,this.sessionIdResolver=i}getSessionId(){let e=this.sessionIdResolver();if(!e)throw new Error("No active ACP session. Cannot perform file operation.");return e}canReadFile(){return this.clientCapabilities?.fs?.readTextFile===!0}canWriteFile(){return this.clientCapabilities?.fs?.writeTextFile===!0}async open(e,r){if(!this.canReadFile())return Le.debug("[ACPDiffViewProvider] Client does not support fs.readTextFile, falling back to local fs"),super.open(e,r);this.isEditing=!0;let i=await ih(),a=NA.resolveWorkspacePath(i,e,"ACPDiffViewProvider.open.absolutePath");this.absolutePath=typeof a=="string"?a:a.absolutePath,this.relPath=r?.displayPath??e;let o=this.editType==="modify";if(o){try{await In.workspace.saveOpenDocumentIfDirty({filePath:this.absolutePath})}catch{}try{Le.debug("[ACPDiffViewProvider] Reading file via ACP:",this.absolutePath);let u=await this.connection.readTextFile({sessionId:this.getSessionId(),path:this.absolutePath});this.originalContent=u.content,this.fileEncoding="utf8",Le.debug("[ACPDiffViewProvider] Read file successfully, length:",u.content.length)}catch(u){Le.debug("[ACPDiffViewProvider] ACP read failed, falling back to local fs:",u);let d=await Srt.readFile(this.absolutePath);this.fileEncoding=await phe(d),this.originalContent=Tnu.decode(d,this.fileEncoding)}}else this.originalContent="",this.fileEncoding="utf8";let n=await qEt(this.absolutePath);if(this.createdDirs=n,!o)if(this.canWriteFile())try{await this.connection.writeTextFile({sessionId:this.getSessionId(),path:this.absolutePath,content:""})}catch{await Srt.writeFile(this.absolutePath,"")}else await Srt.writeFile(this.absolutePath,"");let s=[];try{s=(await In.workspace.getDiagnostics({filePaths:[]})).fileDiagnostics}catch{s=[]}this.preDiagnostics=s,await this.openDiffEditor(),await this.scrollEditorToLine(0),this.streamedLines=[]}async scrollEditorToLine(e){}async openDiffEditor(){}async saveDocument(){if(!this.canWriteFile())return Le.debug("[ACPDiffViewProvider] Client does not support fs.writeTextFile, falling back to local fs"),super.saveDocument();let e=await this.getContent();if(!this.absolutePath||e===void 0)return!1;try{return Le.debug("[ACPDiffViewProvider] Writing file via ACP:",{path:this.absolutePath,contentLength:e.length}),await this.connection.writeTextFile({sessionId:this.getSessionId(),path:this.absolutePath,content:e}),Le.debug("[ACPDiffViewProvider] Write file successfully"),!0}catch(r){return Le.debug("[ACPDiffViewProvider] ACP write failed, falling back to local fs:",r),super.saveDocument()}}};Or();var RLn=class{async openDiff(e){return Le.debug("[ACPDiffServiceClient] openDiff called (stub)"),Kc.OpenDiffResponse.create({})}async getDocumentText(e){return Le.debug("[ACPDiffServiceClient] getDocumentText called (stub)",{diffId:e.diffId}),Kc.GetDocumentTextResponse.create({content:""})}async replaceText(e){return Le.debug("[ACPDiffServiceClient] replaceText called (stub)"),Kc.ReplaceTextResponse.create({})}async scrollDiff(e){return Le.debug("[ACPDiffServiceClient] scrollDiff called (stub)"),Kc.ScrollDiffResponse.create({})}async truncateDocument(e){return Le.debug("[ACPDiffServiceClient] truncateDocument called (stub)"),Kc.TruncateDocumentResponse.create({})}async saveDocument(e){return Le.debug("[ACPDiffServiceClient] saveDocument called (stub)"),Kc.SaveDocumentResponse.create({})}async closeAllDiffs(e){return Le.debug("[ACPDiffServiceClient] closeAllDiffs called (stub)"),Kc.CloseAllDiffsResponse.create({})}async openMultiFileDiff(e){return Le.debug("[ACPDiffServiceClient] openMultiFileDiff called (stub)"),Kc.OpenMultiFileDiffResponse.create({})}},BLn=class{version;constructor(e,r,i){this.version=i}async debugLog(e){return Le.debug(e.value),KM.Empty.create()}async clipboardWriteText(e){return Le.debug("[ACPEnvServiceClient] clipboardWriteText called (stub)"),KM.Empty.create()}async clipboardReadText(e){return Le.debug("[ACPEnvServiceClient] clipboardReadText called (stub)"),KM.String.create({value:""})}async getHostVersion(e){return Kc.GetHostVersionResponse.create({version:this.version,platform:"Dirac ACP Agent",diracType:"CLI"})}async getIdeRedirectUri(e){return Le.debug("[ACPEnvServiceClient] getIdeRedirectUri called (stub)"),KM.String.create({value:""})}async getTelemetrySettings(e){return Kc.GetTelemetrySettingsResponse.create({isEnabled:Kc.Setting.DISABLED})}subscribeToTelemetrySettings(e,r){return r.onResponse(Kc.TelemetrySettingsEvent.create({isEnabled:Kc.Setting.DISABLED})),()=>{}}async shutdown(e){return Le.debug("[ACPEnvServiceClient] shutdown called (stub)"),KM.Empty.create()}async openExternal(e){let r=e.value||"";if(r){Le.debug(`[ACPEnvServiceClient] openExternal: ${r}`);let{openUrlInBrowser:i}=await Promise.resolve().then(()=>(Rnu(),wnu));await i(r)}return KM.Empty.create()}},DLn=class{constructor(e,r){}async showTextDocument(e){return Le.debug("[ACPWindowServiceClient] showTextDocument called (stub)",{path:e.path}),Kc.TextEditorInfo.create({documentPath:e.path})}async showOpenDialogue(e){return Le.debug("[ACPWindowServiceClient] showOpenDialogue called (stub)"),Kc.SelectedResources.create({paths:[]})}async showMessage(e){return Le.debug("[ACPWindowServiceClient] showMessage called (stub)",{message:e.message,type:e.type}),Kc.SelectedResponse.create({})}async showInputBox(e){return Le.debug("[ACPWindowServiceClient] showInputBox called (stub)"),Kc.ShowInputBoxResponse.create({response:""})}async showSaveDialog(e){return Le.debug("[ACPWindowServiceClient] showSaveDialog called (stub)"),Kc.ShowSaveDialogResponse.create({selectedPath:""})}async openFile(e){return Le.debug("[ACPWindowServiceClient] openFile called (stub)",{filePath:e.filePath}),Kc.OpenFileResponse.create({})}async openSettings(e){return Le.debug("[ACPWindowServiceClient] openSettings called (stub)"),Kc.OpenSettingsResponse.create({})}async getOpenTabs(e){return Le.debug("[ACPWindowServiceClient] getOpenTabs called (stub)"),Kc.GetOpenTabsResponse.create({paths:[]})}async getVisibleTabs(e){return Le.debug("[ACPWindowServiceClient] getVisibleTabs called (stub)"),Kc.GetVisibleTabsResponse.create({paths:[]})}async getActiveEditor(e){return Le.debug("[ACPWindowServiceClient] getActiveEditor called (stub)"),Kc.GetActiveEditorResponse.create({})}},kLn=class{_clientCapabilities;cwdResolver;constructor(e,r,i){this._clientCapabilities=e,this.cwdResolver=i}getCwd(){return this.cwdResolver()??process.cwd()}async getWorkspacePaths(e){let r=this.getCwd();return Le.debug("[ACPWorkspaceServiceClient] getWorkspacePaths called",{cwd:r}),Kc.GetWorkspacePathsResponse.create({paths:[r]})}async saveOpenDocumentIfDirty(e){return Le.debug("[ACPWorkspaceServiceClient] saveOpenDocumentIfDirty called (stub)"),Kc.SaveOpenDocumentIfDirtyResponse.create({})}async getDiagnostics(e){return Le.debug("[ACPWorkspaceServiceClient] getDiagnostics called (stub)"),Kc.GetDiagnosticsResponse.create({fileDiagnostics:[]})}async openProblemsPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openProblemsPanel called (stub)"),Kc.OpenProblemsPanelResponse.create({})}async openInFileExplorerPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openInFileExplorerPanel called (stub)",{path:e.path}),Kc.OpenInFileExplorerPanelResponse.create({})}async openDiracSidebarPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openDiracSidebarPanel called (stub)"),Kc.OpenDiracSidebarPanelResponse.create({})}async openTerminalPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openTerminalPanel called (stub)"),Kc.OpenTerminalResponse.create({})}async executeCommandInTerminal(e){return Le.debug("[ACPWorkspaceServiceClient] executeCommandInTerminal called (stub)",{command:e.command,hasTerminalCapability:this._clientCapabilities?.terminal}),Kc.ExecuteCommandInTerminalResponse.create({})}async prepareDiagnostics(e){return Kc.PrepareDiagnosticsResponse.create({success:!0})}async openFolder(e){return Le.debug("[ACPWorkspaceServiceClient] openFolder called (stub)",{path:e.path}),Kc.OpenFolderResponse.create({success:!0})}},uar=class{workspaceClient;envClient;windowClient;diffClient;constructor(e,r,i,a){this.workspaceClient=new kLn(e,r,i),this.envClient=new BLn(e,r,a),this.windowClient=new DLn(e,r),this.diffClient=new RLn}};Or();import{EventEmitter as Jap}from"events";var MLn=class extends Jap{isHot=!1;waitForShellIntegration=!1;_unretrievedOutput="";_continued=!1;_completed=!1;_hotTimeout=null;_exitWaitTimeout=null;manager;terminalId;pollInterval=null;constructor(e,r){super(),this.manager=e,this.terminalId=r}continue(){this._continued=!0,this.cleanup(),this.emit("continue")}getUnretrievedOutput(){let e=this._unretrievedOutput;return this._unretrievedOutput="",e}async terminate(){this.cleanup(),await this.manager.kill(this.terminalId)}cleanup(){this.stopPolling(),this._hotTimeout&&(clearTimeout(this._hotTimeout),this._hotTimeout=null),this._exitWaitTimeout&&(clearTimeout(this._exitWaitTimeout),this._exitWaitTimeout=null)}stopPolling(){this.pollInterval&&(clearInterval(this.pollInterval),this.pollInterval=null)}run(e){let r="";this.pollInterval=setInterval(async()=>{if(this._continued||this._completed){this.stopPolling();return}try{let i=await this.manager.getOutput(this.terminalId);if(!i.success){this.stopPolling(),this.emit("error",new Error(i.error||"Failed to get output"));return}if(i.output.length>r.length){let a=i.output.slice(r.length);this._unretrievedOutput+=a,r=i.output,this.setHot();let o=a.split(`
|
|
5846
|
+
</html>`}var iar=class{};var aar=class extends iar{setOnReplyCallback(e){}async ensureCommentsViewDisabled(){}addReviewComment(e){}startStreamingComment(e,r,i,a,o,n){}appendToStreamingComment(e){}endStreamingComment(){}addReviewComments(e){}clearAllComments(){}clearCommentsForFile(e){}getThreadCount(){return 0}async closeDiffViews(){}dispose(){}};var oar=class extends Aee{RESOURCE_HOSTNAME="internal.resources";getWebviewUrl(e){let r=new URL(`https://${this.RESOURCE_HOSTNAME}/`);return r.pathname=e,r.toString()}getCspSource(){return`'self' https://${this.RESOURCE_HOSTNAME}`}isVisible(){return!0}};io();Or();var wLn="0.2.9";n0();Pc();ru();var Tnu=Pt(Hfe(),1);io();import*as Srt from"fs/promises";gv();Or();var sar=class extends Pee{connection;clientCapabilities;sessionIdResolver;constructor(e,r,i){super(),this.connection=e,this.clientCapabilities=r,this.sessionIdResolver=i}getSessionId(){let e=this.sessionIdResolver();if(!e)throw new Error("No active ACP session. Cannot perform file operation.");return e}canReadFile(){return this.clientCapabilities?.fs?.readTextFile===!0}canWriteFile(){return this.clientCapabilities?.fs?.writeTextFile===!0}async open(e,r){if(!this.canReadFile())return Le.debug("[ACPDiffViewProvider] Client does not support fs.readTextFile, falling back to local fs"),super.open(e,r);this.isEditing=!0;let i=await ih(),a=NA.resolveWorkspacePath(i,e,"ACPDiffViewProvider.open.absolutePath");this.absolutePath=typeof a=="string"?a:a.absolutePath,this.relPath=r?.displayPath??e;let o=this.editType==="modify";if(o){try{await In.workspace.saveOpenDocumentIfDirty({filePath:this.absolutePath})}catch{}try{Le.debug("[ACPDiffViewProvider] Reading file via ACP:",this.absolutePath);let u=await this.connection.readTextFile({sessionId:this.getSessionId(),path:this.absolutePath});this.originalContent=u.content,this.fileEncoding="utf8",Le.debug("[ACPDiffViewProvider] Read file successfully, length:",u.content.length)}catch(u){Le.debug("[ACPDiffViewProvider] ACP read failed, falling back to local fs:",u);let d=await Srt.readFile(this.absolutePath);this.fileEncoding=await phe(d),this.originalContent=Tnu.decode(d,this.fileEncoding)}}else this.originalContent="",this.fileEncoding="utf8";let n=await qEt(this.absolutePath);if(this.createdDirs=n,!o)if(this.canWriteFile())try{await this.connection.writeTextFile({sessionId:this.getSessionId(),path:this.absolutePath,content:""})}catch{await Srt.writeFile(this.absolutePath,"")}else await Srt.writeFile(this.absolutePath,"");let s=[];try{s=(await In.workspace.getDiagnostics({filePaths:[]})).fileDiagnostics}catch{s=[]}this.preDiagnostics=s,await this.openDiffEditor(),await this.scrollEditorToLine(0),this.streamedLines=[]}async scrollEditorToLine(e){}async openDiffEditor(){}async saveDocument(){if(!this.canWriteFile())return Le.debug("[ACPDiffViewProvider] Client does not support fs.writeTextFile, falling back to local fs"),super.saveDocument();let e=await this.getContent();if(!this.absolutePath||e===void 0)return!1;try{return Le.debug("[ACPDiffViewProvider] Writing file via ACP:",{path:this.absolutePath,contentLength:e.length}),await this.connection.writeTextFile({sessionId:this.getSessionId(),path:this.absolutePath,content:e}),Le.debug("[ACPDiffViewProvider] Write file successfully"),!0}catch(r){return Le.debug("[ACPDiffViewProvider] ACP write failed, falling back to local fs:",r),super.saveDocument()}}};Or();var RLn=class{async openDiff(e){return Le.debug("[ACPDiffServiceClient] openDiff called (stub)"),Kc.OpenDiffResponse.create({})}async getDocumentText(e){return Le.debug("[ACPDiffServiceClient] getDocumentText called (stub)",{diffId:e.diffId}),Kc.GetDocumentTextResponse.create({content:""})}async replaceText(e){return Le.debug("[ACPDiffServiceClient] replaceText called (stub)"),Kc.ReplaceTextResponse.create({})}async scrollDiff(e){return Le.debug("[ACPDiffServiceClient] scrollDiff called (stub)"),Kc.ScrollDiffResponse.create({})}async truncateDocument(e){return Le.debug("[ACPDiffServiceClient] truncateDocument called (stub)"),Kc.TruncateDocumentResponse.create({})}async saveDocument(e){return Le.debug("[ACPDiffServiceClient] saveDocument called (stub)"),Kc.SaveDocumentResponse.create({})}async closeAllDiffs(e){return Le.debug("[ACPDiffServiceClient] closeAllDiffs called (stub)"),Kc.CloseAllDiffsResponse.create({})}async openMultiFileDiff(e){return Le.debug("[ACPDiffServiceClient] openMultiFileDiff called (stub)"),Kc.OpenMultiFileDiffResponse.create({})}},BLn=class{version;constructor(e,r,i){this.version=i}async debugLog(e){return Le.debug(e.value),KM.Empty.create()}async clipboardWriteText(e){return Le.debug("[ACPEnvServiceClient] clipboardWriteText called (stub)"),KM.Empty.create()}async clipboardReadText(e){return Le.debug("[ACPEnvServiceClient] clipboardReadText called (stub)"),KM.String.create({value:""})}async getHostVersion(e){return Kc.GetHostVersionResponse.create({version:this.version,platform:"Dirac ACP Agent",diracType:"CLI"})}async getIdeRedirectUri(e){return Le.debug("[ACPEnvServiceClient] getIdeRedirectUri called (stub)"),KM.String.create({value:""})}async getTelemetrySettings(e){return Kc.GetTelemetrySettingsResponse.create({isEnabled:Kc.Setting.DISABLED})}subscribeToTelemetrySettings(e,r){return r.onResponse(Kc.TelemetrySettingsEvent.create({isEnabled:Kc.Setting.DISABLED})),()=>{}}async shutdown(e){return Le.debug("[ACPEnvServiceClient] shutdown called (stub)"),KM.Empty.create()}async openExternal(e){let r=e.value||"";if(r){Le.debug(`[ACPEnvServiceClient] openExternal: ${r}`);let{openUrlInBrowser:i}=await Promise.resolve().then(()=>(Rnu(),wnu));await i(r)}return KM.Empty.create()}},DLn=class{constructor(e,r){}async showTextDocument(e){return Le.debug("[ACPWindowServiceClient] showTextDocument called (stub)",{path:e.path}),Kc.TextEditorInfo.create({documentPath:e.path})}async showOpenDialogue(e){return Le.debug("[ACPWindowServiceClient] showOpenDialogue called (stub)"),Kc.SelectedResources.create({paths:[]})}async showMessage(e){return Le.debug("[ACPWindowServiceClient] showMessage called (stub)",{message:e.message,type:e.type}),Kc.SelectedResponse.create({})}async showInputBox(e){return Le.debug("[ACPWindowServiceClient] showInputBox called (stub)"),Kc.ShowInputBoxResponse.create({response:""})}async showSaveDialog(e){return Le.debug("[ACPWindowServiceClient] showSaveDialog called (stub)"),Kc.ShowSaveDialogResponse.create({selectedPath:""})}async openFile(e){return Le.debug("[ACPWindowServiceClient] openFile called (stub)",{filePath:e.filePath}),Kc.OpenFileResponse.create({})}async openSettings(e){return Le.debug("[ACPWindowServiceClient] openSettings called (stub)"),Kc.OpenSettingsResponse.create({})}async getOpenTabs(e){return Le.debug("[ACPWindowServiceClient] getOpenTabs called (stub)"),Kc.GetOpenTabsResponse.create({paths:[]})}async getVisibleTabs(e){return Le.debug("[ACPWindowServiceClient] getVisibleTabs called (stub)"),Kc.GetVisibleTabsResponse.create({paths:[]})}async getActiveEditor(e){return Le.debug("[ACPWindowServiceClient] getActiveEditor called (stub)"),Kc.GetActiveEditorResponse.create({})}},kLn=class{_clientCapabilities;cwdResolver;constructor(e,r,i){this._clientCapabilities=e,this.cwdResolver=i}getCwd(){return this.cwdResolver()??process.cwd()}async getWorkspacePaths(e){let r=this.getCwd();return Le.debug("[ACPWorkspaceServiceClient] getWorkspacePaths called",{cwd:r}),Kc.GetWorkspacePathsResponse.create({paths:[r]})}async saveOpenDocumentIfDirty(e){return Le.debug("[ACPWorkspaceServiceClient] saveOpenDocumentIfDirty called (stub)"),Kc.SaveOpenDocumentIfDirtyResponse.create({})}async getDiagnostics(e){return Le.debug("[ACPWorkspaceServiceClient] getDiagnostics called (stub)"),Kc.GetDiagnosticsResponse.create({fileDiagnostics:[]})}async openProblemsPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openProblemsPanel called (stub)"),Kc.OpenProblemsPanelResponse.create({})}async openInFileExplorerPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openInFileExplorerPanel called (stub)",{path:e.path}),Kc.OpenInFileExplorerPanelResponse.create({})}async openDiracSidebarPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openDiracSidebarPanel called (stub)"),Kc.OpenDiracSidebarPanelResponse.create({})}async openTerminalPanel(e){return Le.debug("[ACPWorkspaceServiceClient] openTerminalPanel called (stub)"),Kc.OpenTerminalResponse.create({})}async executeCommandInTerminal(e){return Le.debug("[ACPWorkspaceServiceClient] executeCommandInTerminal called (stub)",{command:e.command,hasTerminalCapability:this._clientCapabilities?.terminal}),Kc.ExecuteCommandInTerminalResponse.create({})}async prepareDiagnostics(e){return Kc.PrepareDiagnosticsResponse.create({success:!0})}async openFolder(e){return Le.debug("[ACPWorkspaceServiceClient] openFolder called (stub)",{path:e.path}),Kc.OpenFolderResponse.create({success:!0})}},uar=class{workspaceClient;envClient;windowClient;diffClient;constructor(e,r,i,a){this.workspaceClient=new kLn(e,r,i),this.envClient=new BLn(e,r,a),this.windowClient=new DLn(e,r),this.diffClient=new RLn}};Or();import{EventEmitter as Jap}from"events";var MLn=class extends Jap{isHot=!1;waitForShellIntegration=!1;_unretrievedOutput="";_continued=!1;_completed=!1;_hotTimeout=null;_exitWaitTimeout=null;manager;terminalId;pollInterval=null;constructor(e,r){super(),this.manager=e,this.terminalId=r}continue(){this._continued=!0,this.cleanup(),this.emit("continue")}getUnretrievedOutput(){let e=this._unretrievedOutput;return this._unretrievedOutput="",e}async terminate(){this.cleanup(),await this.manager.kill(this.terminalId)}cleanup(){this.stopPolling(),this._hotTimeout&&(clearTimeout(this._hotTimeout),this._hotTimeout=null),this._exitWaitTimeout&&(clearTimeout(this._exitWaitTimeout),this._exitWaitTimeout=null)}stopPolling(){this.pollInterval&&(clearInterval(this.pollInterval),this.pollInterval=null)}run(e){let r="";this.pollInterval=setInterval(async()=>{if(this._continued||this._completed){this.stopPolling();return}try{let i=await this.manager.getOutput(this.terminalId);if(!i.success){this.stopPolling(),this.emit("error",new Error(i.error||"Failed to get output"));return}if(i.output.length>r.length){let a=i.output.slice(r.length);this._unretrievedOutput+=a,r=i.output,this.setHot();let o=a.split(`
|
|
5847
5847
|
`);for(let n of o)n&&this.emit("line",n)}i.exitStatus&&(this._completed=!0,this.stopPolling(),this.emit("completed"))}catch(i){this.stopPolling(),this.emit("error",i instanceof Error?i:new Error(String(i)))}},100),this.manager.waitForExit(this.terminalId).then(i=>{i.success&&!this._continued&&!this._completed&&(this._exitWaitTimeout=setTimeout(()=>{!this._continued&&!this._completed&&(this._completed=!0,this.cleanup(),this.emit("completed"))},200))})}setHot(){this.isHot=!0,this._hotTimeout&&clearTimeout(this._hotTimeout),this._hotTimeout=setTimeout(()=>{this.isHot=!1},2e3)}},PLn=class{name;processId;shellIntegration;_managedTerminal;_manager;_cwd;constructor(e,r){this._managedTerminal=e,this._manager=r,this._cwd=e.cwd||"",this.name=`ACP Terminal ${e.numericId}`,this.processId=Promise.resolve(e.numericId),this.shellIntegration={cwd:{fsPath:this._cwd}}}sendText(e,r){Le.debug("[AcpTerminal] sendText not supported for ACP terminals")}show(){}hide(){}dispose(){this._manager.release(this._managedTerminal.id).catch(e=>{Le.debug("[AcpTerminal] Error releasing terminal:",e)})}};function Xap(t,e){let r=(async()=>{})().constructor.prototype,i=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(r,a)]);for(let[a,o]of i)if(o){let n=o.value.bind(e);Reflect.defineProperty(t,a,{...o,value:n})}return t.terminate&&typeof t.terminate=="function"&&Object.defineProperty(t,"terminate",{value:t.terminate.bind(t),writable:!1,enumerable:!1,configurable:!1}),t}var car=class{connection;clientCapabilities;sessionIdResolver;terminals=new Map;numericIdToStringId=new Map;nextNumericId=1;processes=new Map;terminalInfos=new Map;terminalReuseEnabled=!0;terminalOutputLineLimit=500;constructor(e,r,i){this.connection=e,this.clientCapabilities=r,this.sessionIdResolver=i}runCommand(e,r){let a=e.terminal._managedTerminal;e.busy=!0,e.lastCommand=r,e.lastActive=Date.now(),a.busy=!0,a.lastCommand=r;let o=new MLn(this,a.id);this.processes.set(a.numericId,o),o.once("completed",()=>{e.busy=!1,a.busy=!1}),o.once("error",s=>{e.busy=!1,a.busy=!1});let n=new Promise((s,u)=>{o.once("continue",()=>s()),o.once("completed",()=>s()),o.once("error",d=>u(d))});return this.runCommandInternal(a,r,o),Xap(o,n)}async runCommandInternal(e,r,i){try{let a={sessionId:this.getSessionId(),command:r,cwd:e.cwd},o=await this.connection.createTerminal(a);e.id&&this.terminals.has(e.id)&&this.terminals.delete(e.id),e.handle=o,e.id=o.id,this.terminals.set(o.id,e),this.numericIdToStringId.set(e.numericId,o.id),i.terminalId=o.id,i.run(r)}catch(a){i.emit("error",a instanceof Error?a:new Error(String(a)))}}async getOrCreateTerminal(e){for(let[s,u]of this.terminalInfos)if(!u.busy&&u.terminal._cwd===e)return u;if(this.terminalReuseEnabled){for(let[s,u]of this.terminalInfos)if(!u.busy){let d=u.terminal;return d._cwd=e,d.shellIntegration?.cwd&&(d.shellIntegration.cwd.fsPath=e),d._managedTerminal.cwd=e,u}}let r=this.nextNumericId++,a={id:`pending-${r}`,numericId:r,handle:null,command:"",cwd:e,createdAt:Date.now(),released:!1,busy:!1,lastCommand:""},o=new PLn(a,this),n={id:r,terminal:o,busy:!1,lastCommand:"",lastActive:Date.now()};return this.terminals.set(a.id,a),this.numericIdToStringId.set(r,a.id),this.terminalInfos.set(r,n),Le.debug("[AcpTerminalManager] Created terminal:",{numericId:r,cwd:e}),n}getTerminals(e){let r=[];for(let[i,a]of this.terminalInfos)a.busy===e&&r.push({id:i,lastCommand:a.lastCommand});return r}getUnretrievedOutput(e){let r=this.processes.get(e);return r?r.getUnretrievedOutput():""}isProcessHot(e){let r=this.processes.get(e);return r?r.isHot:!1}disposeAll(){this.releaseAll().catch(e=>{Le.debug("[AcpTerminalManager] Error releasing terminals:",e)}),this.terminals.clear(),this.numericIdToStringId.clear(),this.processes.clear(),this.terminalInfos.clear(),Le.debug("[AcpTerminalManager] disposeAll complete")}setShellIntegrationTimeout(e){}setTerminalReuseEnabled(e){this.terminalReuseEnabled=e}setTerminalOutputLineLimit(e){this.terminalOutputLineLimit=e}setDefaultTerminalProfile(e){}processOutput(e,r){let i=r!==void 0?r:this.terminalOutputLineLimit;if(e.length>i){let a=Math.floor(i/2),o=e.slice(0,a),n=e.slice(e.length-a);return`${o.join(`
|
|
5848
5848
|
`)}
|
|
5849
5849
|
... (output truncated) ...
|