@ahmednawaz/crank 0.1.6 → 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Text source classification — ported from Vizpatch bookmarklet classifyTextSource.
2
+ * Text source classification — Crank bookmarklet classifyTextSource.
3
3
  * Hardcoded / static labels are editable; dynamic/bound data is locked.
4
4
  */
5
5
  (function (root) {
@@ -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 + Vizpatch text-writer.'
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
+ };
@@ -10,7 +10,10 @@
10
10
  "start": "node server.js"
11
11
  },
12
12
  "dependencies": {
13
+ "@babel/parser": "^7.28.0",
14
+ "@babel/traverse": "^7.28.0",
13
15
  "@cursor/sdk": "^1.0.23",
16
+ "cheerio": "^1.0.0",
14
17
  "cors": "^2.8.5",
15
18
  "express": "^4.21.2",
16
19
  "ws": "^8.18.0"
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * Persist an applied variant to source via Vizpatch text-writer (SAVE_TEXT_CHANGE).
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
 
@@ -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 Vizpatch companion/server.js (Express + ws on a fixed port),
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,12 +19,12 @@ const WebSocket = require('ws');
19
19
 
20
20
  const store = require('./selection-store');
21
21
  const { proposeCopyVariants } = require('./glean-client');
22
- const { vizpatchAsset, resolveVizpatchRoot } = require('./vizpatch-bridge');
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');
26
26
  const agentRunner = require('./agent-runner');
27
- const { env } = require('./env');
27
+ const { env } = require('../lib/env');
28
28
  const { loadTeamEnvFile } = require('../lib/load-team-env');
29
29
  const { describeEnvironment } = require('../lib/resolve-project');
30
30
  const { readRuntimeManifest } = require('../lib/urls');
@@ -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/vizpatch-ui.css', (_req, res) => {
242
+ app.get('/ui/crank-ui.css', (_req, res) => {
244
243
  const file =
245
- vizpatchAsset('bookmarklet', 'vizpatch-ui.css') ||
246
- path.resolve(__dirname, '..', 'bookmarklet', 'vizpatch-ui.css');
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('vizpatch-ui.css not found set VIZPATCH_ROOT');
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] Vizpatch bridge: ${resolveVizpatchRoot() || 'NOT FOUND'} (text-writer ${
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 — reuses Vizpatch text-writer + Vizpatch-like source resolution.
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 = requireVizpatch('companion/text-writer.js').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
- 'Vizpatch text-writer not available. Set VIZPATCH_ROOT to ' +
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