claude-agent 1.2.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.
- package/README.md +171 -0
- package/agents/ca-executor.md +75 -0
- package/agents/ca-researcher.md +69 -0
- package/agents/ca-verifier.md +80 -0
- package/bin/install.js +161 -0
- package/bin/uninstall.js +67 -0
- package/commands/ca/_rules.md +40 -0
- package/commands/ca/context.md +47 -0
- package/commands/ca/discuss.md +74 -0
- package/commands/ca/execute.md +86 -0
- package/commands/ca/fix.md +69 -0
- package/commands/ca/forget.md +34 -0
- package/commands/ca/help.md +62 -0
- package/commands/ca/map.md +46 -0
- package/commands/ca/new.md +109 -0
- package/commands/ca/next.md +36 -0
- package/commands/ca/plan.md +151 -0
- package/commands/ca/quick.md +109 -0
- package/commands/ca/remember.md +35 -0
- package/commands/ca/research.md +74 -0
- package/commands/ca/settings.md +114 -0
- package/commands/ca/status.md +30 -0
- package/commands/ca/todo.md +33 -0
- package/commands/ca/todos.md +29 -0
- package/commands/ca/verify.md +114 -0
- package/hooks/ca-statusline.js +50 -0
- package/package.json +20 -0
- package/references/model-profiles.md +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# CA — Claude Agent
|
|
2
|
+
|
|
3
|
+
A user-controlled development workflow for Claude Code. Every step requires your explicit confirmation before proceeding.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd claude-agent
|
|
9
|
+
npm run install-ca
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This copies slash commands to `~/.claude/commands/ca/`, agents to `~/.claude/agents/`, and registers the statusline hook.
|
|
13
|
+
|
|
14
|
+
## Uninstall
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm run uninstall-ca
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Removes commands, agents, and hooks from `~/.claude/`. Project `.ca/` directories and `~/.claude/ca/` config are preserved.
|
|
21
|
+
|
|
22
|
+
## Workflow
|
|
23
|
+
|
|
24
|
+
Two workflow modes are available:
|
|
25
|
+
|
|
26
|
+
**Full workflow** — for requirements that need discussion and research:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
/ca:new → /ca:discuss → /ca:research → /ca:plan → /ca:execute → /ca:verify
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Quick workflow** — for clear, simple changes:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
/ca:quick → /ca:plan → /ca:execute → /ca:verify
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Use `/ca:next` at any point to automatically detect and run the next step.
|
|
39
|
+
|
|
40
|
+
### 1. New Requirement — `/ca:new [description]`
|
|
41
|
+
|
|
42
|
+
Creates a `.ca/` directory in your project for workflow state. Collects an initial requirement brief. On first run, auto-configures language settings if no global config exists. Warns if there is an unfinished workflow.
|
|
43
|
+
|
|
44
|
+
### 2. Discuss — `/ca:discuss`
|
|
45
|
+
|
|
46
|
+
Clarifies your requirements through focused Q&A (one question at a time), starting from the brief collected in `/ca:new`. Produces a requirement summary that you must confirm before moving on.
|
|
47
|
+
|
|
48
|
+
### 3. Research — `/ca:research` (optional)
|
|
49
|
+
|
|
50
|
+
Analyzes the codebase and optionally searches external resources. Uses an isolated agent to keep the main conversation clean. Findings require your confirmation.
|
|
51
|
+
|
|
52
|
+
### 4. Plan — `/ca:plan`
|
|
53
|
+
|
|
54
|
+
Proposes an implementation plan with **triple confirmation**:
|
|
55
|
+
|
|
56
|
+
1. **Requirement understanding** — "I understand you want X, correct?"
|
|
57
|
+
2. **Approach and method** — "I'll modify these files using this approach, agreed?"
|
|
58
|
+
3. **Expected results** — "The end result will be X, is that what you want?"
|
|
59
|
+
|
|
60
|
+
All three must pass before the plan is finalized.
|
|
61
|
+
|
|
62
|
+
### 5. Execute — `/ca:execute`
|
|
63
|
+
|
|
64
|
+
Runs the confirmed plan using an isolated executor agent. Only proceeds if the plan has been triple-confirmed. Returns an execution summary.
|
|
65
|
+
|
|
66
|
+
### 6. Verify — `/ca:verify`
|
|
67
|
+
|
|
68
|
+
An independent verifier agent checks every success criterion in a fresh context. After your acceptance, optionally creates a git commit (message confirmed by you). Archives the workflow cycle to `.ca/history/`.
|
|
69
|
+
|
|
70
|
+
### Quick Mode — `/ca:quick [description]`
|
|
71
|
+
|
|
72
|
+
Skips the discuss and research phases entirely. Creates a brief and goes straight to planning. Best for small, well-understood changes.
|
|
73
|
+
|
|
74
|
+
## Other Commands
|
|
75
|
+
|
|
76
|
+
| Command | Description |
|
|
77
|
+
|---------|-------------|
|
|
78
|
+
| `/ca:quick [desc]` | Start a quick workflow (skip discuss/research) |
|
|
79
|
+
| `/ca:next` | Auto-detect and run the next workflow step |
|
|
80
|
+
| `/ca:map` | Scan and record project structure |
|
|
81
|
+
| `/ca:settings` | Configure language, model, and auto-proceed settings |
|
|
82
|
+
| `/ca:status` | Show current workflow state |
|
|
83
|
+
| `/ca:fix [step]` | Roll back to a previous step |
|
|
84
|
+
| `/ca:remember <info>` | Save to persistent context (project or global) |
|
|
85
|
+
| `/ca:context` | Show loaded context in current session |
|
|
86
|
+
| `/ca:forget <info>` | Remove from persistent context |
|
|
87
|
+
| `/ca:todo <item>` | Add a todo item |
|
|
88
|
+
| `/ca:todos` | List all todos |
|
|
89
|
+
| `/ca:help` | Show command reference |
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
CA uses a dual-layer configuration system:
|
|
94
|
+
|
|
95
|
+
- **Global** (`~/.claude/ca/config.md`) — applies to all projects
|
|
96
|
+
- **Workspace** (`.ca/config.md`) — applies to current project, overrides global
|
|
97
|
+
|
|
98
|
+
Three language settings:
|
|
99
|
+
|
|
100
|
+
| Setting | Purpose |
|
|
101
|
+
|---------|---------|
|
|
102
|
+
| `interaction_language` | Language for conversations |
|
|
103
|
+
| `comment_language` | Language for code comments |
|
|
104
|
+
| `code_language` | Language for code strings (logs, errors, etc.) |
|
|
105
|
+
|
|
106
|
+
Additional settings:
|
|
107
|
+
|
|
108
|
+
| Setting | Purpose |
|
|
109
|
+
|---------|---------|
|
|
110
|
+
| `model_profile` | Agent model tier: `quality`, `balanced` (default), or `budget` |
|
|
111
|
+
| `auto_proceed_to_plan` | Skip research confirmation, go straight to plan |
|
|
112
|
+
| `auto_proceed_to_verify` | Skip manual verify trigger after execution |
|
|
113
|
+
|
|
114
|
+
Per-agent model overrides (e.g., `ca-verifier_model: opus`) are also supported.
|
|
115
|
+
|
|
116
|
+
Use `/ca:settings` to configure.
|
|
117
|
+
|
|
118
|
+
## Project Structure
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
~/.claude/
|
|
122
|
+
ca/
|
|
123
|
+
config.md # Global config (language, model, auto-proceed)
|
|
124
|
+
version # Installed version number
|
|
125
|
+
commands/ca/ # Slash commands (installed by install-ca)
|
|
126
|
+
agents/ # Agent definitions (installed by install-ca)
|
|
127
|
+
rules/
|
|
128
|
+
ca-rules.md # Shared rules (auto-loaded)
|
|
129
|
+
ca-settings.md # Global language settings (auto-loaded)
|
|
130
|
+
ca-context.md # Global persistent context (auto-loaded)
|
|
131
|
+
ca-errors.md # Global error lessons (auto-loaded)
|
|
132
|
+
|
|
133
|
+
.ca/ # Created per-project by /ca:new or /ca:quick
|
|
134
|
+
config.md # Workspace config (overrides global)
|
|
135
|
+
todos.md # Todo list with archive
|
|
136
|
+
map.md # Codebase structure map (/ca:map)
|
|
137
|
+
current/
|
|
138
|
+
STATUS.md # Workflow state
|
|
139
|
+
BRIEF.md # Initial requirement brief
|
|
140
|
+
REQUIREMENT.md # Finalized requirement from /ca:discuss
|
|
141
|
+
RESEARCH.md # Findings from /ca:research
|
|
142
|
+
PLAN.md # Confirmed plan from /ca:plan
|
|
143
|
+
SUMMARY.md # Execution summary from /ca:execute
|
|
144
|
+
CRITERIA.md # Success criteria from /ca:plan
|
|
145
|
+
history/
|
|
146
|
+
0001-feature-slug/ # Archived workflow cycles
|
|
147
|
+
|
|
148
|
+
.claude/rules/ # Project-level rules (auto-loaded)
|
|
149
|
+
ca-settings.md # Project language settings
|
|
150
|
+
ca-context.md # Project persistent context
|
|
151
|
+
ca-errors.md # Project error lessons
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Agents
|
|
155
|
+
|
|
156
|
+
| Agent | Role | Why isolated |
|
|
157
|
+
|-------|------|-------------|
|
|
158
|
+
| `ca-researcher` | Deep codebase analysis | Research consumes large context |
|
|
159
|
+
| `ca-executor` | Implements the plan | Code edits cause context bloat |
|
|
160
|
+
| `ca-verifier` | Independent verification | Fresh context avoids confirmation bias |
|
|
161
|
+
|
|
162
|
+
## Statusline
|
|
163
|
+
|
|
164
|
+
CA installs a status bar hook that displays:
|
|
165
|
+
- Current model name
|
|
166
|
+
- "ca" + version number
|
|
167
|
+
- Context window usage bar
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ca-executor
|
|
3
|
+
description: Execution agent that implements changes according to the confirmed plan
|
|
4
|
+
tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Edit
|
|
8
|
+
- Bash
|
|
9
|
+
- Grep
|
|
10
|
+
- Glob
|
|
11
|
+
model: inherit
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# CA Executor Agent
|
|
15
|
+
|
|
16
|
+
You are an execution agent for the CA development workflow. Your job is to **implement exactly what the plan says**, step by step. You do NOT deviate from the plan or make independent design decisions.
|
|
17
|
+
|
|
18
|
+
## Input
|
|
19
|
+
|
|
20
|
+
You will receive:
|
|
21
|
+
- The content of PLAN.md (the confirmed implementation plan)
|
|
22
|
+
- The content of REQUIREMENT.md (the original requirement)
|
|
23
|
+
- The content of context.md (persistent project context, if any)
|
|
24
|
+
- The project root path
|
|
25
|
+
|
|
26
|
+
## Your Task
|
|
27
|
+
|
|
28
|
+
### 1. Execute each step in PLAN.md
|
|
29
|
+
|
|
30
|
+
Go through the implementation steps in order. For each step:
|
|
31
|
+
- Read any files you need to understand before modifying
|
|
32
|
+
- Make the changes as specified
|
|
33
|
+
- Verify the change was applied correctly
|
|
34
|
+
|
|
35
|
+
### 2. Track what you did
|
|
36
|
+
|
|
37
|
+
Keep a running log of:
|
|
38
|
+
- Each file modified and what changed
|
|
39
|
+
- Each file created and why
|
|
40
|
+
- Any deviations from the plan (with explanation)
|
|
41
|
+
|
|
42
|
+
### 3. Output Format
|
|
43
|
+
|
|
44
|
+
When done, return your summary in this exact structure:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
## Execution Summary
|
|
48
|
+
|
|
49
|
+
### Changes Made
|
|
50
|
+
- <file_path> — <what changed>
|
|
51
|
+
|
|
52
|
+
### Files Created
|
|
53
|
+
- <file_path> — <purpose>
|
|
54
|
+
|
|
55
|
+
### Steps Completed
|
|
56
|
+
1. <step> — Done
|
|
57
|
+
2. <step> — Done
|
|
58
|
+
|
|
59
|
+
### Deviations from Plan
|
|
60
|
+
- <deviation and reason> (or "None")
|
|
61
|
+
|
|
62
|
+
### Notes
|
|
63
|
+
- <anything the user should know>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Rules
|
|
67
|
+
|
|
68
|
+
- Follow PLAN.md **exactly**. Do not add features, refactor unrelated code, or make "improvements" beyond the plan.
|
|
69
|
+
- If a step is unclear or seems wrong, record it as a deviation note rather than guessing.
|
|
70
|
+
- Do not run tests unless the plan explicitly says to.
|
|
71
|
+
- Do not commit anything. The verify step handles that.
|
|
72
|
+
- All imports must be at the top of files.
|
|
73
|
+
- Write code comments in the language specified by `comment_language` in the config (default: English).
|
|
74
|
+
- Write code strings (logs, error messages, etc.) in the language specified by `code_language` in the config (default: English).
|
|
75
|
+
- Keep code compact and concise — no unnecessary abstractions.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ca-researcher
|
|
3
|
+
description: Research agent that gathers facts about the codebase and external resources
|
|
4
|
+
tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Glob
|
|
7
|
+
- Grep
|
|
8
|
+
- WebFetch
|
|
9
|
+
- WebSearch
|
|
10
|
+
model: inherit
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# CA Researcher Agent
|
|
14
|
+
|
|
15
|
+
You are a research agent for the CA development workflow. Your job is to **gather facts** about the codebase and external resources relevant to a requirement. You do NOT propose solutions or make implementation decisions.
|
|
16
|
+
|
|
17
|
+
## Input
|
|
18
|
+
|
|
19
|
+
You will receive:
|
|
20
|
+
- The content of REQUIREMENT.md (what the user wants)
|
|
21
|
+
- The project root path
|
|
22
|
+
- Optional research scope instructions from the user
|
|
23
|
+
|
|
24
|
+
## Your Task
|
|
25
|
+
|
|
26
|
+
### 1. Codebase Analysis
|
|
27
|
+
|
|
28
|
+
Use Glob and Grep to find files relevant to the requirement:
|
|
29
|
+
- Identify files that will likely need modification
|
|
30
|
+
- Find existing patterns, conventions, and architecture
|
|
31
|
+
- Locate related tests, configs, and dependencies
|
|
32
|
+
- Note any constraints (version requirements, API contracts, etc.)
|
|
33
|
+
|
|
34
|
+
### 2. External Resources (if requested)
|
|
35
|
+
|
|
36
|
+
If the user asked for external research:
|
|
37
|
+
- Search for relevant documentation
|
|
38
|
+
- Find API references, library docs, or best practices
|
|
39
|
+
- Summarize findings concisely
|
|
40
|
+
|
|
41
|
+
### 3. Output Format
|
|
42
|
+
|
|
43
|
+
Return your findings in this exact structure:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
## Research Findings
|
|
47
|
+
|
|
48
|
+
### Relevant Files
|
|
49
|
+
- <file_path> — <why it's relevant>
|
|
50
|
+
|
|
51
|
+
### Code Patterns
|
|
52
|
+
- <pattern description>
|
|
53
|
+
|
|
54
|
+
### Constraints and Dependencies
|
|
55
|
+
- <constraint>
|
|
56
|
+
|
|
57
|
+
### External Resources
|
|
58
|
+
- <resource> — <key finding>
|
|
59
|
+
|
|
60
|
+
### Key Observations
|
|
61
|
+
- <anything notable that could affect implementation>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Rules
|
|
65
|
+
|
|
66
|
+
- Only report facts. Do NOT suggest approaches or implementations.
|
|
67
|
+
- Be thorough but concise. List the most important findings first.
|
|
68
|
+
- If you find potential issues or conflicts, report them as observations.
|
|
69
|
+
- Read file contents when needed to understand structure, don't just list filenames.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ca-verifier
|
|
3
|
+
description: Verification agent that independently checks implementation against requirements
|
|
4
|
+
tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Bash
|
|
7
|
+
- Grep
|
|
8
|
+
- Glob
|
|
9
|
+
model: inherit
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# CA Verifier Agent
|
|
13
|
+
|
|
14
|
+
You are a verification agent for the CA development workflow. Your job is to **independently check** whether the implementation meets the requirements and plan. You operate in a fresh context to avoid confirmation bias.
|
|
15
|
+
|
|
16
|
+
## Input
|
|
17
|
+
|
|
18
|
+
You will receive:
|
|
19
|
+
- The content of REQUIREMENT.md (what was requested)
|
|
20
|
+
- The content of PLAN.md (what was planned)
|
|
21
|
+
- The content of SUMMARY.md (what was executed)
|
|
22
|
+
- The project root path
|
|
23
|
+
|
|
24
|
+
## Your Task
|
|
25
|
+
|
|
26
|
+
### 1. Check each success criterion
|
|
27
|
+
|
|
28
|
+
Read the success criteria from REQUIREMENT.md. For each one:
|
|
29
|
+
- Verify it's actually met by reading the relevant code/files
|
|
30
|
+
- Record the evidence (what you found)
|
|
31
|
+
- Mark as PASS or FAIL
|
|
32
|
+
|
|
33
|
+
### 2. Check plan compliance
|
|
34
|
+
|
|
35
|
+
Compare SUMMARY.md against PLAN.md:
|
|
36
|
+
- Were all planned steps executed?
|
|
37
|
+
- Were there unexpected deviations?
|
|
38
|
+
- Are the expected results achieved?
|
|
39
|
+
|
|
40
|
+
### 3. Basic quality checks
|
|
41
|
+
|
|
42
|
+
- Do modified files have syntax errors? (Run linters/interpreters if available)
|
|
43
|
+
- Are there obvious bugs or issues?
|
|
44
|
+
- Do imports look correct?
|
|
45
|
+
|
|
46
|
+
### 4. Output Format
|
|
47
|
+
|
|
48
|
+
Return your report in this exact structure:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
## Verification Report
|
|
52
|
+
|
|
53
|
+
### Success Criteria
|
|
54
|
+
| # | Criterion | Status | Evidence |
|
|
55
|
+
|---|-----------|--------|----------|
|
|
56
|
+
| 1 | <criterion> | PASS/FAIL | <what you found> |
|
|
57
|
+
|
|
58
|
+
### Plan Compliance
|
|
59
|
+
| # | Planned Step | Status | Notes |
|
|
60
|
+
|---|-------------|--------|-------|
|
|
61
|
+
| 1 | <step> | DONE/MISSING/DEVIATED | <notes> |
|
|
62
|
+
|
|
63
|
+
### Quality Checks
|
|
64
|
+
- Syntax: PASS/FAIL
|
|
65
|
+
- Imports: PASS/FAIL
|
|
66
|
+
- Obvious issues: <list or "None">
|
|
67
|
+
|
|
68
|
+
### Overall: PASS/FAIL
|
|
69
|
+
|
|
70
|
+
### Recommendations (if any)
|
|
71
|
+
- <recommendation>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Rules
|
|
75
|
+
|
|
76
|
+
- Be objective and thorough. Your purpose is to catch issues before the user accepts the work.
|
|
77
|
+
- Do NOT modify any files. You are read-only.
|
|
78
|
+
- Do NOT fix issues. Report them so the user can decide what to do.
|
|
79
|
+
- Check actual file contents, don't just trust SUMMARY.md claims.
|
|
80
|
+
- If you can run tests (e.g., `npm test`, `pytest`), do so and report results.
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const homeDir = require("os").homedir();
|
|
7
|
+
const srcDir = path.resolve(__dirname, "..");
|
|
8
|
+
const targetCommandsDir = path.join(homeDir, ".claude", "commands", "ca");
|
|
9
|
+
const targetAgentsDir = path.join(homeDir, ".claude", "agents");
|
|
10
|
+
const targetHooksDir = path.join(homeDir, ".claude", "hooks");
|
|
11
|
+
const caConfigDir = path.join(homeDir, ".claude", "ca");
|
|
12
|
+
const settingsPath = path.join(homeDir, ".claude", "settings.json");
|
|
13
|
+
|
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(srcDir, "package.json"), "utf8"));
|
|
15
|
+
|
|
16
|
+
// Colors
|
|
17
|
+
const cyan = '\x1b[36m';
|
|
18
|
+
const green = '\x1b[32m';
|
|
19
|
+
const dim = '\x1b[2m';
|
|
20
|
+
const reset = '\x1b[0m';
|
|
21
|
+
|
|
22
|
+
const banner = '\n' +
|
|
23
|
+
cyan + ' ██████╗ █████╗\n' +
|
|
24
|
+
' ██╔════╝██╔══██╗\n' +
|
|
25
|
+
' ██║ ███████║\n' +
|
|
26
|
+
' ██║ ██╔══██║\n' +
|
|
27
|
+
' ╚██████╗██║ ██║\n' +
|
|
28
|
+
' ╚═════╝╚═╝ ╚═╝' + reset + '\n\n' +
|
|
29
|
+
' Claude Agent ' + dim + 'v' + pkg.version + reset + '\n';
|
|
30
|
+
|
|
31
|
+
console.log(banner);
|
|
32
|
+
|
|
33
|
+
function copyDir(src, dest) {
|
|
34
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
35
|
+
for (const entry of fs.readdirSync(src)) {
|
|
36
|
+
const srcPath = path.join(src, entry);
|
|
37
|
+
const destPath = path.join(dest, entry);
|
|
38
|
+
if (fs.statSync(srcPath).isDirectory()) {
|
|
39
|
+
copyDir(srcPath, destPath);
|
|
40
|
+
} else {
|
|
41
|
+
fs.copyFileSync(srcPath, destPath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function copyAgents(src, dest) {
|
|
47
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
48
|
+
for (const entry of fs.readdirSync(src)) {
|
|
49
|
+
if (entry.startsWith("ca-") && entry.endsWith(".md")) {
|
|
50
|
+
fs.copyFileSync(path.join(src, entry), path.join(dest, entry));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function generateSettingsRules(configContent) {
|
|
56
|
+
const lines = configContent.split("\n");
|
|
57
|
+
const rules = ["# CA Settings Rules\n"];
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const match = line.match(/^(\w+):\s*(.+)$/);
|
|
60
|
+
if (!match) continue;
|
|
61
|
+
const [, key, value] = match;
|
|
62
|
+
if (key === "interaction_language") {
|
|
63
|
+
rules.push(`- Always communicate in ${value}`);
|
|
64
|
+
} else if (key === "comment_language") {
|
|
65
|
+
rules.push(`- Write all code comments in ${value}`);
|
|
66
|
+
} else if (key === "code_language") {
|
|
67
|
+
rules.push(`- Use ${value} for code strings (logs, error messages, etc.)`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return rules.join("\n") + "\n";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Copy commands
|
|
74
|
+
const srcCommandsDir = path.join(srcDir, "commands", "ca");
|
|
75
|
+
copyDir(srcCommandsDir, targetCommandsDir);
|
|
76
|
+
const commandCount = fs.readdirSync(targetCommandsDir).filter((f) => f.endsWith(".md")).length;
|
|
77
|
+
console.log(` ${green}✓${reset} Installed ${commandCount} commands`);
|
|
78
|
+
|
|
79
|
+
// Copy agents
|
|
80
|
+
const srcAgentsDir = path.join(srcDir, "agents");
|
|
81
|
+
copyAgents(srcAgentsDir, targetAgentsDir);
|
|
82
|
+
const agentFiles = fs.readdirSync(srcAgentsDir).filter((f) => f.startsWith("ca-") && f.endsWith(".md"));
|
|
83
|
+
console.log(` ${green}✓${reset} Installed ${agentFiles.length} agents`);
|
|
84
|
+
|
|
85
|
+
// Copy hooks
|
|
86
|
+
const srcHooksDir = path.join(srcDir, "hooks");
|
|
87
|
+
fs.mkdirSync(targetHooksDir, { recursive: true });
|
|
88
|
+
const hookFile = "ca-statusline.js";
|
|
89
|
+
fs.copyFileSync(path.join(srcHooksDir, hookFile), path.join(targetHooksDir, hookFile));
|
|
90
|
+
console.log(` ${green}✓${reset} Installed statusline hook`);
|
|
91
|
+
|
|
92
|
+
// Create global config directory
|
|
93
|
+
fs.mkdirSync(caConfigDir, { recursive: true });
|
|
94
|
+
console.log(` ${green}✓${reset} Created config directory`);
|
|
95
|
+
|
|
96
|
+
// Create rules directory and install rules files
|
|
97
|
+
const rulesDir = path.join(homeDir, ".claude", "rules");
|
|
98
|
+
fs.mkdirSync(rulesDir, { recursive: true });
|
|
99
|
+
|
|
100
|
+
// Copy _rules.md as ca-rules.md
|
|
101
|
+
const rulesSource = path.join(srcCommandsDir, "_rules.md");
|
|
102
|
+
const rulesTarget = path.join(rulesDir, "ca-rules.md");
|
|
103
|
+
fs.copyFileSync(rulesSource, rulesTarget);
|
|
104
|
+
console.log(` ${green}✓${reset} Installed rules`);
|
|
105
|
+
|
|
106
|
+
// Generate ca-settings.md from existing config
|
|
107
|
+
const globalConfigPath = path.join(caConfigDir, "config.md");
|
|
108
|
+
if (fs.existsSync(globalConfigPath)) {
|
|
109
|
+
const configContent = fs.readFileSync(globalConfigPath, "utf8");
|
|
110
|
+
const settingsRules = generateSettingsRules(configContent);
|
|
111
|
+
fs.writeFileSync(path.join(rulesDir, "ca-settings.md"), settingsRules);
|
|
112
|
+
console.log(` ${green}✓${reset} Generated settings from config`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Migrate old context.md to rules if exists
|
|
116
|
+
const oldGlobalContext = path.join(caConfigDir, "context.md");
|
|
117
|
+
const newGlobalContext = path.join(rulesDir, "ca-context.md");
|
|
118
|
+
if (fs.existsSync(oldGlobalContext) && !fs.existsSync(newGlobalContext)) {
|
|
119
|
+
fs.copyFileSync(oldGlobalContext, newGlobalContext);
|
|
120
|
+
console.log(` ${green}✓${reset} Migrated context to rules`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Migrate old errors.md to rules if exists
|
|
124
|
+
const oldGlobalErrors = path.join(caConfigDir, "errors.md");
|
|
125
|
+
const newGlobalErrors = path.join(rulesDir, "ca-errors.md");
|
|
126
|
+
if (fs.existsSync(oldGlobalErrors) && !fs.existsSync(newGlobalErrors)) {
|
|
127
|
+
fs.copyFileSync(oldGlobalErrors, newGlobalErrors);
|
|
128
|
+
console.log(` ${green}✓${reset} Migrated errors to rules`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Write version file
|
|
132
|
+
fs.writeFileSync(path.join(caConfigDir, "version"), pkg.version);
|
|
133
|
+
console.log(` ${green}✓${reset} Wrote version (${pkg.version})`);
|
|
134
|
+
|
|
135
|
+
// Register statusline in settings.json
|
|
136
|
+
let settings = {};
|
|
137
|
+
if (fs.existsSync(settingsPath)) {
|
|
138
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
139
|
+
}
|
|
140
|
+
const hookPath = path.join(targetHooksDir, hookFile);
|
|
141
|
+
settings.statusLine = { type: "command", command: `node "${hookPath}"` };
|
|
142
|
+
|
|
143
|
+
// Add Read permissions for CA config files
|
|
144
|
+
if (!settings.permissions) settings.permissions = {};
|
|
145
|
+
if (!Array.isArray(settings.permissions.allow)) settings.permissions.allow = [];
|
|
146
|
+
const readPermissions = [
|
|
147
|
+
"Read(.ca/*)",
|
|
148
|
+
"Read(.ca/**/*)",
|
|
149
|
+
"Read(~/.claude/ca/*)"
|
|
150
|
+
];
|
|
151
|
+
for (const perm of readPermissions) {
|
|
152
|
+
if (!settings.permissions.allow.includes(perm)) {
|
|
153
|
+
settings.permissions.allow.push(perm);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
158
|
+
console.log(` ${green}✓${reset} Configured statusline`);
|
|
159
|
+
console.log(` ${green}✓${reset} Added Read permissions`);
|
|
160
|
+
|
|
161
|
+
console.log(`\n ${green}Done!${reset} Launch Claude Code and run ${cyan}/ca:help${reset}.\n`);
|
package/bin/uninstall.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const homeDir = require("os").homedir();
|
|
5
|
+
const targetCommandsDir = path.join(homeDir, ".claude", "commands", "ca");
|
|
6
|
+
const targetAgentsDir = path.join(homeDir, ".claude", "agents");
|
|
7
|
+
const targetHooksDir = path.join(homeDir, ".claude", "hooks");
|
|
8
|
+
const settingsPath = path.join(homeDir, ".claude", "settings.json");
|
|
9
|
+
|
|
10
|
+
// Remove commands directory
|
|
11
|
+
if (fs.existsSync(targetCommandsDir)) {
|
|
12
|
+
fs.rmSync(targetCommandsDir, { recursive: true });
|
|
13
|
+
console.log(`Removed ${targetCommandsDir}`);
|
|
14
|
+
} else {
|
|
15
|
+
console.log("Commands directory not found, skipping.");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Remove agent files
|
|
19
|
+
if (fs.existsSync(targetAgentsDir)) {
|
|
20
|
+
let removed = 0;
|
|
21
|
+
for (const entry of fs.readdirSync(targetAgentsDir)) {
|
|
22
|
+
if (entry.startsWith("ca-") && entry.endsWith(".md")) {
|
|
23
|
+
fs.unlinkSync(path.join(targetAgentsDir, entry));
|
|
24
|
+
removed++;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log(`Removed ${removed} agent files from ${targetAgentsDir}`);
|
|
28
|
+
} else {
|
|
29
|
+
console.log("Agents directory not found, skipping.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Remove hook file
|
|
33
|
+
const hookFile = path.join(targetHooksDir, "ca-statusline.js");
|
|
34
|
+
if (fs.existsSync(hookFile)) {
|
|
35
|
+
fs.unlinkSync(hookFile);
|
|
36
|
+
console.log(`Removed ${hookFile}`);
|
|
37
|
+
} else {
|
|
38
|
+
console.log("Hook file not found, skipping.");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Deregister statusline from settings.json
|
|
42
|
+
if (fs.existsSync(settingsPath)) {
|
|
43
|
+
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
44
|
+
if (settings.statusLine?.command?.includes("ca-statusline")) {
|
|
45
|
+
delete settings.statusLine;
|
|
46
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
47
|
+
console.log("Removed statusline from settings.json");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Remove all CA rules files
|
|
52
|
+
const rulesDir = path.join(homeDir, ".claude", "rules");
|
|
53
|
+
if (fs.existsSync(rulesDir)) {
|
|
54
|
+
let removedRules = 0;
|
|
55
|
+
for (const entry of fs.readdirSync(rulesDir)) {
|
|
56
|
+
if (entry.startsWith("ca-") && entry.endsWith(".md")) {
|
|
57
|
+
fs.unlinkSync(path.join(rulesDir, entry));
|
|
58
|
+
removedRules++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (removedRules > 0) {
|
|
62
|
+
console.log(`Removed ${removedRules} CA rules files from ${rulesDir}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log("\nCA uninstalled successfully!");
|
|
67
|
+
console.log("Note: .ca/ directories and ~/.claude/ca/ config are preserved. CA rules files have been removed.");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# CA Command Rules
|
|
2
|
+
|
|
3
|
+
## UI Rule
|
|
4
|
+
|
|
5
|
+
Before calling `AskUserQuestion`, always output structured content first (summary, list, checkpoint, etc.) so the user has sufficient context visible above the option picker.
|
|
6
|
+
|
|
7
|
+
In the message immediately before an `AskUserQuestion` call, always end with a horizontal rule (`---`) as the last line. This prevents the option picker from obscuring the last visible line of content.
|
|
8
|
+
|
|
9
|
+
## Discussion Completeness Rule
|
|
10
|
+
|
|
11
|
+
When asking clarifying questions one at a time during the discuss phase:
|
|
12
|
+
- If the user indicates they don't understand the question, you MUST explain or rephrase the current question first before moving on.
|
|
13
|
+
- Do NOT skip to the next question when the user's response shows confusion, disagreement, or a request for clarification about the current question.
|
|
14
|
+
- Only proceed to the next question after the current one is clearly resolved.
|
|
15
|
+
|
|
16
|
+
## Error Recording Rule
|
|
17
|
+
|
|
18
|
+
When an agent makes a mistake during execution (wrong file, logic error, repeated mistake, etc.), it must record the error:
|
|
19
|
+
- **Project-level**: Append to `.claude/rules/ca-errors.md` for project-specific lessons.
|
|
20
|
+
- **Global-level**: Append to `~/.claude/rules/ca-errors.md` for cross-project lessons.
|
|
21
|
+
|
|
22
|
+
Format each entry as:
|
|
23
|
+
```
|
|
24
|
+
- [YYYY-MM-DD] <brief description of the error and what was learned>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Todo Independence Rule
|
|
28
|
+
|
|
29
|
+
Users may invoke `/ca:todo` at any point during a workflow (discuss, research, plan, execute, verify). When this happens:
|
|
30
|
+
- Treat it as an independent command — process the todo addition, then resume the current workflow where you left off.
|
|
31
|
+
- Do NOT incorporate the todo content into the current requirement, plan, or discussion.
|
|
32
|
+
- Do NOT let the todo interrupt or alter the ongoing workflow state.
|
|
33
|
+
|
|
34
|
+
## Map-First File Lookup Rule
|
|
35
|
+
|
|
36
|
+
When searching for project-related files, agents must follow this priority:
|
|
37
|
+
1. **First**, check `.ca/map.md` (if it exists) for the file location or relevant section.
|
|
38
|
+
2. **Only if** the map does not contain the needed information, fall back to Glob/Grep search.
|
|
39
|
+
|
|
40
|
+
This reduces unnecessary searches and ensures agents leverage the existing codebase map.
|