@hearsay-tools/squawk 0.18.0-dev.8364 → 0.18.0-dev.8366

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hearsay-tools/squawk",
3
- "version": "0.18.0-dev.8364",
3
+ "version": "0.18.0-dev.8366",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -68,8 +68,8 @@
68
68
  "devDependencies": {
69
69
  "@babel/parser": "^8.0.8",
70
70
  "@babel/types": "^8.0.8",
71
- "@open-mercato/cezar-api-client": "0.18.0-dev.8364",
72
- "@open-mercato/cezar-contract": "0.18.0-dev.8364",
71
+ "@open-mercato/cezar-api-client": "0.18.0-dev.8366",
72
+ "@open-mercato/cezar-contract": "0.18.0-dev.8366",
73
73
  "@types/node": "^24.19.1",
74
74
  "@types/ws": "^8.18.1",
75
75
  "esbuild": "^0.28.1",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "5924bcc6c3faf5d3f0cc5ceda4164ba8bc8d6e10"
89
+ "gitHead": "db6cd8a0ff318c59122b6cc3b8bb850b4a8252ec"
90
90
  }
@@ -13,6 +13,8 @@ import { createRequire } from 'node:module';
13
13
  import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
14
14
  import { basename, dirname, join, relative, resolve } from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
+ import { parse } from '@babel/parser';
17
+ import { traverse } from '@babel/types';
16
18
  import { build } from 'esbuild';
17
19
 
18
20
  const here = dirname(fileURLToPath(import.meta.url));
@@ -44,7 +46,17 @@ scan(dist);
44
46
  // specifiers (`from`, `import(...)`, side-effect `import`) to the sibling `dist/plugin/<stem>.js`
45
47
  // declaration without touching string-literal type constants; `.js` runtime imports stay on the
46
48
  // package specifier and resolve through `installPluginResolveHook()`.
47
- const PLUGIN_SPEC = /(from\s+|import\s*\(\s*|import\s+)(['"])@hearsay-tools\/squawk\/plugin(?:\/(runtime|model-settings|managed-cli|pi-rpc))?\2/g;
49
+ const PLUGIN_PACKAGE = '@hearsay-tools/squawk/plugin';
50
+ const PLUGIN_SPEC = /^@hearsay-tools\/squawk\/plugin(?:\/(runtime|model-settings|managed-cli|pi-rpc))?$/;
51
+ /** The module specifier literals of a declaration file: `from`, side-effect `import` and `import(...)` types. */
52
+ function declarationSpecifiers(text) {
53
+ const found = [];
54
+ traverse(parse(text, { sourceType: 'module', plugins: [['typescript', { dts: true }]] }), (node) => {
55
+ if ((node.type === 'ImportDeclaration' || node.type === 'ExportNamedDeclaration' || node.type === 'ExportAllDeclaration'
56
+ || node.type === 'TSImportType' || node.type === 'ImportExpression') && node.source?.type === 'StringLiteral') found.push(node.source);
57
+ });
58
+ return found;
59
+ }
48
60
  const pluginDir = join(dist, 'plugin');
49
61
  function repointPluginDecls() {
50
62
  if (!existsSync(join(pluginDir, 'index.d.ts'))) return 0;
@@ -56,13 +68,19 @@ function repointPluginDecls() {
56
68
  if (p !== outdir) walk(p);
57
69
  } else if (item.name.endsWith('.d.ts')) {
58
70
  const text = readFileSync(p, 'utf8');
59
- PLUGIN_SPEC.lastIndex = 0;
60
- if (!PLUGIN_SPEC.test(text)) continue;
61
- const next = text.replace(PLUGIN_SPEC, (_match, prefix, _quote, sub) => {
71
+ if (!text.includes(PLUGIN_PACKAGE)) continue;
72
+ const targets = declarationSpecifiers(text).flatMap((literal) => {
73
+ const match = PLUGIN_SPEC.exec(literal.value);
74
+ return match ? [{ literal, sub: match[1] }] : [];
75
+ });
76
+ if (targets.length === 0) continue;
77
+ let next = text;
78
+ // Replace from the end, so the offsets of earlier literals stay valid.
79
+ for (const { literal, sub } of targets.reverse()) {
62
80
  let rel = relative(dirname(p), join(pluginDir, `${sub ?? 'index'}.js`)).replaceAll('\\', '/');
63
81
  if (!rel.startsWith('.')) rel = `./${rel}`;
64
- return `${prefix}'${rel}'`;
65
- });
82
+ next = `${next.slice(0, literal.start)}'${rel}'${next.slice(literal.end)}`;
83
+ }
66
84
  writeFileSync(p, next, 'utf8');
67
85
  count++;
68
86
  }
@@ -97,8 +115,12 @@ const bundled = await build({
97
115
  // root bundle's unrelated exports (hearsay-tools/cezarion#1813).
98
116
  const rootExports = new Set(Object.values(bundled.metafile.outputs).flatMap((output) => output.exports));
99
117
  for (const file of referrers.filter((name) => name.endsWith('.js'))) {
100
- for (const match of readFileSync(file, 'utf8').matchAll(/export\s+\*\s+from\s+['"](@open-mercato\/cezar-contract\/([^'"]+))['"]/g)) {
101
- const source = join(contractRoot, 'src', `${match[2]}.ts`);
118
+ const wildcards = [];
119
+ traverse(parse(readFileSync(file, 'utf8'), { sourceType: 'module' }), (node) => {
120
+ if (node.type === 'ExportAllDeclaration' && node.source.value.startsWith('@open-mercato/cezar-contract/')) wildcards.push(node.source.value);
121
+ });
122
+ for (const specifier of wildcards) {
123
+ const source = join(contractRoot, 'src', `${specifier.slice('@open-mercato/cezar-contract/'.length)}.ts`);
102
124
  const original = await build({
103
125
  entryPoints: [source], bundle: true, write: false, metafile: true,
104
126
  format: 'esm', platform: 'neutral', external: ['zod'],
@@ -106,7 +128,7 @@ for (const file of referrers.filter((name) => name.endsWith('.js'))) {
106
128
  const missing = Object.values(original.metafile.outputs).flatMap((output) => output.exports)
107
129
  .filter((name) => !rootExports.has(name));
108
130
  if (missing.length) {
109
- console.error(`inline-contract: ${relative(dist, file)} wildcard re-export of "${match[1]}" loses root exports: ${missing.join(', ')}`);
131
+ console.error(`inline-contract: ${relative(dist, file)} wildcard re-export of "${specifier}" loses root exports: ${missing.join(', ')}`);
110
132
  process.exit(1);
111
133
  }
112
134
  }
@@ -147,6 +169,7 @@ const gaps = importers.length === 0 ? [] : await build({
147
169
  if (gaps.length > 0) {
148
170
  for (const { text, location } of gaps) {
149
171
  const where = location ? `${join(basename(dist), location.file)}:${location.line}` : basename(dist);
172
+ // oxlint-disable-next-line cez/regex-module-syntax -- reads esbuild's error message text, not module source.
150
173
  const name = /import "([^"]+)"/i.exec(text)?.[1];
151
174
  const subpath = /"contract:([^"]+)"/.exec(text)?.[1];
152
175
  console.error(name && subpath