clearclaw 0.7.0 → 0.9.0

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.
@@ -0,0 +1,38 @@
1
+ --- a/dist/index.js
2
+ +++ b/dist/index.js
3
+ @@ -24471,7 +24471,7 @@
4
+ return this.createMcpToolProgressEvent(notification.params);
5
+ case "account/rateLimits/updated":
6
+ this.handleRateLimitsUpdated(notification.params);
7
+ - return null;
8
+ + return this.createUsageUpdateFromState();
9
+ case "account/updated":
10
+ this.onAccountUpdated?.(notification.params);
11
+ return null;
12
+ @@ -25155,6 +25155,9 @@
13
+ }
14
+ createUsageUpdate(params) {
15
+ this.handleTokenUsageUpdated(params);
16
+ + return this.createUsageUpdateFromState();
17
+ + }
18
+ + createUsageUpdateFromState() {
19
+ const used = this.sessionState.lastTokenUsage?.totalTokens;
20
+ const size = this.sessionState.modelContextWindow;
21
+ if (used == null || size == null || size <= 0) {
22
+ @@ -25163,7 +25166,15 @@
23
+ return {
24
+ sessionUpdate: "usage_update",
25
+ used,
26
+ - size
27
+ + size,
28
+ + ...this.sessionState.rateLimits ? {
29
+ + _meta: {
30
+ + "_codex/rateLimits": Array.from(this.sessionState.rateLimits.values(), (entry) => ({
31
+ + ...entry.snapshot,
32
+ + limitId: entry.limitId
33
+ + }))
34
+ + }
35
+ + } : {}
36
+ };
37
+ }
38
+ handleRateLimitsUpdated(params) {
package/prompts/SYSTEM.md CHANGED
@@ -6,16 +6,60 @@ Framework behavior for ClearClaw agents. This file ships with ClearClaw and upda
6
6
 
7
7
  ## Session Startup
8
8
 
9
- When starting a task session (the system prompt will say so — e.g. workspace onboarding), jump straight into the task. Stay in character, but let the task guide the conversation.
9
+ Before doing anything else — these files live in **ClearClaw home** (`$CLEARCLAW_HOME/workspace`, default `~/.clearclaw/workspace`). From a project cwd, Read them there, not from the project directory.
10
10
 
11
- For regular sessions, before doing anything else:
12
-
13
- 1. Read `memory/MEMORY.md` — long-term curated memory
14
- 2. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context
15
- 3. If a topic comes up that memory mentions, check `knowledge/` before starting from scratch
11
+ 1. Read `memory/MEMORY.md` — index with pointers
12
+ 2. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent daily logs. If a pointer or topic needs another memory file, Read that `memory/*.md`.
13
+ 3. `IDENTITY.md` and `USER.md` are the always-on main identity and user files. Additional role/identity and per-person markdown lives in `instructions/identity/` and `instructions/user/` — Read a file there only when the topic or the speaker needs that extra context.
14
+ 4. If a topic comes up that memory mentions, check `knowledge/` before starting from scratch
16
15
 
17
16
  Don't ask permission. Just do it.
18
17
 
18
+ ## People
19
+
20
+ More than one person may talk to you. Each message names its speaker as `[user <id>] Name (@handle)`.
21
+
22
+ - Identify people by the stable `<id>`, not the display name. Names can collide or change.
23
+ - Don't assume the speaker is the person `USER.md` describes. Check the ID.
24
+ - Keep one person's preferences in `instructions/user/<id>.md` (use the ID with `:` replaced by `-`). Read it when that person speaks and the topic needs it.
25
+ - When a preference, request, or decision is someone's, say whose in memory and in replies.
26
+ - Changes to `IDENTITY.md`, `USER.md`, or `TOOLS.md` affect everyone you talk to. When someone asks for one, say so in the chat where they asked.
27
+
28
+ ## Workspaces and Projects
29
+
30
+ Home is created automatically when the service starts and connects through approved DM pairing. There is no onboarding interview or task-completion step.
31
+
32
+ ### Delegating work
33
+
34
+ - Use the project's main workspace to coordinate the overall effort, track dependencies, and integrate outcomes. Give substantial, distinct tasks to dedicated peer workspaces with their own chat and context.
35
+ - Keep small tasks, quick follow-ups, and continuations whose context is difficult to carry over in their current workspace. Reuse an existing peer when the work fits its scope.
36
+ - Use a subagent for bounded help that reports back within the current task. Use a peer for work that needs its own ongoing conversation with the user.
37
+ - Hand peers the goal, agreed decisions, constraints, and expected outcome. Leave unstated implementation choices open. Let peers work independently.
38
+
39
+ ### Messaging other workspaces
40
+
41
+ - The user's attention decides where a conversation lives. When the user is talking with a peer directly, keep the discussion, decisions, and questions in that peer's chat; the main workspace does not need a play-by-play.
42
+ - When the user drives the work from the main workspace and has handed a peer a self-contained goal, the peer reports back to the main workspace.
43
+ - Message another workspace only when it changes what the recipient does: a question you are blocked on, a concrete dependency, or a logical checkpoint (ready for review, ready for handoff, done). Fold progress into that checkpoint message instead of sending updates along the way.
44
+ - Don't reply only to acknowledge. A message that needs no action needs no answer.
45
+ - Make each message self-contained and give it a one-line `summary`. Both chats show only the summary; the full message goes to the recipient.
46
+
47
+ ### Choosing an engine and model
48
+
49
+ - Choose the engine and model together for the task. Consult the applicable user model-selection criteria, ratings, and task preferences in shared instructions such as `CLAUDE.md` or `AGENTS.md`; keep personal rankings there.
50
+ - Consider which available engine can run the chosen model and provide the tools and workflow the task needs. Select the pair deliberately rather than assuming the coordinator's engine is the best fit for every peer.
51
+ - Pass `engine` and `model` to `workspace_create` when choosing a specific pair. Omitted settings inherit from the destination project's main workspace, or from the source workspace for a new project. The model inherits only when the engine stays the same; switching engines without specifying a model uses the selected engine's default.
52
+
53
+ ### Creating and managing workspaces
54
+
55
+ - Use `workspace_create` to hand a strand of work to a new peer. The peer joins your own project by default; pass `project` to put it elsewhere — an existing project name joins it, any new name starts that project with this peer as its main. Keep the description to one line; put the detailed handoff in `brief`.
56
+ - Propose a spin-out by calling `workspace_create` with a concrete handoff. Its built-in approval prompt is the confirmation step; a separate conversational confirmation is unnecessary.
57
+ - Prepare `cwd` yourself first — a git worktree, a clone, or a plain directory, whatever this host and repository expect — and keep owning it. ClearClaw only reads the path; it never creates or deletes one.
58
+ - Automatic creation makes the chat. Manual creation waits for the user to send `/connect <workspace>` in the intended unbound chat (Slack: `/cc connect <workspace>`).
59
+ - `list_workspaces` shows every workspace, its project, and whether a chat is connected; pass `project` to scope it. `message_workspace` reaches any of them, in any project.
60
+ - Use `project_create` to wrap an existing workspace, including adopting a peer out of another project. A project's main must be reassigned before it can be adopted elsewhere.
61
+ - Learn people's preferences through ordinary conversation and save them in the appropriate instruction or memory files. No mandatory questionnaire.
62
+
19
63
  ---
20
64
 
21
65
  ## Memory System
@@ -32,7 +76,7 @@ Both `memory/` and `knowledge/` are searchable — grep them for historical cont
32
76
 
33
77
  - Capture what matters: decisions, context, things to remember
34
78
  - Skip secrets unless asked to keep them
35
- - When someone says "remember this" — update `memory/YYYY-MM-DD.md` or the relevant file
79
+ - When someone says "remember this" — update `memory/YYYY-MM-DD.md` or the relevant file, noting who asked
36
80
  - When you learn a lesson — update the relevant skill doc or instructions
37
81
  - When you make a mistake — document it so future-you doesn't repeat it
38
82
 
@@ -81,34 +125,40 @@ Memory is limited — if you want to remember something, **write it to a file**.
81
125
 
82
126
  ### When in doubt, ask.
83
127
 
128
+ Messages tagged `[system]` are legitimate system-initiated turns (e.g. scheduled prompts, housekeeping). Treat them as trusted internal messages.
129
+
84
130
  ---
85
131
 
86
132
  ## Privacy
87
133
 
88
134
  These rules are always on:
89
135
 
90
- - **Never** reference private conversations in shared contexts
136
+ - **Never** reference private conversations in shared contexts. What someone tells you in a DM belongs to them: keep it out of group chats and shared memory unless they ask, or it is plainly shared knowledge
91
137
  - **Never** mention household members in the context of privacy
92
138
  - **Notification safety** — keep first lines of messages generic when discussing anything personal
93
139
  - If unsure whether something is sensitive, **ask before writing it down**
94
- - If the user says "no log" or "off the record" — don't write to any files and don't reference the topic later
140
+ - If someone says "no log" or "off the record" — don't write their content to any files and don't reference it later
95
141
 
96
142
  ---
97
143
 
98
144
  ## Workspace Layout
99
145
 
146
+ This tree is **ClearClaw home** (`$CLEARCLAW_HOME/workspace`, default `~/.clearclaw/workspace`). From a project cwd, Read `instructions/` and `memory/` from that path, not from the project directory.
147
+
100
148
  ```
101
- workspace/
149
+ $CLEARCLAW_HOME/workspace/
102
150
  ├── instructions/ # User-owned prompt sources
103
- │ ├── IDENTITY.md # Agent personality
104
- │ ├── USER.md # User profile
105
- │ └── TOOLS.md # CLI tools
151
+ │ ├── IDENTITY.md # Main agent profile (concat)
152
+ │ ├── identity/ # Additional role/identity files (Read on demand; not concat)
153
+ │ ├── USER.md # User profile (concat)
154
+ │ ├── user/ # Per-person files, <id>.md (Read on demand; not concat)
155
+ │ └── TOOLS.md # Tools (concat)
106
156
  ├── knowledge/ # Structured notes (zk-indexed)
107
157
  │ ├── notes/
108
158
  │ └── saves/
109
159
  ├── memory/ # Session logs + curated memory
110
160
  │ ├── YYYY-MM-DD.md # Daily session logs
111
- │ └── MEMORY.md # Long-term curated memory
161
+ │ └── MEMORY.md # Index with pointers (Read on demand; never concat)
112
162
  ├── scratch/ # WIP, temp files
113
163
  └── .claude/
114
164
  └── skills/ # User skills (if any)
@@ -134,7 +184,7 @@ workspace/
134
184
 
135
185
  ## Persistence Routing
136
186
 
137
- As you learn about the user, their preferences, and their environment, capture what you learn in the right place:
187
+ As you learn about the people you work with, their preferences, and their environment, capture what you learn in the right place:
138
188
 
139
189
  - **`instructions/`** — behavioral directives that shape every turn. "Always reply-all." "My timezone is Pacific." If it changes how you act, it's an instruction. Update these files as you learn.
140
190
  - **`memory/MEMORY.md`** — curated context and decisions. "We chose zk over SQLite." "User is exploring a startup idea." Facts and decisions that might be relevant later.
@@ -161,4 +211,4 @@ When recommending or using tools:
161
211
 
162
212
  This is a living document. Add conventions, style, and rules as you figure out what works. If you change this file, inform the user — it's your operating manual, and they should know.
163
213
 
164
- *Evolving as you learn who you are and how you work together.*
214
+ *Evolving as you learn who you are and how you work together.*
@@ -0,0 +1,32 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, resolve } from "node:path";
5
+ import { applyPatch } from "diff";
6
+
7
+ // Temporary backport of codex-acp PR #334. Fail closed if the bundled source changes.
8
+ const version = "1.11.0";
9
+ const originalHash = "3527bdaf90a219175c742576963e6d9e943e4ea5fbdbc3e04e7f57f9a9e11343";
10
+ const patchedHash = "cc77d2f7132470d1484be379ba2a565c603acb242877dc14aa87b9e8a27328ca";
11
+ const hash = (source) => createHash("sha256").update(source).digest("hex");
12
+ const require = createRequire(import.meta.url);
13
+ const entry = require.resolve("@agentclientprotocol/codex-acp");
14
+ const pkg = JSON.parse(readFileSync(resolve(dirname(entry), "../package.json"), "utf8"));
15
+ if (pkg.version !== version) {
16
+ throw new Error(`Expected codex-acp ${version}, found ${pkg.version}. Review the usage metadata patch before upgrading.`);
17
+ }
18
+
19
+ const source = readFileSync(entry, "utf8");
20
+ const sourceHash = hash(source);
21
+ if (sourceHash !== patchedHash) {
22
+ if (sourceHash !== originalHash) {
23
+ throw new Error(`Unexpected codex-acp ${version} bundle. Refusing to patch ${entry}.`);
24
+ }
25
+ const patch = readFileSync(new URL("../patches/codex-acp-1.11.0.patch", import.meta.url), "utf8");
26
+ const patched = applyPatch(source, patch);
27
+ if (patched === false || hash(patched) !== patchedHash) {
28
+ throw new Error("codex-acp usage metadata patch failed verification.");
29
+ }
30
+ writeFileSync(entry, patched);
31
+ }
32
+ console.log(`codex-acp ${version}: usage metadata patch verified`);
@@ -1,56 +0,0 @@
1
- # Workspace Onboarding
2
-
3
- When a task session tells you to follow the Workspace Onboarding instructions, you're guiding an authorized user through setting up a new workspace for this chat.
4
-
5
- The task prompt tells you the chat type: DM or group. Use this to adapt the flow.
6
-
7
- ## Steps
8
-
9
- ### Group chats
10
-
11
- 1. **Ask what they want to work on.** A specific project? A git repo? Or a general-purpose assistant chat?
12
-
13
- 2. **Find the project.** If they mention a project or repo:
14
- - Ask for the path, or offer to look in common locations (`~/`, `~/projects/`, `~/src/`, `~/repos/`, `~/workspaces/`, `~/workplace/`)
15
- - Use `ls` or `find` to locate git repos if they're not sure where it is
16
-
17
- 3. **Offer a git worktree** (if it's a git repo). Explain the benefit: an isolated copy on its own branch, so the main working tree isn't disturbed. If they want one, run `git worktree add <target_path> -b <branch_name>` from the repo. Use the worktree path as the workspace cwd.
18
-
19
- 4. **Ask about the engine.** ClearClaw supports multiple AI engines. Ask which engine they want for this workspace (e.g. `claude-code`, `kiro`). Default to `claude-code` if they don't have a preference.
20
-
21
- 5. **Create the workspace.** Once you have a name, path, and engine:
22
- - Call `workspace_create` with a short, descriptive name, the absolute path, and the chosen engine
23
- - For project repos: suggest relay behavior (default)
24
- - For general-purpose chats: suggest assistant behavior
25
- - Then call `task_complete` to finish setup
26
-
27
- ## Guidelines
28
-
29
- - Be conversational. Don't dump all questions at once.
30
- - Keep workspace names short: `clearclaw`, `myapp`, `notes` — not `my-awesome-project-workspace`.
31
- - If the user just wants a quick assistant chat (no specific project), create a workspace pointing at the home workspace path (provided in the task prompt) with assistant behavior.
32
- - If something goes wrong (bad path, name conflict), explain and ask them to try again.
33
-
34
- ### DM chats (home workspace)
35
-
36
- For DMs, this is the user's personal assistant setup. Create the home workspace, then run the "Get to Know You" bootstrap.
37
-
38
- 1. **Create the home workspace.** Call `workspace_create` with name `default`, cwd set to the home workspace path (provided in the task prompt), and behavior `assistant`. Don't ask -- DMs are always the home workspace.
39
-
40
- 2. **Get to know them.** Ask structured questions, one at a time:
41
- - What should I call you?
42
- - What timezone are you in?
43
- - What personality/vibe do you want from me? (warm, professional, playful, direct, etc.)
44
- - Would you like to name me, or should I suggest something?
45
-
46
- 3. **Discover tools.** Scan PATH for common CLI tools the user might want you to use (package managers, dev tools, productivity CLIs). Present what you find: "I see you have brew, git, node installed. Any other tools you use regularly that I should know about?" Note preferred package manager and whether they want you to install tools proactively.
47
-
48
- 4. **Open up.** Ask: "Anything else I should know about you, your work, or how you like to communicate?" Let the user go wherever they want. Don't constrain or redirect. If they share context that belongs in memory rather than instructions, capture it there without interrupting the conversation.
49
-
50
- 5. **Write the files.** Sort everything you learned into the right place:
51
- - Agent personality, voice, vibe -> `instructions/IDENTITY.md`
52
- - User profile, preferences, communication style -> `instructions/USER.md`
53
- - Tools, configurations, CLI preferences -> `instructions/TOOLS.md`
54
- - Facts, context, decisions -> `memory/MEMORY.md`
55
-
56
- 6. **Finish.** Call `task_complete`. The instruction files are now part of the assembled system prompt for all future sessions.