@fractaal/pi-goal-x 0.20.1 → 0.28.0

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 (95) hide show
  1. package/README.md +38 -293
  2. package/dist/goal-auditor.d.ts +7 -61
  3. package/dist/goal-auditor.js +98 -300
  4. package/dist/goal-auditor.js.map +1 -1
  5. package/dist/goal-contract.d.ts +205 -0
  6. package/dist/goal-contract.js +135 -0
  7. package/dist/goal-contract.js.map +1 -0
  8. package/dist/goal-transcript-events.d.ts +54 -0
  9. package/dist/goal-transcript-events.js +177 -0
  10. package/dist/goal-transcript-events.js.map +1 -0
  11. package/dist/goal-widget.d.ts +13 -0
  12. package/dist/goal-widget.js +45 -0
  13. package/dist/goal-widget.js.map +1 -0
  14. package/dist/goal.d.ts +8 -49
  15. package/dist/goal.js +581 -3648
  16. package/dist/goal.js.map +1 -1
  17. package/dist/legacy-migration.d.ts +61 -0
  18. package/dist/legacy-migration.js +306 -0
  19. package/dist/legacy-migration.js.map +1 -0
  20. package/docs/architecture.md +14 -232
  21. package/extensions/goal-auditor.ts +108 -363
  22. package/extensions/goal-contract.ts +149 -0
  23. package/extensions/goal-transcript-events.ts +194 -0
  24. package/extensions/goal-widget.ts +50 -0
  25. package/extensions/goal.ts +602 -3920
  26. package/extensions/legacy-migration.ts +340 -0
  27. package/package.json +46 -21
  28. package/dist/goal-compaction.d.ts +0 -10
  29. package/dist/goal-compaction.js +0 -104
  30. package/dist/goal-compaction.js.map +0 -1
  31. package/dist/goal-core.d.ts +0 -19
  32. package/dist/goal-core.js +0 -66
  33. package/dist/goal-core.js.map +0 -1
  34. package/dist/goal-draft.d.ts +0 -71
  35. package/dist/goal-draft.js +0 -201
  36. package/dist/goal-draft.js.map +0 -1
  37. package/dist/goal-ledger.d.ts +0 -139
  38. package/dist/goal-ledger.js +0 -306
  39. package/dist/goal-ledger.js.map +0 -1
  40. package/dist/goal-policy.d.ts +0 -127
  41. package/dist/goal-policy.js +0 -359
  42. package/dist/goal-policy.js.map +0 -1
  43. package/dist/goal-pool.d.ts +0 -17
  44. package/dist/goal-pool.js +0 -85
  45. package/dist/goal-pool.js.map +0 -1
  46. package/dist/goal-questionnaire.d.ts +0 -56
  47. package/dist/goal-questionnaire.js +0 -733
  48. package/dist/goal-questionnaire.js.map +0 -1
  49. package/dist/goal-record.d.ts +0 -94
  50. package/dist/goal-record.js +0 -155
  51. package/dist/goal-record.js.map +0 -1
  52. package/dist/goal-settings.d.ts +0 -56
  53. package/dist/goal-settings.js +0 -184
  54. package/dist/goal-settings.js.map +0 -1
  55. package/dist/goal-tool-names.d.ts +0 -20
  56. package/dist/goal-tool-names.js +0 -69
  57. package/dist/goal-tool-names.js.map +0 -1
  58. package/dist/prompts/goal-prompts.d.ts +0 -17
  59. package/dist/prompts/goal-prompts.js +0 -304
  60. package/dist/prompts/goal-prompts.js.map +0 -1
  61. package/dist/storage/goal-files.d.ts +0 -40
  62. package/dist/storage/goal-files.js +0 -320
  63. package/dist/storage/goal-files.js.map +0 -1
  64. package/dist/widgets/goal-escape-dialog.d.ts +0 -15
  65. package/dist/widgets/goal-escape-dialog.js +0 -118
  66. package/dist/widgets/goal-escape-dialog.js.map +0 -1
  67. package/dist/widgets/goal-notifications.d.ts +0 -5
  68. package/dist/widgets/goal-notifications.js +0 -9
  69. package/dist/widgets/goal-notifications.js.map +0 -1
  70. package/dist/widgets/goal-widget.d.ts +0 -58
  71. package/dist/widgets/goal-widget.js +0 -282
  72. package/dist/widgets/goal-widget.js.map +0 -1
  73. package/dist/widgets/task-list-overlay.d.ts +0 -8
  74. package/dist/widgets/task-list-overlay.js +0 -321
  75. package/dist/widgets/task-list-overlay.js.map +0 -1
  76. package/docs/agent-flow-design.md +0 -432
  77. package/docs/agentic-runtime-prd.md +0 -764
  78. package/docs/goal-ts-refactor-test-strategy.md +0 -82
  79. package/docs/pi-autoresearch-survey.md +0 -45
  80. package/extensions/goal-compaction.ts +0 -133
  81. package/extensions/goal-core.ts +0 -77
  82. package/extensions/goal-draft.ts +0 -263
  83. package/extensions/goal-ledger.ts +0 -354
  84. package/extensions/goal-policy.ts +0 -389
  85. package/extensions/goal-pool.ts +0 -98
  86. package/extensions/goal-questionnaire.ts +0 -779
  87. package/extensions/goal-record.ts +0 -256
  88. package/extensions/goal-settings.ts +0 -181
  89. package/extensions/goal-tool-names.ts +0 -76
  90. package/extensions/prompts/goal-prompts.ts +0 -308
  91. package/extensions/storage/goal-files.ts +0 -352
  92. package/extensions/widgets/goal-escape-dialog.ts +0 -146
  93. package/extensions/widgets/goal-notifications.ts +0 -9
  94. package/extensions/widgets/goal-widget.ts +0 -378
  95. package/extensions/widgets/task-list-overlay.ts +0 -389
@@ -1,256 +0,0 @@
1
- export type GoalStatus = "active" | "paused" | "complete";
2
- export type StopReason = "user" | "agent";
3
- export type GoalEventKind = "checkpoint" | "stale" | "drafting";
4
- export type DraftingFocus = "goal" | "sisyphus";
5
- export type GoalFocusReason = "created" | "selected" | "resumed" | "completed" | "cleared" | "aborted" | "migrated";
6
-
7
- export type TaskStatus = "pending" | "complete" | "skipped";
8
-
9
- export interface GoalTask {
10
- id: string;
11
- title: string;
12
- status: TaskStatus;
13
- completedAt?: string;
14
- skippedAt?: string;
15
- evidence?: string;
16
- skipReason?: string;
17
- verificationContract?: string;
18
- lightweightSubtasks?: boolean;
19
- subtasks?: GoalTask[];
20
- }
21
-
22
- export interface GoalTaskList {
23
- tasks: GoalTask[];
24
- blockCompletion: boolean;
25
- proposedAt: string;
26
- }
27
-
28
- export interface GoalUsage {
29
- tokensUsed: number;
30
- activeSeconds: number;
31
- }
32
-
33
- export interface GoalRecord {
34
- id: string;
35
- objective: string;
36
- status: GoalStatus;
37
- autoContinue: boolean;
38
- usage: GoalUsage;
39
- sisyphus: boolean;
40
- createdAt: string;
41
- updatedAt: string;
42
- activePath?: string;
43
- archivedPath?: string;
44
- stopReason?: StopReason;
45
- // Set by the agent's pause_goal tool. Cleared when the goal becomes active again.
46
- pauseReason?: string;
47
- pauseSuggestedAction?: string;
48
- skipAuditor?: boolean;
49
- taskList?: GoalTaskList;
50
- /** Plain-text description of what verification evidence is required before completing this goal. */
51
- verificationContract?: string;
52
- }
53
-
54
- export interface GoalStateEntry {
55
- version: 3;
56
- goal: GoalRecord | null;
57
- }
58
-
59
- export interface GoalFocusEntry {
60
- version: 1;
61
- focusedGoalId: string | null;
62
- reason: GoalFocusReason;
63
- }
64
-
65
- export interface GoalEventDetails {
66
- kind: GoalEventKind;
67
- goalId: string;
68
- status?: GoalStatus;
69
- objective?: string;
70
- timestamp?: number;
71
- continuationEpoch?: number;
72
- currentGoalId?: string | null;
73
- currentStatus?: GoalStatus | null;
74
- focus?: DraftingFocus;
75
- }
76
-
77
- export interface GoalCreationConfig {
78
- objective: string;
79
- autoContinue: boolean;
80
- sisyphus: boolean;
81
- }
82
-
83
- export interface AssistantUsage {
84
- input?: number;
85
- output?: number;
86
- }
87
-
88
- export interface AssistantMessageLike {
89
- role?: string;
90
- stopReason?: string;
91
- usage?: AssistantUsage;
92
- }
93
-
94
- export function nowIso(now = Date.now()): string {
95
- return new Date(now).toISOString();
96
- }
97
-
98
- export function safeIdPart(value: string): string {
99
- return value.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 80) || "goal";
100
- }
101
-
102
- export function newGoalId(): string {
103
- return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
104
- }
105
-
106
- export function normalizeRelPath(relPath: string): string {
107
- return relPath.split(/[\\/]+/).join("/");
108
- }
109
-
110
- export function asRecord(value: unknown): Record<string, unknown> | null {
111
- return value && typeof value === "object" && !Array.isArray(value) ? (value as Record<string, unknown>) : null;
112
- }
113
-
114
- export function emptyUsage(): GoalUsage {
115
- return { tokensUsed: 0, activeSeconds: 0 };
116
- }
117
-
118
- function cloneGoalTask(task: GoalTask): GoalTask {
119
- return {
120
- ...task,
121
- subtasks: task.subtasks ? task.subtasks.map(cloneGoalTask) : undefined,
122
- };
123
- }
124
-
125
- export function cloneGoal(goal: GoalRecord): GoalRecord {
126
- return {
127
- ...goal,
128
- usage: { ...goal.usage },
129
- taskList: goal.taskList
130
- ? { ...goal.taskList, tasks: goal.taskList.tasks.map(cloneGoalTask) }
131
- : undefined,
132
- };
133
- }
134
-
135
- export function goalFocusDetails(focusedGoalId: string | null, reason: GoalFocusReason): GoalFocusEntry {
136
- return {
137
- version: 1,
138
- focusedGoalId: focusedGoalId ? safeIdPart(focusedGoalId) : null,
139
- reason,
140
- };
141
- }
142
-
143
- export function normalizeGoalFocusEntry(value: unknown): GoalFocusEntry | null {
144
- const raw = asRecord(value);
145
- if (!raw || raw.version !== 1) return null;
146
- const focusedGoalId = typeof raw.focusedGoalId === "string" && raw.focusedGoalId.trim()
147
- ? safeIdPart(raw.focusedGoalId)
148
- : null;
149
- const reason: GoalFocusReason =
150
- raw.reason === "created" || raw.reason === "selected" || raw.reason === "resumed" || raw.reason === "completed" || raw.reason === "cleared" || raw.reason === "aborted" || raw.reason === "migrated"
151
- ? raw.reason
152
- : "selected";
153
- return { version: 1, focusedGoalId, reason };
154
- }
155
-
156
- export function createGoal(config: GoalCreationConfig, now = Date.now()): GoalRecord {
157
- const timestamp = nowIso(now);
158
- return {
159
- id: newGoalId(),
160
- objective: config.objective,
161
- status: "active",
162
- autoContinue: config.autoContinue,
163
- usage: emptyUsage(),
164
- sisyphus: config.sisyphus,
165
- createdAt: timestamp,
166
- updatedAt: timestamp,
167
- };
168
- }
169
-
170
- export function normalizeUsage(value: unknown): GoalUsage {
171
- const raw = asRecord(value);
172
- if (!raw) return emptyUsage();
173
- const tokensUsed = typeof raw.tokensUsed === "number" && Number.isFinite(raw.tokensUsed) ? Math.max(0, Math.floor(raw.tokensUsed)) : 0;
174
- const activeSeconds = typeof raw.activeSeconds === "number" && Number.isFinite(raw.activeSeconds) ? Math.max(0, Math.floor(raw.activeSeconds)) : 0;
175
- return { tokensUsed, activeSeconds };
176
- }
177
-
178
- export function normalizeTaskItem(raw: Record<string, unknown>): GoalTask | undefined {
179
- const id = typeof raw.id === "string" && raw.id.trim() ? raw.id.trim() : "";
180
- const title = typeof raw.title === "string" ? raw.title.trim() : "";
181
- if (!id || !title) return undefined;
182
- const status: TaskStatus = raw.status === "complete" ? "complete" : raw.status === "skipped" ? "skipped" : "pending";
183
- const subtasksRaw = raw.subtasks;
184
- let subtasks: GoalTask[] | undefined;
185
- if (Array.isArray(subtasksRaw)) {
186
- subtasks = subtasksRaw
187
- .map((item) => (item && typeof item === "object" ? normalizeTaskItem(item as Record<string, unknown>) : undefined))
188
- .filter((t): t is GoalTask => !!t);
189
- if (subtasks.length === 0) subtasks = undefined;
190
- }
191
- return {
192
- id,
193
- title,
194
- status,
195
- completedAt: typeof raw.completedAt === "string" ? raw.completedAt : undefined,
196
- skippedAt: typeof raw.skippedAt === "string" ? raw.skippedAt : undefined,
197
- evidence: typeof raw.evidence === "string" ? raw.evidence : undefined,
198
- skipReason: typeof raw.skipReason === "string" ? raw.skipReason : undefined,
199
- verificationContract: typeof raw.verificationContract === "string" ? raw.verificationContract : undefined,
200
- lightweightSubtasks: raw.lightweightSubtasks === true ? true : undefined,
201
- subtasks,
202
- };
203
- }
204
-
205
- export function normalizeTaskList(value: unknown): GoalTaskList | undefined {
206
- const raw = asRecord(value);
207
- if (!raw) return undefined;
208
- const tasksRaw = raw.tasks;
209
- if (!Array.isArray(tasksRaw)) return undefined;
210
- const tasks: GoalTask[] = tasksRaw
211
- .map((item) => (item && typeof item !== "object" || Array.isArray(item) ? undefined : normalizeTaskItem(item as Record<string, unknown>)))
212
- .filter((t): t is GoalTask => !!t);
213
- if (tasks.length === 0) return undefined;
214
- return {
215
- tasks,
216
- blockCompletion: raw.blockCompletion === true,
217
- proposedAt: typeof raw.proposedAt === "string" ? raw.proposedAt : nowIso(),
218
- };
219
- }
220
-
221
- export function normalizeGoalRecord(value: unknown): GoalRecord | null {
222
- const raw = asRecord(value);
223
- if (!raw) return null;
224
- const objective = typeof raw.objective === "string" ? raw.objective.trim() : "";
225
- if (!objective) return null;
226
-
227
- const timestamp = nowIso();
228
- const rawStatus = raw.status;
229
- let status: GoalStatus = rawStatus === "complete" ? "complete" : rawStatus === "paused" ? "paused" : "active";
230
- const autoContinue = typeof raw.autoContinue === "boolean" ? raw.autoContinue : true;
231
- const usage = normalizeUsage(raw.usage);
232
- const sisyphus = raw.sisyphus === true;
233
-
234
- if (status === "paused" && autoContinue) {
235
- status = "active";
236
- }
237
-
238
- return {
239
- id: typeof raw.id === "string" && raw.id ? safeIdPart(raw.id) : newGoalId(),
240
- objective,
241
- status,
242
- autoContinue,
243
- usage,
244
- sisyphus,
245
- createdAt: typeof raw.createdAt === "string" ? raw.createdAt : timestamp,
246
- updatedAt: typeof raw.updatedAt === "string" ? raw.updatedAt : timestamp,
247
- activePath: typeof raw.activePath === "string" ? raw.activePath : undefined,
248
- archivedPath: typeof raw.archivedPath === "string" ? raw.archivedPath : undefined,
249
- stopReason: raw.stopReason === "agent" || raw.stopReason === "user" ? raw.stopReason : undefined,
250
- pauseReason: typeof raw.pauseReason === "string" && raw.pauseReason.trim() ? raw.pauseReason : undefined,
251
- pauseSuggestedAction: typeof raw.pauseSuggestedAction === "string" && raw.pauseSuggestedAction.trim() ? raw.pauseSuggestedAction : undefined,
252
- skipAuditor: raw.skipAuditor === true ? true : undefined,
253
- taskList: normalizeTaskList(raw.taskList),
254
- verificationContract: typeof raw.verificationContract === "string" ? raw.verificationContract : undefined,
255
- };
256
- }
@@ -1,181 +0,0 @@
1
- /**
2
- * Unified global goal settings.
3
- *
4
- * Reads `.pi/pi-goal-x-settings.json` with env var overrides:
5
- * PI_GOAL_DISABLE_TASKS — "true" to disable, any other value = use file config
6
- * PI_GOAL_DISABLE_CONTRACTS — "true" to disable, any other value = use file config
7
- * PI_GOAL_SETTINGS_FILE — alternative settings file path (relative to cwd or absolute)
8
- *
9
- * The file may contain:
10
- * disableTasks, disableContracts, subtaskDepth,
11
- * provider, model, thinkingLevel, disabled
12
- *
13
- * additionalProperties: false — unknown keys are rejected.
14
- */
15
-
16
- import * as fs from "node:fs";
17
- import * as path from "node:path";
18
-
19
- export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
20
-
21
- export interface GoalSettings {
22
- disableTasks?: boolean;
23
- disableContracts?: boolean;
24
- subtaskDepth?: number;
25
- provider?: string;
26
- model?: string;
27
- thinkingLevel?: ThinkingLevel;
28
- disabled?: boolean;
29
- }
30
-
31
- export const PI_GOAL_SETTINGS_FILE_ENV = "PI_GOAL_SETTINGS_FILE";
32
-
33
- const THINKING_LEVELS = new Set(["off", "minimal", "low", "medium", "high", "xhigh"]);
34
-
35
- const ALLOWED_SETTINGS_KEYS = new Set([
36
- "disableTasks",
37
- "disableContracts",
38
- "subtaskDepth",
39
- "provider",
40
- "model",
41
- "thinkingLevel",
42
- "thinking_level",
43
- "disabled",
44
- ]);
45
-
46
- /**
47
- * Resolve the path to the unified settings file.
48
- * Uses `PI_GOAL_SETTINGS_FILE` env var if set (relative to cwd or absolute).
49
- * Otherwise defaults to `.pi/pi-goal-x-settings.json`.
50
- */
51
- export function goalSettingsPath(cwd: string, env: NodeJS.ProcessEnv = process.env): string {
52
- const override = asNonEmptyString(env[PI_GOAL_SETTINGS_FILE_ENV]);
53
- if (override) {
54
- return path.isAbsolute(override) ? override : path.join(cwd, override);
55
- }
56
- return path.join(cwd, ".pi", "pi-goal-x-settings.json");
57
- }
58
-
59
- function asNonEmptyString(value: unknown): string | undefined {
60
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
61
- }
62
-
63
- function asBool(value: unknown): boolean | undefined {
64
- if (value === true || value === "true") return true;
65
- if (value === false || value === "false") return false;
66
- return undefined;
67
- }
68
-
69
- function asPositiveInt(value: unknown): number | undefined {
70
- if (typeof value === "number" && Number.isInteger(value) && value >= 1) return value;
71
- if (typeof value === "string") {
72
- const n = parseInt(value, 10);
73
- if (!isNaN(n) && n >= 1) return n;
74
- }
75
- return undefined;
76
- }
77
-
78
- function asThinkingLevel(value: unknown): ThinkingLevel | undefined {
79
- const text = asNonEmptyString(value);
80
- return text && THINKING_LEVELS.has(text) ? text as ThinkingLevel : undefined;
81
- }
82
-
83
- /**
84
- * Parse raw (deserialized JSON) into a GoalSettings object.
85
- * Rejects unknown keys (additionalProperties: false semantics).
86
- */
87
- export function parseGoalSettings(raw: unknown): GoalSettings {
88
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
89
- const record = raw as Record<string, unknown>;
90
- const unknownKeys = Object.keys(record).filter((k) => !ALLOWED_SETTINGS_KEYS.has(k));
91
- if (unknownKeys.length > 0) {
92
- throw new Error(`Unknown pi-goal-x-settings.json key(s): ${unknownKeys.join(", ")}`);
93
- }
94
- const settings: GoalSettings = {};
95
- const disableTasks = asBool(record.disableTasks);
96
- const disableContracts = asBool(record.disableContracts);
97
- const subtaskDepth = asPositiveInt(record.subtaskDepth);
98
- const provider = asNonEmptyString(record.provider);
99
- const model = asNonEmptyString(record.model);
100
- const thinkingLevel = asThinkingLevel(record.thinkingLevel ?? record.thinking_level);
101
- if (disableTasks !== undefined) settings.disableTasks = disableTasks;
102
- if (disableContracts !== undefined) settings.disableContracts = disableContracts;
103
- if (subtaskDepth !== undefined) settings.subtaskDepth = subtaskDepth;
104
- if (provider !== undefined) settings.provider = provider;
105
- if (model !== undefined) settings.model = model;
106
- if (thinkingLevel !== undefined) settings.thinkingLevel = thinkingLevel;
107
- if (record.disabled === true || record.disabled === "true") settings.disabled = true;
108
- return settings;
109
- }
110
-
111
- /**
112
- * Load settings from the file on disk. Returns {} if file missing or invalid.
113
- */
114
- export function loadGoalSettingsFileConfig(cwd: string, env?: NodeJS.ProcessEnv): GoalSettings {
115
- try {
116
- const configPath = goalSettingsPath(cwd, env);
117
- if (fs.existsSync(configPath)) return parseGoalSettings(JSON.parse(fs.readFileSync(configPath, "utf8")));
118
- } catch {
119
- // file missing, malformed JSON, etc. — use defaults
120
- }
121
- return {};
122
- }
123
-
124
- /**
125
- * Load settings with env var overrides.
126
- * Env vars take precedence over file config.
127
- * Default: all flags false/undefined (features enabled, default model).
128
- */
129
- export function loadGoalSettings(cwd: string, env: NodeJS.ProcessEnv = process.env): GoalSettings {
130
- const fileConfig = loadGoalSettingsFileConfig(cwd, env);
131
- return {
132
- disableTasks: asBool(env.PI_GOAL_DISABLE_TASKS) ?? fileConfig.disableTasks ?? false,
133
- disableContracts: asBool(env.PI_GOAL_DISABLE_CONTRACTS) ?? fileConfig.disableContracts ?? false,
134
- subtaskDepth: fileConfig.subtaskDepth ?? 1,
135
- provider: fileConfig.provider,
136
- model: fileConfig.model,
137
- thinkingLevel: fileConfig.thinkingLevel,
138
- disabled: fileConfig.disabled,
139
- };
140
- }
141
-
142
- /**
143
- * Save settings to the unified settings file on disk.
144
- * Persists only non-default values using the canonical key names.
145
- */
146
- /**
147
- * Determine whether the auditor should be enabled by default based on settings.
148
- * The auditor is enabled by default unless settings.disabled === true.
149
- */
150
- export function isAuditorEnabledByDefault(settings: GoalSettings): boolean {
151
- return settings.disabled !== true;
152
- }
153
-
154
- export function saveGoalSettingsFileConfig(cwd: string, settings: GoalSettings): GoalSettings {
155
- const clean: GoalSettings = {};
156
- const provider = asNonEmptyString(settings.provider);
157
- const model = asNonEmptyString(settings.model);
158
- const thinkingLevel = asThinkingLevel(settings.thinkingLevel);
159
- const disableTasks = asBool(settings.disableTasks);
160
- const disableContracts = asBool(settings.disableContracts);
161
- const subtaskDepth = asPositiveInt(settings.subtaskDepth);
162
- if (provider) clean.provider = provider;
163
- if (model) clean.model = model;
164
- if (thinkingLevel) clean.thinkingLevel = thinkingLevel;
165
- if (settings.disabled === true) clean.disabled = true;
166
- if (disableTasks === true) clean.disableTasks = true;
167
- if (disableContracts === true) clean.disableContracts = true;
168
- if (subtaskDepth !== undefined) clean.subtaskDepth = subtaskDepth;
169
- const configPath = goalSettingsPath(cwd);
170
- fs.mkdirSync(path.dirname(configPath), { recursive: true });
171
- const persisted: Record<string, unknown> = {};
172
- if (clean.provider) persisted.provider = clean.provider;
173
- if (clean.model) persisted.model = clean.model;
174
- if (clean.thinkingLevel) persisted.thinking_level = clean.thinkingLevel;
175
- if (clean.disabled) persisted.disabled = true;
176
- if (clean.disableTasks) persisted.disableTasks = true;
177
- if (clean.disableContracts) persisted.disableContracts = true;
178
- if (clean.subtaskDepth !== undefined) persisted.subtaskDepth = clean.subtaskDepth;
179
- fs.writeFileSync(configPath, `${JSON.stringify(persisted, null, 2)}\n`, "utf8");
180
- return clean;
181
- }
@@ -1,76 +0,0 @@
1
- export const SISYPHUS_STEP_TOOL_NAME = "step_complete";
2
- export const PROPOSE_TWEAK_TOOL_NAME = "propose_goal_tweak";
3
- export const PROPOSE_DRAFT_TOOL_NAME = "propose_goal_draft";
4
- export const CREATE_GOAL_TOOL_NAME = "create_goal";
5
- export const QUESTION_TOOL_NAME = "goal_question";
6
- export const QUESTIONNAIRE_TOOL_NAME = "goal_questionnaire";
7
- export const ABORT_GOAL_TOOL_NAME = "abort_goal";
8
- export const PROPOSE_TASK_LIST_TOOL_NAME = "propose_task_list";
9
- export const COMPLETE_TASK_TOOL_NAME = "complete_task";
10
- export const SKIP_TASK_TOOL_NAME = "skip_task";
11
-
12
- export const ACTIVE_GOAL_TOOL_NAMES = ["get_goal", "complete_goal", "pause_goal", ABORT_GOAL_TOOL_NAME, PROPOSE_TWEAK_TOOL_NAME, PROPOSE_TASK_LIST_TOOL_NAME, COMPLETE_TASK_TOOL_NAME, SKIP_TASK_TOOL_NAME] as const;
13
- export const PAUSED_GOAL_TOOL_NAMES = ["get_goal", "complete_goal", ABORT_GOAL_TOOL_NAME, PROPOSE_TWEAK_TOOL_NAME, PROPOSE_TASK_LIST_TOOL_NAME] as const;
14
- export const NO_FOCUSED_GOAL_TOOL_NAMES = ["get_goal"] as const;
15
-
16
- export const GOAL_WORK_TOOL_NAMES = [
17
- "complete_goal",
18
- "pause_goal",
19
- ABORT_GOAL_TOOL_NAME,
20
- PROPOSE_TWEAK_TOOL_NAME,
21
- PROPOSE_TASK_LIST_TOOL_NAME,
22
- COMPLETE_TASK_TOOL_NAME,
23
- SKIP_TASK_TOOL_NAME,
24
- CREATE_GOAL_TOOL_NAME,
25
- PROPOSE_DRAFT_TOOL_NAME,
26
- QUESTION_TOOL_NAME,
27
- QUESTIONNAIRE_TOOL_NAME,
28
- "get_goal",
29
- "write",
30
- "edit",
31
- "bash",
32
- "read",
33
- "grep",
34
- "find",
35
- "ls",
36
- ] as const;
37
-
38
- export const GOAL_PROGRESS_TOOL_NAMES = [
39
- "complete_goal",
40
- "pause_goal",
41
- ABORT_GOAL_TOOL_NAME,
42
- COMPLETE_TASK_TOOL_NAME,
43
- SKIP_TASK_TOOL_NAME,
44
- "write",
45
- "edit",
46
- "bash",
47
- "read",
48
- "grep",
49
- "find",
50
- "ls",
51
- ] as const;
52
-
53
- export const POST_STOP_ALLOWED_TOOLS = ["get_goal"] as const;
54
-
55
- export type GoalToolStatus = "active" | "paused" | "complete" | null | undefined;
56
-
57
-
58
- export type GoalToolPhase = "normal" | "drafting" | "tweakDrafting";
59
-
60
- export function lifecycleToolNamesForGoalStatus(status: GoalToolStatus, phase: GoalToolPhase = "normal"): readonly string[] {
61
- if (phase === "drafting" || phase === "tweakDrafting") return NO_FOCUSED_GOAL_TOOL_NAMES;
62
- if (status === "active") return ACTIVE_GOAL_TOOL_NAMES;
63
- if (status === "paused") return PAUSED_GOAL_TOOL_NAMES;
64
- return NO_FOCUSED_GOAL_TOOL_NAMES;
65
- }
66
-
67
- export function isQuestionLikeToolName(toolName: string): boolean {
68
- const lower = toolName.toLowerCase();
69
- return lower === QUESTION_TOOL_NAME
70
- || lower === QUESTIONNAIRE_TOOL_NAME
71
- || lower.includes("question")
72
- || lower.includes("questionnaire")
73
- || lower.includes("ask")
74
- || lower.includes("clarify")
75
- || lower.includes("confirm");
76
- }