@notis_ai/cli 0.2.30 → 0.2.31
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 +1 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +37890 -10794
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/references/query.md +6 -4
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +8 -3
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
- package/dist/base-skills/notis-spaces/references/design.md +7 -1
- package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
- package/dist/base-skills/notis-spaces/references/sdk.md +90 -31
- package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
- package/dist/base-skills/notis-spaces/references/views.md +20 -0
- package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
- package/dist/sdk/src/index.ts +1 -1
- package/dist/sdk/src/space.ts +3 -1
- package/dist/sdk/src/tailwind.ts +53 -3
- package/dist/sdk/src/ui/icons.tsx +1 -0
- package/dist/sdk/src/words/types.ts +28 -0
- package/dist/skill-sync/index.js +10 -90
- package/dist/skill-sync-worker.mjs +50 -93
- package/dist/space-harness/host.js +150 -81
- package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
- package/dist/space-sdk/dist/index.js +2 -2
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
- package/dist/space-sdk/src/index.d.ts +1 -1
- package/dist/space-sdk/src/space.ts +3 -1
- package/dist/space-sdk/src/tailwind-candidates.d.ts +273 -2
- package/dist/space-sdk/src/tailwind.ts +53 -3
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
- package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
- package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
- package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
- package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
- package/dist/space-sdk/src/ui/index.d.ts +4 -2
- package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
- package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
- package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
- package/dist/space-sdk/src/words/types.ts +28 -0
- package/dist/view-renderer/dist/host.js +219 -150
- package/dist/view-renderer/src/dom.js +3 -2
- package/dist/view-renderer/src/errors.js +9 -0
- package/dist/view-renderer/src/host.tsx +12 -5
- package/dist/view-renderer/src/remote-broker.js +3 -1
- package/dist/view-renderer/src/renderer.js +63 -16
- package/dist/view-renderer/src/skeleton.js +70 -18
- package/package.json +5 -4
- package/skills/notis-query/cli.md +3 -0
- package/src/command-specs/spaces.js +71 -15
- package/src/command-specs/tools.js +3 -0
- package/src/runtime/api-hosts.generated.js +35 -0
- package/src/runtime/api-hosts.js +27 -10
- package/src/runtime/app-platform.js +68 -24
- package/src/runtime/http-agent.js +53 -0
- package/src/runtime/native-record-files.js +11 -0
- package/src/runtime/oauth.js +2 -1
- package/src/runtime/skill-sync/cloud-client.ts +0 -10
- package/src/runtime/skill-sync/index.ts +13 -15
- package/src/runtime/skill-sync/local-scanner.ts +0 -67
- package/src/runtime/skill-sync/types.ts +1 -0
- package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
- package/src/runtime/space-dependencies.js +66 -0
- package/src/runtime/space-fixture-broker.js +23 -8
- package/src/runtime/space-platform.js +47 -3
- package/src/runtime/space-source.js +10 -1
- package/src/runtime/space-test-server.js +105 -6
- package/src/runtime/space-verification.js +103 -43
- package/src/runtime/space-view-manifest.js +38 -5
- package/src/runtime/transport.js +19 -4
- package/src/runtime/view-render.js +4 -1
- package/template/tailwind.config.ts +2 -35
- package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
|
@@ -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 };
|
package/dist/skill-sync/index.js
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
|
1890
|
-
|
|
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
|
|
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
|
|
162
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
|
3623
|
-
|
|
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
|
|
3597
|
+
failures.push({ name: cloudSkill.name, error: "Skill content could not be written; sync will retry" });
|
|
3641
3598
|
}
|
|
3642
3599
|
}
|
|
3643
3600
|
return downloaded;
|