@dcode-dev/dcode-cli 1.0.0
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/NPM_README.md +78 -0
- package/README.md +341 -0
- package/bin/dcode-bin +0 -0
- package/bin/dcode.js +44 -0
- package/cmd/agent_v2.go +448 -0
- package/cmd/analyze.go +97 -0
- package/cmd/auth.go +338 -0
- package/cmd/compose.go +284 -0
- package/cmd/context.go +111 -0
- package/cmd/edit.go +116 -0
- package/cmd/env.go +10 -0
- package/cmd/fix.go +145 -0
- package/cmd/gemini.go +20 -0
- package/cmd/generate.go +47 -0
- package/cmd/interactive.go +33 -0
- package/cmd/mcp.go +196 -0
- package/cmd/patch.go +19 -0
- package/cmd/providers.go +67 -0
- package/cmd/root.go +41 -0
- package/cmd/search.go +61 -0
- package/cmd/server.go +36 -0
- package/cmd/switch.go +122 -0
- package/cmd/terminal.go +277 -0
- package/go.mod +42 -0
- package/go.sum +86 -0
- package/internal/agent/agent.go +332 -0
- package/internal/agent/parse.go +25 -0
- package/internal/agents/base.go +154 -0
- package/internal/agents/documenter.go +77 -0
- package/internal/agents/generalist.go +266 -0
- package/internal/agents/investigator.go +60 -0
- package/internal/agents/registry.go +34 -0
- package/internal/agents/reviewer.go +67 -0
- package/internal/agents/tester.go +73 -0
- package/internal/ai/client.go +634 -0
- package/internal/ai/tools.go +332 -0
- package/internal/auth/adc.go +108 -0
- package/internal/auth/apikey.go +67 -0
- package/internal/auth/factory.go +145 -0
- package/internal/auth/oauth2.go +227 -0
- package/internal/auth/store.go +216 -0
- package/internal/auth/types.go +79 -0
- package/internal/auth/vertex.go +138 -0
- package/internal/config/config.go +428 -0
- package/internal/config/policy.go +251 -0
- package/internal/context/builder.go +312 -0
- package/internal/detector/detector.go +204 -0
- package/internal/diffutil/diffutil.go +30 -0
- package/internal/fsutil/fsutil.go +35 -0
- package/internal/mcp/client.go +314 -0
- package/internal/mcp/manager.go +221 -0
- package/internal/policy/policy.go +89 -0
- package/internal/prompt/interactive.go +338 -0
- package/internal/registry/agent.go +201 -0
- package/internal/registry/tool.go +181 -0
- package/internal/scheduler/scheduler.go +250 -0
- package/internal/server/server.go +167 -0
- package/internal/tools/file.go +183 -0
- package/internal/tools/filesystem.go +286 -0
- package/internal/tools/git.go +355 -0
- package/internal/tools/memory.go +269 -0
- package/internal/tools/registry.go +49 -0
- package/internal/tools/search.go +230 -0
- package/internal/tools/shell.go +84 -0
- package/internal/websearch/search.go +40 -0
- package/internal/websearch/tavily.go +79 -0
- package/main.go +19 -0
- package/package.json +57 -0
- package/scripts/install.js +59 -0
- package/scripts/uninstall.js +28 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package websearch
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"io"
|
|
9
|
+
"net/http"
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
type Tavily struct {
|
|
14
|
+
apiKey string
|
|
15
|
+
client *http.Client
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func NewTavily(apiKey string) *Tavily {
|
|
19
|
+
return &Tavily{apiKey: apiKey, client: &http.Client{Timeout: 30 * time.Second}}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func (t *Tavily) Search(ctx context.Context, query string) ([]Result, error) {
|
|
23
|
+
type request struct {
|
|
24
|
+
APIKey string `json:"api_key"`
|
|
25
|
+
Query string `json:"query"`
|
|
26
|
+
SearchDepth string `json:"search_depth"`
|
|
27
|
+
MaxResults int `json:"max_results"`
|
|
28
|
+
IncludeAnswer bool `json:"include_answer"`
|
|
29
|
+
}
|
|
30
|
+
type response struct {
|
|
31
|
+
Results []struct {
|
|
32
|
+
Title string `json:"title"`
|
|
33
|
+
URL string `json:"url"`
|
|
34
|
+
Content string `json:"content"`
|
|
35
|
+
} `json:"results"`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
body, _ := json.Marshal(request{
|
|
39
|
+
APIKey: t.apiKey,
|
|
40
|
+
Query: query,
|
|
41
|
+
SearchDepth: "basic",
|
|
42
|
+
MaxResults: 5,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.tavily.com/search", bytes.NewReader(body))
|
|
46
|
+
if err != nil {
|
|
47
|
+
return nil, err
|
|
48
|
+
}
|
|
49
|
+
req.Header.Set("Content-Type", "application/json")
|
|
50
|
+
|
|
51
|
+
resp, err := t.client.Do(req)
|
|
52
|
+
if err != nil {
|
|
53
|
+
return nil, err
|
|
54
|
+
}
|
|
55
|
+
defer resp.Body.Close()
|
|
56
|
+
|
|
57
|
+
respBody, err := io.ReadAll(resp.Body)
|
|
58
|
+
if err != nil {
|
|
59
|
+
return nil, err
|
|
60
|
+
}
|
|
61
|
+
if resp.StatusCode != http.StatusOK {
|
|
62
|
+
return nil, fmt.Errorf("tavily error (%d): %s", resp.StatusCode, string(respBody))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var decoded response
|
|
66
|
+
if err := json.Unmarshal(respBody, &decoded); err != nil {
|
|
67
|
+
return nil, err
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
out := make([]Result, 0, len(decoded.Results))
|
|
71
|
+
for _, r := range decoded.Results {
|
|
72
|
+
snippet := r.Content
|
|
73
|
+
if len(snippet) > 400 {
|
|
74
|
+
snippet = snippet[:400] + "..."
|
|
75
|
+
}
|
|
76
|
+
out = append(out, Result{Title: r.Title, URL: r.URL, Snippet: snippet})
|
|
77
|
+
}
|
|
78
|
+
return out, nil
|
|
79
|
+
}
|
package/main.go
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"os"
|
|
6
|
+
|
|
7
|
+
"github.com/ddhanush1/dcode/cmd"
|
|
8
|
+
"github.com/joho/godotenv"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func main() {
|
|
12
|
+
// Load .env file
|
|
13
|
+
_ = godotenv.Load()
|
|
14
|
+
|
|
15
|
+
if err := cmd.Execute(); err != nil {
|
|
16
|
+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
|
17
|
+
os.Exit(1)
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dcode-dev/dcode-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "DCode - AI-powered coding assistant CLI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"cli",
|
|
8
|
+
"coding-assistant",
|
|
9
|
+
"gemini",
|
|
10
|
+
"openai",
|
|
11
|
+
"copilot",
|
|
12
|
+
"code-generation",
|
|
13
|
+
"developer-tools"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/ddhanush1/dcode",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/ddhanush1/dcode/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/ddhanush1/dcode.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "ddhanush1",
|
|
25
|
+
"bin": {
|
|
26
|
+
"dcode": "./bin/dcode.js"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node scripts/install.js",
|
|
30
|
+
"preuninstall": "node scripts/uninstall.js",
|
|
31
|
+
"build": "go build -o bin/dcode-bin .",
|
|
32
|
+
"test": "go test ./...",
|
|
33
|
+
"prepare": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"bin/",
|
|
37
|
+
"scripts/",
|
|
38
|
+
"internal/",
|
|
39
|
+
"cmd/",
|
|
40
|
+
"main.go",
|
|
41
|
+
"go.mod",
|
|
42
|
+
"go.sum",
|
|
43
|
+
"NPM_README.md"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=14.0.0"
|
|
47
|
+
},
|
|
48
|
+
"os": [
|
|
49
|
+
"darwin",
|
|
50
|
+
"linux",
|
|
51
|
+
"win32"
|
|
52
|
+
],
|
|
53
|
+
"cpu": [
|
|
54
|
+
"x64",
|
|
55
|
+
"arm64"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Post-install script for DCode CLI
|
|
5
|
+
* Builds the Go binary after npm install
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { execSync } = require('child_process');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
|
|
13
|
+
const platform = os.platform();
|
|
14
|
+
const arch = os.arch();
|
|
15
|
+
|
|
16
|
+
console.log('๐จ Building DCode CLI...');
|
|
17
|
+
console.log(`Platform: ${platform}, Architecture: ${arch}`);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Check if Go is installed
|
|
21
|
+
try {
|
|
22
|
+
execSync('go version', { stdio: 'pipe' });
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error('โ Error: Go is not installed or not in PATH');
|
|
25
|
+
console.error('Please install Go from https://golang.org/dl/');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Build the Go binary
|
|
30
|
+
const projectRoot = path.join(__dirname, '..');
|
|
31
|
+
const binaryName = platform === 'win32' ? 'dcode-bin.exe' : 'dcode-bin';
|
|
32
|
+
const outputPath = path.join(projectRoot, 'bin', binaryName);
|
|
33
|
+
|
|
34
|
+
console.log(`Building binary to: ${outputPath}`);
|
|
35
|
+
|
|
36
|
+
const buildCmd = `go build -o "${outputPath}" .`;
|
|
37
|
+
execSync(buildCmd, {
|
|
38
|
+
cwd: projectRoot,
|
|
39
|
+
stdio: 'inherit'
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Make executable on Unix systems
|
|
43
|
+
if (platform !== 'win32') {
|
|
44
|
+
fs.chmodSync(outputPath, '755');
|
|
45
|
+
fs.chmodSync(path.join(projectRoot, 'bin', 'dcode.js'), '755');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log('โ
DCode CLI installed successfully!');
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log('Run "dcode" to get started!');
|
|
51
|
+
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('โ Failed to build DCode:', err.message);
|
|
54
|
+
console.error('');
|
|
55
|
+
console.error('Please try manually:');
|
|
56
|
+
console.error(' cd', path.join(__dirname, '..'));
|
|
57
|
+
console.error(' go build -o bin/dcode-bin .');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-uninstall script for DCode CLI
|
|
5
|
+
* Cleanup binary files
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
console.log('๐งน Cleaning up DCode CLI...');
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
15
|
+
const files = ['dcode-bin', 'dcode-bin.exe'];
|
|
16
|
+
|
|
17
|
+
files.forEach(file => {
|
|
18
|
+
const filePath = path.join(binDir, file);
|
|
19
|
+
if (fs.existsSync(filePath)) {
|
|
20
|
+
fs.unlinkSync(filePath);
|
|
21
|
+
console.log(`Removed: ${file}`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log('โ
Cleanup complete');
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.error('Warning: Cleanup failed:', err.message);
|
|
28
|
+
}
|