sproutkit-code 0.1.1 → 0.1.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 +131 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25238,7 +25238,7 @@ var require_promisify = __commonJS({
|
|
|
25238
25238
|
"../../node_modules/agent-base/dist/src/promisify.js"(exports2) {
|
|
25239
25239
|
"use strict";
|
|
25240
25240
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
25241
|
-
function
|
|
25241
|
+
function promisify2(fn) {
|
|
25242
25242
|
return function(req, opts) {
|
|
25243
25243
|
return new Promise((resolve, reject) => {
|
|
25244
25244
|
fn.call(this, req, opts, (err, rtn) => {
|
|
@@ -25251,7 +25251,7 @@ var require_promisify = __commonJS({
|
|
|
25251
25251
|
});
|
|
25252
25252
|
};
|
|
25253
25253
|
}
|
|
25254
|
-
exports2.default =
|
|
25254
|
+
exports2.default = promisify2;
|
|
25255
25255
|
}
|
|
25256
25256
|
});
|
|
25257
25257
|
|
|
@@ -36147,9 +36147,9 @@ var require_get_stream = __commonJS({
|
|
|
36147
36147
|
"use strict";
|
|
36148
36148
|
var { constants: BufferConstants } = require("buffer");
|
|
36149
36149
|
var stream = require("stream");
|
|
36150
|
-
var { promisify } = require("util");
|
|
36150
|
+
var { promisify: promisify2 } = require("util");
|
|
36151
36151
|
var bufferStream = require_buffer_stream();
|
|
36152
|
-
var streamPipelinePromisified =
|
|
36152
|
+
var streamPipelinePromisified = promisify2(stream.pipeline);
|
|
36153
36153
|
var MaxBufferError = class extends Error {
|
|
36154
36154
|
constructor() {
|
|
36155
36155
|
super("maxBuffer exceeded");
|
|
@@ -68960,7 +68960,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
68960
68960
|
var require_mock_client = __commonJS({
|
|
68961
68961
|
"../../node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
|
|
68962
68962
|
"use strict";
|
|
68963
|
-
var { promisify } = require("node:util");
|
|
68963
|
+
var { promisify: promisify2 } = require("node:util");
|
|
68964
68964
|
var Client = require_client();
|
|
68965
68965
|
var { buildMockDispatch } = require_mock_utils();
|
|
68966
68966
|
var {
|
|
@@ -69000,7 +69000,7 @@ var require_mock_client = __commonJS({
|
|
|
69000
69000
|
return new MockInterceptor(opts, this[kDispatches]);
|
|
69001
69001
|
}
|
|
69002
69002
|
async [kClose]() {
|
|
69003
|
-
await
|
|
69003
|
+
await promisify2(this[kOriginalClose])();
|
|
69004
69004
|
this[kConnected] = 0;
|
|
69005
69005
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
69006
69006
|
}
|
|
@@ -69013,7 +69013,7 @@ var require_mock_client = __commonJS({
|
|
|
69013
69013
|
var require_mock_pool = __commonJS({
|
|
69014
69014
|
"../../node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
69015
69015
|
"use strict";
|
|
69016
|
-
var { promisify } = require("node:util");
|
|
69016
|
+
var { promisify: promisify2 } = require("node:util");
|
|
69017
69017
|
var Pool = require_pool();
|
|
69018
69018
|
var { buildMockDispatch } = require_mock_utils();
|
|
69019
69019
|
var {
|
|
@@ -69053,7 +69053,7 @@ var require_mock_pool = __commonJS({
|
|
|
69053
69053
|
return new MockInterceptor(opts, this[kDispatches]);
|
|
69054
69054
|
}
|
|
69055
69055
|
async [kClose]() {
|
|
69056
|
-
await
|
|
69056
|
+
await promisify2(this[kOriginalClose])();
|
|
69057
69057
|
this[kConnected] = 0;
|
|
69058
69058
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
69059
69059
|
}
|
|
@@ -82042,6 +82042,50 @@ Return this exact shape:
|
|
|
82042
82042
|
}
|
|
82043
82043
|
});
|
|
82044
82044
|
|
|
82045
|
+
// package.json
|
|
82046
|
+
var require_package = __commonJS({
|
|
82047
|
+
"package.json"(exports2, module2) {
|
|
82048
|
+
module2.exports = {
|
|
82049
|
+
name: "sproutkit-code",
|
|
82050
|
+
version: "0.1.2",
|
|
82051
|
+
description: "Sproutkit in your terminal \u2014 find leads, build sites, run outreach, all via chat.",
|
|
82052
|
+
bin: {
|
|
82053
|
+
sproutkit: "./dist/index.js"
|
|
82054
|
+
},
|
|
82055
|
+
type: "commonjs",
|
|
82056
|
+
files: [
|
|
82057
|
+
"dist",
|
|
82058
|
+
"README.md"
|
|
82059
|
+
],
|
|
82060
|
+
engines: {
|
|
82061
|
+
node: ">=18"
|
|
82062
|
+
},
|
|
82063
|
+
keywords: [
|
|
82064
|
+
"sproutkit",
|
|
82065
|
+
"leads",
|
|
82066
|
+
"websites",
|
|
82067
|
+
"cli",
|
|
82068
|
+
"ai"
|
|
82069
|
+
],
|
|
82070
|
+
scripts: {
|
|
82071
|
+
dev: "tsc && node dist/index.js",
|
|
82072
|
+
build: "node build.mjs && chmod +x dist/index.js",
|
|
82073
|
+
typecheck: "tsc --noEmit",
|
|
82074
|
+
prepublishOnly: "cd ../desktop && npm run build:main && cd ../sproutkit-code && npm run build"
|
|
82075
|
+
},
|
|
82076
|
+
dependencies: {
|
|
82077
|
+
"@anthropic-ai/sdk": "^0.30.1",
|
|
82078
|
+
axios: "^1.7.1",
|
|
82079
|
+
"node-sqlite3-wasm": "^0.8.20"
|
|
82080
|
+
},
|
|
82081
|
+
devDependencies: {
|
|
82082
|
+
"@types/node": "^20.14.0",
|
|
82083
|
+
typescript: "^5.4.0"
|
|
82084
|
+
}
|
|
82085
|
+
};
|
|
82086
|
+
}
|
|
82087
|
+
});
|
|
82088
|
+
|
|
82045
82089
|
// src/engine.ts
|
|
82046
82090
|
var db = require_db();
|
|
82047
82091
|
var chat = require_chat();
|
|
@@ -82449,11 +82493,86 @@ async function runTurn(userMessage) {
|
|
|
82449
82493
|
}
|
|
82450
82494
|
}
|
|
82451
82495
|
|
|
82496
|
+
// src/update.ts
|
|
82497
|
+
var import_child_process = require("child_process");
|
|
82498
|
+
var import_util = require("util");
|
|
82499
|
+
var execFileP = (0, import_util.promisify)(import_child_process.execFile);
|
|
82500
|
+
var PKG = "sproutkit-code";
|
|
82501
|
+
var CURRENT_VERSION = require_package().version;
|
|
82502
|
+
async function latestOnRegistry() {
|
|
82503
|
+
try {
|
|
82504
|
+
const r = await fetch(`https://registry.npmjs.org/${PKG}/latest`, {
|
|
82505
|
+
signal: AbortSignal.timeout(5e3)
|
|
82506
|
+
});
|
|
82507
|
+
if (!r.ok) return null;
|
|
82508
|
+
const j = await r.json();
|
|
82509
|
+
return j.version ?? null;
|
|
82510
|
+
} catch {
|
|
82511
|
+
return null;
|
|
82512
|
+
}
|
|
82513
|
+
}
|
|
82514
|
+
function isNewer(a, b) {
|
|
82515
|
+
const pa = a.split(".").map(Number);
|
|
82516
|
+
const pb = b.split(".").map(Number);
|
|
82517
|
+
for (let i = 0; i < 3; i++) {
|
|
82518
|
+
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return true;
|
|
82519
|
+
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return false;
|
|
82520
|
+
}
|
|
82521
|
+
return false;
|
|
82522
|
+
}
|
|
82523
|
+
async function runUpdate() {
|
|
82524
|
+
say(c.dim(` Current version ${CURRENT_VERSION}. Checking npm\u2026`));
|
|
82525
|
+
const latest = await latestOnRegistry();
|
|
82526
|
+
if (!latest) {
|
|
82527
|
+
say(c.amber(" Couldn't reach npm. Check your connection and try again."));
|
|
82528
|
+
return;
|
|
82529
|
+
}
|
|
82530
|
+
if (!isNewer(latest, CURRENT_VERSION)) {
|
|
82531
|
+
say(c.green(` \u2713 You're on the latest version (${CURRENT_VERSION}).`));
|
|
82532
|
+
return;
|
|
82533
|
+
}
|
|
82534
|
+
say(c.dim(` Updating ${CURRENT_VERSION} \u2192 ${latest}\u2026`));
|
|
82535
|
+
try {
|
|
82536
|
+
await execFileP("npm", ["install", "-g", `${PKG}@latest`], { timeout: 12e4 });
|
|
82537
|
+
say(c.green(` \u2713 Updated to ${latest}. Restart sproutkit to use it.`));
|
|
82538
|
+
} catch (e) {
|
|
82539
|
+
say(c.red(` Update failed: ${e.message}`));
|
|
82540
|
+
say(c.dim(` Try manually: npm install -g ${PKG}@latest`));
|
|
82541
|
+
}
|
|
82542
|
+
}
|
|
82543
|
+
async function notifyIfOutdated() {
|
|
82544
|
+
try {
|
|
82545
|
+
const last = Number(getSetting("update_checked_at") ?? 0);
|
|
82546
|
+
if (Date.now() - last < 24 * 60 * 60 * 1e3) return;
|
|
82547
|
+
setSetting("update_checked_at", String(Date.now()));
|
|
82548
|
+
const latest = await latestOnRegistry();
|
|
82549
|
+
if (latest && isNewer(latest, CURRENT_VERSION)) {
|
|
82550
|
+
say(
|
|
82551
|
+
c.amber(
|
|
82552
|
+
` \u2191 Update available: ${CURRENT_VERSION} \u2192 ${latest}. Run 'sproutkit update'.`
|
|
82553
|
+
)
|
|
82554
|
+
);
|
|
82555
|
+
say();
|
|
82556
|
+
}
|
|
82557
|
+
} catch {
|
|
82558
|
+
}
|
|
82559
|
+
}
|
|
82560
|
+
|
|
82452
82561
|
// src/index.ts
|
|
82453
82562
|
process.env.SPROUTKIT_HEADLESS = "1";
|
|
82454
82563
|
async function main() {
|
|
82455
82564
|
const arg = process.argv[2];
|
|
82456
82565
|
initDatabase();
|
|
82566
|
+
if (arg === "update") {
|
|
82567
|
+
await runUpdate();
|
|
82568
|
+
closeTty();
|
|
82569
|
+
return;
|
|
82570
|
+
}
|
|
82571
|
+
if (arg === "version" || arg === "--version" || arg === "-v") {
|
|
82572
|
+
say(CURRENT_VERSION);
|
|
82573
|
+
closeTty();
|
|
82574
|
+
return;
|
|
82575
|
+
}
|
|
82457
82576
|
if (arg === "setup") {
|
|
82458
82577
|
await runOnboarding(true);
|
|
82459
82578
|
closeTty();
|
|
@@ -82465,7 +82584,9 @@ async function main() {
|
|
|
82465
82584
|
say(" Find leads, build sites and run outreach from your terminal.");
|
|
82466
82585
|
say();
|
|
82467
82586
|
say(` ${c.bold("sproutkit")} start the chat`);
|
|
82468
|
-
say(` ${c.bold("sproutkit setup")} set or update your
|
|
82587
|
+
say(` ${c.bold("sproutkit setup")} set or update your keys and licence`);
|
|
82588
|
+
say(` ${c.bold("sproutkit update")} update to the latest version`);
|
|
82589
|
+
say(` ${c.bold("sproutkit version")} show the installed version`);
|
|
82469
82590
|
say(` ${c.bold('sproutkit "..."')} run a single message and exit`);
|
|
82470
82591
|
say();
|
|
82471
82592
|
say(c.dim(" In chat: type a request, Ctrl+C to quit. Actions that spend money ask y/N first."));
|
|
@@ -82491,6 +82612,7 @@ async function main() {
|
|
|
82491
82612
|
closeTty();
|
|
82492
82613
|
return;
|
|
82493
82614
|
}
|
|
82615
|
+
await notifyIfOutdated();
|
|
82494
82616
|
say(c.dim(" Chat with Sproutkit. Type a request, or 'exit' to quit."));
|
|
82495
82617
|
say();
|
|
82496
82618
|
while (true) {
|