@notis_ai/cli 0.2.0-beta.16.1 → 0.2.0-beta.160.1

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 (154) hide show
  1. package/README.md +433 -133
  2. package/config/notis_app_boundary_rules.json +50 -0
  3. package/config/notis_app_design_rules.json +135 -0
  4. package/dist/agent-hooks/notis-agent-hook.mjs +18672 -0
  5. package/dist/base-skills/notis-apps/SKILL.md +70 -0
  6. package/dist/base-skills/notis-apps/references/architecture.md +164 -0
  7. package/dist/base-skills/notis-apps/references/context.md +81 -0
  8. package/dist/base-skills/notis-apps/references/design.md +165 -0
  9. package/dist/base-skills/notis-apps/references/reading.md +89 -0
  10. package/dist/base-skills/notis-apps/references/release.md +99 -0
  11. package/dist/base-skills/notis-apps/references/sdk.md +62 -0
  12. package/dist/base-skills/notis-apps/references/troubleshooting.md +23 -0
  13. package/dist/base-skills/notis-cli/SKILL.md +140 -0
  14. package/dist/base-skills/notis-cli/references/app-delivery.md +18 -0
  15. package/dist/base-skills/notis-cli/references/native-databases.md +20 -0
  16. package/dist/base-skills/notis-cli/references/tool-examples.md +56 -0
  17. package/dist/base-skills/notis-cli/references/troubleshooting.md +39 -0
  18. package/dist/base-skills/notis-query/SKILL.md +67 -0
  19. package/dist/base-skills/notis-query/references/database-discovery.md +59 -0
  20. package/dist/base-skills/notis-query/references/documents.md +50 -0
  21. package/dist/base-skills/notis-query/references/query.md +543 -0
  22. package/dist/skill-sync/index.js +1626 -0
  23. package/dist/skill-sync/index.js.map +7 -0
  24. package/dist/skill-sync-worker.mjs +2990 -0
  25. package/package.json +16 -6
  26. package/skills/notis-apps/cli.md +313 -0
  27. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +39 -0
  28. package/skills/notis-onboarding/BRIEF.md +129 -0
  29. package/skills/notis-query/cli.md +39 -0
  30. package/src/agent-hook-entry.js +5 -0
  31. package/src/cli.js +294 -25
  32. package/src/command-specs/agents.js +392 -0
  33. package/src/command-specs/apps.js +1470 -202
  34. package/src/command-specs/auth.js +114 -137
  35. package/src/command-specs/diagnostics.js +716 -0
  36. package/src/command-specs/handover.js +374 -0
  37. package/src/command-specs/helpers.js +84 -82
  38. package/src/command-specs/index.js +25 -6
  39. package/src/command-specs/meta.js +150 -18
  40. package/src/command-specs/onboarding.js +290 -0
  41. package/src/command-specs/profile.js +358 -0
  42. package/src/command-specs/reports.js +86 -0
  43. package/src/command-specs/skills.js +75 -0
  44. package/src/command-specs/smoke.js +386 -0
  45. package/src/command-specs/tools.js +455 -139
  46. package/src/runtime/agent-browser.js +632 -0
  47. package/src/runtime/agent-memory-state.js +126 -0
  48. package/src/runtime/agent-setup.js +383 -0
  49. package/src/runtime/app-boundary-validator.js +404 -0
  50. package/src/runtime/app-changelog.js +79 -0
  51. package/src/runtime/app-platform.js +2633 -210
  52. package/src/runtime/app-registry-scaffolds.js +367 -0
  53. package/src/runtime/app-test-server.js +292 -0
  54. package/src/runtime/assets/store-screenshot-dark.png +0 -0
  55. package/src/runtime/auth-recovery.js +110 -0
  56. package/src/runtime/base-skills.d.ts +20 -0
  57. package/src/runtime/base-skills.js +167 -0
  58. package/src/runtime/channel.js +133 -0
  59. package/src/runtime/delegated-context.js +68 -0
  60. package/src/runtime/errors.js +1 -0
  61. package/src/runtime/git.js +233 -0
  62. package/src/runtime/login-listener.js +15 -0
  63. package/src/runtime/oauth.js +2622 -0
  64. package/src/runtime/output.js +37 -5
  65. package/src/runtime/ports.js +31 -0
  66. package/src/runtime/profiles.js +906 -55
  67. package/src/runtime/skill-sync/cloud-client.ts +99 -0
  68. package/src/runtime/skill-sync/index.ts +697 -0
  69. package/src/runtime/skill-sync/local-scanner.ts +1046 -0
  70. package/src/runtime/skill-sync/symlink-manager.ts +433 -0
  71. package/src/runtime/skill-sync/sync-plan.ts +22 -0
  72. package/src/runtime/skill-sync/types.ts +110 -0
  73. package/src/runtime/skill-sync/write-cloud-skill.ts +50 -0
  74. package/src/runtime/skill-sync-service.js +109 -0
  75. package/src/runtime/store-screenshot.js +143 -0
  76. package/src/runtime/sync-skills.d.ts +37 -0
  77. package/src/runtime/sync-skills.js +231 -0
  78. package/src/runtime/telemetry.js +92 -0
  79. package/src/runtime/transport.js +324 -45
  80. package/src/skill-sync-worker-entry.js +2 -0
  81. package/src/skill-sync-worker.js +50 -0
  82. package/template/.harness/index.html.tmpl +430 -0
  83. package/template/CHANGELOG.md +5 -0
  84. package/template/app/layout.tsx +5 -2
  85. package/template/app/page.tsx +49 -42
  86. package/template/components/page-heading.tsx +23 -0
  87. package/template/components/ui/badge.tsx +7 -4
  88. package/template/components/ui/card.tsx +24 -11
  89. package/template/components/ui/native-select.tsx +24 -0
  90. package/template/notis.config.ts +24 -6
  91. package/template/package-lock.json +4137 -0
  92. package/template/package.json +5 -5
  93. package/template/packages/{notis-sdk → sdk}/package.json +13 -3
  94. package/template/packages/sdk/src/agentContext.ts +36 -0
  95. package/template/packages/sdk/src/components/DocumentEditor.tsx +103 -0
  96. package/template/packages/sdk/src/components/Markdown.tsx +60 -0
  97. package/template/packages/sdk/src/components/MarkdownEditor.tsx +121 -0
  98. package/template/packages/sdk/src/components/MultiSelectActionBar.tsx +285 -0
  99. package/template/packages/sdk/src/components/MultiSelectCheckbox.tsx +97 -0
  100. package/template/packages/sdk/src/components/MultiSelectDragOverlay.tsx +39 -0
  101. package/template/packages/sdk/src/components/NotisCommentBoundary.tsx +172 -0
  102. package/template/packages/sdk/src/components/NotisSelectionBoundary.tsx +59 -0
  103. package/template/packages/sdk/src/components/ShortcutHints.tsx +56 -0
  104. package/template/packages/sdk/src/components/Skeleton.tsx +24 -0
  105. package/template/packages/sdk/src/config.ts +257 -0
  106. package/template/packages/sdk/src/documents.ts +256 -0
  107. package/template/packages/sdk/src/hooks/useActiveResource.ts +19 -0
  108. package/template/packages/sdk/src/hooks/useAgentContext.ts +23 -0
  109. package/template/packages/sdk/src/hooks/useCloudComputer.ts +64 -0
  110. package/template/packages/sdk/src/hooks/useCollectionInteractions.ts +836 -0
  111. package/template/packages/sdk/src/hooks/useDatabaseSchema.ts +49 -0
  112. package/template/packages/sdk/src/hooks/useDatabaseSubscription.ts +76 -0
  113. package/template/packages/sdk/src/hooks/useDocument.ts +43 -0
  114. package/template/packages/sdk/src/hooks/useDocuments.ts +84 -0
  115. package/template/packages/sdk/src/hooks/useHandover.ts +78 -0
  116. package/template/packages/sdk/src/hooks/useLongPressSelection.ts +79 -0
  117. package/template/packages/sdk/src/hooks/useMultiSelect.ts +95 -0
  118. package/template/packages/{notis-sdk → sdk}/src/hooks/useNotis.ts +10 -4
  119. package/template/packages/{notis-sdk → sdk}/src/hooks/useNotisNavigation.ts +11 -8
  120. package/template/packages/sdk/src/hooks/useQuery.ts +71 -0
  121. package/template/packages/sdk/src/hooks/useTool.ts +65 -0
  122. package/template/packages/sdk/src/hooks/useToolQuery.ts +12 -0
  123. package/template/packages/sdk/src/hooks/useTopBarSearch.ts +81 -0
  124. package/template/packages/sdk/src/hooks/useUpsertDocument.ts +95 -0
  125. package/template/packages/sdk/src/index.ts +161 -0
  126. package/template/packages/sdk/src/interactions/actions.ts +59 -0
  127. package/template/packages/sdk/src/interactions/shortcuts.tsx +694 -0
  128. package/template/packages/sdk/src/interactions/visibility.ts +13 -0
  129. package/template/packages/sdk/src/interactions.ts +45 -0
  130. package/template/packages/sdk/src/provider.tsx +44 -0
  131. package/template/packages/sdk/src/queryCache.ts +170 -0
  132. package/template/packages/sdk/src/runtime.ts +451 -0
  133. package/template/packages/sdk/src/styles.css +213 -0
  134. package/template/packages/sdk/src/tailwind.ts +56 -0
  135. package/template/packages/{notis-sdk → sdk}/src/vite.ts +5 -1
  136. package/template/tailwind.config.ts +1 -0
  137. package/src/command-specs/db.js +0 -163
  138. package/src/runtime/app-preview-server.js +0 -312
  139. package/template/packages/notis-sdk/src/config.ts +0 -48
  140. package/template/packages/notis-sdk/src/helpers.ts +0 -131
  141. package/template/packages/notis-sdk/src/hooks/useAppState.ts +0 -50
  142. package/template/packages/notis-sdk/src/hooks/useCollectionItem.ts +0 -58
  143. package/template/packages/notis-sdk/src/hooks/useDatabase.ts +0 -87
  144. package/template/packages/notis-sdk/src/hooks/useDocument.ts +0 -61
  145. package/template/packages/notis-sdk/src/hooks/useTool.ts +0 -49
  146. package/template/packages/notis-sdk/src/hooks/useUpsertDocument.ts +0 -57
  147. package/template/packages/notis-sdk/src/index.ts +0 -47
  148. package/template/packages/notis-sdk/src/provider.tsx +0 -44
  149. package/template/packages/notis-sdk/src/runtime.ts +0 -159
  150. package/template/packages/notis-sdk/src/styles.css +0 -123
  151. /package/template/packages/{notis-sdk → sdk}/src/hooks/useBackend.ts +0 -0
  152. /package/template/packages/{notis-sdk → sdk}/src/hooks/useTools.ts +0 -0
  153. /package/template/packages/{notis-sdk → sdk}/src/ui.ts +0 -0
  154. /package/template/packages/{notis-sdk → sdk}/tsconfig.json +0 -0
@@ -1,178 +1,155 @@
1
- import { CliError, EXIT_CODES } from '../runtime/errors.js';
2
- import {
3
- clearStoredJwt,
4
- probeAuth,
5
- promptForJwt,
6
- updateStoredProfile,
7
- } from './helpers.js';
1
+ import { loginWithOAuth, logoutOAuth } from '../runtime/oauth.js';
2
+ import { installLocalAgentContext } from './agents.js';
8
3
 
9
- async function authLoginHandler(ctx) {
10
- let jwt = ctx.options.jwt || process.env.NOTIS_JWT;
11
- if (!jwt) {
12
- if (ctx.runtime.nonInteractive) {
13
- throw new CliError({
14
- code: 'auth_missing',
15
- message: `No JWT configured for profile ${ctx.runtime.profileName}`,
16
- exitCode: EXIT_CODES.auth,
17
- hints: [
18
- {
19
- command: 'notis auth login --jwt <token>',
20
- reason: 'Provide a token explicitly in non-interactive mode',
21
- },
22
- ],
23
- });
24
- }
25
- jwt = await promptForJwt();
4
+ async function loginHandler(ctx) {
5
+ const result = await loginWithOAuth(ctx.runtime, ctx.options, ctx.output);
6
+ if (result.agentAuthorization) {
7
+ const presentation = loginAgentAuthorizationPresentation(result.agentAuthorization);
8
+ return ctx.output.emitSuccess({
9
+ command: 'login',
10
+ data: result.agentAuthorization,
11
+ ...presentation,
12
+ });
13
+ }
14
+ let agentSetup = [];
15
+ const setupWarnings = [];
16
+ try {
17
+ // Login may add static CLI guidance, but automatic capture is a separate
18
+ // explicit choice made through `notis agents install`.
19
+ agentSetup = installLocalAgentContext(ctx, {
20
+ onlyExisting: true,
21
+ memoryHooks: null,
22
+ });
23
+ } catch (error) {
24
+ setupWarnings.push(`Notis CLI login succeeded, but local agent context setup failed: ${error.message}`);
26
25
  }
27
-
28
- updateStoredProfile({
29
- profileName: ctx.runtime.profileName,
30
- jwt,
31
- apiBase: ctx.globalOptions.apiBase,
32
- setCurrent: true,
33
- });
34
-
35
26
  return ctx.output.emitSuccess({
36
- command: ctx.spec.command_path.join(' '),
27
+ command: 'login',
37
28
  data: {
29
+ authenticated: true,
30
+ credential_source: 'oauth',
38
31
  profile: ctx.runtime.profileName,
39
- api_base: ctx.globalOptions.apiBase || ctx.runtime.apiBase,
32
+ api_base: result.profile.api_base || ctx.runtime.apiBase,
33
+ user_id: result.profile.oauth_user_id,
34
+ scopes: result.profile.oauth_scopes,
35
+ access_expires_at: result.profile.oauth_access_expires_at,
36
+ refresh_expires_at: result.profile.oauth_refresh_expires_at,
37
+ agent_setup: agentSetup,
40
38
  },
41
- humanSummary: `Stored credentials for profile ${ctx.runtime.profileName}`,
39
+ humanSummary: `Notis CLI is authorized for profile "${ctx.runtime.profileName}".`,
40
+ warnings: setupWarnings,
42
41
  hints: [
43
- { command: 'notis whoami', reason: 'Verify your identity and available toolkits' },
42
+ { command: 'notis profile list', reason: 'See every account this machine can switch between' },
43
+ { command: 'notis agents install', reason: 'Install or refresh Notis context for Codex and Claude Code' },
44
44
  ],
45
- meta: { mutating: true },
46
45
  });
47
46
  }
48
47
 
49
- async function authLogoutHandler(ctx) {
50
- clearStoredJwt(ctx.runtime.profileName);
51
- return ctx.output.emitSuccess({
52
- command: ctx.spec.command_path.join(' '),
53
- data: { profile: ctx.runtime.profileName },
54
- humanSummary: `Removed stored JWT for profile ${ctx.runtime.profileName}`,
55
- meta: { mutating: true },
56
- });
48
+ export function loginAgentAuthorizationPresentation(authorization) {
49
+ const browserHandOff = authorization?.hand_off === 'browser_callback';
50
+ const nextCommand = browserHandOff
51
+ ? authorization?.confirm_command
52
+ : authorization?.redeem_command;
53
+ return {
54
+ humanSummary: browserHandOff
55
+ ? 'Give the user the authorization URL. Signing in there completes it — there is no code to ask them for.'
56
+ : 'Give the user the authorization URL, then ask them for the code it shows.',
57
+ hints: nextCommand
58
+ ? [{
59
+ command: nextCommand,
60
+ reason: browserHandOff
61
+ ? 'Confirm the account once they have finished in the browser'
62
+ : 'Redeem the code shown in the browser',
63
+ }]
64
+ : [],
65
+ renderHuman: () => `Authorize Notis CLI: ${authorization.authorize_url}`,
66
+ };
57
67
  }
58
68
 
59
- async function authStatusHandler(ctx) {
60
- const hasJwt = Boolean(ctx.runtime.jwt);
61
- let verified = false;
62
- let toolkits = [];
63
- if (hasJwt && ctx.options.verify) {
64
- const payload = await probeAuth(ctx.runtime);
65
- toolkits = payload.toolkits || [];
66
- verified = true;
67
- }
68
-
69
+ async function logoutHandler(ctx) {
70
+ const result = await logoutOAuth(ctx.runtime, {
71
+ allProfiles: Boolean(ctx.options.allProfiles),
72
+ });
69
73
  return ctx.output.emitSuccess({
70
- command: ctx.spec.command_path.join(' '),
74
+ command: 'logout',
71
75
  data: {
72
- profile: ctx.runtime.profileName,
73
- api_base: ctx.runtime.apiBase,
74
- has_jwt: hasJwt,
75
- verified,
76
- toolkits,
76
+ oauth_connected: false,
77
+ cleared_profiles: result.profiles,
77
78
  },
78
- humanSummary: hasJwt
79
- ? `Profile ${ctx.runtime.profileName} is configured`
80
- : `Profile ${ctx.runtime.profileName} is missing a JWT`,
81
- hints: hasJwt
82
- ? []
83
- : [{ command: 'notis auth login --jwt <token>', reason: 'Configure credentials for this profile' }],
84
- meta: { mutating: false },
79
+ humanSummary: logoutHumanSummary(result, {
80
+ allProfiles: Boolean(ctx.options.allProfiles),
81
+ profileName: ctx.runtime.profileName,
82
+ }),
85
83
  });
86
84
  }
87
85
 
86
+ export function logoutHumanSummary(result, { allProfiles, profileName }) {
87
+ if (allProfiles) {
88
+ return result.profiles.length > 0
89
+ ? 'OAuth state was cleared from all connected or pending CLI profiles.'
90
+ : 'No OAuth credentials were connected in any CLI profile.';
91
+ }
92
+ return result.profiles.includes(profileName)
93
+ ? `OAuth state was cleared for profile "${profileName}", including any pending authorization.`
94
+ : `No OAuth credential was connected for profile "${profileName}".`;
95
+ }
96
+
88
97
  export const authCommandSpecs = [
89
98
  {
90
- command_path: ['auth', 'login'],
91
- summary: 'Store credentials for a named CLI profile.',
92
- when_to_use: 'Use this before authenticated commands, especially in fresh environments or CI profiles.',
99
+ command_path: ['login'],
100
+ summary: 'Authorize a CLI profile in a browser with scoped OAuth access.',
101
+ when_to_use:
102
+ 'Run this once per account you want the CLI to reach. Pass --profile to add a second account without signing the first one out.',
93
103
  args_schema: {
94
104
  arguments: [],
95
105
  options: [
96
- { flags: '--jwt <token>', description: 'JWT token to store for the profile.' },
106
+ { flags: '--no-browser', description: 'Print the authorization URL without opening a browser.' },
107
+ { flags: '--print-url', description: 'Print the authorization URL even when opening a browser.' },
108
+ { flags: '--mode <mode>', description: 'auto (default) hands the browser callback to a background listener when this command cannot wait; browser waits in-process; code shows a one-time code to copy.' },
109
+ { flags: '--paste-code', description: 'Alias for --mode code.' },
110
+ { flags: '--timeout-seconds <n>', description: 'Authorization lifetime in seconds (default 300 while waiting in a terminal; 1800 for detached or code hand-offs).' },
111
+ { flags: '--scope <scope>', description: 'OAuth permission to request (repeatable).', collect: true },
112
+ { flags: '--code <code>', description: 'Redeem the code shown in the browser after a non-interactive login.' },
97
113
  ],
98
114
  },
99
- examples: ['notis auth login --jwt <token>', 'notis auth login --profile staging --api-base http://localhost:3001'],
100
- output_schema: 'Returns the active profile name and API base.',
101
- mutates: true,
102
- idempotent: true,
103
- require_auth: false,
104
- related_commands: ['notis auth status --verify', 'notis auth logout'],
105
- backend_call: { type: 'local' },
106
- handler: authLoginHandler,
107
- },
108
- {
109
- command_path: ['auth', 'logout'],
110
- summary: 'Remove the stored JWT for the active profile.',
111
- when_to_use: 'Use this to clear local credentials without touching other profiles.',
112
- args_schema: { arguments: [], options: [] },
113
- examples: ['notis auth logout', 'notis auth logout --profile staging'],
114
- output_schema: 'Returns the profile that was updated.',
115
+ examples: [
116
+ 'notis login',
117
+ 'notis login --profile work',
118
+ 'notis login --profile beta --api-base https://api-beta.notis.ai',
119
+ 'notis login --no-browser --print-url',
120
+ 'notis login --mode browser',
121
+ 'notis login --mode code',
122
+ 'notis login --code 4f3c2b1a',
123
+ ],
124
+ output_schema:
125
+ 'Returns credential_source, profile, api_base, user_id, scopes, and credential expiries; non-blocking agent, machine-output, or non-interactive modes return authorize_url, expires_in, and hand_off ("browser_callback" needs no code, "code" must be redeemed with redeem_command).',
115
126
  mutates: true,
116
127
  idempotent: true,
117
128
  require_auth: false,
118
- related_commands: ['notis auth login --jwt <token>', 'notis auth status'],
119
- backend_call: { type: 'local' },
120
- handler: authLogoutHandler,
121
- },
122
- {
123
- command_path: ['auth', 'status'],
124
- summary: 'Inspect local auth configuration and optionally verify it against the API.',
125
- when_to_use: 'Use this before automating commands to confirm the active profile and token health.',
126
- args_schema: {
127
- arguments: [],
128
- options: [
129
- { flags: '--verify', description: 'Perform a live authenticated roundtrip to the API.' },
130
- ],
131
- },
132
- examples: ['notis auth status', 'notis auth status --verify --json'],
133
- output_schema: 'Returns profile, api_base, local auth presence, and optional verification data.',
134
- mutates: false,
135
- idempotent: true,
136
- require_auth: false,
137
- related_commands: ['notis doctor', 'notis auth login --jwt <token>'],
138
- backend_call: { type: 'notis_find_toolkits' },
139
- handler: authStatusHandler,
129
+ allow_unknown_profile: true,
130
+ related_commands: ['notis profile list', 'notis profile use', 'notis logout', 'notis doctor'],
131
+ backend_call: { type: 'oauth', name: 'authorization_code+pkce' },
132
+ handler: loginHandler,
140
133
  },
141
134
  {
142
- command_path: ['login'],
143
- display_name: 'login',
144
- summary: 'Deprecated alias for `notis auth login`.',
145
- when_to_use: 'Use only for backward compatibility with older scripts.',
135
+ command_path: ['logout'],
136
+ summary: 'Revoke and remove the OAuth credential for one CLI profile.',
137
+ when_to_use:
138
+ 'Use this to disconnect a single account. Other profiles keep their credentials unless you pass --all-profiles.',
146
139
  args_schema: {
147
140
  arguments: [],
148
141
  options: [
149
- { flags: '--jwt <token>', description: 'JWT token to store for the profile.' },
142
+ { flags: '--all-profiles', description: 'Clear OAuth credentials and pending authorizations from every CLI profile.' },
150
143
  ],
151
144
  },
152
- examples: ['notis login --jwt <token>'],
153
- output_schema: 'Same output as `notis auth login`.',
154
- mutates: true,
155
- idempotent: true,
156
- require_auth: false,
157
- related_commands: ['notis auth login --jwt <token>'],
158
- backend_call: { type: 'local', alias_for: 'auth login' },
159
- deprecated_alias_for: 'notis auth login',
160
- handler: authLoginHandler,
161
- },
162
- {
163
- command_path: ['logout'],
164
- display_name: 'logout',
165
- summary: 'Deprecated alias for `notis auth logout`.',
166
- when_to_use: 'Use only for backward compatibility with older scripts.',
167
- args_schema: { arguments: [], options: [] },
168
- examples: ['notis logout'],
169
- output_schema: 'Same output as `notis auth logout`.',
145
+ examples: ['notis logout', 'notis logout --profile work', 'notis logout --all-profiles'],
146
+ output_schema: 'Returns oauth_connected=false and the profiles whose OAuth credentials or pending authorizations were cleared.',
170
147
  mutates: true,
171
148
  idempotent: true,
172
149
  require_auth: false,
173
- related_commands: ['notis auth logout'],
174
- backend_call: { type: 'local', alias_for: 'auth logout' },
175
- deprecated_alias_for: 'notis auth logout',
176
- handler: authLogoutHandler,
150
+ allow_unknown_profile: true,
151
+ related_commands: ['notis login', 'notis profile list'],
152
+ backend_call: { type: 'oauth', name: 'revocation' },
153
+ handler: logoutHandler,
177
154
  },
178
155
  ];