prjct-cli 0.10.13 → 0.11.0
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/CHANGELOG.md +58 -0
- package/CLAUDE.md +47 -2
- package/bin/dev.js +217 -0
- package/bin/prjct +10 -0
- package/bin/serve.js +78 -0
- package/core/agentic/command-executor.js +38 -112
- package/core/agentic/prompt-builder.js +72 -0
- package/core/bus/index.js +322 -0
- package/core/command-registry.js +65 -0
- package/core/domain/snapshot-manager.js +375 -0
- package/core/plugin/hooks.js +313 -0
- package/core/plugin/index.js +52 -0
- package/core/plugin/loader.js +331 -0
- package/core/plugin/registry.js +325 -0
- package/core/plugins/webhook.js +143 -0
- package/core/session/index.js +449 -0
- package/core/session/metrics.js +293 -0
- package/package.json +18 -4
- package/templates/agentic/agent-routing.md +42 -9
- package/templates/agentic/checklist-routing.md +98 -0
- package/templates/checklists/accessibility.md +33 -0
- package/templates/checklists/architecture.md +28 -0
- package/templates/checklists/code-quality.md +28 -0
- package/templates/checklists/data.md +33 -0
- package/templates/checklists/documentation.md +33 -0
- package/templates/checklists/infrastructure.md +33 -0
- package/templates/checklists/performance.md +33 -0
- package/templates/checklists/security.md +33 -0
- package/templates/checklists/testing.md +33 -0
- package/templates/checklists/ux-ui.md +37 -0
- package/templates/commands/bug.md +27 -1
- package/templates/commands/done.md +176 -54
- package/templates/commands/feature.md +38 -1
- package/templates/commands/history.md +176 -0
- package/templates/commands/init.md +28 -1
- package/templates/commands/now.md +191 -9
- package/templates/commands/pause.md +176 -12
- package/templates/commands/redo.md +142 -0
- package/templates/commands/resume.md +166 -62
- package/templates/commands/serve.md +121 -0
- package/templates/commands/ship.md +45 -1
- package/templates/commands/sync.md +34 -1
- package/templates/commands/task.md +27 -1
- package/templates/commands/undo.md +152 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
allowed-tools: [Read, Write, Bash]
|
|
3
|
+
description: 'Undo last changes by restoring previous snapshot'
|
|
4
|
+
timestamp-rule: 'GetTimestamp() for ALL timestamps'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /p:undo - Revert to Previous Snapshot
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
Reverts the project to the previous snapshot state. Uses Git-based snapshots stored in `~/.prjct-cli/projects/{projectId}/snapshots/`.
|
|
11
|
+
|
|
12
|
+
## Context Variables
|
|
13
|
+
- `{projectId}`: From `.prjct/prjct.config.json`
|
|
14
|
+
- `{globalPath}`: `~/.prjct-cli/projects/{projectId}`
|
|
15
|
+
- `{snapshotDir}`: `{globalPath}/snapshots`
|
|
16
|
+
- `{memoryPath}`: `{globalPath}/memory/context.jsonl`
|
|
17
|
+
|
|
18
|
+
## Step 1: Read Config
|
|
19
|
+
|
|
20
|
+
READ: `.prjct/prjct.config.json`
|
|
21
|
+
EXTRACT: `projectId`
|
|
22
|
+
|
|
23
|
+
IF file not found:
|
|
24
|
+
OUTPUT: "No prjct project. Run /p:init first."
|
|
25
|
+
STOP
|
|
26
|
+
|
|
27
|
+
## Step 2: Check Snapshot History
|
|
28
|
+
|
|
29
|
+
BASH: `cd ~/.prjct-cli/projects/{projectId}/snapshots && git log --oneline -5 2>/dev/null || echo "NO_SNAPSHOTS"`
|
|
30
|
+
|
|
31
|
+
IF output contains "NO_SNAPSHOTS" OR empty:
|
|
32
|
+
OUTPUT: "⚠️ No snapshots available. Create one with /p:ship first."
|
|
33
|
+
STOP
|
|
34
|
+
|
|
35
|
+
CAPTURE last two lines as:
|
|
36
|
+
- {currentHash}: First line (current snapshot)
|
|
37
|
+
- {previousHash}: Second line (snapshot to restore)
|
|
38
|
+
|
|
39
|
+
IF only one snapshot exists:
|
|
40
|
+
OUTPUT: "⚠️ Only one snapshot exists. Nothing to undo."
|
|
41
|
+
STOP
|
|
42
|
+
|
|
43
|
+
## Step 3: Get Current State Info
|
|
44
|
+
|
|
45
|
+
BASH: `cd ~/.prjct-cli/projects/{projectId}/snapshots && git log -1 --pretty=format:'%s' {currentHash}`
|
|
46
|
+
CAPTURE as {currentMessage}
|
|
47
|
+
|
|
48
|
+
BASH: `cd ~/.prjct-cli/projects/{projectId}/snapshots && git log -1 --pretty=format:'%s' {previousHash}`
|
|
49
|
+
CAPTURE as {previousMessage}
|
|
50
|
+
|
|
51
|
+
## Step 4: Get Files That Will Change
|
|
52
|
+
|
|
53
|
+
BASH: `cd ~/.prjct-cli/projects/{projectId}/snapshots && git diff --name-only {previousHash} {currentHash}`
|
|
54
|
+
CAPTURE as {affectedFiles}
|
|
55
|
+
|
|
56
|
+
COUNT files as {fileCount}
|
|
57
|
+
|
|
58
|
+
## Step 5: Save Current State to Redo Stack
|
|
59
|
+
|
|
60
|
+
Before undoing, save current state so we can redo later.
|
|
61
|
+
|
|
62
|
+
READ: `{snapshotDir}/redo-stack.json` (create if not exists with `[]`)
|
|
63
|
+
PARSE as JSON array
|
|
64
|
+
|
|
65
|
+
ADD to array:
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"hash": "{currentHash}",
|
|
69
|
+
"message": "{currentMessage}",
|
|
70
|
+
"timestamp": "{GetTimestamp()}"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
WRITE: `{snapshotDir}/redo-stack.json`
|
|
75
|
+
|
|
76
|
+
## Step 6: Restore Previous Snapshot
|
|
77
|
+
|
|
78
|
+
### Checkout files from previous snapshot
|
|
79
|
+
BASH: `cd ~/.prjct-cli/projects/{projectId}/snapshots && git checkout {previousHash} -- .`
|
|
80
|
+
|
|
81
|
+
### Copy files back to project
|
|
82
|
+
For each file in {affectedFiles}:
|
|
83
|
+
- Source: `{snapshotDir}/{file}`
|
|
84
|
+
- Destination: `{projectPath}/{file}`
|
|
85
|
+
- Copy content
|
|
86
|
+
|
|
87
|
+
NOTE: Use the SnapshotManager.restore() method if available via Node.js, or copy files manually.
|
|
88
|
+
|
|
89
|
+
## Step 7: Log to Memory
|
|
90
|
+
|
|
91
|
+
APPEND to: `{memoryPath}`
|
|
92
|
+
|
|
93
|
+
Single line (JSONL):
|
|
94
|
+
```json
|
|
95
|
+
{"timestamp":"{GetTimestamp()}","action":"snapshot_undo","from":"{currentHash}","to":"{previousHash}","files":{fileCount}}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Step 8: Log to Manifest
|
|
99
|
+
|
|
100
|
+
APPEND to: `{snapshotDir}/manifest.jsonl`
|
|
101
|
+
|
|
102
|
+
Single line (JSONL):
|
|
103
|
+
```json
|
|
104
|
+
{"type":"undo","from":"{currentHash}","to":"{previousHash}","timestamp":"{GetTimestamp()}","files":{fileCount}}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Output
|
|
108
|
+
|
|
109
|
+
SUCCESS:
|
|
110
|
+
```
|
|
111
|
+
⏪ Undone: {currentMessage}
|
|
112
|
+
|
|
113
|
+
Restored to: {previousMessage}
|
|
114
|
+
Files affected: {fileCount}
|
|
115
|
+
|
|
116
|
+
/p:redo to redo | /p:history to see all snapshots
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Error Handling
|
|
120
|
+
|
|
121
|
+
| Error | Response | Action |
|
|
122
|
+
|-------|----------|--------|
|
|
123
|
+
| No snapshots | "No snapshots available" | STOP |
|
|
124
|
+
| Only one snapshot | "Nothing to undo" | STOP |
|
|
125
|
+
| Git error | Show error message | STOP |
|
|
126
|
+
| File copy fails | "Failed to restore {file}" | CONTINUE |
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### Example 1: Successful Undo
|
|
131
|
+
```
|
|
132
|
+
⏪ Undone: Ship authentication feature
|
|
133
|
+
|
|
134
|
+
Restored to: Add login form
|
|
135
|
+
Files affected: 5
|
|
136
|
+
|
|
137
|
+
/p:redo to redo | /p:history to see all snapshots
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Example 2: Nothing to Undo
|
|
141
|
+
```
|
|
142
|
+
⚠️ Only one snapshot exists. Nothing to undo.
|
|
143
|
+
|
|
144
|
+
Create more snapshots with /p:ship
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Notes
|
|
148
|
+
|
|
149
|
+
- Undo is non-destructive: current state is saved to redo stack
|
|
150
|
+
- You can redo immediately after undoing
|
|
151
|
+
- Creating a new snapshot after undo clears the redo stack
|
|
152
|
+
- Snapshots are project-specific, not global
|