@pi-unipi/workflow 0.1.4 → 0.1.6

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/commands.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
9
- import { readFileSync, readdirSync, existsSync } from "fs";
9
+ import { readFileSync, readdirSync, existsSync, statSync } from "fs";
10
10
  import { join, basename } from "path";
11
11
  import { UNIPI_PREFIX, WORKFLOW_COMMANDS, getToolsForCommand, getSandboxLevel, type SandboxLevel } from "@pi-unipi/core";
12
12
 
@@ -41,13 +41,17 @@ function suggestSpecFiles(prefix: string): { value: string; label: string; descr
41
41
  if (!existsSync(specsDir)) return [];
42
42
 
43
43
  try {
44
- const files = readdirSync(specsDir).filter((f) => f.endsWith(".md"));
44
+ const search = prefix?.trim().split(/\s+/).pop() ?? "";
45
+ const files = readdirSync(specsDir)
46
+ .filter((f) => f.endsWith(".md"))
47
+ .map((f) => ({ name: f, time: statSync(join(specsDir, f)).mtimeMs }))
48
+ .sort((a, b) => b.time - a.time);
45
49
  return files
46
- .filter((f) => !prefix || f.includes(prefix))
50
+ .filter((f) => !search || f.name.includes(search))
47
51
  .map((f) => ({
48
- value: `specs:${f}`,
49
- label: basename(f, ".md"),
50
- description: `Spec: ${f}`,
52
+ value: `specs:${f.name}`,
53
+ label: basename(f.name, ".md"),
54
+ description: `Spec: ${f.name}`,
51
55
  }));
52
56
  } catch {
53
57
  return [];
@@ -62,13 +66,17 @@ function suggestPlanFiles(prefix: string): { value: string; label: string; descr
62
66
  if (!existsSync(plansDir)) return [];
63
67
 
64
68
  try {
65
- const files = readdirSync(plansDir).filter((f) => f.endsWith(".md"));
69
+ const search = prefix?.trim().split(/\s+/).pop() ?? "";
70
+ const files = readdirSync(plansDir)
71
+ .filter((f) => f.endsWith(".md"))
72
+ .map((f) => ({ name: f, time: statSync(join(plansDir, f)).mtimeMs }))
73
+ .sort((a, b) => b.time - a.time);
66
74
  return files
67
- .filter((f) => !prefix || f.includes(prefix))
75
+ .filter((f) => !search || f.name.includes(search))
68
76
  .map((f) => ({
69
- value: `plan:${f}`,
70
- label: basename(f, ".md"),
71
- description: `Plan: ${f}`,
77
+ value: `plan:${f.name}`,
78
+ label: basename(f.name, ".md"),
79
+ description: `Plan: ${f.name}`,
72
80
  }));
73
81
  } catch {
74
82
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/workflow",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Structured development workflow commands for Pi coding agent",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -70,6 +70,7 @@ Structure the plan with heart of gold style:
70
70
  title: "{Topic} — Implementation Plan"
71
71
  type: plan
72
72
  date: YYYY-MM-DD
73
+ workbranch: {branch-name or empty if on main}
73
74
  specs:
74
75
  - path/to/spec.md
75
76
  ---
@@ -25,13 +25,17 @@ Review what was built, verify task completion, run codebase checks, add reviewer
25
25
 
26
26
  ---
27
27
 
28
- ## Phase 1: Load Plan
28
+ ## Phase 1: Load Plan & Switch Branch
29
29
 
30
30
  1. If `plan:` arg provided, read that plan
31
31
  2. If not, list plans in `.unipi/docs/plans/` and ask user
32
32
  3. Read plan fully — understand tasks, acceptance criteria, current status
33
+ 4. **Read `workbranch:` from plan frontmatter:**
34
+ - If `workbranch:` exists and is not empty → switch to that branch/worktree
35
+ - If `workbranch:` missing or empty → review on current branch (main)
36
+ - To switch: `git checkout {workbranch}` or use worktree path
33
37
 
34
- **Exit:** Plan loaded. Know what to review.
38
+ **Exit:** On correct branch. Plan loaded.
35
39
 
36
40
  ---
37
41
 
@@ -39,6 +39,7 @@ If args not provided, ask user interactively:
39
39
  - "Do you want to work on current branch or create a worktree?"
40
40
  - If worktree: "What branch name?" (suggest based on spec topic)
41
41
  - Create worktree if not exists
42
+ - **After creating/confirming worktree:** write `workbranch: {branch-name}` to the plan file frontmatter
42
43
 
43
44
  2. **Specs:**
44
45
  - List available plans in `.unipi/docs/plans/`