aircana 3.0.0.rc7 → 3.0.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.
data/README.md CHANGED
@@ -5,21 +5,9 @@
5
5
 
6
6
  ## Intro
7
7
 
8
- Aircana is a "batteries-included" CLI for creating and managing Claude Code plugins. It provides:
8
+ Aircana is a CLI for generating [Claude Code plugins](https://docs.claude.com/en/docs/claude-code/plugins) with per-agent knowledge bases. Each agent gets a curated knowledge base synced from Confluence (label-based) or web URLs, yielding more relevant, predictable, and project-specific results than general-purpose agents.
9
9
 
10
- **Plugin Development**: Create distributable Claude Code plugins with proper manifests and structure.
11
-
12
- **Knowledge Base Management**: Agent-accessible knowledge bases sourced from Confluence or public websites, with automatic syncing and caching.
13
-
14
- **Specialized Agents**: Generate domain-specific agents with dedicated knowledge bases for improved context management.
15
-
16
- **Complete Development Workflow**: Five-phase workflow (plan, record, execute, review, apply-feedback) for systematic feature development.
17
-
18
- **Hook Management**: Event-driven automation through Claude Code hooks with support for multiple hook types.
19
-
20
- **Plugin Distribution**: Create plugins that can be shared via Claude Code plugin marketplaces.
21
-
22
- While Aircana includes features beneficial in many agentic contexts (like knowledge base syncing), its primary tools are built on "human-in-the-loop" principles.
10
+ Knowledge bases automatically refresh once daily on session start, keeping agents up-to-date without manual intervention. Knowledge sources are tracked in version-controlled manifests, so team members can independently refresh content while keeping actual documentation out of git.
23
11
 
24
12
  ## How can I try it?
25
13
 
@@ -97,6 +85,8 @@ aircana plugin validate
97
85
 
98
86
  ### Things to try
99
87
 
88
+ - Follow the [Getting Started](#getting-started) tutorial to create agents with knowledge bases—Aircana's key differentiator
89
+
100
90
  - Configure the Confluence integration and create domain-specific agents
101
91
 
102
92
  - Use the `/ask-expert` command to consult multiple specialized agents
@@ -105,108 +95,152 @@ aircana plugin validate
105
95
 
106
96
  - Explore other tools by running `aircana --help`
107
97
 
108
- ## Development Workflow
98
+ ## Getting Started
109
99
 
110
- Aircana provides a complete development lifecycle through five integrated slash commands:
100
+ This tutorial walks through creating a complete Claude Code plugin with agents backed by Confluence knowledge bases, then publishing it to a marketplace for team distribution.
111
101
 
112
- ```mermaid
113
- stateDiagram-v2
114
- [*] --> Plan: /plan
115
- Plan --> Record: /record
116
- Record --> Execute: /execute
117
- Execute --> Review: /review
118
- Review --> ApplyFeedback: /apply-feedback
119
- ApplyFeedback --> Review: More issues found
120
- ApplyFeedback --> [*]: Satisfied
102
+ ### Prerequisites
103
+
104
+ 1. **Install Aircana:**
105
+ ```bash
106
+ gem install aircana
107
+ aircana doctor # Verify dependencies
121
108
  ```
122
109
 
123
- ### Quick Overview
110
+ 2. **Configure Confluence (optional but recommended):**
124
111
 
125
- 1. **`/plan`** - Create strategic implementation plan
126
- 2. **`/record`** - Save plan to Jira ticket
127
- 3. **`/execute`** - Implement plan and create commit
128
- 4. **`/review`** - Adversarial code review with expert feedback
129
- 5. **`/apply-feedback`** - Apply review changes and amend commit
112
+ Add to your shell profile (`.bashrc`, `.zshrc`, etc.):
113
+ ```bash
114
+ export CONFLUENCE_BASE_URL="https://your-company.atlassian.net"
115
+ export CONFLUENCE_USERNAME="your.email@company.com"
116
+ export CONFLUENCE_API_TOKEN="your-generated-token"
117
+ ```
130
118
 
131
- ### Command Details
119
+ To generate a Confluence API token:
120
+ 1. Go to your Confluence instance
121
+ 2. Click profile picture → **Account Settings** → **Security**
122
+ 3. Select **Create and manage API tokens** → **Create API token**
123
+ 4. Copy the token and add to your environment variables
132
124
 
133
- #### 1. `/plan` - Strategic Planning
125
+ Reload your shell: `source ~/.zshrc` (or your shell config file)
134
126
 
135
- Creates a high-level implementation plan by:
136
- - Asking you to specify relevant files and directories
137
- - Consulting specialized sub-agents for domain expertise
138
- - Sharing research context to avoid duplicate work
139
- - Generating a focused strategic plan (what to do, not how)
140
- - Creating actionable todo checklist
127
+ ### Step 1: Create Your Plugin
141
128
 
142
- The planner focuses on architecture decisions and approach, avoiding exhaustive code implementations.
129
+ ```bash
130
+ # Create a new directory for your plugin
131
+ mkdir my-team-plugin
132
+ cd my-team-plugin
143
133
 
144
- #### 2. `/record` - Save to Jira
134
+ # Initialize the plugin
135
+ aircana init --plugin-name my-team
145
136
 
146
- Records your approved plan to a Jira ticket by:
147
- - Taking the ticket key/ID as input
148
- - Delegating to the `jira` sub-agent for MCP operations
149
- - Storing the plan in the ticket description or comments
137
+ # Verify the structure was created
138
+ ls -la
139
+ ```
150
140
 
151
- This creates a traceable link between planning and execution.
141
+ This creates:
142
+ - `.claude-plugin/plugin.json` - Plugin manifest with metadata
143
+ - `agents/` - Directory for specialized agents
144
+ - `commands/` - Custom slash commands
145
+ - `hooks/hooks.json` - Hook configurations
146
+ - `scripts/` - Hook scripts and utilities
152
147
 
153
- #### 3. `/execute` - Implementation
148
+ ### Step 2: Create an Agent Backed by Confluence
154
149
 
155
- Executes the strategic plan by:
156
- - Reading the plan from the Jira ticket
157
- - Creating detailed implementation todo list
158
- - Presenting plan for your approval
159
- - Implementing changes sequentially
160
- - Writing unit tests (delegates to test-writing sub-agent if available)
161
- - Running tests to verify implementation
162
- - Creating git commit (delegates to git-ops sub-agent if available)
150
+ ```bash
151
+ aircana agents create
152
+ ```
163
153
 
164
- After commit creation, suggests running `/review`.
154
+ You'll be prompted for:
155
+ - **Agent name**: e.g., "backend-api" (use kebab-case)
156
+ - **Description**: e.g., "Expert in backend API development and best practices"
157
+ - **Model**: Choose sonnet (smarter), haiku (faster), or inherit (uses default)
158
+ - **Color**: Pick an interface color for visual identification
165
159
 
166
- #### 4. `/review` - Adversarial Review
160
+ The agent file is created at `agents/backend-api.md` with:
161
+ - Agent configuration (name, description, model)
162
+ - Knowledge base path reference
163
+ - Custom instructions
167
164
 
168
- Conducts comprehensive code review of HEAD commit by:
169
- - Analyzing changed files to identify technical domains
170
- - Using sub-agent-coordinator to select relevant expert agents
171
- - Presenting changes to experts in parallel
172
- - Synthesizing feedback organized by severity (Critical/Important/Suggestions)
173
- - Storing review output for next step
165
+ ### Step 3: Tag Confluence Pages
174
166
 
175
- Explicitly states "Reviewing: <commit message>" and ends with "Run /apply-feedback".
167
+ In Confluence, label pages you want the agent to access:
176
168
 
177
- #### 5. `/apply-feedback` - Apply Changes
169
+ 1. Open a relevant Confluence page (e.g., "API Design Guidelines")
170
+ 2. Click **...** → **Edit labels**
171
+ 3. Add label: `backend-api` (must match your agent name)
172
+ 4. Click **Save**
178
173
 
179
- Applies code review feedback by:
180
- - Reading review output from conversation context
181
- - Creating prioritized change plan (critical issues first)
182
- - Presenting plan for your approval
183
- - Applying approved changes
184
- - Re-running unit tests
185
- - Fixing any test failures
186
- - **Amending HEAD commit** with improvements using `git commit --amend --no-edit`
174
+ Repeat for all documentation pages relevant to this agent. Aircana will discover pages by label during the refresh process.
187
175
 
188
- This preserves the original commit message while incorporating review improvements in a single commit.
176
+ **Tip:** Use a consistent labeling strategy. For example, label all backend documentation with `backend-api`, all frontend docs with `frontend-expert`, etc.
189
177
 
190
- ### Usage Example
178
+ ### Step 4: Refresh Agent Knowledge
191
179
 
192
180
  ```bash
193
- # 1. Start planning
194
- /plan
195
- > Specify relevant files: src/api/, spec/api/
181
+ aircana agents refresh backend-api
182
+ ```
196
183
 
197
- # 2. Save plan to ticket
198
- /record PROJ-123
184
+ This will:
185
+ 1. Search Confluence for pages labeled `backend-api`
186
+ 2. Download page content via Confluence REST API
187
+ 3. Convert HTML to Markdown using ReverseMarkdown
188
+ 4. Store content in the knowledge base directory
189
+ 5. Update `agents/backend-api/manifest.json` with source metadata
199
190
 
200
- # 3. Execute implementation
201
- /execute PROJ-123
191
+ **Output:** Knowledge files are created in `~/.claude/agents/my-team-backend-api/knowledge/`
202
192
 
203
- # 4. Review the commit
204
- /review
193
+ **Note:** The actual knowledge content is stored globally (not in your plugin directory) to avoid version control bloat and potential sensitive information leaks. Only the manifest (source tracking) is version controlled.
205
194
 
206
- # 5. Apply feedback
207
- /apply-feedback
195
+ ### Step 5: Add Web URLs (Optional)
196
+
197
+ You can also add public web documentation to your agent's knowledge base:
198
+
199
+ ```bash
200
+ aircana agents add-url backend-api https://docs.example.com/api-guide
201
+ aircana agents add-url backend-api https://restfulapi.net/rest-architectural-constraints/
208
202
  ```
209
203
 
204
+ This downloads the web page, extracts main content (removes nav/ads/scripts), converts to Markdown, and adds it to the knowledge base.
205
+
206
+ Refresh to sync web URLs:
207
+ ```bash
208
+ aircana agents refresh backend-api
209
+ ```
210
+
211
+ ### Step 6: Use Your Agent
212
+
213
+ Your agent is now ready! Claude Code will automatically consult your agent when appropriate based on the agent's description. You can also explicitly request the agent:
214
+
215
+ ```
216
+ Ask backend-api to review this API endpoint design
217
+ Ask backend-api how to implement authentication
218
+ ```
219
+
220
+ The agent has access to all Confluence pages and web URLs you've synced to its knowledge base.
221
+
222
+ ### Step 7: Share Your Plugin with Your Team
223
+
224
+ For detailed instructions on distributing your plugin via Git repositories or Claude Code plugin marketplaces, see the official [Claude Code Plugin Marketplaces documentation](https://docs.claude.com/en/docs/claude-code/plugin-marketplaces).
225
+
226
+ **Quick summary:**
227
+ - Share via Git repository: Team members clone the plugin, configure Confluence credentials, and run `aircana agents refresh-all`
228
+ - Publish to a marketplace: Create a marketplace.json file in a separate repository, add your plugin metadata, and team members install via the marketplace UI
229
+
230
+ ### Next: Keep Knowledge Up-to-Date
231
+
232
+ As your Confluence documentation evolves:
233
+
234
+ ```bash
235
+ # Refresh a specific agent's knowledge
236
+ aircana agents refresh backend-api
237
+
238
+ # Or refresh all agents at once
239
+ aircana agents refresh-all
240
+ ```
241
+
242
+ Knowledge sources are tracked in `agents/<agent-name>/manifest.json`, so team members can independently refresh without manual coordination.
243
+
210
244
  ## Key Concepts
211
245
 
212
246
  ### Plugins
@@ -266,7 +300,7 @@ Aircana provides each agent with a human-curated knowledge base stored within th
266
300
  - Stay up-to-date with refreshable sources
267
301
  - Provide more relevant responses with less back-and-forth
268
302
 
269
- Knowledge bases support multiple source types and can be refreshed to pull the latest content.
303
+ Knowledge bases support multiple source types and can be refreshed to pull the latest content. **Aircana-generated plugins automatically refresh all agent knowledge bases once daily on session start** via the SessionStart hook, keeping agents up-to-date without manual intervention.
270
304
 
271
305
  #### Confluence
272
306
 
@@ -334,6 +368,137 @@ At Instructure this means you can easily configure Claude Code to send you slack
334
368
 
335
369
  (Instructions coming soon, send a message if you want help with this)
336
370
 
371
+ ## Best Practices
372
+
373
+ ### Designing Effective Agents
374
+
375
+ **Design agents as narrow domain experts, not generalists.** More granular agents with focused knowledge bases generally perform better than broad, general-purpose agents.
376
+
377
+ **Examples:**
378
+
379
+ ✅ **Good - Narrow domains:**
380
+ - `database-schema-expert` - Database design, migrations, indexing strategies
381
+ - `api-authentication-expert` - OAuth, JWT, session management
382
+ - `frontend-styling-expert` - CSS, design systems, responsive layouts
383
+
384
+ ❌ **Avoid - Too broad:**
385
+ - `backend-engineer` - Too many domains, knowledge base becomes unfocused
386
+ - `full-stack-developer` - Overlapping responsibilities with unclear boundaries
387
+
388
+ **Why narrow domains work better:**
389
+ - **Focused knowledge bases**: Each agent gets highly relevant documentation for their specific domain
390
+ - **Better results**: Agents can provide more accurate, detailed answers within their expertise
391
+ - **Less context pollution**: Smaller, focused context windows prevent information overload
392
+ - **Non-overlapping responsibilities**: Clear delegation boundaries reduce confusion
393
+
394
+ **Tips:**
395
+ - Break large domains into smaller, specialized areas
396
+ - Each agent should have a clear, distinct purpose
397
+ - Knowledge bases should contain 5-20 highly relevant documents, not 100+ loosely related ones
398
+ - Use agent descriptions to clearly define boundaries and expertise areas
399
+
400
+ ## Development Workflow
401
+
402
+ Aircana provides a complete development lifecycle through five integrated slash commands:
403
+
404
+ ```mermaid
405
+ stateDiagram-v2
406
+ [*] --> Plan: /plan
407
+ Plan --> Record: /record
408
+ Record --> Execute: /execute
409
+ Execute --> Review: /review
410
+ Review --> ApplyFeedback: /apply-feedback
411
+ ApplyFeedback --> Review: More issues found
412
+ ApplyFeedback --> [*]: Satisfied
413
+ ```
414
+
415
+ ### Quick Overview
416
+
417
+ 1. **`/plan`** - Create strategic implementation plan
418
+ 2. **`/record`** - Save plan to Jira ticket
419
+ 3. **`/execute`** - Implement plan and create commit
420
+ 4. **`/review`** - Adversarial code review with expert feedback
421
+ 5. **`/apply-feedback`** - Apply review changes and amend commit
422
+
423
+ ### Command Details
424
+
425
+ #### 1. `/plan` - Strategic Planning
426
+
427
+ Creates a high-level implementation plan by:
428
+ - Asking you to specify relevant files and directories
429
+ - Consulting specialized sub-agents for domain expertise
430
+ - Sharing research context to avoid duplicate work
431
+ - Generating a focused strategic plan (what to do, not how)
432
+ - Creating actionable todo checklist
433
+
434
+ The planner focuses on architecture decisions and approach, avoiding exhaustive code implementations.
435
+
436
+ #### 2. `/record` - Save to Jira
437
+
438
+ Records your approved plan to a Jira ticket by:
439
+ - Taking the ticket key/ID as input
440
+ - Delegating to the `jira` sub-agent for MCP operations
441
+ - Storing the plan in the ticket description or comments
442
+
443
+ This creates a traceable link between planning and execution.
444
+
445
+ #### 3. `/execute` - Implementation
446
+
447
+ Executes the strategic plan by:
448
+ - Reading the plan from the Jira ticket
449
+ - Creating detailed implementation todo list
450
+ - Presenting plan for your approval
451
+ - Implementing changes sequentially
452
+ - Writing unit tests (delegates to test-writing sub-agent if available)
453
+ - Running tests to verify implementation
454
+ - Creating git commit (delegates to git-ops sub-agent if available)
455
+
456
+ After commit creation, suggests running `/review`.
457
+
458
+ #### 4. `/review` - Adversarial Review
459
+
460
+ Conducts comprehensive code review of HEAD commit by:
461
+ - Analyzing changed files to identify technical domains
462
+ - Using sub-agent-coordinator to select relevant expert agents
463
+ - Presenting changes to experts in parallel
464
+ - Synthesizing feedback organized by severity (Critical/Important/Suggestions)
465
+ - Storing review output for next step
466
+
467
+ Explicitly states "Reviewing: <commit message>" and ends with "Run /apply-feedback".
468
+
469
+ #### 5. `/apply-feedback` - Apply Changes
470
+
471
+ Applies code review feedback by:
472
+ - Reading review output from conversation context
473
+ - Creating prioritized change plan (critical issues first)
474
+ - Presenting plan for your approval
475
+ - Applying approved changes
476
+ - Re-running unit tests
477
+ - Fixing any test failures
478
+ - **Amending HEAD commit** with improvements using `git commit --amend --no-edit`
479
+
480
+ This preserves the original commit message while incorporating review improvements in a single commit.
481
+
482
+ ### Usage Example
483
+
484
+ ```bash
485
+ # 1. Start planning
486
+ /plan
487
+ > Specify relevant files: src/api/, spec/api/
488
+
489
+ # 2. Save plan to ticket
490
+ /record PROJ-123
491
+
492
+ # 3. Execute implementation
493
+ /execute PROJ-123
494
+
495
+ # 4. Review the commit
496
+ /review
497
+
498
+ # 5. Apply feedback
499
+ /apply-feedback
500
+ ```
501
+
337
502
  ## Configuration (Optional)
338
503
 
339
504
  ### Confluence Setup (Optional)
@@ -408,73 +573,6 @@ aircana doctor
408
573
 
409
574
  This will check if Confluence and other integrations are properly configured.
410
575
 
411
- ## Agent Workflow Tutorial
412
-
413
- Here's a complete example of creating an agent and syncing knowledge from Confluence:
414
-
415
- ### 1. Create an Agent
416
-
417
- ```bash
418
- aircana agents create
419
- ```
420
-
421
- You'll be prompted for:
422
- - **Agent name**: e.g., "backend-api"
423
- - **Description**: e.g., "Helps with backend API development"
424
- - **Model**: Choose from sonnet, haiku, or inherit
425
- - **Color**: Choose interface color
426
-
427
- ### 2. Tag Confluence Pages
428
-
429
- In Confluence, add the label `backend-api` (matching your agent name) to relevant pages:
430
-
431
- 1. Open a Confluence page with relevant documentation
432
- 2. Click **...** → **Edit labels**
433
- 3. Add label: `backend-api`
434
- 4. Save
435
-
436
- Repeat for all pages you want the agent to know about.
437
-
438
- ### 3. Add Knowledge Sources
439
-
440
- **From Confluence:**
441
- ```bash
442
- aircana agents refresh backend-api
443
- ```
444
-
445
- This downloads all Confluence pages labeled `backend-api` and makes them available to your agent.
446
-
447
- **From Web URLs:**
448
- ```bash
449
- aircana agents add-url backend-api https://docs.example.com/api-guide
450
- aircana agents add-url backend-api https://blog.example.com/best-practices
451
- ```
452
-
453
- This fetches web content and converts it to Markdown for your agent's knowledge base.
454
-
455
- ### 4. Use the Agent
456
-
457
- Once created with a good description, Claude Code will automatically use your agent when appropriate during conversations. You can also explicitly request a specific agent:
458
-
459
- ```
460
- Ask backend-api for a code review of this function
461
- Ask backend-api to help debug this API endpoint
462
- Ask rspec-test-writer to write and run tests for @file
463
- ```
464
-
465
- The agent will have access to all the Confluence knowledge you synced.
466
-
467
- ### 5. Update Knowledge
468
-
469
- Whenever you update Confluence pages, add new ones with the agent label, or want to refresh web content:
470
-
471
- ```bash
472
- aircana agents refresh backend-api
473
- ```
474
-
475
- This refreshes both Confluence pages and web URLs associated with the agent.
476
-
477
-
478
576
  ## All Commands
479
577
 
480
578
  ### Plugin Management
@@ -30,7 +30,7 @@ Work through each task in the todo list sequentially:
30
30
  TASK DETAILS:
31
31
 
32
32
  1. PARSE FEEDBACK: Extract review feedback from conversation:
33
- - Look for review output from previous /air-review command
33
+ - Look for review output from previous /review command
34
34
  - Parse feedback organized by severity (Critical / Important / Suggestions)
35
35
  - Extract actionable items with file, line, issue, and recommendation
36
36
  - If no review feedback found in context, inform user and exit
data/agents/executor.md CHANGED
@@ -72,7 +72,7 @@ TASK DETAILS:
72
72
  - Provide context: Jira ticket key, summary of changes, files modified
73
73
  - If no git-ops agent exists, create commit directly using Bash tool
74
74
  - Commit message should reference Jira ticket and describe implementation
75
- - After successful commit, suggest user runs '/air-review' command to review changes
75
+ - After successful commit, suggest user runs '/review' command to review changes
76
76
 
77
77
  IMPORTANT INSTRUCTIONS:
78
78
  - ALWAYS start by creating the todo list file before doing any other work
data/agents/planner.md CHANGED
@@ -14,7 +14,7 @@ MANDATORY WORKFLOW (Use TodoWrite to track):
14
14
  3. Perform targeted research on user-specified files
15
15
  4. Create implementation plan in current session
16
16
  5. Iterate with user feedback
17
- 6. Suggest '/air-record' command to save plan to Jira
17
+ 6. Suggest '/record' command to save plan to Jira
18
18
 
19
19
  TASK DETAILS:
20
20
 
data/agents/reviewer.md CHANGED
@@ -20,7 +20,7 @@ First, create a todo list file with the following tasks enumerated in order:
20
20
  6. Present changes to each expert agent in parallel for review
21
21
  7. Synthesize feedback organized by severity
22
22
  8. Present comprehensive review report
23
- 9. Suggest running '/air-apply-feedback' command
23
+ 9. Suggest running '/apply-feedback' command
24
24
 
25
25
  STEP 2: EXECUTE EACH TASK IN ORDER
26
26
  Work through each task in the todo list sequentially:
@@ -79,7 +79,7 @@ TASK DETAILS:
79
79
  - Store this output in conversation context for apply-feedback agent
80
80
 
81
81
  9. NEXT STEPS: End with clear instruction:
82
- - Output: "Run /air-apply-feedback to apply recommended changes"
82
+ - Output: "Run /apply-feedback to apply recommended changes"
83
83
  - This guides user to next step in workflow
84
84
 
85
85
  IMPORTANT INSTRUCTIONS:
@@ -29,7 +29,7 @@ module Aircana
29
29
  end
30
30
 
31
31
  desc "dump-context",
32
- "dumps relevant files, knowledge, memories, and decisions for the specified agent"
32
+ "dumps knowledge, memories, and decisions for the specified agent"
33
33
  option :verbose, type: :boolean, default: true
34
34
  def dump_context(agent_name)
35
35
  DumpContext.run(agent_name: agent_name, verbose: options[:verbose])
@@ -25,6 +25,7 @@ module Aircana
25
25
  end
26
26
 
27
27
  def run
28
+ clean_output_directories
28
29
  generators.each(&:generate)
29
30
  generate_default_agents
30
31
  generate_default_hooks
@@ -33,6 +34,16 @@ module Aircana
33
34
 
34
35
  private
35
36
 
37
+ def clean_output_directories
38
+ # Remove stale command files to prevent duplicates during init
39
+ commands_dir = File.join(Aircana.configuration.output_dir, "commands")
40
+ FileUtils.rm_rf(Dir.glob("#{commands_dir}/*")) if Dir.exist?(commands_dir)
41
+
42
+ # Remove stale agent files for consistency
43
+ agents_dir = File.join(Aircana.configuration.output_dir, "agents")
44
+ FileUtils.rm_rf(Dir.glob("#{agents_dir}/*")) if Dir.exist?(agents_dir)
45
+ end
46
+
36
47
  def generate_default_agents
37
48
  Aircana::Generators::AgentsGenerator.available_default_agents.each do |agent_name|
38
49
  Aircana::Generators::AgentsGenerator.create_default_agent(agent_name)
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module Aircana
4
6
  class Configuration
5
7
  attr_accessor :global_dir, :project_dir, :stream, :output_dir,
6
8
  :claude_code_config_path, :claude_code_project_config_path, :agent_knowledge_dir,
7
9
  :hooks_dir, :scripts_dir, :confluence_base_url, :confluence_username, :confluence_api_token,
8
- :plugin_root, :plugin_manifest_dir, :commands_dir, :agents_dir
10
+ :plugin_root, :plugin_manifest_dir, :commands_dir, :agents_dir, :global_agents_dir
9
11
 
10
12
  def initialize
11
13
  setup_directory_paths
@@ -30,6 +32,28 @@ module Aircana
30
32
  File.join(@hooks_dir, "hooks.json")
31
33
  end
32
34
 
35
+ # Returns the plugin name from plugin.json, or falls back to directory name
36
+ def plugin_name
37
+ return @plugin_name if defined?(@plugin_name)
38
+
39
+ @plugin_name = if plugin_mode?
40
+ manifest = JSON.parse(File.read(plugin_manifest_path))
41
+ manifest["name"]
42
+ else
43
+ # Fallback to directory name if not in plugin mode
44
+ File.basename(@plugin_root).downcase.gsub(/[^a-z0-9]+/, "-")
45
+ end
46
+ rescue StandardError
47
+ # If anything fails, use directory name as fallback
48
+ File.basename(@plugin_root).downcase.gsub(/[^a-z0-9]+/, "-")
49
+ end
50
+
51
+ # Returns the global knowledge directory path for an agent
52
+ # Format: ~/.claude/agents/<plugin-name>-<agent-name>/knowledge/
53
+ def global_agent_knowledge_path(agent_name)
54
+ File.join(@global_agents_dir, "#{plugin_name}-#{agent_name}", "knowledge")
55
+ end
56
+
33
57
  private
34
58
 
35
59
  def setup_directory_paths
@@ -54,6 +78,8 @@ module Aircana
54
78
  @claude_code_config_path = File.join(Dir.home, ".claude")
55
79
  # For backward compatibility, keep this but plugin mode uses plugin_root
56
80
  @claude_code_project_config_path = File.join(Dir.pwd, ".claude")
81
+ # Global agents directory for knowledge bases (not version controlled)
82
+ @global_agents_dir = File.join(Dir.home, ".claude", "agents")
57
83
  end
58
84
 
59
85
  def setup_stream
@@ -20,7 +20,8 @@ module Aircana
20
20
 
21
21
  def create_agent_knowledge_dir(agent)
22
22
  config = Aircana.configuration
23
- agent_dir = File.join(config.agent_knowledge_dir, agent, "knowledge")
23
+ # Use global agents directory with plugin prefix
24
+ agent_dir = config.global_agent_knowledge_path(agent)
24
25
 
25
26
  FileUtils.mkdir_p(agent_dir)
26
27
 
@@ -45,7 +45,7 @@ module Aircana
45
45
  def locals
46
46
  super.merge({
47
47
  agent_name:, short_description:, description:,
48
- model:, color:, knowledge_path:
48
+ model:, color:, knowledge_path:, plugin_prefix:
49
49
  })
50
50
  end
51
51
 
@@ -63,9 +63,13 @@ module Aircana
63
63
  File.join(Aircana.configuration.agents_dir, "#{agent_name}.md")
64
64
  end
65
65
 
66
+ def plugin_prefix
67
+ Aircana.configuration.plugin_name
68
+ end
69
+
66
70
  def knowledge_path
67
- # Use plugin-relative path for knowledge base
68
- "agents/#{agent_name}/knowledge/"
71
+ # Use global agents directory with plugin prefix
72
+ "~/.claude/agents/#{plugin_prefix}-#{agent_name}/knowledge/"
69
73
  end
70
74
  end
71
75
  end
@@ -5,7 +5,7 @@ model: <%= model %>
5
5
  color: <%= color %>
6
6
  ---
7
7
 
8
- <%= helpers.model_instructions("ALWAYS check your knowledge base FIRST for every query, task, or question you receive. Use `ls ${CLAUDE_PLUGIN_ROOT}/agents/#{agent_name}/knowledge/*.md` to list files from your knowledge base.
8
+ <%= helpers.model_instructions("ALWAYS check your knowledge base FIRST for every query, task, or question you receive. Use `ls #{knowledge_path}*.md` to list files from your knowledge base.
9
9
 
10
10
  MANDATORY WORKFLOW:
11
11
  1. BEFORE responding to ANY request - search and read relevant files in your knowledge base
@@ -18,7 +18,7 @@ Your knowledge base contains domain-specific information that takes priority ove
18
18
 
19
19
  ## Knowledge Base Integration
20
20
 
21
- Your specialized knowledge is in the plugin directory. Use `ls ${CLAUDE_PLUGIN_ROOT}/agents/<%= agent_name %>/knowledge/*.md` to list available files, then read them with the Read tool.
21
+ Your specialized knowledge is in the global agents directory. Use `ls <%= knowledge_path %>*.md` to list available files, then read them with the Read tool.
22
22
 
23
23
  This knowledge base contains:
24
24
  - Domain-specific documentation from Confluence