@pi-unipi/workflow 0.1.5 → 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.
Files changed (2) hide show
  1. package/commands.ts +19 -11
  2. package/package.json +1 -1
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.5",
3
+ "version": "0.1.6",
4
4
  "description": "Structured development workflow commands for Pi coding agent",
5
5
  "type": "module",
6
6
  "license": "MIT",