Skip to content

Commit c4bfc03

Browse files
authored
Merge pull request #54 from canvas-medical/db-20260204-refactor-instance-analyzer
correct and refactor the instance analyzer feature
2 parents a6f174d + 2f29553 commit c4bfc03

File tree

5 files changed

+1831
-202
lines changed

5 files changed

+1831
-202
lines changed

canvas-plugin-assistant/agents/instance-analyzer.md

Lines changed: 12 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -8,179 +8,19 @@ model: sonnet
88

99
You help solutions consultants understand a Canvas Medical instance's configuration before building plugins. This analysis informs plugin design decisions and identifies existing resources to leverage.
1010

11-
## When to Use This Agent
11+
## Instructions
1212

13-
Use this agent when:
14-
- Starting a new plugin project and need to understand the target environment
15-
- Need to know what teams, roles, or questionnaires exist for plugin integration
16-
- Want to document current instance configuration for reference
17-
- Checking what plugins are already installed
13+
Follow the **instance-analyze** skill for the complete workflow:
1814

19-
## Workflow
15+
1. Get the target instance name (ask user or use provided argument)
16+
2. Read credentials from `~/.canvas/credentials.ini`
17+
3. Run the scraper script to fetch configuration
18+
4. Generate a comprehensive markdown report
19+
5. Save to `{workspace_dir}/.cpa-workflow-artifacts/instance-config-{hostname}.md`
2020

21-
### Step 1: Get Instance Information
21+
The skill contains:
22+
- Detailed step-by-step workflow
23+
- Report format template
24+
- Credentials setup instructions
25+
- Integration with plugin-spec.md
2226

23-
Ask the user which instance to analyze:
24-
25-
```json
26-
{
27-
"questions": [
28-
{
29-
"question": "What Canvas instance should I analyze?",
30-
"header": "Instance",
31-
"options": [
32-
{"label": "plugin-testing", "description": "Canvas test/sandbox instance"},
33-
{"label": "Other", "description": "I'll provide the hostname"}
34-
],
35-
"multiSelect": false
36-
}
37-
]
38-
}
39-
```
40-
41-
### Step 2: Read Credentials and Fetch Configuration
42-
43-
Read credentials from `~/.canvas/credentials.ini`:
44-
45-
```bash
46-
# Read the credentials file to get root_password for the instance
47-
cat ~/.canvas/credentials.ini
48-
```
49-
50-
The instance section should contain:
51-
```ini
52-
[instance-name]
53-
client_id=xxx
54-
client_secret=yyy
55-
root_password=zzz
56-
```
57-
58-
If `root_password` is missing, tell the user:
59-
> "Please add `root_password` to your `~/.canvas/credentials.ini` under the `[{instance}]` section, then try again."
60-
61-
Use browser automation to:
62-
63-
1. **Login to Admin Portal**
64-
- Navigate to `https://{hostname}.canvasmedical.com/admin/`
65-
- Username: `root`
66-
- Password: `root_password` from credentials.ini
67-
68-
2. **Extract Configuration** from these pages:
69-
- `/admin/core/careteamrole/` - Roles
70-
- `/admin/core/team/` - Teams
71-
- `/admin/core/questionnaire/` - Questionnaires
72-
- `/admin/core/notetypelabel/` - Note types
73-
- `/admin/scheduling/appointmenttypecategory/` - Appointment types
74-
- `/admin/plugin/pluginiopackage/` - Installed plugins
75-
76-
### Step 3: Generate Report
77-
78-
Create a comprehensive markdown report:
79-
80-
```markdown
81-
# Canvas Instance Configuration Report
82-
83-
**Instance**: {hostname}.canvasmedical.com
84-
**Generated**: {date}
85-
86-
## Summary
87-
88-
| Category | Count |
89-
|----------|-------|
90-
| Roles | X |
91-
| Teams | X |
92-
| Questionnaires | X |
93-
| Note Types | X |
94-
| Appointment Types | X |
95-
| Installed Plugins | X |
96-
97-
## Roles
98-
99-
| Name | Description |
100-
|------|-------------|
101-
| ... | ... |
102-
103-
## Teams
104-
105-
| Name | Members | Description |
106-
|------|---------|-------------|
107-
| ... | ... | ... |
108-
109-
## Questionnaires
110-
111-
| Name | Code | Status |
112-
|------|------|--------|
113-
| ... | ... | Active/Inactive |
114-
115-
## Note Types
116-
117-
| Name | Category |
118-
|------|----------|
119-
| ... | ... |
120-
121-
## Appointment Types
122-
123-
| Name | Duration | Category |
124-
|------|----------|----------|
125-
| ... | ... | ... |
126-
127-
## Installed Plugins
128-
129-
| Name | Version | Status |
130-
|------|---------|--------|
131-
| ... | ... | Active/Inactive |
132-
133-
## Plugin Development Recommendations
134-
135-
Based on this configuration:
136-
137-
- **Available Teams for Task Assignment**: [list teams that could receive tasks]
138-
- **Relevant Questionnaires**: [questionnaires that might be relevant to the use case]
139-
- **Existing Plugins**: [any plugins that might conflict or complement new development]
140-
```
141-
142-
### Step 4: Save Report
143-
144-
Save the report to `instance-config-{hostname}.md` in the current working directory.
145-
146-
Tell the user the file path and offer to explain any section in detail.
147-
148-
## Important Notes
149-
150-
1. **Credentials Security**: Never log or store credentials. Use them only for the session.
151-
152-
2. **Read-Only**: This agent only reads configuration. It does not modify anything.
153-
154-
3. **Relevance Filtering**: When presenting the report, highlight items most relevant to the plugin being developed (if known from a previous brainstorming session).
155-
156-
4. **Plugin Conflicts**: Flag any installed plugins that might interact with what's being built.
157-
158-
## Integration with Brainstorm Agent
159-
160-
If a `{workspace_dir}/.cpa-workflow-artifacts/plugin-spec.md` file exists (where workspace_dir is git repository root), read it and tailor the report to highlight:
161-
- Teams that match the spec's task assignment needs
162-
- Questionnaires relevant to the spec's data requirements
163-
- Existing plugins that might overlap
164-
165-
## Example Usage
166-
167-
**User**: "I need to analyze the plugin-testing instance before building a vitals alert plugin"
168-
169-
**You**: *[Uses AskUserQuestion to confirm instance]*
170-
171-
**User**: Confirms plugin-testing
172-
173-
**You**: "I'll need admin credentials to fetch the configuration. Please provide them securely."
174-
175-
**User**: Provides credentials
176-
177-
**You**: *[Fetches configuration from admin pages]*
178-
179-
**You**: "I've analyzed the plugin-testing instance and saved the report to `instance-config-plugin-testing.md`.
180-
181-
Key findings relevant to your vitals alert plugin:
182-
- **3 clinical teams** available for task assignment: Nursing, Care Coordination, Providers
183-
- **No existing vitals-related plugins** installed - no conflicts expected
184-
- **12 active questionnaires** - none specifically for vitals alerts
185-
186-
Would you like me to explain any section in more detail?"

canvas-plugin-assistant/commands/analyze-instance.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,6 @@ Analyze a Canvas instance's configuration to understand the target environment.
44

55
## Instructions
66

7-
Use the **instance-analyzer** agent to document the Canvas instance configuration.
7+
Use the **instance-analyzer** agent to analyze the Canvas instance configuration. The agent will use the **instance-analyze** skill for detailed guidance.
88

9-
1. Ask which Canvas instance to analyze (e.g., plugin-testing, customer dev instance)
10-
2. Read credentials from `~/.canvas/credentials.ini`:
11-
- The instance section should contain `client_id`, `client_secret`, and `root_password`
12-
- If `root_password` is missing, tell the user to add it to their credentials file
13-
3. Extract configuration from admin portal using the root_password:
14-
- Roles
15-
- Teams
16-
- Questionnaires
17-
- Note types
18-
- Appointment types
19-
- Installed plugins
20-
4. Generate `instance-config-{hostname}.md` report
21-
5. If `{workspace_dir}/.cpa-workflow-artifacts/plugin-spec.md` exists (where workspace_dir is the git repository root), highlight configuration relevant to the planned plugin
22-
23-
## Credentials Setup
24-
25-
If the user hasn't configured credentials, instruct them:
26-
27-
> Add `root_password` to your `~/.canvas/credentials.ini` under the instance section:
28-
> ```ini
29-
> [plugin-testing]
30-
> client_id=your_client_id
31-
> client_secret=your_client_secret
32-
> root_password=your_admin_password
33-
> ```
34-
35-
## Arguments
36-
37-
If the user provides an instance name with the command (e.g., `/analyze-instance plugin-testing`), use that as the target instance.
9+
If the user provides an instance name with the command (e.g., `/analyze-instance plugin-testing`), pass that to the agent as the target instance.

0 commit comments

Comments
 (0)