claude-autopm 3.1.0 → 3.1.2

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.
@@ -0,0 +1,334 @@
1
+ # Context Compaction Rules - MANDATORY
2
+
3
+ > **CRITICAL**: Apply these compaction strategies to prevent context window exhaustion during long sessions.
4
+
5
+ ## Core Principle
6
+
7
+ **Context is a finite resource.** Every token matters. Compact aggressively, preserve strategically.
8
+
9
+ ## Automatic Compaction Triggers
10
+
11
+ ### Trigger 1: Tool Result Accumulation
12
+
13
+ **When**: 10+ tool results in session
14
+
15
+ **Action**: Summarize older tool results
16
+
17
+ ```markdown
18
+ # BEFORE (consuming ~5000 tokens per result)
19
+ Tool Result 1: [full 500-line file]
20
+ Tool Result 2: [full 300-line file]
21
+ ...
22
+ Tool Result 15: [full 200-line file]
23
+
24
+ # AFTER (consuming ~200 tokens per summary)
25
+ ## Compacted Tool Results
26
+ - config.json: DB settings (PostgreSQL:5432), API keys, feature flags
27
+ - src/auth.js: Authentication module with login/logout/validateToken
28
+ - package.json: Node 18, React 18, Express 4, Jest testing
29
+ ...
30
+ ```
31
+
32
+ ### Trigger 2: Code Block Proliferation
33
+
34
+ **When**: Same file read 3+ times OR 10+ different files read
35
+
36
+ **Action**: Consolidate to essential references
37
+
38
+ ```markdown
39
+ # BEFORE
40
+ [src/auth.js - first read - 200 lines]
41
+ [src/auth.js - second read after edit - 205 lines]
42
+ [src/auth.js - third read to verify - 205 lines]
43
+
44
+ # AFTER
45
+ ## src/auth.js Summary
46
+ - Purpose: User authentication with JWT
47
+ - Key functions: login(email, password), validateToken(jwt), refreshToken()
48
+ - Modified sections: lines 45-60 (added MFA check)
49
+ - Current length: 205 lines
50
+ - Last state: MFA integrated, tests passing
51
+ ```
52
+
53
+ ### Trigger 3: Thinking Block Growth
54
+
55
+ **When**: Multiple extended reasoning chains completed
56
+
57
+ **Action**: Compress to decisions and rationale
58
+
59
+ ```markdown
60
+ # BEFORE
61
+ <thinking>
62
+ Let me analyze this step by step...
63
+ First, I should consider option A because...
64
+ Actually, option B might be better since...
65
+ On further reflection, option A is correct because...
66
+ [500+ tokens of reasoning]
67
+ </thinking>
68
+
69
+ # AFTER
70
+ ## Decision: Option A (Authentication Strategy)
71
+ - Choice: JWT with refresh tokens
72
+ - Rationale: Stateless architecture, better scalability
73
+ - Rejected: Sessions (state management complexity)
74
+ ```
75
+
76
+ ### Trigger 4: Conversation Length
77
+
78
+ **When**: 30+ messages in session
79
+
80
+ **Action**: Summarize completed topics
81
+
82
+ ```markdown
83
+ # BEFORE
84
+ [Messages 1-15: Debugging authentication issue]
85
+ [Messages 16-25: Implementing MFA]
86
+ [Messages 26-35: Current work on dashboard]
87
+
88
+ # AFTER
89
+ ## Session Summary (Messages 1-25)
90
+ ### Completed: Authentication Debugging
91
+ - Issue: Token validation failing on refresh
92
+ - Fix: Updated expiry check in validateToken()
93
+ - PR: #123 merged
94
+
95
+ ### Completed: MFA Implementation
96
+ - Added TOTP support
97
+ - Backup codes generated
98
+ - Tests: 15/15 passing
99
+
100
+ ## Active Context (Messages 26+)
101
+ [Current dashboard implementation work...]
102
+ ```
103
+
104
+ ## Compaction Formats
105
+
106
+ ### Format 1: File Summary
107
+
108
+ ```markdown
109
+ ## File: [path]
110
+ - Purpose: [one-line description]
111
+ - Key exports: [list main functions/classes]
112
+ - Dependencies: [external dependencies]
113
+ - Modified: [what changed, if applicable]
114
+ - State: [current state/version]
115
+ ```
116
+
117
+ ### Format 2: Search Results Summary
118
+
119
+ ```markdown
120
+ ## Search: [query]
121
+ - Total matches: [count]
122
+ - Key files: [most relevant files]
123
+ - Pattern: [what the matches reveal]
124
+ - Action needed: [what to do with this info]
125
+ ```
126
+
127
+ ### Format 3: Test Results Summary
128
+
129
+ ```markdown
130
+ ## Tests: [suite/file]
131
+ - Status: [PASS/FAIL] ([passed]/[total])
132
+ - Failures: [list failing tests if any]
133
+ - Coverage: [percentage if available]
134
+ - Action: [what to fix/investigate]
135
+ ```
136
+
137
+ ### Format 4: Decision Record
138
+
139
+ ```markdown
140
+ ## Decision: [title]
141
+ - Choice: [what was decided]
142
+ - Rationale: [why, in one sentence]
143
+ - Rejected: [alternatives not chosen]
144
+ - Impact: [what this affects]
145
+ ```
146
+
147
+ ## Preservation Rules
148
+
149
+ ### ALWAYS Preserve
150
+
151
+ 1. **Active Task Context**
152
+ - Current file being edited
153
+ - Unsaved changes
154
+ - Active error messages
155
+
156
+ 2. **Critical Decisions**
157
+ - Architectural choices
158
+ - Security configurations
159
+ - Breaking changes
160
+
161
+ 3. **Blocking Issues**
162
+ - Current errors
163
+ - Failing tests
164
+ - Unresolved dependencies
165
+
166
+ 4. **User Requirements**
167
+ - Original request
168
+ - Constraints specified
169
+ - Preferences stated
170
+
171
+ ### SAFE to Compact
172
+
173
+ 1. **Historical Tool Results**
174
+ - Files read 5+ messages ago
175
+ - Search results already acted upon
176
+ - Test results from passing suites
177
+
178
+ 2. **Superseded Information**
179
+ - Old file versions
180
+ - Rejected approaches
181
+ - Fixed bugs
182
+
183
+ 3. **Verbose Output**
184
+ - Full stack traces (keep summary)
185
+ - Build logs (keep errors only)
186
+ - Long lists (keep relevant items)
187
+
188
+ 4. **Exploratory Work**
189
+ - Hypothesis testing completed
190
+ - Alternative approaches evaluated
191
+ - Research phase findings
192
+
193
+ ## Implementation Patterns
194
+
195
+ ### Pattern 1: Progressive Summarization
196
+
197
+ ```markdown
198
+ # Level 0: Full content (initial read)
199
+ [Complete file: 500 lines]
200
+
201
+ # Level 1: Key sections (after analysis)
202
+ ## Key Sections in config.json
203
+ - Database config (lines 1-50)
204
+ - API settings (lines 51-100)
205
+ - Feature flags (lines 101-150)
206
+
207
+ # Level 2: Actionable summary (after decision)
208
+ config.json: Using PostgreSQL on 5432, rate limit 100/min, darkMode enabled
209
+ ```
210
+
211
+ ### Pattern 2: Rolling Window
212
+
213
+ Keep last N items in full detail, summarize older:
214
+
215
+ ```markdown
216
+ ## Recent (full detail)
217
+ - Tool Result 8: [full content]
218
+ - Tool Result 9: [full content]
219
+ - Tool Result 10: [full content]
220
+
221
+ ## Historical (summarized)
222
+ - Results 1-7: config files read, auth system analyzed,
223
+ tests confirmed passing, dependencies validated
224
+ ```
225
+
226
+ ### Pattern 3: Topic-Based Grouping
227
+
228
+ Group related items for efficient summarization:
229
+
230
+ ```markdown
231
+ ## Authentication Work (compacted)
232
+ Files read: src/auth.js, src/middleware/auth.js, src/models/User.js
233
+ Changes made: Added MFA support (auth.js:45-60)
234
+ Tests: 15/15 passing
235
+ Outcome: MFA feature complete
236
+
237
+ ## Database Work (compacted)
238
+ Files read: src/db/connection.js, migrations/*.js
239
+ Changes made: Added index on users.email
240
+ Tests: 8/8 passing
241
+ Outcome: Query performance improved 40%
242
+ ```
243
+
244
+ ## Enforcement
245
+
246
+ ### Self-Check Questions
247
+
248
+ Before adding new content, ask:
249
+ 1. Is this information already in context (in another form)?
250
+ 2. Will this be needed after the current operation?
251
+ 3. Can this be summarized without losing actionable details?
252
+ 4. Does this duplicate information from another tool result?
253
+
254
+ ### Compaction Checklist
255
+
256
+ When context feels heavy:
257
+ - [ ] Summarize tool results older than 5 messages
258
+ - [ ] Compress completed reasoning chains
259
+ - [ ] Consolidate multiple reads of same file
260
+ - [ ] Remove superseded information
261
+ - [ ] Group related items into summaries
262
+
263
+ ### Warning Signs
264
+
265
+ **Immediate Action Needed:**
266
+ - Response times noticeably slower
267
+ - "Context too long" errors
268
+ - Repetitive information in context
269
+ - Multiple versions of same file
270
+ - 50+ messages without compaction
271
+
272
+ ## Integration with /clear
273
+
274
+ ### When to Compact vs Clear
275
+
276
+ | Situation | Action |
277
+ |-----------|--------|
278
+ | Same task, growing context | Compact |
279
+ | Task complete, starting new | /clear |
280
+ | Context heavy but continuity needed | Compact + Checkpoint |
281
+ | Unrelated topics mixing | /clear |
282
+ | Long research session | Compact progressively |
283
+
284
+ ### Handoff Pattern
285
+
286
+ Before `/clear`, create transfer summary:
287
+
288
+ ```markdown
289
+ ## Session Transfer Summary
290
+
291
+ ### Completed
292
+ - [list completed items]
293
+
294
+ ### In Progress
295
+ - [current state]
296
+
297
+ ### Preserved Context
298
+ - [critical information for next session]
299
+
300
+ ### Next Steps
301
+ - [what to do next]
302
+ ```
303
+
304
+ ## Metrics
305
+
306
+ ### Context Efficiency Score
307
+
308
+ Calculate: (Useful tokens / Total tokens) Ɨ 100
309
+
310
+ - **>80%**: Excellent - minimal waste
311
+ - **60-80%**: Good - some optimization possible
312
+ - **40-60%**: Fair - compaction recommended
313
+ - **<40%**: Poor - immediate compaction needed
314
+
315
+ ### Token Budget Guidelines
316
+
317
+ | Session Type | Recommended Budget |
318
+ |--------------|-------------------|
319
+ | Quick fix | <20k tokens |
320
+ | Feature implementation | <50k tokens |
321
+ | Complex debugging | <80k tokens |
322
+ | Full project work | <100k tokens + checkpoints |
323
+
324
+ ## Summary
325
+
326
+ **Golden Rules:**
327
+ 1. Compact early, compact often
328
+ 2. Preserve decisions, discard deliberation
329
+ 3. Summarize verbose output immediately
330
+ 4. Use progressive summarization
331
+ 5. Create checkpoints for long work
332
+ 6. /clear between unrelated tasks
333
+
334
+ **Remember**: A well-compacted context leads to better responses, faster processing, and more productive sessions.
@@ -0,0 +1,15 @@
1
+ {
2
+ "current_task": {
3
+ "id": "",
4
+ "title": "",
5
+ "branch": "",
6
+ "started": "",
7
+ "status": "pending"
8
+ },
9
+ "recent_changes": [],
10
+ "blockers": [],
11
+ "next_steps": [],
12
+ "context_notes": "",
13
+ "decisions_made": [],
14
+ "files_of_interest": []
15
+ }
@@ -0,0 +1,58 @@
1
+ # Checkpoint: {{FEATURE_NAME}}
2
+
3
+ **Date**: {{TIMESTAMP}}
4
+ **Session**: {{SESSION_NUMBER}}
5
+
6
+ ## Status Summary
7
+
8
+ - **Overall Progress**: {{PERCENTAGE}}% complete
9
+ - **Tests**: {{TESTS_PASSING}}/{{TESTS_TOTAL}} passing
10
+ - **Branch**: {{BRANCH_NAME}}
11
+ - **Last Commit**: {{COMMIT_HASH}}
12
+
13
+ ## Completed Items
14
+
15
+ - [x] {{COMPLETED_ITEM_1}}
16
+ - [x] {{COMPLETED_ITEM_2}}
17
+
18
+ ## In Progress
19
+
20
+ - [ ] {{IN_PROGRESS_ITEM}} - {{CURRENT_STATE}}
21
+
22
+ ## Pending
23
+
24
+ - [ ] {{PENDING_ITEM_1}}
25
+ - [ ] {{PENDING_ITEM_2}}
26
+
27
+ ## Key Decisions Made
28
+
29
+ | Decision | Choice | Rationale |
30
+ |----------|--------|-----------|
31
+ | {{DECISION_1}} | {{CHOICE_1}} | {{RATIONALE_1}} |
32
+
33
+ ## Critical Context
34
+
35
+ - {{CRITICAL_INFO_1}}
36
+ - {{CRITICAL_INFO_2}}
37
+
38
+ ## Files Modified This Session
39
+
40
+ - `{{FILE_1}}` - {{CHANGE_DESCRIPTION_1}}
41
+ - `{{FILE_2}}` - {{CHANGE_DESCRIPTION_2}}
42
+
43
+ ## Commands to Resume
44
+
45
+ ```bash
46
+ git checkout {{BRANCH_NAME}}
47
+ npm install
48
+ npm run dev
49
+ # Then: "Continue {{FEATURE_NAME}} implementation"
50
+ ```
51
+
52
+ ## Notes for Next Session
53
+
54
+ - {{NOTE_1}}
55
+ - {{NOTE_2}}
56
+
57
+ ---
58
+ *Generated by context-optimizer agent*
@@ -301,11 +301,91 @@ async function prdStatus(argv) {
301
301
  }
302
302
  }
303
303
 
304
+ /**
305
+ * Create new PRD from content (non-interactive mode)
306
+ * @param {Object} argv - Command arguments
307
+ */
308
+ async function prdNewFromContent(argv) {
309
+ const spinner = ora(`Creating PRD: ${argv.name}`).start();
310
+
311
+ try {
312
+ let content = argv.content;
313
+
314
+ // Check if content is a file reference (starts with @)
315
+ if (content.startsWith('@')) {
316
+ const filePath = content.slice(1); // Remove @ prefix
317
+ const absolutePath = path.isAbsolute(filePath)
318
+ ? filePath
319
+ : path.join(process.cwd(), filePath);
320
+
321
+ const fileExists = await fs.pathExists(absolutePath);
322
+ if (!fileExists) {
323
+ spinner.fail(chalk.red('Source file not found'));
324
+ console.error(chalk.red(`\nError: File not found: ${absolutePath}`));
325
+ process.exit(1);
326
+ }
327
+
328
+ content = await fs.readFile(absolutePath, 'utf8');
329
+ spinner.text = `Reading content from: ${absolutePath}`;
330
+ }
331
+
332
+ // Ensure PRDs directory exists
333
+ const prdsDir = path.join(process.cwd(), '.claude', 'prds');
334
+ await fs.ensureDir(prdsDir);
335
+
336
+ // Check if PRD already exists
337
+ const prdPath = getPrdPath(argv.name);
338
+ const exists = await fs.pathExists(prdPath);
339
+ if (exists && !argv.force) {
340
+ spinner.fail(chalk.red('PRD already exists'));
341
+ console.error(chalk.red(`\nError: PRD file already exists: ${prdPath}`));
342
+ console.error(chalk.yellow('Use --force to overwrite'));
343
+ process.exit(1);
344
+ }
345
+
346
+ // Add frontmatter if not present
347
+ if (!content.startsWith('---')) {
348
+ const timestamp = new Date().toISOString();
349
+ const frontmatter = `---
350
+ title: ${argv.name}
351
+ status: draft
352
+ priority: ${argv.priority || 'P2'}
353
+ created: ${timestamp}
354
+ author: ${process.env.USER || 'unknown'}
355
+ timeline: ${argv.timeline || 'TBD'}
356
+ ---
357
+
358
+ `;
359
+ content = frontmatter + content;
360
+ }
361
+
362
+ // Write PRD file
363
+ await fs.writeFile(prdPath, content);
364
+ spinner.succeed(chalk.green('PRD created successfully'));
365
+
366
+ console.log(chalk.green(`\nāœ… PRD created: ${prdPath}`));
367
+ console.log(chalk.cyan('\nšŸ“‹ Next steps:'));
368
+ console.log(` 1. Review: ${chalk.yellow('autopm prd show ' + argv.name)}`);
369
+ console.log(` 2. Edit: ${chalk.yellow('autopm prd edit ' + argv.name)}`);
370
+ console.log(` 3. Parse: ${chalk.yellow('autopm prd parse ' + argv.name)}`);
371
+
372
+ } catch (error) {
373
+ spinner.fail(chalk.red('Failed to create PRD'));
374
+ console.error(chalk.red(`\nError: ${error.message}`));
375
+ process.exit(1);
376
+ }
377
+ }
378
+
304
379
  /**
305
380
  * Create new PRD
306
381
  * @param {Object} argv - Command arguments
307
382
  */
308
383
  async function prdNew(argv) {
384
+ // Check if content is provided (non-interactive mode)
385
+ if (argv.content) {
386
+ return await prdNewFromContent(argv);
387
+ }
388
+
309
389
  // Check if AI mode is enabled
310
390
  if (argv.ai) {
311
391
  return await prdNewWithAI(argv);
@@ -803,7 +883,7 @@ function builder(yargs) {
803
883
  )
804
884
  .command(
805
885
  'new <name>',
806
- 'Create new PRD interactively',
886
+ 'Create new PRD interactively or from existing content',
807
887
  (yargs) => {
808
888
  return yargs
809
889
  .positional('name', {
@@ -815,6 +895,27 @@ function builder(yargs) {
815
895
  type: 'string',
816
896
  alias: 't'
817
897
  })
898
+ .option('content', {
899
+ describe: 'PRD content: inline text or @filepath to read from file (non-interactive)',
900
+ type: 'string',
901
+ alias: 'c'
902
+ })
903
+ .option('force', {
904
+ describe: 'Overwrite existing PRD file',
905
+ type: 'boolean',
906
+ alias: 'f',
907
+ default: false
908
+ })
909
+ .option('priority', {
910
+ describe: 'PRD priority (P0/P1/P2/P3)',
911
+ type: 'string',
912
+ alias: 'p',
913
+ default: 'P2'
914
+ })
915
+ .option('timeline', {
916
+ describe: 'PRD timeline (e.g., Q1 2025)',
917
+ type: 'string'
918
+ })
818
919
  .option('ai', {
819
920
  describe: 'Use AI to generate PRD content (requires ANTHROPIC_API_KEY)',
820
921
  type: 'boolean',
@@ -827,6 +928,8 @@ function builder(yargs) {
827
928
  })
828
929
  .example('autopm prd new my-feature', 'Create PRD with wizard')
829
930
  .example('autopm prd new payment-api --template api-feature', 'Create PRD from template')
931
+ .example('autopm prd new my-feature --content @/path/to/draft.md', 'Create from file')
932
+ .example('autopm prd new my-feature --content "# My PRD\\n\\nDescription..."', 'Create from inline')
830
933
  .example('autopm prd new my-feature --ai', 'AI-powered PRD generation')
831
934
  .example('autopm prd new my-feature --ai --stream', 'AI generation with streaming');
832
935
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-autopm",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Autonomous Project Management Framework for Claude Code - Advanced AI-powered development automation",
5
5
  "main": "bin/autopm.js",
6
6
  "workspaces": [
@@ -6,6 +6,11 @@ allowed-tools: Bash, Read, Write, LS, Task
6
6
 
7
7
  Break epic into concrete, actionable tasks.
8
8
 
9
+ **āš ļø IMPORTANT**: This is a Claude Code command file, not a standalone script.
10
+ - Execute via Claude Code as: `/pm:epic-decompose <feature_name>`
11
+ - Do NOT run as: `node .claude/scripts/pm/epic-decompose.js`
12
+ - This command has no standalone script equivalent
13
+
9
14
  ## Usage
10
15
 
11
16
  **Single Epic:**
@@ -24,14 +24,10 @@ Begin work on a GitHub issue with parallel agents based on work stream analysis.
24
24
  - If not found, search for file containing `github:.*issues/$ARGUMENTS` in frontmatter (old naming)
25
25
  - If not found: "āŒ No local task for issue #$ARGUMENTS. This issue may have been created outside the PM system."
26
26
 
27
- 3. **Check for analysis:**
28
- ` ``bash
29
- test -f .claude/epics/*/$ARGUMENTS-analysis.md || echo "āŒ No analysis found for issue #$ARGUMENTS
30
-
31
- Run: /pm:issue-analyze $ARGUMENTS first
32
- Or: /pm:issue-start $ARGUMENTS --analyze to do both"
33
- ` ``
34
- If no analysis exists and no --analyze flag, stop execution.
27
+ 3. **Check for analysis (when NOT using --analyze flag):**
28
+ - If user didn't use `--analyze` flag, check if analysis file exists
29
+ - Analysis file location: `.claude/epics/{epic_name}/$ARGUMENTS-analysis.md`
30
+ - If no analysis AND no `--analyze` flag: Stop and suggest using `--analyze` flag
35
31
 
36
32
  ## Required Documentation Access
37
33
 
@@ -71,7 +67,25 @@ See `.claude/rules/tdd.enforcement.md` for complete TDD requirements.
71
67
 
72
68
  ## Instructions
73
69
 
74
- ### 1. Ensure Branch Exists
70
+ ### 0. Handle --analyze Flag (if provided)
71
+
72
+ If user provided `--analyze` flag, delegate to the Node.js script:
73
+ ` ``bash
74
+ node packages/plugin-pm/scripts/pm/issue-start.cjs $ARGUMENTS --analyze
75
+ ` ``
76
+
77
+ This script will:
78
+ 1. Find the task file for the issue
79
+ 2. Generate analysis file with parallel work streams
80
+ 3. Create workspace structure
81
+ 4. Launch parallel agents based on analysis
82
+ 5. Handle all subsequent steps automatically
83
+
84
+ **STOP HERE** if using `--analyze` flag - the script handles everything.
85
+
86
+ ---
87
+
88
+ ### 1. Ensure Branch Exists (Non-analyze workflow)
75
89
 
76
90
  Check if epic branch exists:
77
91
  ` ``bash