pmpt-cli 1.12.2 → 1.12.3
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/commands/diff.js +3 -2
- package/dist/commands/squash.js +2 -0
- package/dist/index.js +75 -4
- package/dist/lib/api.js +11 -0
- package/package.json +1 -1
package/dist/commands/diff.js
CHANGED
|
@@ -126,16 +126,17 @@ export function cmdDiff(v1, v2, pathOrOptions, maybeOptions) {
|
|
|
126
126
|
p.log.error('No snapshots found.');
|
|
127
127
|
process.exit(1);
|
|
128
128
|
}
|
|
129
|
+
const versionList = snapshots.map(s => `v${s.version}`).join(', ');
|
|
129
130
|
const fromIndex = snapshots.findIndex(s => s.version === fromVersion);
|
|
130
131
|
if (fromIndex === -1) {
|
|
131
|
-
p.log.error(`Version v${fromVersion} not found
|
|
132
|
+
p.log.error(`Version v${fromVersion} not found. Available: ${versionList}`);
|
|
132
133
|
process.exit(1);
|
|
133
134
|
}
|
|
134
135
|
let toIndex;
|
|
135
136
|
if (!diffAgainstWorking) {
|
|
136
137
|
toIndex = snapshots.findIndex(s => s.version === toVersion);
|
|
137
138
|
if (toIndex === -1) {
|
|
138
|
-
p.log.error(`Version v${toVersion} not found
|
|
139
|
+
p.log.error(`Version v${toVersion} not found. Available: ${versionList}`);
|
|
139
140
|
process.exit(1);
|
|
140
141
|
}
|
|
141
142
|
}
|
package/dist/commands/squash.js
CHANGED
|
@@ -25,10 +25,12 @@ export async function cmdSquash(from, to, path) {
|
|
|
25
25
|
p.log.error('No snapshots found.');
|
|
26
26
|
process.exit(1);
|
|
27
27
|
}
|
|
28
|
+
const versionList = snapshots.map(s => `v${s.version}`).join(', ');
|
|
28
29
|
// Find snapshots to squash
|
|
29
30
|
const toSquash = snapshots.filter(s => s.version >= fromVersion && s.version <= toVersion);
|
|
30
31
|
if (toSquash.length < 2) {
|
|
31
32
|
p.log.error(`Need at least 2 versions to squash. Found ${toSquash.length} in range v${fromVersion}-v${toVersion}.`);
|
|
33
|
+
p.log.info(`Available versions: ${versionList}`);
|
|
32
34
|
process.exit(1);
|
|
33
35
|
}
|
|
34
36
|
p.intro('pmpt squash');
|
package/dist/index.js
CHANGED
|
@@ -42,10 +42,15 @@ import { cmdExplore } from './commands/browse.js';
|
|
|
42
42
|
import { cmdRecover } from './commands/recover.js';
|
|
43
43
|
import { cmdDiff } from './commands/diff.js';
|
|
44
44
|
import { cmdInternalSeed } from './commands/internal-seed.js';
|
|
45
|
+
import { trackCommand } from './lib/api.js';
|
|
45
46
|
import { createRequire } from 'module';
|
|
46
47
|
const require = createRequire(import.meta.url);
|
|
47
48
|
const { version } = require('../package.json');
|
|
48
49
|
const program = new Command();
|
|
50
|
+
// Track every command invocation (fire-and-forget)
|
|
51
|
+
program.hook('preAction', (thisCommand) => {
|
|
52
|
+
trackCommand(thisCommand.name());
|
|
53
|
+
});
|
|
49
54
|
program
|
|
50
55
|
.name('pmpt')
|
|
51
56
|
.description('pmpt — Record and share your AI-driven product development journey')
|
|
@@ -56,19 +61,24 @@ Examples:
|
|
|
56
61
|
$ pmpt plan Start product planning (5 questions → AI prompt)
|
|
57
62
|
$ pmpt save Save snapshot of docs folder
|
|
58
63
|
$ pmpt watch Auto-detect file changes
|
|
59
|
-
$ pmpt history
|
|
64
|
+
$ pmpt history (hist) View version history
|
|
60
65
|
$ pmpt diff v1 v2 Compare two versions
|
|
61
66
|
$ pmpt diff v3 Compare v3 to working copy
|
|
62
67
|
$ pmpt squash v2 v5 Merge versions v2-v5 into v2
|
|
63
68
|
$ pmpt export Export as .pmpt file (single JSON)
|
|
64
69
|
$ pmpt import <file.pmpt> Import from .pmpt file
|
|
65
70
|
$ pmpt login Authenticate with pmptwiki
|
|
66
|
-
$ pmpt publish
|
|
71
|
+
$ pmpt publish (pub) Publish project to pmptwiki
|
|
67
72
|
$ pmpt update Quick re-publish (content only)
|
|
68
73
|
$ pmpt clone <slug> Clone a project from pmptwiki
|
|
69
|
-
$ pmpt explore
|
|
74
|
+
$ pmpt explore (exp) Explore projects on pmptwiki.com
|
|
70
75
|
$ pmpt recover Recover damaged pmpt.md via AI
|
|
71
76
|
|
|
77
|
+
Workflow:
|
|
78
|
+
init → plan → save → publish Basic publishing flow
|
|
79
|
+
init → plan → watch Continuous development
|
|
80
|
+
login → publish → update Re-publish with updates
|
|
81
|
+
|
|
72
82
|
Documentation: https://pmptwiki.com
|
|
73
83
|
`);
|
|
74
84
|
// Project tracking commands
|
|
@@ -87,10 +97,12 @@ program
|
|
|
87
97
|
.action(cmdSave);
|
|
88
98
|
program
|
|
89
99
|
.command('status [path]')
|
|
100
|
+
.alias('st')
|
|
90
101
|
.description('Check project status and tracked files')
|
|
91
102
|
.action(cmdStatus);
|
|
92
103
|
program
|
|
93
104
|
.command('history [path]')
|
|
105
|
+
.alias('hist')
|
|
94
106
|
.description('View saved version history')
|
|
95
107
|
.option('-c, --compact', 'Show compact history (hide small changes)')
|
|
96
108
|
.action(cmdHistory);
|
|
@@ -123,9 +135,12 @@ program
|
|
|
123
135
|
.command('logout')
|
|
124
136
|
.description('Clear saved GitHub authentication')
|
|
125
137
|
.action(async () => {
|
|
138
|
+
const prompts = await import('@clack/prompts');
|
|
126
139
|
const { clearAuth } = await import('./lib/auth.js');
|
|
140
|
+
prompts.intro('pmpt logout');
|
|
127
141
|
clearAuth();
|
|
128
|
-
|
|
142
|
+
prompts.log.success('Logged out successfully.');
|
|
143
|
+
prompts.outro('');
|
|
129
144
|
});
|
|
130
145
|
// Platform commands
|
|
131
146
|
program
|
|
@@ -134,6 +149,7 @@ program
|
|
|
134
149
|
.action(cmdLogin);
|
|
135
150
|
program
|
|
136
151
|
.command('publish [path]')
|
|
152
|
+
.alias('pub')
|
|
137
153
|
.description('Publish project to pmptwiki platform')
|
|
138
154
|
.option('--non-interactive', 'Run without interactive prompts')
|
|
139
155
|
.option('--meta-file <file>', 'JSON file with slug, description, tags, category')
|
|
@@ -163,6 +179,7 @@ program
|
|
|
163
179
|
.action(cmdClone);
|
|
164
180
|
program
|
|
165
181
|
.command('explore')
|
|
182
|
+
.alias('exp')
|
|
166
183
|
.description('Open pmptwiki.com to explore and search projects')
|
|
167
184
|
.action(cmdExplore);
|
|
168
185
|
program
|
|
@@ -174,4 +191,58 @@ program
|
|
|
174
191
|
.command('internal-seed', { hidden: true })
|
|
175
192
|
.requiredOption('--spec <file>', 'Seed spec JSON file')
|
|
176
193
|
.action(cmdInternalSeed);
|
|
194
|
+
// "Did you mean?" helper
|
|
195
|
+
function levenshtein(a, b) {
|
|
196
|
+
const m = a.length, n = b.length;
|
|
197
|
+
const dp = Array.from({ length: m + 1 }, (_, i) => Array.from({ length: n + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)));
|
|
198
|
+
for (let i = 1; i <= m; i++) {
|
|
199
|
+
for (let j = 1; j <= n; j++) {
|
|
200
|
+
dp[i][j] = a[i - 1] === b[j - 1]
|
|
201
|
+
? dp[i - 1][j - 1]
|
|
202
|
+
: 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return dp[m][n];
|
|
206
|
+
}
|
|
207
|
+
function suggestCommand(unknown) {
|
|
208
|
+
const available = program.commands
|
|
209
|
+
.filter(cmd => !cmd._hidden)
|
|
210
|
+
.flatMap(cmd => [cmd.name(), ...(cmd.aliases?.() ?? [])]);
|
|
211
|
+
let bestMatch = '';
|
|
212
|
+
let bestDist = Infinity;
|
|
213
|
+
for (const name of available) {
|
|
214
|
+
const dist = levenshtein(unknown, name);
|
|
215
|
+
if (dist < bestDist) {
|
|
216
|
+
bestDist = dist;
|
|
217
|
+
bestMatch = name;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
console.error(`\n Unknown command: ${unknown}\n`);
|
|
221
|
+
if (bestDist <= 3 && bestMatch) {
|
|
222
|
+
console.error(` Did you mean \x1b[36mpmpt ${bestMatch}\x1b[0m?\n`);
|
|
223
|
+
}
|
|
224
|
+
console.error(` Run \x1b[36mpmpt --help\x1b[0m to see all commands.\n`);
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
// Handle unknown subcommands and Quick Start
|
|
228
|
+
program.on('command:*', (operands) => {
|
|
229
|
+
suggestCommand(operands[0]);
|
|
230
|
+
});
|
|
231
|
+
// Show Quick Start when no arguments provided
|
|
232
|
+
const args = process.argv.slice(2);
|
|
233
|
+
if (args.length === 0) {
|
|
234
|
+
console.log(`
|
|
235
|
+
pmpt v${version} — Record and share your AI-driven product development journey
|
|
236
|
+
|
|
237
|
+
Quick Start:
|
|
238
|
+
$ pmpt init 1. Initialize project
|
|
239
|
+
$ pmpt plan 2. Generate AI prompt (copied to clipboard)
|
|
240
|
+
$ pmpt save 3. Save snapshot after progress
|
|
241
|
+
$ pmpt publish 4. Share on pmptwiki.com
|
|
242
|
+
|
|
243
|
+
Run \x1b[36mpmpt --help\x1b[0m for all commands.
|
|
244
|
+
Documentation: https://pmptwiki.com
|
|
245
|
+
`);
|
|
246
|
+
process.exit(0);
|
|
247
|
+
}
|
|
177
248
|
program.parse();
|
package/dist/lib/api.js
CHANGED
|
@@ -92,3 +92,14 @@ export function trackClone(slug) {
|
|
|
92
92
|
body: JSON.stringify({ slug }),
|
|
93
93
|
}).catch(() => { });
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Fire-and-forget CLI command usage tracking.
|
|
97
|
+
* Never throws — failures are silently ignored.
|
|
98
|
+
*/
|
|
99
|
+
export function trackCommand(command) {
|
|
100
|
+
fetch(`${API_BASE}/metrics/command`, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
body: JSON.stringify({ command }),
|
|
104
|
+
}).catch(() => { });
|
|
105
|
+
}
|