@notis_ai/cli 0.2.25 → 0.2.26

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 (157) hide show
  1. package/README.md +186 -5
  2. package/config/notis_app_design_rules.json +36 -14
  3. package/config/portal-route-roots.json +1 -0
  4. package/dist/agent-hooks/notis-agent-hook.mjs +2784 -541
  5. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-cli/references/intelligence.md +1 -1
  7. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  8. package/dist/base-skills/notis-query/SKILL.md +0 -1
  9. package/dist/base-skills/notis-query/references/documents.md +7 -0
  10. package/dist/base-skills/notis-query/references/query.md +1 -0
  11. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  12. package/dist/base-skills/notis-spaces/SKILL.md +96 -24
  13. package/dist/base-skills/notis-spaces/references/architecture.md +4 -3
  14. package/dist/base-skills/notis-spaces/references/design.md +37 -18
  15. package/dist/base-skills/notis-spaces/references/reading.md +8 -1
  16. package/dist/base-skills/notis-spaces/references/reports.md +6 -6
  17. package/dist/base-skills/notis-spaces/references/sdk.md +71 -7
  18. package/dist/base-skills/notis-spaces/references/store.md +22 -13
  19. package/dist/base-skills/notis-spaces/references/views.md +99 -6
  20. package/dist/sdk/package.json +3 -0
  21. package/dist/sdk/src/cloudComputerWords.ts +53 -0
  22. package/dist/sdk/src/components/Audience.tsx +76 -0
  23. package/dist/sdk/src/components/DocumentPage.tsx +15 -4
  24. package/dist/sdk/src/components/MarkdownEditor.tsx +44 -14
  25. package/dist/sdk/src/components/MultiSelectActionBar.tsx +16 -5
  26. package/dist/sdk/src/components/Skeleton.tsx +162 -6
  27. package/dist/sdk/src/hooks/useAction.ts +12 -2
  28. package/dist/sdk/src/hooks/useAgentQueue.ts +125 -0
  29. package/dist/sdk/src/hooks/useCloudComputerJob.ts +142 -0
  30. package/dist/sdk/src/hooks/useCloudComputerService.ts +388 -0
  31. package/dist/sdk/src/hooks/useCloudComputerShell.ts +95 -7
  32. package/dist/sdk/src/hooks/useCollectionInteractions.ts +40 -2
  33. package/dist/sdk/src/hooks/useItemThread.ts +58 -0
  34. package/dist/sdk/src/hooks/useMarqueeSelection.ts +6 -1
  35. package/dist/sdk/src/hooks/useNativeDocuments.ts +61 -8
  36. package/dist/sdk/src/hooks/useNotisNavigation.ts +31 -8
  37. package/dist/sdk/src/hooks/useQuery.ts +67 -10
  38. package/dist/sdk/src/hooks/useViewParams.ts +47 -11
  39. package/dist/sdk/src/index.ts +31 -4
  40. package/dist/sdk/src/interactions.ts +2 -0
  41. package/dist/sdk/src/nativeData.ts +2 -0
  42. package/dist/sdk/src/optimisticRows.ts +329 -0
  43. package/dist/sdk/src/perf.ts +188 -0
  44. package/dist/sdk/src/provider.tsx +2 -1
  45. package/dist/sdk/src/queryCache.ts +366 -17
  46. package/dist/sdk/src/runtime.ts +55 -4
  47. package/dist/sdk/src/skeleton.ts +103 -0
  48. package/dist/sdk/src/space.ts +662 -28
  49. package/dist/sdk/src/spacePublicUI.ts +36 -0
  50. package/dist/sdk/src/ui/engine/step.ts +54 -0
  51. package/dist/sdk/src/ui/icons.tsx +3 -1
  52. package/dist/sdk/src/words/shell.ts +1 -0
  53. package/dist/skill-sync/index.js +7 -2
  54. package/dist/skill-sync-worker.mjs +40 -26
  55. package/dist/space-harness/host.js +272 -105
  56. package/dist/space-sdk/dist/chunk-BWHAORT4.js +5 -0
  57. package/dist/space-sdk/dist/index.js +9 -4
  58. package/dist/space-sdk/dist/ui.js +12 -12
  59. package/dist/space-sdk/package.json +3 -0
  60. package/dist/space-sdk/src/cloudComputerWords.d.ts +34 -0
  61. package/dist/space-sdk/src/components/Audience.d.ts +46 -0
  62. package/dist/space-sdk/src/components/DocumentPage.d.ts +3 -1
  63. package/dist/space-sdk/src/components/MarkdownEditor.d.ts +21 -0
  64. package/dist/space-sdk/src/components/MultiSelectActionBar.d.ts +5 -1
  65. package/dist/space-sdk/src/components/Skeleton.d.ts +7 -2
  66. package/dist/space-sdk/src/hooks/useAction.d.ts +8 -1
  67. package/dist/space-sdk/src/hooks/useAgentQueue.d.ts +61 -0
  68. package/dist/space-sdk/src/hooks/useCloudComputerJob.d.ts +35 -0
  69. package/dist/space-sdk/src/hooks/useCloudComputerService.d.ts +75 -0
  70. package/dist/space-sdk/src/hooks/useCloudComputerShell.d.ts +36 -3
  71. package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +6 -0
  72. package/dist/space-sdk/src/hooks/useItemThread.d.ts +32 -0
  73. package/dist/space-sdk/src/hooks/useMarqueeSelection.d.ts +2 -1
  74. package/dist/space-sdk/src/hooks/useNativeDocumentBody.d.ts +1 -0
  75. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +20 -5
  76. package/dist/space-sdk/src/hooks/useNotisNavigation.d.ts +11 -2
  77. package/dist/space-sdk/src/hooks/useQuery.d.ts +24 -2
  78. package/dist/space-sdk/src/hooks/useViewParams.d.ts +2 -0
  79. package/dist/space-sdk/src/index.d.ts +24 -4
  80. package/dist/space-sdk/src/nativeData.d.ts +6 -0
  81. package/dist/space-sdk/src/queryCache.d.ts +97 -2
  82. package/dist/space-sdk/src/runtime.d.ts +53 -4
  83. package/dist/space-sdk/src/skeleton.d.ts +42 -0
  84. package/dist/space-sdk/src/space.ts +662 -28
  85. package/dist/space-sdk/src/tailwind-candidates.d.ts +754 -5
  86. package/dist/space-sdk/src/ui/cloud/CloudComputerFrame.d.ts +29 -0
  87. package/dist/space-sdk/src/ui/cloud/CloudComputerWaking.d.ts +20 -0
  88. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +15 -2
  89. package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +50 -0
  90. package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +64 -0
  91. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +49 -1
  92. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +26 -0
  93. package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
  94. package/dist/space-sdk/src/ui/comments/passageModel.d.ts +82 -0
  95. package/dist/space-sdk/src/ui/comments/useComments.d.ts +34 -4
  96. package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +67 -0
  97. package/dist/space-sdk/src/ui/engine/index.d.ts +2 -2
  98. package/dist/space-sdk/src/ui/engine/step.d.ts +9 -0
  99. package/dist/space-sdk/src/ui/fields/fields.d.ts +2 -1
  100. package/dist/space-sdk/src/ui/index.d.ts +4 -0
  101. package/dist/space-sdk/src/ui/layout/Panels.d.ts +9 -2
  102. package/dist/space-sdk/src/ui/layout/SidePane.d.ts +42 -0
  103. package/dist/space-sdk/src/ui/layout/index.d.ts +2 -1
  104. package/dist/space-sdk/src/ui/layout/panelMath.d.ts +11 -2
  105. package/dist/space-sdk/src/ui/list/ListReader.d.ts +38 -7
  106. package/dist/space-sdk/src/ui/list/Row.d.ts +4 -0
  107. package/dist/space-sdk/src/ui/list/SelectionBar.d.ts +9 -4
  108. package/dist/space-sdk/src/ui/list/useListKeys.d.ts +4 -0
  109. package/dist/space-sdk/src/words/shell.ts +1 -0
  110. package/dist/view-renderer/dist/host.js +355 -188
  111. package/dist/view-renderer/dist/theme.css +1 -1
  112. package/dist/view-renderer/src/host.tsx +4 -1
  113. package/dist/view-renderer/src/index.js +3 -0
  114. package/dist/view-renderer/src/pool.js +8 -4
  115. package/dist/view-renderer/src/renderer.js +92 -23
  116. package/dist/view-renderer/src/skeleton.js +450 -0
  117. package/package.json +4 -4
  118. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +8 -4
  119. package/skills/notis-onboarding/BRIEF.md +15 -9
  120. package/skills/notis-spaces/cli.md +43 -4
  121. package/src/command-specs/auth.js +5 -3
  122. package/src/command-specs/cc.js +410 -0
  123. package/src/command-specs/computer.js +320 -0
  124. package/src/command-specs/diagnostics.js +2 -13
  125. package/src/command-specs/documents.js +22 -4
  126. package/src/command-specs/index.js +7 -0
  127. package/src/command-specs/onboarding.js +127 -7
  128. package/src/command-specs/skills.js +2 -2
  129. package/src/command-specs/spaces.js +162 -30
  130. package/src/command-specs/tools.js +26 -8
  131. package/src/command-specs/views.js +4 -1
  132. package/src/runtime/agent-setup.js +20 -2
  133. package/src/runtime/app-boundary-validator.js +2 -1
  134. package/src/runtime/app-platform.js +13 -0
  135. package/src/runtime/auth-recovery.js +5 -0
  136. package/src/runtime/channel.js +16 -2
  137. package/src/runtime/cloud-transfer.js +587 -0
  138. package/src/runtime/computer-ssh.js +127 -0
  139. package/src/runtime/oauth.js +50 -4
  140. package/src/runtime/skill-sync/index.ts +20 -1
  141. package/src/runtime/skill-sync/local-scanner.ts +1 -0
  142. package/src/runtime/skill-sync/types.ts +2 -0
  143. package/src/runtime/space-audience.js +94 -0
  144. package/src/runtime/space-collection-scaffold.js +2 -1
  145. package/src/runtime/space-fixture-broker.js +2 -1
  146. package/src/runtime/space-lock.js +1 -4
  147. package/src/runtime/space-platform.js +18 -2
  148. package/src/runtime/space-source.js +105 -7
  149. package/src/runtime/space-test-server.js +13 -2
  150. package/src/runtime/space-verification.js +99 -6
  151. package/src/runtime/space-view-manifest.js +22 -4
  152. package/src/runtime/sync-skills.js +24 -20
  153. package/src/runtime/transport.js +19 -0
  154. package/src/runtime/view-render.js +2 -2
  155. package/template/.harness/index.html.tmpl +1 -1
  156. package/dist/skill-sync/index.js.map +0 -7
  157. package/dist/space-sdk/dist/chunk-SVZATGZB.js +0 -5
@@ -0,0 +1,36 @@
1
+ import { createElement } from 'react';
2
+ import type { NotisDocumentEditorProps, NotisDocumentPageProps, NotisRuntimeUI } from './runtime';
3
+ import type { SpacePublicRecordUI } from './space';
4
+
5
+ /**
6
+ * A DocumentPage `properties` choice with these editor-only properties left out. A chosen `include` list is filtered
7
+ * case-insensitively; otherwise they are excluded by name, which the host matches exactly, so the names passed are the
8
+ * declared ones plus the real names the page has seen in rows and schemas.
9
+ */
10
+ export function publicDocumentPageProperties(option: NotisDocumentPageProps['properties'], names: readonly string[]): NotisDocumentPageProps['properties'] {
11
+ if (option === 'hidden' || !names.length) return option;
12
+ const hidden = new Set(names.map(name => name.toLowerCase()));
13
+ const chosen = option && option !== 'panel' ? option : {};
14
+ return { ...chosen,
15
+ ...(chosen.include ? { include: chosen.include.filter(name => !hidden.has(name.toLowerCase())) } : {}),
16
+ exclude: [...new Set([...(chosen.exclude ?? []), ...names])] };
17
+ }
18
+
19
+ /**
20
+ * The host record components while an editor views the Space as the public. They read and write with the editor's
21
+ * authority, so what they draw is held to the public floor here: a document page leaves the editor-only properties
22
+ * out, a document editor shows no properties, and the properties form (which cannot leave single properties out) is
23
+ * not drawn. The title stays: the host does not say which column is the record's title.
24
+ */
25
+ export const publicRecordUI: SpacePublicRecordUI = (ui, columns): NotisRuntimeUI => {
26
+ const { DocumentPage, DocumentEditor } = ui;
27
+ return { ...ui,
28
+ DocumentPage: DocumentPage ? function PublicDocumentPage(props: NotisDocumentPageProps) {
29
+ return createElement(DocumentPage, { ...props, properties: publicDocumentPageProperties(props.properties, columns()) });
30
+ } : undefined,
31
+ DocumentEditor: DocumentEditor ? function PublicDocumentEditor(props: NotisDocumentEditorProps) {
32
+ return createElement(DocumentEditor, { ...props, showProperties: false });
33
+ } : undefined,
34
+ RecordProperties: undefined,
35
+ };
36
+ };
@@ -0,0 +1,54 @@
1
+ export interface StepOptions {
2
+ /** Wrap from the last item to the first (and back). Default true. */
3
+ wrap?: boolean;
4
+ /** The key is held (`event.repeat`): never wrap, stop at the edge. */
5
+ repeat?: boolean;
6
+ }
7
+
8
+ /**
9
+ * Next cursor id for J/K stepping. Wraps only on a fresh press, so holding J stops at the last row instead of
10
+ * spinning back to the top. No cursor: J lands on the first item, K on the last.
11
+ */
12
+ export function stepCursor(ids: readonly string[], cursor: string | null | undefined, delta: number,
13
+ options: StepOptions = {}): string | null {
14
+ if (!ids.length) return null;
15
+ const { wrap = true, repeat = false } = options;
16
+ const index = cursor == null ? -1 : ids.indexOf(cursor);
17
+ if (index === -1) return delta >= 0 ? ids[0]! : ids[ids.length - 1]!;
18
+ let next = index + delta;
19
+ if (next < 0 || next >= ids.length) {
20
+ if (wrap && !repeat) next = ((next % ids.length) + ids.length) % ids.length;
21
+ else next = Math.max(0, Math.min(ids.length - 1, next));
22
+ }
23
+ return ids[next]!;
24
+ }
25
+
26
+ /** The way the cursor last moved through a list. A removal continues that way (iOS Photos). */
27
+ export type TravelDirection = 'next' | 'previous';
28
+
29
+ /** The way a move from `from` to `to` went in `ids`; null when either is not in the list or nothing moved. */
30
+ export function travelBetween(ids: readonly string[], from: string | null | undefined,
31
+ to: string | null | undefined): TravelDirection | null {
32
+ if (from == null || to == null || from === to) return null;
33
+ const a = ids.indexOf(from);
34
+ const b = ids.indexOf(to);
35
+ if (a === -1 || b === -1) return null;
36
+ return b > a ? 'next' : 'previous';
37
+ }
38
+
39
+ /**
40
+ * The id that takes `gone`'s place after it left `previous` (`now` holds the ids still listed): the nearest one still
41
+ * there in the travel direction, else the nearest the other way. Null when none is left.
42
+ */
43
+ export function continuationOf(previous: readonly string[], now: readonly string[] | ReadonlySet<string>,
44
+ gone: string, direction: TravelDirection = 'next'): string | null {
45
+ const present = now instanceof Set ? now : new Set(now as readonly string[]);
46
+ const index = previous.indexOf(gone);
47
+ if (index === -1) return null;
48
+ const scan = (delta: number) => {
49
+ for (let i = index + delta; i >= 0 && i < previous.length; i += delta) if (present.has(previous[i]!)) return previous[i]!;
50
+ return null;
51
+ };
52
+ const first = direction === 'next' ? 1 : -1;
53
+ return scan(first) ?? scan(-first);
54
+ }
@@ -47,7 +47,8 @@ const SHAPES: Record<string, Shape> = {
47
47
  hourglass: <path {...S} d="M4 2.5h8M4 13.5h8M5 2.5c0 3 6 3.5 6 5.5s-6 2.5-6 5.5M11 2.5c0 3-6 3.5-6 5.5s6 2.5 6 5.5" />,
48
48
  'arrow-counter-clockwise': <path {...S} d="M4.5 6H2V3.5M2.3 6A6 6 0 112 9" />,
49
49
  'arrow-clockwise': <path {...S} d="M11.5 6H14V3.5M13.7 6A6 6 0 1 0 14 9" />,
50
- 'arrows-clockwise': <path {...S} d="M3 6a5.4 5.4 0 0110 0M13 3v3h-3M13 10a5.4 5.4 0 01-10 0M3 13v-3h3" />,
50
+ 'arrows-left-right': <path {...S} d="M11 2.5l2.5 2.5L11 7.5M13.5 5h-11M5 8.5L2.5 11 5 13.5M2.5 11h11" />,
51
+ 'arrows-clockwise':<path {...S} d="M3 6a5.4 5.4 0 0110 0M13 3v3h-3M13 10a5.4 5.4 0 01-10 0M3 13v-3h3" />,
51
52
  plus: <path {...S} d="M8 3v10M3 8h10" />,
52
53
  'circle-dashed': <circle {...S} cx="8" cy="8" r="6" strokeDasharray="2.2 2.2" />,
53
54
  circle: <circle {...S} cx="8" cy="8" r="6" />,
@@ -61,6 +62,7 @@ const SHAPES: Record<string, Shape> = {
61
62
  'magnifying-glass-plus': <path {...S} d="M7 12A5 5 0 107 2a5 5 0 000 10zM10.6 10.6L14 14M5 7h4M7 5v4" />,
62
63
  'magnifying-glass-minus': <path {...S} d="M7 12A5 5 0 107 2a5 5 0 000 10zM10.6 10.6L14 14M5 7h4" />,
63
64
  '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
+ info: <g {...S}><circle cx="8" cy="8" r="6.5" /><path d="M8 7.5V11M8 5.25v.01" /></g>,
64
66
  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" />,
65
67
  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" />,
66
68
  '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>,
@@ -23,6 +23,7 @@ export const SHELL_WORDS = Object.freeze({
23
23
  tryAgain: { en: 'Try again', fr: 'Réessayer' },
24
24
  selectedOne: { en: '1 selected', fr: '1 sélectionné' },
25
25
  selectedMany: { en: '{n} selected', fr: '{n} sélectionnés' },
26
+ moreNotLoaded: { en: 'more not loaded', fr: 'suite non chargée' },
26
27
  sidePeek: { en: 'Side peek', fr: 'Aperçu latéral' },
27
28
  centerPeek: { en: 'Center peek', fr: 'Aperçu centré' },
28
29
  fullPage: { en: 'Full page', fr: 'Pleine page' },
@@ -660,6 +660,7 @@ async function scanLocalSkills(paths = DEFAULT_SYNC_PATHS) {
660
660
  nativeScope: identity.scope,
661
661
  nativeBaseFolderHash: identity.folderHash,
662
662
  nativeFilesCurrent: current,
663
+ nativeManagedFiles: [...Object.keys(identity.files), NATIVE_IDENTITY_FILE].sort(),
663
664
  displayName: editedName && editedName !== identity.frontmatterName ? editedName : identity.displayName
664
665
  });
665
666
  }
@@ -1795,6 +1796,11 @@ function applyLegacyFirstRunState(localSkills, scopedState, legacyState) {
1795
1796
  skills: migratedSkills
1796
1797
  };
1797
1798
  }
1799
+ function previouslyAppliedFiles(skill, local, previousState) {
1800
+ const recorded = previousNativeState(previousState, skill)?.appliedFiles;
1801
+ if (recorded || !isNativeSkill(skill) || !local?.nativeManagedFiles) return recorded;
1802
+ return local.nativeFilesCurrent === true && local.cloudId === skill.id && local.folderHash === local.nativeBaseFolderHash ? local.nativeManagedFiles : void 0;
1803
+ }
1798
1804
  async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previousState, syncPaths, deps, failures = [], writtenSkillNames = /* @__PURE__ */ new Set(), appliedFilesByName = {}, acknowledgedNative = /* @__PURE__ */ new Map()) {
1799
1805
  const localSkillMap = toSkillMap(localSkills);
1800
1806
  const warnSkillSync = (message, error) => {
@@ -1816,7 +1822,7 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
1816
1822
  writeCloudSkillToDisk: (skill, bundleBytes) => deps.writeCloudSkillToDisk(skill, bundleBytes, syncPaths, {
1817
1823
  // What the last write put there. Everything else in the folder was
1818
1824
  // produced locally and survives this one.
1819
- previouslyApplied: previousNativeState(previousState, skill)?.appliedFiles,
1825
+ previouslyApplied: previouslyAppliedFiles(skill, local, previousState),
1820
1826
  ...isNativeSkill(skill) && local ? { expectedFolderHash: local.folderHash } : {},
1821
1827
  ...legacyBaseline ? { legacyBaseline } : {}
1822
1828
  }),
@@ -2206,4 +2212,3 @@ export {
2206
2212
  runSkillSync,
2207
2213
  shouldWriteCloudSkill
2208
2214
  };
2209
- //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@ import { join as join8 } from "node:path";
6
6
 
7
7
  // src/runtime/profiles.js
8
8
  import {
9
- existsSync as existsSync2,
9
+ existsSync as existsSync3,
10
10
  mkdirSync as mkdirSync2,
11
11
  readFileSync as readFileSync2,
12
12
  renameSync as renameSync2,
@@ -153,6 +153,8 @@ function withConfigFileWriteLock(configFile, callback) {
153
153
  }
154
154
 
155
155
  // src/runtime/channel.js
156
+ import { existsSync as existsSync2 } from "node:fs";
157
+ import { isAbsolute } from "node:path";
156
158
  var RELEASE_CHANNELS = ["stable", "nightly"];
157
159
  var CHANNEL_TAGS = { stable: "latest", nightly: "nightly" };
158
160
  var API_HOST_CHANNELS = {
@@ -179,8 +181,14 @@ function channelFromApiBase(apiBase) {
179
181
  function packageTagForChannel(channel) {
180
182
  return CHANNEL_TAGS[channel] || CHANNEL_TAGS.stable;
181
183
  }
182
- function cliCommandForChannel(channel) {
183
- return `npx --package ${CLI_PACKAGE_NAME}@${packageTagForChannel(channel)} -- notis`;
184
+ var CLI_LAUNCHER_ENV = "NOTIS_CLI_LAUNCHER";
185
+ function installedLauncher(env = process.env) {
186
+ const value = env[CLI_LAUNCHER_ENV];
187
+ if (typeof value !== "string" || !isAbsolute(value) || !existsSync2(value)) return null;
188
+ return /^[A-Za-z0-9_./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'"'"'`)}'`;
189
+ }
190
+ function cliCommandForChannel(channel, env = process.env) {
191
+ return installedLauncher(env) || `npx --package ${CLI_PACKAGE_NAME}@${packageTagForChannel(channel)} -- notis`;
184
192
  }
185
193
  function pinnedReleaseChannel(profile = {}) {
186
194
  if (profile.beta === true) return "nightly";
@@ -353,7 +361,7 @@ function findUp(filename, startDir = process.cwd(), boundary = null) {
353
361
  const root = parse(current).root;
354
362
  while (true) {
355
363
  const candidate = join2(current, filename);
356
- if (existsSync2(candidate)) {
364
+ if (existsSync3(candidate)) {
357
365
  return candidate;
358
366
  }
359
367
  if (current === root || current === boundary) {
@@ -437,7 +445,7 @@ function resolveConfigFile() {
437
445
  }
438
446
  function loadConfig() {
439
447
  const configFile = resolveConfigFile();
440
- if (!existsSync2(configFile)) {
448
+ if (!existsSync3(configFile)) {
441
449
  return normalizeConfig({});
442
450
  }
443
451
  try {
@@ -1466,7 +1474,7 @@ function lockIsStale() {
1466
1474
  return false;
1467
1475
  }
1468
1476
  }
1469
- async function acquireRefreshLock(runtime, waitMs = OAUTH_REFRESH_LOCK_WAIT_MS) {
1477
+ async function acquireRefreshLock(runtime, staleAccessToken, waitMs = OAUTH_REFRESH_LOCK_WAIT_MS) {
1470
1478
  mkdirSync4(join4(homedir3(), ".notis"), { recursive: true });
1471
1479
  const deadline = Date.now() + waitMs;
1472
1480
  for (; ; ) {
@@ -1476,7 +1484,7 @@ async function acquireRefreshLock(runtime, waitMs = OAUTH_REFRESH_LOCK_WAIT_MS)
1476
1484
  } catch (error) {
1477
1485
  if (error?.code !== "EEXIST") throw error;
1478
1486
  const profile = getProfile(loadConfig(), runtime.profileName);
1479
- if (profile.oauth_access_token && profile.oauth_access_token !== runtime.oauthAccessToken && !credentialIsExpired({ credentialKind: "oauth" }, profile)) {
1487
+ if (profile.oauth_access_token && profile.oauth_access_token !== staleAccessToken && !credentialIsExpired({ credentialKind: "oauth" }, profile)) {
1480
1488
  updateRuntimeFromOAuthProfile(runtime, profile);
1481
1489
  return false;
1482
1490
  }
@@ -1509,6 +1517,7 @@ function keepLockFoldersFresh(paths) {
1509
1517
  return () => clearInterval(interval);
1510
1518
  }
1511
1519
  async function refreshOAuthCredential(runtime, fetchImpl = fetch, tokenRequestOptions = {}) {
1520
+ const staleAccessToken = runtime.oauthAccessToken;
1512
1521
  const globalLock = await acquireListenerGlobalLock({ waitMs: OAUTH_REFRESH_LOCK_WAIT_MS });
1513
1522
  let profileLock = null;
1514
1523
  let ownsLock = false;
@@ -1517,13 +1526,13 @@ async function refreshOAuthCredential(runtime, fetchImpl = fetch, tokenRequestOp
1517
1526
  let metadata = null;
1518
1527
  try {
1519
1528
  profileLock = await acquireListenerStartLock(runtime);
1520
- ownsLock = await acquireRefreshLock(runtime);
1529
+ ownsLock = await acquireRefreshLock(runtime, staleAccessToken);
1521
1530
  if (!ownsLock) return true;
1522
1531
  stopTouchingLocks = keepLockFoldersFresh([profileLock, oauthLockDir()]);
1523
1532
  const config = loadConfig();
1524
1533
  const profile = getProfile(config, runtime.profileName);
1525
1534
  assertOAuthApiTarget(runtime, profile);
1526
- if (profile.oauth_access_token && profile.oauth_access_token !== runtime.oauthAccessToken && !credentialIsExpired({ credentialKind: "oauth" }, profile)) {
1535
+ if (profile.oauth_access_token && profile.oauth_access_token !== staleAccessToken && !credentialIsExpired({ credentialKind: "oauth" }, profile)) {
1527
1536
  updateRuntimeFromOAuthProfile(runtime, profile);
1528
1537
  return true;
1529
1538
  }
@@ -2250,6 +2259,7 @@ async function scanLocalSkills(paths = DEFAULT_SYNC_PATHS) {
2250
2259
  nativeScope: identity.scope,
2251
2260
  nativeBaseFolderHash: identity.folderHash,
2252
2261
  nativeFilesCurrent: current,
2262
+ nativeManagedFiles: [...Object.keys(identity.files), NATIVE_IDENTITY_FILE].sort(),
2253
2263
  displayName: editedName && editedName !== identity.frontmatterName ? editedName : identity.displayName
2254
2264
  });
2255
2265
  }
@@ -3371,6 +3381,11 @@ function applyLegacyFirstRunState(localSkills, scopedState, legacyState) {
3371
3381
  skills: migratedSkills
3372
3382
  };
3373
3383
  }
3384
+ function previouslyAppliedFiles(skill, local, previousState) {
3385
+ const recorded = previousNativeState(previousState, skill)?.appliedFiles;
3386
+ if (recorded || !isNativeSkill(skill) || !local?.nativeManagedFiles) return recorded;
3387
+ return local.nativeFilesCurrent === true && local.cloudId === skill.id && local.folderHash === local.nativeBaseFolderHash ? local.nativeManagedFiles : void 0;
3388
+ }
3374
3389
  async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previousState, syncPaths, deps, failures = [], writtenSkillNames = /* @__PURE__ */ new Set(), appliedFilesByName = {}, acknowledgedNative = /* @__PURE__ */ new Map()) {
3375
3390
  const localSkillMap = toSkillMap(localSkills);
3376
3391
  const warnSkillSync = (message, error) => {
@@ -3392,7 +3407,7 @@ async function writePulledSkillsToScopedMirror(pullResponse, localSkills, previo
3392
3407
  writeCloudSkillToDisk: (skill, bundleBytes) => deps.writeCloudSkillToDisk(skill, bundleBytes, syncPaths, {
3393
3408
  // What the last write put there. Everything else in the folder was
3394
3409
  // produced locally and survives this one.
3395
- previouslyApplied: previousNativeState(previousState, skill)?.appliedFiles,
3410
+ previouslyApplied: previouslyAppliedFiles(skill, local, previousState),
3396
3411
  ...isNativeSkill(skill) && local ? { expectedFolderHash: local.folderHash } : {},
3397
3412
  ...legacyBaseline ? { legacyBaseline } : {}
3398
3413
  }),
@@ -3750,11 +3765,20 @@ async function quarantineStaleLock(lockDirectory, snapshot) {
3750
3765
  throw error;
3751
3766
  }
3752
3767
  }
3753
- async function writeLockOwnerAtomically(lockDirectory, owner) {
3754
- const temporaryOwnerPath = join7(lockDirectory, `.owner.${owner.id}.tmp`);
3755
- const ownerPath = join7(lockDirectory, "owner");
3756
- await writeFile(temporaryOwnerPath, JSON.stringify(owner), { mode: 384 });
3757
- await rename(temporaryOwnerPath, ownerPath);
3768
+ async function publishOwnedLock(lockDirectory, owner) {
3769
+ const quarantineRoot = join7(dirname7(lockDirectory), ".stale-operation-locks");
3770
+ const staging = join7(quarantineRoot, `staging.${owner.id}`);
3771
+ await mkdir(quarantineRoot, { recursive: true, mode: 448 });
3772
+ await mkdir(staging, { mode: 448 });
3773
+ try {
3774
+ await writeFile(join7(staging, "owner"), JSON.stringify(owner), { mode: 384 });
3775
+ await rename(staging, lockDirectory);
3776
+ } catch (error) {
3777
+ await rm(staging, { recursive: true, force: true });
3778
+ const held = ["EEXIST", "ENOTEMPTY"].includes(error?.code) || error?.code === "EPERM" && await lockSnapshot(lockDirectory) !== null;
3779
+ if (held) throw Object.assign(new Error("Lock held."), { code: "EEXIST" });
3780
+ throw error;
3781
+ }
3758
3782
  }
3759
3783
  async function releaseOwnedLock(lockDirectory, ownerId) {
3760
3784
  const owner = await lockSnapshot(lockDirectory);
@@ -3783,17 +3807,7 @@ async function withSkillSyncLock(callback, {
3783
3807
  await mkdir(dirname7(lockDirectory), { recursive: true, mode: 448 });
3784
3808
  for (; ; ) {
3785
3809
  try {
3786
- await mkdir(lockDirectory, { mode: 448 });
3787
- try {
3788
- await writeLockOwnerAtomically(lockDirectory, {
3789
- id: ownerId,
3790
- pid: process.pid,
3791
- at: now()
3792
- });
3793
- } catch (error) {
3794
- await rm(lockDirectory, { recursive: true, force: true });
3795
- throw error;
3796
- }
3810
+ await publishOwnedLock(lockDirectory, { id: ownerId, pid: process.pid, at: now() });
3797
3811
  break;
3798
3812
  } catch (error) {
3799
3813
  if (error?.code !== "EEXIST") throw error;