@opengsd/gsd-pi 1.7.0 → 1.8.1
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/README.md +8 -6
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/doctor-history.js +65 -0
- package/dist/resources/extensions/gsd/doctor-state-checks.js +509 -0
- package/dist/resources/extensions/gsd/doctor-workspace-checks.js +91 -0
- package/dist/resources/extensions/gsd/doctor.js +14 -653
- package/dist/resources/extensions/gsd/md-importer.js +7 -2
- package/dist/resources/extensions/gsd/migrate/planning-writer.js +8 -2
- package/dist/resources/extensions/gsd/migration-auto-check.js +4 -0
- package/dist/resources/extensions/gsd/state-reconciliation/drift/project-md.js +54 -14
- package/dist/resources/extensions/gsd/state-reconciliation/drift/sketch-flag.js +48 -5
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +10 -10
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +10 -10
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/node_modules/@gsd/native/package.json +1 -1
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/integrations/hermes/open_gsd_hermes/gsd_client.py +1 -1
- package/integrations/hermes/pyproject.toml +1 -1
- package/package.json +6 -6
- package/packages/cloud-mcp-gateway/package.json +2 -2
- package/packages/contracts/package.json +1 -1
- package/packages/daemon/dist/cloud-config.d.ts.map +1 -1
- package/packages/daemon/dist/cloud-config.js +25 -7
- package/packages/daemon/dist/cloud-config.js.map +1 -1
- package/packages/daemon/dist/cloud-config.test.js +19 -1
- package/packages/daemon/dist/cloud-config.test.js.map +1 -1
- package/packages/daemon/package.json +4 -4
- package/packages/gsd-agent-core/package.json +5 -5
- package/packages/gsd-agent-modes/package.json +7 -7
- package/packages/gsd-cloud/README.md +18 -4
- package/packages/gsd-cloud/bin/gsd-cloud.js +6 -5
- package/packages/gsd-cloud/package.json +6 -4
- package/packages/mcp-server/package.json +4 -4
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-coding-agent/package.json +7 -7
- package/packages/pi-tui/package.json +2 -2
- package/packages/rpc-client/package.json +2 -2
- package/pkg/package.json +1 -1
- package/src/resources/extensions/gsd/doctor-history.ts +81 -0
- package/src/resources/extensions/gsd/doctor-state-checks.ts +527 -0
- package/src/resources/extensions/gsd/doctor-workspace-checks.ts +97 -0
- package/src/resources/extensions/gsd/doctor.ts +14 -673
- package/src/resources/extensions/gsd/md-importer.ts +7 -2
- package/src/resources/extensions/gsd/migrate/planning-writer.ts +9 -3
- package/src/resources/extensions/gsd/migration-auto-check.ts +3 -0
- package/src/resources/extensions/gsd/state-reconciliation/drift/project-md.ts +67 -20
- package/src/resources/extensions/gsd/state-reconciliation/drift/sketch-flag.ts +47 -5
- package/src/resources/extensions/gsd/tests/db-authority-regression.test.ts +76 -1
- package/src/resources/extensions/gsd/tests/doctor-history-public-api.test.ts +25 -0
- package/src/resources/extensions/gsd/tests/migrate-hierarchy.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +4 -0
- package/src/resources/extensions/gsd/tests/planning-writer.test.ts +18 -1
- package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +18 -3
- package/src/resources/extensions/gsd/tests/state-reconciliation-drift.test.ts +177 -25
- /package/dist/web/standalone/.next/static/{enWQFRY-aLTUq3wmxG2Qz → UaXRrOYxBpG9QBINKhZkg}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{enWQFRY-aLTUq3wmxG2Qz → UaXRrOYxBpG9QBINKhZkg}/_ssgManifest.js +0 -0
|
@@ -656,8 +656,13 @@ export function migrateHierarchyToDb(basePath) {
|
|
|
656
656
|
updateSliceStatus(milestoneId, sliceEntry.id, sliceStatus, importCompletionTimestamp(sliceSummary));
|
|
657
657
|
}
|
|
658
658
|
counts.slices++;
|
|
659
|
-
// Insert tasks from parsed plan
|
|
660
|
-
|
|
659
|
+
// Insert tasks from parsed plan.
|
|
660
|
+
// Sketch slices carry only a stub PLAN until refined; do not seed DB
|
|
661
|
+
// tasks from a placeholder <tasks> block (would falsely flip
|
|
662
|
+
// planning -> executing before the slice is decomposed). Once the
|
|
663
|
+
// `[sketch]` badge is removed by a real plan-slice, tasks import
|
|
664
|
+
// normally on the next pass. (#1286)
|
|
665
|
+
if (!plan || sliceEntry.isSketch)
|
|
661
666
|
continue;
|
|
662
667
|
for (const taskEntry of plan.tasks) {
|
|
663
668
|
// Per K002: use 'complete' not 'done'
|
|
@@ -9,6 +9,7 @@ import { mkdirSync } from "node:fs";
|
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
10
|
import { getAllMilestones, getMilestoneSlices, getSliceTasks } from "../gsd-db.js";
|
|
11
11
|
import { saveFile } from "../files.js";
|
|
12
|
+
import { isClosedStatus } from "../status-guards.js";
|
|
12
13
|
import { applyPlanningProjectionWrites, } from "../compat/planning-compat.js";
|
|
13
14
|
function planningRoot(basePath) {
|
|
14
15
|
return join(basePath, ".planning");
|
|
@@ -86,7 +87,11 @@ function formatPlanningPlan(phaseNum, planNum, title, tasks) {
|
|
|
86
87
|
lines.push("<tasks>");
|
|
87
88
|
for (const t of tasks) {
|
|
88
89
|
const est = t.estimate ? ` _(${t.estimate})_` : "";
|
|
89
|
-
|
|
90
|
+
// Render the checkbox from the task's DB status so a DB→.planning
|
|
91
|
+
// projection preserves completion. Hardcoding `[ ]` here silently reset
|
|
92
|
+
// every completed historical task to unchecked on each reconcile (#1276).
|
|
93
|
+
const box = t.done ? "[x]" : "[ ]";
|
|
94
|
+
lines.push(`- ${box} **${t.id}**: ${t.title}${est}`);
|
|
90
95
|
}
|
|
91
96
|
lines.push("</tasks>");
|
|
92
97
|
lines.push("");
|
|
@@ -131,7 +136,7 @@ export async function writePlanningDirectory(basePath, layout) {
|
|
|
131
136
|
const phaseDir = join(root, "phases", phaseDirName);
|
|
132
137
|
mkdirSync(phaseDir, { recursive: true });
|
|
133
138
|
const tasks = getSliceTasks(milestone.id, slice.id);
|
|
134
|
-
const isDone = tasks.length > 0 && tasks.every((t) => t.status
|
|
139
|
+
const isDone = tasks.length > 0 && tasks.every((t) => isClosedStatus(t.status));
|
|
135
140
|
roadmapEntries.push({
|
|
136
141
|
number: phaseNum,
|
|
137
142
|
title: slice.title || slice.id,
|
|
@@ -157,6 +162,7 @@ export async function writePlanningDirectory(basePath, layout) {
|
|
|
157
162
|
id: task.id,
|
|
158
163
|
title: task.title || task.id,
|
|
159
164
|
estimate: task.estimate || undefined,
|
|
165
|
+
done: isClosedStatus(task.status),
|
|
160
166
|
},
|
|
161
167
|
]));
|
|
162
168
|
paths.push(planPath);
|
|
@@ -117,6 +117,10 @@ export function scanMarkdownHierarchy(basePath) {
|
|
|
117
117
|
scan.counts.slices += roadmap.slices.length;
|
|
118
118
|
for (const slice of roadmap.slices) {
|
|
119
119
|
scan.slices.add(`${milestoneId}/${slice.id}`);
|
|
120
|
+
// Sketch slices carry only a stub PLAN until refined; match migrateHierarchyToDb
|
|
121
|
+
// and do not count placeholder tasks from the <tasks> block (#1286).
|
|
122
|
+
if (slice.isSketch)
|
|
123
|
+
continue;
|
|
120
124
|
const planPath = resolveSliceFile(basePath, milestoneId, slice.id, "PLAN");
|
|
121
125
|
if (!planPath || !existsSync(planPath))
|
|
122
126
|
continue;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// instruction. Markdown hierarchy import is reserved for operator-controlled
|
|
6
6
|
// migration/recovery commands, not automatic runtime reconciliation.
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
|
-
import { getMilestone, isDbAvailable } from "../../gsd-db.js";
|
|
9
|
-
import { findMilestoneIds } from "../../milestone-ids.js";
|
|
8
|
+
import { getAllMilestones, getMilestone, isDbAvailable } from "../../gsd-db.js";
|
|
9
|
+
import { findMilestoneIds, parseMilestoneId } from "../../milestone-ids.js";
|
|
10
10
|
import { resolveMilestoneFile, resolveMilestonePath } from "../../paths.js";
|
|
11
11
|
function milestoneHasContent(basePath, milestoneId) {
|
|
12
12
|
const roadmap = resolveMilestoneFile(basePath, milestoneId, "ROADMAP");
|
|
@@ -16,6 +16,26 @@ function milestoneHasContent(basePath, milestoneId) {
|
|
|
16
16
|
(context !== null && existsSync(context)) ||
|
|
17
17
|
(summary !== null && existsSync(summary)));
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* A directory extracted to a bare `M{NNN}` id is not unregistered when the
|
|
21
|
+
* milestone is actually registered under a `unique_milestone_ids` suffixed id
|
|
22
|
+
* (`M{NNN}-<suffix>`) for the same sequence number. The flat-phase extractor in
|
|
23
|
+
* `milestone-ids` cannot recover the suffix from a descriptive slug (e.g.
|
|
24
|
+
* `07-v40fmq-m007-...-footer-system`), so it falls through to the bare `M007`.
|
|
25
|
+
* Probing the DB for a suffixed row on that sequence resolves the directory to
|
|
26
|
+
* its registered identity instead of firing a false-positive drift (issue
|
|
27
|
+
* #1281).
|
|
28
|
+
*/
|
|
29
|
+
function hasRegisteredSuffixedVariant(milestoneId) {
|
|
30
|
+
const { suffix, num } = parseMilestoneId(milestoneId);
|
|
31
|
+
// Only bare, well-formed `M{NNN}` ids can be ambiguous with a suffixed row.
|
|
32
|
+
if (suffix || num === 0)
|
|
33
|
+
return false;
|
|
34
|
+
return getAllMilestones().some((m) => {
|
|
35
|
+
const parsed = parseMilestoneId(m.id);
|
|
36
|
+
return parsed.num === num && parsed.suffix !== undefined;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
19
39
|
export function detectUnregisteredMilestoneDrift(_state, ctx) {
|
|
20
40
|
if (!isDbAvailable())
|
|
21
41
|
return [];
|
|
@@ -23,6 +43,8 @@ export function detectUnregisteredMilestoneDrift(_state, ctx) {
|
|
|
23
43
|
for (const milestoneId of findMilestoneIds(ctx.basePath)) {
|
|
24
44
|
if (getMilestone(milestoneId))
|
|
25
45
|
continue;
|
|
46
|
+
if (hasRegisteredSuffixedVariant(milestoneId))
|
|
47
|
+
continue;
|
|
26
48
|
if (!milestoneHasContent(ctx.basePath, milestoneId))
|
|
27
49
|
continue;
|
|
28
50
|
drifts.push({ kind: "unregistered-milestone", milestoneId });
|
|
@@ -30,29 +52,47 @@ export function detectUnregisteredMilestoneDrift(_state, ctx) {
|
|
|
30
52
|
return drifts;
|
|
31
53
|
}
|
|
32
54
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* directory — not a full DB reimport. `/gsd recover --confirm` is a destructive
|
|
41
|
-
* clear-and-reimport of the entire DB and is offered only as a last resort, so
|
|
42
|
-
* users do not reach for it expecting a targeted repair (see issue #826).
|
|
55
|
+
* The recovery hint deliberately leads with the *targeted*, non-destructive
|
|
56
|
+
* options. The common cause of this drift is a directory left under an old ID
|
|
57
|
+
* after a `unique_milestone_ids` rename, where the right fix is to rename (move)
|
|
58
|
+
* the directory — not a full DB reimport. `/gsd recover --confirm` is a
|
|
59
|
+
* destructive clear-and-reimport of the entire DB and is offered only as a last
|
|
60
|
+
* resort, so users do not reach for it expecting a targeted repair (see issue
|
|
61
|
+
* #826).
|
|
43
62
|
*/
|
|
44
|
-
|
|
63
|
+
function unregisteredMilestoneGuidance(record, ctx) {
|
|
45
64
|
const dir = resolveMilestonePath(ctx.basePath, record.milestoneId);
|
|
46
65
|
const dirHint = dir ?? `the .gsd directory for ${record.milestoneId}`;
|
|
47
|
-
|
|
66
|
+
return (`Milestone ${record.milestoneId} exists only as markdown projection ` +
|
|
48
67
|
"(on-disk ROADMAP/CONTEXT/SUMMARY with no authoritative DB row). " +
|
|
49
68
|
"Runtime reconciliation will not import markdown into the DB. Choose one:\n" +
|
|
50
69
|
` • Rename: if this directory is the same milestone under an old ID (e.g. a unique_milestone_ids rename), move \`${dirHint}\` to the current ID's directory and re-run.\n` +
|
|
51
70
|
` • Discard: if this milestone is no longer relevant, delete \`${dirHint}\` and re-run.\n` +
|
|
52
71
|
" • Last resort: `/gsd recover --confirm` performs a destructive full DB clear-and-reimport — it does NOT do a targeted import and can replace or duplicate existing DB milestones.");
|
|
53
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Terminal blocker for an unregistered milestone. The project-root DB is
|
|
75
|
+
* authoritative at runtime; markdown-only milestones must be reconciled through
|
|
76
|
+
* an explicit, operator-controlled action so operators opt into changing
|
|
77
|
+
* canonical state. Exposing this as a `blocker` (matching the `artifact-db`
|
|
78
|
+
* convention) surfaces the drift as a pause-with-hint that gates dispatch,
|
|
79
|
+
* instead of a guaranteed repair throw that escalates auto-mode health to red
|
|
80
|
+
* (see issue #1281).
|
|
81
|
+
*/
|
|
82
|
+
export function describeUnregisteredMilestoneBlocker(record, ctx) {
|
|
83
|
+
return unregisteredMilestoneGuidance(record, ctx);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Repair intentionally fails closed. Retained as a defensive fallback for the
|
|
87
|
+
* reconciliation engine; in practice `blocker` short-circuits this drift into a
|
|
88
|
+
* non-fatal pause before repair is ever attempted.
|
|
89
|
+
*/
|
|
90
|
+
export function repairUnregisteredMilestone(record, ctx) {
|
|
91
|
+
throw new Error(unregisteredMilestoneGuidance(record, ctx));
|
|
92
|
+
}
|
|
54
93
|
export const unregisteredMilestoneHandler = {
|
|
55
94
|
kind: "unregistered-milestone",
|
|
56
95
|
detect: detectUnregisteredMilestoneDrift,
|
|
96
|
+
blocker: describeUnregisteredMilestoneBlocker,
|
|
57
97
|
repair: repairUnregisteredMilestone,
|
|
58
98
|
};
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
// 2. Flag-OFF downgrade: when progressive_planning is off, dispatch routes
|
|
8
8
|
// sketch slices to plan-slice, which writes PLAN.md but leaves
|
|
9
9
|
// is_sketch=1 — the next reconciliation pass clears it.
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import { getSketchedSliceIds, isDbAvailable, setSliceSketchFlag, } from "../../gsd-db.js";
|
|
12
|
+
import { parsePlan } from "../../parsers-legacy.js";
|
|
12
13
|
import { resolveSliceFile } from "../../paths.js";
|
|
13
14
|
export function detectStaleSketchFlags(state, ctx) {
|
|
14
15
|
if (!isDbAvailable())
|
|
@@ -18,12 +19,54 @@ export function detectStaleSketchFlags(state, ctx) {
|
|
|
18
19
|
return [];
|
|
19
20
|
const sliceIds = getSketchedSliceIds(mid);
|
|
20
21
|
return sliceIds
|
|
21
|
-
.filter((sid) =>
|
|
22
|
-
const planPath = resolveSliceFile(ctx.basePath, mid, sid, "PLAN");
|
|
23
|
-
return planPath !== null && existsSync(planPath);
|
|
24
|
-
})
|
|
22
|
+
.filter((sid) => sketchIsPlanned(ctx.basePath, mid, sid))
|
|
25
23
|
.map((sid) => ({ kind: "stale-sketch-flag", mid, sid }));
|
|
26
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* True when a task title is a synthetic placeholder emitted by a projection
|
|
27
|
+
* round-trip rather than a real, refined task. `migrate/transformer.buildTaskTitle`
|
|
28
|
+
* produces two shapes when a plan was never decomposed:
|
|
29
|
+
* - `Plan NN` (fallback when phase/plan frontmatter is absent)
|
|
30
|
+
* - `${phase} ${plan}` (e.g. `00 01`, `00 03b`, `29-auth-system 01`)
|
|
31
|
+
* Neither carries genuine planning intent, so both must be treated as stubs.
|
|
32
|
+
*/
|
|
33
|
+
function isPlaceholderTaskTitle(title) {
|
|
34
|
+
const t = title.trim();
|
|
35
|
+
if (/^Plan\s+\d+[a-z]*$/i.test(t))
|
|
36
|
+
return true;
|
|
37
|
+
// buildTaskTitle returns `${phase} ${plan}` when frontmatter has both fields.
|
|
38
|
+
// Phase slugs are digit-led (e.g. `00`, `29-auth-system`); require that so
|
|
39
|
+
// legitimate titles like `Step 1` are not misclassified as stubs.
|
|
40
|
+
return /^\d[\w-]*\s+\d+[a-z]*$/i.test(t);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A sketch slice counts as "planned" (so its is_sketch flag may be cleared)
|
|
44
|
+
* only when it has a *real* plan on disk — not merely any PLAN file.
|
|
45
|
+
*
|
|
46
|
+
* File existence alone (#1287) is too weak: a stub/placeholder PLAN, a
|
|
47
|
+
* crash-leftover, or a projection round-trip that emits synthetic placeholder
|
|
48
|
+
* task titles (migrate/transformer.buildTaskTitle) all satisfy existsSync yet
|
|
49
|
+
* were never actually refined. Clearing the flag for one strips the `refining`
|
|
50
|
+
* guard in phase derivation and lets a phantom task drive dispatch.
|
|
51
|
+
*
|
|
52
|
+
* A legitimate plan-slice always decomposes into >= 1 genuine task, so require
|
|
53
|
+
* at least one non-placeholder task. This is strictly stricter than the old
|
|
54
|
+
* existence check — the documented crash-recovery scenarios (a real plan-slice
|
|
55
|
+
* that wrote its tasks) still clear, a bare stub no longer does.
|
|
56
|
+
*/
|
|
57
|
+
function sketchIsPlanned(basePath, mid, sid) {
|
|
58
|
+
const planPath = resolveSliceFile(basePath, mid, sid, "PLAN");
|
|
59
|
+
if (planPath === null || !existsSync(planPath))
|
|
60
|
+
return false;
|
|
61
|
+
try {
|
|
62
|
+
const plan = parsePlan(readFileSync(planPath, "utf-8"));
|
|
63
|
+
return plan.tasks.some((t) => !isPlaceholderTaskTitle(t.title));
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// A PLAN we cannot parse is not a trustworthy "planning done" signal.
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
27
70
|
export function repairStaleSketchFlag(record) {
|
|
28
71
|
setSliceSketchFlag(record.mid, record.sid, false);
|
|
29
72
|
}
|