prjct-cli 0.44.0 → 0.45.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/bin/prjct.ts +14 -0
  3. package/core/commands/analysis.ts +239 -0
  4. package/core/commands/command-data.ts +21 -4
  5. package/core/commands/commands.ts +4 -0
  6. package/core/commands/register.ts +1 -0
  7. package/core/commands/shipping.ts +1 -1
  8. package/core/context-tools/files-tool.ts +584 -0
  9. package/core/context-tools/imports-tool.ts +423 -0
  10. package/core/context-tools/index.ts +458 -0
  11. package/core/context-tools/recent-tool.ts +313 -0
  12. package/core/context-tools/signatures-tool.ts +510 -0
  13. package/core/context-tools/summary-tool.ts +309 -0
  14. package/core/context-tools/token-counter.ts +279 -0
  15. package/core/context-tools/types.ts +253 -0
  16. package/core/index.ts +4 -0
  17. package/core/infrastructure/ai-provider.ts +11 -36
  18. package/core/schemas/metrics.ts +143 -0
  19. package/core/services/sync-service.ts +99 -0
  20. package/core/storage/index.ts +4 -0
  21. package/core/storage/metrics-storage.ts +315 -0
  22. package/core/types/index.ts +3 -0
  23. package/core/types/storage.ts +49 -0
  24. package/core/utils/branding.ts +2 -3
  25. package/dist/bin/prjct.mjs +5362 -2825
  26. package/dist/core/infrastructure/command-installer.js +10 -32
  27. package/dist/core/infrastructure/setup.js +10 -32
  28. package/package.json +1 -1
  29. package/templates/commands/git.md +143 -54
  30. package/templates/commands/merge.md +121 -13
  31. package/templates/commands/review.md +1 -1
  32. package/templates/commands/ship.md +165 -20
  33. package/templates/commands/sync.md +1 -1
  34. package/templates/commands/task.md +104 -7
  35. package/templates/global/ANTIGRAVITY.md +2 -4
  36. package/templates/global/CLAUDE.md +58 -29
  37. package/templates/global/CURSOR.mdc +1 -3
  38. package/templates/global/GEMINI.md +2 -4
  39. package/templates/global/WINDSURF.md +1 -3
  40. package/templates/subagents/workflow/prjct-shipper.md +1 -2
@@ -4,50 +4,195 @@ allowed-tools: [Read, Write, Bash, AskUserQuestion]
4
4
 
5
5
  # p. ship "$ARGUMENTS"
6
6
 
7
+ ## ⛔ MANDATORY WORKFLOW - DO NOT SKIP ANY STEP
8
+
9
+ **CRITICAL: Execute steps IN ORDER. Each step MUST complete before proceeding.**
10
+
11
+ ---
12
+
13
+ ### STEP 1: Pre-flight Checks (BLOCKING)
14
+
15
+ ```bash
16
+ # 1a. Check current branch
17
+ BRANCH=$(git branch --show-current)
18
+ ```
19
+
20
+ **⛔ IF branch is `main` or `master`:**
21
+ ```
22
+ STOP. DO NOT PROCEED.
23
+ Tell user: "Cannot ship from main branch. Create a feature branch first."
24
+ ABORT the ship command entirely.
25
+ ```
26
+
7
27
  ```bash
8
- prjct context ship $ARGUMENTS
28
+ # 1b. Check GitHub auth
29
+ gh auth status
9
30
  ```
10
31
 
11
- IF `currentTask` active → Ask: "Complete and ship?" or "Cancel"
32
+ **⛔ IF not authenticated:**
33
+ ```
34
+ STOP. DO NOT PROCEED.
35
+ Tell user: "GitHub CLI not authenticated. Run: gh auth login"
36
+ ABORT the ship command entirely.
37
+ ```
12
38
 
13
39
  ```bash
14
- git status --porcelain # No changes? STOP
15
- git diff --stat HEAD
40
+ # 1c. Check for changes
41
+ git status --porcelain
16
42
  ```
17
43
 
18
- Run lint/tests if configured
44
+ **⛔ IF no changes:**
45
+ ```
46
+ STOP. DO NOT PROCEED.
47
+ Tell user: "No changes to ship."
48
+ ABORT the ship command entirely.
49
+ ```
50
+
51
+ ---
19
52
 
20
- IF not trivial Review for security issues, error handling
53
+ ### STEP 2: Show Plan and Get Approval (BLOCKING)
21
54
 
22
- Version bump (patch default, minor for feat:, major for BREAKING)
23
- Update CHANGELOG.md
55
+ **⛔ DO NOT execute any commits/pushes until user explicitly approves.**
56
+
57
+ Show the user:
58
+ ```
59
+ ## Ship Plan
60
+
61
+ Branch: {branch}
62
+ Changes:
63
+ {git diff --stat}
64
+
65
+ Will do:
66
+ 1. Run tests (if configured)
67
+ 2. Bump version (patch/minor/major)
68
+ 3. Update CHANGELOG.md
69
+ 4. Commit with prjct footer
70
+ 5. Push branch
71
+ 6. Create PR to main
72
+
73
+ Proceed? (yes/no)
74
+ ```
75
+
76
+ **⛔ WAIT for explicit "yes" or approval. Do not assume.**
77
+
78
+ ---
79
+
80
+ ### STEP 3: Quality Checks
24
81
 
25
82
  ```bash
26
- gh auth status # Not auth? STOP
27
- git branch --show-current # On main? STOP
83
+ # Run tests if package.json has test script
84
+ npm test 2>/dev/null || bun test 2>/dev/null || echo "No tests configured"
28
85
  ```
29
86
 
30
- Commit with footer:
87
+ ```bash
88
+ # Run lint if configured
89
+ npm run lint 2>/dev/null || echo "No lint configured"
31
90
  ```
32
- 🤖 Generated with [p/](https://www.prjct.app/)
33
- Designed for [Claude](https://www.anthropic.com/claude)
91
+
92
+ ---
93
+
94
+ ### STEP 4: Version Bump (REQUIRED)
95
+
96
+ Determine version bump type:
97
+ - `fix:` commits → **patch** (0.0.X)
98
+ - `feat:` commits → **minor** (0.X.0)
99
+ - `BREAKING:` in commits → **major** (X.0.0)
100
+
101
+ ```bash
102
+ # Read current version
103
+ OLD_VERSION=$(node -p "require('./package.json').version")
104
+
105
+ # Calculate new version and update package.json
106
+ # Use npm version OR manual edit
34
107
  ```
35
108
 
109
+ ---
110
+
111
+ ### STEP 5: Update CHANGELOG.md (REQUIRED)
112
+
113
+ Add entry at top of CHANGELOG.md:
114
+ ```markdown
115
+ ## [X.X.X] - YYYY-MM-DD
116
+
117
+ ### {Fixed/Added/Changed}
118
+ - {description of changes}
119
+ ```
120
+
121
+ ---
122
+
123
+ ### STEP 6: Commit (REQUIRED FORMAT)
124
+
125
+ ```bash
126
+ git add .
127
+ git commit -m "$(cat <<'EOF'
128
+ {type}: {description}
129
+
130
+ {body if needed}
131
+
132
+ Generated with [p/](https://www.prjct.app/)
133
+ EOF
134
+ )"
135
+ ```
136
+
137
+ **⛔ The prjct footer MUST be included. No exceptions.**
138
+
139
+ ---
140
+
141
+ ### STEP 7: Push and Create PR (REQUIRED)
142
+
36
143
  ```bash
37
- git add . && git commit && git push -u origin {branch}
38
- gh pr create --title "feat: {feature}" --base main
144
+ git push -u origin {branch}
145
+ gh pr create --title "{type}: {description}" --base main --body "$(cat <<'EOF'
146
+ ## Summary
147
+ {bullet points}
148
+
149
+ ## Changes
150
+ {what changed}
151
+
152
+ ## Test Plan
153
+ {how to verify}
154
+
155
+ Generated with [p/](https://www.prjct.app/)
156
+ EOF
157
+ )"
39
158
  ```
40
159
 
41
- **Output**:
160
+ ---
161
+
162
+ ### STEP 8: Update Linear/Issue Tracker (if applicable)
163
+
164
+ If task has `linearId`:
165
+ - Update issue status to "In Review" or appropriate state
166
+ - Add comment with PR link
167
+
168
+ ---
169
+
170
+ ## Output Format
171
+
42
172
  ```
43
173
  🚀 Shipped: {feature}
44
174
 
45
175
  Version: {old} → {new}
46
176
  PR: {url}
47
- CI: {status}
177
+ Branch: {branch}
48
178
 
49
179
  Next:
50
- - CI failed?Fix and push again
51
- - Merge ready? → `p. merge` or merge in GitHub
52
- - New task? → `p. task "description"`
180
+ - Review PR{url}
181
+ - Merge when ready → `p. merge`
53
182
  ```
183
+
184
+ ---
185
+
186
+ ## ⛔ VIOLATIONS
187
+
188
+ **If you skip ANY step, you are BREAKING the prjct workflow.**
189
+
190
+ Common violations:
191
+ - ❌ Committing directly to main
192
+ - ❌ Pushing without creating PR
193
+ - ❌ Skipping version bump
194
+ - ❌ Skipping CHANGELOG update
195
+ - ❌ Not waiting for user approval
196
+ - ❌ Missing prjct footer in commit
197
+
198
+ **These violations make prjct useless. Follow the workflow.**
@@ -18,7 +18,7 @@ READ: {globalPath}/project.json → check integrations.linear.enabled
18
18
 
19
19
  IF integrations.linear.enabled:
20
20
  # Sync Linear issues to local cache
21
- RUN: bun core/cli/linear.ts --project {projectId} sync
21
+ RUN: bun $PRJCT_CLI/core/cli/linear.ts --project {projectId} sync
22
22
 
23
23
  # Result stored in {globalPath}/storage/issues.json
24
24
  # Contains all assigned issues from Linear
@@ -4,10 +4,62 @@ allowed-tools: [Read, Write, Bash, Task, Glob, Grep, AskUserQuestion]
4
4
 
5
5
  # p. task "$ARGUMENTS"
6
6
 
7
+ ## ⛔ MANDATORY PRE-FLIGHT CHECKS
8
+
9
+ **Execute these checks BEFORE any task creation:**
10
+
11
+ ### Check 1: Validate Arguments
12
+
13
+ ```
14
+ IF $ARGUMENTS is empty:
15
+ ASK: "What task do you want to start?"
16
+ WAIT for response
17
+ DO NOT proceed with empty task
18
+ ```
19
+
20
+ ### Check 2: Check for Active Task
21
+
22
+ ```
23
+ READ: {globalPath}/storage/state.json
24
+
25
+ IF currentTask exists AND currentTask.status == "active":
26
+ OUTPUT:
27
+ """
28
+ ⚠️ Active task detected: {currentTask.description}
29
+
30
+ Options:
31
+ 1. Complete current task first → `p. done`
32
+ 2. Pause current task → `p. pause`
33
+ 3. Switch anyway (current task will be paused)
34
+ """
35
+
36
+ ASK: "What would you like to do?"
37
+ WAIT for explicit choice
38
+ DO NOT automatically switch tasks
39
+ ```
40
+
41
+ ### Check 3: Validate Git State
42
+
7
43
  ```bash
8
- prjct context task $ARGUMENTS
44
+ git status --porcelain
45
+ ```
46
+
47
+ ```
48
+ IF uncommitted changes exist:
49
+ OUTPUT:
50
+ """
51
+ ⚠️ You have uncommitted changes:
52
+ {list of files}
53
+
54
+ Commit or stash them before starting a new task.
55
+ """
56
+
57
+ ASK: "Would you like to commit these changes first?"
58
+ WAIT for response
9
59
  ```
10
60
 
61
+ ---
62
+
11
63
  ## Step 0: Detect Issue Tracker Reference
12
64
 
13
65
  IF `$ARGUMENTS` matches pattern `/^[A-Z]+-\d+$/` (e.g., PRJ-123, PROJ-456):
@@ -20,7 +72,7 @@ IF integrations.linear.enabled:
20
72
  # Linear issue detected - use LOCAL-FIRST approach
21
73
  # Try local cache first (issues.json), then API if not found
22
74
 
23
- RUN: bun core/cli/linear.ts --project {projectId} get-local "$ARGUMENTS"
75
+ RUN: bun $PRJCT_CLI/core/cli/linear.ts --project {projectId} get-local "$ARGUMENTS"
24
76
 
25
77
  IF issue found in local cache:
26
78
  USE cached issue data (no API call needed)
@@ -67,14 +119,59 @@ ELSE:
67
119
 
68
120
  ## Main Flow
69
121
 
70
- IF `currentTask` active Ask: complete, pause, or cancel?
122
+ ### Step A: Show Plan and Get Approval (BLOCKING)
71
123
 
124
+ **⛔ DO NOT create branches or modify state without user approval.**
125
+
126
+ ```
127
+ OUTPUT:
128
+ """
129
+ ## Task Plan
130
+
131
+ Description: $ARGUMENTS
132
+ Type: {classified type}
133
+ Branch: {type}/{slug}
134
+
135
+ Will do:
136
+ 1. Create feature branch from current branch
137
+ 2. Initialize task tracking in state.json
138
+ 3. Break down into subtasks
139
+ 4. {If Linear: Update issue status to In Progress}
140
+
141
+ Proceed? (yes/no)
142
+ """
143
+
144
+ WAIT for explicit "yes" or approval
145
+ DO NOT assume
146
+ ```
147
+
148
+ ### Step B: Explore Codebase
149
+
150
+ ```
72
151
  USE Task(Explore) → find similar code, affected files
73
- READ `agents[].filePath` → get patterns
74
- Classify: feature|bug|improvement|refactor|chore
75
- Break into subtasks
152
+ READ agents/*.md → get domain patterns
153
+ ```
154
+
155
+ ### Step C: Classify Task
76
156
 
77
- IF on main `git checkout -b {type}/{slug}`
157
+ Determine type: feature | bug | improvement | refactor | chore
158
+
159
+ ### Step D: Create Branch (if needed)
160
+
161
+ ```bash
162
+ CURRENT_BRANCH=$(git branch --show-current)
163
+ ```
164
+
165
+ ```
166
+ IF CURRENT_BRANCH == "main" OR CURRENT_BRANCH == "master":
167
+ OUTPUT: "Creating feature branch: {type}/{slug}"
168
+
169
+ git checkout -b {type}/{slug}
170
+
171
+ IF git command fails:
172
+ OUTPUT: "Failed to create branch. Check git status."
173
+ STOP
174
+ ```
78
175
 
79
176
  ```bash
80
177
  prjct work "$ARGUMENTS"
@@ -79,12 +79,10 @@ node -e "console.log(require('crypto').randomUUID())"
79
79
  **Every commit made with prjct MUST include this footer:**
80
80
 
81
81
  ```
82
- 🤖 Generated with [p/](https://www.prjct.app/)
83
- Powered by [Antigravity](https://gemini.google.com/app/antigravity)
84
-
82
+ Generated with [p/](https://www.prjct.app/)
85
83
  ```
86
84
 
87
- **This is NON-NEGOTIABLE. The prjct signature (`🤖 Generated with [p/]`) must appear in ALL commits.**
85
+ **This is NON-NEGOTIABLE. The prjct signature must appear in ALL commits.**
88
86
 
89
87
  ### 5. Storage Rules (CROSS-AGENT COMPATIBILITY)
90
88
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## HOW TO USE PRJCT (Read This First)
7
7
 
8
- When user types `p. <command>`, load the template from `templates/commands/{command}.md` and execute it intelligently.
8
+ When user types `p. <command>`, load the template from `templates/commands/{command}.md` and execute it.
9
9
 
10
10
  ```
11
11
  p. sync → templates/commands/sync.md
@@ -14,39 +14,70 @@ p. done → templates/commands/done.md
14
14
  p. ship X → templates/commands/ship.md
15
15
  ```
16
16
 
17
- **Key Insight**: Templates are GUIDANCE, not scripts. Use your intelligence to adapt them to the situation.
18
-
19
17
  ---
20
18
 
21
- ## CRITICAL RULES
19
+ ## CRITICAL RULES - READ BEFORE EVERY COMMAND
22
20
 
23
- ### 0. PLAN BEFORE ACTION (NON-NEGOTIABLE)
21
+ ### 0. FOLLOW TEMPLATES STEP BY STEP (NON-NEGOTIABLE)
24
22
 
25
- **For ANY prjct task, you MUST create a plan and get user approval BEFORE executing.**
23
+ **Templates are MANDATORY WORKFLOWS, not suggestions.**
26
24
 
27
25
  ```
28
- EVERY prjct command (p. task, p. sync, p. ship, etc.):
29
- 1. STOP - Do not execute anything yet
30
- 2. ANALYZE - Read relevant files, understand scope
31
- 3. PLAN - Write a clear plan with:
32
- - What will be done
33
- - Files that will be modified
34
- - Potential risks
35
- 4. ASK - Present plan to user and wait for explicit approval
36
- 5. EXECUTE - Only after user says "yes", "approved", "go ahead", etc.
26
+ BEFORE executing ANY p. command:
27
+ 1. READ the template file COMPLETELY
28
+ 2. FOLLOW each step IN ORDER
29
+ 3. DO NOT skip steps - even "obvious" ones
30
+ 4. DO NOT take shortcuts - even for "simple" tasks
31
+ 5. STOP at any BLOCKING condition
37
32
  ```
38
33
 
39
- **NEVER:**
40
- - Execute code changes without showing a plan first
41
- - Assume approval - wait for explicit confirmation
42
- - Skip the plan step for "simple" tasks
34
+ **WHY THIS MATTERS:**
35
+ - Skipping steps breaks the prjct workflow for ALL users
36
+ - "Intelligent adaptation" is NOT permission to skip steps
37
+ - Every step exists for a reason
38
+ - If you skip steps, prjct becomes useless
39
+
40
+ ### ⛔ BLOCKING CONDITIONS
41
+
42
+ When a template says "STOP" or has a ⛔ symbol:
43
+ ```
44
+ 1. HALT execution immediately
45
+ 2. TELL the user why you stopped
46
+ 3. DO NOT proceed until the condition is resolved
47
+ 4. DO NOT work around the blocker
48
+ ```
49
+
50
+ **Examples of blockers:**
51
+ - `p. ship` on main branch → STOP, tell user to create branch
52
+ - `gh auth status` fails → STOP, tell user to authenticate
53
+ - No changes to commit → STOP, tell user nothing to ship
54
+
55
+ ### GIT WORKFLOW RULES (CRITICAL)
43
56
 
44
- **ALWAYS:**
45
- - Show the plan in a clear, readable format
46
- - Wait for user response before proceeding
47
- - If user asks questions, answer them before executing
57
+ **⛔ NEVER commit directly to main/master**
58
+ - Always create a feature branch first
59
+ - Always create a PR for review
60
+ - Direct pushes to main are FORBIDDEN
48
61
 
49
- This rule applies to ALL prjct operations. No exceptions.
62
+ **⛔ NEVER push without a PR**
63
+ - All changes go through pull requests
64
+ - No exceptions for "small fixes"
65
+
66
+ **⛔ NEVER skip version bump on ship**
67
+ - Every ship requires version update
68
+ - Every ship requires CHANGELOG entry
69
+
70
+ ### PLAN BEFORE DESTRUCTIVE ACTIONS
71
+
72
+ For commands that modify git state (ship, merge, done):
73
+ ```
74
+ 1. Show the user what will happen
75
+ 2. List all changes/files affected
76
+ 3. WAIT for explicit approval ("yes", "proceed", "do it")
77
+ 4. Only then execute
78
+ ```
79
+
80
+ **DO NOT assume approval. WAIT for it.**
50
81
 
51
82
  ---
52
83
 
@@ -79,12 +110,10 @@ bun -e "console.log(crypto.randomUUID())" 2>/dev/null || node -e "console.log(re
79
110
  **Every commit made with prjct MUST include this footer:**
80
111
 
81
112
  ```
82
- 🤖 Generated with [p/](https://www.prjct.app/)
83
- Designed for [Claude](https://www.anthropic.com/claude)
84
-
113
+ Generated with [p/](https://www.prjct.app/)
85
114
  ```
86
115
 
87
- **This is NON-NEGOTIABLE. The prjct signature (`🤖 Generated with [p/]`) must appear in ALL commits.**
116
+ **This is NON-NEGOTIABLE. The prjct signature must appear in ALL commits.**
88
117
 
89
118
  ### 5. Storage Rules (CROSS-AGENT COMPATIBILITY)
90
119
 
@@ -256,7 +285,7 @@ Next: [suggested action]
256
285
 
257
286
  5. **Prefer prjct CLI over raw commands**:
258
287
  ```
259
- GOOD: bun core/cli/linear.ts list
288
+ GOOD: bun $PRJCT_CLI/core/cli/linear.ts list
260
289
  BAD: curl -X POST https://api.linear.app/graphql...
261
290
  ```
262
291
 
@@ -99,9 +99,7 @@ node -e "console.log(require('crypto').randomUUID())"
99
99
  **Every commit made with prjct MUST include this footer:**
100
100
 
101
101
  ```
102
- 🤖 Generated with [p/](https://www.prjct.app/)
103
- Built with [Cursor](https://www.cursor.com/)
104
-
102
+ Generated with [p/](https://www.prjct.app/)
105
103
  ```
106
104
 
107
105
  **This is NON-NEGOTIABLE. The prjct signature must appear in ALL commits.**
@@ -79,12 +79,10 @@ bun -e "console.log(crypto.randomUUID())" 2>/dev/null || node -e "console.log(re
79
79
  **Every commit made with prjct MUST include this footer:**
80
80
 
81
81
  ```
82
- 🤖 Generated with [p/](https://www.prjct.app/)
83
- Designed for [Gemini](https://geminicli.com/)
84
-
82
+ Generated with [p/](https://www.prjct.app/)
85
83
  ```
86
84
 
87
- **This is NON-NEGOTIABLE. The prjct signature (`🤖 Generated with [p/]`) must appear in ALL commits.**
85
+ **This is NON-NEGOTIABLE. The prjct signature must appear in ALL commits.**
88
86
 
89
87
  ### 5. Storage Rules (CROSS-AGENT COMPATIBILITY)
90
88
 
@@ -99,9 +99,7 @@ node -e "console.log(require('crypto').randomUUID())"
99
99
  **Every commit made with prjct MUST include this footer:**
100
100
 
101
101
  ```
102
- 🤖 Generated with [p/](https://www.prjct.app/)
103
- Built with [Windsurf](https://www.windsurf.com/)
104
-
102
+ Generated with [p/](https://www.prjct.app/)
105
103
  ```
106
104
 
107
105
  **This is NON-NEGOTIABLE. The prjct signature must appear in ALL commits.**
@@ -64,8 +64,7 @@ Fix issues and try again.
64
64
 
65
65
  {body if needed}
66
66
 
67
- 🤖 Generated with [p/](https://www.prjct.app/)
68
- Designed for [Claude](https://www.anthropic.com/claude)
67
+ Generated with [p/](https://www.prjct.app/)
69
68
  ```
70
69
  3. Commit: `git commit -m "{message}"`
71
70
  4. Push: `git push origin {current-branch}`