decorated-pi 0.1.0 → 0.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 +42 -151
- package/extensions/extend-model.ts +1 -6
- package/extensions/index.ts +2 -0
- package/extensions/lsp/client.ts +12 -1
- package/extensions/lsp/env.ts +6 -0
- package/extensions/lsp/format.ts +6 -0
- package/extensions/lsp/index.ts +6 -0
- package/extensions/lsp/prompt.ts +6 -0
- package/extensions/lsp/server-manager.ts +6 -0
- package/extensions/lsp/servers.ts +9 -1
- package/extensions/lsp/tools.ts +8 -0
- package/extensions/lsp/trust.ts +6 -0
- package/extensions/providers/ark-coding.ts +73 -0
- package/extensions/providers/index.ts +9 -0
- package/extensions/providers/ollama-cloud.ts +101 -0
- package/extensions/providers/qianfan-coding.ts +71 -0
- package/extensions/safety.ts +610 -104
- package/extensions/settings.ts +38 -1
- package/extensions/smart-at.ts +10 -3
- package/package.json +11 -7
package/extensions/settings.ts
CHANGED
|
@@ -8,12 +8,27 @@ import * as path from "node:path";
|
|
|
8
8
|
import * as os from "node:os";
|
|
9
9
|
import type { Model } from "@earendil-works/pi-ai";
|
|
10
10
|
|
|
11
|
-
const CONFIG_DIR = path.join(os.homedir(), ".pi", "agent"
|
|
11
|
+
const CONFIG_DIR = path.join(os.homedir(), ".pi", "agent");
|
|
12
12
|
const CONFIG_FILE = path.join(CONFIG_DIR, "decorated-pi.json");
|
|
13
13
|
|
|
14
|
+
export interface ProviderModelEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
reasoning: boolean;
|
|
18
|
+
contextWindow: number;
|
|
19
|
+
maxTokens: number;
|
|
20
|
+
input: ("text" | "image")[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ProviderCache {
|
|
24
|
+
lastSynced?: string;
|
|
25
|
+
models: ProviderModelEntry[];
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
export interface DecoratedPiConfig {
|
|
15
29
|
imageModelKey?: string | null;
|
|
16
30
|
compactModelKey?: string | null;
|
|
31
|
+
providers?: Record<string, ProviderCache>;
|
|
17
32
|
}
|
|
18
33
|
|
|
19
34
|
export function loadConfig(): DecoratedPiConfig {
|
|
@@ -41,6 +56,28 @@ export function parseModelKey(key: string): { provider: string; modelId: string
|
|
|
41
56
|
return { provider: key.slice(0, i), modelId: key.slice(i + 1) };
|
|
42
57
|
}
|
|
43
58
|
|
|
59
|
+
// ─── Provider ────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
export function loadProvider(name: string): ProviderCache | null {
|
|
62
|
+
return loadConfig().providers?.[name] ?? null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function saveProvider(name: string, data: ProviderCache) {
|
|
66
|
+
if (!fs.existsSync(CONFIG_DIR)) fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
67
|
+
const current = loadConfig();
|
|
68
|
+
if (!current.providers) current.providers = {};
|
|
69
|
+
current.providers[name] = data;
|
|
70
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(current, null, 2) + "\n", "utf-8");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function removeProvider(name: string) {
|
|
74
|
+
const current = loadConfig();
|
|
75
|
+
if (current.providers?.[name]) {
|
|
76
|
+
delete current.providers[name];
|
|
77
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(current, null, 2) + "\n", "utf-8");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
44
81
|
// ─── Getter ─────────────────────────────────────────────────────────────────
|
|
45
82
|
|
|
46
83
|
export function getImageModelKey(): string | null {
|
package/extensions/smart-at.ts
CHANGED
|
@@ -200,9 +200,13 @@ export function setupSmartAt(pi: ExtensionAPI) {
|
|
|
200
200
|
|
|
201
201
|
const { dirs, files } = getFileAndDirList(cwd);
|
|
202
202
|
const results = smartSearch(dirs, files, prefix.slice(1));
|
|
203
|
-
ctx.ui.setWidget("smart-at", ["[2mpowered by decorated-pi[0m"]);
|
|
204
203
|
|
|
205
|
-
if (!results.length)
|
|
204
|
+
if (!results.length) {
|
|
205
|
+
ctx.ui.setWidget("smart-at", undefined);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
ctx.ui.setWidget("smart-at", ["[2mpowered by decorated-pi[0m"]);
|
|
206
210
|
return Promise.resolve({
|
|
207
211
|
items: results.map((f: string) => ({
|
|
208
212
|
value: "@" + f,
|
|
@@ -213,7 +217,10 @@ export function setupSmartAt(pi: ExtensionAPI) {
|
|
|
213
217
|
});
|
|
214
218
|
},
|
|
215
219
|
// ⚠️ 必须 .bind(orig)
|
|
216
|
-
applyCompletion:
|
|
220
|
+
applyCompletion: (...args: any[]) => {
|
|
221
|
+
ctx.ui.setWidget("smart-at", undefined);
|
|
222
|
+
return orig.applyCompletion.apply(orig, args);
|
|
223
|
+
},
|
|
217
224
|
shouldTriggerFileCompletion: orig.shouldTriggerFileCompletion?.bind(orig),
|
|
218
225
|
}));
|
|
219
226
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decorated-pi",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Essential utilities for pi: safety gates, secret redaction, smart @ completion, dynamic AGENTS loading, image fallback, and LSP tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
@@ -11,25 +11,23 @@
|
|
|
11
11
|
"lsp",
|
|
12
12
|
"language-server",
|
|
13
13
|
"autocomplete",
|
|
14
|
-
"
|
|
14
|
+
"entropy",
|
|
15
|
+
"secret-detection"
|
|
15
16
|
],
|
|
16
17
|
"license": "MIT",
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/lcwecker/decorated-pi.git"
|
|
20
|
+
"url": "git+https://github.com/lcwecker/decorated-pi.git"
|
|
20
21
|
},
|
|
21
22
|
"homepage": "https://github.com/lcwecker/decorated-pi#readme",
|
|
22
23
|
"bugs": "https://github.com/lcwecker/decorated-pi/issues",
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@secretlint/node": "^13.0.0",
|
|
25
|
-
"@secretlint/secretlint-rule-azure": "^13.0.0",
|
|
26
|
-
"@secretlint/secretlint-rule-preset-recommend": "^13.0.0",
|
|
27
|
-
"@secretlint/secretlint-rule-secp256k1-privatekey": "^13.0.0",
|
|
28
25
|
"@spences10/pi-child-env": "0.1.4",
|
|
29
26
|
"@spences10/pi-project-trust": "0.0.6",
|
|
30
27
|
"openai": "^6.37.0"
|
|
31
28
|
},
|
|
32
29
|
"peerDependencies": {
|
|
30
|
+
"@earendil-works/pi-ai": "*",
|
|
33
31
|
"@earendil-works/pi-coding-agent": "*",
|
|
34
32
|
"@earendil-works/pi-tui": "*",
|
|
35
33
|
"typebox": "*"
|
|
@@ -38,5 +36,11 @@
|
|
|
38
36
|
"extensions": [
|
|
39
37
|
"./extensions/index.ts"
|
|
40
38
|
]
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"vitest": "^4.1.6"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "vitest run"
|
|
41
45
|
}
|
|
42
46
|
}
|