gsd-pi 2.41.0-dev.0acbce9 → 2.41.0-dev.3557dc4
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/dist/cli-web-branch.d.ts +6 -0
- package/dist/cli-web-branch.js +17 -0
- package/dist/onboarding.js +2 -1
- package/dist/resources/extensions/gsd/auto/loop.js +9 -1
- package/dist/resources/extensions/gsd/auto/phases.js +26 -8
- package/dist/resources/extensions/gsd/auto-dashboard.js +6 -2
- package/dist/resources/extensions/gsd/auto-dispatch.js +19 -2
- package/dist/resources/extensions/gsd/auto-post-unit.js +7 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +12 -4
- package/dist/resources/extensions/gsd/auto-start.js +8 -3
- package/dist/resources/extensions/gsd/auto-worktree.js +147 -13
- package/dist/resources/extensions/gsd/auto.js +36 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +199 -164
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +62 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +16 -0
- package/dist/resources/extensions/gsd/commands/catalog.js +8 -1
- package/dist/resources/extensions/gsd/commands/handlers/core.js +1 -0
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +5 -0
- package/dist/resources/extensions/gsd/context-store.js +4 -3
- package/dist/resources/extensions/gsd/db-writer.js +5 -2
- package/dist/resources/extensions/gsd/detection.js +1 -1
- package/dist/resources/extensions/gsd/doctor.js +11 -1
- package/dist/resources/extensions/gsd/exit-command.js +12 -2
- package/dist/resources/extensions/gsd/export.js +9 -13
- package/dist/resources/extensions/gsd/extension-manifest.json +2 -2
- package/dist/resources/extensions/gsd/files.js +28 -11
- package/dist/resources/extensions/gsd/forensics.js +10 -3
- package/dist/resources/extensions/gsd/git-service.js +5 -1
- package/dist/resources/extensions/gsd/gsd-db.js +25 -8
- package/dist/resources/extensions/gsd/guided-flow-queue.js +1 -1
- package/dist/resources/extensions/gsd/guided-flow.js +7 -3
- package/dist/resources/extensions/gsd/journal.js +85 -0
- package/dist/resources/extensions/gsd/md-importer.js +5 -0
- package/dist/resources/extensions/gsd/milestone-ids.js +1 -1
- package/dist/resources/extensions/gsd/native-git-bridge.js +2 -2
- package/dist/resources/extensions/gsd/post-unit-hooks.js +24 -412
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences.js +1 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +34 -4
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +11 -10
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +2 -2
- package/dist/resources/extensions/gsd/prompts/discuss.md +1 -1
- package/dist/resources/extensions/gsd/prompts/queue.md +1 -1
- package/dist/resources/extensions/gsd/repo-identity.js +46 -2
- package/dist/resources/extensions/gsd/rule-registry.js +489 -0
- package/dist/resources/extensions/gsd/rule-types.js +6 -0
- package/dist/resources/extensions/gsd/service-tier.js +138 -0
- package/dist/resources/extensions/gsd/structured-data-formatter.js +2 -1
- package/dist/resources/extensions/gsd/templates/decisions.md +2 -2
- package/dist/resources/extensions/gsd/workflow-templates.js +13 -1
- package/dist/resources/extensions/gsd/worktree-manager.js +20 -6
- package/dist/resources/extensions/gsd/worktree-resolver.js +19 -2
- package/dist/resources/extensions/subagent/index.js +7 -3
- package/dist/resources/extensions/voice/index.js +4 -4
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
- 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/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +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 +13 -13
- package/dist/web/standalone/.next/server/chunks/229.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +2 -2
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/4024.c195dc1fdd2adbea.js +9 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-9afaaebf6042a1d7.js → webpack-fa307370fcf9fb2c.js} +1 -1
- package/dist/web-mode.d.ts +2 -0
- package/dist/web-mode.js +29 -7
- package/package.json +1 -1
- package/packages/native/src/__tests__/text.test.mjs +33 -0
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js +3 -1
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +10 -7
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/pi-coding-agent/src/core/discovery-cache.test.ts +4 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +11 -7
- package/src/resources/extensions/gsd/auto/loop-deps.ts +5 -1
- package/src/resources/extensions/gsd/auto/loop.ts +10 -1
- package/src/resources/extensions/gsd/auto/phases.ts +28 -8
- package/src/resources/extensions/gsd/auto/types.ts +4 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +7 -2
- package/src/resources/extensions/gsd/auto-dispatch.ts +25 -5
- package/src/resources/extensions/gsd/auto-post-unit.ts +8 -0
- package/src/resources/extensions/gsd/auto-recovery.ts +12 -4
- package/src/resources/extensions/gsd/auto-start.ts +8 -3
- package/src/resources/extensions/gsd/auto-worktree.ts +162 -18
- package/src/resources/extensions/gsd/auto.ts +40 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +209 -162
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +62 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +2 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +13 -0
- package/src/resources/extensions/gsd/commands/catalog.ts +8 -1
- package/src/resources/extensions/gsd/commands/handlers/core.ts +1 -0
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +5 -0
- package/src/resources/extensions/gsd/context-store.ts +4 -3
- package/src/resources/extensions/gsd/db-writer.ts +6 -2
- package/src/resources/extensions/gsd/detection.ts +1 -1
- package/src/resources/extensions/gsd/doctor.ts +12 -1
- package/src/resources/extensions/gsd/exit-command.ts +14 -2
- package/src/resources/extensions/gsd/export.ts +8 -15
- package/src/resources/extensions/gsd/extension-manifest.json +2 -2
- package/src/resources/extensions/gsd/files.ts +29 -12
- package/src/resources/extensions/gsd/forensics.ts +9 -3
- package/src/resources/extensions/gsd/git-service.ts +5 -4
- package/src/resources/extensions/gsd/gsd-db.ts +37 -8
- package/src/resources/extensions/gsd/guided-flow-queue.ts +1 -1
- package/src/resources/extensions/gsd/guided-flow.ts +7 -3
- package/src/resources/extensions/gsd/journal.ts +134 -0
- package/src/resources/extensions/gsd/md-importer.ts +6 -0
- package/src/resources/extensions/gsd/milestone-ids.ts +1 -1
- package/src/resources/extensions/gsd/native-git-bridge.ts +2 -2
- package/src/resources/extensions/gsd/post-unit-hooks.ts +24 -462
- package/src/resources/extensions/gsd/preferences-types.ts +3 -0
- package/src/resources/extensions/gsd/preferences.ts +1 -0
- package/src/resources/extensions/gsd/prompt-loader.ts +35 -4
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +11 -10
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +2 -2
- package/src/resources/extensions/gsd/prompts/discuss.md +1 -1
- package/src/resources/extensions/gsd/prompts/queue.md +1 -1
- package/src/resources/extensions/gsd/repo-identity.ts +47 -2
- package/src/resources/extensions/gsd/rule-registry.ts +599 -0
- package/src/resources/extensions/gsd/rule-types.ts +68 -0
- package/src/resources/extensions/gsd/service-tier.ts +171 -0
- package/src/resources/extensions/gsd/structured-data-formatter.ts +3 -1
- package/src/resources/extensions/gsd/templates/decisions.md +2 -2
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +202 -0
- package/src/resources/extensions/gsd/tests/context-store.test.ts +10 -5
- package/src/resources/extensions/gsd/tests/db-writer.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/doctor-completion-deferral.test.ts +15 -10
- package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/doctor-roadmap-summary-atomicity.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/doctor-task-done-missing-summary-slice-loop.test.ts +174 -0
- package/src/resources/extensions/gsd/tests/exit-command.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +8 -1
- package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +7 -7
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +513 -0
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +147 -0
- package/src/resources/extensions/gsd/tests/journal.test.ts +386 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +31 -1
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/milestone-id-reservation.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/parsers.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +47 -25
- package/src/resources/extensions/gsd/tests/prompt-db.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +61 -1
- package/src/resources/extensions/gsd/tests/routing-history.test.ts +11 -22
- package/src/resources/extensions/gsd/tests/rule-registry.test.ts +413 -0
- package/src/resources/extensions/gsd/tests/service-tier.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/skill-lifecycle.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/structured-data-formatter.test.ts +4 -3
- package/src/resources/extensions/gsd/tests/tool-naming.test.ts +117 -0
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +6 -1
- package/src/resources/extensions/gsd/tests/windows-path-normalization.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +4 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +178 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +78 -3
- package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +74 -0
- package/src/resources/extensions/gsd/types.ts +3 -0
- package/src/resources/extensions/gsd/workflow-templates.ts +12 -1
- package/src/resources/extensions/gsd/worktree-manager.ts +21 -6
- package/src/resources/extensions/gsd/worktree-resolver.ts +30 -9
- package/src/resources/extensions/subagent/index.ts +7 -3
- package/src/resources/extensions/voice/index.ts +4 -4
- package/dist/web/standalone/.next/static/chunks/4024.279c423e4661ece1.js +0 -9
- /package/dist/web/standalone/.next/static/{SwbKZ7JPNFlEmU4f8pKEv → JBSIr4fSfHXs5g5x2ZBSC}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{SwbKZ7JPNFlEmU4f8pKEv → JBSIr4fSfHXs5g5x2ZBSC}/_ssgManifest.js +0 -0
|
@@ -2,18 +2,65 @@ import { Type } from "@sinclair/typebox";
|
|
|
2
2
|
import { findMilestoneIds, nextMilestoneId, claimReservedId, getReservedMilestoneIds } from "../guided-flow.js";
|
|
3
3
|
import { loadEffectiveGSDPreferences } from "../preferences.js";
|
|
4
4
|
import { ensureDbOpen } from "./dynamic-tools.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Register an alias tool that shares the same execute function as its canonical counterpart.
|
|
7
|
+
* The alias description and promptGuidelines direct the LLM to prefer the canonical name.
|
|
8
|
+
*/
|
|
9
|
+
function registerAlias(pi, toolDef, aliasName, canonicalName) {
|
|
6
10
|
pi.registerTool({
|
|
7
|
-
|
|
11
|
+
...toolDef,
|
|
12
|
+
name: aliasName,
|
|
13
|
+
description: toolDef.description + ` (alias for ${canonicalName} — prefer the canonical name)`,
|
|
14
|
+
promptGuidelines: [`Alias for ${canonicalName} — prefer the canonical name.`],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function registerDbTools(pi) {
|
|
18
|
+
// ─── gsd_decision_save (formerly gsd_save_decision) ─────────────────────
|
|
19
|
+
const decisionSaveExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
20
|
+
const dbAvailable = await ensureDbOpen();
|
|
21
|
+
if (!dbAvailable) {
|
|
22
|
+
return {
|
|
23
|
+
content: [{ type: "text", text: "Error: GSD database is not available. Cannot save decision." }],
|
|
24
|
+
details: { operation: "save_decision", error: "db_unavailable" },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const { saveDecisionToDb } = await import("../db-writer.js");
|
|
29
|
+
const { id } = await saveDecisionToDb({
|
|
30
|
+
scope: params.scope,
|
|
31
|
+
decision: params.decision,
|
|
32
|
+
choice: params.choice,
|
|
33
|
+
rationale: params.rationale,
|
|
34
|
+
revisable: params.revisable,
|
|
35
|
+
when_context: params.when_context,
|
|
36
|
+
made_by: params.made_by,
|
|
37
|
+
}, process.cwd());
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: `Saved decision ${id}` }],
|
|
40
|
+
details: { operation: "save_decision", id },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
45
|
+
process.stderr.write(`gsd-db: gsd_decision_save tool failed: ${msg}\n`);
|
|
46
|
+
return {
|
|
47
|
+
content: [{ type: "text", text: `Error saving decision: ${msg}` }],
|
|
48
|
+
details: { operation: "save_decision", error: msg },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const decisionSaveTool = {
|
|
53
|
+
name: "gsd_decision_save",
|
|
8
54
|
label: "Save Decision",
|
|
9
55
|
description: "Record a project decision to the GSD database and regenerate DECISIONS.md. " +
|
|
10
56
|
"Decision IDs are auto-assigned — never provide an ID manually.",
|
|
11
57
|
promptSnippet: "Record a project decision to the GSD database (auto-assigns ID, regenerates DECISIONS.md)",
|
|
12
58
|
promptGuidelines: [
|
|
13
|
-
"Use
|
|
59
|
+
"Use gsd_decision_save when recording an architectural, pattern, library, or observability decision.",
|
|
14
60
|
"Decision IDs are auto-assigned (D001, D002, ...) — never guess or provide an ID.",
|
|
15
|
-
"All fields except revisable and
|
|
61
|
+
"All fields except revisable, when_context, and made_by are required.",
|
|
16
62
|
"The tool writes to the DB and regenerates .gsd/DECISIONS.md automatically.",
|
|
63
|
+
"Set made_by to 'human' when the user explicitly directed the decision, 'agent' when the LLM chose autonomously (default), or 'collaborative' when it was discussed and agreed together.",
|
|
17
64
|
],
|
|
18
65
|
parameters: Type.Object({
|
|
19
66
|
scope: Type.String({ description: "Scope of the decision (e.g. 'architecture', 'library', 'observability')" }),
|
|
@@ -22,48 +69,71 @@ export function registerDbTools(pi) {
|
|
|
22
69
|
rationale: Type.String({ description: "Why this choice was made" }),
|
|
23
70
|
revisable: Type.Optional(Type.String({ description: "Whether this can be revisited (default: 'Yes')" })),
|
|
24
71
|
when_context: Type.Optional(Type.String({ description: "When/context for the decision (e.g. milestone ID)" })),
|
|
72
|
+
made_by: Type.Optional(Type.Union([
|
|
73
|
+
Type.Literal("human"),
|
|
74
|
+
Type.Literal("agent"),
|
|
75
|
+
Type.Literal("collaborative"),
|
|
76
|
+
], { description: "Who made this decision: 'human' (user directed), 'agent' (LLM decided autonomously), or 'collaborative' (discussed and agreed). Default: 'agent'" })),
|
|
25
77
|
}),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, process.cwd());
|
|
44
|
-
return {
|
|
45
|
-
content: [{ type: "text", text: `Saved decision ${id}` }],
|
|
46
|
-
details: { operation: "save_decision", id },
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
51
|
-
process.stderr.write(`gsd-db: gsd_save_decision tool failed: ${msg}\n`);
|
|
78
|
+
execute: decisionSaveExecute,
|
|
79
|
+
};
|
|
80
|
+
pi.registerTool(decisionSaveTool);
|
|
81
|
+
registerAlias(pi, decisionSaveTool, "gsd_save_decision", "gsd_decision_save");
|
|
82
|
+
// ─── gsd_requirement_update (formerly gsd_update_requirement) ───────────
|
|
83
|
+
const requirementUpdateExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
84
|
+
const dbAvailable = await ensureDbOpen();
|
|
85
|
+
if (!dbAvailable) {
|
|
86
|
+
return {
|
|
87
|
+
content: [{ type: "text", text: "Error: GSD database is not available. Cannot update requirement." }],
|
|
88
|
+
details: { operation: "update_requirement", id: params.id, error: "db_unavailable" },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const db = await import("../gsd-db.js");
|
|
93
|
+
const existing = db.getRequirementById(params.id);
|
|
94
|
+
if (!existing) {
|
|
52
95
|
return {
|
|
53
|
-
content: [{ type: "text", text: `Error
|
|
54
|
-
details: { operation: "
|
|
96
|
+
content: [{ type: "text", text: `Error: Requirement ${params.id} not found.` }],
|
|
97
|
+
details: { operation: "update_requirement", id: params.id, error: "not_found" },
|
|
55
98
|
};
|
|
56
99
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
100
|
+
const { updateRequirementInDb } = await import("../db-writer.js");
|
|
101
|
+
const updates = {};
|
|
102
|
+
if (params.status !== undefined)
|
|
103
|
+
updates.status = params.status;
|
|
104
|
+
if (params.validation !== undefined)
|
|
105
|
+
updates.validation = params.validation;
|
|
106
|
+
if (params.notes !== undefined)
|
|
107
|
+
updates.notes = params.notes;
|
|
108
|
+
if (params.description !== undefined)
|
|
109
|
+
updates.description = params.description;
|
|
110
|
+
if (params.primary_owner !== undefined)
|
|
111
|
+
updates.primary_owner = params.primary_owner;
|
|
112
|
+
if (params.supporting_slices !== undefined)
|
|
113
|
+
updates.supporting_slices = params.supporting_slices;
|
|
114
|
+
await updateRequirementInDb(params.id, updates, process.cwd());
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: `Updated requirement ${params.id}` }],
|
|
117
|
+
details: { operation: "update_requirement", id: params.id },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
122
|
+
process.stderr.write(`gsd-db: gsd_requirement_update tool failed: ${msg}\n`);
|
|
123
|
+
return {
|
|
124
|
+
content: [{ type: "text", text: `Error updating requirement: ${msg}` }],
|
|
125
|
+
details: { operation: "update_requirement", id: params.id, error: msg },
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const requirementUpdateTool = {
|
|
130
|
+
name: "gsd_requirement_update",
|
|
61
131
|
label: "Update Requirement",
|
|
62
132
|
description: "Update an existing requirement in the GSD database and regenerate REQUIREMENTS.md. " +
|
|
63
133
|
"Provide the requirement ID (e.g. R001) and any fields to update.",
|
|
64
134
|
promptSnippet: "Update an existing GSD requirement by ID (regenerates REQUIREMENTS.md)",
|
|
65
135
|
promptGuidelines: [
|
|
66
|
-
"Use
|
|
136
|
+
"Use gsd_requirement_update to change status, validation, notes, or other fields on an existing requirement.",
|
|
67
137
|
"The id parameter is required — it must be an existing RXXX identifier.",
|
|
68
138
|
"All other fields are optional — only provided fields are updated.",
|
|
69
139
|
"The tool verifies the requirement exists before updating.",
|
|
@@ -77,61 +147,68 @@ export function registerDbTools(pi) {
|
|
|
77
147
|
primary_owner: Type.Optional(Type.String({ description: "Primary owning slice" })),
|
|
78
148
|
supporting_slices: Type.Optional(Type.String({ description: "Supporting slices" })),
|
|
79
149
|
}),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
150
|
+
execute: requirementUpdateExecute,
|
|
151
|
+
};
|
|
152
|
+
pi.registerTool(requirementUpdateTool);
|
|
153
|
+
registerAlias(pi, requirementUpdateTool, "gsd_update_requirement", "gsd_requirement_update");
|
|
154
|
+
// ─── gsd_summary_save (formerly gsd_save_summary) ──────────────────────
|
|
155
|
+
const summarySaveExecute = async (_toolCallId, params, _signal, _onUpdate, _ctx) => {
|
|
156
|
+
const dbAvailable = await ensureDbOpen();
|
|
157
|
+
if (!dbAvailable) {
|
|
158
|
+
return {
|
|
159
|
+
content: [{ type: "text", text: "Error: GSD database is not available. Cannot save artifact." }],
|
|
160
|
+
details: { operation: "save_summary", error: "db_unavailable" },
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const validTypes = ["SUMMARY", "RESEARCH", "CONTEXT", "ASSESSMENT"];
|
|
164
|
+
if (!validTypes.includes(params.artifact_type)) {
|
|
165
|
+
return {
|
|
166
|
+
content: [{ type: "text", text: `Error: Invalid artifact_type "${params.artifact_type}". Must be one of: ${validTypes.join(", ")}` }],
|
|
167
|
+
details: { operation: "save_summary", error: "invalid_artifact_type" },
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
let relativePath;
|
|
172
|
+
if (params.task_id && params.slice_id) {
|
|
173
|
+
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/tasks/${params.task_id}-${params.artifact_type}.md`;
|
|
87
174
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const existing = db.getRequirementById(params.id);
|
|
91
|
-
if (!existing) {
|
|
92
|
-
return {
|
|
93
|
-
content: [{ type: "text", text: `Error: Requirement ${params.id} not found.` }],
|
|
94
|
-
details: { operation: "update_requirement", id: params.id, error: "not_found" },
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const { updateRequirementInDb } = await import("../db-writer.js");
|
|
98
|
-
const updates = {};
|
|
99
|
-
if (params.status !== undefined)
|
|
100
|
-
updates.status = params.status;
|
|
101
|
-
if (params.validation !== undefined)
|
|
102
|
-
updates.validation = params.validation;
|
|
103
|
-
if (params.notes !== undefined)
|
|
104
|
-
updates.notes = params.notes;
|
|
105
|
-
if (params.description !== undefined)
|
|
106
|
-
updates.description = params.description;
|
|
107
|
-
if (params.primary_owner !== undefined)
|
|
108
|
-
updates.primary_owner = params.primary_owner;
|
|
109
|
-
if (params.supporting_slices !== undefined)
|
|
110
|
-
updates.supporting_slices = params.supporting_slices;
|
|
111
|
-
await updateRequirementInDb(params.id, updates, process.cwd());
|
|
112
|
-
return {
|
|
113
|
-
content: [{ type: "text", text: `Updated requirement ${params.id}` }],
|
|
114
|
-
details: { operation: "update_requirement", id: params.id },
|
|
115
|
-
};
|
|
175
|
+
else if (params.slice_id) {
|
|
176
|
+
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/${params.slice_id}-${params.artifact_type}.md`;
|
|
116
177
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
process.stderr.write(`gsd-db: gsd_update_requirement tool failed: ${msg}\n`);
|
|
120
|
-
return {
|
|
121
|
-
content: [{ type: "text", text: `Error updating requirement: ${msg}` }],
|
|
122
|
-
details: { operation: "update_requirement", id: params.id, error: msg },
|
|
123
|
-
};
|
|
178
|
+
else {
|
|
179
|
+
relativePath = `milestones/${params.milestone_id}/${params.milestone_id}-${params.artifact_type}.md`;
|
|
124
180
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
181
|
+
const { saveArtifactToDb } = await import("../db-writer.js");
|
|
182
|
+
await saveArtifactToDb({
|
|
183
|
+
path: relativePath,
|
|
184
|
+
artifact_type: params.artifact_type,
|
|
185
|
+
content: params.content,
|
|
186
|
+
milestone_id: params.milestone_id,
|
|
187
|
+
slice_id: params.slice_id,
|
|
188
|
+
task_id: params.task_id,
|
|
189
|
+
}, process.cwd());
|
|
190
|
+
return {
|
|
191
|
+
content: [{ type: "text", text: `Saved ${params.artifact_type} artifact to ${relativePath}` }],
|
|
192
|
+
details: { operation: "save_summary", path: relativePath, artifact_type: params.artifact_type },
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
197
|
+
process.stderr.write(`gsd-db: gsd_summary_save tool failed: ${msg}\n`);
|
|
198
|
+
return {
|
|
199
|
+
content: [{ type: "text", text: `Error saving artifact: ${msg}` }],
|
|
200
|
+
details: { operation: "save_summary", error: msg },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const summarySaveTool = {
|
|
205
|
+
name: "gsd_summary_save",
|
|
129
206
|
label: "Save Summary",
|
|
130
207
|
description: "Save a summary, research, context, or assessment artifact to the GSD database and write it to disk. " +
|
|
131
208
|
"Computes the file path from milestone/slice/task IDs automatically.",
|
|
132
209
|
promptSnippet: "Save a GSD artifact (summary/research/context/assessment) to DB and disk",
|
|
133
210
|
promptGuidelines: [
|
|
134
|
-
"Use
|
|
211
|
+
"Use gsd_summary_save to persist structured artifacts (SUMMARY, RESEARCH, CONTEXT, ASSESSMENT).",
|
|
135
212
|
"milestone_id is required. slice_id and task_id are optional — they determine the file path.",
|
|
136
213
|
"The tool computes the relative path automatically: milestones/M001/M001-SUMMARY.md, milestones/M001/slices/S01/S01-SUMMARY.md, etc.",
|
|
137
214
|
"artifact_type must be one of: SUMMARY, RESEARCH, CONTEXT, ASSESSMENT.",
|
|
@@ -143,98 +220,56 @@ export function registerDbTools(pi) {
|
|
|
143
220
|
artifact_type: Type.String({ description: "One of: SUMMARY, RESEARCH, CONTEXT, ASSESSMENT" }),
|
|
144
221
|
content: Type.String({ description: "The full markdown content of the artifact" }),
|
|
145
222
|
}),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
content: [{ type: "text", text: `Error: Invalid artifact_type "${params.artifact_type}". Must be one of: ${validTypes.join(", ")}` }],
|
|
158
|
-
details: { operation: "save_summary", error: "invalid_artifact_type" },
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
let relativePath;
|
|
163
|
-
if (params.task_id && params.slice_id) {
|
|
164
|
-
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/tasks/${params.task_id}-${params.artifact_type}.md`;
|
|
165
|
-
}
|
|
166
|
-
else if (params.slice_id) {
|
|
167
|
-
relativePath = `milestones/${params.milestone_id}/slices/${params.slice_id}/${params.slice_id}-${params.artifact_type}.md`;
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
relativePath = `milestones/${params.milestone_id}/${params.milestone_id}-${params.artifact_type}.md`;
|
|
171
|
-
}
|
|
172
|
-
const { saveArtifactToDb } = await import("../db-writer.js");
|
|
173
|
-
await saveArtifactToDb({
|
|
174
|
-
path: relativePath,
|
|
175
|
-
artifact_type: params.artifact_type,
|
|
176
|
-
content: params.content,
|
|
177
|
-
milestone_id: params.milestone_id,
|
|
178
|
-
slice_id: params.slice_id,
|
|
179
|
-
task_id: params.task_id,
|
|
180
|
-
}, process.cwd());
|
|
181
|
-
return {
|
|
182
|
-
content: [{ type: "text", text: `Saved ${params.artifact_type} artifact to ${relativePath}` }],
|
|
183
|
-
details: { operation: "save_summary", path: relativePath, artifact_type: params.artifact_type },
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch (err) {
|
|
187
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
188
|
-
process.stderr.write(`gsd-db: gsd_save_summary tool failed: ${msg}\n`);
|
|
223
|
+
execute: summarySaveExecute,
|
|
224
|
+
};
|
|
225
|
+
pi.registerTool(summarySaveTool);
|
|
226
|
+
registerAlias(pi, summarySaveTool, "gsd_save_summary", "gsd_summary_save");
|
|
227
|
+
// ─── gsd_milestone_generate_id (formerly gsd_generate_milestone_id) ────
|
|
228
|
+
const milestoneGenerateIdExecute = async (_toolCallId, _params, _signal, _onUpdate, _ctx) => {
|
|
229
|
+
try {
|
|
230
|
+
// Claim a reserved ID if the guided-flow already previewed one to the user.
|
|
231
|
+
// This guarantees the ID shown in the UI matches the one materialised on disk.
|
|
232
|
+
const reserved = claimReservedId();
|
|
233
|
+
if (reserved) {
|
|
189
234
|
return {
|
|
190
|
-
content: [{ type: "text", text:
|
|
191
|
-
details: { operation: "
|
|
235
|
+
content: [{ type: "text", text: reserved }],
|
|
236
|
+
details: { operation: "generate_milestone_id", id: reserved, source: "reserved" },
|
|
192
237
|
};
|
|
193
238
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
239
|
+
const basePath = process.cwd();
|
|
240
|
+
const existingIds = findMilestoneIds(basePath);
|
|
241
|
+
const uniqueEnabled = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
242
|
+
const allIds = [...new Set([...existingIds, ...getReservedMilestoneIds()])];
|
|
243
|
+
const newId = nextMilestoneId(allIds, uniqueEnabled);
|
|
244
|
+
return {
|
|
245
|
+
content: [{ type: "text", text: newId }],
|
|
246
|
+
details: { operation: "generate_milestone_id", id: newId, existingCount: existingIds.length, uniqueEnabled },
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
251
|
+
return {
|
|
252
|
+
content: [{ type: "text", text: `Error generating milestone ID: ${msg}` }],
|
|
253
|
+
details: { operation: "generate_milestone_id", error: msg },
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const milestoneGenerateIdTool = {
|
|
258
|
+
name: "gsd_milestone_generate_id",
|
|
198
259
|
label: "Generate Milestone ID",
|
|
199
260
|
description: "Generate the next milestone ID for a new GSD milestone. " +
|
|
200
261
|
"Scans existing milestones on disk and respects the unique_milestone_ids preference. " +
|
|
201
262
|
"Always use this tool when creating a new milestone — never invent milestone IDs manually.",
|
|
202
263
|
promptSnippet: "Generate a valid milestone ID (respects unique_milestone_ids preference)",
|
|
203
264
|
promptGuidelines: [
|
|
204
|
-
"ALWAYS call
|
|
265
|
+
"ALWAYS call gsd_milestone_generate_id before creating a new milestone directory or writing milestone files.",
|
|
205
266
|
"Never invent or hardcode milestone IDs like M001, M002 — always use this tool.",
|
|
206
267
|
"Call it once per milestone you need to create. For multi-milestone projects, call it once for each milestone in sequence.",
|
|
207
268
|
"The tool returns the correct format based on project preferences (e.g. M001 or M001-r5jzab).",
|
|
208
269
|
],
|
|
209
270
|
parameters: Type.Object({}),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const reserved = claimReservedId();
|
|
215
|
-
if (reserved) {
|
|
216
|
-
return {
|
|
217
|
-
content: [{ type: "text", text: reserved }],
|
|
218
|
-
details: { operation: "generate_milestone_id", id: reserved, source: "reserved" },
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
const basePath = process.cwd();
|
|
222
|
-
const existingIds = findMilestoneIds(basePath);
|
|
223
|
-
const uniqueEnabled = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
224
|
-
const allIds = [...new Set([...existingIds, ...getReservedMilestoneIds()])];
|
|
225
|
-
const newId = nextMilestoneId(allIds, uniqueEnabled);
|
|
226
|
-
return {
|
|
227
|
-
content: [{ type: "text", text: newId }],
|
|
228
|
-
details: { operation: "generate_milestone_id", id: newId, existingCount: existingIds.length, uniqueEnabled },
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
catch (err) {
|
|
232
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
233
|
-
return {
|
|
234
|
-
content: [{ type: "text", text: `Error generating milestone ID: ${msg}` }],
|
|
235
|
-
details: { operation: "generate_milestone_id", error: msg },
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
});
|
|
271
|
+
execute: milestoneGenerateIdExecute,
|
|
272
|
+
};
|
|
273
|
+
pi.registerTool(milestoneGenerateIdTool);
|
|
274
|
+
registerAlias(pi, milestoneGenerateIdTool, "gsd_generate_milestone_id", "gsd_milestone_generate_id");
|
|
240
275
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { queryJournal } from "../journal.js";
|
|
3
|
+
export function registerJournalTools(pi) {
|
|
4
|
+
pi.registerTool({
|
|
5
|
+
name: "gsd_journal_query",
|
|
6
|
+
label: "Query Journal",
|
|
7
|
+
description: "Query the structured event journal for auto-mode iterations. " +
|
|
8
|
+
"Returns matching journal entries filtered by flow ID, unit ID, rule name, event type, or time range.",
|
|
9
|
+
promptSnippet: "Query the GSD event journal with filters (flowId, unitId, rule, eventType, time range, limit)",
|
|
10
|
+
promptGuidelines: [
|
|
11
|
+
"Filter by flowId to trace all events from a single auto-mode iteration.",
|
|
12
|
+
"Filter by unitId to reconstruct the causal chain for a specific milestone/slice/task.",
|
|
13
|
+
"Use limit to control context size — default is 100 entries.",
|
|
14
|
+
],
|
|
15
|
+
parameters: Type.Object({
|
|
16
|
+
flowId: Type.Optional(Type.String({ description: "Filter by flow ID (UUID grouping one iteration)" })),
|
|
17
|
+
unitId: Type.Optional(Type.String({ description: "Filter by unit ID (e.g. M001/S01/T01) from event data" })),
|
|
18
|
+
rule: Type.Optional(Type.String({ description: "Filter by rule name from the unified registry" })),
|
|
19
|
+
eventType: Type.Optional(Type.String({ description: "Filter by event type (e.g. dispatch-match, unit-start)" })),
|
|
20
|
+
after: Type.Optional(Type.String({ description: "ISO-8601 lower bound (inclusive)" })),
|
|
21
|
+
before: Type.Optional(Type.String({ description: "ISO-8601 upper bound (inclusive)" })),
|
|
22
|
+
limit: Type.Optional(Type.Number({ description: "Maximum entries to return (default: 100)", default: 100 })),
|
|
23
|
+
}),
|
|
24
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
25
|
+
try {
|
|
26
|
+
const filters = {};
|
|
27
|
+
if (params.flowId !== undefined)
|
|
28
|
+
filters.flowId = params.flowId;
|
|
29
|
+
if (params.unitId !== undefined)
|
|
30
|
+
filters.unitId = params.unitId;
|
|
31
|
+
if (params.rule !== undefined)
|
|
32
|
+
filters.rule = params.rule;
|
|
33
|
+
if (params.eventType !== undefined)
|
|
34
|
+
filters.eventType = params.eventType;
|
|
35
|
+
if (params.after !== undefined)
|
|
36
|
+
filters.after = params.after;
|
|
37
|
+
if (params.before !== undefined)
|
|
38
|
+
filters.before = params.before;
|
|
39
|
+
const entries = queryJournal(process.cwd(), filters);
|
|
40
|
+
const limited = entries.slice(0, params.limit ?? 100);
|
|
41
|
+
if (limited.length === 0) {
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: "No matching journal entries found." }],
|
|
44
|
+
details: { operation: "journal_query", count: 0 },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: "text", text: JSON.stringify(limited, null, 2) }],
|
|
49
|
+
details: { operation: "journal_query", count: limited.length },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
54
|
+
process.stderr.write(`gsd-journal: gsd_journal_query tool failed: ${msg}\n`);
|
|
55
|
+
return {
|
|
56
|
+
content: [{ type: "text", text: `Error querying journal: ${msg}` }],
|
|
57
|
+
details: { operation: "journal_query", error: msg },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -3,6 +3,7 @@ import { registerExitCommand } from "../exit-command.js";
|
|
|
3
3
|
import { registerWorktreeCommand } from "../worktree-command.js";
|
|
4
4
|
import { registerDbTools } from "./db-tools.js";
|
|
5
5
|
import { registerDynamicTools } from "./dynamic-tools.js";
|
|
6
|
+
import { registerJournalTools } from "./journal-tools.js";
|
|
6
7
|
import { registerHooks } from "./register-hooks.js";
|
|
7
8
|
import { registerShortcuts } from "./register-shortcuts.js";
|
|
8
9
|
function installEpipeGuard() {
|
|
@@ -33,6 +34,7 @@ export function registerGsdExtension(pi) {
|
|
|
33
34
|
});
|
|
34
35
|
registerDynamicTools(pi);
|
|
35
36
|
registerDbTools(pi);
|
|
37
|
+
registerJournalTools(pi);
|
|
36
38
|
registerShortcuts(pi);
|
|
37
39
|
registerHooks(pi);
|
|
38
40
|
}
|
|
@@ -179,4 +179,20 @@ export function registerHooks(pi) {
|
|
|
179
179
|
pi.on("tool_execution_end", async (event) => {
|
|
180
180
|
markToolEnd(event.toolCallId);
|
|
181
181
|
});
|
|
182
|
+
pi.on("before_provider_request", async (event) => {
|
|
183
|
+
if (!isAutoActive())
|
|
184
|
+
return;
|
|
185
|
+
const modelId = event.model?.id;
|
|
186
|
+
if (!modelId)
|
|
187
|
+
return;
|
|
188
|
+
const { getEffectiveServiceTier, supportsServiceTier } = await import("../service-tier.js");
|
|
189
|
+
const tier = getEffectiveServiceTier();
|
|
190
|
+
if (!tier || !supportsServiceTier(modelId))
|
|
191
|
+
return;
|
|
192
|
+
const payload = event.payload;
|
|
193
|
+
if (!payload || typeof payload !== "object")
|
|
194
|
+
return;
|
|
195
|
+
payload.service_tier = tier;
|
|
196
|
+
return payload;
|
|
197
|
+
});
|
|
182
198
|
}
|
|
@@ -3,7 +3,7 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { loadRegistry } from "../workflow-templates.js";
|
|
5
5
|
const gsdHome = process.env.GSD_HOME || join(homedir(), ".gsd");
|
|
6
|
-
export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|rate|skip|export|cleanup|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|cmux|park|unpark|init|setup|inspect|extensions|update";
|
|
6
|
+
export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|rate|skip|export|cleanup|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|cmux|park|unpark|init|setup|inspect|extensions|update|fast";
|
|
7
7
|
export const TOP_LEVEL_SUBCOMMANDS = [
|
|
8
8
|
{ cmd: "help", desc: "Categorized command reference with descriptions" },
|
|
9
9
|
{ cmd: "next", desc: "Explicit step mode (same as /gsd)" },
|
|
@@ -52,6 +52,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
|
|
|
52
52
|
{ cmd: "start", desc: "Start a workflow template (bugfix, spike, feature, etc.)" },
|
|
53
53
|
{ cmd: "templates", desc: "List available workflow templates" },
|
|
54
54
|
{ cmd: "extensions", desc: "Manage extensions (list, enable, disable, info)" },
|
|
55
|
+
{ cmd: "fast", desc: "Toggle OpenAI service tier (on/off/flex/status)" },
|
|
55
56
|
];
|
|
56
57
|
const NESTED_COMPLETIONS = {
|
|
57
58
|
auto: [
|
|
@@ -163,6 +164,12 @@ const NESTED_COMPLETIONS = {
|
|
|
163
164
|
{ cmd: "disable", desc: "Disable an extension" },
|
|
164
165
|
{ cmd: "info", desc: "Show extension details" },
|
|
165
166
|
],
|
|
167
|
+
fast: [
|
|
168
|
+
{ cmd: "on", desc: "Priority tier (2x cost, faster)" },
|
|
169
|
+
{ cmd: "off", desc: "Disable service tier" },
|
|
170
|
+
{ cmd: "flex", desc: "Flex tier (0.5x cost, slower)" },
|
|
171
|
+
{ cmd: "status", desc: "Show current service tier setting" },
|
|
172
|
+
],
|
|
166
173
|
doctor: [
|
|
167
174
|
{ cmd: "fix", desc: "Auto-fix detected issues" },
|
|
168
175
|
{ cmd: "heal", desc: "AI-driven deep healing" },
|
|
@@ -48,6 +48,7 @@ export function showHelp(ctx) {
|
|
|
48
48
|
" /gsd keys API key manager [list|add|remove|test|rotate|doctor]",
|
|
49
49
|
" /gsd hooks Show post-unit hook configuration",
|
|
50
50
|
" /gsd extensions Manage extensions [list|enable|disable|info]",
|
|
51
|
+
" /gsd fast Toggle OpenAI service tier [on|off|flex|status]",
|
|
51
52
|
"",
|
|
52
53
|
"MAINTENANCE",
|
|
53
54
|
" /gsd doctor Diagnose and repair .gsd/ state [audit|fix|heal] [scope]",
|
|
@@ -169,6 +169,11 @@ Examples:
|
|
|
169
169
|
await handleUpdate(ctx);
|
|
170
170
|
return true;
|
|
171
171
|
}
|
|
172
|
+
if (trimmed === "fast" || trimmed.startsWith("fast ")) {
|
|
173
|
+
const { handleFast } = await import("../../service-tier.js");
|
|
174
|
+
await handleFast(trimmed.replace(/^fast\s*/, "").trim(), ctx);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
172
177
|
if (trimmed === "extensions" || trimmed.startsWith("extensions ")) {
|
|
173
178
|
const { handleExtensions } = await import("../../commands-extensions.js");
|
|
174
179
|
await handleExtensions(trimmed.replace(/^extensions\s*/, "").trim(), ctx);
|
|
@@ -39,6 +39,7 @@ export function queryDecisions(opts) {
|
|
|
39
39
|
choice: row['choice'],
|
|
40
40
|
rationale: row['rationale'],
|
|
41
41
|
revisable: row['revisable'],
|
|
42
|
+
made_by: row['made_by'] ?? 'agent',
|
|
42
43
|
superseded_by: null,
|
|
43
44
|
}));
|
|
44
45
|
}
|
|
@@ -99,9 +100,9 @@ export function queryRequirements(opts) {
|
|
|
99
100
|
export function formatDecisionsForPrompt(decisions) {
|
|
100
101
|
if (decisions.length === 0)
|
|
101
102
|
return '';
|
|
102
|
-
const header = '| # | When | Scope | Decision | Choice | Rationale | Revisable? |';
|
|
103
|
-
const separator = '
|
|
104
|
-
const rows = decisions.map(d => `| ${d.id} | ${d.when_context} | ${d.scope} | ${d.decision} | ${d.choice} | ${d.rationale} | ${d.revisable} |`);
|
|
103
|
+
const header = '| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By |';
|
|
104
|
+
const separator = '|---|------|-------|----------|--------|-----------|------------|---------|';
|
|
105
|
+
const rows = decisions.map(d => `| ${d.id} | ${d.when_context} | ${d.scope} | ${d.decision} | ${d.choice} | ${d.rationale} | ${d.revisable} | ${d.made_by ?? 'agent'} |`);
|
|
105
106
|
return [header, separator, ...rows].join('\n');
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
@@ -30,8 +30,8 @@ export function generateDecisionsMd(decisions) {
|
|
|
30
30
|
lines.push(' To reverse a decision, add a new row that supersedes it.');
|
|
31
31
|
lines.push(' Read this file at the start of any planning or research phase. -->');
|
|
32
32
|
lines.push('');
|
|
33
|
-
lines.push('| # | When | Scope | Decision | Choice | Rationale | Revisable? |');
|
|
34
|
-
lines.push('
|
|
33
|
+
lines.push('| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By |');
|
|
34
|
+
lines.push('|---|------|-------|----------|--------|-----------|------------|---------|');
|
|
35
35
|
for (const d of decisions) {
|
|
36
36
|
// Escape pipe characters within cell values to preserve table structure
|
|
37
37
|
const cells = [
|
|
@@ -42,6 +42,7 @@ export function generateDecisionsMd(decisions) {
|
|
|
42
42
|
d.choice,
|
|
43
43
|
d.rationale,
|
|
44
44
|
d.revisable,
|
|
45
|
+
d.made_by ?? 'agent',
|
|
45
46
|
].map(cell => (cell ?? '').replace(/\|/g, '\\|'));
|
|
46
47
|
lines.push(`| ${cells.join(' | ')} |`);
|
|
47
48
|
}
|
|
@@ -172,6 +173,7 @@ export async function saveDecisionToDb(fields, basePath) {
|
|
|
172
173
|
choice: fields.choice,
|
|
173
174
|
rationale: fields.rationale,
|
|
174
175
|
revisable: fields.revisable ?? 'Yes',
|
|
176
|
+
made_by: fields.made_by ?? 'agent',
|
|
175
177
|
superseded_by: null,
|
|
176
178
|
});
|
|
177
179
|
// Fetch all decisions (including superseded for the full register)
|
|
@@ -188,6 +190,7 @@ export async function saveDecisionToDb(fields, basePath) {
|
|
|
188
190
|
choice: row['choice'],
|
|
189
191
|
rationale: row['rationale'],
|
|
190
192
|
revisable: row['revisable'],
|
|
193
|
+
made_by: row['made_by'] ?? 'agent',
|
|
191
194
|
superseded_by: row['superseded_by'] ?? null,
|
|
192
195
|
}));
|
|
193
196
|
}
|