@diegopetrucci/pi-claude-fast 0.1.2 → 0.1.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/.pi-fleet-tested-version +1 -1
- package/README.md +1 -1
- package/index.ts +17 -6
- package/package.json +1 -1
package/.pi-fleet-tested-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.79.10
|
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
type ExtensionContext,
|
|
7
7
|
} from "@earendil-works/pi-coding-agent";
|
|
8
8
|
|
|
9
|
+
const CONFIG_DIR_NAME = ".pi";
|
|
10
|
+
|
|
9
11
|
const EXTENSION_ID = "claude-fast";
|
|
10
12
|
const PROVIDER_ID = "anthropic";
|
|
11
13
|
const API_ID = "anthropic-messages";
|
|
@@ -35,6 +37,11 @@ type SessionState = {
|
|
|
35
37
|
lastInjectedModel?: string;
|
|
36
38
|
};
|
|
37
39
|
|
|
40
|
+
type ProjectConfigContext = {
|
|
41
|
+
cwd: string;
|
|
42
|
+
isProjectTrusted?: () => boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
38
45
|
type RecursivePartial<T> = {
|
|
39
46
|
[P in keyof T]?: T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
40
47
|
};
|
|
@@ -77,21 +84,25 @@ function mergeConfig(
|
|
|
77
84
|
};
|
|
78
85
|
}
|
|
79
86
|
|
|
87
|
+
function canReadProjectConfig(ctx: ProjectConfigContext): boolean {
|
|
88
|
+
return typeof ctx.isProjectTrusted === "function" && ctx.isProjectTrusted();
|
|
89
|
+
}
|
|
90
|
+
|
|
80
91
|
function findProjectConfigPath(cwd: string): string {
|
|
81
92
|
let current = cwd;
|
|
82
93
|
while (true) {
|
|
83
|
-
const candidate = join(current,
|
|
94
|
+
const candidate = join(current, CONFIG_DIR_NAME, "claude-fast.json");
|
|
84
95
|
if (existsSync(candidate)) return candidate;
|
|
85
96
|
|
|
86
97
|
const parent = dirname(current);
|
|
87
|
-
if (parent === current) return join(cwd,
|
|
98
|
+
if (parent === current) return join(cwd, CONFIG_DIR_NAME, "claude-fast.json");
|
|
88
99
|
current = parent;
|
|
89
100
|
}
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
function loadConfig(
|
|
103
|
+
function loadConfig(ctx: ProjectConfigContext): ClaudeFastConfig {
|
|
93
104
|
const globalConfig = readConfigFile(join(getAgentDir(), "extensions", "claude-fast.json"));
|
|
94
|
-
const projectConfig = readConfigFile(findProjectConfigPath(cwd));
|
|
105
|
+
const projectConfig = canReadProjectConfig(ctx) ? readConfigFile(findProjectConfigPath(ctx.cwd)) : {};
|
|
95
106
|
return mergeConfig(mergeConfig(DEFAULT_CONFIG, globalConfig), projectConfig);
|
|
96
107
|
}
|
|
97
108
|
|
|
@@ -235,7 +246,7 @@ export default function claudeFastExtension(pi: ExtensionAPI) {
|
|
|
235
246
|
let state = states.get(ctx.sessionManager);
|
|
236
247
|
if (!state) {
|
|
237
248
|
state = {
|
|
238
|
-
config: loadConfig(ctx
|
|
249
|
+
config: loadConfig(ctx),
|
|
239
250
|
override: "auto",
|
|
240
251
|
};
|
|
241
252
|
states.set(ctx.sessionManager, state);
|
|
@@ -245,7 +256,7 @@ export default function claudeFastExtension(pi: ExtensionAPI) {
|
|
|
245
256
|
|
|
246
257
|
pi.on("session_start", (_event, ctx) => {
|
|
247
258
|
const state: SessionState = {
|
|
248
|
-
config: loadConfig(ctx
|
|
259
|
+
config: loadConfig(ctx),
|
|
249
260
|
override: "auto",
|
|
250
261
|
};
|
|
251
262
|
states.set(ctx.sessionManager, state);
|
package/package.json
CHANGED