@getpawl/setup 1.3.7 → 1.4.0
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 +47 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,8 @@ async function main() {
|
|
|
15
15
|
if (arg === "sync") {
|
|
16
16
|
pawlSync(process.argv[3]);
|
|
17
17
|
} else if (arg === "connect") {
|
|
18
|
-
await pawlConnect();
|
|
18
|
+
const connected = await pawlConnect();
|
|
19
|
+
if (!connected) process.exit(1);
|
|
19
20
|
} else if (arg === "init") {
|
|
20
21
|
const rest = process.argv.slice(3);
|
|
21
22
|
const noConnect = rest.includes("--no-connect");
|
|
@@ -149,7 +150,7 @@ async function pawlConnect() {
|
|
|
149
150
|
const cwd = process.cwd();
|
|
150
151
|
if (!(0, import_node_fs.existsSync)((0, import_node_path.join)(cwd, ".pawl"))) {
|
|
151
152
|
console.error("Error: .pawl/ not found \u2014 run `pawl init` first.");
|
|
152
|
-
|
|
153
|
+
return null;
|
|
153
154
|
}
|
|
154
155
|
const apiUrl = DEFAULT_API_URL;
|
|
155
156
|
const code = generateCode();
|
|
@@ -161,7 +162,7 @@ async function pawlConnect() {
|
|
|
161
162
|
});
|
|
162
163
|
if (!startRes.ok) {
|
|
163
164
|
console.error("Error: Could not start connect session. Is the API reachable?");
|
|
164
|
-
|
|
165
|
+
return null;
|
|
165
166
|
}
|
|
166
167
|
const connectUrl = `https://app.getpawl.dev/connect?code=${code}&repo=${encodeURIComponent(repoName)}`;
|
|
167
168
|
console.log(`
|
|
@@ -173,7 +174,7 @@ async function pawlConnect() {
|
|
|
173
174
|
const result = await pollForKey(apiUrl, code);
|
|
174
175
|
if (!result) {
|
|
175
176
|
console.error(" Session expired or cancelled. Run `pawl connect` to try again.");
|
|
176
|
-
|
|
177
|
+
return null;
|
|
177
178
|
}
|
|
178
179
|
(0, import_node_fs.mkdirSync)((0, import_node_path.join)(cwd, ".pawl"), { recursive: true });
|
|
179
180
|
writePawlEnvFile(cwd, result);
|
|
@@ -183,6 +184,31 @@ async function pawlConnect() {
|
|
|
183
184
|
console.log(" Useful commands:");
|
|
184
185
|
console.log(" pawl sync --pull Pull latest context before starting work");
|
|
185
186
|
console.log(" pawl sync Push session data manually\n");
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
function getRepoUrl(cwd) {
|
|
190
|
+
try {
|
|
191
|
+
return (0, import_node_child_process.execSync)("git remote get-url origin", { cwd, stdio: "pipe" }).toString().trim();
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function autoBootstrap(projectId, apiKey, repoUrl, apiUrl) {
|
|
197
|
+
try {
|
|
198
|
+
const res = await fetch(`${apiUrl}/api/projects/${projectId}/bootstrap/cli-scan`, {
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers: {
|
|
201
|
+
"Content-Type": "application/json",
|
|
202
|
+
Authorization: `Bearer ${apiKey}`
|
|
203
|
+
},
|
|
204
|
+
body: JSON.stringify({ repoUrl })
|
|
205
|
+
});
|
|
206
|
+
if (!res.ok) return null;
|
|
207
|
+
const data = await res.json();
|
|
208
|
+
return { specsGenerated: data.specsGenerated, previewUrl: data.previewUrl };
|
|
209
|
+
} catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
186
212
|
}
|
|
187
213
|
function legacySetup(encoded) {
|
|
188
214
|
let config;
|
|
@@ -217,15 +243,15 @@ async function pawlInit(key, opts) {
|
|
|
217
243
|
migrateIfNeeded(cwd, detected.hasAgentMapDir);
|
|
218
244
|
(0, import_node_fs.mkdirSync)((0, import_node_path.join)(cwd, ".pawl"), { recursive: true });
|
|
219
245
|
if (key) {
|
|
220
|
-
let
|
|
246
|
+
let config2;
|
|
221
247
|
try {
|
|
222
248
|
const decoded = Buffer.from(key, "base64").toString("utf-8");
|
|
223
|
-
|
|
249
|
+
config2 = JSON.parse(decoded);
|
|
224
250
|
} catch {
|
|
225
251
|
console.error("Error: Invalid project key \u2014 could not decode.");
|
|
226
252
|
process.exit(1);
|
|
227
253
|
}
|
|
228
|
-
writePawlEnvFile(cwd,
|
|
254
|
+
writePawlEnvFile(cwd, config2);
|
|
229
255
|
}
|
|
230
256
|
writePawlSyncScript(cwd);
|
|
231
257
|
writePawlSyncMjs(cwd);
|
|
@@ -242,9 +268,22 @@ async function pawlInit(key, opts) {
|
|
|
242
268
|
writeAgentsMd(cwd);
|
|
243
269
|
updateGitignore(cwd);
|
|
244
270
|
printSummary(detected, !!key, !!opts?.noConnect);
|
|
271
|
+
let config = null;
|
|
245
272
|
if (!key && !opts?.noConnect) {
|
|
246
273
|
console.log("\nConnecting to Pawl dashboard...\n");
|
|
247
|
-
await pawlConnect();
|
|
274
|
+
config = await pawlConnect();
|
|
275
|
+
}
|
|
276
|
+
if (config) {
|
|
277
|
+
const repoUrl = getRepoUrl(cwd);
|
|
278
|
+
if (repoUrl) {
|
|
279
|
+
console.log("Scanning your repo to generate specs...");
|
|
280
|
+
const result = await autoBootstrap(config.projectId, config.apiKey, repoUrl, config.apiUrl);
|
|
281
|
+
if (result && result.specsGenerated > 0) {
|
|
282
|
+
console.log(` Generated ${result.specsGenerated} draft specs`);
|
|
283
|
+
console.log(` Review and confirm at: ${result.previewUrl}
|
|
284
|
+
`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
248
287
|
}
|
|
249
288
|
}
|
|
250
289
|
function detectAgents(cwd) {
|