agent-nuvira 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2453
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +17 -3
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/app.js +26 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +101 -2
- package/dist/cli/chat.js.map +1 -1
- package/dist/config/auth.js +18 -0
- package/dist/config/jwt.js +24 -0
- package/dist/config/keys.js +14 -0
- package/dist/gateway/chat-store.d.ts +32 -5
- package/dist/gateway/chat-store.d.ts.map +1 -1
- package/dist/gateway/chat-store.js +52 -6
- package/dist/gateway/chat-store.js.map +1 -1
- package/dist/gateway/registry.d.ts.map +1 -1
- package/dist/gateway/registry.js +42 -5
- package/dist/gateway/registry.js.map +1 -1
- package/dist/inference/model-validator.d.ts.map +1 -1
- package/dist/inference/model-validator.js +11 -1
- package/dist/inference/model-validator.js.map +1 -1
- package/dist/inference/tool-call-utils.d.ts +31 -0
- package/dist/inference/tool-call-utils.d.ts.map +1 -1
- package/dist/inference/tool-call-utils.js +41 -0
- package/dist/inference/tool-call-utils.js.map +1 -1
- package/dist/learning/reasoning-trace.d.ts +5 -3
- package/dist/learning/reasoning-trace.d.ts.map +1 -1
- package/dist/learning/reasoning-trace.js +2 -2
- package/dist/learning/reasoning-trace.js.map +1 -1
- package/dist/middleware/auth.js +30 -0
- package/dist/nlu/intent.d.ts.map +1 -1
- package/dist/nlu/intent.js +20 -3
- package/dist/nlu/intent.js.map +1 -1
- package/dist/passport.js +34 -0
- package/dist/routes/auth.js +42 -0
- package/dist/routes/user.js +31 -0
- package/dist/server.js +17 -0
- package/dist/tools/pipeline-tool.d.ts.map +1 -1
- package/dist/tools/pipeline-tool.js +14 -0
- package/dist/tools/pipeline-tool.js.map +1 -1
- package/dist/tools/release-sync.d.ts +52 -16
- package/dist/tools/release-sync.d.ts.map +1 -1
- package/dist/tools/release-sync.js +143 -79
- package/dist/tools/release-sync.js.map +1 -1
- package/dist/web-dashboard/src/App.js +85 -0
- package/dist/web-dashboard/src/admin-auth.test.js +186 -0
- package/dist/web-dashboard/src/ansi.js +23 -0
- package/dist/web-dashboard/src/ansi.test.js +31 -0
- package/dist/web-dashboard/src/api-admin-auth.test.js +172 -0
- package/dist/web-dashboard/src/api-admin.test.js +65 -0
- package/dist/web-dashboard/src/api-hub.test.js +117 -0
- package/dist/web-dashboard/src/api.js +1421 -0
- package/dist/web-dashboard/src/api.test.js +51 -0
- package/dist/web-dashboard/src/artifacts.js +128 -0
- package/dist/web-dashboard/src/artifacts.test.js +139 -0
- package/dist/web-dashboard/src/components/AdminPanel.js +567 -0
- package/dist/web-dashboard/src/components/AdminPanel.test.js +288 -0
- package/dist/web-dashboard/src/components/AgentHub.js +1580 -0
- package/dist/web-dashboard/src/components/AgentHub.test.js +343 -0
- package/dist/web-dashboard/src/components/BedrockOnboarding.js +320 -0
- package/dist/web-dashboard/src/components/BenchmarkCharts.js +228 -0
- package/dist/web-dashboard/src/components/ChatPage.js +1586 -0
- package/dist/web-dashboard/src/components/ChatPage.test.js +899 -0
- package/dist/web-dashboard/src/components/ContactsPage.js +141 -0
- package/dist/web-dashboard/src/components/CostDashboard.js +105 -0
- package/dist/web-dashboard/src/components/DAGView.js +477 -0
- package/dist/web-dashboard/src/components/DAGView.test.js +147 -0
- package/dist/web-dashboard/src/components/EnvVarEditor.js +138 -0
- package/dist/web-dashboard/src/components/EvalsPage.js +73 -0
- package/dist/web-dashboard/src/components/EvalsPage.test.js +120 -0
- package/dist/web-dashboard/src/components/ExecutionHistory.js +201 -0
- package/dist/web-dashboard/src/components/GatewayPage.js +40 -0
- package/dist/web-dashboard/src/components/GatewayPage.test.js +74 -0
- package/dist/web-dashboard/src/components/HealthPanel.js +68 -0
- package/dist/web-dashboard/src/components/HistoryBrowser.js +34 -0
- package/dist/web-dashboard/src/components/Layout.js +50 -0
- package/dist/web-dashboard/src/components/Markdown.js +152 -0
- package/dist/web-dashboard/src/components/Markdown.test.js +126 -0
- package/dist/web-dashboard/src/components/MarkdownZeroDep.js +237 -0
- package/dist/web-dashboard/src/components/MemoryPanel.js +81 -0
- package/dist/web-dashboard/src/components/ModelTimeline.js +298 -0
- package/dist/web-dashboard/src/components/ModelsPanel.js +1484 -0
- package/dist/web-dashboard/src/components/ModelsPanel.test.js +460 -0
- package/dist/web-dashboard/src/components/Overview.js +123 -0
- package/dist/web-dashboard/src/components/PhaseTimeline.js +359 -0
- package/dist/web-dashboard/src/components/PhaseTimeline.test.js +234 -0
- package/dist/web-dashboard/src/components/PlatformConfigSection.js +384 -0
- package/dist/web-dashboard/src/components/PlatformConfigSection.test.js +106 -0
- package/dist/web-dashboard/src/components/PlatformsPage.js +250 -0
- package/dist/web-dashboard/src/components/QuotaPanel.js +159 -0
- package/dist/web-dashboard/src/components/QuotaPanel.test.js +85 -0
- package/dist/web-dashboard/src/components/RequestsPanel.js +229 -0
- package/dist/web-dashboard/src/components/RequestsPanel.test.js +103 -0
- package/dist/web-dashboard/src/components/RoutingInsightsPanel.js +938 -0
- package/dist/web-dashboard/src/components/RoutingInsightsPanel.test.js +339 -0
- package/dist/web-dashboard/src/components/RoutingWalkthrough.js +408 -0
- package/dist/web-dashboard/src/components/RoutingWalkthrough.test.js +209 -0
- package/dist/web-dashboard/src/components/TaskConsole.js +119 -0
- package/dist/web-dashboard/src/components/TaskConsole.test.js +123 -0
- package/dist/web-dashboard/src/components/TasksPage.js +256 -0
- package/dist/web-dashboard/src/components/TasksPage.test.js +103 -0
- package/dist/web-dashboard/src/components/TracePanel.js +306 -0
- package/dist/web-dashboard/src/components/WhatsAppPanel.js +195 -0
- package/dist/web-dashboard/src/components/WhatsAppPanel.test.js +122 -0
- package/dist/web-dashboard/src/jsonOrNull.js +37 -0
- package/dist/web-dashboard/src/main.js +15 -0
- package/dist/web-dashboard/src/mask.js +11 -0
- package/dist/web-dashboard/vite.config.js +23 -0
- package/dist/web-dashboard/vitest.config.js +15 -0
- package/package.json +5 -3
package/dist/nlu/intent.js
CHANGED
|
@@ -85,7 +85,11 @@ export function matchConfigureRule(text) {
|
|
|
85
85
|
* (test is not a writing artifact) still resolves to create.
|
|
86
86
|
*/
|
|
87
87
|
export function matchWriteRule(text) {
|
|
88
|
-
|
|
88
|
+
// Songs/hymns/bha_jans/shayari were missing (observed live: "Write a song in
|
|
89
|
+
// hindi … for my daughter" routed to the DEVELOPER pipeline). Keep the
|
|
90
|
+
// explicit list (fast, precise) but treat it as an allowlist WITH a
|
|
91
|
+
// fallback, not the only path.
|
|
92
|
+
const writingObject = /\b(?:essay|poem|poetry|song|lyrics|hymn|anthem|shayari|ghazal|jingle|story|short story|letter|article|blog(?: post)?|paragraph|composition|novel|dialogue|screenplay|speech|caption|advertisement|review|summary|note|message|email|homework|assignment)\b/i;
|
|
89
93
|
// Verb + article + writing object: "write an essay on elephants for class 4".
|
|
90
94
|
if (/^(?:please\s+)?(?:write|build|make|create|draft|compose|prepare)\s+(?:a|an|the|new|my|our)\s+/i.test(text) &&
|
|
91
95
|
writingObject.test(text)) {
|
|
@@ -111,8 +115,21 @@ export function matchCreateRule(text) {
|
|
|
111
115
|
// here (and in the object-noun branch below) — NOT in the verb-initial list
|
|
112
116
|
// — so the common developer phrasing "add auth to the app" routes to dev
|
|
113
117
|
// mode while "add 2 + 2" (no article, no project noun) never false-positives.
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
// GUARD (observed live: "Write a song in hindi … for my daughter" hit this
|
|
119
|
+
// branch and spun up the developer pipeline): when the OBJECT is explicitly
|
|
120
|
+
// creative (a person-centric/creative frame — "for my daughter", "about
|
|
121
|
+
// love", a language of expression), the ask is content, not code. The
|
|
122
|
+
// pipeline must never run for it — matchWriteRule's artifact list can never
|
|
123
|
+
// cover every creative noun (song, lullaby, rap, …).
|
|
124
|
+
const articleMatch = /^(?:please\s+)?(?:build|write|make|add)\s+(?:a|an|the|new)\s+/i.exec(text);
|
|
125
|
+
if (articleMatch) {
|
|
126
|
+
const creativeFrame = /\bfor (?:my|his|her|our)\b/i.test(text) ||
|
|
127
|
+
/\babout (?:love|life|friendship|family|her|him|them|us|my|his)\b/i.test(text) ||
|
|
128
|
+
/\bin (?:hindi|english|spanish|french|tamil|telugu|bengali|marathi|urdu|punjabi|gujarati|kannada|malayalam)\b/i.test(text);
|
|
129
|
+
if (!creativeFrame) {
|
|
130
|
+
return { intent: 'create', confidence: 0.85, modeHint: 'dev' };
|
|
131
|
+
}
|
|
132
|
+
return { intent: 'write', confidence: 0.8, modeHint: 'chat' };
|
|
116
133
|
}
|
|
117
134
|
// Verb + project-object noun anywhere: "I want to create a new module".
|
|
118
135
|
const objectNoun = /\b(?:file|program|script|app(?:lication)?|function|class|module|component|page|route|api|endpoint|service|cli|tool|package|library|project|plugin|addon|extension|website|server|client|database|schema|feature|daemon|worker)\b/i;
|
package/dist/nlu/intent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.js","sourceRoot":"","sources":["../../src/nlu/intent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAiCnF,iFAAiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,+EAA+E;AAC/E,+EAA+E;AAC/E,uEAAuE;AAEvE,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IACE,yFAAyF,CAAC,IAAI,CAC5F,IAAI,CACL;QACD,mEAAmE,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9E,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH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U,cAAc,CAAC,IAAY,EAAE,gBAAsB,IAAI,IAAI,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAE1E,OAAO,CACL,gBAAgB,CAAC,OAAO,CAAC;QACzB,iBAAiB,CAAC,OAAO,EAAE,aAAa,CAAC;QACzC,YAAY,CAAC,OAAO,CAAC;QACrB,kBAAkB,CAAC,OAAO,CAAC;QAC3B,cAAc,CAAC,OAAO,CAAC;QACvB,eAAe,CAAC,OAAO,CAAC;QACxB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CACrD,CAAC;AACJ,CAAC"}
|
package/dist/passport.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const passport_1 = __importDefault(require("passport"));
|
|
7
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
8
|
+
const userService_1 = require("./services/userService"); // Adjust the import path as needed
|
|
9
|
+
// JWT options – these should be configured via environment variables.
|
|
10
|
+
const jwtOptions = {
|
|
11
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
12
|
+
secretOrKey: process.env.JWT_SECRET || 'default_secret', // Replace with a strong secret in production
|
|
13
|
+
passReqToCallback: true,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Verify callback for the JWT strategy.
|
|
17
|
+
* It receives the JWT payload and should return the corresponding user object.
|
|
18
|
+
*/
|
|
19
|
+
const verifyJwt = async (req, payload, done) => {
|
|
20
|
+
try {
|
|
21
|
+
// Assuming the payload contains a `sub` (subject) field with the user ID.
|
|
22
|
+
const user = await (0, userService_1.getUserById)(payload.sub);
|
|
23
|
+
if (!user) {
|
|
24
|
+
return done(null, false);
|
|
25
|
+
}
|
|
26
|
+
return done(null, user);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return done(error, false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Register the JWT strategy with Passport.
|
|
33
|
+
passport_1.default.use(new passport_jwt_1.Strategy(jwtOptions, verifyJwt));
|
|
34
|
+
exports.default = passport_1.default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication Routes
|
|
4
|
+
*
|
|
5
|
+
* Exposes endpoints for user login and token issuance. This
|
|
6
|
+
* example uses a hard‑coded user for demonstration purposes.
|
|
7
|
+
*
|
|
8
|
+
* @module routes/auth
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const express_1 = require("express");
|
|
15
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
16
|
+
const jwt_1 = require("../config/jwt");
|
|
17
|
+
const router = (0, express_1.Router)();
|
|
18
|
+
/**
|
|
19
|
+
* POST /auth/login
|
|
20
|
+
*
|
|
21
|
+
* Accepts a JSON body with `username` and `password`. In a real
|
|
22
|
+
* application this would validate against a database. Here we
|
|
23
|
+
* simply issue a token for a single demo user.
|
|
24
|
+
*/
|
|
25
|
+
router.post('/login', (req, res) => {
|
|
26
|
+
const { username, password } = req.body;
|
|
27
|
+
// Basic validation
|
|
28
|
+
if (typeof username !== 'string' || typeof password !== 'string') {
|
|
29
|
+
return res.status(400).json({ error: 'Username and password required' });
|
|
30
|
+
}
|
|
31
|
+
// Demo credentials check
|
|
32
|
+
if (username !== 'admin' || password !== 'password') {
|
|
33
|
+
return res.status(401).json({ error: 'Invalid credentials' });
|
|
34
|
+
}
|
|
35
|
+
const payload = { sub: username, role: 'admin' };
|
|
36
|
+
const token = jsonwebtoken_1.default.sign(payload, jwt_1.jwtConfig.secret, {
|
|
37
|
+
expiresIn: jwt_1.jwtConfig.expiresIn,
|
|
38
|
+
algorithm: jwt_1.jwtConfig.algorithm,
|
|
39
|
+
});
|
|
40
|
+
res.json({ token });
|
|
41
|
+
});
|
|
42
|
+
exports.default = router;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const express_1 = require("express");
|
|
4
|
+
const auth_1 = require("../middleware/auth");
|
|
5
|
+
const router = (0, express_1.Router)();
|
|
6
|
+
/**
|
|
7
|
+
* GET /api/user/profile
|
|
8
|
+
* Returns the profile of the currently authenticated user.
|
|
9
|
+
* This route is protected by the `ensureAuthenticated` middleware.
|
|
10
|
+
*/
|
|
11
|
+
router.get('/profile', auth_1.ensureAuthenticated, async (req, res, _next) => {
|
|
12
|
+
// Assuming the user information is attached to req.user by Passport
|
|
13
|
+
const user = req.user;
|
|
14
|
+
if (!user) {
|
|
15
|
+
return res.status(404).json({ error: 'User not found' });
|
|
16
|
+
}
|
|
17
|
+
res.json({
|
|
18
|
+
id: user.id,
|
|
19
|
+
username: user.username,
|
|
20
|
+
email: user.email,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* GET /api/user/settings
|
|
25
|
+
* Example of another protected endpoint.
|
|
26
|
+
*/
|
|
27
|
+
router.get('/settings', auth_1.ensureAuthenticated, async (_req, res, _next) => {
|
|
28
|
+
// Placeholder response – replace with real settings logic
|
|
29
|
+
res.json({ theme: 'dark', notificationsEnabled: true });
|
|
30
|
+
});
|
|
31
|
+
exports.default = router;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Server Bootstrap
|
|
4
|
+
*
|
|
5
|
+
* Starts the Express server on the configured port.
|
|
6
|
+
*
|
|
7
|
+
* @module server
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const app_1 = __importDefault(require("./app"));
|
|
14
|
+
const PORT = process.env.PORT ?? 3000;
|
|
15
|
+
app_1.default.listen(PORT, () => {
|
|
16
|
+
console.log(`Server running on port ${PORT}`);
|
|
17
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-tool.d.ts","sourceRoot":"","sources":["../../src/tools/pipeline-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAOnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,EAAE,CAA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EAAE,MAAM,CAAC;CACjB;AAED,yCAAyC;AACzC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gEAAgE;IAChE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,GAAG,EAClB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAYxE;AA0BD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -58,6 +58,19 @@ export async function runPipelineTool(goal, configManager, opts) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
// When the caller did NOT pin a provider/model, hand the decision to the
|
|
62
|
+
// AutoModelRouter — the product's core routing USP. Without this, an
|
|
63
|
+
// unpinned pipeline ran on the single configured default provider, so a
|
|
64
|
+
// rate-limited provider (Groq's free-tier TPM is shared across ALL its
|
|
65
|
+
// models — switching models within Groq can never escape it) became a
|
|
66
|
+
// 429 death spiral instead of failing over to the configured alternatives
|
|
67
|
+
// (observed live: trace-1788970301803-8302u5 — 14 steps / 112s of 429s on
|
|
68
|
+
// gpt-oss-120b/gpt-oss-20b while Gemini + OpenRouter sat unused).
|
|
69
|
+
// Auto-routing scores ALL configured providers per task (bandit + ML +
|
|
70
|
+
// model-first + quota-parking), sinks away from session-failed providers,
|
|
71
|
+
// and records real routing snapshots in the reasoning trace. An explicit
|
|
72
|
+
// provider/model still wins (matches the orchestrator's own rule).
|
|
73
|
+
const autoRoute = !provider && !model;
|
|
61
74
|
// E3a + Session 20: intent transparency + D1 recall parity — parse ONCE,
|
|
62
75
|
// resolve the REQUEST CONTRACT (understanding-first), seed the 🧠 card +
|
|
63
76
|
// router task-intent hint. The contract's acceptance criteria are passed to
|
|
@@ -101,6 +114,7 @@ export async function runPipelineTool(goal, configManager, opts) {
|
|
|
101
114
|
const result = await orchestrator.execute(goal, {
|
|
102
115
|
provider,
|
|
103
116
|
model,
|
|
117
|
+
autoRouteModels: autoRoute,
|
|
104
118
|
verbose: false,
|
|
105
119
|
...(liveBoard ? { spinner: liveBoard } : {}),
|
|
106
120
|
taskIntentHint: opts.taskIntentHint ?? dispatch.taskIntentHint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-tool.js","sourceRoot":"","sources":["../../src/tools/pipeline-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,YAAY,EAA4B,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,oBA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;AACf,CAAC"}
|
|
@@ -10,11 +10,21 @@
|
|
|
10
10
|
* `vX.Y.Z · N tests` badge, `docs/COMMANDS.md` carries a `nuvira vX.Y.x`
|
|
11
11
|
* header), and NO post-publish diff existed.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* P5a.2 — AUTO-FIX: detection alone left the fix to a human (or a lucky
|
|
14
|
+
* agent turn). Since every marker is a NARROW, version-bearing regex, the
|
|
15
|
+
* fix is deterministic: rewrite the stale version token, keep everything
|
|
16
|
+
* else byte-identical, then RE-DETECT on the result (a fix that does not
|
|
17
|
+
* verify is reported as failed, never silently claimed). `runReleaseSync`
|
|
18
|
+
* now fixes by default; `reportOnly` opts out. File writes are surgical
|
|
19
|
+
* (target file, matched span only) and failures are best-effort — a sync
|
|
20
|
+
* failure must never mark the publish failed.
|
|
21
|
+
*
|
|
22
|
+
* Deterministic and pure at the core (`findReleaseDrift` / `fixReleaseDrift`
|
|
23
|
+
* — fixture-testable): each release-marker pattern is matched and compared
|
|
24
|
+
* against the CURRENT version; a marker that still names an older version is
|
|
25
|
+
* a gap. Historical "Since v1.60.x" notes are deliberately NOT markers —
|
|
26
|
+
* only the three release-marker patterns below are checked, so nothing
|
|
27
|
+
* false-positives.
|
|
18
28
|
*
|
|
19
29
|
* Best-effort by construction: a missing/unreadable sync target, or an
|
|
20
30
|
* emission failure, never throws — a sync check failure must never mark the
|
|
@@ -36,23 +46,49 @@ export interface ReleaseDriftGap {
|
|
|
36
46
|
}
|
|
37
47
|
/** The sync targets scanned after a publish (relative to the workspace root). */
|
|
38
48
|
export declare const SYNC_TARGETS: string[];
|
|
49
|
+
/** One deterministic marker edit applied to a target file. */
|
|
50
|
+
export interface ReleaseSyncFix {
|
|
51
|
+
file: string;
|
|
52
|
+
line: number;
|
|
53
|
+
kind: ReleaseDriftGap['kind'];
|
|
54
|
+
found: string;
|
|
55
|
+
expected: string;
|
|
56
|
+
/** True when the re-detection pass confirmed the marker is now current. */
|
|
57
|
+
verified: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** The result of one auto-fix pass over the sync targets. */
|
|
60
|
+
export interface ReleaseSyncResult {
|
|
61
|
+
version: string;
|
|
62
|
+
/** Gaps that were detected (before any fix ran). */
|
|
63
|
+
gaps: ReleaseDriftGap[];
|
|
64
|
+
/** Fixes that were applied (only when auto-fix ran). */
|
|
65
|
+
fixes: ReleaseSyncFix[];
|
|
66
|
+
/** True when every detected gap was fixed AND re-detection is clean. */
|
|
67
|
+
synced: boolean;
|
|
68
|
+
/** Sync targets that could not be read or written (best-effort notes). */
|
|
69
|
+
errors: string[];
|
|
70
|
+
}
|
|
39
71
|
/**
|
|
40
72
|
* Pure drift detector — the testable core. Scans one file's text for the
|
|
41
73
|
* release-marker patterns and returns every marker whose version does NOT
|
|
42
74
|
* match the current (published) version. Never throws.
|
|
43
|
-
*
|
|
44
|
-
* Markers (deliberately narrow — historical notes are not markers):
|
|
45
|
-
* 1. `Current release <strong>vX.Y.Z</strong>` → exact version
|
|
46
|
-
* 2. `vX.Y.Z · N tests` (the arch-tier badge) → exact version
|
|
47
|
-
* 3. `nuvira vX.Y.x` (COMMANDS.md header) → major.minor only
|
|
48
75
|
*/
|
|
49
76
|
export declare function findReleaseDrift(text: string, file: string, currentVersion: string): ReleaseDriftGap[];
|
|
50
77
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
78
|
+
* P5a.2 — pure marker patcher. Rewrites ONLY the stale version tokens of the
|
|
79
|
+
* release markers in `text` to `currentVersion`; every other byte is kept.
|
|
80
|
+
* Deterministic: same input + version → same output. Companion to
|
|
81
|
+
* `findReleaseDrift` (shared marker table), so anything detection would flag,
|
|
82
|
+
* the patcher fixes — and vice versa.
|
|
83
|
+
*/
|
|
84
|
+
export declare function fixReleaseDrift(text: string, currentVersion: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* P5a.2 — run the post-publish sync pass with AUTO-FIX. Detects drift,
|
|
87
|
+
* patches every stale marker, re-reads and RE-DETECTS to verify, and emits a
|
|
88
|
+
* structured `release:sync` event. `reportOnly: true` restores the old
|
|
89
|
+
* detect-only behavior. Returns a model-feedable summary — never throws.
|
|
56
90
|
*/
|
|
57
|
-
export declare function runReleaseSync(currentVersion: string, ctx: ToolContext
|
|
91
|
+
export declare function runReleaseSync(currentVersion: string, ctx: ToolContext, opts?: {
|
|
92
|
+
reportOnly?: boolean;
|
|
93
|
+
}): string;
|
|
58
94
|
//# sourceMappingURL=release-sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-sync.d.ts","sourceRoot":"","sources":["../../src/tools/release-sync.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"release-sync.d.ts","sourceRoot":"","sources":["../../src/tools/release-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;CACrE;AAED,iFAAiF;AACjF,eAAO,MAAM,YAAY,UAA6C,CAAC;AAEvE,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,wDAAwD;IACxD,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AA0CD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,eAAe,EAAE,CA4BtG;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAa5E;AAuBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,WAAW,EAChB,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9B,MAAM,CAsER"}
|
|
@@ -10,127 +10,191 @@
|
|
|
10
10
|
* `vX.Y.Z · N tests` badge, `docs/COMMANDS.md` carries a `nuvira vX.Y.x`
|
|
11
11
|
* header), and NO post-publish diff existed.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* P5a.2 — AUTO-FIX: detection alone left the fix to a human (or a lucky
|
|
14
|
+
* agent turn). Since every marker is a NARROW, version-bearing regex, the
|
|
15
|
+
* fix is deterministic: rewrite the stale version token, keep everything
|
|
16
|
+
* else byte-identical, then RE-DETECT on the result (a fix that does not
|
|
17
|
+
* verify is reported as failed, never silently claimed). `runReleaseSync`
|
|
18
|
+
* now fixes by default; `reportOnly` opts out. File writes are surgical
|
|
19
|
+
* (target file, matched span only) and failures are best-effort — a sync
|
|
20
|
+
* failure must never mark the publish failed.
|
|
21
|
+
*
|
|
22
|
+
* Deterministic and pure at the core (`findReleaseDrift` / `fixReleaseDrift`
|
|
23
|
+
* — fixture-testable): each release-marker pattern is matched and compared
|
|
24
|
+
* against the CURRENT version; a marker that still names an older version is
|
|
25
|
+
* a gap. Historical "Since v1.60.x" notes are deliberately NOT markers —
|
|
26
|
+
* only the three release-marker patterns below are checked, so nothing
|
|
27
|
+
* false-positives.
|
|
18
28
|
*
|
|
19
29
|
* Best-effort by construction: a missing/unreadable sync target, or an
|
|
20
30
|
* emission failure, never throws — a sync check failure must never mark the
|
|
21
31
|
* publish failed (the brief's hard rule).
|
|
22
32
|
*/
|
|
23
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
33
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
24
34
|
import { join } from 'node:path';
|
|
25
35
|
/** The sync targets scanned after a publish (relative to the workspace root). */
|
|
26
36
|
export const SYNC_TARGETS = ['website/index.html', 'docs/COMMANDS.md'];
|
|
37
|
+
const RELEASE_MARKERS = [
|
|
38
|
+
{
|
|
39
|
+
kind: 'current-release',
|
|
40
|
+
// Marker 1 — the website's "Current release" callout.
|
|
41
|
+
pattern: /Current release <strong>v(\d+\.\d+\.\d+)<\/strong>/g,
|
|
42
|
+
render: (_full, stale, fixed) => _full.replace(`v${stale}`, `v${fixed}`),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
kind: 'test-count-badge',
|
|
46
|
+
// Marker 2 — the arch-tier "vX.Y.Z · N tests" badge (N is comma-grouped).
|
|
47
|
+
pattern: /v(\d+\.\d+\.\d+) · [\d,]+ tests/g,
|
|
48
|
+
render: (_full, stale, fixed) => _full.replace(`v${stale}`, `v${fixed}`),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: 'cli-version-header',
|
|
52
|
+
// Marker 3 — the docs "`buff` vX.Y.x" / "`nuvira` vX.Y.x" CLI header
|
|
53
|
+
// (major.minor only). COMMANDS.md has used both binary names.
|
|
54
|
+
pattern: /`?(?:buff|nuvira)`? v(\d+\.\d+)\.x/g,
|
|
55
|
+
render: (_full, stale, fixed) => _full.replace(`v${stale}.x`, `v${fixed}.x`),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
/** 1-based line number of a character offset. */
|
|
59
|
+
function lineNumberAt(text, index) {
|
|
60
|
+
let line = 1;
|
|
61
|
+
for (let i = 0; i < index && i < text.length; i++) {
|
|
62
|
+
if (text[i] === '\n')
|
|
63
|
+
line++;
|
|
64
|
+
}
|
|
65
|
+
return line;
|
|
66
|
+
}
|
|
27
67
|
/**
|
|
28
68
|
* Pure drift detector — the testable core. Scans one file's text for the
|
|
29
69
|
* release-marker patterns and returns every marker whose version does NOT
|
|
30
70
|
* match the current (published) version. Never throws.
|
|
31
|
-
*
|
|
32
|
-
* Markers (deliberately narrow — historical notes are not markers):
|
|
33
|
-
* 1. `Current release <strong>vX.Y.Z</strong>` → exact version
|
|
34
|
-
* 2. `vX.Y.Z · N tests` (the arch-tier badge) → exact version
|
|
35
|
-
* 3. `nuvira vX.Y.x` (COMMANDS.md header) → major.minor only
|
|
36
71
|
*/
|
|
37
72
|
export function findReleaseDrift(text, file, currentVersion) {
|
|
38
73
|
const gaps = [];
|
|
39
74
|
const clean = currentVersion.trim().replace(/^v/, '');
|
|
40
75
|
const expectedExact = `v${clean}`;
|
|
41
76
|
const expectedMajorMinor = clean.split('.').slice(0, 2).join('.');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const badgeRe = /v(\d+\.\d+\.\d+) · [\d,]+ tests/g;
|
|
60
|
-
while ((m = badgeRe.exec(text)) !== null) {
|
|
61
|
-
const found = m[1];
|
|
62
|
-
if (found !== clean) {
|
|
63
|
-
gaps.push({
|
|
64
|
-
file,
|
|
65
|
-
line: lineNumberAt(text, m.index),
|
|
66
|
-
found: `v${found}`,
|
|
67
|
-
expected: expectedExact,
|
|
68
|
-
kind: 'test-count-badge',
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Marker 3 — the docs "`buff` vX.Y.x" / "`nuvira` vX.Y.x" CLI header
|
|
73
|
-
// (major.minor only). COMMANDS.md has used both binary names
|
|
74
|
-
// ("`nuvira` v1.74.x" observed live); tolerate backticked or bare.
|
|
75
|
-
const cliRe = /`?(buff|nuvira)`? v(\d+\.\d+)\.x/g;
|
|
76
|
-
while ((m = cliRe.exec(text)) !== null) {
|
|
77
|
-
const found = m[2];
|
|
78
|
-
if (found !== expectedMajorMinor) {
|
|
79
|
-
gaps.push({
|
|
80
|
-
file,
|
|
81
|
-
line: lineNumberAt(text, m.index),
|
|
82
|
-
found: `v${found}.x`,
|
|
83
|
-
expected: `v${expectedMajorMinor}.x`,
|
|
84
|
-
kind: 'cli-version-header',
|
|
85
|
-
});
|
|
77
|
+
for (const marker of RELEASE_MARKERS) {
|
|
78
|
+
marker.pattern.lastIndex = 0;
|
|
79
|
+
let m;
|
|
80
|
+
while ((m = marker.pattern.exec(text)) !== null) {
|
|
81
|
+
const found = m[1];
|
|
82
|
+
const stale = marker.kind === 'cli-version-header'
|
|
83
|
+
? found !== expectedMajorMinor
|
|
84
|
+
: found !== clean;
|
|
85
|
+
if (stale) {
|
|
86
|
+
gaps.push({
|
|
87
|
+
file,
|
|
88
|
+
line: lineNumberAt(text, m.index),
|
|
89
|
+
found: marker.kind === 'cli-version-header' ? `v${found}.x` : `v${found}`,
|
|
90
|
+
expected: marker.kind === 'cli-version-header' ? `v${expectedMajorMinor}.x` : expectedExact,
|
|
91
|
+
kind: marker.kind,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
return gaps;
|
|
89
97
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
/**
|
|
99
|
+
* P5a.2 — pure marker patcher. Rewrites ONLY the stale version tokens of the
|
|
100
|
+
* release markers in `text` to `currentVersion`; every other byte is kept.
|
|
101
|
+
* Deterministic: same input + version → same output. Companion to
|
|
102
|
+
* `findReleaseDrift` (shared marker table), so anything detection would flag,
|
|
103
|
+
* the patcher fixes — and vice versa.
|
|
104
|
+
*/
|
|
105
|
+
export function fixReleaseDrift(text, currentVersion) {
|
|
106
|
+
const clean = currentVersion.trim().replace(/^v/, '');
|
|
107
|
+
const expectedMajorMinor = clean.split('.').slice(0, 2).join('.');
|
|
108
|
+
let out = text;
|
|
109
|
+
for (const marker of RELEASE_MARKERS) {
|
|
110
|
+
marker.pattern.lastIndex = 0;
|
|
111
|
+
out = out.replace(marker.pattern, (full, stale) => {
|
|
112
|
+
const fixed = marker.kind === 'cli-version-header' ? expectedMajorMinor : clean;
|
|
113
|
+
return stale === fixed ? full : marker.render(full, stale, fixed);
|
|
114
|
+
});
|
|
96
115
|
}
|
|
97
|
-
return
|
|
116
|
+
return out;
|
|
98
117
|
}
|
|
99
118
|
/** Read a sync target's text (empty string when missing/unreadable). */
|
|
100
119
|
function readTarget(root, target) {
|
|
101
120
|
try {
|
|
102
121
|
const p = join(root, target);
|
|
103
|
-
|
|
122
|
+
if (!existsSync(p))
|
|
123
|
+
return { text: '', ok: false };
|
|
124
|
+
return { text: readFileSync(p, 'utf-8'), ok: true };
|
|
104
125
|
}
|
|
105
126
|
catch {
|
|
106
|
-
return '';
|
|
127
|
+
return { text: '', ok: false };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Write a sync target (false on any failure — reported, never thrown). */
|
|
131
|
+
function writeTarget(root, target, text) {
|
|
132
|
+
try {
|
|
133
|
+
writeFileSync(join(root, target), text, 'utf-8');
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
107
138
|
}
|
|
108
139
|
}
|
|
109
140
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* structured `release:sync` event
|
|
113
|
-
*
|
|
114
|
-
* never throws.
|
|
141
|
+
* P5a.2 — run the post-publish sync pass with AUTO-FIX. Detects drift,
|
|
142
|
+
* patches every stale marker, re-reads and RE-DETECTS to verify, and emits a
|
|
143
|
+
* structured `release:sync` event. `reportOnly: true` restores the old
|
|
144
|
+
* detect-only behavior. Returns a model-feedable summary — never throws.
|
|
115
145
|
*/
|
|
116
|
-
export function runReleaseSync(currentVersion, ctx) {
|
|
146
|
+
export function runReleaseSync(currentVersion, ctx, opts) {
|
|
117
147
|
const root = ctx.cwd || process.cwd();
|
|
118
148
|
const clean = currentVersion.trim().replace(/^v/, '');
|
|
149
|
+
const reportOnly = opts?.reportOnly === true;
|
|
119
150
|
const gaps = [];
|
|
151
|
+
const fixes = [];
|
|
152
|
+
const errors = [];
|
|
120
153
|
for (const target of SYNC_TARGETS) {
|
|
121
|
-
const
|
|
122
|
-
if (!text)
|
|
154
|
+
const read = readTarget(root, target);
|
|
155
|
+
if (!read.ok || !read.text)
|
|
123
156
|
continue; // a missing target is not a gap — best-effort
|
|
124
|
-
|
|
157
|
+
const found = findReleaseDrift(read.text, target, clean);
|
|
158
|
+
gaps.push(...found);
|
|
159
|
+
if (found.length === 0 || reportOnly)
|
|
160
|
+
continue;
|
|
161
|
+
const fixedText = fixReleaseDrift(read.text, clean);
|
|
162
|
+
if (!writeTarget(root, target, fixedText)) {
|
|
163
|
+
errors.push(`${target}: write failed (read-only checkout?) — fix manually or commit the version bump first.`);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// Verify: re-read the file we just wrote and re-detect. A fix that does
|
|
167
|
+
// not verify is reported as failed — never silently claimed as done.
|
|
168
|
+
const verify = readTarget(root, target);
|
|
169
|
+
const remaining = verify.ok ? findReleaseDrift(verify.text, target, clean) : found;
|
|
170
|
+
for (const gap of found) {
|
|
171
|
+
const stillThere = remaining.some((r) => r.kind === gap.kind && r.line === gap.line);
|
|
172
|
+
fixes.push({ file: gap.file, line: gap.line, kind: gap.kind, found: gap.found, expected: gap.expected, verified: !stillThere });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const fixedCount = fixes.filter((f) => f.verified).length;
|
|
176
|
+
const failedCount = fixes.filter((f) => !f.verified).length;
|
|
177
|
+
const synced = gaps.length === 0 || (reportOnly === false && failedCount === 0 && errors.length === 0);
|
|
178
|
+
try {
|
|
179
|
+
ctx.emit?.('release:sync', { version: clean, gaps, fixes, synced, reportOnly, errors });
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
/* best-effort — the text summary below still ships */
|
|
125
183
|
}
|
|
126
184
|
if (gaps.length === 0) {
|
|
127
|
-
ctx.emit?.('release:sync', { version: clean, gaps: [], synced: true });
|
|
128
185
|
return `✅ Release-sync: website/docs already at v${clean} — no version drift.`;
|
|
129
186
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
187
|
+
if (reportOnly) {
|
|
188
|
+
const lines = gaps.map((g) => ` • ${g.file}:${g.line} — ${g.kind} shows ${g.found}, should be ${g.expected}`);
|
|
189
|
+
return (`⚠️ Release-sync: ${gaps.length} stale release marker(s) vs v${clean}:\n` +
|
|
190
|
+
lines.join('\n') +
|
|
191
|
+
`\nOffer to fix them (ask_user → edit_file) so the website/docs stay at the release level.`);
|
|
192
|
+
}
|
|
193
|
+
const fixLines = fixes.map((f) => ` • ${f.file}:${f.line} — ${f.kind} ${f.found} → ${f.expected}${f.verified ? ' ✅' : ' ❌ verify failed'}`);
|
|
194
|
+
const errorLines = errors.length > 0 ? `\n⚠️ ${errors.join('\n⚠️ ')}` : '';
|
|
195
|
+
const status = failedCount === 0 && errors.length === 0
|
|
196
|
+
? `✅ Release-sync auto-fixed ${fixedCount} stale marker(s) for v${clean} — verified by re-scan.`
|
|
197
|
+
: `⚠️ Release-sync: ${fixedCount} fixed, ${failedCount} failed for v${clean}:`;
|
|
198
|
+
return `${status}\n${fixLines.join('\n')}${errorLines}`;
|
|
135
199
|
}
|
|
136
200
|
//# sourceMappingURL=release-sync.js.map
|