@notis_ai/cli 0.2.26 → 0.2.28

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 (51) hide show
  1. package/README.md +2 -2
  2. package/config/notis_app_design_rules.json +5 -123
  3. package/dist/agent-hooks/notis-agent-hook.mjs +84 -14
  4. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  5. package/dist/base-skills/notis-spaces/SKILL.md +13 -19
  6. package/dist/base-skills/notis-spaces/references/context.md +3 -0
  7. package/dist/base-skills/notis-spaces/references/design.md +11 -45
  8. package/dist/base-skills/notis-spaces/references/sdk.md +86 -67
  9. package/dist/base-skills/notis-spaces/references/views.md +12 -1
  10. package/dist/sdk/src/components/NotisCommentBoundary.tsx +43 -16
  11. package/dist/sdk/src/components/NotisSelectionBoundary.tsx +105 -26
  12. package/dist/sdk/src/components/SelectionActionBar.tsx +262 -0
  13. package/dist/sdk/src/hooks/useCollectionInteractions.ts +5 -2
  14. package/dist/sdk/src/space.ts +4 -0
  15. package/dist/sdk/src/ui/icons.tsx +11 -2
  16. package/dist/sdk/src/words/actions.ts +9 -1
  17. package/dist/sdk/src/words/keymap.ts +3 -0
  18. package/dist/skill-sync/index.js +81 -11
  19. package/dist/skill-sync-worker.mjs +87 -12
  20. package/dist/space-harness/host.js +172 -134
  21. package/dist/space-sdk/dist/{chunk-BWHAORT4.js → chunk-BFGB6XXC.js} +2 -2
  22. package/dist/space-sdk/dist/index.js +2 -2
  23. package/dist/space-sdk/dist/ui.js +14 -11
  24. package/dist/space-sdk/src/components/NotisSelectionBoundary.d.ts +26 -2
  25. package/dist/space-sdk/src/space.ts +4 -0
  26. package/dist/space-sdk/src/tailwind-candidates.d.ts +124 -14
  27. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +86 -0
  28. package/dist/space-sdk/src/ui/blocks/InfoTip.d.ts +25 -0
  29. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +39 -0
  30. package/dist/space-sdk/src/ui/blocks/blocks.d.ts +1 -1
  31. package/dist/space-sdk/src/ui/blocks/index.d.ts +6 -0
  32. package/dist/space-sdk/src/ui/charts/Chart.d.ts +15 -2
  33. package/dist/space-sdk/src/ui/charts/StatRow.d.ts +4 -3
  34. package/dist/space-sdk/src/ui/charts/chartData.d.ts +6 -0
  35. package/dist/space-sdk/src/ui/icons.d.ts +1 -1
  36. package/dist/space-sdk/src/ui/index.d.ts +2 -2
  37. package/dist/space-sdk/src/ui/list/Row.d.ts +10 -3
  38. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +14 -0
  39. package/dist/space-sdk/src/words/actions.ts +9 -1
  40. package/dist/space-sdk/src/words/keymap.ts +3 -0
  41. package/dist/view-renderer/dist/host.js +243 -205
  42. package/dist/view-renderer/src/dom.js +15 -2
  43. package/package.json +3 -3
  44. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +1 -1
  45. package/src/command-specs/computer.js +3 -3
  46. package/src/runtime/skill-sync/cloud-client.ts +98 -15
  47. package/src/runtime/skill-sync/index.ts +22 -3
  48. package/src/runtime/skill-sync/types.ts +4 -0
  49. package/src/skill-sync-worker.js +5 -1
  50. package/template/components/ui/button.tsx +1 -1
  51. package/template/components/ui/native-select.tsx +1 -1
@@ -62,9 +62,10 @@ export function extractRenderedMarkdown({ baseUrl = document.baseURI } = {}) {
62
62
  flush();
63
63
  return '\n\n' + lines.join('\n') + '\n\n';
64
64
  };
65
+ let skipped = null;
65
66
  function walk(node) {
66
67
  if (node.nodeType === Node.TEXT_NODE) return node.textContent || '';
67
- if (node.nodeType !== Node.ELEMENT_NODE) return '';
68
+ if (node.nodeType !== Node.ELEMENT_NODE || node === skipped) return '';
68
69
  const tag = node.tagName;
69
70
  if (['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'LINK', 'META'].includes(tag)) return '';
70
71
  const semantic = node.getAttribute('data-notis-render');
@@ -100,7 +101,19 @@ export function extractRenderedMarkdown({ baseUrl = document.baseURI } = {}) {
100
101
  const content = children(node);
101
102
  return ['P', 'DIV', 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER', 'MAIN', 'UL', 'OL', 'FIGURE'].includes(tag) ? '\n\n' + content + '\n\n' : content;
102
103
  }
103
- return walk(document.body).replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
104
+ const tidy = value => value.replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
105
+ // A link that opens one item of a list (the SDK ListReader's reader) is a link to that item: its
106
+ // Markdown comes first, then the rest of the page. A reader that keeps only the start of a long
107
+ // page (a voice call keeps 12,000 characters) otherwise got the list and never the item.
108
+ const shown = node => {
109
+ for (let current = node; current; current = current.parentElement) if (!visible(current)) return false;
110
+ return node.getClientRects().length > 0;
111
+ };
112
+ const reader = [...document.querySelectorAll('.nui-lr-reader-body')].find(shown);
113
+ if (!reader) return tidy(walk(document.body));
114
+ const item = walk(reader);
115
+ skipped = reader;
116
+ return tidy(item + '\n\n' + walk(document.body));
104
117
  }
105
118
 
106
119
  /** Bounded capture expands clipped content; no 1500px crop or hidden inner scroll tail. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notis_ai/cli",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "Agent-first Notis CLI for Spaces, Skills and generic tool execution",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,8 +52,8 @@
52
52
  "react-dom": "19.3.0"
53
53
  },
54
54
  "notisRelease": {
55
- "sourceSha": "c068b2d7889470bec2210030c1aac6770fb54382",
55
+ "sourceSha": "b30c41a5c3e0b065aaf9a0be08c918eea77be86d",
56
56
  "channel": "stable"
57
57
  },
58
- "gitHead": "c068b2d7889470bec2210030c1aac6770fb54382"
58
+ "gitHead": "b30c41a5c3e0b065aaf9a0be08c918eea77be86d"
59
59
  }
@@ -29,7 +29,7 @@ Call these with `notis tools exec <TOOL>` (add `--get-schema` first when you nee
29
29
  [
30
30
  {
31
31
  "name": "LOCAL_NOTIS_LOAD_CONVERSATION_HISTORY",
32
- "description": "Read the current or specified owned topical conversation, including user replies, sent messages, attachments, saved voice transcripts with speaker roles and delivery state. Use LOCAL_NOTIS_SEARCH_THREADS to find another conversation when its thread_id is unknown. Raw provider payloads and developer/tool internals are not returned. Omit after and limit for full history; pass limit (1–200) to page from the start, then reuse next_cursor as after. Cursor reads default to 50 records and return immediately, even when empty. Merge records by record_id, replacing that record’s items on each revision; removed records delete prior items. Full reads and the first page (no after) also return agents, one entry per agent that worked in the thread: agent_id, name, provider (notis, codex or claude), intelligence, status, first_run_at, last_run_at, runs, skills it loaded, the interaction_ids it handled and a one-line last_result; read one agent's full work with LOCAL_NOTIS_LOAD_AGENT_CONTEXT. Cursor reads (after) omit agents. Reads are independent and never consume another agent’s replies. Poll as often as your task needs; sending is always a separate explicit action."
32
+ "description": "Read the current or specified owned topical conversation, including user replies, sent messages, attachments, saved voice transcripts with speaker roles and delivery state. Use LOCAL_NOTIS_SEARCH_THREADS to find another conversation when its thread_id is unknown. Raw provider payloads and developer/tool internals are not returned. Omit after and limit for full history; pass limit (1–200) to page from the start, then reuse next_cursor as after. To read what a conversation says now, pass latest (1–200) alone: the newest messages first, without change records. Cursor reads default to 50 records and return immediately, even when empty. Merge records by record_id, replacing that record’s items on each revision; removed records delete prior items. Full reads and the first page (no after) also return agents, one entry per agent that worked in the thread: agent_id, name, provider (notis, codex or claude), intelligence, status, first_run_at, last_run_at, runs, skills it loaded, the interaction_ids it handled and a one-line last_result; read one agent's full work with LOCAL_NOTIS_LOAD_AGENT_CONTEXT. Cursor reads (after) omit agents. Reads are independent and never consume another agent’s replies. Poll as often as your task needs; sending is always a separate explicit action."
33
33
  },
34
34
  {
35
35
  "name": "LOCAL_NOTIS_LOAD_AGENT_CONTEXT",
@@ -8,7 +8,7 @@
8
8
  // With neither, the command sets up when needed, waits for the computer and
9
9
  // runs ssh.
10
10
  //
11
- // `notis computer status | restart | recover` (CC-150, CC-151) go through
11
+ // `notis computer status | restart | recover` (CC-150, CC-245) go through
12
12
  // LOCAL_NOTIS_GET_CLOUD_COMPUTER and LOCAL_NOTIS_MANAGE_CLOUD_COMPUTER, so the
13
13
  // server keeps every check. Restart and recover preview first and ask.
14
14
 
@@ -241,8 +241,8 @@ export const computerCommandSpecs = [{
241
241
  },
242
242
  }, {
243
243
  command_path: ['computer', 'restart'],
244
- summary: 'Restart a Cloud Computer that stopped answering. Its files are kept.',
245
- when_to_use: 'Only while notis computer status says it is not responding. Whatever was running on it stops; it answers again in 1 to 2 minutes.',
244
+ summary: 'Restart your Cloud Computer, awake or not responding. Its files are kept.',
245
+ when_to_use: 'When it is stuck, slow or not responding. Whatever was running on it stops; it answers again in 1 to 2 minutes. An asleep one has nothing to restart.',
246
246
  args_schema: { arguments: [], options: [YES_OPTION] },
247
247
  examples: ['notis computer restart', 'notis computer restart --yes'],
248
248
  mutates: true, idempotent: false, require_auth: true,
@@ -1,7 +1,7 @@
1
1
  import { captureNativeSkillFiles, createSkillBundleBase64 } from './local-scanner';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { checkedNativeReference } from './native-identity';
4
- import type { AgentTargets, LocalSkill, NativeSkillReference, SyncPullResponse, SyncPushResponse, SyncSettings } from './types';
4
+ import type { AgentTargets, LocalSkill, NativeSkillReference, SkillSyncFailure, SyncPullResponse, SyncPushResponse, SyncSettings } from './types';
5
5
 
6
6
  type JsonBody = Record<string, unknown> | undefined;
7
7
 
@@ -22,12 +22,33 @@ async function requestJson<T>(
22
22
 
23
23
  if (!response.ok) {
24
24
  const text = await response.text();
25
- throw new Error(`${options.method || 'POST'} ${url} → ${response.status}: ${text}`);
25
+ throw new SkillSyncHttpError(
26
+ `${options.method || 'POST'} ${url} → ${response.status}: ${text}`,
27
+ response.status,
28
+ response.headers.get('content-type'),
29
+ );
26
30
  }
27
31
 
28
32
  return response.json() as Promise<T>;
29
33
  }
30
34
 
35
+ /**
36
+ * A non-2xx answer, classified so a status can be recorded without its body:
37
+ * `edge_blocked` for an HTML 403 (the edge in front of the API refused the
38
+ * request before it reached Notis), `http_<status>` otherwise.
39
+ */
40
+ export class SkillSyncHttpError extends Error {
41
+ readonly status: number;
42
+ readonly code: string;
43
+
44
+ constructor(message: string, status: number, contentType: string | null) {
45
+ super(message);
46
+ this.name = 'SkillSyncHttpError';
47
+ this.status = status;
48
+ this.code = status === 403 && /text\/html/i.test(contentType || '') ? 'edge_blocked' : `http_${status}`;
49
+ }
50
+ }
51
+
31
52
  export async function fetchSyncSettings(serverUrl: string, jwt: string): Promise<SyncSettings> {
32
53
  return requestJson<SyncSettings>(`${serverUrl}/portal_skills/sync-settings`, jwt, {
33
54
  body: {},
@@ -40,12 +61,11 @@ export async function pullSkills(serverUrl: string, jwt: string): Promise<SyncPu
40
61
  });
41
62
  }
42
63
 
43
- export async function pushChangedSkills(
44
- serverUrl: string,
45
- jwt: string,
46
- changedSkills: LocalSkill[],
47
- ): Promise<SyncPushResponse> {
48
- const payloadSkills = await Promise.all(changedSkills.map(async (skill) => ({
64
+ /** Largest sync-push body sent at once; a single larger skill goes alone. */
65
+ export const MAX_SYNC_PUSH_BODY_BYTES = 2 * 1024 * 1024;
66
+
67
+ async function skillPushPayload(skill: LocalSkill): Promise<Record<string, unknown>> {
68
+ return {
49
69
  name: skill.name,
50
70
  description: skill.description,
51
71
  skill_md: skill.skillMd,
@@ -56,14 +76,77 @@ export async function pushChangedSkills(
56
76
  ...(skill.cloudId ? { cloud_id: skill.cloudId } : {}),
57
77
  ...(skill.nativeReference ? { native_reference: skill.nativeReference, display_name: skill.displayName,
58
78
  native_scope: skill.nativeScope } : {}),
59
- })));
79
+ };
80
+ }
60
81
 
61
- return requestJson<SyncPushResponse>(`${serverUrl}/portal_skills/sync-push`, jwt, {
62
- body: {
63
- skill_sync_protocol: 2,
64
- skills: payloadSkills,
65
- },
66
- });
82
+ /** The request body around the skills array, counted in every batch's size. */
83
+ const SYNC_PUSH_ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({ skill_sync_protocol: 2, skills: [] }));
84
+
85
+ function pushBatches(payloads: Record<string, unknown>[], maxBodyBytes: number): Record<string, unknown>[][] {
86
+ const batches: Record<string, unknown>[][] = [];
87
+ let batch: Record<string, unknown>[] = [];
88
+ let batchBytes = SYNC_PUSH_ENVELOPE_BYTES;
89
+ for (const payload of payloads) {
90
+ // +1 for the comma between array items.
91
+ const bytes = Buffer.byteLength(JSON.stringify(payload)) + 1;
92
+ if (batch.length > 0 && batchBytes + bytes > maxBodyBytes) {
93
+ batches.push(batch);
94
+ batch = [];
95
+ batchBytes = SYNC_PUSH_ENVELOPE_BYTES;
96
+ }
97
+ batch.push(payload);
98
+ batchBytes += bytes;
99
+ }
100
+ if (batch.length > 0) batches.push(batch);
101
+ return batches;
102
+ }
103
+
104
+ function pushFailure(name: string, error: unknown): SkillSyncFailure {
105
+ if (error instanceof SkillSyncHttpError) {
106
+ return {
107
+ name,
108
+ error: error.code === 'edge_blocked'
109
+ ? `Upload blocked before reaching Notis (HTTP ${error.status}); sync will retry`
110
+ : `Upload failed (HTTP ${error.status}); sync will retry`,
111
+ status: error.status,
112
+ code: error.code,
113
+ };
114
+ }
115
+ const code = typeof (error as { code?: unknown })?.code === 'string' ? (error as { code: string }).code : 'push_failed';
116
+ return { name, error: 'Upload failed; sync will retry', code };
117
+ }
118
+
119
+ /**
120
+ * Push changed skills in bodies of at most `maxBodyBytes` (one skill when it is
121
+ * larger alone). A batch the server or the edge refuses fails only its own skills,
122
+ * recorded with the HTTP status, and the other batches still push.
123
+ */
124
+ export async function pushChangedSkills(
125
+ serverUrl: string,
126
+ jwt: string,
127
+ changedSkills: LocalSkill[],
128
+ options: { maxBodyBytes?: number } = {},
129
+ ): Promise<SyncPushResponse> {
130
+ const payloadSkills = await Promise.all(changedSkills.map(skillPushPayload));
131
+ const saved: unknown[] = [];
132
+ const failed: SkillSyncFailure[] = [];
133
+ for (const batch of pushBatches(payloadSkills, options.maxBodyBytes ?? MAX_SYNC_PUSH_BODY_BYTES)) {
134
+ try {
135
+ const result = await requestJson<SyncPushResponse>(`${serverUrl}/portal_skills/sync-push`, jwt, {
136
+ body: {
137
+ skill_sync_protocol: 2,
138
+ skills: batch,
139
+ },
140
+ });
141
+ saved.push(...(result.skills || []));
142
+ if (Array.isArray(result.failed)) failed.push(...result.failed);
143
+ } catch (error) {
144
+ // A rejected sign-in fails every batch alike: stop and let the sync report it.
145
+ if (error instanceof SkillSyncHttpError && error.status === 401) throw error;
146
+ for (const payload of batch) failed.push(pushFailure(String(payload.name), error));
147
+ }
148
+ }
149
+ return { skills: saved, ...(failed.length ? { failed } : {}) };
67
150
  }
68
151
 
69
152
  export async function downloadSkillBundle(bundleUrl: string): Promise<Buffer> {
@@ -40,7 +40,7 @@ import {
40
40
  } from "./symlink-manager";
41
41
  import { getPushCandidates, selectCloudSkillsToApply } from "./sync-plan";
42
42
  import { writeCloudSkillWithBundleFallback } from "./write-cloud-skill";
43
- export { fetchSyncSettings } from './cloud-client';
43
+ export { fetchSyncSettings, pushChangedSkills } from './cloud-client';
44
44
 
45
45
  export interface RunSkillSyncResult {
46
46
  syncEnabled: boolean;
@@ -403,6 +403,25 @@ function buildSyncState(
403
403
  });
404
404
  }
405
405
 
406
+ /**
407
+ * A local edit whose upload failed keeps the previously synced folder hash, so the
408
+ * next sync still sees it as changed and pushes it again instead of recording the
409
+ * unsent edit as synced.
410
+ */
411
+ function keepFailedPushesPending(
412
+ state: NotisSyncState,
413
+ previousState: NotisSyncState,
414
+ failedPushes: readonly SkillSyncFailure[],
415
+ ): NotisSyncState {
416
+ for (const { name } of failedPushes) {
417
+ const row = state.skills[name];
418
+ const previous = previousState.skills[name];
419
+ if (!row || !previous || row.nativeReference || previous.nativeReference) continue;
420
+ state.skills[name] = { ...row, folderHash: previous.folderHash };
421
+ }
422
+ return state;
423
+ }
424
+
406
425
  function buildLocalSymlinkCandidates(
407
426
  pullResponse: SyncPullResponse,
408
427
  localSkills: LocalSkill[],
@@ -968,7 +987,7 @@ export async function runSkillSync(
968
987
  const lastSyncedAt = pullResponse.last_synced_at || new Date().toISOString();
969
988
 
970
989
  await deps.writeSyncState(
971
- buildSyncState(
990
+ keepFailedPushesPending(buildSyncState(
972
991
  pullResponse,
973
992
  finalLocalSkills,
974
993
  lastSyncedAt,
@@ -977,7 +996,7 @@ export async function runSkillSync(
977
996
  collectAppliedCloudRevisions(pullResponse, previousState, writtenSkillNames),
978
997
  collectAppliedFiles(pullResponse, previousState, appliedFilesByName),
979
998
  previousState,
980
- ),
999
+ ), previousState, failedPushes),
981
1000
  syncPaths,
982
1001
  );
983
1002
 
@@ -135,6 +135,10 @@ export interface SyncPullResponse {
135
135
  export interface SkillSyncFailure {
136
136
  name: string;
137
137
  error: string;
138
+ /** HTTP status of a refused upload, when the push itself was answered non-2xx. */
139
+ status?: number;
140
+ /** Classified cause (e.g. `edge_blocked`, `http_413`); never a response body. */
141
+ code?: string;
138
142
  }
139
143
 
140
144
  export interface SyncPushResponse {
@@ -106,7 +106,11 @@ export async function main(args = process.argv.slice(2), {
106
106
  } catch (error) {
107
107
  // Persist only a classified error, never a bearer, signed URL or response body.
108
108
  const code = error.code || 'sync_failed';
109
- record({ status: 'error', code, ...(REJECTED_SIGN_IN_CODES.has(code) && signIn ? { sign_in: signIn } : {}) });
109
+ // An HTTP refusal keeps its status, e.g. `edge_blocked` with 403 when the
110
+ // edge in front of the API refused the request before it reached Notis.
111
+ const httpStatus = Number.isInteger(error.status) ? { http_status: error.status } : {};
112
+ record({ status: 'error', code, ...httpStatus,
113
+ ...(REJECTED_SIGN_IN_CODES.has(code) && signIn ? { sign_in: signIn } : {}) });
110
114
  process.exitCode = 1;
111
115
  } finally {
112
116
  clearTimeout(deadline);
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
5
5
  import { cn } from '@/lib/utils';
6
6
 
7
7
  const buttonVariants = cva(
8
- 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
8
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50',
9
9
  {
10
10
  variants: {
11
11
  variant: {
@@ -10,7 +10,7 @@ const NativeSelect = React.forwardRef<HTMLSelectElement, React.SelectHTMLAttribu
10
10
  <span className={cn('relative inline-flex', className)}>
11
11
  <select
12
12
  ref={ref}
13
- className="h-9 w-full appearance-none rounded-md bg-muted pl-3 pr-8 text-sm text-foreground outline-hidden transition-colors hover:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
13
+ className="h-9 w-full appearance-none rounded-md bg-muted pl-3 pr-8 text-sm text-foreground outline-hidden transition-colors hover:bg-muted/70"
14
14
  {...props}
15
15
  >
16
16
  {children}