pmpt-cli 1.14.17 → 1.14.21

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.
@@ -1,7 +1,7 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import { join, dirname, resolve, sep } from 'path';
3
3
  import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
4
- import { isInitialized, getConfigDir, getHistoryDir, getDocsDir, initializeProject } from '../lib/config.js';
4
+ import { isInitialized, getConfigDir, getHistoryDir, getDocsDir, initializeProject, ensurePmptClaudeMd, ensureMcpJson } from '../lib/config.js';
5
5
  import { validatePmptFile, isSafeFilename } from '../lib/pmptFile.js';
6
6
  import { fetchPmptFile, trackClone } from '../lib/api.js';
7
7
  import { copyToClipboard } from '../lib/clipboard.js';
@@ -112,6 +112,9 @@ export async function cmdClone(slug) {
112
112
  const docsDir = getDocsDir(projectPath);
113
113
  // History is not restored — user's journey starts fresh from v1.
114
114
  // The version summary is embedded in pmpt.ai.md for AI reference.
115
+ // Add pmpt MCP instructions to CLAUDE.md and register .mcp.json for Claude Code
116
+ ensurePmptClaudeMd(projectPath);
117
+ ensureMcpJson(projectPath);
115
118
  if (pmptData.docs) {
116
119
  restoreDocs(docsDir, pmptData.docs);
117
120
  }
@@ -161,7 +164,13 @@ export async function cmdClone(slug) {
161
164
  `- When requirements change or new decisions are made`,
162
165
  '',
163
166
  `Keep the Progress and Snapshot Log sections in pmpt.md up to date.`,
164
- `After significant milestones, run \`pmpt save\` to create a snapshot.`,
167
+ `**Always save proactively after milestones do not wait for the user to ask.**`,
168
+ ``,
169
+ `Try the pmpt MCP tool first:`,
170
+ `- Claude Code: call \`mcp__pmpt__pmpt_save\` with a descriptive \`summary\``,
171
+ `- Other MCP clients: call \`pmpt_save\` with a descriptive \`summary\``,
172
+ ``,
173
+ `If no MCP tool is available, run \`pmpt save\` in terminal.`,
165
174
  '',
166
175
  '---',
167
176
  '',
@@ -1,7 +1,7 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import { existsSync, readFileSync, writeFileSync } from 'fs';
3
3
  import { resolve, basename, join } from 'path';
4
- import { initializeProject, isInitialized, getDocsDir } from '../lib/config.js';
4
+ import { initializeProject, isInitialized, getDocsDir, ensurePmptClaudeMd, ensureMcpJson } from '../lib/config.js';
5
5
  import { isGitRepo, getGitInfo, formatGitInfo, getCommitCount } from '../lib/git.js';
6
6
  import { cmdPlan } from './plan.js';
7
7
  import { scanProject, scanResultToAnswers } from '../lib/scanner.js';
@@ -97,6 +97,9 @@ export async function cmdInit(path, options) {
97
97
  gitCommitsAtInit: isGit ? gitCommits : undefined,
98
98
  });
99
99
  s.stop('Initialized');
100
+ // Add pmpt MCP instructions to CLAUDE.md and register .mcp.json for Claude Code
101
+ ensurePmptClaudeMd(projectPath);
102
+ ensureMcpJson(projectPath);
100
103
  // Build folder structure display
101
104
  const notes = [
102
105
  `Path: ${config.projectPath}`,
@@ -114,7 +114,13 @@ When you make progress, update \`.pmpt/docs/pmpt.md\`:
114
114
  - When a feature is implemented (mark as done)
115
115
  - When a development phase is completed
116
116
 
117
- Keep the Snapshot Log up to date. Run \`pmpt save\` after milestones.
117
+ Keep the Snapshot Log up to date. **Always save proactively after milestones — do not wait for the user to ask.**
118
+
119
+ Try the pmpt MCP tool first:
120
+ - Claude Code: call \`mcp__pmpt__pmpt_save\` with a descriptive \`summary\`
121
+ - Other MCP clients: call \`pmpt_save\` with a descriptive \`summary\`
122
+
123
+ If no MCP tool is available, run \`pmpt save\` in terminal.
118
124
 
119
125
  ---
120
126
 
@@ -1,5 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
2
+ import { join, dirname } from 'path';
3
+ import { execSync } from 'child_process';
3
4
  const CONFIG_DIR = '.pmpt';
4
5
  const CONFIG_FILE = 'config.json';
5
6
  const DEFAULT_DOCS_DIR = 'docs';
@@ -61,6 +62,87 @@ export function saveConfig(projectPath, config) {
61
62
  const configPath = join(getConfigDir(projectPath), CONFIG_FILE);
62
63
  writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
63
64
  }
65
+ const PMPT_CLAUDE_SECTION = `
66
+ <!-- pmpt -->
67
+ ## pmpt MCP Tools
68
+
69
+ This project uses [pmpt](https://pmptwiki.com) to track development progress.
70
+
71
+ **If pmpt MCP is available in this session**, use these tools proactively — do not wait for the user to ask:
72
+ - \`mcp__pmpt__pmpt_save\` — save a snapshot after milestones (always include a \`summary\`)
73
+ - \`mcp__pmpt__pmpt_status\` — check project status
74
+ - \`mcp__pmpt__pmpt_read_context\` — read project context at session start
75
+
76
+ Save after: feature completion, architecture decisions, bug fixes, or any significant progress.
77
+
78
+ If pmpt MCP is not available, run \`pmpt save\` in terminal instead.
79
+ <!-- /pmpt -->
80
+ `;
81
+ /**
82
+ * Add pmpt MCP instructions to CLAUDE.md in the project root.
83
+ * Creates the file if it doesn't exist; appends the section if not already present.
84
+ */
85
+ export function ensurePmptClaudeMd(projectPath) {
86
+ const claudeMdPath = join(projectPath, 'CLAUDE.md');
87
+ const marker = '<!-- pmpt -->';
88
+ if (existsSync(claudeMdPath)) {
89
+ const content = readFileSync(claudeMdPath, 'utf-8');
90
+ if (content.includes(marker))
91
+ return; // already has pmpt section
92
+ writeFileSync(claudeMdPath, content.trimEnd() + '\n' + PMPT_CLAUDE_SECTION, 'utf-8');
93
+ }
94
+ else {
95
+ writeFileSync(claudeMdPath, '# Project Instructions\n' + PMPT_CLAUDE_SECTION, 'utf-8');
96
+ }
97
+ }
98
+ function detectPmptMcpPath() {
99
+ // Strategy 1: sibling to the current pmpt binary
100
+ try {
101
+ const pmptBin = process.argv[1];
102
+ const siblingPath = join(dirname(pmptBin), 'pmpt-mcp');
103
+ if (existsSync(siblingPath))
104
+ return siblingPath;
105
+ }
106
+ catch { /* skip */ }
107
+ // Strategy 2: which / where command
108
+ try {
109
+ const cmd = process.platform === 'win32' ? 'where pmpt-mcp' : 'which pmpt-mcp';
110
+ const result = execSync(cmd, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
111
+ const firstLine = result.split('\n')[0].trim();
112
+ if (firstLine && existsSync(firstLine))
113
+ return firstLine;
114
+ }
115
+ catch { /* not in PATH */ }
116
+ return null;
117
+ }
118
+ /**
119
+ * Create or update .mcp.json in the project root to register the pmpt MCP server.
120
+ * Skips silently if pmpt-mcp binary cannot be found.
121
+ */
122
+ export function ensureMcpJson(projectPath) {
123
+ const mcpJsonPath = join(projectPath, '.mcp.json');
124
+ const mcpPath = detectPmptMcpPath();
125
+ if (!mcpPath)
126
+ return; // can't detect binary — skip silently
127
+ let config = {};
128
+ if (existsSync(mcpJsonPath)) {
129
+ try {
130
+ config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));
131
+ }
132
+ catch {
133
+ config = {};
134
+ }
135
+ // Already registered — don't overwrite
136
+ const servers = config.mcpServers;
137
+ if (servers?.pmpt)
138
+ return;
139
+ }
140
+ if (!config.mcpServers || typeof config.mcpServers !== 'object') {
141
+ config.mcpServers = {};
142
+ }
143
+ config.mcpServers.pmpt = { command: mcpPath };
144
+ writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
145
+ }
64
146
  const PMPT_README = `# .pmpt — Your Project's Development Journal
65
147
 
66
148
  This folder is managed by [pmpt](https://pmptwiki.com). It records your product development journey with AI.
package/dist/lib/plan.js CHANGED
@@ -98,13 +98,23 @@ ${workflowSteps}
98
98
  - When requirements change or new decisions are made
99
99
 
100
100
  Keep the Progress and Snapshot Log sections in pmpt.md up to date.
101
- After significant milestones, run \`pmpt save\` to create a snapshot.
101
+ After significant milestones, save a snapshot using the method below.
102
+
103
+ ### Saving Snapshots
104
+
105
+ **Always save proactively after milestones — do not wait for the user to ask.**
106
+
107
+ Try the pmpt MCP tool first:
108
+ - Claude Code: call \`mcp__pmpt__pmpt_save\` with a descriptive \`summary\`
109
+ - Other MCP clients: call \`pmpt_save\` with a descriptive \`summary\`
110
+
111
+ If no MCP tool is available, run \`pmpt save\` in the terminal.
102
112
 
103
113
  ### Per-Feature Checklist
104
114
  After completing each feature above:
105
115
  1. Mark the feature done in \`.pmpt/docs/pmpt.md\` (change \`- [ ]\` to \`- [x]\`)
106
116
  2. Add a brief note to the Snapshot Log section
107
- 3. Run \`pmpt save\` in terminal
117
+ 3. Call \`mcp__pmpt__pmpt_save\` (or \`pmpt save\` in terminal) with a summary
108
118
 
109
119
  ### What to Record in pmpt.md
110
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmpt-cli",
3
- "version": "1.14.17",
3
+ "version": "1.14.21",
4
4
  "description": "Record and share your AI-driven product development journey",
5
5
  "type": "module",
6
6
  "bin": {