@nerviq/cli 1.8.9 → 1.10.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.
@@ -1,215 +1,215 @@
1
- /**
2
- * Windsurf Freshness Operationalization
3
- *
4
- * Release gates, recurring probes, propagation checklists,
5
- * and staleness blocking for Windsurf surfaces.
6
- *
7
- * P0 sources from windsurf.com docs, propagation for rule format changes.
8
- */
9
-
10
- const { version } = require('../../package.json');
11
-
12
- /**
13
- * P0 sources that must be fresh before any Windsurf release claim.
14
- */
15
- const P0_SOURCES = [
16
- {
17
- key: 'windsurf-rules-docs',
18
- label: 'Windsurf Rules Documentation',
19
- url: 'https://docs.windsurf.com/windsurf/cascade/rules',
20
- stalenessThresholdDays: 30,
21
- verifiedAt: null,
22
- },
23
- {
24
- key: 'windsurf-cascade-docs',
25
- label: 'Cascade Agent Documentation',
26
- url: 'https://docs.windsurf.com/windsurf/cascade',
27
- stalenessThresholdDays: 30,
28
- verifiedAt: null,
29
- },
30
- {
31
- key: 'windsurf-mcp-docs',
32
- label: 'Windsurf MCP Documentation',
33
- url: 'https://docs.windsurf.com/windsurf/mcp',
34
- stalenessThresholdDays: 30,
35
- verifiedAt: null,
36
- },
37
- {
38
- key: 'windsurf-memories-docs',
39
- label: 'Memories Documentation',
40
- url: 'https://docs.windsurf.com/windsurf/cascade/memories',
41
- stalenessThresholdDays: 30,
42
- verifiedAt: null,
43
- },
44
- {
45
- key: 'windsurf-workflows-docs',
46
- label: 'Workflows Documentation',
47
- url: 'https://docs.windsurf.com/windsurf/cascade/workflows',
48
- stalenessThresholdDays: 30,
49
- verifiedAt: null,
50
- },
51
- {
52
- key: 'windsurf-steps-docs',
53
- label: 'Steps Documentation',
54
- url: 'https://docs.windsurf.com/windsurf/cascade/steps',
55
- stalenessThresholdDays: 30,
56
- verifiedAt: null,
57
- },
58
- {
59
- key: 'windsurf-cascadeignore-docs',
60
- label: 'Cascadeignore Documentation',
61
- url: 'https://docs.windsurf.com/windsurf/cascade/cascadeignore',
62
- stalenessThresholdDays: 30,
63
- verifiedAt: null,
64
- },
65
- {
66
- key: 'windsurf-changelog',
67
- label: 'Windsurf Changelog',
68
- url: 'https://windsurf.com/changelog',
69
- stalenessThresholdDays: 14,
70
- verifiedAt: null,
71
- },
72
- {
73
- key: 'windsurf-security',
74
- label: 'Windsurf Security Documentation',
75
- url: 'https://docs.windsurf.com/windsurf/security',
76
- stalenessThresholdDays: 30,
77
- verifiedAt: null,
78
- },
79
- ];
80
-
81
- /**
82
- * Propagation checklist: when a Windsurf source changes, these must update.
83
- */
84
- const PROPAGATION_CHECKLIST = [
85
- {
86
- trigger: 'Rule format change (new frontmatter fields, activation mode change)',
87
- targets: [
88
- 'src/windsurf/config-parser.js — update VALID_WINDSURF_FIELDS, detectRuleType, parseSimpleYaml',
89
- 'src/windsurf/techniques.js — update rule validation checks (WS-A01..WS-A09)',
90
- 'src/windsurf/context.js — update windsurfRules() parsing and type detection',
91
- 'src/windsurf/setup.js — update rule template generation',
92
- ],
93
- },
94
- {
95
- trigger: 'Cascade agent behavior change (multi-file, Steps, Skills)',
96
- targets: [
97
- 'src/windsurf/techniques.js — update Cascade agent checks (WS-D01..WS-D05)',
98
- 'src/windsurf/governance.js — update permission profiles',
99
- 'src/windsurf/deep-review.js — update trust class detection',
100
- ],
101
- },
102
- {
103
- trigger: 'Memories format or sync behavior change',
104
- targets: [
105
- 'src/windsurf/techniques.js — update memory checks (WS-H01..WS-H05)',
106
- 'src/windsurf/context.js — update memoryContents() parsing',
107
- 'src/windsurf/governance.js — update team-managed permission profile',
108
- ],
109
- },
110
- {
111
- trigger: 'MCP configuration format change in .windsurf/mcp.json',
112
- targets: [
113
- 'src/windsurf/mcp-packs.js — update pack JSON projections and merge logic',
114
- 'src/windsurf/techniques.js — update MCP checks (WS-E01..WS-E05)',
115
- 'src/windsurf/context.js — update mcpConfig() parsing',
116
- 'src/windsurf/config-parser.js — update validateMcpEnvVars',
117
- ],
118
- },
119
- {
120
- trigger: 'MCP team whitelist format change',
121
- targets: [
122
- 'src/windsurf/techniques.js — update WS-B02, WS-E05 thresholds',
123
- 'src/windsurf/governance.js — update mcp-team-whitelist caveat',
124
- 'src/windsurf/mcp-packs.js — update recommendation logic',
125
- ],
126
- },
127
- {
128
- trigger: 'Workflow / slash command format change',
129
- targets: [
130
- 'src/windsurf/techniques.js — update workflow checks (WS-G01..WS-G05)',
131
- 'src/windsurf/context.js — update workflowFiles() parsing',
132
- 'src/windsurf/governance.js — update workflow-trigger hook',
133
- ],
134
- },
135
- {
136
- trigger: 'Cascadeignore format or behavior change',
137
- targets: [
138
- 'src/windsurf/techniques.js — update cascadeignore checks (WS-J01..WS-J02)',
139
- 'src/windsurf/context.js — update cascadeignoreContent() parsing',
140
- 'src/windsurf/patch.js — update patchCascadeignore',
141
- ],
142
- },
143
- {
144
- trigger: '10K char rule limit change',
145
- targets: [
146
- 'src/windsurf/techniques.js — update WS-A05, WS-L05',
147
- 'src/windsurf/context.js — update overLimit calculation',
148
- 'src/windsurf/governance.js — update rule-char-limit caveat',
149
- ],
150
- },
151
- ];
152
-
153
- /**
154
- * Release gate: check if all P0 sources are within staleness threshold.
155
- */
156
- function checkReleaseGate(sourceVerifications = {}) {
157
- const now = new Date();
158
- const results = P0_SOURCES.map(source => {
159
- const verifiedAt = sourceVerifications[source.key]
160
- ? new Date(sourceVerifications[source.key])
161
- : source.verifiedAt ? new Date(source.verifiedAt) : null;
162
-
163
- if (!verifiedAt) {
164
- return { ...source, status: 'unverified', daysStale: null };
165
- }
166
-
167
- const daysSince = Math.floor((now - verifiedAt) / (1000 * 60 * 60 * 24));
168
- const isStale = daysSince > source.stalenessThresholdDays;
169
-
170
- return { ...source, verifiedAt: verifiedAt.toISOString(), daysStale: daysSince, status: isStale ? 'stale' : 'fresh' };
171
- });
172
-
173
- return {
174
- ready: results.every(r => r.status === 'fresh'),
175
- stale: results.filter(r => r.status === 'stale' || r.status === 'unverified'),
176
- fresh: results.filter(r => r.status === 'fresh'),
177
- results,
178
- };
179
- }
180
-
181
- function formatReleaseGate(gateResult) {
182
- const lines = [
183
- `Windsurf Freshness Gate (nerviq v${version})`,
184
- '═══════════════════════════════════════',
185
- '',
186
- `Status: ${gateResult.ready ? 'READY' : 'BLOCKED'}`,
187
- `Fresh: ${gateResult.fresh.length}/${gateResult.results.length}`,
188
- '',
189
- ];
190
-
191
- for (const result of gateResult.results) {
192
- const icon = result.status === 'fresh' ? '✓' : result.status === 'stale' ? '✗' : '?';
193
- const age = result.daysStale !== null ? ` (${result.daysStale}d ago)` : ' (unverified)';
194
- lines.push(` ${icon} ${result.label}${age} — threshold: ${result.stalenessThresholdDays}d`);
195
- }
196
-
197
- if (!gateResult.ready) {
198
- lines.push('', 'Action required: verify stale/unverified sources before claiming release freshness.');
199
- }
200
-
201
- return lines.join('\n');
202
- }
203
-
204
- function getPropagationTargets(triggerKeyword) {
205
- const keyword = triggerKeyword.toLowerCase();
206
- return PROPAGATION_CHECKLIST.filter(item => item.trigger.toLowerCase().includes(keyword));
207
- }
208
-
209
- module.exports = {
210
- P0_SOURCES,
211
- PROPAGATION_CHECKLIST,
212
- checkReleaseGate,
213
- formatReleaseGate,
214
- getPropagationTargets,
215
- };
1
+ /**
2
+ * Windsurf Freshness Operationalization
3
+ *
4
+ * Release gates, recurring probes, propagation checklists,
5
+ * and staleness blocking for Windsurf surfaces.
6
+ *
7
+ * P0 sources from windsurf.com docs, propagation for rule format changes.
8
+ */
9
+
10
+ const { version } = require('../../package.json');
11
+
12
+ /**
13
+ * P0 sources that must be fresh before any Windsurf release claim.
14
+ */
15
+ const P0_SOURCES = [
16
+ {
17
+ key: 'windsurf-rules-docs',
18
+ label: 'Windsurf Rules & Memories Documentation',
19
+ url: 'https://docs.windsurf.com/windsurf/cascade/memories',
20
+ stalenessThresholdDays: 30,
21
+ verifiedAt: '2026-04-07',
22
+ },
23
+ {
24
+ key: 'windsurf-cascade-docs',
25
+ label: 'Cascade Agent Documentation',
26
+ url: 'https://docs.windsurf.com/windsurf/cascade',
27
+ stalenessThresholdDays: 30,
28
+ verifiedAt: '2026-04-07',
29
+ },
30
+ {
31
+ key: 'windsurf-mcp-docs',
32
+ label: 'Windsurf MCP Documentation',
33
+ url: 'https://docs.windsurf.com/plugins/cascade/mcp',
34
+ stalenessThresholdDays: 30,
35
+ verifiedAt: '2026-04-07',
36
+ },
37
+ {
38
+ key: 'windsurf-memories-docs',
39
+ label: 'Memories & Rules Documentation',
40
+ url: 'https://docs.windsurf.com/windsurf/cascade/memories',
41
+ stalenessThresholdDays: 30,
42
+ verifiedAt: '2026-04-07',
43
+ },
44
+ {
45
+ key: 'windsurf-workflows-docs',
46
+ label: 'Workflows Documentation',
47
+ url: 'https://docs.windsurf.com/windsurf/cascade/workflows',
48
+ stalenessThresholdDays: 30,
49
+ verifiedAt: '2026-04-07',
50
+ },
51
+ {
52
+ key: 'windsurf-steps-docs',
53
+ label: 'Steps Documentation (via Workflows)',
54
+ url: 'https://docs.windsurf.com/windsurf/cascade/workflows',
55
+ stalenessThresholdDays: 30,
56
+ verifiedAt: '2026-04-07',
57
+ },
58
+ {
59
+ key: 'windsurf-cascadeignore-docs',
60
+ label: 'Windsurf Ignore Documentation',
61
+ url: 'https://docs.windsurf.com/context-awareness/windsurf-ignore',
62
+ stalenessThresholdDays: 30,
63
+ verifiedAt: '2026-04-07',
64
+ },
65
+ {
66
+ key: 'windsurf-changelog',
67
+ label: 'Windsurf Changelog',
68
+ url: 'https://windsurf.com/changelog',
69
+ stalenessThresholdDays: 14,
70
+ verifiedAt: '2026-04-07',
71
+ },
72
+ {
73
+ key: 'windsurf-security',
74
+ label: 'Windsurf Security Admin Guide',
75
+ url: 'https://docs.windsurf.com/security/security-admin-guide',
76
+ stalenessThresholdDays: 30,
77
+ verifiedAt: '2026-04-07',
78
+ },
79
+ ];
80
+
81
+ /**
82
+ * Propagation checklist: when a Windsurf source changes, these must update.
83
+ */
84
+ const PROPAGATION_CHECKLIST = [
85
+ {
86
+ trigger: 'Rule format change (new frontmatter fields, activation mode change)',
87
+ targets: [
88
+ 'src/windsurf/config-parser.js — update VALID_WINDSURF_FIELDS, detectRuleType, parseSimpleYaml',
89
+ 'src/windsurf/techniques.js — update rule validation checks (WS-A01..WS-A09)',
90
+ 'src/windsurf/context.js — update windsurfRules() parsing and type detection',
91
+ 'src/windsurf/setup.js — update rule template generation',
92
+ ],
93
+ },
94
+ {
95
+ trigger: 'Cascade agent behavior change (multi-file, Steps, Skills)',
96
+ targets: [
97
+ 'src/windsurf/techniques.js — update Cascade agent checks (WS-D01..WS-D05)',
98
+ 'src/windsurf/governance.js — update permission profiles',
99
+ 'src/windsurf/deep-review.js — update trust class detection',
100
+ ],
101
+ },
102
+ {
103
+ trigger: 'Memories format or sync behavior change',
104
+ targets: [
105
+ 'src/windsurf/techniques.js — update memory checks (WS-H01..WS-H05)',
106
+ 'src/windsurf/context.js — update memoryContents() parsing',
107
+ 'src/windsurf/governance.js — update team-managed permission profile',
108
+ ],
109
+ },
110
+ {
111
+ trigger: 'MCP configuration format change in .windsurf/mcp.json',
112
+ targets: [
113
+ 'src/windsurf/mcp-packs.js — update pack JSON projections and merge logic',
114
+ 'src/windsurf/techniques.js — update MCP checks (WS-E01..WS-E05)',
115
+ 'src/windsurf/context.js — update mcpConfig() parsing',
116
+ 'src/windsurf/config-parser.js — update validateMcpEnvVars',
117
+ ],
118
+ },
119
+ {
120
+ trigger: 'MCP team whitelist format change',
121
+ targets: [
122
+ 'src/windsurf/techniques.js — update WS-B02, WS-E05 thresholds',
123
+ 'src/windsurf/governance.js — update mcp-team-whitelist caveat',
124
+ 'src/windsurf/mcp-packs.js — update recommendation logic',
125
+ ],
126
+ },
127
+ {
128
+ trigger: 'Workflow / slash command format change',
129
+ targets: [
130
+ 'src/windsurf/techniques.js — update workflow checks (WS-G01..WS-G05)',
131
+ 'src/windsurf/context.js — update workflowFiles() parsing',
132
+ 'src/windsurf/governance.js — update workflow-trigger hook',
133
+ ],
134
+ },
135
+ {
136
+ trigger: 'Cascadeignore format or behavior change',
137
+ targets: [
138
+ 'src/windsurf/techniques.js — update cascadeignore checks (WS-J01..WS-J02)',
139
+ 'src/windsurf/context.js — update cascadeignoreContent() parsing',
140
+ 'src/windsurf/patch.js — update patchCascadeignore',
141
+ ],
142
+ },
143
+ {
144
+ trigger: '10K char rule limit change',
145
+ targets: [
146
+ 'src/windsurf/techniques.js — update WS-A05, WS-L05',
147
+ 'src/windsurf/context.js — update overLimit calculation',
148
+ 'src/windsurf/governance.js — update rule-char-limit caveat',
149
+ ],
150
+ },
151
+ ];
152
+
153
+ /**
154
+ * Release gate: check if all P0 sources are within staleness threshold.
155
+ */
156
+ function checkReleaseGate(sourceVerifications = {}) {
157
+ const now = new Date();
158
+ const results = P0_SOURCES.map(source => {
159
+ const verifiedAt = sourceVerifications[source.key]
160
+ ? new Date(sourceVerifications[source.key])
161
+ : source.verifiedAt ? new Date(source.verifiedAt) : null;
162
+
163
+ if (!verifiedAt) {
164
+ return { ...source, status: 'unverified', daysStale: null };
165
+ }
166
+
167
+ const daysSince = Math.floor((now - verifiedAt) / (1000 * 60 * 60 * 24));
168
+ const isStale = daysSince > source.stalenessThresholdDays;
169
+
170
+ return { ...source, verifiedAt: verifiedAt.toISOString(), daysStale: daysSince, status: isStale ? 'stale' : 'fresh' };
171
+ });
172
+
173
+ return {
174
+ ready: results.every(r => r.status === 'fresh'),
175
+ stale: results.filter(r => r.status === 'stale' || r.status === 'unverified'),
176
+ fresh: results.filter(r => r.status === 'fresh'),
177
+ results,
178
+ };
179
+ }
180
+
181
+ function formatReleaseGate(gateResult) {
182
+ const lines = [
183
+ `Windsurf Freshness Gate (nerviq v${version})`,
184
+ '═══════════════════════════════════════',
185
+ '',
186
+ `Status: ${gateResult.ready ? 'READY' : 'BLOCKED'}`,
187
+ `Fresh: ${gateResult.fresh.length}/${gateResult.results.length}`,
188
+ '',
189
+ ];
190
+
191
+ for (const result of gateResult.results) {
192
+ const icon = result.status === 'fresh' ? '✓' : result.status === 'stale' ? '✗' : '?';
193
+ const age = result.daysStale !== null ? ` (${result.daysStale}d ago)` : ' (unverified)';
194
+ lines.push(` ${icon} ${result.label}${age} — threshold: ${result.stalenessThresholdDays}d`);
195
+ }
196
+
197
+ if (!gateResult.ready) {
198
+ lines.push('', 'Action required: verify stale/unverified sources before claiming release freshness.');
199
+ }
200
+
201
+ return lines.join('\n');
202
+ }
203
+
204
+ function getPropagationTargets(triggerKeyword) {
205
+ const keyword = triggerKeyword.toLowerCase();
206
+ return PROPAGATION_CHECKLIST.filter(item => item.trigger.toLowerCase().includes(keyword));
207
+ }
208
+
209
+ module.exports = {
210
+ P0_SOURCES,
211
+ PROPAGATION_CHECKLIST,
212
+ checkReleaseGate,
213
+ formatReleaseGate,
214
+ getPropagationTargets,
215
+ };
package/src/workspace.js CHANGED
@@ -166,6 +166,17 @@ function parseWorkspaceSelection(value) {
166
166
  return unique(String(value).split(',').map((item) => item.trim()).filter(Boolean));
167
167
  }
168
168
 
169
+ function summarizeAuditResult(result, scoreType, scope) {
170
+ return {
171
+ scope,
172
+ scoreType,
173
+ score: typeof result?.score === 'number' ? result.score : null,
174
+ passed: typeof result?.passed === 'number' ? result.passed : 0,
175
+ total: typeof result?.checkCount === 'number' ? result.checkCount : 0,
176
+ topAction: result?.topNextActions?.[0]?.name || null,
177
+ };
178
+ }
179
+
169
180
  async function auditWorkspaces(dir, workspaceGlobs, platform = 'claude') {
170
181
  const { audit } = require('./audit');
171
182
  const rootDir = path.resolve(dir);
@@ -175,6 +186,22 @@ async function auditWorkspaces(dir, workspaceGlobs, platform = 'claude') {
175
186
  ? expandWorkspacePatterns(rootDir, selectedPatterns)
176
187
  : detectWorkspaces(rootDir);
177
188
  const results = [];
189
+ let rootGovernance;
190
+
191
+ try {
192
+ const rootResult = await audit({ dir: rootDir, platform, silent: true });
193
+ rootGovernance = summarizeAuditResult(rootResult, 'root-live-audit', 'root-governance');
194
+ } catch (error) {
195
+ rootGovernance = {
196
+ scope: 'root-governance',
197
+ scoreType: 'root-live-audit',
198
+ score: null,
199
+ passed: 0,
200
+ total: 0,
201
+ topAction: null,
202
+ error: error.message,
203
+ };
204
+ }
178
205
 
179
206
  for (const workspacePath of workspacePaths) {
180
207
  const absPath = path.join(rootDir, workspacePath);
@@ -185,10 +212,7 @@ async function auditWorkspaces(dir, workspaceGlobs, platform = 'claude') {
185
212
  workspace: workspacePath,
186
213
  dir: absPath,
187
214
  platform,
188
- score: result.score,
189
- passed: result.passed,
190
- total: result.checkCount,
191
- topAction: result.topNextActions?.[0]?.name || null,
215
+ ...summarizeAuditResult(result, 'workspace-live-audit', 'workspace-package'),
192
216
  result,
193
217
  });
194
218
  } catch (error) {
@@ -197,6 +221,8 @@ async function auditWorkspaces(dir, workspaceGlobs, platform = 'claude') {
197
221
  workspace: workspacePath,
198
222
  dir: absPath,
199
223
  platform,
224
+ scope: 'workspace-package',
225
+ scoreType: 'workspace-live-audit',
200
226
  score: null,
201
227
  passed: 0,
202
228
  total: 0,
@@ -210,17 +236,36 @@ async function auditWorkspaces(dir, workspaceGlobs, platform = 'claude') {
210
236
  const averageScore = validScores.length > 0
211
237
  ? Math.round(validScores.reduce((sum, value) => sum + value, 0) / validScores.length)
212
238
  : 0;
239
+ const maxScore = validScores.length > 0 ? Math.max(...validScores) : 0;
240
+ const minScore = validScores.length > 0 ? Math.min(...validScores) : 0;
213
241
 
214
242
  return {
243
+ summaryType: 'monorepo-workspace-audit',
215
244
  rootDir,
216
245
  platform,
246
+ selectionMode: selectedPatterns.length > 0 ? 'explicit-patterns' : 'detected-workspaces',
217
247
  patterns: sourcePatterns,
248
+ rootGovernance,
249
+ workspaceAggregate: {
250
+ scope: 'workspace-aggregate',
251
+ scoreType: 'workspace-average-live-audit',
252
+ score: averageScore,
253
+ workspaceCount: workspacePaths.length,
254
+ maxScore,
255
+ minScore,
256
+ },
257
+ scoreSemantics: {
258
+ rootGovernance: 'Root repo live audit for shared instructions, hooks, permissions, and top-level governance files.',
259
+ workspaceAggregate: 'Average of the selected workspace live audit scores. This is a package coverage rollup, not the root repo score.',
260
+ workspaceEntries: 'Each workspace row is a package-level live audit. Package scores can differ from the root governance score for legitimate reasons.',
261
+ },
218
262
  workspaces: results,
219
263
  detectedWorkspaces: workspacePaths,
220
264
  workspaceCount: workspacePaths.length,
265
+ averageScoreType: 'workspace-average-live-audit',
221
266
  averageScore,
222
- maxScore: validScores.length > 0 ? Math.max(...validScores) : 0,
223
- minScore: validScores.length > 0 ? Math.min(...validScores) : 0,
267
+ maxScore,
268
+ minScore,
224
269
  };
225
270
  }
226
271