poly-agent 1.0.5 → 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 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.5",
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
+ }
@@ -82,3 +82,22 @@ status: [in-progress | completed | blocked | paused]
82
82
  5. You edit `src/routes/login.ts`
83
83
  6. You update `.context/feature-api-auth.md` again
84
84
  7. Continue until task complete, then set status to `completed`
85
+
86
+ ## Recalling Context
87
+
88
+ When a user asks to recall or resume a context (e.g., "recall feature-auth", "continue from context X", "load context"):
89
+
90
+ 1. **Read ONLY the specified context file** from `.context/` - Do NOT scan the entire project
91
+ 2. **Trust the context file** - It contains all the information you need
92
+ 3. **Summarize the current state** - What was done, what remains
93
+ 4. **Confirm understanding** with the user before proceeding
94
+ 5. **Only read files listed in "Files Changed"** if you need to check current state
95
+ 6. **Continue updating** the same context file as you work
96
+
97
+ **IMPORTANT**: When recalling context, do NOT:
98
+ - Search or scan the entire codebase
99
+ - Read files not mentioned in the context
100
+ - Run broad exploratory searches
101
+ - Assume information beyond what's in the context file
102
+
103
+ If asked to **list contexts**, read the `.context/` directory and show available files with their status.
@@ -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.
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: Context Recall
3
+ description: Load and resume work from a saved context file.
4
+ ---
5
+ # Context Recall
6
+
7
+ You are being asked to **resume work** from a previously saved context.
8
+
9
+ ## Instructions
10
+
11
+ 1. **Read the context file** specified by the user (from `.context/` directory)
12
+ 2. **Understand the state** - Review the summary, files changed, goals, and progress
13
+ 3. **Identify next steps** - Look at what was marked as pending or in "Next Steps"
14
+ 4. **Resume seamlessly** - Continue the work as if you never left
15
+
16
+ ## How to Use
17
+
18
+ The user will provide one of:
19
+ - A context file name: `feature-auth` or `feature-auth.md`
20
+ - A full path: `.context/feature-auth.md`
21
+ - Or ask you to list available contexts
22
+
23
+ ## If Asked to List Contexts
24
+
25
+ Read the `.context/` directory and present available context files:
26
+
27
+ ```
28
+ Available contexts:
29
+ - feature-auth.md (updated: 2026-01-12)
30
+ - bugfix-api-timeout.md (updated: 2026-01-11)
31
+ - refactor-database.md (updated: 2026-01-10)
32
+ ```
33
+
34
+ ## After Loading Context
35
+
36
+ 1. **Summarize** what you understand about the task
37
+ 2. **Confirm** the current state and what remains to be done
38
+ 3. **Ask** if the user wants to continue from where it left off, or modify the approach
39
+ 4. **Continue updating** the same context file as you make changes
40
+
41
+ ## Example Interaction
42
+
43
+ **User**: "Recall context feature-auth"
44
+
45
+ **You**:
46
+ > I've loaded the context for **feature-auth**:
47
+ >
48
+ > **Summary**: Implementing JWT-based authentication for the API
49
+ >
50
+ > **Progress**:
51
+ > - ✅ Created auth middleware
52
+ > - ✅ Set up login route
53
+ > - ⏳ Token refresh logic (in progress)
54
+ > - ⬜ Rate limiting
55
+ >
56
+ > **Last worked on**: `src/auth/refresh.ts`
57
+ >
58
+ > Would you like me to continue with the token refresh logic, or would you prefer to work on something else?
59
+
60
+ ## Critical Rules
61
+
62
+ 1. **ONLY read the context file** - Do NOT scan the entire project or codebase
63
+ 2. **Trust the context file** - It contains everything you need to understand the task
64
+ 3. **Read files listed in "Files Changed"** - Only if you need to understand current state
65
+ 4. **Don't guess or make up content** - Only use information from the context file
66
+ 5. **If context file doesn't exist** - Inform the user and offer to create one
67
+ 6. **Keep the context file updated** - As you continue working
68
+
69
+ ## What NOT To Do
70
+
71
+ - ❌ Do NOT search the entire codebase to "understand the project"
72
+ - ❌ Do NOT read files that aren't mentioned in the context
73
+ - ❌ Do NOT run broad searches or scans
74
+ - ❌ Do NOT assume context beyond what's in the file
75
+
76
+ ## What TO Do
77
+
78
+ - ✅ Read ONLY `.context/[name].md` first
79
+ - ✅ Use the "Files Changed" section to know which files are relevant
80
+ - ✅ Read specific files from "Files Changed" if needed for current state
81
+ - ✅ Follow "Next Steps" from the context file
82
+ - ✅ Ask the user if anything is unclear