@notis_ai/cli 0.2.30 → 0.2.32

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.
Files changed (87) hide show
  1. package/README.md +15 -0
  2. package/config/notis_app_design_rules.json +22 -0
  3. package/dist/agent-hooks/notis-agent-hook.mjs +38244 -10823
  4. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  5. package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
  6. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  7. package/dist/base-skills/notis-query/references/query.md +6 -4
  8. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  9. package/dist/base-skills/notis-spaces/SKILL.md +12 -4
  10. package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
  11. package/dist/base-skills/notis-spaces/references/design.md +7 -1
  12. package/dist/base-skills/notis-spaces/references/fixtures.md +29 -2
  13. package/dist/base-skills/notis-spaces/references/reading.md +3 -1
  14. package/dist/base-skills/notis-spaces/references/release.md +3 -1
  15. package/dist/base-skills/notis-spaces/references/sdk.md +112 -33
  16. package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
  17. package/dist/base-skills/notis-spaces/references/views.md +20 -0
  18. package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
  19. package/dist/sdk/src/index.ts +1 -1
  20. package/dist/sdk/src/space.ts +3 -1
  21. package/dist/sdk/src/tailwind.ts +53 -3
  22. package/dist/sdk/src/ui/icons.tsx +18 -1
  23. package/dist/sdk/src/words/types.ts +28 -0
  24. package/dist/skill-sync/index.js +10 -90
  25. package/dist/skill-sync-worker.mjs +50 -93
  26. package/dist/space-harness/host.js +155 -82
  27. package/dist/space-sdk/dist/chunk-I4Z4UFGB.js +3 -0
  28. package/dist/space-sdk/dist/index.js +2 -2
  29. package/dist/space-sdk/dist/ui.js +12 -12
  30. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
  31. package/dist/space-sdk/src/index.d.ts +1 -1
  32. package/dist/space-sdk/src/space.ts +3 -1
  33. package/dist/space-sdk/src/tailwind-candidates.d.ts +315 -2
  34. package/dist/space-sdk/src/tailwind.ts +53 -3
  35. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
  36. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
  37. package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
  38. package/dist/space-sdk/src/ui/blocks/blocks.d.ts +18 -0
  39. package/dist/space-sdk/src/ui/blocks/index.d.ts +3 -3
  40. package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
  41. package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
  42. package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
  43. package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
  44. package/dist/space-sdk/src/ui/icons.d.ts +6 -0
  45. package/dist/space-sdk/src/ui/index.d.ts +5 -3
  46. package/dist/space-sdk/src/ui/list/ListReader.d.ts +8 -0
  47. package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
  48. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
  49. package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
  50. package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
  51. package/dist/space-sdk/src/words/types.ts +28 -0
  52. package/dist/view-renderer/dist/host.js +224 -151
  53. package/dist/view-renderer/src/dom.js +3 -2
  54. package/dist/view-renderer/src/errors.js +9 -0
  55. package/dist/view-renderer/src/host.tsx +12 -5
  56. package/dist/view-renderer/src/remote-broker.js +3 -1
  57. package/dist/view-renderer/src/renderer.js +63 -16
  58. package/dist/view-renderer/src/skeleton.js +70 -18
  59. package/package.json +5 -4
  60. package/skills/notis-query/cli.md +3 -0
  61. package/skills/notis-spaces/cli.md +14 -0
  62. package/src/command-specs/spaces.js +138 -15
  63. package/src/command-specs/tools.js +3 -0
  64. package/src/runtime/api-hosts.generated.js +35 -0
  65. package/src/runtime/api-hosts.js +27 -10
  66. package/src/runtime/app-boundary-validator.js +248 -3
  67. package/src/runtime/app-data-literals.js +32 -23
  68. package/src/runtime/app-platform.js +68 -24
  69. package/src/runtime/http-agent.js +53 -0
  70. package/src/runtime/native-record-files.js +11 -0
  71. package/src/runtime/oauth.js +2 -1
  72. package/src/runtime/skill-sync/cloud-client.ts +0 -10
  73. package/src/runtime/skill-sync/index.ts +13 -15
  74. package/src/runtime/skill-sync/local-scanner.ts +0 -67
  75. package/src/runtime/skill-sync/types.ts +1 -0
  76. package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
  77. package/src/runtime/space-dependencies.js +66 -0
  78. package/src/runtime/space-fixture-broker.js +23 -8
  79. package/src/runtime/space-platform.js +47 -3
  80. package/src/runtime/space-source.js +10 -1
  81. package/src/runtime/space-test-server.js +124 -6
  82. package/src/runtime/space-verification.js +103 -43
  83. package/src/runtime/space-view-manifest.js +38 -5
  84. package/src/runtime/transport.js +19 -4
  85. package/src/runtime/view-render.js +4 -1
  86. package/template/tailwind.config.ts +2 -35
  87. package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
@@ -1,9 +1,41 @@
1
- /** Build-only SDK content discovery. Author configuration and PostCSS plugins stay intact. */
1
+ /**
2
+ * Build-only SDK content discovery and Notis theme colours. Author configuration and PostCSS plugins stay intact:
3
+ * a colour, theme value or opacity step the Space defines itself always wins over the defaults added here.
4
+ */
2
5
  import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3
6
  import { tmpdir } from 'node:os';
4
7
  import { dirname, join, relative, resolve } from 'node:path';
5
8
  import { fileURLToPath } from 'node:url';
6
9
 
10
+ const tone = (name: string) => `hsl(var(--${name}))`;
11
+ const pair = (name: string) => ({ DEFAULT: tone(name), foreground: tone(`${name}-foreground`) });
12
+
13
+ /**
14
+ * The colours the Notis host sets on every Space page (light and dark), as Tailwind colours, so `bg-accent`,
15
+ * `text-chart-2` and opacity modifiers such as `bg-chart-2/40` or `bg-foreground/12` work in every Space.
16
+ */
17
+ export const NOTIS_THEME_COLORS = {
18
+ border: tone('border'), input: tone('input'), ring: tone('ring'),
19
+ background: tone('background'), foreground: tone('foreground'),
20
+ primary: pair('primary'), secondary: pair('secondary'), destructive: pair('destructive'), muted: pair('muted'),
21
+ accent: pair('accent'), popover: pair('popover'), card: pair('card'),
22
+ chart: { 1: tone('chart-1'), 2: tone('chart-2'), 3: tone('chart-3'), 4: tone('chart-4'), 5: tone('chart-5') },
23
+ } as const;
24
+
25
+ /** Tailwind 4 theme block: `default` keeps every colour a Space sets in its own `@theme` or `@config` first. */
26
+ const THEME_MARK = '/* notis-theme-colors */';
27
+ const themeBlock = () => {
28
+ const lines: string[] = [];
29
+ for (const [name, value] of Object.entries(NOTIS_THEME_COLORS)) {
30
+ if (typeof value === 'string') { lines.push(` --color-${name}: ${value};`); continue; }
31
+ for (const [key, shade] of Object.entries(value)) lines.push(` --color-${name}${key === 'DEFAULT' ? '' : `-${key}`}: ${shade};`);
32
+ }
33
+ return `${THEME_MARK}\n@theme default inline {\n${lines.join('\n')}\n}`;
34
+ };
35
+
36
+ /** Tailwind 3 only knows the opacity steps of its scale (5, 10, 15...): every whole percent works, as in Tailwind 4. */
37
+ const OPACITY_STEPS = Object.fromEntries(Array.from({ length: 101 }, (_, step) => [String(step), String(step / 100)]));
38
+
7
39
  export function notisTailwindContent() {
8
40
  let root = process.cwd();
9
41
  let temporary: string | undefined;
@@ -26,7 +58,8 @@ export function notisTailwindContent() {
26
58
  const sdkSource = dirname(fileURLToPath(import.meta.url));
27
59
  const relativeSource = './' + relative(dirname(stylesheet), sdkSource).replaceAll('\\', '/');
28
60
  const directive = `@source ${JSON.stringify(relativeSource)};`;
29
- return source.includes(directive) ? null : { code: `${source}\n${directive}\n`, map: null };
61
+ const added = [source.includes(directive) ? '' : `${directive}\n`, source.includes(THEME_MARK) ? '' : `${themeBlock()}\n`].join('');
62
+ return added ? { code: `${source}\n${added}`, map: null } : null;
30
63
  }
31
64
  if (!/@tailwind\s/.test(source)) return null;
32
65
  const explicit = source.match(/@config\s+(['"])(.*?)\1\s*;/);
@@ -41,11 +74,28 @@ export function notisTailwindContent() {
41
74
  const sdkGlob = join(dirname(fileURLToPath(import.meta.url)), '**/*.{ts,tsx}').replaceAll('\\', '/');
42
75
  writeFileSync(wrapper, `import config from ${JSON.stringify(config)};
43
76
  import { resolve } from 'node:path';
77
+ const defaults = ${JSON.stringify({ colors: NOTIS_THEME_COLORS, opacity: OPACITY_STEPS })};
78
+ const theme = config.theme || {};
79
+ const extend = theme.extend || {};
80
+ const presets = (config.presets || []).filter(preset => preset && typeof preset === 'object').map(preset => preset.theme || {});
81
+ // The Space's own colours and opacity steps win: a default fills only what the Space (or its presets) leaves unset,
82
+ // one level deep, so a Space's own card keeps the Notis card-foreground. A scale the Space replaces stays as it is.
83
+ const fill = (key) => {
84
+ if (typeof theme[key] === 'function' || (key === 'opacity' && theme.opacity)) return extend[key];
85
+ const own = [...presets.flatMap(t => [t[key], (t.extend || {})[key]]), theme[key], extend[key]].filter(v => v && typeof v === 'object');
86
+ const added = {};
87
+ for (const [name, value] of Object.entries(defaults[key])) {
88
+ const set = own.map(o => o[name]).filter(v => v !== undefined);
89
+ if (!set.length) added[name] = value;
90
+ else if (typeof value === 'object' && set.every(v => v && typeof v === 'object')) added[name] = Object.assign({}, value, ...set);
91
+ }
92
+ return typeof extend[key] === 'function' ? (utils) => ({ ...added, ...extend[key](utils) }) : { ...extend[key], ...added };
93
+ };
44
94
  const content = config.content || [];
45
95
  const files = Array.isArray(content) ? content : (content.files || []);
46
96
  const base = ${JSON.stringify(root)};
47
97
  const relativeBase = ${JSON.stringify(dirname(config))};
48
- export default { ...config, content: {
98
+ export default { ...config, theme: { ...theme, extend: { ...extend, colors: fill('colors'), opacity: fill('opacity') } }, content: {
49
99
  ...(Array.isArray(content) ? {} : content),
50
100
  relative: false,
51
101
  files: [...files.map(file => typeof file !== 'string' ? file :
@@ -56,6 +56,7 @@ const SHAPES: Record<string, Shape> = {
56
56
  'check-circle-fill': <g><circle {...F} cx="8" cy="8" r="6.5" /><path d="M5 8.2l2 2 4-4" fill="none" stroke="hsl(var(--background))" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" /></g>,
57
57
  'minus-circle': <g {...S}><circle cx="8" cy="8" r="6" /><path d="M5.5 8h5" /></g>,
58
58
  'paper-plane-right': <path {...S} d="M2.5 2.8l11 5.2-11 5.2 1.8-5.2zM4.3 8h4.7" />,
59
+ 'paper-plane-tilt': <path {...S} d="M2.3 6.7l11.2-4.2-4.2 11.2-2.2-4.8zM7.1 8.9l3.3-3.3" />,
59
60
  paperclip: <path {...S} d="M10.5 5l-4.6 4.6a1.1 1.1 0 001.6 1.6l5-5a2.3 2.3 0 00-3.2-3.2l-5 5a3.4 3.4 0 004.8 4.8L13 8.9" />,
60
61
  'clipboard-text': <g {...S}><path d="M10.5 3h2a.5.5 0 01.5.5v10a.5.5 0 01-.5.5h-9a.5.5 0 01-.5-.5v-10a.5.5 0 01.5-.5h2" /><rect x="5.5" y="2" width="5" height="2.5" rx=".75" /><path d="M6 8h4M6 10.5h4" /></g>,
61
62
  'x-circle-fill': <g><circle {...F} cx="8" cy="8" r="6.5" /><path d="M5.8 5.8l4.4 4.4M10.2 5.8l-4.4 4.4" fill="none" stroke="hsl(var(--background))" strokeWidth={1.5} strokeLinecap="round" /></g>,
@@ -63,13 +64,29 @@ const SHAPES: Record<string, Shape> = {
63
64
  'magnifying-glass-minus': <path {...S} d="M7 12A5 5 0 107 2a5 5 0 000 10zM10.6 10.6L14 14M5 7h4" />,
64
65
  'download-simple': <path {...S} d="M8 2.5v7.5M4.5 6.5L8 10l3.5-3.5M2.5 10v3a.5.5 0 00.5.5h10a.5.5 0 00.5-.5v-3" />,
65
66
  info: <g {...S}><circle cx="8" cy="8" r="6.5" /><path d="M8 7.5V11M8 5.25v.01" /></g>,
67
+ 'arrow-square-out': <path {...S} d="M12.5 9v3.5a.5.5 0 01-.5.5H3.5a.5.5 0 01-.5-.5V4a.5.5 0 01.5-.5H7M9.5 2.5h4v4M13.5 2.5L8 8" />,
68
+ 'funnel-simple': <path {...S} d="M2.5 4.5h11M4.5 8h7M6.5 11.5h3" />,
66
69
  link: <path {...S} d="M6.8 9.2l2.4-2.4M7.6 4.6l1.2-1.2a2.8 2.8 0 014 4l-1.2 1.2M8.4 11.4l-1.2 1.2a2.8 2.8 0 01-4-4l1.2-1.2" />,
67
70
  file: <path {...S} d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" />,
68
71
  'file-image': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M3.5 12l3-3 2 2 1.5-1.5 2.5 2.5" /><circle cx="6.5" cy="6.75" r=".75" /></g>,
69
72
  'file-video': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M6.5 8v3.5L9.5 9.75z" /></g>,
70
73
  'file-audio': <g {...S}><path d="M9.5 2H4a.5.5 0 00-.5.5v11a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V5zM9.5 2v3h3" /><path d="M6 9.5v1.5h1.25L9 12.25v-4.5L7.25 9H6M10.5 8.5a1.8 1.8 0 010 2.5" /></g>,
74
+ 'fork-knife': <path {...S} d="M3.5 2v3.5a1.5 1.5 0 003 0V2M5 2v12M11.5 14V2c-1.4.9-2.2 3-2.2 6.5h2.2" />,
75
+ 'check-circle': <g {...S}><circle cx="8" cy="8" r="6" /><path d="M5.5 8.2l1.8 1.8 3.4-3.6" /></g>,
76
+ 'chart-line-up': <path {...S} d="M2.5 2.5v11h11M4.5 10.5l3-3 2 2 4-4.5M10.5 5h3v3" />,
77
+ sparkle: <path {...S} d="M7 3.5l1.2 3.3 3.3 1.2-3.3 1.2L7 12.5 5.8 9.2 2.5 8l3.3-1.2zM12.5 1.75v2.5M11.25 3h2.5" />,
78
+ 'rocket-launch': <g {...S}><path d="M5.2 7.3l4.4-4.4C11 1.5 13.5 2 14 2c0 .5.5 3-.9 4.4l-4.4 4.4zM5.2 7.3H3l2-2.3h2.8M8.7 10.8V13l2.3-2V8.2M5.3 10.7c-1.3.4-2.3 1.5-2.8 2.8 1.3-.5 2.4-1.5 2.8-2.8z" /><circle cx="10.8" cy="5.2" r=".9" /></g>,
79
+ chats: <g {...S}><path d="M3 3h6.5a.5.5 0 01.5.5v5a.5.5 0 01-.5.5H5.2L2.5 11V3.5A.5.5 0 013 3z" /><path d="M10 6h3a.5.5 0 01.5.5V14l-2.6-2H7a.5.5 0 01-.5-.5V9" /></g>,
80
+ kanban: <g {...S}><rect x="2.5" y="2.5" width="3" height="10" rx=".5" /><rect x="6.5" y="2.5" width="3" height="6" rx=".5" /><rect x="10.5" y="2.5" width="3" height="8" rx=".5" /></g>,
71
81
  };
72
82
 
83
+ /**
84
+ * Every name the set draws, in the order above. `notis spaces build` refuses an `icon` or `<Icon name>` string that is
85
+ * not one of them; the CLI and the server read the same list from `server/config/notis_app_design_rules.json`, kept
86
+ * equal to this one by `icons.test.tsx`.
87
+ */
88
+ export const ICON_NAMES: readonly string[] = Object.freeze(Object.keys(SHAPES));
89
+
73
90
  export function hasIcon(name: string): boolean {
74
91
  return Object.prototype.hasOwnProperty.call(SHAPES, name);
75
92
  }
@@ -80,7 +97,7 @@ const warned = new Set<string>();
80
97
  function warnUnknown(name: string): void {
81
98
  if (warned.has(name) || typeof console === 'undefined') return;
82
99
  warned.add(name);
83
- console.warn(`[notis/ui] Unknown icon "${name}": it renders nothing. Use a name from the toolkit set (${Object.keys(SHAPES).length} icons, listed in the design system) or pass a Phosphor component.`);
100
+ console.warn(`[notis/ui] Unknown icon "${name}": it renders nothing. Use a name from the toolkit set (${ICON_NAMES.length} icons, listed in the design system) or pass a Phosphor component.`);
84
101
  }
85
102
 
86
103
  /** A built-in icon by name; an unknown name renders nothing and warns once. Decorative: the control carries the label. */
@@ -48,6 +48,34 @@ export function fillWords(words: Words, vars: Readonly<Record<string, string | n
48
48
  return { en: interpolate(words.en, vars), fr: interpolate(words.fr, vars) };
49
49
  }
50
50
 
51
+ const PLURAL_INTL = new Map<Locale, { rules: Intl.PluralRules; number: Intl.NumberFormat }>();
52
+ function pluralIntl(locale: Locale) {
53
+ let intl = PLURAL_INTL.get(locale);
54
+ if (!intl) {
55
+ const tag = locale === 'fr' ? 'fr-FR' : 'en-US';
56
+ intl = { rules: new Intl.PluralRules(tag), number: new Intl.NumberFormat(tag) };
57
+ PLURAL_INTL.set(locale, intl);
58
+ }
59
+ return intl;
60
+ }
61
+
62
+ /**
63
+ * The words for a count, in the grammar of each language: English "1 campaign" / "2 campaigns", French "1 campagne" /
64
+ * "2 campagnes" (French also uses the singular for 0 and 1.5). `forms` holds the singular (`one`) and the plural
65
+ * (`other`) of each language; `{n}` in them is the count as written in that locale ("1,250" / "1 250").
66
+ * `pluralWords(3, { one: w('{n} campaign', '{n} campagne'), other: w('{n} campaigns', '{n} campagnes') })`.
67
+ */
68
+ export function pluralWords(count: number, forms: { one: Words; other: Words }): Words {
69
+ const form = (locale: Locale) => {
70
+ const intl = pluralIntl(locale);
71
+ const rule = Number.isFinite(count) ? intl.rules.select(count) : 'other';
72
+ const words = rule === 'one' ? forms.one : forms.other;
73
+ const n = Number.isFinite(count) ? intl.number.format(count) : String(count);
74
+ return interpolate(locale === 'fr' ? words.fr : words.en, { n });
75
+ };
76
+ return { en: form('en'), fr: form('fr') };
77
+ }
78
+
51
79
  /** Shorthand for a Words pair. */
52
80
  export function w(en: string, fr: string): Words {
53
81
  return { en, fr };
@@ -811,44 +811,6 @@ async function createZipFromDirectory(directoryPath) {
811
811
  await fs.rm(stagingRoot, { recursive: true, force: true });
812
812
  }
813
813
  }
814
- async function extractZipToDirectory(zipPath, destinationDir) {
815
- const extractRoot = await fs.mkdtemp(
816
- path.join(os.tmpdir(), "notis-skill-extract-")
817
- );
818
- try {
819
- if (process.platform === "win32") {
820
- await execFileAsync("powershell.exe", [
821
- "-NoProfile",
822
- "-Command",
823
- `Expand-Archive -Path '${zipPath.replace(/'/g, "''")}' -DestinationPath '${extractRoot.replace(/'/g, "''")}' -Force`
824
- ]);
825
- } else {
826
- await execFileAsync("unzip", ["-qq", zipPath, "-d", extractRoot]);
827
- }
828
- const extractedEntries = await fs.readdir(extractRoot, {
829
- withFileTypes: true
830
- });
831
- const extractedDirectory = extractedEntries.find(
832
- (entry) => entry.isDirectory()
833
- );
834
- const sourceDir = extractedDirectory ? path.join(extractRoot, extractedDirectory.name) : extractRoot;
835
- await fs.rm(destinationDir, { recursive: true, force: true });
836
- await fs.mkdir(path.dirname(destinationDir), { recursive: true });
837
- await fs.cp(sourceDir, destinationDir, { recursive: true });
838
- return await listRelativeFiles(destinationDir);
839
- } finally {
840
- await fs.rm(extractRoot, { recursive: true, force: true });
841
- }
842
- }
843
- async function listRelativeFiles(dirPath) {
844
- try {
845
- const files = await listFilesRecursive(dirPath);
846
- return files.map((filePath) => toPosixRelativePath(dirPath, filePath)).sort();
847
- } catch (error) {
848
- if (error?.code === "ENOENT") return [];
849
- throw error;
850
- }
851
- }
852
814
  function toPosixRelativePath(rootDir, filePath) {
853
815
  return path.relative(rootDir, filePath).split(path.sep).join("/");
854
816
  }
@@ -990,7 +952,7 @@ async function captureNativeSkillFiles(skill) {
990
952
  if (hash.digest("hex") !== skill.folderHash) throw new Error("Local Skill files changed before upload. Sync again with the current files.");
991
953
  return files;
992
954
  }
993
- async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PATHS, options = {}) {
955
+ async function writeCloudSkillToDisk(skill, paths = DEFAULT_SYNC_PATHS, options = {}) {
994
956
  if (isNativeSkill(skill)) {
995
957
  assertNativePull({
996
958
  skills: [{ ...skill, name: "native-" + skill.id }],
@@ -999,7 +961,6 @@ async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PA
999
961
  sync_enabled: true,
1000
962
  last_synced_at: null
1001
963
  });
1002
- if (bundleBytes?.length) throw new Error("Native Skills require their verified complete file response.");
1003
964
  }
1004
965
  const skillDir = path.join(
1005
966
  paths.skillsDir,
@@ -1012,22 +973,6 @@ async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PA
1012
973
  // An unchanged legacy folder upgrading in place: shared files take the cloud version.
1013
974
  legacyBaseline: isNativeSkill(skill) && options.legacyBaseline === true && options.expectedFolderHash !== void 0
1014
975
  };
1015
- if (bundleBytes?.length) {
1016
- const bundlePath = path.join(
1017
- os.tmpdir(),
1018
- `notis-skill-download-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`
1019
- );
1020
- try {
1021
- await fs.writeFile(bundlePath, bundleBytes);
1022
- let appliedFiles = [];
1023
- await replaceSkillDirectoryAtomically(skillDir, async (stagingDir) => {
1024
- appliedFiles = await extractZipToDirectory(bundlePath, stagingDir);
1025
- }, preserve);
1026
- return { written: true, appliedFiles };
1027
- } finally {
1028
- await fs.rm(bundlePath, { force: true });
1029
- }
1030
- }
1031
976
  if (!skill.skill_md && (!skill.bundle_files || skill.bundle_files.length === 0)) {
1032
977
  return false;
1033
978
  }
@@ -1188,14 +1133,6 @@ async function pushChangedSkills(serverUrl, jwt, changedSkills, options = {}) {
1188
1133
  }
1189
1134
  return { skills: saved, ...failed.length ? { failed } : {} };
1190
1135
  }
1191
- async function downloadSkillBundle(bundleUrl) {
1192
- const response = await fetch(bundleUrl, { signal: AbortSignal.timeout(9e4) });
1193
- if (!response.ok) {
1194
- const text = await response.text();
1195
- throw new Error(`GET ${bundleUrl} \u2192 ${response.status}: ${text}`);
1196
- }
1197
- return Buffer.from(await response.arrayBuffer());
1198
- }
1199
1136
  async function updateAgentTargets(serverUrl, jwt, skillId, targets, expectedUpdatedAt, native) {
1200
1137
  if (native) {
1201
1138
  checkedNativeReference(native.reference, skillId);
@@ -1566,25 +1503,7 @@ function getPushCandidates(localSkills, syncState, cloudCuratedSkillNames = /* @
1566
1503
  }
1567
1504
 
1568
1505
  // src/runtime/skill-sync/write-cloud-skill.ts
1569
- async function writeCloudSkillWithBundleFallback(skill, dependencies) {
1570
- if (skill.skill_source_url) {
1571
- try {
1572
- const bundleBytes = await dependencies.downloadSkillBundle(skill.skill_source_url);
1573
- const wroteBundleToDisk = await dependencies.writeCloudSkillToDisk(skill, bundleBytes);
1574
- if (wroteBundleToDisk) {
1575
- return wroteBundleToDisk;
1576
- }
1577
- dependencies.onWarning?.(
1578
- `Bundle sync for "${skill.name}" produced no local changes, falling back to SKILL.md payload.`,
1579
- new Error("Bundle write returned false")
1580
- );
1581
- } catch (error) {
1582
- dependencies.onWarning?.(
1583
- `Failed to apply bundle sync for "${skill.name}", falling back to SKILL.md payload.`,
1584
- error
1585
- );
1586
- }
1587
- }
1506
+ async function writeCloudSkill(skill, dependencies) {
1588
1507
  if (skill.bundle_hydration_failed) {
1589
1508
  dependencies.onWarning?.(
1590
1509
  `Skipping markdown fallback for synced skill "${skill.name}" because its stored bundle could not be hydrated by the server.`,
@@ -1623,7 +1542,6 @@ var DEFAULT_RUN_SKILL_SYNC_DEPS = {
1623
1542
  fetchSyncSettings,
1624
1543
  pullSkills,
1625
1544
  pushChangedSkills,
1626
- downloadSkillBundle,
1627
1545
  gatherTopLevelLocalSkills,
1628
1546
  readLegacySyncState,
1629
1547
  readSyncState,
@@ -1712,7 +1630,10 @@ function cloudContentHash(skill) {
1712
1630
  return createHash4("sha256").update(JSON.stringify({
1713
1631
  md: skill.skill_md,
1714
1632
  hash: skill.skill_folder_hash,
1715
- source: skill.skill_source_url,
1633
+ // A recorded origin is provenance, never content (SKL-059): a URL hashes as null so
1634
+ // it cannot force a rewrite, and an absent or null one hashes as before so stored
1635
+ // hashes stay valid.
1636
+ source: skill.skill_source_url ? null : skill.skill_source_url,
1716
1637
  files: skill.bundle_files?.slice().sort((a, b) => a.path.localeCompare(b.path)),
1717
1638
  hydrationFailed: skill.bundle_hydration_failed === true
1718
1639
  })).digest("hex");
@@ -1785,7 +1706,7 @@ function buildSyncState(pullResponse, localSkills, lastSyncedAt, verifiedAgentLi
1785
1706
  agentTargets: normalizeAgentTargets(skill.agent_targets),
1786
1707
  verifiedAgentLinks: skill.status === "active" ? verifiedAgentLinks[skill.name] ?? {} : {},
1787
1708
  cloudUpdatedAt: skill.updated_at,
1788
- ...!failedContentNames.has(skill.name) && !skill.skill_source_url ? { cloudContentHash: cloudContentHash(skill) } : {},
1709
+ ...!failedContentNames.has(skill.name) ? { cloudContentHash: cloudContentHash(skill) } : {},
1789
1710
  ...appliedCloudFolderHash !== void 0 ? { appliedCloudFolderHash } : {},
1790
1711
  ...appliedFileList !== void 0 ? { appliedFiles: appliedFileList } : {},
1791
1712
  syncedAt: lastSyncedAt || (/* @__PURE__ */ new Date()).toISOString()
@@ -1886,9 +1807,8 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
1886
1807
  }
1887
1808
  continue;
1888
1809
  }
1889
- const outcome = await writeCloudSkillWithBundleFallback(cloudSkill, {
1890
- downloadSkillBundle: deps.downloadSkillBundle,
1891
- writeCloudSkillToDisk: (skill, bundleBytes) => deps.writeCloudSkillToDisk(skill, bundleBytes, syncPaths, {
1810
+ const outcome = await writeCloudSkill(cloudSkill, {
1811
+ writeCloudSkillToDisk: (skill) => deps.writeCloudSkillToDisk(skill, syncPaths, {
1892
1812
  // What the last write put there. Everything else in the folder was
1893
1813
  // produced locally and survives this one.
1894
1814
  previouslyApplied: previouslyAppliedFiles(skill, local, previousState),
@@ -1904,7 +1824,7 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
1904
1824
  appliedFilesByName[cloudSkill.name] = outcome.appliedFiles;
1905
1825
  }
1906
1826
  } else {
1907
- failures.push({ name: cloudSkill.name, error: "Skill content could not be downloaded or written; sync will retry" });
1827
+ failures.push({ name: cloudSkill.name, error: "Skill content could not be written; sync will retry" });
1908
1828
  }
1909
1829
  }
1910
1830
  return downloaded;
@@ -157,11 +157,48 @@ function withConfigFileWriteLock(configFile, callback) {
157
157
  import { existsSync as existsSync2 } from "node:fs";
158
158
  import { isAbsolute } from "node:path";
159
159
 
160
+ // src/runtime/api-hosts.generated.js
161
+ var CHANNEL_ORIGINS = {
162
+ stable: {
163
+ portal: "https://app.notis.ai",
164
+ api: "https://api.notis.ai",
165
+ mcp: "https://mcp.notis.ai",
166
+ realtime: "wss://realtime.notis.ai"
167
+ },
168
+ nightly: {
169
+ portal: "https://app-nightly.notis.ai",
170
+ api: "https://api-nightly.notis.ai",
171
+ mcp: "https://mcp-nightly.notis.ai",
172
+ realtime: "wss://realtime-nightly.notis.ai"
173
+ }
174
+ };
175
+ var CHANNEL_HOSTNAMES = {
176
+ stable: {
177
+ portal: ["app.notis.ai"],
178
+ api: ["api.notis.ai"],
179
+ mcp: ["mcp.notis.ai"],
180
+ realtime: ["realtime.notis.ai", "websocket-prod.onrender.com"]
181
+ },
182
+ nightly: {
183
+ portal: ["app-nightly.notis.ai"],
184
+ api: ["api-nightly.notis.ai"],
185
+ mcp: ["mcp-nightly.notis.ai"],
186
+ realtime: ["realtime-nightly.notis.ai", "notis-websocket.onrender.com"]
187
+ }
188
+ };
189
+
160
190
  // src/runtime/api-hosts.js
161
- var CHANNEL_APIS = {
162
- stable: { current: "api.notis.ai", retired: [], portal: "https://app.notis.ai" },
163
- nightly: { current: "api-nightly.notis.ai", retired: ["api-beta.notis.ai"], portal: "https://app-nightly.notis.ai" }
191
+ var CLI_RETIRED_API_HOSTS = {
192
+ nightly: ["api-beta.notis.ai"]
164
193
  };
194
+ var CHANNEL_APIS = channelApis(CHANNEL_HOSTNAMES, CHANNEL_ORIGINS);
195
+ function channelApis(channelHostnames, channelOrigins) {
196
+ return Object.fromEntries(Object.entries(channelHostnames).map(([channel, surfaces]) => {
197
+ const [current, ...legacy] = surfaces.api;
198
+ const retired = [.../* @__PURE__ */ new Set([...legacy, ...CLI_RETIRED_API_HOSTS[channel] || []])].filter((host) => host !== current);
199
+ return [channel, { current, retired, portal: channelOrigins[channel].portal }];
200
+ }));
201
+ }
165
202
  var HOST_ROWS = Object.entries(CHANNEL_APIS).flatMap(([channel, row]) => [
166
203
  { host: row.current, channel, current: true },
167
204
  ...row.retired.map((host) => ({ host, channel, current: false }))
@@ -2558,44 +2595,6 @@ async function createZipFromDirectory(directoryPath) {
2558
2595
  await fs.rm(stagingRoot, { recursive: true, force: true });
2559
2596
  }
2560
2597
  }
2561
- async function extractZipToDirectory(zipPath, destinationDir) {
2562
- const extractRoot = await fs.mkdtemp(
2563
- path.join(os.tmpdir(), "notis-skill-extract-")
2564
- );
2565
- try {
2566
- if (process.platform === "win32") {
2567
- await execFileAsync("powershell.exe", [
2568
- "-NoProfile",
2569
- "-Command",
2570
- `Expand-Archive -Path '${zipPath.replace(/'/g, "''")}' -DestinationPath '${extractRoot.replace(/'/g, "''")}' -Force`
2571
- ]);
2572
- } else {
2573
- await execFileAsync("unzip", ["-qq", zipPath, "-d", extractRoot]);
2574
- }
2575
- const extractedEntries = await fs.readdir(extractRoot, {
2576
- withFileTypes: true
2577
- });
2578
- const extractedDirectory = extractedEntries.find(
2579
- (entry) => entry.isDirectory()
2580
- );
2581
- const sourceDir = extractedDirectory ? path.join(extractRoot, extractedDirectory.name) : extractRoot;
2582
- await fs.rm(destinationDir, { recursive: true, force: true });
2583
- await fs.mkdir(path.dirname(destinationDir), { recursive: true });
2584
- await fs.cp(sourceDir, destinationDir, { recursive: true });
2585
- return await listRelativeFiles(destinationDir);
2586
- } finally {
2587
- await fs.rm(extractRoot, { recursive: true, force: true });
2588
- }
2589
- }
2590
- async function listRelativeFiles(dirPath) {
2591
- try {
2592
- const files = await listFilesRecursive(dirPath);
2593
- return files.map((filePath) => toPosixRelativePath(dirPath, filePath)).sort();
2594
- } catch (error) {
2595
- if (error?.code === "ENOENT") return [];
2596
- throw error;
2597
- }
2598
- }
2599
2598
  function toPosixRelativePath(rootDir, filePath) {
2600
2599
  return path.relative(rootDir, filePath).split(path.sep).join("/");
2601
2600
  }
@@ -2737,7 +2736,7 @@ async function captureNativeSkillFiles(skill) {
2737
2736
  if (hash.digest("hex") !== skill.folderHash) throw new Error("Local Skill files changed before upload. Sync again with the current files.");
2738
2737
  return files;
2739
2738
  }
2740
- async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PATHS, options = {}) {
2739
+ async function writeCloudSkillToDisk(skill, paths = DEFAULT_SYNC_PATHS, options = {}) {
2741
2740
  if (isNativeSkill(skill)) {
2742
2741
  assertNativePull({
2743
2742
  skills: [{ ...skill, name: "native-" + skill.id }],
@@ -2746,7 +2745,6 @@ async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PA
2746
2745
  sync_enabled: true,
2747
2746
  last_synced_at: null
2748
2747
  });
2749
- if (bundleBytes?.length) throw new Error("Native Skills require their verified complete file response.");
2750
2748
  }
2751
2749
  const skillDir = path.join(
2752
2750
  paths.skillsDir,
@@ -2759,22 +2757,6 @@ async function writeCloudSkillToDisk(skill, bundleBytes, paths = DEFAULT_SYNC_PA
2759
2757
  // An unchanged legacy folder upgrading in place: shared files take the cloud version.
2760
2758
  legacyBaseline: isNativeSkill(skill) && options.legacyBaseline === true && options.expectedFolderHash !== void 0
2761
2759
  };
2762
- if (bundleBytes?.length) {
2763
- const bundlePath = path.join(
2764
- os.tmpdir(),
2765
- `notis-skill-download-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`
2766
- );
2767
- try {
2768
- await fs.writeFile(bundlePath, bundleBytes);
2769
- let appliedFiles = [];
2770
- await replaceSkillDirectoryAtomically(skillDir, async (stagingDir) => {
2771
- appliedFiles = await extractZipToDirectory(bundlePath, stagingDir);
2772
- }, preserve);
2773
- return { written: true, appliedFiles };
2774
- } finally {
2775
- await fs.rm(bundlePath, { force: true });
2776
- }
2777
- }
2778
2760
  if (!skill.skill_md && (!skill.bundle_files || skill.bundle_files.length === 0)) {
2779
2761
  return false;
2780
2762
  }
@@ -2932,14 +2914,6 @@ async function pushChangedSkills(serverUrl, jwt, changedSkills, options = {}) {
2932
2914
  }
2933
2915
  return { skills: saved, ...failed.length ? { failed } : {} };
2934
2916
  }
2935
- async function downloadSkillBundle(bundleUrl) {
2936
- const response = await fetch(bundleUrl, { signal: AbortSignal.timeout(9e4) });
2937
- if (!response.ok) {
2938
- const text = await response.text();
2939
- throw new Error(`GET ${bundleUrl} \u2192 ${response.status}: ${text}`);
2940
- }
2941
- return Buffer.from(await response.arrayBuffer());
2942
- }
2943
2917
  async function updateAgentTargets(serverUrl, jwt, skillId, targets, expectedUpdatedAt, native) {
2944
2918
  if (native) {
2945
2919
  checkedNativeReference(native.reference, skillId);
@@ -3301,25 +3275,7 @@ function getPushCandidates(localSkills, syncState, cloudCuratedSkillNames = /* @
3301
3275
  return { ...skill, ...skill.cloudId || previous?.cloudId ? { cloudId: skill.cloudId || previous.cloudId } : {} };
3302
3276
  });
3303
3277
  }
3304
- async function writeCloudSkillWithBundleFallback(skill, dependencies) {
3305
- if (skill.skill_source_url) {
3306
- try {
3307
- const bundleBytes = await dependencies.downloadSkillBundle(skill.skill_source_url);
3308
- const wroteBundleToDisk = await dependencies.writeCloudSkillToDisk(skill, bundleBytes);
3309
- if (wroteBundleToDisk) {
3310
- return wroteBundleToDisk;
3311
- }
3312
- dependencies.onWarning?.(
3313
- `Bundle sync for "${skill.name}" produced no local changes, falling back to SKILL.md payload.`,
3314
- new Error("Bundle write returned false")
3315
- );
3316
- } catch (error) {
3317
- dependencies.onWarning?.(
3318
- `Failed to apply bundle sync for "${skill.name}", falling back to SKILL.md payload.`,
3319
- error
3320
- );
3321
- }
3322
- }
3278
+ async function writeCloudSkill(skill, dependencies) {
3323
3279
  if (skill.bundle_hydration_failed) {
3324
3280
  dependencies.onWarning?.(
3325
3281
  `Skipping markdown fallback for synced skill "${skill.name}" because its stored bundle could not be hydrated by the server.`,
@@ -3356,7 +3312,6 @@ var DEFAULT_RUN_SKILL_SYNC_DEPS = {
3356
3312
  fetchSyncSettings,
3357
3313
  pullSkills,
3358
3314
  pushChangedSkills,
3359
- downloadSkillBundle,
3360
3315
  gatherTopLevelLocalSkills,
3361
3316
  readLegacySyncState,
3362
3317
  readSyncState,
@@ -3445,7 +3400,10 @@ function cloudContentHash(skill) {
3445
3400
  return createHash4("sha256").update(JSON.stringify({
3446
3401
  md: skill.skill_md,
3447
3402
  hash: skill.skill_folder_hash,
3448
- source: skill.skill_source_url,
3403
+ // A recorded origin is provenance, never content (SKL-059): a URL hashes as null so
3404
+ // it cannot force a rewrite, and an absent or null one hashes as before so stored
3405
+ // hashes stay valid.
3406
+ source: skill.skill_source_url ? null : skill.skill_source_url,
3449
3407
  files: skill.bundle_files?.slice().sort((a, b) => a.path.localeCompare(b.path)),
3450
3408
  hydrationFailed: skill.bundle_hydration_failed === true
3451
3409
  })).digest("hex");
@@ -3518,7 +3476,7 @@ function buildSyncState(pullResponse, localSkills, lastSyncedAt, verifiedAgentLi
3518
3476
  agentTargets: normalizeAgentTargets(skill.agent_targets),
3519
3477
  verifiedAgentLinks: skill.status === "active" ? verifiedAgentLinks[skill.name] ?? {} : {},
3520
3478
  cloudUpdatedAt: skill.updated_at,
3521
- ...!failedContentNames.has(skill.name) && !skill.skill_source_url ? { cloudContentHash: cloudContentHash(skill) } : {},
3479
+ ...!failedContentNames.has(skill.name) ? { cloudContentHash: cloudContentHash(skill) } : {},
3522
3480
  ...appliedCloudFolderHash !== void 0 ? { appliedCloudFolderHash } : {},
3523
3481
  ...appliedFileList !== void 0 ? { appliedFiles: appliedFileList } : {},
3524
3482
  syncedAt: lastSyncedAt || (/* @__PURE__ */ new Date()).toISOString()
@@ -3619,9 +3577,8 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
3619
3577
  }
3620
3578
  continue;
3621
3579
  }
3622
- const outcome = await writeCloudSkillWithBundleFallback(cloudSkill, {
3623
- downloadSkillBundle: deps.downloadSkillBundle,
3624
- writeCloudSkillToDisk: (skill, bundleBytes) => deps.writeCloudSkillToDisk(skill, bundleBytes, syncPaths, {
3580
+ const outcome = await writeCloudSkill(cloudSkill, {
3581
+ writeCloudSkillToDisk: (skill) => deps.writeCloudSkillToDisk(skill, syncPaths, {
3625
3582
  // What the last write put there. Everything else in the folder was
3626
3583
  // produced locally and survives this one.
3627
3584
  previouslyApplied: previouslyAppliedFiles(skill, local, previousState),
@@ -3637,7 +3594,7 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
3637
3594
  appliedFilesByName[cloudSkill.name] = outcome.appliedFiles;
3638
3595
  }
3639
3596
  } else {
3640
- failures.push({ name: cloudSkill.name, error: "Skill content could not be downloaded or written; sync will retry" });
3597
+ failures.push({ name: cloudSkill.name, error: "Skill content could not be written; sync will retry" });
3641
3598
  }
3642
3599
  }
3643
3600
  return downloaded;