@cargo-ai/cli 1.0.77 → 1.0.80
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/README.md +12 -0
- package/build/commands/ai/chat.d.ts.map +1 -1
- package/build/commands/ai/chat.js +6 -0
- package/build/commands/ai/message.d.ts.map +1 -1
- package/build/commands/ai/message.js +10 -0
- package/build/commands/ai/release.d.ts.map +1 -1
- package/build/commands/ai/release.js +29 -2
- package/build/commands/ask/argvFlags.d.ts +18 -0
- package/build/commands/ask/argvFlags.d.ts.map +1 -0
- package/build/commands/ask/argvFlags.js +46 -0
- package/build/commands/ask/artifacts.d.ts +2 -0
- package/build/commands/ask/artifacts.d.ts.map +1 -0
- package/build/commands/ask/artifacts.js +100 -0
- package/build/commands/ask/binding.d.ts +13 -0
- package/build/commands/ask/binding.d.ts.map +1 -0
- package/build/commands/ask/binding.js +19 -0
- package/build/commands/ask/claudeConfig.d.ts +23 -0
- package/build/commands/ask/claudeConfig.d.ts.map +1 -0
- package/build/commands/ask/claudeConfig.js +33 -0
- package/build/commands/ask/completer.d.ts +48 -0
- package/build/commands/ask/completer.d.ts.map +1 -0
- package/build/commands/ask/completer.js +217 -0
- package/build/commands/ask/history.d.ts +32 -0
- package/build/commands/ask/history.d.ts.map +1 -0
- package/build/commands/ask/history.js +122 -0
- package/build/commands/ask/index.d.ts +14 -0
- package/build/commands/ask/index.d.ts.map +1 -0
- package/build/commands/ask/index.js +111 -0
- package/build/commands/ask/localHarness.d.ts +225 -0
- package/build/commands/ask/localHarness.d.ts.map +1 -0
- package/build/commands/ask/localHarness.js +1074 -0
- package/build/commands/ask/messageStream.d.ts +33 -0
- package/build/commands/ask/messageStream.d.ts.map +1 -0
- package/build/commands/ask/messageStream.js +114 -0
- package/build/commands/ask/persist.d.ts +5 -0
- package/build/commands/ask/persist.d.ts.map +1 -0
- package/build/commands/ask/persist.js +31 -0
- package/build/commands/ask/pnpmShim.d.ts +20 -0
- package/build/commands/ask/pnpmShim.d.ts.map +1 -0
- package/build/commands/ask/pnpmShim.js +39 -0
- package/build/commands/ask/prompt.d.ts +20 -0
- package/build/commands/ask/prompt.d.ts.map +1 -0
- package/build/commands/ask/prompt.js +228 -0
- package/build/commands/ask/rewriteChatFlag.d.ts +9 -0
- package/build/commands/ask/rewriteChatFlag.d.ts.map +1 -0
- package/build/commands/ask/rewriteChatFlag.js +26 -0
- package/build/commands/ask/session.d.ts +94 -0
- package/build/commands/ask/session.d.ts.map +1 -0
- package/build/commands/ask/session.js +965 -0
- package/build/commands/ask/slash.d.ts +20 -0
- package/build/commands/ask/slash.d.ts.map +1 -0
- package/build/commands/ask/slash.js +73 -0
- package/build/commands/ask/state.d.ts +9 -0
- package/build/commands/ask/state.d.ts.map +1 -0
- package/build/commands/ask/state.js +18 -0
- package/build/commands/bookDemo.d.ts +14 -0
- package/build/commands/bookDemo.d.ts.map +1 -0
- package/build/commands/bookDemo.js +100 -0
- package/build/commands/runHandler.d.ts +9 -1
- package/build/commands/runHandler.d.ts.map +1 -1
- package/build/commands/runHandler.js +16 -1
- package/build/index.js +56 -18
- package/build/paletteLayout.d.ts +6 -1
- package/build/paletteLayout.d.ts.map +1 -1
- package/build/paletteLayout.js +35 -9
- package/build/utils/cdkState.d.ts +17 -4
- package/build/utils/cdkState.d.ts.map +1 -1
- package/build/utils/cdkState.js +26 -4
- package/build/utils/loadCompiledAgent.d.ts.map +1 -1
- package/build/utils/loadCompiledAgent.js +51 -11
- package/build/utils/prompt.d.ts.map +1 -1
- package/build/utils/prompt.js +4 -1
- package/package.json +8 -4
package/build/utils/cdkState.js
CHANGED
|
@@ -8,6 +8,7 @@ import { existsSync } from "node:fs";
|
|
|
8
8
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import { dependenciesOf, readState, resolveTokens } from "@cargo-ai/cdk";
|
|
11
|
+
import { cdkProjectDir, cdkProjectRoot } from "@cargo-ai/cdk/cli";
|
|
11
12
|
import { ExitCodes, failWith } from "../commands/runHandler.js";
|
|
12
13
|
// Peel the extra interop layer tsx adds when a TS source is transpiled to CJS:
|
|
13
14
|
// the ESM namespace's `default` is then the CJS `module.exports`
|
|
@@ -27,10 +28,10 @@ export function resolveDefaultExport(mod) {
|
|
|
27
28
|
* Load a `.ts`/`.js` module through the tsx ESM loader (so `.ts` sources and
|
|
28
29
|
* their imports of `@cargo-ai/*` / `zod` are transpiled on the fly) and return
|
|
29
30
|
* its resolved default export. Shared by both `--file` loaders: the workflow
|
|
30
|
-
* loader validates the result as a compiled workflow; the agent loader reads
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* loader validates the result as a compiled workflow; the agent loader reads
|
|
32
|
+
* the exported handle to learn which agent the file declares, then loads the
|
|
33
|
+
* whole project for the nodes. `subject` labels the file in errors (e.g.
|
|
34
|
+
* "Workflow", "Agent").
|
|
34
35
|
*/
|
|
35
36
|
export async function importModuleDefault(file, subject) {
|
|
36
37
|
const absPath = isAbsolute(file) ? file : resolve(process.cwd(), file);
|
|
@@ -49,6 +50,27 @@ export async function importModuleDefault(file, subject) {
|
|
|
49
50
|
}
|
|
50
51
|
return { absPath, defaultExport: resolveDefaultExport(mod) };
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The CDK project directory a `--file` module belongs to — the directory `cdk
|
|
55
|
+
* plan` and `cdk deploy` run in, which is what a harness agent's inferred
|
|
56
|
+
* `rootDirectory` is measured from. Walk up to the repo, then back down to the
|
|
57
|
+
* project (`infra/` in a scaffolded repo); a file in no recognisable project
|
|
58
|
+
* answers its own directory.
|
|
59
|
+
*
|
|
60
|
+
* Deliberately NOT the nearest cargo.state.json. That file's position is
|
|
61
|
+
* incidental — a repo deployed before `cdk deploy` ran from the project has one
|
|
62
|
+
* at the repo root — so measuring from it would report no `rootDirectory` and
|
|
63
|
+
* clone the repo root, while the deployed agent clones `infra/`.
|
|
64
|
+
*/
|
|
65
|
+
export function cdkProjectDirFor(file) {
|
|
66
|
+
const absPath = isAbsolute(file) ? file : resolve(process.cwd(), file);
|
|
67
|
+
const fileDir = dirname(absPath);
|
|
68
|
+
const repoRoot = cdkProjectRoot(fileDir);
|
|
69
|
+
if (repoRoot === undefined)
|
|
70
|
+
return fileDir;
|
|
71
|
+
const project = cdkProjectDir(repoRoot);
|
|
72
|
+
return project === undefined ? repoRoot : project;
|
|
73
|
+
}
|
|
52
74
|
// Walk up from `startDir` looking for a directory that holds cargo.state.json.
|
|
53
75
|
function findStateRoot(startDir) {
|
|
54
76
|
let dir = startDir;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadCompiledAgent.d.ts","sourceRoot":"","sources":["../../src/utils/loadCompiledAgent.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"loadCompiledAgent.d.ts","sourceRoot":"","sources":["../../src/utils/loadCompiledAgent.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,aAAa,EAKnB,MAAM,eAAe,CAAC;AAUvB,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA8CnD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAkF5E;AAQD,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,MAAM,GACX,aAAa,CAQf"}
|
|
@@ -7,15 +7,27 @@
|
|
|
7
7
|
// (`compileAgent`); `resolveCompiledAgentFromState` then resolves the
|
|
8
8
|
// `@cargo-ai/cdk` handle tokens it still carries to real uuids from
|
|
9
9
|
// cargo.state.json — a faithful test of the agent's core chat behaviour.
|
|
10
|
-
import { compileAgent,
|
|
10
|
+
import { bindHarnessRepositories, compileAgent, loadResourcesCollecting, resetRegistry, } from "@cargo-ai/cdk";
|
|
11
|
+
import { inDirectory } from "@cargo-ai/cdk/cli";
|
|
11
12
|
import { ExitCodes, failWith } from "../commands/runHandler.js";
|
|
12
|
-
import { importModuleDefault, resolveTokensFromState } from "./cdkState.js";
|
|
13
|
+
import { cdkProjectDirFor, importModuleDefault, resolveTokensFromState, } from "./cdkState.js";
|
|
13
14
|
function isAgentHandle(value) {
|
|
14
15
|
if (value === null || typeof value !== "object")
|
|
15
16
|
return false;
|
|
16
17
|
const v = value;
|
|
17
18
|
return v["resource"] === "agent" && typeof v["slug"] === "string";
|
|
18
19
|
}
|
|
20
|
+
// Files the project load could not import, appended to a failure that a missing
|
|
21
|
+
// resource explains — the connector this agent needs may be in one of them.
|
|
22
|
+
function loadErrorContext(errors) {
|
|
23
|
+
if (errors.length === 0)
|
|
24
|
+
return [];
|
|
25
|
+
return [
|
|
26
|
+
"",
|
|
27
|
+
"Some project files failed to load, which may be why:",
|
|
28
|
+
...errors.map((error) => ` ${error.file}: ${error.message}`),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
19
31
|
// Agent config an inline message can't express — rejected up front (rather than
|
|
20
32
|
// silently dropped) so a test run is never quietly less than the deployed agent.
|
|
21
33
|
// Each entry: the spec field, and whether the stored value means "set".
|
|
@@ -34,24 +46,52 @@ const UNSUPPORTED = [
|
|
|
34
46
|
},
|
|
35
47
|
];
|
|
36
48
|
// Load a `defineAgent` module and lower it to a `CompiledAgent` (tokens still
|
|
37
|
-
// embedded — resolve them with `resolveCompiledAgentFromState`).
|
|
38
|
-
// first so a stale registry (e.g. a prior load in the same process) can't leak
|
|
39
|
-
// resources into this one.
|
|
49
|
+
// embedded — resolve them with `resolveCompiledAgentFromState`).
|
|
40
50
|
export async function loadCompiledAgent(file) {
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
51
|
+
// The import below answers only WHICH agent this file exports; the resources
|
|
52
|
+
// come from the project load further down. Reset first anyway, so a prior
|
|
53
|
+
// load in the same process can't leak into either.
|
|
44
54
|
resetRegistry();
|
|
45
55
|
const { absPath, defaultExport: handle } = await importModuleDefault(file, "Agent");
|
|
46
56
|
if (!isAgentHandle(handle)) {
|
|
47
57
|
failWith("Agent module must `export default` an agent handle (the value returned by defineAgent()).", { code: ExitCodes.InvalidUsage });
|
|
48
58
|
}
|
|
59
|
+
// Re-load the WHOLE project, not just this file. The harness binding needs
|
|
60
|
+
// the project's GitHub connector to bind an omitted `repository`, and a
|
|
61
|
+
// scaffolded repo declares that connector in its own file — invisible to a
|
|
62
|
+
// single-module import, which would fail as though the project declared none.
|
|
63
|
+
//
|
|
64
|
+
// Safe to load after the import above: the loader resets the registry and
|
|
65
|
+
// cache-busts every entry file (`?cdk=<pass>`), so this file's `define*`
|
|
66
|
+
// calls run again and re-register. Errors are collected rather than thrown so
|
|
67
|
+
// one unrelated broken file can't block a test chat.
|
|
68
|
+
//
|
|
69
|
+
// Load standing IN the project: resources that resolve paths from cwd — the
|
|
70
|
+
// scaffold's `defineContext({ dir: "../context" })` — fail when invoked from
|
|
71
|
+
// the repo root.
|
|
72
|
+
const projectDir = cdkProjectDirFor(absPath);
|
|
73
|
+
const project = await inDirectory(projectDir, () => loadResourcesCollecting(projectDir));
|
|
74
|
+
// Fill an omitted harness `repository` from the checkout, the same pass
|
|
75
|
+
// `cdk plan`/`deploy` run — so a test message clones what the deployed agent
|
|
76
|
+
// would, instead of silently getting an empty sandbox.
|
|
77
|
+
const bound = await bindHarnessRepositories(project.nodes, {
|
|
78
|
+
dir: projectDir,
|
|
79
|
+
});
|
|
80
|
+
if (bound.errors.length > 0) {
|
|
81
|
+
failWith([
|
|
82
|
+
...bound.errors.map((error) => `${error.id}: ${error.message}`),
|
|
83
|
+
...loadErrorContext(project.errors),
|
|
84
|
+
].join("\n"), { code: ExitCodes.InvalidUsage });
|
|
85
|
+
}
|
|
49
86
|
// A file can register several agents (its sub-agents), so pick THE one it
|
|
50
87
|
// exports by slug rather than assuming a single registration.
|
|
51
|
-
const node =
|
|
88
|
+
const node = bound.nodes.find((n) => n.kind === "agent" && n.slug === handle.slug);
|
|
52
89
|
if (node === undefined) {
|
|
53
|
-
failWith(
|
|
54
|
-
"
|
|
90
|
+
failWith([
|
|
91
|
+
`Agent "${handle.slug}" was not registered by ${absPath}. Ensure the ` +
|
|
92
|
+
"module's default export is the handle returned by defineAgent().",
|
|
93
|
+
...loadErrorContext(project.errors),
|
|
94
|
+
].join("\n"), { code: ExitCodes.GenericError });
|
|
55
95
|
}
|
|
56
96
|
const setUnsupported = UNSUPPORTED.filter((u) => u.isSet(node.spec[u.field])).map((u) => u.label);
|
|
57
97
|
if (setUnsupported.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":";AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAMF,wBAAgB,eAAe,IAAI,WAAW,GAAG,SAAS,CAYzD;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,CAAC,cAAc,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":";AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAMF,wBAAgB,eAAe,IAAI,WAAW,GAAG,SAAS,CAYzD;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,CAAC,cAAc,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkB7B"}
|
package/build/utils/prompt.js
CHANGED
|
@@ -23,7 +23,10 @@ export function openPromptInput() {
|
|
|
23
23
|
* stderr so that piping stdout to `jq` keeps working.
|
|
24
24
|
*/
|
|
25
25
|
export async function askQuestion(input, question) {
|
|
26
|
-
const rl = readline.createInterface({
|
|
26
|
+
const rl = readline.createInterface({
|
|
27
|
+
input,
|
|
28
|
+
output: process.stderr,
|
|
29
|
+
});
|
|
27
30
|
try {
|
|
28
31
|
const answer = await rl.question(question);
|
|
29
32
|
const trimmed = answer.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.80",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://getcargo.ai",
|
|
@@ -64,13 +64,17 @@
|
|
|
64
64
|
"format:check": "prettier --check ."
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@
|
|
67
|
+
"@ai-sdk/harness": "^1.0.95",
|
|
68
|
+
"@ai-sdk/harness-claude-code": "^1.0.99",
|
|
69
|
+
"@cargo-ai/api": "^1.0.75",
|
|
68
70
|
"@cargo-ai/app-sdk": "^1.0.9",
|
|
69
|
-
"@cargo-ai/cdk": "^1.0.
|
|
70
|
-
"@cargo-ai/types": "^1.0.
|
|
71
|
+
"@cargo-ai/cdk": "^1.0.65",
|
|
72
|
+
"@cargo-ai/types": "^1.0.72",
|
|
71
73
|
"@cargo-ai/utils": "^1.0.28",
|
|
72
74
|
"@cargo-ai/worker-sdk": "^1.0.17",
|
|
73
75
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
76
|
+
"ai": "^7.0.84",
|
|
77
|
+
"ai-sdk-sandbox-local": "^0.1.2",
|
|
74
78
|
"commander": "^12.1.0",
|
|
75
79
|
"tsx": "^4.19.2",
|
|
76
80
|
"undici": "^7.29.0"
|