@picahq/cli 1.9.1 → 1.9.2
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/dist/index.js +43 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,9 +37,49 @@ function writeConfig(config) {
|
|
|
37
37
|
}
|
|
38
38
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 384 });
|
|
39
39
|
}
|
|
40
|
+
function readPicaRc() {
|
|
41
|
+
const rcPath = path.join(process.cwd(), ".picarc");
|
|
42
|
+
if (!fs.existsSync(rcPath)) return {};
|
|
43
|
+
try {
|
|
44
|
+
const content = fs.readFileSync(rcPath, "utf-8");
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const line of content.split("\n")) {
|
|
47
|
+
const trimmed = line.trim();
|
|
48
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
49
|
+
const eqIndex = trimmed.indexOf("=");
|
|
50
|
+
if (eqIndex === -1) continue;
|
|
51
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
52
|
+
const value = trimmed.slice(eqIndex + 1).trim();
|
|
53
|
+
result[key] = value;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
} catch {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
40
60
|
function getApiKey() {
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
if (process.env.PICA_SECRET) return process.env.PICA_SECRET;
|
|
62
|
+
const rc = readPicaRc();
|
|
63
|
+
if (rc.PICA_SECRET) return rc.PICA_SECRET;
|
|
64
|
+
return readConfig()?.apiKey ?? null;
|
|
65
|
+
}
|
|
66
|
+
function getAccessControlFromAllSources() {
|
|
67
|
+
const rc = readPicaRc();
|
|
68
|
+
const fileAc = getAccessControl();
|
|
69
|
+
const merged = { ...fileAc };
|
|
70
|
+
if (rc.PICA_PERMISSIONS) {
|
|
71
|
+
merged.permissions = rc.PICA_PERMISSIONS;
|
|
72
|
+
}
|
|
73
|
+
if (rc.PICA_CONNECTION_KEYS) {
|
|
74
|
+
merged.connectionKeys = rc.PICA_CONNECTION_KEYS.split(",").map((s) => s.trim()).filter(Boolean);
|
|
75
|
+
}
|
|
76
|
+
if (rc.PICA_ACTION_IDS) {
|
|
77
|
+
merged.actionIds = rc.PICA_ACTION_IDS.split(",").map((s) => s.trim()).filter(Boolean);
|
|
78
|
+
}
|
|
79
|
+
if (rc.PICA_KNOWLEDGE_AGENT) {
|
|
80
|
+
merged.knowledgeAgent = rc.PICA_KNOWLEDGE_AGENT === "true";
|
|
81
|
+
}
|
|
82
|
+
return merged;
|
|
43
83
|
}
|
|
44
84
|
function getAccessControl() {
|
|
45
85
|
return readConfig()?.accessControl ?? {};
|
|
@@ -1568,7 +1608,7 @@ function getConfig() {
|
|
|
1568
1608
|
p5.cancel("Not configured. Run `pica init` first.");
|
|
1569
1609
|
process.exit(1);
|
|
1570
1610
|
}
|
|
1571
|
-
const ac =
|
|
1611
|
+
const ac = getAccessControlFromAllSources();
|
|
1572
1612
|
const permissions = ac.permissions || "admin";
|
|
1573
1613
|
const connectionKeys = ac.connectionKeys || ["*"];
|
|
1574
1614
|
const actionIds = ac.actionIds || ["*"];
|