@goodandready/dsh-goal 0.2.8 → 0.2.10
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/lib/client.js +350 -13
- package/lib/engine-git-branch.js +105 -0
- package/lib/engine-intervention.js +150 -0
- package/lib/engine-issue-sync.js +66 -0
- package/lib/engine-milestones.js +42 -3
- package/lib/engine-prompt.js +28 -4
- package/lib/engine-retrospective.js +79 -0
- package/lib/engine-sessions.js +82 -0
- package/lib/engine-templates.js +167 -0
- package/lib/goal-engine-constants.js +30 -0
- package/lib/goal-engine.js +199 -233
- package/lib/index.js +36 -0
- package/lib/routes.js +139 -9
- package/lib/tools.js +11 -1
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { MilestoneStatus } from './goal-engine-constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Standard engineering goal templates
|
|
5
|
+
*/
|
|
6
|
+
export const GOAL_TEMPLATES = [
|
|
7
|
+
{
|
|
8
|
+
id: 'refactor-module',
|
|
9
|
+
title: 'Refactor Module < 600 Lines',
|
|
10
|
+
description: 'Decompose oversized source files into cohesive sub-modules while preserving test suites',
|
|
11
|
+
inputs: [
|
|
12
|
+
{ key: 'targetFile', label: 'Target File Path', placeholder: 'lib/goal-engine.js', required: true },
|
|
13
|
+
{ key: 'lineThreshold', label: 'Max Lines Target', placeholder: '500', defaultValue: '500' },
|
|
14
|
+
],
|
|
15
|
+
defaultMilestones: [
|
|
16
|
+
{ id: 'm-1', title: 'Analyze target module responsibilities and candidate sub-helpers' },
|
|
17
|
+
{ id: 'm-2', title: 'Extract cohesive helper functions into independent modules', dependsOn: ['m-1'] },
|
|
18
|
+
{ id: 'm-3', title: 'Update main module imports and re-exports', dependsOn: ['m-2'] },
|
|
19
|
+
{ id: 'm-4', title: 'Verify test suite and assert line counts < threshold', dependsOn: ['m-3'] },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'bugfix-regression',
|
|
24
|
+
title: 'Bugfix & Regression Suite',
|
|
25
|
+
description: 'Diagnose issue root cause, write failing regression test, implement fix, and verify',
|
|
26
|
+
inputs: [
|
|
27
|
+
{ key: 'issueId', label: 'Issue # or Title', placeholder: '#83 or Bug description', required: true },
|
|
28
|
+
{ key: 'testFile', label: 'Test File Path', placeholder: 'test/bugfix.test.mjs', required: true },
|
|
29
|
+
],
|
|
30
|
+
defaultMilestones: [
|
|
31
|
+
{ id: 'm-1', title: 'Reproduce bug and create failing regression test' },
|
|
32
|
+
{ id: 'm-2', title: 'Implement targeted fix in codebase', dependsOn: ['m-1'] },
|
|
33
|
+
{ id: 'm-3', title: 'Verify regression test passes without side effects', dependsOn: ['m-2'] },
|
|
34
|
+
{ id: 'm-4', title: 'Run full repository test suite and check cleanliness', dependsOn: ['m-3'] },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'dsh-plugin-standard',
|
|
39
|
+
title: 'DSH Plugin Conformance Standard',
|
|
40
|
+
description: 'Audit and align DeepSeek Harness plugin to Cordis, bilingual i18n, and UI standards',
|
|
41
|
+
inputs: [
|
|
42
|
+
{ key: 'pluginName', label: 'Plugin Package Name', placeholder: '@goodandready/dsh-example', required: true },
|
|
43
|
+
],
|
|
44
|
+
defaultMilestones: [
|
|
45
|
+
{ id: 'm-1', title: 'Verify Cordis lifecycle, service injection, and package.json exports' },
|
|
46
|
+
{ id: 'm-2', title: 'Enforce bilingual en/zh dictionary and purge hardcoded locales', dependsOn: ['m-1'] },
|
|
47
|
+
{ id: 'm-3', title: 'Check semantic design tokens (--dsw-alias-*) and UI slots', dependsOn: ['m-2'] },
|
|
48
|
+
{ id: 'm-4', title: 'Run preflight checks and dry-run npm packaging', dependsOn: ['m-3'] },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'security-preflight',
|
|
53
|
+
title: 'Security Audit & Preflight',
|
|
54
|
+
description: 'Check CSRF protection, origin validation, path traversal, and payload limits',
|
|
55
|
+
inputs: [
|
|
56
|
+
{ key: 'routesFile', label: 'Routes Module Path', placeholder: 'lib/routes.js', defaultValue: 'lib/routes.js' },
|
|
57
|
+
],
|
|
58
|
+
defaultMilestones: [
|
|
59
|
+
{ id: 'm-1', title: 'Audit HTTP endpoints for origin/referer and Sec-Fetch-Site guards' },
|
|
60
|
+
{ id: 'm-2', title: 'Verify filesystem boundaries and path traversal confinement', dependsOn: ['m-1'] },
|
|
61
|
+
{ id: 'm-3', title: 'Run automated security unit test suite', dependsOn: ['m-2'] },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'i18n-hygiene',
|
|
66
|
+
title: 'i18n Localization & Zero-Cyrillic Hygiene',
|
|
67
|
+
description: 'Purge hardcoded strings and comments from source code and verify test gates',
|
|
68
|
+
inputs: [
|
|
69
|
+
{ key: 'targetDir', label: 'Target Directory', placeholder: 'lib/', defaultValue: 'lib/' },
|
|
70
|
+
],
|
|
71
|
+
defaultMilestones: [
|
|
72
|
+
{ id: 'm-1', title: 'Scan target directory for non-ASCII/Cyrillic characters' },
|
|
73
|
+
{ id: 'm-2', title: 'Migrate messages to external locale dictionaries', dependsOn: ['m-1'] },
|
|
74
|
+
{ id: 'm-3', title: 'Assert repository-hygiene automated test passes cleanly', dependsOn: ['m-2'] },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Return list of all available templates
|
|
81
|
+
*/
|
|
82
|
+
export function getTemplatesCatalogue() {
|
|
83
|
+
return GOAL_TEMPLATES;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Instantiate a template with custom input values
|
|
88
|
+
* @param {string} templateId
|
|
89
|
+
* @param {object} inputValues
|
|
90
|
+
* @returns {object|null}
|
|
91
|
+
*/
|
|
92
|
+
export function instantiateTemplate(templateId, inputValues = {}) {
|
|
93
|
+
const tpl = GOAL_TEMPLATES.find((t) => t.id === templateId);
|
|
94
|
+
if (!tpl) return null;
|
|
95
|
+
|
|
96
|
+
let title = tpl.title;
|
|
97
|
+
let description = tpl.description;
|
|
98
|
+
if (inputValues.targetFile) {
|
|
99
|
+
title = `Refactor ${inputValues.targetFile}`;
|
|
100
|
+
description = `Decompose ${inputValues.targetFile} to < ${inputValues.lineThreshold || 500} lines`;
|
|
101
|
+
} else if (inputValues.issueId) {
|
|
102
|
+
title = `Fix ${inputValues.issueId}`;
|
|
103
|
+
description = `Regression fix for ${inputValues.issueId} in ${inputValues.testFile || 'test suite'}`;
|
|
104
|
+
} else if (inputValues.pluginName) {
|
|
105
|
+
title = `Audit ${inputValues.pluginName} standards`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const milestones = tpl.defaultMilestones.map((m, idx) => ({
|
|
109
|
+
id: `m-${idx + 1}`,
|
|
110
|
+
title: m.title,
|
|
111
|
+
status: MilestoneStatus.PENDING,
|
|
112
|
+
dependsOn: m.dependsOn ? [...m.dependsOn] : [],
|
|
113
|
+
checklist: [],
|
|
114
|
+
notes: '',
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
templateId: tpl.id,
|
|
119
|
+
title,
|
|
120
|
+
description,
|
|
121
|
+
milestones,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Generate a smart preliminary plan draft from a user goal prompt
|
|
127
|
+
* @param {string} goalTitle
|
|
128
|
+
* @returns {Array<object>} draft milestones
|
|
129
|
+
*/
|
|
130
|
+
export function generatePreplanDraft(goalTitle) {
|
|
131
|
+
const clean = String(goalTitle || '').trim();
|
|
132
|
+
const lower = clean.toLowerCase();
|
|
133
|
+
|
|
134
|
+
// Tailored breakdown based on keywords
|
|
135
|
+
if (lower.includes('fix') || lower.includes('bug') || lower.includes('issue')) {
|
|
136
|
+
return [
|
|
137
|
+
{ id: 'm-1', title: 'Analyze issue description, reproduce symptoms and locate root cause' },
|
|
138
|
+
{ id: 'm-2', title: 'Write automated regression test reproducing failure', dependsOn: ['m-1'] },
|
|
139
|
+
{ id: 'm-3', title: 'Apply code fix addressing root cause cleanly', dependsOn: ['m-2'] },
|
|
140
|
+
{ id: 'm-4', title: 'Verify test suite and confirm zero regressions', dependsOn: ['m-3'] },
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (lower.includes('refactor') || lower.includes('clean') || lower.includes('split')) {
|
|
145
|
+
return [
|
|
146
|
+
{ id: 'm-1', title: 'Map module architecture, call sites, and identify cohesive sub-domains' },
|
|
147
|
+
{ id: 'm-2', title: 'Extract sub-modules into isolated files maintaining line threshold', dependsOn: ['m-1'] },
|
|
148
|
+
{ id: 'm-3', title: 'Update exports, bindings, and run test verification', dependsOn: ['m-2'] },
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (lower.includes('test') || lower.includes('coverage') || lower.includes('suite')) {
|
|
153
|
+
return [
|
|
154
|
+
{ id: 'm-1', title: 'Audit existing test coverage and identify untested edge cases' },
|
|
155
|
+
{ id: 'm-2', title: 'Implement targeted unit and integration test assertions', dependsOn: ['m-1'] },
|
|
156
|
+
{ id: 'm-3', title: 'Execute full test runner and verify passing report', dependsOn: ['m-2'] },
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Default balanced 4-step engineering plan
|
|
161
|
+
return [
|
|
162
|
+
{ id: 'm-1', title: `Research and inspect prerequisites for "${clean.slice(0, 40)}"` },
|
|
163
|
+
{ id: 'm-2', title: 'Implement core functionality and requisite code updates', dependsOn: ['m-1'] },
|
|
164
|
+
{ id: 'm-3', title: 'Add automated tests verifying implementation correctness', dependsOn: ['m-2'] },
|
|
165
|
+
{ id: 'm-4', title: 'Run full verification, linting, and documentation updates', dependsOn: ['m-3'] },
|
|
166
|
+
];
|
|
167
|
+
}
|
|
@@ -168,7 +168,22 @@ export function buildSnapshot(goal, sid, engine) {
|
|
|
168
168
|
maxTokenBudget: engine.maxTokenBudget,
|
|
169
169
|
budgetWarningThreshold: engine.budgetWarningThreshold,
|
|
170
170
|
budgetWarningTriggered: false,
|
|
171
|
+
budgetAutoScaled: false,
|
|
171
172
|
autoCheckpointOnMilestone: engine.autoCheckpointOnMilestone,
|
|
173
|
+
activityFeed: [],
|
|
174
|
+
userDirective: null,
|
|
175
|
+
preplan: null,
|
|
176
|
+
gitBranch: null,
|
|
177
|
+
retrospective: null,
|
|
178
|
+
enableLiveActivityFeed: engine.enableLiveActivityFeed ?? true,
|
|
179
|
+
enablePreplanning: engine.enablePreplanning ?? true,
|
|
180
|
+
autoBranchOnGoalStart: engine.autoBranchOnGoalStart ?? true,
|
|
181
|
+
enablePostGoalRetrospective: engine.enablePostGoalRetrospective ?? true,
|
|
182
|
+
autoScaleBudgetNearCompletion: engine.autoScaleBudgetNearCompletion ?? false,
|
|
183
|
+
enableTemplatesDrawer: engine.enableTemplatesDrawer ?? true,
|
|
184
|
+
enableMilestoneDependencies: engine.enableMilestoneDependencies ?? true,
|
|
185
|
+
soundScheme: engine.soundScheme ?? 'default',
|
|
186
|
+
enableVoiceAnnouncements: engine.enableVoiceAnnouncements ?? false,
|
|
172
187
|
};
|
|
173
188
|
}
|
|
174
189
|
|
|
@@ -211,6 +226,21 @@ export function buildSnapshot(goal, sid, engine) {
|
|
|
211
226
|
maxTokenBudget: goal.maxTokenBudget ?? engine.maxTokenBudget,
|
|
212
227
|
budgetWarningThreshold: engine.budgetWarningThreshold,
|
|
213
228
|
budgetWarningTriggered: Boolean(goal.budgetWarningTriggered),
|
|
229
|
+
budgetAutoScaled: Boolean(goal.budgetAutoScaled),
|
|
214
230
|
autoCheckpointOnMilestone: engine.autoCheckpointOnMilestone,
|
|
231
|
+
activityFeed: Array.isArray(goal.activityFeed) ? goal.activityFeed : [],
|
|
232
|
+
userDirective: goal.userDirective || null,
|
|
233
|
+
preplan: goal.preplan || null,
|
|
234
|
+
gitBranch: goal.gitBranch || null,
|
|
235
|
+
retrospective: goal.retrospective || null,
|
|
236
|
+
enableLiveActivityFeed: engine.enableLiveActivityFeed ?? true,
|
|
237
|
+
enablePreplanning: engine.enablePreplanning ?? true,
|
|
238
|
+
autoBranchOnGoalStart: engine.autoBranchOnGoalStart ?? true,
|
|
239
|
+
enablePostGoalRetrospective: engine.enablePostGoalRetrospective ?? true,
|
|
240
|
+
autoScaleBudgetNearCompletion: engine.autoScaleBudgetNearCompletion ?? false,
|
|
241
|
+
enableTemplatesDrawer: engine.enableTemplatesDrawer ?? true,
|
|
242
|
+
enableMilestoneDependencies: engine.enableMilestoneDependencies ?? true,
|
|
243
|
+
soundScheme: engine.soundScheme ?? 'default',
|
|
244
|
+
enableVoiceAnnouncements: engine.enableVoiceAnnouncements ?? false,
|
|
215
245
|
};
|
|
216
246
|
}
|