@oked/sdk 0.6.2 → 0.6.3
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/describe.js +25 -5
- package/package.json +2 -2
package/dist/describe.js
CHANGED
|
@@ -495,16 +495,31 @@ function extractSqlFromScriptBody(body) {
|
|
|
495
495
|
// to gate SQL extraction so SQL words appearing in *argument data* (a `gh pr
|
|
496
496
|
// create --body` mentioning "TRUNCATE", a path like `better-sqlite3`) don't get
|
|
497
497
|
// misread as a statement to run.
|
|
498
|
-
const
|
|
498
|
+
const SQL_CLI_CONSUMER_RE = /(?:^|\||&&|;|\$\(|`)\s*(?:\w+=\S+\s+)*(?:sudo\s+)?(?:psql|mysql|mariadb|sqlite3?)\b/;
|
|
499
|
+
const INTERPRETER_CONSUMER_RE = /(?:^|\||&&|;|\$\(|`)\s*(?:\w+=\S+\s+)*(?:sudo\s+)?(?:node|python\d?|ruby|perl|deno|bun)\b/;
|
|
500
|
+
// A database client library named in a script body. A script that has SQL
|
|
501
|
+
// words but no .execute()-style call and no DB library cannot run SQL: it is
|
|
502
|
+
// text processing (a Python script that edits a source file whose comments
|
|
503
|
+
// say "DELETE FROM", for example), so it must not be shown as a SQL statement.
|
|
504
|
+
const DB_LIBRARY_RE = /\b(?:sqlite3|better-sqlite3|psycopg2?|pymysql|MySQLdb|mysql2?|sqlalchemy|duckdb|knex|prisma|pg|sequel|DBI)\b/;
|
|
505
|
+
// SQL to run from an interpreter body (node -e, python -c, `python - <<EOF`).
|
|
506
|
+
function sqlFromInterpreterBody(body) {
|
|
507
|
+
if (!SQL_KEYWORDS_RE.test(body))
|
|
508
|
+
return null;
|
|
509
|
+
const extracted = extractSqlFromScriptBody(body);
|
|
510
|
+
if (extracted)
|
|
511
|
+
return extracted;
|
|
512
|
+
return DB_LIBRARY_RE.test(body) ? body : null;
|
|
513
|
+
}
|
|
499
514
|
export function findSqlInCommand(cmd) {
|
|
500
515
|
// Inline interpreter flags: node -e, python -c, ruby -e, perl -e. Anchored to
|
|
501
516
|
// a command position so a SQL-looking string elsewhere doesn't match.
|
|
502
517
|
const inline = cmd.match(/(?:^|\||&&|;|\$\()\s*(?:\w+=\S+\s+)*(?:sudo\s+)?(?:node|python\d?|ruby|perl|deno|bun)\s+-[ec]\s+(?:"([\s\S]+?)"|'([\s\S]+?)')\s*$/);
|
|
503
518
|
if (inline) {
|
|
504
519
|
const body = inline[1] ?? inline[2];
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
520
|
+
const sql = body ? sqlFromInterpreterBody(body) : null;
|
|
521
|
+
if (sql)
|
|
522
|
+
return sql;
|
|
508
523
|
}
|
|
509
524
|
// psql -c "..." / mysql -e "..." / sqlite3 db "..." — outer-quoted statement.
|
|
510
525
|
// Anchored to the start of the command so "psql"/"mysql" appearing inside an
|
|
@@ -523,9 +538,14 @@ export function findSqlInCommand(cmd) {
|
|
|
523
538
|
if (hd) {
|
|
524
539
|
const body = hd[2];
|
|
525
540
|
const context = cmd.slice(0, hd.index) + cmd.slice((hd.index ?? 0) + hd[0].length);
|
|
526
|
-
if (body &&
|
|
541
|
+
if (body && SQL_CLI_CONSUMER_RE.test(context) && SQL_KEYWORDS_RE.test(body)) {
|
|
527
542
|
return extractSqlFromScriptBody(body) ?? body;
|
|
528
543
|
}
|
|
544
|
+
if (body && INTERPRETER_CONSUMER_RE.test(context)) {
|
|
545
|
+
const sql = sqlFromInterpreterBody(body);
|
|
546
|
+
if (sql)
|
|
547
|
+
return sql;
|
|
548
|
+
}
|
|
529
549
|
}
|
|
530
550
|
// Direct SQL keywords at top of command
|
|
531
551
|
if (/^\s*(DROP|DELETE\s+FROM|TRUNCATE|UPDATE|INSERT\s+INTO|CREATE\s+TABLE|ALTER\s+TABLE)\b/i.test(cmd)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "OKed SDK - human approval layer for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@oked/receipt-core": "0.6.
|
|
48
|
+
"@oked/receipt-core": "0.6.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.13.10",
|