poly-agent 1.0.6 → 1.0.7
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/dist/cli.js +48 -1
- package/dist/lib/prompt-loader.js +3 -0
- package/package.json +2 -2
- package/prompts/_shared/context-rule.md +104 -0
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { intro, select, multiselect, spinner, log, outro, cancel, isCancel } from '@clack/prompts';
|
|
2
|
+
import { intro, select, multiselect, spinner, log, outro, cancel, isCancel, confirm } from '@clack/prompts';
|
|
3
3
|
import fs from 'fs/promises';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import os from 'os';
|
|
5
6
|
import { PromptLoader } from './lib/prompt-loader.js';
|
|
6
7
|
import { createRequire } from 'module';
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
@@ -40,6 +41,17 @@ const IDE_DIRECTORIES = {
|
|
|
40
41
|
'Antigravity': '.agent/workflows',
|
|
41
42
|
'Claude': '.claude/skills',
|
|
42
43
|
};
|
|
44
|
+
const IDE_GLOBAL_CONFIG_DIR = {
|
|
45
|
+
'Cursor': '.cursor',
|
|
46
|
+
'Antigravity': '.antigravity',
|
|
47
|
+
'Claude': '.claude',
|
|
48
|
+
};
|
|
49
|
+
function getGlobalRulesPath(ide) {
|
|
50
|
+
const homeDir = os.homedir();
|
|
51
|
+
const configDir = IDE_GLOBAL_CONFIG_DIR[ide] || `.${ide.toLowerCase()}`;
|
|
52
|
+
// Assuming 'rules' directory for all pending further customization
|
|
53
|
+
return path.join(homeDir, configDir, 'rules');
|
|
54
|
+
}
|
|
43
55
|
async function runInit() {
|
|
44
56
|
// Welcome message
|
|
45
57
|
intro('Welcome to PolyAgent CLI');
|
|
@@ -141,6 +153,41 @@ ${prompt.content}`;
|
|
|
141
153
|
log.error(`Failed to install prompts: ${error instanceof Error ? error.message : String(error)}`);
|
|
142
154
|
process.exit(1);
|
|
143
155
|
}
|
|
156
|
+
// Step 5: Ask if user wants global context rule
|
|
157
|
+
const wantsContextRule = await confirm({
|
|
158
|
+
message: 'Install global context-rule for automatic context management?',
|
|
159
|
+
initialValue: true
|
|
160
|
+
});
|
|
161
|
+
if (isCancel(wantsContextRule)) {
|
|
162
|
+
cancel('Operation cancelled.');
|
|
163
|
+
process.exit(0);
|
|
164
|
+
}
|
|
165
|
+
if (wantsContextRule) {
|
|
166
|
+
const globalRuleS = spinner();
|
|
167
|
+
const globalRulePath = getGlobalRulesPath(selectedIDE);
|
|
168
|
+
globalRuleS.start(`Installing global context rule to ${globalRulePath}...`);
|
|
169
|
+
try {
|
|
170
|
+
await fs.mkdir(globalRulePath, { recursive: true });
|
|
171
|
+
// Load shared instructions to find context-hook
|
|
172
|
+
// UPDATED: Copy context-rule.md directly from _shared
|
|
173
|
+
const contextRulePath = path.join(promptsDir, '_shared', 'context-rule.md');
|
|
174
|
+
try {
|
|
175
|
+
const contextRuleContent = await fs.readFile(contextRulePath, 'utf-8');
|
|
176
|
+
await fs.writeFile(path.join(globalRulePath, 'context-rule.md'), contextRuleContent, 'utf-8');
|
|
177
|
+
globalRuleS.stop('✓ Global context rule installed successfully');
|
|
178
|
+
log.info(` - ${path.join(globalRulePath, 'context-rule.md')}`);
|
|
179
|
+
}
|
|
180
|
+
catch (readError) {
|
|
181
|
+
globalRuleS.stop('! Context rule file not found in _shared but installation continued');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
globalRuleS.stop('✗ Global rule installation failed');
|
|
186
|
+
log.error(`Failed to install global rule: ${error instanceof Error ? error.message : String(error)}`);
|
|
187
|
+
// Don't exit process, as local prompts might have been installed successfully
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
outro('Installation complete! 🎉');
|
|
144
191
|
}
|
|
145
192
|
function showHelp() {
|
|
146
193
|
console.log(`
|
|
@@ -82,6 +82,8 @@ export class PromptLoader {
|
|
|
82
82
|
// Inject variables
|
|
83
83
|
content = this.injectVariables(content, variables);
|
|
84
84
|
// Append shared instructions
|
|
85
|
+
// logic moved to CLI for global installation
|
|
86
|
+
/*
|
|
85
87
|
const sharedInstructions = await this.loadSharedInstructions();
|
|
86
88
|
if (sharedInstructions.length > 0) {
|
|
87
89
|
const sharedContent = sharedInstructions
|
|
@@ -89,6 +91,7 @@ export class PromptLoader {
|
|
|
89
91
|
.join('\n');
|
|
90
92
|
content = content + sharedContent;
|
|
91
93
|
}
|
|
94
|
+
*/
|
|
92
95
|
return { name, description, content };
|
|
93
96
|
}
|
|
94
97
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poly-agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "CLI installer for AI IDE prompts - install commands, skills, and workflows for Cursor, ClaudeCode, and Antigravity",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"ts-node": "^10.9.2",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Context Rule
|
|
3
|
+
description: Shared instructions for automatic context dumping after file edits.
|
|
4
|
+
mode: always apply
|
|
5
|
+
type: shared
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Context Management Hook
|
|
9
|
+
|
|
10
|
+
## Behavior
|
|
11
|
+
|
|
12
|
+
After **every file edit** you make, you MUST update the project context file. This ensures continuity across conversations and helps maintain a clear record of progress.
|
|
13
|
+
|
|
14
|
+
## When to Update Context
|
|
15
|
+
|
|
16
|
+
1. **After any file edit** - Immediately after modifying, creating, or deleting a file
|
|
17
|
+
2. **When the task context changes** - New goals, pivots, or scope changes
|
|
18
|
+
3. **When explicitly mentioned** - If the user references `.context/` or asks about context
|
|
19
|
+
4. **At conversation milestones** - Completing a feature, fixing a bug, reaching a checkpoint
|
|
20
|
+
|
|
21
|
+
## Context File Location & Naming
|
|
22
|
+
|
|
23
|
+
- **Directory**: `.context/`
|
|
24
|
+
- **Filename**: Generate a short, descriptive kebab-case name based on the current task
|
|
25
|
+
- Examples: `feature-auth.md`, `bugfix-api-timeout.md`, `refactor-database-layer.md`, `setup-ci-pipeline.md`
|
|
26
|
+
- **Persistence**: Use the SAME context file throughout a conversation/task. Only create a new one if the task fundamentally changes.
|
|
27
|
+
|
|
28
|
+
## Context File Format
|
|
29
|
+
|
|
30
|
+
Use this exact structure:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
---
|
|
34
|
+
created: [ISO timestamp when first created]
|
|
35
|
+
updated: [ISO timestamp of last update]
|
|
36
|
+
task: [One-line task description]
|
|
37
|
+
status: [in-progress | completed | blocked | paused]
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Context: [short-name]
|
|
41
|
+
|
|
42
|
+
## Summary
|
|
43
|
+
[2-3 sentence AI-generated summary of what this task is about and current state]
|
|
44
|
+
|
|
45
|
+
## Files Changed
|
|
46
|
+
- `path/to/file.ts` - [Brief description of change]
|
|
47
|
+
- `path/to/another.ts` - [Brief description of change]
|
|
48
|
+
|
|
49
|
+
## Current Goals
|
|
50
|
+
1. [Primary goal]
|
|
51
|
+
2. [Secondary goal]
|
|
52
|
+
3. [etc.]
|
|
53
|
+
|
|
54
|
+
## Progress
|
|
55
|
+
- [x] [Completed item]
|
|
56
|
+
- [x] [Completed item]
|
|
57
|
+
- [ ] [Pending item]
|
|
58
|
+
- [ ] [Pending item]
|
|
59
|
+
|
|
60
|
+
## Next Steps
|
|
61
|
+
- [Immediate next action]
|
|
62
|
+
- [Following action]
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
65
|
+
[Any important context, decisions made, blockers, or things to remember]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Rules
|
|
69
|
+
|
|
70
|
+
1. **Always update, never skip** - Even small edits warrant a context update
|
|
71
|
+
2. **Be concise but complete** - Capture essential information without verbosity
|
|
72
|
+
3. **Track ALL file changes** - Every file you touch should be listed
|
|
73
|
+
4. **Maintain history** - Don't remove completed items from Progress, mark them done
|
|
74
|
+
5. **Update timestamps** - Always update the `updated` field in frontmatter
|
|
75
|
+
6. **Create directory if needed** - If `.context/` doesn't exist, create it
|
|
76
|
+
|
|
77
|
+
## Example Workflow
|
|
78
|
+
|
|
79
|
+
1. User asks: "Add authentication to the API"
|
|
80
|
+
2. You create/update `.context/feature-api-auth.md` with initial goals
|
|
81
|
+
3. You edit `src/auth/middleware.ts`
|
|
82
|
+
4. You immediately update `.context/feature-api-auth.md` with the file change
|
|
83
|
+
5. You edit `src/routes/login.ts`
|
|
84
|
+
6. You update `.context/feature-api-auth.md` again
|
|
85
|
+
7. Continue until task complete, then set status to `completed`
|
|
86
|
+
|
|
87
|
+
## Recalling Context
|
|
88
|
+
|
|
89
|
+
When a user asks to recall or resume a context (e.g., "recall feature-auth", "continue from context X", "load context"):
|
|
90
|
+
|
|
91
|
+
1. **Read ONLY the specified context file** from `.context/` - Do NOT scan the entire project
|
|
92
|
+
2. **Trust the context file** - It contains all the information you need
|
|
93
|
+
3. **Summarize the current state** - What was done, what remains
|
|
94
|
+
4. **Confirm understanding** with the user before proceeding
|
|
95
|
+
5. **Only read files listed in "Files Changed"** if you need to check current state
|
|
96
|
+
6. **Continue updating** the same context file as you work
|
|
97
|
+
|
|
98
|
+
**IMPORTANT**: When recalling context, do NOT:
|
|
99
|
+
- Search or scan the entire codebase
|
|
100
|
+
- Read files not mentioned in the context
|
|
101
|
+
- Run broad exploratory searches
|
|
102
|
+
- Assume information beyond what's in the context file
|
|
103
|
+
|
|
104
|
+
If asked to **list contexts**, read the `.context/` directory and show available files with their status.
|