@ahmednawaz/crank 0.1.7 → 0.1.8
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/.env.example +2 -1
- package/AGENTS.md +3 -2
- package/README.md +16 -14
- package/bookmarklet/crank-bookmarklet.js +3 -3
- package/bookmarklet/crank-ui-helpers.js +5 -5
- package/bookmarklet/crank-ui.css +1991 -0
- package/bookmarklet/text-source.js +1 -1
- package/companion/agent-queue.js +1 -1
- package/companion/asset-bridge.js +28 -0
- package/companion/package.json +3 -0
- package/companion/persist-apply.js +1 -1
- package/companion/server.js +12 -10
- package/companion/text-dispatch.js +3 -5
- package/companion/text-writer.js +580 -0
- package/mcp-server/tools.js +1 -1
- package/package.json +4 -1
- package/companion/vizpatch-bridge.js +0 -49
package/companion/agent-queue.js
CHANGED
|
@@ -359,7 +359,7 @@ function getFormattedChanges(opts = {}) {
|
|
|
359
359
|
'3. Prefer hardcoded literals; do not invent i18n keys for dynamic/bound strings.'
|
|
360
360
|
);
|
|
361
361
|
lines.push(
|
|
362
|
-
'4. Optionally call `apply_copy_variant` with persist for DOM +
|
|
362
|
+
'4. Optionally call `apply_copy_variant` with persist for DOM + Crank text-writer.'
|
|
363
363
|
);
|
|
364
364
|
lines.push(
|
|
365
365
|
'5. Always call `crank_clear_changes` (or `ack_pending_agent_prompt`) when done.'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve packaged Crank UI assets (CSS, helpers) under this install.
|
|
5
|
+
*/
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
function resolveCrankAssetRoot() {
|
|
12
|
+
if (process.env.CRANK_ASSET_ROOT) {
|
|
13
|
+
return path.resolve(process.env.CRANK_ASSET_ROOT);
|
|
14
|
+
}
|
|
15
|
+
return PACKAGE_ROOT;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function crankAsset(...parts) {
|
|
19
|
+
const root = resolveCrankAssetRoot();
|
|
20
|
+
const full = path.join(root, ...parts);
|
|
21
|
+
return fs.existsSync(full) ? full : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
resolveCrankAssetRoot,
|
|
26
|
+
crankAsset,
|
|
27
|
+
PACKAGE_ROOT
|
|
28
|
+
};
|
package/companion/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Persist an applied variant to source via
|
|
4
|
+
* Persist an applied variant to source via Crank text-writer (SAVE_TEXT_CHANGE).
|
|
5
5
|
* Skips locked/dynamic nodes with an explicit reason — never silent.
|
|
6
6
|
*/
|
|
7
7
|
|
package/companion/server.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - Glean agent client (stubbed)
|
|
7
7
|
* - MCP server (HTTP API used by @crank/mcp-server)
|
|
8
8
|
*
|
|
9
|
-
* Pattern adapted from
|
|
9
|
+
* Pattern adapted from a companion Express + ws bridge on a fixed port,
|
|
10
10
|
* stripped of CSS/source-map machinery and focused on copy selection + variants.
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ const WebSocket = require('ws');
|
|
|
19
19
|
|
|
20
20
|
const store = require('./selection-store');
|
|
21
21
|
const { proposeCopyVariants } = require('./glean-client');
|
|
22
|
-
const {
|
|
22
|
+
const { crankAsset } = require('./asset-bridge');
|
|
23
23
|
const { saveTextChange, writeTextChangeAvailable } = require('./text-dispatch');
|
|
24
24
|
const { persistAppliedVariant } = require('./persist-apply');
|
|
25
25
|
const agentQueue = require('./agent-queue');
|
|
@@ -201,7 +201,6 @@ app.get('/health', (_req, res) => {
|
|
|
201
201
|
...getAuthStatus(),
|
|
202
202
|
activeSessionId: store.getActiveSession()?.id || null,
|
|
203
203
|
gleanStub: String(process.env.GLEAN_STUB || 'true').toLowerCase() !== 'false',
|
|
204
|
-
vizpatchRoot: resolveVizpatchRoot(),
|
|
205
204
|
textWriter: writeTextChangeAvailable(),
|
|
206
205
|
mcpConfig: mcpConfigPresent(),
|
|
207
206
|
apiKeyConfigured: status.apiKeyConfigured,
|
|
@@ -240,12 +239,12 @@ app.get('/dev-loader.js', (_req, res) => {
|
|
|
240
239
|
res.sendFile(file);
|
|
241
240
|
});
|
|
242
241
|
|
|
243
|
-
app.get('/ui/
|
|
242
|
+
app.get('/ui/crank-ui.css', (_req, res) => {
|
|
244
243
|
const file =
|
|
245
|
-
|
|
246
|
-
path.resolve(__dirname, '..', 'bookmarklet', '
|
|
244
|
+
crankAsset('bookmarklet', 'crank-ui.css') ||
|
|
245
|
+
path.resolve(__dirname, '..', 'bookmarklet', 'crank-ui.css');
|
|
247
246
|
if (!fs.existsSync(file)) {
|
|
248
|
-
res.status(404).type('text/plain').send('
|
|
247
|
+
res.status(404).type('text/plain').send('crank-ui.css not found in package');
|
|
249
248
|
return;
|
|
250
249
|
}
|
|
251
250
|
res.set({
|
|
@@ -257,6 +256,11 @@ app.get('/ui/vizpatch-ui.css', (_req, res) => {
|
|
|
257
256
|
res.sendFile(file);
|
|
258
257
|
});
|
|
259
258
|
|
|
259
|
+
// Back-compat alias for older bookmarklets still requesting the old path.
|
|
260
|
+
app.get('/ui/vizpatch-ui.css', (_req, res) => {
|
|
261
|
+
res.redirect(301, '/ui/crank-ui.css');
|
|
262
|
+
});
|
|
263
|
+
|
|
260
264
|
app.get('/ui/text-source.js', (_req, res) => {
|
|
261
265
|
const file = path.resolve(__dirname, '..', 'bookmarklet', 'text-source.js');
|
|
262
266
|
res.set({
|
|
@@ -1131,9 +1135,7 @@ server.listen(PORT, HOST, () => {
|
|
|
1131
1135
|
}`
|
|
1132
1136
|
);
|
|
1133
1137
|
console.log(
|
|
1134
|
-
`[Crank]
|
|
1135
|
-
writeTextChangeAvailable() ? 'ok' : 'missing'
|
|
1136
|
-
})`
|
|
1138
|
+
`[Crank] Text-writer: ${writeTextChangeAvailable() ? 'ok (bundled)' : 'missing'}`
|
|
1137
1139
|
);
|
|
1138
1140
|
});
|
|
1139
1141
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Text save / resolve —
|
|
4
|
+
* Text save / resolve — Crank source resolution + bundled text-writer.
|
|
5
5
|
*
|
|
6
6
|
* Resolution order:
|
|
7
7
|
* 1. Explicit file / pathHints (route-like absolute paths resolved under project root)
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
|
-
const { requireVizpatch, resolveVizpatchRoot } = require('./vizpatch-bridge');
|
|
14
13
|
|
|
15
14
|
let writeTextChange;
|
|
16
15
|
try {
|
|
17
|
-
writeTextChange =
|
|
16
|
+
writeTextChange = require('./text-writer').writeTextChange;
|
|
18
17
|
} catch (err) {
|
|
19
18
|
writeTextChange = null;
|
|
20
19
|
console.warn('[Crank] text-writer unavailable:', err.message);
|
|
@@ -356,8 +355,7 @@ function saveTextChange(payload, projectRoot) {
|
|
|
356
355
|
return {
|
|
357
356
|
success: false,
|
|
358
357
|
error:
|
|
359
|
-
'
|
|
360
|
-
(resolveVizpatchRoot() || '(missing)')
|
|
358
|
+
'Crank text-writer not available. Ensure companion/text-writer.js is installed with the package.'
|
|
361
359
|
};
|
|
362
360
|
}
|
|
363
361
|
|