@useavalon/caelence-agent 0.1.1-canary.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 (44) hide show
  1. package/README.md +120 -32
  2. package/brand/logo/favicon-agent-bg-16.svg +7 -0
  3. package/brand/logo/favicon-agent-bg-32.svg +7 -0
  4. package/brand/previews/desktop-chat.png +0 -0
  5. package/brand/previews/desktop-commands.png +0 -0
  6. package/brand/previews/desktop-integrations.png +0 -0
  7. package/brand/previews/desktop-skills.png +0 -0
  8. package/package.json +3 -1
  9. package/skills/impeccable/LICENSE +13 -0
  10. package/skills/impeccable/NOTICE +14 -0
  11. package/skills/impeccable/SKILL.md +2 -1
  12. package/src/agent-cwd.ts +51 -0
  13. package/src/cli/agent-cwd.test.ts +65 -0
  14. package/src/cli/main.test.ts +5 -0
  15. package/src/cli/main.ts +282 -201
  16. package/src/cli/picker.test.ts +59 -1
  17. package/src/cli/picker.ts +46 -0
  18. package/src/cli/slash-dispatch.test.ts +116 -7
  19. package/src/cli/slash-dispatch.ts +343 -174
  20. package/src/cli/slash.test.ts +25 -2
  21. package/src/cli/slash.ts +37 -8
  22. package/src/cli/theme.test.ts +7 -0
  23. package/src/cli/theme.ts +6 -6
  24. package/src/cli/tui.tsx +385 -217
  25. package/src/config.ts +1 -1
  26. package/src/desktop/bridge.test.ts +24 -0
  27. package/src/desktop/bridge.ts +526 -395
  28. package/src/index.ts +26 -2
  29. package/src/init.test.ts +19 -2
  30. package/src/init.ts +25 -17
  31. package/src/integrations/loopback.test.ts +17 -0
  32. package/src/integrations/loopback.ts +91 -0
  33. package/src/observability/prompts.ts +1 -1
  34. package/src/product.ts +3 -1
  35. package/src/runtime.ts +48 -5
  36. package/src/skills/catalog.test.ts +188 -0
  37. package/src/skills/catalog.ts +279 -0
  38. package/src/skills/disabled.test.ts +27 -0
  39. package/src/skills/disabled.ts +59 -0
  40. package/src/skills/loader.test.ts +31 -0
  41. package/src/skills/loader.ts +31 -4
  42. package/src/skills/registry.test.ts +64 -3
  43. package/src/skills/registry.ts +248 -93
  44. package/src/skills/skill-command.ts +2 -0
package/README.md CHANGED
@@ -1,39 +1,46 @@
1
+ <p align="center">
2
+ <img src="brand/logo/favicon-agent-bg-32.svg" alt="Caelence agent" width="96" height="96" />
3
+ </p>
4
+
1
5
  # Caelence agent
2
6
 
3
- A coding agent you run in a project. Terminal UI, local tools, and skills you can add or remove.
7
+ A coding agent on this machine
8
+
9
+ Desktop app, or the terminal.
4
10
 
5
11
  [`@useavalon/caelence-agent`](https://www.npmjs.com/package/@useavalon/caelence-agent) on npm. Needs [Bun](https://bun.sh) 1.2 or later.
6
12
 
7
- ## Get started
13
+ ## Install
8
14
 
9
15
  ```bash
10
16
  bun add -g @useavalon/caelence-agent
11
- cd your-project
12
- bunx harness init
13
- export OPENROUTER_API_KEY=…
14
- harness
17
+ caelence desktop
15
18
  ```
16
19
 
17
- `bunx harness init` writes `harness.config.ts`, `AGENTS.md`, a sample skill, and a smoke eval. `harness` opens the terminal UI. `caelence-agent` is the same CLI.
20
+ `caelence desktop` opens the OS window. Paste an OpenRouter key in **Settings** after it opens. You do not need to export `OPENROUTER_API_KEY` in the terminal. The window needs [Rust](https://rustup.rs).
21
+
22
+ <p align="center">
23
+ <img src="brand/previews/desktop-chat.png" alt="Desktop chat" width="720" />
24
+ </p>
18
25
 
19
- As a library:
26
+ Or the terminal:
20
27
 
21
28
  ```bash
22
- bun add @useavalon/caelence-agent
29
+ caelence
23
30
  ```
24
31
 
25
- ```ts
26
- import { createHarness } from "@useavalon/caelence-agent";
27
- ```
32
+ `caelence` opens the terminal UI. Paste an OpenRouter key with `/settings key <token>`. In a git repo, that repo is the workspace. `--cwd` picks a folder. `caelence-agent` and `harness` are the same CLI.
28
33
 
29
34
  ## Config
30
35
 
36
+ Optional. Without `harness.config.ts`, these defaults apply.
37
+
31
38
  ```ts
32
39
  import type { HarnessConfig } from "@useavalon/caelence-agent";
33
40
 
34
41
  export default {
35
42
  name: "my-agent",
36
- model: "~x-ai/grok-latest",
43
+ model: "openrouter/auto",
37
44
  instructionsFile: "AGENTS.md",
38
45
  skillsDir: "skills",
39
46
  evalsDir: "evals",
@@ -51,44 +58,90 @@ export default {
51
58
  | `evals/<suite>/eval.ts` | Eval suites |
52
59
  | `AGENTS.md` | Project instructions |
53
60
  | `~/.harness/AGENTS.md` | User instructions for every project |
54
- | `.harness/sessions/` | Session logs (gitignored) |
61
+ | `.harness/sessions/` | Session logs |
62
+ | `~/.harness/integrations.json` | Connected hosted MCP servers |
55
63
 
56
- Set `OPENROUTER_API_KEY`. Optional: `OPENROUTER_MODEL`, `OPENROUTER_BASE_URL`. `/settings key <token>` stores a key in `~/.harness`.
64
+ Desktop Settings stores a key in `~/.harness`. Optional env: `OPENROUTER_API_KEY`, `OPENROUTER_MODEL`, `OPENROUTER_BASE_URL`. In the TUI, `/settings key <token>` does the same.
57
65
 
58
66
  ## Commands
59
67
 
60
68
  ```
61
- harness Terminal UI
62
- harness --mode plan Start in plan mode
63
- harness chat -m "…" One-shot turn
64
- harness eval [name] Run or list evals
65
- harness init Scaffold host files
66
- harness desktop Optional OS window (needs Rust)
69
+ caelence desktop Desktop window (needs Rust)
70
+ caelence Terminal UI
71
+ caelence chat -m "…" One turn, then exit (no TUI)
72
+ caelence --mode plan Start the TUI in plan mode
73
+ caelence eval [name] Run an eval suite, or list suites
74
+ caelence experiment Local website-generation regression (no Langfuse)
75
+ caelence init Add .harness/ to .gitignore
76
+ caelence skill find [query] Bundled skills and popular skills.sh
77
+ caelence skill add <src> Install into ~/.harness/skills
78
+ caelence skill remove <name> Uninstall a user skill, or disable a project skill
79
+ caelence help This list
67
80
  ```
68
81
 
69
- Type `/` in the terminal for the command list. Tab completes.
82
+ Flags: `--mode ask|plan|agent`, `--cwd <path>`, `-m` / `--message <text>`. `caelence init --examples` writes a host scaffold (`--name` sets the config name).
83
+
84
+ `caelence chat -m "…"` runs one turn, prints the reply (and tool lines), then exits. For a script or CI: no desktop, no TUI. `--mode` still applies. Without a TTY, tool approval is deny.
85
+
86
+ Type `/` for slash commands. Tab completes in the terminal UI.
87
+
88
+ <p align="center">
89
+ <img src="brand/previews/desktop-commands.png" alt="Desktop slash commands" width="720" />
90
+ </p>
70
91
 
71
92
  ```
72
- /skill find
73
- /skill add copywriting
74
- /skill add impeccable
75
- /skill add anthropics/skills@frontend-design
76
- /skill remove copywriting
93
+ /help this list
94
+ /skills loaded skills
95
+ /skill find [q] browse bundled and skills.sh
96
+ /skill add install a bundled or skills.sh skill
97
+ /skill new author a project skill
98
+ /skill remove remove a user skill
99
+ /integrations connect MCP servers
100
+ /eval [name] run an eval suite
101
+ /clear new session
102
+ /resume pick a session by title
103
+ /model pick a model
104
+ /mode ask, plan, or agent
105
+ /compact summarize earlier turns
106
+ /image [prompt] generate an image
107
+ /video [prompt] generate a clip
108
+ /transcribe speech to text model
109
+ /settings OpenRouter API key
110
+ /exit quit
77
111
  ```
78
112
 
79
113
  `/skill add --project <name>` writes into the project `skillsDir`. `/skill new <name> <what it should do>` authors a project skill from a brief.
80
114
 
81
115
  ## Skills
82
116
 
83
- Skills are `SKILL.md` files with YAML `name` and `description`. Load order: user store (`~/.harness/skills`), then the project (project wins). The package catalog is off until you add a skill. The agent also reads `skills/`, `.cursor/skills`, and `.claude/skills` when those folders exist.
117
+ A skill is a `SKILL.md` with YAML `name` and `description`. Skills in `~/.harness/skills` and in the project load; the project wins on name clash. Bundled skills and skills.sh are a catalog: add one and it starts working. The agent also reads `skills/`, `.cursor/skills`, and `.claude/skills` when those folders exist. Disable a project skill from `/skill find` to keep the file and drop it from the prompt.
118
+
119
+ <p align="center">
120
+ <img src="brand/previews/desktop-skills.png" alt="Desktop skills" width="720" />
121
+ </p>
84
122
 
85
123
  | Add | What you get |
86
124
  |------|------|
87
- | `copywriting` | Writing pipeline: RMBC, Harry Dry, copy-editor |
88
- | `copy-editor` | That step only |
89
- | `impeccable` | Visual QA against the host `design.md` |
125
+ | `copywriting` | One writing pipeline: RMBC, Harry Dry, then copy-editor. No invented metrics or testimonials. |
126
+ | `impeccable` | Visual QA against the host `design.md` (Apache 2.0 adaptation) |
127
+
128
+ ## Integrations
129
+
130
+ Hosted MCP servers the agent can call. Connect from the desktop sidebar or `/integrations`. Sign-in is in the browser; those tools show up on the next turn.
131
+
132
+ <p align="center">
133
+ <img src="brand/previews/desktop-integrations.png" alt="Desktop integrations" width="720" />
134
+ </p>
135
+
136
+ | Connect | Needs |
137
+ |------|------|
138
+ | Hosted server | Browser sign-in |
139
+ | Google or Microsoft | Desktop OAuth client in Settings |
140
+ | Figma | Dev Mode MCP in Figma desktop |
141
+
142
+ Connections are stored in `~/.harness/integrations.json`. Disconnect removes that row.
90
143
 
91
- Invented metrics and testimonials stay illegal.
144
+ `mcp` in `harness.config.ts` adds local stdio servers (`command`, `args`, `env`) for this project.
92
145
 
93
146
  ## Modes
94
147
 
@@ -100,6 +153,41 @@ Invented metrics and testimonials stay illegal.
100
153
 
101
154
  `/mode ask`, `/mode plan`, or `/mode agent`. `exec` and `git_commit` ask for approval by default (`prompt`). `auto` still denies destructive commands. Local exec is the host machine, not a sandbox.
102
155
 
156
+ ## Library
157
+
158
+ The desktop, TUI, and `caelence chat -m` all call `createHarness`. Call it from your own UI, bot, or script.
159
+
160
+ ```bash
161
+ bun add @useavalon/caelence-agent
162
+ ```
163
+
164
+ ```ts
165
+ import { createHarness } from "@useavalon/caelence-agent";
166
+
167
+ const harness = await createHarness({ cwd: process.cwd() });
168
+ await harness.runTurn("fix the failing test", (event) => {
169
+ if (event.kind === "text_delta") process.stdout.write(event.text);
170
+ if (event.kind === "tool_call_start") process.stderr.write(`› ${event.toolName}\n`);
171
+ });
172
+ harness.close();
173
+ ```
174
+
175
+ `runTurn` streams `AgentEvent`s (text, tools, usage, errors) and writes the session under `.harness/sessions`. Optional: `config`, `mode`, `provider`, `extraTools`, `approvalPolicy`, `observability`.
176
+
177
+ You can pass a custom model provider in tests. `extraTools` adds MCP tools of your own. `approvalAsk` on `runTurn` is how a host UI prompts for `exec` and `git_commit`.
178
+
179
+ Other exports from the same package:
180
+
181
+ | Import | Use |
182
+ |------|------|
183
+ | `HarnessConfig`, `loadConfig` | Typed `harness.config.ts` |
184
+ | `createOpenRouterChat` | OpenRouter chat without the full agent |
185
+ | `EvalSuite`, `runNamedEval` | Eval suites under `evals/` |
186
+ | `initHost` | Add `.harness/` to `.gitignore`. `examples: true` writes a host scaffold |
187
+ | `@useavalon/caelence-agent/observability` | Langfuse, gates, `runLocalExperiment` |
188
+
189
+ Config types and observability do not require `createHarness`.
190
+
103
191
  ## License
104
192
 
105
193
  [MIT](LICENSE)
@@ -0,0 +1,7 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="16" height="16" rx="3" fill="#212227"/>
3
+ <path d="M3.25098 7.43878C3.23691 7.64059 3.40228 7.80519 3.60458 7.80519H8.00032V3C5.39648 3 3.42625 4.92544 3.25098 7.43878Z" fill="#FDFCF8"/>
4
+ <path d="M12.7474 3.36627C12.7637 3.16463 12.5982 2.99999 12.3959 2.99999H8.00017V7.80518C10.2723 7.80518 12.5439 5.87967 12.7474 3.36627Z" fill="#FDFCF8"/>
5
+ <path d="M3.25098 9.06122C3.23691 8.85941 3.40228 8.69481 3.60458 8.69481H8.00032V13.5C5.39648 13.5 3.42625 11.5746 3.25098 9.06122Z" fill="#FDFCF8"/>
6
+ <path d="M12.7474 13.1337C12.7637 13.3354 12.5982 13.5 12.3959 13.5H8.00017V8.69482C10.2723 8.69482 12.5439 10.6203 12.7474 13.1337Z" fill="#FDFCF8"/>
7
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="32" height="32" rx="5" fill="#212227"/>
3
+ <path d="M6.50197 14.8776C6.47382 15.2812 6.80456 15.6104 7.20916 15.6104H16.0006V6C10.793 6 6.85251 9.85089 6.50197 14.8776Z" fill="#FDFCF8"/>
4
+ <path d="M25.4948 6.73255C25.5275 6.32926 25.1964 5.99998 24.7918 5.99998H16.0003V15.6104C20.5445 15.6104 25.0877 11.7593 25.4948 6.73255Z" fill="#FDFCF8"/>
5
+ <path d="M6.50197 18.1224C6.47382 17.7188 6.80456 17.3896 7.20916 17.3896H16.0006V27C10.793 27 6.85251 23.1491 6.50197 18.1224Z" fill="#FDFCF8"/>
6
+ <path d="M25.4948 26.2675C25.5275 26.6707 25.1964 27 24.7918 27H16.0003V17.3896C20.5445 17.3896 25.0877 21.2407 25.4948 26.2675Z" fill="#FDFCF8"/>
7
+ </svg>
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/caelence-agent",
3
- "version": "0.1.1-canary.0",
3
+ "version": "0.1.1-canary.1",
4
4
  "description": "Caelence agent: Strands turn loop, local tools, skills, evals, and a themable terminal UI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "bin": {
23
23
  "harness": "./bin/harness.ts",
24
+ "caelence": "./bin/harness.ts",
24
25
  "caelence-agent": "./bin/harness.ts"
25
26
  },
26
27
  "exports": {
@@ -32,6 +33,7 @@
32
33
  "bin",
33
34
  "src",
34
35
  "skills",
36
+ "brand",
35
37
  "README.md"
36
38
  ],
37
39
  "scripts": {
@@ -0,0 +1,13 @@
1
+ Copyright 2025 Paul Bakaus
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,14 @@
1
+ Impeccable
2
+ Copyright 2025 Paul Bakaus
3
+
4
+ This folder is a derivative of https://github.com/pbakaus/impeccable
5
+ licensed under the Apache License, Version 2.0. See LICENSE.
6
+
7
+ Trademark: the name Impeccable is used only to describe the origin of
8
+ the work. This is not an official Impeccable distribution.
9
+
10
+ Modifications for Caelence agent:
11
+ - Rewritten as SKILL.md for this agent (no npm installer, no /impeccable binary)
12
+ - Host design.md is visual authority
13
+ - Copy pipeline (copywriting) is out of scope here
14
+ - Visual-slop list kept as references/visual-slop.md
@@ -12,7 +12,8 @@ description: >-
12
12
  # Impeccable checks
13
13
 
14
14
  Adapted from [Impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0,
15
- Copyright 2025 Paul Bakaus). This skill is **not** a vendor of that repository.
15
+ Copyright 2025 Paul Bakaus). Modified for this agent. See `NOTICE` and
16
+ `LICENSE` in this folder. This skill is **not** a vendor of that repository.
16
17
 
17
18
  **Visual authority:** the host project's `docs/design.md` or `design.md` if
18
19
  either exists. Read it before changing UI. Do not dump a whole tokens file
@@ -0,0 +1,51 @@
1
+ import { existsSync, mkdirSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { dirname, resolve } from "node:path";
4
+ import { resolveConfigPath } from "./config.ts";
5
+ import { harnessHome } from "./desktop/secrets.ts";
6
+
7
+ export function standaloneWorkspaceDir(
8
+ env: Record<string, string | undefined> = process.env,
9
+ ): string {
10
+ return resolve(harnessHome(env), "workspace");
11
+ }
12
+
13
+ export function ensureStandaloneWorkspace(
14
+ env: Record<string, string | undefined> = process.env,
15
+ ): string {
16
+ const dir = standaloneWorkspaceDir(env);
17
+ mkdirSync(dir, { recursive: true });
18
+ return dir;
19
+ }
20
+
21
+ function isProjectRoot(dir: string): boolean {
22
+ if (resolveConfigPath(dir)) return true;
23
+ return existsSync(resolve(dir, ".git"));
24
+ }
25
+
26
+ /** Nearest git repo or harness.config, not the home directory. */
27
+ export function findProjectRoot(
28
+ start: string,
29
+ env: Record<string, string | undefined> = process.env,
30
+ ): string | undefined {
31
+ const home = resolve(env.HOME?.trim() || homedir());
32
+ let dir = resolve(start);
33
+ while (true) {
34
+ if (dir !== home && isProjectRoot(dir)) return dir;
35
+ const parent = dirname(dir);
36
+ if (parent === dir) return undefined;
37
+ dir = parent;
38
+ }
39
+ }
40
+
41
+ /** `--cwd` wins. Else a project root from `start`. Else `~/.harness/workspace`. */
42
+ export function resolveAgentCwd(input: {
43
+ start: string;
44
+ explicit?: string;
45
+ env?: Record<string, string | undefined>;
46
+ }): string {
47
+ const env = input.env ?? process.env;
48
+ const explicit = input.explicit?.trim();
49
+ if (explicit) return resolve(explicit);
50
+ return findProjectRoot(input.start, env) ?? ensureStandaloneWorkspace(env);
51
+ }
@@ -0,0 +1,65 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { mkdir, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import {
6
+ ensureStandaloneWorkspace,
7
+ findProjectRoot,
8
+ resolveAgentCwd,
9
+ standaloneWorkspaceDir,
10
+ } from "../agent-cwd.ts";
11
+
12
+ async function tempDir(prefix: string): Promise<string> {
13
+ const dir = join(tmpdir(), `${prefix}${Date.now()}-${Math.random().toString(16).slice(2)}`);
14
+ await mkdir(dir, { recursive: true });
15
+ return dir;
16
+ }
17
+
18
+ describe("resolveAgentCwd", () => {
19
+ test("explicit --cwd wins", async () => {
20
+ const cwd = await tempDir("agent-cwd-explicit-");
21
+ try {
22
+ expect(resolveAgentCwd({ start: tmpdir(), explicit: cwd })).toBe(cwd);
23
+ } finally {
24
+ await rm(cwd, { recursive: true, force: true });
25
+ }
26
+ });
27
+
28
+ test("walks up to a git root", async () => {
29
+ const root = await tempDir("agent-cwd-git-");
30
+ const nested = join(root, "src", "cli");
31
+ try {
32
+ await mkdir(join(root, ".git"));
33
+ await mkdir(nested, { recursive: true });
34
+ expect(findProjectRoot(nested)).toBe(root);
35
+ expect(resolveAgentCwd({ start: nested })).toBe(root);
36
+ } finally {
37
+ await rm(root, { recursive: true, force: true });
38
+ }
39
+ });
40
+
41
+ test("uses harness.config.ts as a project root", async () => {
42
+ const root = await tempDir("agent-cwd-config-");
43
+ try {
44
+ await writeFile(join(root, "harness.config.ts"), "export default {}\n");
45
+ expect(findProjectRoot(root)).toBe(root);
46
+ } finally {
47
+ await rm(root, { recursive: true, force: true });
48
+ }
49
+ });
50
+
51
+ test("home is not a project even with .git", async () => {
52
+ const home = await tempDir("agent-cwd-home-");
53
+ const harnessHome = await tempDir("agent-cwd-home-harness-");
54
+ try {
55
+ await mkdir(join(home, ".git"));
56
+ const env = { HOME: home, HARNESS_HOME: harnessHome };
57
+ expect(findProjectRoot(home, env)).toBeUndefined();
58
+ expect(resolveAgentCwd({ start: home, env })).toBe(standaloneWorkspaceDir(env));
59
+ expect(ensureStandaloneWorkspace(env)).toBe(join(harnessHome, "workspace"));
60
+ } finally {
61
+ await rm(home, { recursive: true, force: true });
62
+ await rm(harnessHome, { recursive: true, force: true });
63
+ }
64
+ });
65
+ });
@@ -33,4 +33,9 @@ describe("parseCliArgs", () => {
33
33
  expect(parsed.mode).toBe("ask");
34
34
  expect(parsed.message).toBe("hello");
35
35
  });
36
+
37
+ test("marks --cwd as explicit", () => {
38
+ expect(parseCliArgs(["eval"]).cwdExplicit).toBe(false);
39
+ expect(parseCliArgs(["--cwd", "/tmp/proj", "eval"]).cwdExplicit).toBe(true);
40
+ });
36
41
  });