@agent-plan/pi-adapter 0.2.19-next.24 → 0.2.19-next.25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,iCAAiC,CAAC;AAgzBtF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA0hH9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,iCAAiC,CAAC;AAgzBtF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAkhH9D"}
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@
9
9
  * - inject context into prompts
10
10
  */
11
11
  import { Type } from "typebox";
12
- import { ExportService, PlanStore, setWriteBusyHook, setWriteNotifyHook, migrateToUuids, migrateToGlobalSequence, withFeatureLock, needsMotivation, findPhaseByRef, findTaskByRef, buildRecap, addChecklistItem, removeChecklistItem, toggleChecklistItem, buildPhaseContextBlock, checkExplicitTaskStart, recommendNextTask } from "@agent-plan/core";
13
- import { createChecklistItemId, createFeatureId, createPhaseId, createShortId, createTaskId, clampSlug, normalizeSlug, formatPhaseRef, formatFeatureRef, featureNumberOfPhase, validateResolvedTarget } from "@agent-plan/core/naming";
12
+ import { ExportService, PlanStore, setWriteBusyHook, setWriteNotifyHook, withFeatureLock, needsMotivation, findPhaseByRef, findTaskByRef, buildRecap, addChecklistItem, removeChecklistItem, toggleChecklistItem, buildPhaseContextBlock, checkExplicitTaskStart, recommendNextTask } from "@agent-plan/core";
13
+ import { createChecklistItemId, createFeatureId, createPhaseId, createTaskId, clampSlug, normalizeSlug, formatPhaseRef, formatFeatureRef, featureNumberOfPhase, validateResolvedTarget } from "@agent-plan/core/naming";
14
14
  import { join, dirname } from "node:path";
15
15
  import { homedir } from "node:os";
16
16
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
@@ -1469,13 +1469,13 @@ export default function planPiExtension(pi) {
1469
1469
  return;
1470
1470
  }
1471
1471
  const now = nowISO();
1472
- const featureNumber = await st.allocFeatureNumber();
1473
- const shortId = createShortId(await st.assignedShortIds());
1472
+ const id = createFeatureId();
1473
+ const identity = await st.allocateEntityIdentity("feature", id);
1474
1474
  const priority = await st.nextPriority("feature");
1475
1475
  const feature = {
1476
- id: createFeatureId(),
1477
- number: featureNumber,
1478
- shortId,
1476
+ id,
1477
+ number: identity.number,
1478
+ shortId: identity.shortId,
1479
1479
  priority,
1480
1480
  name: nameInput.trim(),
1481
1481
  description: description?.trim() ?? "",
@@ -1699,13 +1699,12 @@ export default function planPiExtension(pi) {
1699
1699
  await withFeatureLock(feature.id, async () => {
1700
1700
  const phases = await st.loadAllPhases();
1701
1701
  const featurePhases = phases.filter((p) => p.featureId === feature.id);
1702
- const number = await st.allocPhaseNumber();
1703
1702
  const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1704
1703
  const id = createPhaseId();
1705
- const shortId = createShortId(await st.assignedShortIds());
1704
+ const identity = await st.allocateEntityIdentity("phase", id);
1706
1705
  const priority = await st.nextPriority("phase", feature.id);
1707
1706
  phase = {
1708
- id, number, shortId, priority, slug, title, featureId: feature.id, status: "draft", discussedAt: "", contextReady: false, contextReadyReason: "", summary: "", description: "", notes: "",
1707
+ id, number: identity.number, shortId: identity.shortId, priority, slug, title, featureId: feature.id, status: "draft", discussedAt: "", contextReady: false, contextReadyReason: "", summary: "", description: "", notes: "",
1709
1708
  goals: [], nonGoals: [], dependencies: [], dependsOn: [], risks: [],
1710
1709
  openQuestions: [], decisions: [], acceptedDecisions: [], completionCriteria: [], taskIds: [], tasks: [],
1711
1710
  createdAt: nowISO(), updatedAt: nowISO(),
@@ -1942,13 +1941,12 @@ export default function planPiExtension(pi) {
1942
1941
  // Escape can still cancel before a task is persisted.
1943
1942
  const startDiscuss = await ctx.ui.input("Start task discuss now? Type yes to continue");
1944
1943
  const shortName = clampSlug(title, 30, `task-${Date.now().toString(36)}`);
1945
- const taskNum = await st.allocTaskNumber();
1946
1944
  const taskId = createTaskId();
1947
- const shortId = createShortId(await st.assignedShortIds());
1945
+ const identity = await st.allocateEntityIdentity("task", taskId);
1948
1946
  const priority = await st.nextPriority("task", phase.id);
1949
1947
  const now = nowISO();
1950
1948
  const task = {
1951
- id: taskId, phaseId: phase.id, number: taskNum, shortId, priority, shortName,
1949
+ id: taskId, phaseId: phase.id, number: identity.number, shortId: identity.shortId, priority, shortName,
1952
1950
  title: title.trim(), status: "planned",
1953
1951
  description: "",
1954
1952
  notes: "",
@@ -3201,12 +3199,13 @@ export default function planPiExtension(pi) {
3201
3199
  const now = nowISO();
3202
3200
  const status = params.status ?? "planned";
3203
3201
  const currentFeatures = (await st.loadFeatures()).features;
3204
- const shortId = createShortId(await st.assignedShortIds());
3202
+ const id = createFeatureId();
3203
+ const identity = await st.allocateEntityIdentity("feature", id);
3205
3204
  const priority = await st.nextPriority("feature");
3206
3205
  const feature = {
3207
- id: createFeatureId(),
3208
- number: await st.allocFeatureNumber(),
3209
- shortId,
3206
+ id,
3207
+ number: identity.number,
3208
+ shortId: identity.shortId,
3210
3209
  priority,
3211
3210
  name: params.name,
3212
3211
  description: params.description ?? "",
@@ -3511,13 +3510,12 @@ export default function planPiExtension(pi) {
3511
3510
  return { content: [{ type: "text", text: `Resolved feature ${featureId} no longer exists. Refusing to create phase.` }], details: {} };
3512
3511
  let phase;
3513
3512
  await withFeatureLock(featureId, async () => {
3514
- const number = await st.allocPhaseNumber();
3515
3513
  const id = createPhaseId();
3516
- const shortId = createShortId(await st.assignedShortIds());
3514
+ const identity = await st.allocateEntityIdentity("phase", id);
3517
3515
  const priority = await st.nextPriority("phase", featureId);
3518
3516
  const now = nowISO();
3519
3517
  phase = {
3520
- id, number, shortId, priority, slug: normalizeSlug(params.title), title: params.title,
3518
+ id, number: identity.number, shortId: identity.shortId, priority, slug: normalizeSlug(params.title), title: params.title,
3521
3519
  featureId,
3522
3520
  status: params.status ?? "draft",
3523
3521
  discussedAt: "",
@@ -3872,12 +3870,12 @@ export default function planPiExtension(pi) {
3872
3870
  return { content: [{ type: "text", text: `Resolved phase ${phaseId} no longer exists. Refusing to create task.` }], details: {} };
3873
3871
  const shortName = clampSlug(params.shortName ?? params.title, 30, `task-${Date.now().toString(36)}`); // clamp+strip trailing dash; never empty
3874
3872
  const taskId = createTaskId();
3875
- const shortId = createShortId(await st.assignedShortIds());
3873
+ const identity = await st.allocateEntityIdentity("task", taskId);
3876
3874
  const priority = await st.nextPriority("task", phaseId);
3877
3875
  const now = nowISO();
3878
3876
  const initialStatus = params.status ?? "planned";
3879
3877
  const task = {
3880
- id: taskId, phaseId, number: await st.allocTaskNumber(), shortId, priority, shortName,
3878
+ id: taskId, phaseId, number: identity.number, shortId: identity.shortId, priority, shortName,
3881
3879
  title: params.title,
3882
3880
  status: initialStatus,
3883
3881
  description: params.description ?? "",
@@ -4419,15 +4417,9 @@ export default function planPiExtension(pi) {
4419
4417
  if (!(await st.exists()))
4420
4418
  return;
4421
4419
  try {
4422
- // Heavy one-time-per-session init: migration, language prefs, status
4423
- // healing, and a fresh resume. These write/scan the whole plan and would
4424
- // add seconds of latency on every turn if run unconditionally.
4420
+ // Session initialization must not mutate canonical planner entities.
4421
+ // Migrations/backfills/repairs are explicit tools; resume is `.local`.
4425
4422
  if (!plannerHeavyInitDone) {
4426
- await migrateToUuids(st);
4427
- await migrateToGlobalSequence(st).catch(() => null);
4428
- await st.ensureShortIdsAndPriority().catch(() => null);
4429
- await ensureProjectLanguagePreferences(st).catch(() => null);
4430
- await maybeHealStatuses(st, ctx);
4431
4423
  await st.refreshResume();
4432
4424
  plannerHeavyInitDone = true;
4433
4425
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-plan/pi-adapter",
3
- "version": "0.2.19-next.24",
3
+ "version": "0.2.19-next.25",
4
4
  "private": false,
5
5
  "description": "Pi agent extension for Agent Plan — structured project planning in .planner/",
6
6
  "keywords": [
@@ -28,8 +28,8 @@
28
28
  "dependencies": {
29
29
  "typebox": "^1.1.24",
30
30
  "zod": "^3.24.0",
31
- "@agent-plan/core": "0.2.19-next.24",
32
- "@agent-plan/server": "0.2.19-next.24"
31
+ "@agent-plan/core": "0.2.19-next.25",
32
+ "@agent-plan/server": "0.2.19-next.25"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@earendil-works/pi-coding-agent": "^0.74.0",