seclaw 0.1.12 → 0.1.14
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/cli.js +4 -15
- package/dist/runtime/agent.js +22 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1441,7 +1441,6 @@ function getTemplatePath(template, targetDir) {
|
|
|
1441
1441
|
import { resolve as resolve6 } from "path";
|
|
1442
1442
|
import { existsSync as existsSync6 } from "fs";
|
|
1443
1443
|
import { writeFile as writeFile3, mkdir as mkdir3, readFile as readFile3, cp as cp3 } from "fs/promises";
|
|
1444
|
-
import { execSync } from "child_process";
|
|
1445
1444
|
import * as p3 from "@clack/prompts";
|
|
1446
1445
|
import pc3 from "picocolors";
|
|
1447
1446
|
var API_URL = process.env.SECLAW_API || "https://seclawai.com";
|
|
@@ -1450,8 +1449,9 @@ async function add(template, options) {
|
|
|
1450
1449
|
p3.intro(`${pc3.bgCyan(pc3.black(" seclaw "))} Adding template: ${template}`);
|
|
1451
1450
|
const isFree = FREE_TEMPLATES.includes(template);
|
|
1452
1451
|
const s = p3.spinner();
|
|
1452
|
+
const projectDir = findProjectDir() || process.cwd();
|
|
1453
1453
|
const monorepoTemplatesDir = resolve6(import.meta.dirname, "..", "..", "templates", "paid");
|
|
1454
|
-
const templateDir = !isFree && existsSync6(resolve6(import.meta.dirname, "..", "..", "templates")) ? resolve6(monorepoTemplatesDir, template) : resolve6(
|
|
1454
|
+
const templateDir = !isFree && existsSync6(resolve6(import.meta.dirname, "..", "..", "templates")) ? resolve6(monorepoTemplatesDir, template) : resolve6(projectDir, "templates", template);
|
|
1455
1455
|
if (isFree) {
|
|
1456
1456
|
s.start("Setting up free template...");
|
|
1457
1457
|
const bundledPath = resolve6(
|
|
@@ -1512,17 +1512,6 @@ async function add(template, options) {
|
|
|
1512
1512
|
await writeFile3(resolve6(templateDir, filename), content);
|
|
1513
1513
|
}
|
|
1514
1514
|
s.stop(`${Object.keys(data.files).length} files written to ${pc3.dim(templateDir)}`);
|
|
1515
|
-
const cliDir = resolve6(import.meta.dirname, "..");
|
|
1516
|
-
const cliPkgPath = resolve6(cliDir, "package.json");
|
|
1517
|
-
if (existsSync6(cliPkgPath)) {
|
|
1518
|
-
s.start("Rebuilding CLI...");
|
|
1519
|
-
try {
|
|
1520
|
-
execSync("pnpm build", { cwd: cliDir, stdio: "pipe" });
|
|
1521
|
-
s.stop("CLI rebuilt with new template.");
|
|
1522
|
-
} catch {
|
|
1523
|
-
s.stop("CLI rebuild failed \u2014 run `pnpm build` manually.");
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
1515
|
} catch (err) {
|
|
1527
1516
|
s.stop("Failed.");
|
|
1528
1517
|
p3.log.error(`Network error: ${err}`);
|
|
@@ -1532,12 +1521,12 @@ async function add(template, options) {
|
|
|
1532
1521
|
}
|
|
1533
1522
|
let wsHostPath = "shared";
|
|
1534
1523
|
try {
|
|
1535
|
-
const envContent = await readFile3(resolve6(
|
|
1524
|
+
const envContent = await readFile3(resolve6(projectDir, ".env"), "utf-8");
|
|
1536
1525
|
const wsMatch = envContent.match(/WORKSPACE_HOST_PATH=(.+)/);
|
|
1537
1526
|
if (wsMatch?.[1]?.trim()) wsHostPath = wsMatch[1].trim();
|
|
1538
1527
|
} catch {
|
|
1539
1528
|
}
|
|
1540
|
-
const configDir = resolve6(
|
|
1529
|
+
const configDir = resolve6(projectDir, wsHostPath, "config");
|
|
1541
1530
|
if (existsSync6(configDir)) {
|
|
1542
1531
|
const capDir = resolve6(configDir, "capabilities", template);
|
|
1543
1532
|
await mkdir3(capDir, { recursive: true });
|
package/dist/runtime/agent.js
CHANGED
|
@@ -2102,8 +2102,7 @@ Mode: *${modeLabel}*`;
|
|
|
2102
2102
|
if (notInstalled.length > 0) {
|
|
2103
2103
|
text += `
|
|
2104
2104
|
|
|
2105
|
-
|
|
2106
|
-
_Tap to view details:_`;
|
|
2105
|
+
${notInstalled.length} more available:`;
|
|
2107
2106
|
}
|
|
2108
2107
|
const keyboard = [];
|
|
2109
2108
|
if (capabilities.length >= 2) {
|
|
@@ -2121,7 +2120,7 @@ _Tap to view details:_`;
|
|
|
2121
2120
|
}
|
|
2122
2121
|
for (const t of notInstalled) {
|
|
2123
2122
|
keyboard.push([{
|
|
2124
|
-
text: `${t.name} \u2014
|
|
2123
|
+
text: `${t.name} \u2014 Details`,
|
|
2125
2124
|
url: `https://seclawai.com/templates/${t.id}`
|
|
2126
2125
|
}]);
|
|
2127
2126
|
}
|
|
@@ -2144,7 +2143,7 @@ async function handleSwitchCallback(chatId, msgId, capId, config2) {
|
|
|
2144
2143
|
async function sendMessageWithButtons(token, chatId, text, keyboard) {
|
|
2145
2144
|
if (!token || !chatId) return;
|
|
2146
2145
|
try {
|
|
2147
|
-
await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
2146
|
+
const res = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
2148
2147
|
method: "POST",
|
|
2149
2148
|
headers: { "Content-Type": "application/json" },
|
|
2150
2149
|
body: JSON.stringify({
|
|
@@ -2154,7 +2153,25 @@ async function sendMessageWithButtons(token, chatId, text, keyboard) {
|
|
|
2154
2153
|
reply_markup: { inline_keyboard: keyboard }
|
|
2155
2154
|
})
|
|
2156
2155
|
});
|
|
2157
|
-
|
|
2156
|
+
const data = await res.json();
|
|
2157
|
+
if (!data.ok) {
|
|
2158
|
+
console.log(`[telegram] Markdown failed (buttons): ${data.description} \u2014 retrying plain`);
|
|
2159
|
+
const retryRes = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
2160
|
+
method: "POST",
|
|
2161
|
+
headers: { "Content-Type": "application/json" },
|
|
2162
|
+
body: JSON.stringify({
|
|
2163
|
+
chat_id: chatId,
|
|
2164
|
+
text,
|
|
2165
|
+
reply_markup: { inline_keyboard: keyboard }
|
|
2166
|
+
})
|
|
2167
|
+
});
|
|
2168
|
+
const retryData = await retryRes.json();
|
|
2169
|
+
if (!retryData.ok) {
|
|
2170
|
+
console.error(`[telegram] Plain also failed (buttons): ${retryData.description}`);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
} catch (err) {
|
|
2174
|
+
console.error(`[telegram] sendMessageWithButtons error:`, err.message);
|
|
2158
2175
|
try {
|
|
2159
2176
|
await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
2160
2177
|
method: "POST",
|