@cargo-ai/cli 1.0.128 → 1.0.130
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/build/index.js +43 -9
- package/build/paletteLayout.d.ts +7 -0
- package/build/paletteLayout.d.ts.map +1 -1
- package/build/paletteLayout.js +19 -0
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { availableCodingAgents, BRAND, canRunPalette, creditsLeftOf, declareSources, fetchSubscription, fetchWorkspaceName, findProjectDir, formatWorkspaceSuffix, isInteractive, isUnpaidPlan, printSetupIssues, registerCommands as registerCdkCommands, runPalette, SessionExpiredError, } from "@cargo-ai/cdk/cli";
|
|
3
|
+
import { availableCodingAgents, BRAND, canRunPalette, creditsLeftOf, declareSources, fetchStateConnected, fetchSubscription, fetchWorkspaceName, findProjectDir, formatWorkspaceSuffix, isInteractive, isUnpaidPlan, printSetupIssues, registerCommands as registerCdkCommands, runPalette, SessionExpiredError, } from "@cargo-ai/cdk/cli";
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import { AGENT_SKILLS_HINT } from "./agentSkills.js";
|
|
6
6
|
import { createApi } from "./api.js";
|
|
@@ -308,7 +308,7 @@ async function openPalette(startPath) {
|
|
|
308
308
|
// Re-read after each command: signing in or out from inside the palette
|
|
309
309
|
// changes both what the setup line says and which rows are worth pinning.
|
|
310
310
|
// The cwd is re-tested too — a command can create a project in it.
|
|
311
|
-
const layoutFor = (
|
|
311
|
+
const layoutFor = (lookups) => {
|
|
312
312
|
// Read once: a layout describing two different directories could offer to
|
|
313
313
|
// deploy one and name the other.
|
|
314
314
|
const cwd = process.cwd();
|
|
@@ -318,7 +318,14 @@ async function openPalette(startPath) {
|
|
|
318
318
|
agents,
|
|
319
319
|
projectDir: root,
|
|
320
320
|
cwd,
|
|
321
|
-
unpaidPlan,
|
|
321
|
+
unpaidPlan: lookups.unpaidPlan,
|
|
322
|
+
// Only trusted for the project it was asked about: a command can `cd`
|
|
323
|
+
// the process or create a project, and an answer about another state
|
|
324
|
+
// would offer to connect one that is already connected.
|
|
325
|
+
stateConnected: lookups.stateConnected !== undefined &&
|
|
326
|
+
lookups.stateConnected.projectDir === root
|
|
327
|
+
? lookups.stateConnected.connected
|
|
328
|
+
: undefined,
|
|
322
329
|
});
|
|
323
330
|
};
|
|
324
331
|
await runPalette({
|
|
@@ -328,10 +335,17 @@ async function openPalette(startPath) {
|
|
|
328
335
|
title: chrome.title,
|
|
329
336
|
issues: collectIssues(),
|
|
330
337
|
refreshIssues: collectIssues,
|
|
331
|
-
// First paint reuses the
|
|
332
|
-
layout: layoutFor(chrome
|
|
333
|
-
// After a command the plan can change (sign-in, upgrade)
|
|
334
|
-
|
|
338
|
+
// First paint reuses the lookups already made for the title.
|
|
339
|
+
layout: layoutFor(chrome),
|
|
340
|
+
// After a command the plan can change (sign-in, upgrade), and so can the
|
|
341
|
+
// state (the command may have been the connect); look both up again.
|
|
342
|
+
refreshLayout: async () => {
|
|
343
|
+
const [unpaidPlan, stateConnected] = await Promise.all([
|
|
344
|
+
resolveUnpaidPlan(),
|
|
345
|
+
resolveStateConnected(),
|
|
346
|
+
]);
|
|
347
|
+
return layoutFor({ unpaidPlan, stateConnected });
|
|
348
|
+
},
|
|
335
349
|
});
|
|
336
350
|
}
|
|
337
351
|
/**
|
|
@@ -342,19 +356,39 @@ async function openPalette(startPath) {
|
|
|
342
356
|
async function paletteChrome() {
|
|
343
357
|
const base = `${BRAND} cargo-ai ${version}`;
|
|
344
358
|
if (isSignedIn() === false) {
|
|
345
|
-
return { title: base, unpaidPlan: false };
|
|
359
|
+
return { title: base, unpaidPlan: false, stateConnected: undefined };
|
|
346
360
|
}
|
|
347
361
|
const api = getApi();
|
|
348
|
-
|
|
362
|
+
// The state lookup rides alongside the two the title already waits for, so
|
|
363
|
+
// it adds no round-trip of its own to the first paint.
|
|
364
|
+
const [name, subscription, stateConnected] = await Promise.all([
|
|
349
365
|
fetchWorkspaceName(api),
|
|
350
366
|
fetchSubscription(api),
|
|
367
|
+
resolveStateConnected(),
|
|
351
368
|
]);
|
|
352
369
|
const creditsLeft = subscription === undefined ? undefined : creditsLeftOf(subscription);
|
|
353
370
|
return {
|
|
354
371
|
title: `${base}${formatWorkspaceSuffix(name, creditsLeft)}`,
|
|
355
372
|
unpaidPlan: subscription === undefined ? false : isUnpaidPlan(subscription),
|
|
373
|
+
stateConnected,
|
|
356
374
|
};
|
|
357
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Best-effort, like the plan: whether the project the palette is standing in
|
|
378
|
+
* deploys from GitHub. Undefined outside a project, signed out, or when the
|
|
379
|
+
* lookup could not tell, all of which leave "Connect to GitHub" unpinned.
|
|
380
|
+
*/
|
|
381
|
+
async function resolveStateConnected() {
|
|
382
|
+
if (isSignedIn() === false) {
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
const projectDir = findProjectDir(process.cwd());
|
|
386
|
+
if (projectDir === undefined) {
|
|
387
|
+
return undefined;
|
|
388
|
+
}
|
|
389
|
+
const connected = await fetchStateConnected(getApi(), projectDir);
|
|
390
|
+
return connected === undefined ? undefined : { projectDir, connected };
|
|
391
|
+
}
|
|
358
392
|
/**
|
|
359
393
|
* Best-effort: true only when we can see an Orb $0 plan. A failed lookup or a
|
|
360
394
|
* signed-out session leaves the pin off rather than guessing.
|
package/build/paletteLayout.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ export type PaletteLayoutInput = {
|
|
|
15
15
|
* false leaves it in the last section only.
|
|
16
16
|
*/
|
|
17
17
|
unpaidPlan?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the project's deploy state is connected to its GitHub repository.
|
|
20
|
+
* Only `false` pins "Connect to GitHub": undefined means the lookup could not
|
|
21
|
+
* say (no state yet, offline, timed out), and a row offered on a guess is a
|
|
22
|
+
* row that fails when picked.
|
|
23
|
+
*/
|
|
24
|
+
stateConnected?: boolean;
|
|
18
25
|
};
|
|
19
26
|
export declare function buildPaletteLayout(input: PaletteLayoutInput): PaletteLayout;
|
|
20
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paletteLayout.d.ts","sourceRoot":"","sources":["../src/paletteLayout.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"paletteLayout.d.ts","sourceRoot":"","sources":["../src/paletteLayout.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAgF3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/B,mFAAmF;IACnF,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAS3E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,EAAE,CAmFjE"}
|
package/build/paletteLayout.js
CHANGED
|
@@ -16,6 +16,7 @@ const CODE = " code";
|
|
|
16
16
|
const ADD = " add";
|
|
17
17
|
const DEPLOY = " deploy";
|
|
18
18
|
const BOOK_DEMO = " book-demo";
|
|
19
|
+
const CONNECT = " connect";
|
|
19
20
|
/**
|
|
20
21
|
* `start` runs most of these; the pinned row is the shortcut to one of them.
|
|
21
22
|
* The exceptions are "Add" and "Deploy", which run `project add` and `project
|
|
@@ -139,7 +140,25 @@ export function pinnedRows(input) {
|
|
|
139
140
|
},
|
|
140
141
|
]
|
|
141
142
|
: [];
|
|
143
|
+
// Above everything, even Ask: a project deployed from a laptop has no review
|
|
144
|
+
// and no record of who changed what, and the step that fixes that is one
|
|
145
|
+
// command nobody guesses the name of. It disappears once taken (the layout
|
|
146
|
+
// is rebuilt after every command), so it is never a permanent tenant of the
|
|
147
|
+
// top row.
|
|
148
|
+
const connectRow = input.projectDir !== undefined && input.stateConnected === false
|
|
149
|
+
? [
|
|
150
|
+
{
|
|
151
|
+
value: CONNECT,
|
|
152
|
+
label: "Connect to GitHub",
|
|
153
|
+
hint: "review every change in a pull request; merging deploys",
|
|
154
|
+
// `--dir` for the same reason as Add and Deploy: connect the
|
|
155
|
+
// project the palette found, not whatever the cwd happens to be.
|
|
156
|
+
argv: ["project", "state", "connect", "--dir", input.projectDir],
|
|
157
|
+
},
|
|
158
|
+
]
|
|
159
|
+
: [];
|
|
142
160
|
return [
|
|
161
|
+
...connectRow,
|
|
143
162
|
{
|
|
144
163
|
value: ASK,
|
|
145
164
|
label: "Ask Cargo",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.130",
|
|
4
4
|
"mcpName": "io.github.getcargohq/cargo",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@ai-sdk/harness-claude-code": "1.0.148",
|
|
77
77
|
"@cargo-ai/api": "^1.0.101",
|
|
78
78
|
"@cargo-ai/app-sdk": "^1.0.11",
|
|
79
|
-
"@cargo-ai/cdk": "^1.0.
|
|
79
|
+
"@cargo-ai/cdk": "^1.0.123",
|
|
80
80
|
"@cargo-ai/types": "^1.0.103",
|
|
81
81
|
"@cargo-ai/utils": "^1.0.35",
|
|
82
82
|
"@cargo-ai/worker-sdk": "^1.0.21",
|