@vellumai/cli 0.10.0-dev.202606230318.fd58ed1 → 0.10.0-dev.202606230727.0d65a6b

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.
@@ -69,6 +69,32 @@ describe("isActiveAssistant", () => {
69
69
  expect(isActiveAssistant([lockfilePath], "active")).toBe(true);
70
70
  });
71
71
 
72
+ test("returns true for the sole assistant when activeAssistant is empty", () => {
73
+ const dir = makeTempDir();
74
+ const lockfilePath = path.join(dir, "lockfile.json");
75
+ fs.writeFileSync(
76
+ lockfilePath,
77
+ JSON.stringify({
78
+ assistants: [{ assistantId: "only" }],
79
+ activeAssistant: null,
80
+ }),
81
+ );
82
+ expect(isActiveAssistant([lockfilePath], "only")).toBe(true);
83
+ });
84
+
85
+ test("returns true for the sole assistant when activeAssistant is stale", () => {
86
+ const dir = makeTempDir();
87
+ const lockfilePath = path.join(dir, "lockfile.json");
88
+ fs.writeFileSync(
89
+ lockfilePath,
90
+ JSON.stringify({
91
+ assistants: [{ assistantId: "only" }],
92
+ activeAssistant: "missing",
93
+ }),
94
+ );
95
+ expect(isActiveAssistant([lockfilePath], "only")).toBe(true);
96
+ });
97
+
72
98
  test("returns false for a non-active assistant", () => {
73
99
  const dir = makeTempDir();
74
100
  const lockfilePath = path.join(dir, "lockfile.json");
@@ -94,8 +94,15 @@ export function isActiveAssistant(
94
94
  ): boolean {
95
95
  for (const candidate of lockfilePaths) {
96
96
  try {
97
- const data = JSON.parse(fs.readFileSync(candidate, "utf-8")) as Record<string, unknown>;
98
- return data.activeAssistant === assistantId;
97
+ const data = JSON.parse(fs.readFileSync(candidate, "utf-8")) as Record<
98
+ string,
99
+ unknown
100
+ >;
101
+ if (data.activeAssistant === assistantId) return true;
102
+ const assistants = data.assistants;
103
+ if (!Array.isArray(assistants) || assistants.length !== 1) return false;
104
+ const [onlyAssistant] = assistants as Array<Record<string, unknown>>;
105
+ return onlyAssistant?.assistantId === assistantId;
99
106
  } catch {
100
107
  continue;
101
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/cli",
3
- "version": "0.10.0-dev.202606230318.fd58ed1",
3
+ "version": "0.10.0-dev.202606230727.0d65a6b",
4
4
  "description": "CLI tools for vellum-assistant",
5
5
  "type": "module",
6
6
  "exports": {