@useavalon/caelence-agent 0.1.0 → 0.1.1-canary.1

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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -137
  3. package/brand/logo/favicon-agent-bg-16.svg +7 -0
  4. package/brand/logo/favicon-agent-bg-32.svg +7 -0
  5. package/brand/previews/desktop-chat.png +0 -0
  6. package/brand/previews/desktop-commands.png +0 -0
  7. package/brand/previews/desktop-integrations.png +0 -0
  8. package/brand/previews/desktop-skills.png +0 -0
  9. package/package.json +5 -3
  10. package/skills/impeccable/LICENSE +13 -0
  11. package/skills/impeccable/NOTICE +14 -0
  12. package/skills/impeccable/SKILL.md +2 -1
  13. package/src/agent-cwd.ts +51 -0
  14. package/src/cli/agent-cwd.test.ts +65 -0
  15. package/src/cli/main.test.ts +5 -0
  16. package/src/cli/main.ts +282 -201
  17. package/src/cli/picker.test.ts +59 -1
  18. package/src/cli/picker.ts +46 -0
  19. package/src/cli/slash-dispatch.test.ts +116 -7
  20. package/src/cli/slash-dispatch.ts +343 -174
  21. package/src/cli/slash.test.ts +25 -2
  22. package/src/cli/slash.ts +37 -8
  23. package/src/cli/theme.test.ts +7 -0
  24. package/src/cli/theme.ts +6 -6
  25. package/src/cli/tui.tsx +385 -217
  26. package/src/config.ts +1 -1
  27. package/src/core/strands.ts +10 -1
  28. package/src/desktop/bridge.test.ts +56 -1
  29. package/src/desktop/bridge.ts +527 -390
  30. package/src/desktop/uploads.test.ts +57 -0
  31. package/src/desktop/uploads.ts +92 -0
  32. package/src/index.ts +26 -2
  33. package/src/init.test.ts +19 -2
  34. package/src/init.ts +25 -17
  35. package/src/integrations/loopback.test.ts +17 -0
  36. package/src/integrations/loopback.ts +91 -0
  37. package/src/observability/prompts.ts +1 -1
  38. package/src/product.ts +3 -1
  39. package/src/runtime.test.ts +24 -0
  40. package/src/runtime.ts +48 -5
  41. package/src/skills/catalog.test.ts +188 -0
  42. package/src/skills/catalog.ts +279 -0
  43. package/src/skills/disabled.test.ts +27 -0
  44. package/src/skills/disabled.ts +59 -0
  45. package/src/skills/loader.test.ts +31 -0
  46. package/src/skills/loader.ts +31 -4
  47. package/src/skills/registry.test.ts +64 -3
  48. package/src/skills/registry.ts +248 -93
  49. package/src/skills/skill-command.ts +2 -0
package/src/cli/picker.ts CHANGED
@@ -46,3 +46,49 @@ export function stepIndex(index: number, count: number, delta: number): number {
46
46
  if (count <= 0) return 0;
47
47
  return (index + delta + count) % count;
48
48
  }
49
+
50
+ export const PICKER_PAGE = 8;
51
+ /** Header, picker title, hint, and vertical margins. */
52
+ export const PICKER_RESERVED_ROWS = 6;
53
+
54
+ /** How many picker rows fit in the terminal after chrome. */
55
+ export function pickerVisibleRows(terminalRows: number): number {
56
+ return Math.max(4, terminalRows - PICKER_RESERVED_ROWS);
57
+ }
58
+
59
+ /** Visible slice of a long picker, keeping the selected row on screen. */
60
+ export function pickerPage<T>(
61
+ items: T[],
62
+ index: number,
63
+ size = PICKER_PAGE,
64
+ ): { items: T[]; offset: number } {
65
+ if (items.length <= size) return { items, offset: 0 };
66
+ const clamped = Math.min(Math.max(index, 0), items.length - 1);
67
+ const start = Math.min(Math.max(0, clamped - Math.floor(size / 2)), items.length - size);
68
+ return { items: items.slice(start, start + size), offset: start };
69
+ }
70
+
71
+ type InkPickerKey = {
72
+ escape: boolean;
73
+ upArrow: boolean;
74
+ downArrow: boolean;
75
+ tab: boolean;
76
+ shift: boolean;
77
+ return: boolean;
78
+ };
79
+
80
+ /** Arrow keys arrive as ESC+[+A — treat movement before cancel. */
81
+ export function inkPickerNav(key: InkPickerKey): "esc" | "enter" | number | undefined {
82
+ if (key.upArrow || (key.tab && key.shift)) return -1;
83
+ if (key.downArrow || key.tab) return 1;
84
+ if (key.return) return "enter";
85
+ if (key.escape) return "esc";
86
+ return undefined;
87
+ }
88
+
89
+ /** Pad to width so Ink does not leave leftover cells from a longer previous row. */
90
+ export function paintPickerLine(text: string, width: number): string {
91
+ const max = Math.max(1, width);
92
+ const body = text.length > max ? `${text.slice(0, max - 1)}…` : text;
93
+ return body.padEnd(max, " ");
94
+ }
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import type { Session } from "../core/session.ts";
6
6
  import type { HarnessRuntime } from "../runtime.ts";
7
+ import { clearPopularSkillsCache, writePopularSkillsCache } from "../skills/catalog.ts";
7
8
  import { HARNESS_MODELS } from "./models.ts";
8
9
  import { applyPickerChoice, dispatchSlash, runSlashLine } from "./slash-dispatch.ts";
9
10
 
@@ -54,6 +55,9 @@ function fakeHarness(overrides: Partial<HarnessRuntime> = {}): HarnessRuntime {
54
55
  findSkills: async () => "frontend-design",
55
56
  addSkill: async () => ({ rel: "frontend-design/SKILL.md" }),
56
57
  removeSkill: () => ({ ok: true }),
58
+ disabledSkills: () => [],
59
+ enableSkill: () => ({ ok: true }),
60
+ reloadIntegrations: async () => {},
57
61
  chat: async () => "",
58
62
  observability: {} as HarnessRuntime["observability"],
59
63
  close() {},
@@ -153,7 +157,11 @@ describe("dispatchSlash", () => {
153
157
  const prevHome = process.env.HARNESS_HOME;
154
158
  process.env.HARNESS_HOME = home;
155
159
  try {
156
- const result = applyPickerChoice(fakeHarness(), "image", "google/gemini-2.5-flash-image");
160
+ const result = await applyPickerChoice(
161
+ fakeHarness(),
162
+ "image",
163
+ "google/gemini-2.5-flash-image",
164
+ );
157
165
  expect(result).toEqual({ kind: "applied" });
158
166
  } finally {
159
167
  if (prevHome === undefined) delete process.env.HARNESS_HOME;
@@ -162,18 +170,78 @@ describe("dispatchSlash", () => {
162
170
  }
163
171
  });
164
172
 
165
- test("mode picker stores the mode without a transcript line", () => {
173
+ test("mode picker stores the mode without a transcript line", async () => {
166
174
  const harness = fakeHarness({ mode: "ask" });
167
- const result = applyPickerChoice(harness, "mode", "agent");
175
+ const result = await applyPickerChoice(harness, "mode", "agent");
168
176
  expect(result).toEqual({ kind: "applied" });
169
177
  expect(harness.mode).toBe("agent");
170
178
  });
171
179
 
172
- test("runSlashLine lists the skill catalog on bare find", async () => {
173
- expect(await runSlashLine(fakeHarness(), "/skill find")).toEqual({
174
- kind: "text",
175
- text: "frontend-design",
180
+ test("skill picker adds a catalog skill and disables project skills", async () => {
181
+ const harness = fakeHarness();
182
+ const added = await applyPickerChoice(harness, "skill", "obra/superpowers@brainstorming");
183
+ expect(added).toEqual({ kind: "text", text: "Loaded frontend-design/SKILL.md" });
184
+ const already = await applyPickerChoice(harness, "skill", "bundled@copywriting");
185
+ expect(already).toEqual({ kind: "text", text: "Disabled copywriting" });
186
+ const userHarness = fakeHarness({
187
+ skills: [
188
+ {
189
+ name: "frontend-design",
190
+ source: "user",
191
+ catalogRef: "anthropics/skills@frontend-design",
192
+ },
193
+ ] as HarnessRuntime["skills"],
194
+ });
195
+ const removed = await applyPickerChoice(
196
+ userHarness,
197
+ "skill",
198
+ "anthropics/skills@frontend-design",
199
+ );
200
+ expect(removed).toEqual({ kind: "text", text: "Removed frontend-design" });
201
+ const disabledHarness = fakeHarness({
202
+ disabledSkills: () => ["copywriting"],
176
203
  });
204
+ const enabled = await applyPickerChoice(disabledHarness, "skill", "bundled@copywriting");
205
+ expect(enabled).toEqual({ kind: "text", text: "Enabled copywriting" });
206
+ });
207
+
208
+ test("runSlashLine opens a skill picker for empty find", async () => {
209
+ const home = await mkdtemp(join(tmpdir(), "harness-skill-find-"));
210
+ const prevHome = process.env.HARNESS_HOME;
211
+ process.env.HARNESS_HOME = home;
212
+ writePopularSkillsCache(
213
+ [{ id: "acme/pack/hello", name: "hello", source: "acme/pack", installs: 9 }],
214
+ process.env,
215
+ );
216
+ try {
217
+ const result = await runSlashLine(fakeHarness(), "/skill find");
218
+ expect(result.kind).toBe("picker");
219
+ if (result.kind === "picker") {
220
+ expect(result.picker).toBe("skill");
221
+ expect(result.title).toBe("Skills");
222
+ expect(result.items.some((item) => item.id === "bundled@copywriting")).toBe(true);
223
+ expect(result.items.some((item) => item.id === "acme/pack@hello")).toBe(true);
224
+ }
225
+ } finally {
226
+ clearPopularSkillsCache();
227
+ if (prevHome === undefined) delete process.env.HARNESS_HOME;
228
+ else process.env.HARNESS_HOME = prevHome;
229
+ await rm(home, { recursive: true, force: true });
230
+ }
231
+ const prevFetch = globalThis.fetch;
232
+ globalThis.fetch = (async () =>
233
+ new Response(JSON.stringify({ skills: [] }))) as unknown as typeof fetch;
234
+ try {
235
+ const result = await runSlashLine(fakeHarness(), "/skill find copywriting");
236
+ expect(result.kind).toBe("picker");
237
+ if (result.kind === "picker") {
238
+ expect(result.picker).toBe("skill");
239
+ expect(result.title).toBe("Skills · copywriting");
240
+ expect(result.items.some((item) => item.id === "bundled@copywriting")).toBe(true);
241
+ }
242
+ } finally {
243
+ globalThis.fetch = prevFetch;
244
+ }
177
245
  expect(await runSlashLine(fakeHarness(), "/ima")).toEqual({
178
246
  kind: "incomplete",
179
247
  draft: "/image ",
@@ -190,6 +258,47 @@ describe("dispatchSlash", () => {
190
258
  }
191
259
  });
192
260
 
261
+ test("integrations picker lists MCP servers", async () => {
262
+ const result = await dispatchSlash(fakeHarness(), "/integrations");
263
+ expect(result.kind).toBe("picker");
264
+ if (result.kind === "picker") {
265
+ expect(result.picker).toBe("integration");
266
+ expect(result.items.some((item) => item.id === "linear" && item.label === "Linear")).toBe(
267
+ true,
268
+ );
269
+ expect(result.items.find((item) => item.id === "linear")?.hint).toBe("connect");
270
+ }
271
+ const missing = await dispatchSlash(fakeHarness(), "/integrations not-a-server");
272
+ expect(missing).toEqual({ kind: "text", text: 'No integration "not-a-server".' });
273
+ });
274
+
275
+ test("integration picker disconnects a stored connection", async () => {
276
+ const home = await mkdtemp(join(tmpdir(), "harness-int-"));
277
+ const prevHome = process.env.HARNESS_HOME;
278
+ process.env.HARNESS_HOME = home;
279
+ try {
280
+ const { upsertConnection } = await import("../integrations/store.ts");
281
+ upsertConnection({
282
+ id: "linear",
283
+ label: "Linear",
284
+ mcpUrl: "https://mcp.linear.app/mcp",
285
+ accessToken: "tok",
286
+ connectedAt: "2026-01-01T00:00:00.000Z",
287
+ });
288
+ const listed = await dispatchSlash(fakeHarness(), "/integrations");
289
+ expect(listed.kind).toBe("picker");
290
+ if (listed.kind === "picker") {
291
+ expect(listed.items.find((item) => item.id === "linear")?.hint).toBe("on · disconnect");
292
+ }
293
+ const removed = await applyPickerChoice(fakeHarness(), "integration", "linear");
294
+ expect(removed).toEqual({ kind: "text", text: "Disconnected Linear" });
295
+ } finally {
296
+ if (prevHome === undefined) delete process.env.HARNESS_HOME;
297
+ else process.env.HARNESS_HOME = prevHome;
298
+ await rm(home, { recursive: true, force: true });
299
+ }
300
+ });
301
+
193
302
  test("clear starts a new session", async () => {
194
303
  let cleared = false;
195
304
  const result = await dispatchSlash(