@revition/plugin-dev 0.0.0-canary.2a173bc

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 (205) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +8 -0
  3. package/dist/api.d.ts +43 -0
  4. package/dist/api.js +19 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/apps/apps-api.d.ts +12 -0
  7. package/dist/apps/apps-api.js +19 -0
  8. package/dist/apps/apps-api.js.map +1 -0
  9. package/dist/apps/keys.d.ts +26 -0
  10. package/dist/apps/keys.js +13 -0
  11. package/dist/apps/keys.js.map +1 -0
  12. package/dist/checks/local-checks.d.ts +40 -0
  13. package/dist/checks/local-checks.js +123 -0
  14. package/dist/checks/local-checks.js.map +1 -0
  15. package/dist/commands/account/link-workspace.d.ts +12 -0
  16. package/dist/commands/account/link-workspace.js +29 -0
  17. package/dist/commands/account/link-workspace.js.map +1 -0
  18. package/dist/commands/account/register.d.ts +14 -0
  19. package/dist/commands/account/register.js +51 -0
  20. package/dist/commands/account/register.js.map +1 -0
  21. package/dist/commands/account/status.d.ts +9 -0
  22. package/dist/commands/account/status.js +33 -0
  23. package/dist/commands/account/status.js.map +1 -0
  24. package/dist/commands/analytics.d.ts +55 -0
  25. package/dist/commands/analytics.js +79 -0
  26. package/dist/commands/analytics.js.map +1 -0
  27. package/dist/commands/apps/create.d.ts +13 -0
  28. package/dist/commands/apps/create.js +39 -0
  29. package/dist/commands/apps/create.js.map +1 -0
  30. package/dist/commands/apps/keys/create.d.ts +19 -0
  31. package/dist/commands/apps/keys/create.js +39 -0
  32. package/dist/commands/apps/keys/create.js.map +1 -0
  33. package/dist/commands/apps/keys/list.d.ts +16 -0
  34. package/dist/commands/apps/keys/list.js +28 -0
  35. package/dist/commands/apps/keys/list.js.map +1 -0
  36. package/dist/commands/apps/keys/revoke.d.ts +19 -0
  37. package/dist/commands/apps/keys/revoke.js +35 -0
  38. package/dist/commands/apps/keys/revoke.js.map +1 -0
  39. package/dist/commands/apps/keys/rotate.d.ts +17 -0
  40. package/dist/commands/apps/keys/rotate.js +38 -0
  41. package/dist/commands/apps/keys/rotate.js.map +1 -0
  42. package/dist/commands/apps/list.d.ts +13 -0
  43. package/dist/commands/apps/list.js +26 -0
  44. package/dist/commands/apps/list.js.map +1 -0
  45. package/dist/commands/apps/listing.d.ts +11 -0
  46. package/dist/commands/apps/listing.js +26 -0
  47. package/dist/commands/apps/listing.js.map +1 -0
  48. package/dist/commands/apps/scopes/set.d.ts +25 -0
  49. package/dist/commands/apps/scopes/set.js +52 -0
  50. package/dist/commands/apps/scopes/set.js.map +1 -0
  51. package/dist/commands/apps/view.d.ts +12 -0
  52. package/dist/commands/apps/view.js +26 -0
  53. package/dist/commands/apps/view.js.map +1 -0
  54. package/dist/commands/audit.d.ts +31 -0
  55. package/dist/commands/audit.js +48 -0
  56. package/dist/commands/audit.js.map +1 -0
  57. package/dist/commands/branches/eval.d.ts +42 -0
  58. package/dist/commands/branches/eval.js +104 -0
  59. package/dist/commands/branches/eval.js.map +1 -0
  60. package/dist/commands/branches/list.d.ts +21 -0
  61. package/dist/commands/branches/list.js +43 -0
  62. package/dist/commands/branches/list.js.map +1 -0
  63. package/dist/commands/branches/status.d.ts +26 -0
  64. package/dist/commands/branches/status.js +47 -0
  65. package/dist/commands/branches/status.js.map +1 -0
  66. package/dist/commands/branches/view.d.ts +19 -0
  67. package/dist/commands/branches/view.js +41 -0
  68. package/dist/commands/branches/view.js.map +1 -0
  69. package/dist/commands/build.d.ts +42 -0
  70. package/dist/commands/build.js +76 -0
  71. package/dist/commands/build.js.map +1 -0
  72. package/dist/commands/changelog.d.ts +41 -0
  73. package/dist/commands/changelog.js +44 -0
  74. package/dist/commands/changelog.js.map +1 -0
  75. package/dist/commands/deploy.d.ts +74 -0
  76. package/dist/commands/deploy.js +75 -0
  77. package/dist/commands/deploy.js.map +1 -0
  78. package/dist/commands/dev.d.ts +43 -0
  79. package/dist/commands/dev.js +191 -0
  80. package/dist/commands/dev.js.map +1 -0
  81. package/dist/commands/docs.d.ts +33 -0
  82. package/dist/commands/docs.js +101 -0
  83. package/dist/commands/docs.js.map +1 -0
  84. package/dist/commands/eval/list.d.ts +18 -0
  85. package/dist/commands/eval/list.js +49 -0
  86. package/dist/commands/eval/list.js.map +1 -0
  87. package/dist/commands/eval/run.d.ts +30 -0
  88. package/dist/commands/eval/run.js +190 -0
  89. package/dist/commands/eval/run.js.map +1 -0
  90. package/dist/commands/extension-points.d.ts +19 -0
  91. package/dist/commands/extension-points.js +26 -0
  92. package/dist/commands/extension-points.js.map +1 -0
  93. package/dist/commands/generate.d.ts +44 -0
  94. package/dist/commands/generate.js +145 -0
  95. package/dist/commands/generate.js.map +1 -0
  96. package/dist/commands/init.d.ts +29 -0
  97. package/dist/commands/init.js +91 -0
  98. package/dist/commands/init.js.map +1 -0
  99. package/dist/commands/link.d.ts +19 -0
  100. package/dist/commands/link.js +54 -0
  101. package/dist/commands/link.js.map +1 -0
  102. package/dist/commands/logs.d.ts +77 -0
  103. package/dist/commands/logs.js +128 -0
  104. package/dist/commands/logs.js.map +1 -0
  105. package/dist/commands/open.d.ts +28 -0
  106. package/dist/commands/open.js +54 -0
  107. package/dist/commands/open.js.map +1 -0
  108. package/dist/commands/runs/list.d.ts +31 -0
  109. package/dist/commands/runs/list.js +56 -0
  110. package/dist/commands/runs/list.js.map +1 -0
  111. package/dist/commands/scaffold.d.ts +22 -0
  112. package/dist/commands/scaffold.js +40 -0
  113. package/dist/commands/scaffold.js.map +1 -0
  114. package/dist/commands/secrets/list.d.ts +13 -0
  115. package/dist/commands/secrets/list.js +32 -0
  116. package/dist/commands/secrets/list.js.map +1 -0
  117. package/dist/commands/secrets/set.d.ts +23 -0
  118. package/dist/commands/secrets/set.js +45 -0
  119. package/dist/commands/secrets/set.js.map +1 -0
  120. package/dist/commands/secrets/unset.d.ts +20 -0
  121. package/dist/commands/secrets/unset.js +33 -0
  122. package/dist/commands/secrets/unset.js.map +1 -0
  123. package/dist/commands/starters/list.d.ts +16 -0
  124. package/dist/commands/starters/list.js +33 -0
  125. package/dist/commands/starters/list.js.map +1 -0
  126. package/dist/commands/starters/view.d.ts +19 -0
  127. package/dist/commands/starters/view.js +27 -0
  128. package/dist/commands/starters/view.js.map +1 -0
  129. package/dist/commands/submissions/list.d.ts +18 -0
  130. package/dist/commands/submissions/list.js +35 -0
  131. package/dist/commands/submissions/list.js.map +1 -0
  132. package/dist/commands/submissions/open.d.ts +28 -0
  133. package/dist/commands/submissions/open.js +49 -0
  134. package/dist/commands/submissions/open.js.map +1 -0
  135. package/dist/commands/submissions/view.d.ts +16 -0
  136. package/dist/commands/submissions/view.js +32 -0
  137. package/dist/commands/submissions/view.js.map +1 -0
  138. package/dist/commands/submit.d.ts +48 -0
  139. package/dist/commands/submit.js +85 -0
  140. package/dist/commands/submit.js.map +1 -0
  141. package/dist/commands/test.d.ts +42 -0
  142. package/dist/commands/test.js +137 -0
  143. package/dist/commands/test.js.map +1 -0
  144. package/dist/commands/versions/channels.d.ts +26 -0
  145. package/dist/commands/versions/channels.js +34 -0
  146. package/dist/commands/versions/channels.js.map +1 -0
  147. package/dist/commands/versions/list.d.ts +27 -0
  148. package/dist/commands/versions/list.js +41 -0
  149. package/dist/commands/versions/list.js.map +1 -0
  150. package/dist/commands/versions/open.d.ts +29 -0
  151. package/dist/commands/versions/open.js +48 -0
  152. package/dist/commands/versions/open.js.map +1 -0
  153. package/dist/commands/versions/rollouts.d.ts +27 -0
  154. package/dist/commands/versions/rollouts.js +32 -0
  155. package/dist/commands/versions/rollouts.js.map +1 -0
  156. package/dist/commands/wallet/open.d.ts +14 -0
  157. package/dist/commands/wallet/open.js +28 -0
  158. package/dist/commands/wallet/open.js.map +1 -0
  159. package/dist/commands/wallet/show.d.ts +27 -0
  160. package/dist/commands/wallet/show.js +51 -0
  161. package/dist/commands/wallet/show.js.map +1 -0
  162. package/dist/dev/sandbox-session.d.ts +48 -0
  163. package/dist/dev/sandbox-session.js +50 -0
  164. package/dist/dev/sandbox-session.js.map +1 -0
  165. package/dist/dev/uploader.d.ts +11 -0
  166. package/dist/dev/uploader.js +63 -0
  167. package/dist/dev/uploader.js.map +1 -0
  168. package/dist/dev/watcher.d.ts +6 -0
  169. package/dist/dev/watcher.js +30 -0
  170. package/dist/dev/watcher.js.map +1 -0
  171. package/dist/eval/report.d.ts +65 -0
  172. package/dist/eval/report.js +42 -0
  173. package/dist/eval/report.js.map +1 -0
  174. package/dist/generate/manifest-patch.d.ts +18 -0
  175. package/dist/generate/manifest-patch.js +59 -0
  176. package/dist/generate/manifest-patch.js.map +1 -0
  177. package/dist/generate/render.d.ts +20 -0
  178. package/dist/generate/render.js +55 -0
  179. package/dist/generate/render.js.map +1 -0
  180. package/dist/index.d.ts +2 -0
  181. package/dist/index.js +5 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/local/fixture-sdk.d.ts +27 -0
  184. package/dist/local/fixture-sdk.js +105 -0
  185. package/dist/local/fixture-sdk.js.map +1 -0
  186. package/dist/local/local-run.d.ts +58 -0
  187. package/dist/local/local-run.js +197 -0
  188. package/dist/local/local-run.js.map +1 -0
  189. package/dist/project/ownership.d.ts +8 -0
  190. package/dist/project/ownership.js +27 -0
  191. package/dist/project/ownership.js.map +1 -0
  192. package/dist/project/project-link.d.ts +13 -0
  193. package/dist/project/project-link.js +34 -0
  194. package/dist/project/project-link.js.map +1 -0
  195. package/dist/project/read-project.d.ts +6 -0
  196. package/dist/project/read-project.js +30 -0
  197. package/dist/project/read-project.js.map +1 -0
  198. package/dist/project/write-starter.d.ts +12 -0
  199. package/dist/project/write-starter.js +38 -0
  200. package/dist/project/write-starter.js.map +1 -0
  201. package/dist/secrets/secrets-api.d.ts +35 -0
  202. package/dist/secrets/secrets-api.js +54 -0
  203. package/dist/secrets/secrets-api.js.map +1 -0
  204. package/oclif.manifest.json +5658 -0
  205. package/package.json +72 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"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AAChF,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * T2.1.5 - the only edits `generate` makes to existing files: an additive capability entry in `revition.json` and an
3
+ * appended case in a `tests.json`, each shown as a diff before it is applied. The platform limits (5 capabilities,
4
+ * 32 files, 1.5 MB) are checked against the RESULT before anything is written. PURE.
5
+ */
6
+ type Files = Readonly<Record<string, string>>;
7
+ export declare function manifestOf(files: Files): {
8
+ readonly summary: string;
9
+ readonly capabilities: Array<Record<string, unknown>>;
10
+ };
11
+ export declare function withCapability(manifestText: string, entry: Record<string, unknown>): string;
12
+ /** A unified-style diff of two texts (whole-line), for the confirmation. */
13
+ export declare function lineDiff(file: string, before: string, after: string): string;
14
+ /** Refuses (exit 2, nothing written) when the result would break a platform limit or overwrite a file. */
15
+ export declare function assertWritable(current: Files, added: Files, opts: {
16
+ readonly addsCapability: boolean;
17
+ }): void;
18
+ export {};
@@ -0,0 +1,59 @@
1
+ import { EXIT, RevitionCliError } from '@revition/cli-core';
2
+ import { MAX_CAPABILITIES, MAX_PROJECT_BYTES, MAX_PROJECT_FILES, PROJECT_MANIFEST_PATH } from '../checks/local-checks.js';
3
+ function refuse(code, message, hint) {
4
+ return new RevitionCliError({ code, message, ...(hint === undefined ? {} : { hint }) }, EXIT.usage);
5
+ }
6
+ export function manifestOf(files) {
7
+ const text = files[PROJECT_MANIFEST_PATH];
8
+ if (text === undefined)
9
+ throw refuse('NO_PROJECT', 'No revition.json here.', 'Run `revition init` to start a project.');
10
+ try {
11
+ const m = JSON.parse(text);
12
+ if (!Array.isArray(m.capabilities))
13
+ throw new Error('capabilities');
14
+ return m;
15
+ }
16
+ catch {
17
+ throw refuse('MANIFEST_INVALID', 'revition.json is not a valid project manifest.', 'Run `revition build` to see the problem.');
18
+ }
19
+ }
20
+ export function withCapability(manifestText, entry) {
21
+ const m = JSON.parse(manifestText);
22
+ return `${JSON.stringify({ ...m, capabilities: [...m.capabilities, entry] }, null, 2)}\n`;
23
+ }
24
+ /** A unified-style diff of two texts (whole-line), for the confirmation. */
25
+ export function lineDiff(file, before, after) {
26
+ const a = before.split('\n');
27
+ const b = after.split('\n');
28
+ const out = [`--- ${file}`, `+++ ${file}`];
29
+ let i = 0;
30
+ while (i < a.length && i < b.length && a[i] === b[i])
31
+ i++;
32
+ let ja = a.length - 1;
33
+ let jb = b.length - 1;
34
+ while (ja >= i && jb >= i && a[ja] === b[jb]) {
35
+ ja--;
36
+ jb--;
37
+ }
38
+ for (const l of a.slice(i, ja + 1))
39
+ out.push(`-${l}`);
40
+ for (const l of b.slice(i, jb + 1))
41
+ out.push(`+${l}`);
42
+ return `${out.join('\n')}\n`;
43
+ }
44
+ /** Refuses (exit 2, nothing written) when the result would break a platform limit or overwrite a file. */
45
+ export function assertWritable(current, added, opts) {
46
+ const taken = Object.keys(added).filter((f) => current[f] !== undefined);
47
+ if (taken.length > 0)
48
+ throw refuse('FILE_EXISTS', `${taken.join(', ')} already ${taken.length === 1 ? 'exists' : 'exist'}: nothing was written.`);
49
+ if (opts.addsCapability && manifestOf(current).capabilities.length >= MAX_CAPABILITIES) {
50
+ throw refuse('CAPABILITY_LIMIT', `The project already has ${MAX_CAPABILITIES} capabilities, the platform limit: nothing was written.`);
51
+ }
52
+ const count = Object.keys(current).length + Object.keys(added).length;
53
+ if (count > MAX_PROJECT_FILES)
54
+ throw refuse('FILE_LIMIT', `That would make ${count} files; the platform limit is ${MAX_PROJECT_FILES}: nothing was written.`);
55
+ const bytes = Object.entries({ ...current, ...added }).reduce((n, [f, t]) => n + Buffer.byteLength(f) + Buffer.byteLength(t), 0);
56
+ if (bytes > MAX_PROJECT_BYTES)
57
+ throw refuse('SIZE_LIMIT', `That would make ${bytes} bytes; the platform limit is ${MAX_PROJECT_BYTES}: nothing was written.`);
58
+ }
59
+ //# sourceMappingURL=manifest-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-patch.js","sourceRoot":"","sources":["../../src/generate/manifest-patch.ts"],"names":[],"mappings":"AAAA,OAAO,E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M,CAAC,YAAY,EAAE,mBAAmB,KAAK,iCAAiC,iBAAiB,wBAAwB,CAAC,CAAC;AAChK,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * T2.1.5 - each generator renders new files from the PLATFORM's own templates (a starter of the right extension point)
3
+ * or the PLATFORM's published schema (EvalSuite); the CLI holds no template of its own. PURE.
4
+ */
5
+ type Files = Readonly<Record<string, string>>;
6
+ export declare const KINDS: readonly ["capability", "test", "eval-suite", "ui-surface"];
7
+ export type Kind = (typeof KINDS)[number];
8
+ export declare function assertId(what: string, value: string): string;
9
+ /** The starter's one capability, renamed to `name`: its files under capabilities/<name>/ and its manifest entry. */
10
+ export declare function renderCapability(starterFiles: Files, name: string): {
11
+ files: Files;
12
+ entry: Record<string, unknown>;
13
+ };
14
+ /** The UI surface: the custom_ui starter's ui/manifest.json, nothing else. */
15
+ export declare function renderUiSurface(starterFiles: Files): Files;
16
+ /** A skeleton valid against the platform's published EvalSuite schema: one dimension (the first listed), one case. */
17
+ export declare function renderEvalSuite(name: string, capability: string | null): Files;
18
+ /** tests.json with one more case (`{name, input: {}, expect: {}}`); refuses a duplicate name or a 21st case. */
19
+ export declare function withTestCase(testsText: string | undefined, caseName: string): string;
20
+ export {};
@@ -0,0 +1,55 @@
1
+ import { COMPONENT_SCHEMAS } from '@revition/api-client';
2
+ import { EXIT, RevitionCliError, usageError } from '@revition/cli-core';
3
+ import { EVAL_SUITE_PATH, PROJECT_MANIFEST_PATH, UI_MANIFEST_PATH } from '../checks/local-checks.js';
4
+ export const KINDS = ['capability', 'test', 'eval-suite', 'ui-surface'];
5
+ const ID = /^[a-z][a-z0-9-]{0,62}$/;
6
+ export function assertId(what, value) {
7
+ if (!ID.test(value))
8
+ throw usageError('INVALID_NAME', `${what} "${value}" must be lowercase letters, digits and dashes (start with a letter).`);
9
+ return value;
10
+ }
11
+ /** The starter's one capability, renamed to `name`: its files under capabilities/<name>/ and its manifest entry. */
12
+ export function renderCapability(starterFiles, name) {
13
+ const manifest = JSON.parse(starterFiles[PROJECT_MANIFEST_PATH] ?? '{}');
14
+ const source = manifest.capabilities?.[0];
15
+ const from = typeof source?.['id'] === 'string' ? source['id'] : null;
16
+ if (source === undefined || from === null) {
17
+ throw new RevitionCliError({ code: 'STARTER_HAS_NO_CAPABILITY', message: 'The platform starter for that point has no capability to copy.' }, EXIT.general);
18
+ }
19
+ const prefix = `capabilities/${from}/`;
20
+ const files = {};
21
+ for (const [path, text] of Object.entries(starterFiles)) {
22
+ if (path.startsWith(prefix))
23
+ files[`capabilities/${name}/${path.slice(prefix.length)}`] = text;
24
+ }
25
+ return { files, entry: { ...source, id: name, name } };
26
+ }
27
+ /** The UI surface: the custom_ui starter's ui/manifest.json, nothing else. */
28
+ export function renderUiSurface(starterFiles) {
29
+ const ui = starterFiles[UI_MANIFEST_PATH];
30
+ if (ui === undefined)
31
+ throw new RevitionCliError({ code: 'STARTER_HAS_NO_UI', message: 'The platform starter for custom_ui has no ui/manifest.json.' }, EXIT.general);
32
+ return { [UI_MANIFEST_PATH]: ui };
33
+ }
34
+ /** A skeleton valid against the platform's published EvalSuite schema: one dimension (the first listed), one case. */
35
+ export function renderEvalSuite(name, capability) {
36
+ const path = `evals/${name}.json`;
37
+ if (!EVAL_SUITE_PATH.test(path))
38
+ throw usageError('INVALID_NAME', `An eval suite name is lowercase letters, digits and dashes: ${name}.`);
39
+ const schema = COMPONENT_SCHEMAS['EvalSuite'];
40
+ const dims = schema?.properties?.['dimensions']?.items?.enum ?? [];
41
+ if (dims.length === 0)
42
+ throw new RevitionCliError({ code: 'CONTRACT_MISSING_EVALSUITE', message: 'This CLI build has no EvalSuite schema in its contract.' }, EXIT.general);
43
+ const suite = { description: '', ...(capability === null ? {} : { capability }), dimensions: [dims[0]], cases: [{ id: 'case-1', input: {} }] };
44
+ return { [path]: `${JSON.stringify(suite, null, 2)}\n` };
45
+ }
46
+ /** tests.json with one more case (`{name, input: {}, expect: {}}`); refuses a duplicate name or a 21st case. */
47
+ export function withTestCase(testsText, caseName) {
48
+ const cases = testsText === undefined ? [] : JSON.parse(testsText);
49
+ if (cases.some((c) => c.name === caseName))
50
+ throw usageError('TEST_EXISTS', `A test named "${caseName}" already exists.`);
51
+ if (cases.length >= 20)
52
+ throw usageError('TEST_LIMIT', 'A capability has at most 20 tests.');
53
+ return `${JSON.stringify([...cases, { name: caseName, input: {}, expect: {} }], null, 2)}\n`;
54
+ }
55
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/generate/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQrG,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAEjF,MAAM,EAAE,GAAG,wBAAwB,CAAC;AAEpC,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAa;IAClD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,UAAU,CAAC,cAAc,EAAE,GAAG,IAAI,KAAK,KAAK,uEAAuE,CAAC,CAAC;IAChJ,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,gBAAgB,CAAC,YAAmB,EAAE,IAAY;IAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,IAAI,IAAI,CAAsD,CAAC;IAC9H,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,MAAM,EAAE,CAAC,IAAI,CA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,aAAa,EAAE,iBAAiB,QAAQ,mBAAmB,CAAC,CAAC;IAC1H,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE;QAAE,MAAM,UAAU,CAAC,YAAY,EAAE,oCAAoC,CAAC,CAAC;IAC7F,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { unsafePath, writeStarter, type ProjectFiles } from './project/write-starter.js';
2
+ export { ensureGitignore, GITIGNORE_LINES, readLink, writeLink } from './project/project-link.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // @revition/plugin-dev - the developer workflow (REVITION-CLI-PLAN Phase 2). Commands are discovered from dist/commands;
2
+ // the helpers below are exported for the plugin's own tests and for later plugins.
3
+ export { unsafePath, writeStarter } from './project/write-starter.js';
4
+ export { ensureGitignore, GITIGNORE_LINES, readLink, writeLink } from './project/project-link.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,mFAAmF;AACnF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAqB,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * T2.1.3 (REVITION-CLI-PLAN.md:2021-2024; Q1 answered from the plan): the Extension SDK for `revition test`, answered
3
+ * from the project's `fixtures.json` with NO network and NO credential. Ported from the platform's own dev sandbox
4
+ * (`apps/api/src/services/foundry/devportal/sandbox/fixture-sdk.ts`):
5
+ * - THE SAME CALLS AND PERMISSIONS: each call needs exactly the permission templates of the published reference
6
+ * (SDK_CALLS below, exported from the platform's `sdkCallTable()` by `scripts-local/export-sdk-call-table.ts`,
7
+ * SDK 1.0.0), granted by the platform's rule (a resource family whole with `family:*`, never an effect by
8
+ * wildcard) from what the capability declares (`sdkPermissions` in revition.json, the platform's
9
+ * `grantedSdkPermissions`);
10
+ * - NO REAL DATA: an answer comes only from a fixture; a call with none is refused with the fix; `secrets.get` returns
11
+ * a sandbox handle, never a value;
12
+ * - THE SAME SHAPE: `revition.sdk(call, ...args)` in TypeScript, `revition_sdk(call, *args)` in Python. PURE.
13
+ */
14
+ interface CallRow {
15
+ readonly params: readonly string[];
16
+ readonly permissions: readonly string[];
17
+ }
18
+ export declare const SDK_VERSION = "1.0.0";
19
+ /** The platform's SDK call table (SDK 1.0.0), pinned. */
20
+ export declare const SDK_CALLS: Readonly<Record<string, CallRow>>;
21
+ export interface FixtureSdkSpec {
22
+ readonly fixtures: Readonly<Record<string, unknown>>;
23
+ readonly granted: readonly string[];
24
+ }
25
+ /** The SDK client for a local test run: calls, grants and fixtures embedded; nothing reached over a network. */
26
+ export declare function fixtureSdkPrelude(language: 'typescript' | 'python', spec: FixtureSdkSpec): string;
27
+ export {};
@@ -0,0 +1,105 @@
1
+ /**
2
+ * T2.1.3 (REVITION-CLI-PLAN.md:2021-2024; Q1 answered from the plan): the Extension SDK for `revition test`, answered
3
+ * from the project's `fixtures.json` with NO network and NO credential. Ported from the platform's own dev sandbox
4
+ * (`apps/api/src/services/foundry/devportal/sandbox/fixture-sdk.ts`):
5
+ * - THE SAME CALLS AND PERMISSIONS: each call needs exactly the permission templates of the published reference
6
+ * (SDK_CALLS below, exported from the platform's `sdkCallTable()` by `scripts-local/export-sdk-call-table.ts`,
7
+ * SDK 1.0.0), granted by the platform's rule (a resource family whole with `family:*`, never an effect by
8
+ * wildcard) from what the capability declares (`sdkPermissions` in revition.json, the platform's
9
+ * `grantedSdkPermissions`);
10
+ * - NO REAL DATA: an answer comes only from a fixture; a call with none is refused with the fix; `secrets.get` returns
11
+ * a sandbox handle, never a value;
12
+ * - THE SAME SHAPE: `revition.sdk(call, ...args)` in TypeScript, `revition_sdk(call, *args)` in Python. PURE.
13
+ */
14
+ export const SDK_VERSION = '1.0.0';
15
+ /** The platform's SDK call table (SDK 1.0.0), pinned. */
16
+ export const SDK_CALLS = {
17
+ 'agent.get': { params: ['agentId'], permissions: ['agent:read'] },
18
+ 'context.current': { params: [], permissions: [] },
19
+ 'context.addInstruction': { params: ['text'], permissions: ['context:write'] },
20
+ 'tool.list': { params: [], permissions: [] },
21
+ 'tool.invoke': { params: ['ref', 'args'], permissions: ['capability:<ref>'] },
22
+ 'knowledge.search': { params: ['query', 'limit'], permissions: ['effect:read', 'knowledge:read'] },
23
+ 'data.listSources': { params: [], permissions: ['effect:read'] },
24
+ 'data.read': { params: ['sourceId', 'query', 'cursor'], permissions: ['effect:read', 'source:<sourceId>'] },
25
+ 'file.get': { params: ['fileId'], permissions: ['file:read'] },
26
+ 'file.put': { params: ['name', 'bytes'], permissions: ['effect:change', 'file:write'] },
27
+ 'user.current': { params: [], permissions: ['user:read'] },
28
+ 'conversation.history': { params: ['conversationId'], permissions: ['effect:read', 'conversation:read'] },
29
+ 'conversation.reply': { params: ['conversationId', 'text'], permissions: ['effect:send', 'conversation:reply'] },
30
+ 'task.create': { params: ['title', 'detail'], permissions: ['effect:change', 'task:write'] },
31
+ 'task.update': { params: ['taskId', 'status'], permissions: ['effect:change', 'task:write'] },
32
+ 'workflow.start': { params: ['workflowId', 'input'], permissions: ['effect:change', 'workflow:<workflowId>'] },
33
+ 'event.emit': { params: ['name', 'payload'], permissions: ['event:<name>'] },
34
+ 'ai.complete': { params: ['prompt', 'maxTokens'], permissions: ['ai:complete'] },
35
+ 'ui.render': { params: ['surface', 'tree'], permissions: ['ui:render'] },
36
+ 'notification.send': { params: ['toUserId', 'message'], permissions: ['effect:send', 'notification:send'] },
37
+ 'secrets.get': { params: ['name'], permissions: ['secret:<name>'] },
38
+ 'observability.log': { params: ['event', 'detail'], permissions: [] },
39
+ 'observability.metric': { params: ['name', 'value'], permissions: [] },
40
+ };
41
+ /** A JSON value as a string literal both TypeScript and Python read (JSON escapes are valid in both). */
42
+ const literal = (v) => JSON.stringify(JSON.stringify(v));
43
+ /** The SDK client for a local test run: calls, grants and fixtures embedded; nothing reached over a network. */
44
+ export function fixtureSdkPrelude(language, spec) {
45
+ const data = literal({ calls: SDK_CALLS, granted: spec.granted, fixtures: spec.fixtures });
46
+ if (language === 'python') {
47
+ return [
48
+ 'import json as __rv_sdk_json',
49
+ `__rv_sdk = __rv_sdk_json.loads(${data})`,
50
+ 'def __rv_sdk_str(v):',
51
+ " return 'null' if v is None else ('true' if v is True else ('false' if v is False else str(v)))",
52
+ 'def __rv_sdk_granted(p):',
53
+ " g = __rv_sdk['granted']",
54
+ " i = p.find(':')",
55
+ " return p in g or (i > 0 and not p.startswith('effect:') and (p[:i] + ':*') in g)",
56
+ 'def revition_sdk(call, *args):',
57
+ " c = __rv_sdk['calls'].get(call)",
58
+ ' if c is None:',
59
+ " raise RuntimeError('SDK ' + call + ' refused: AGENT_FORBIDDEN')",
60
+ ' need = []',
61
+ " for p in c['permissions']:",
62
+ " for i, n in enumerate(c['params']):",
63
+ " p = p.replace('<' + n + '>', __rv_sdk_str(args[i]) if i < len(args) else 'undefined')",
64
+ ' need.append(p)',
65
+ ' if any(not __rv_sdk_granted(p) for p in need):',
66
+ " raise RuntimeError('SDK ' + call + ' refused: AGENT_FORBIDDEN')",
67
+ " if call == 'secrets.get':",
68
+ " return {'handle': 'dev-sandbox:' + str(args[0])}",
69
+ " if call not in __rv_sdk['fixtures']:",
70
+ " raise RuntimeError('SDK ' + call + ' refused: no fixture (add \"' + call + '\" to fixtures.json)')",
71
+ " return __rv_sdk['fixtures'][call]",
72
+ '',
73
+ ].join('\n');
74
+ }
75
+ return [
76
+ `const __rvSdk = JSON.parse(${data});`,
77
+ 'const __rvGranted = (p) => {',
78
+ ' const i = p.indexOf(":");',
79
+ ' const g = __rvSdk.granted;',
80
+ ' return g.includes(p) || (i > 0 && !p.startsWith("effect:") && g.includes(p.slice(0, i) + ":*"));',
81
+ '};',
82
+ 'const revition = {',
83
+ ' sdk: async (call, ...args) => {',
84
+ ' const c = __rvSdk.calls[call];',
85
+ ' if (c === undefined) {',
86
+ " throw new Error('SDK ' + call + ' refused: AGENT_FORBIDDEN');",
87
+ ' }',
88
+ ' const fill = (p) => c.params.reduce((o, n, i) => o.split("<" + n + ">").join(String(args[i])), p);',
89
+ ' const need = c.permissions.map(fill);',
90
+ ' if (need.some((p) => !__rvGranted(p))) {',
91
+ " throw new Error('SDK ' + call + ' refused: AGENT_FORBIDDEN');",
92
+ ' }',
93
+ " if (call === 'secrets.get') {",
94
+ " return { handle: 'dev-sandbox:' + String(args[0]) };",
95
+ ' }',
96
+ ' if (!Object.prototype.hasOwnProperty.call(__rvSdk.fixtures, call)) {',
97
+ " throw new Error('SDK ' + call + ' refused: no fixture (add \"' + call + '\" to fixtures.json)');",
98
+ ' }',
99
+ ' return __rvSdk.fixtures[call];',
100
+ ' },',
101
+ '};',
102
+ '',
103
+ ].join('\n');
104
+ }
105
+ //# sourceMappingURL=fixture-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixture-sdk.js","sourceRoot":"","sources":["../../src/local/fixture-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAsC;IAC1D,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC,YAAY,CAAC,EAAE;IACjE,iBAAiB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;IAClD,wBAAwB,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CA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,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO;YACL,8BAA8B;YAC9B,kCAAkC,IAAI,GAAG;YACzC,sBAAsB;YACtB,oGAAoG;YACpG,0BAA0B;YAC1B,6BAA6B;YAC7B,qBAAqB;YACrB,sFAAsF;YACtF,gCAAgC;YAChC,qCAAqC;YACrC,mBAAmB;YACnB,yEAAyE;YACzE,eAAe;YACf,gCAAgC;YAChC,6CAA6C;YAC7C,mGAAmG;YACnG,wBAAwB;YACxB,oDAAoD;YACpD,yEAAyE;YACzE,+BAA+B;YAC/B,0DAA0D;YAC1D,0CAA0C;YAC1C,4GAA4G;YAC5G,uCAAuC;YACvC,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IACD,OAAO;QACL,8BAA8B,IAAI,IAAI;QACtC,8BAA8B;QAC9B,6BAA6B;QAC7B,8BAA8B;QAC9B,oGAAoG;QACpG,IAAI;QACJ,oBAAoB;QACpB,mCAAmC;QACnC,oCAAoC;QACpC,4BAA4B;QAC5B,qEAAqE;QACrE,OAAO;QACP,wGAAwG;QACxG,2CAA2C;QAC3C,8CAA8C;QAC9C,qEAAqE;QACrE,OAAO;QACP,mCAAmC;QACnC,4DAA4D;QAC5D,OAAO;QACP,0EAA0E;QAC1E,wGAAwG;QACxG,OAAO;QACP,oCAAoC;QACpC,MAAM;QACN,IAAI;QACJ,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { type FixtureSdkSpec } from './fixture-sdk.js';
2
+ export type ProgramLanguage = 'typescript' | 'python';
3
+ /** The marker of a blocked network attempt, in every refusal the child raises. */
4
+ export declare const NETWORK_BLOCKED = "REVITION_TEST_NETWORK_BLOCKED";
5
+ export declare function newNonce(): string;
6
+ /** The preload for a TypeScript program: every way out of the machine refuses, with the marker and the fix. */
7
+ export declare const NODE_NETWORK_BLOCK: string;
8
+ /** The same refusal at the top of a Python program. */
9
+ export declare const PYTHON_NETWORK_BLOCK: string;
10
+ /** The program for one call, or null when the entrypoint is not a plain identifier (never spliced into code). */
11
+ export declare function buildProgram(language: ProgramLanguage, source: string, entrypoint: string, input: unknown, nonce: string): string | null;
12
+ export interface ParsedRun {
13
+ readonly logs: readonly string[];
14
+ readonly answer: {
15
+ readonly ok: true;
16
+ readonly output: unknown;
17
+ } | {
18
+ readonly ok: false;
19
+ readonly message: string;
20
+ } | null;
21
+ }
22
+ /** Split a run's stdout into log lines and the (last) tagged answer. */
23
+ export declare function parseRun(stdout: string, nonce: string): ParsedRun;
24
+ export interface LocalCapability {
25
+ readonly language: 'ts' | 'python' | 'wasm';
26
+ readonly source: string;
27
+ readonly entrypoint: string;
28
+ }
29
+ export interface LocalResult {
30
+ readonly ok: boolean;
31
+ readonly output?: unknown;
32
+ readonly message?: string;
33
+ readonly logs: readonly string[];
34
+ /** The run tried to reach the network (and was refused). */
35
+ readonly networkAttempt: boolean;
36
+ }
37
+ export interface LocalRunOptions {
38
+ /** The program's own time, counted from the moment it starts running (the interpreter's boot is not in it). */
39
+ readonly timeoutMs: number;
40
+ /** The Python interpreter (default `python3`). */
41
+ readonly python?: string;
42
+ }
43
+ /**
44
+ * The most an interpreter may take to START the program (before `timeoutMs` begins). The legacy 10 s per test
45
+ * (legacy/src/commands.ts:58, kept for T2.1.3 AC1 parity) is the program's own time: counted from spawn, a cold Python
46
+ * or Node start on a loaded Windows machine spent it before a line of the user's code ran (PR #11 run 45592049755:
47
+ * a network-attempt test "timed out" instead of reporting the blocked attempt). A hung boot still ends here.
48
+ */
49
+ export declare const BOOT_CEILING_MS = 60000;
50
+ /**
51
+ * `--import` takes a module SPECIFIER, not a path: a Windows absolute path (`C:\\...`) parses as a URL with scheme `c:`
52
+ * and Node refuses it (ERR_UNSUPPORTED_ESM_URL_SCHEME, the windows-latest CI run). A file: URL is valid on every OS.
53
+ */
54
+ export declare function preloadSpecifier(path: string, windows?: boolean): string;
55
+ /** The environment the code gets: nothing of the developer's shell but PATH. */
56
+ export declare function childEnv(): NodeJS.ProcessEnv;
57
+ /** Run one call of a capability locally, against the fixture SDK, with the network blocked. */
58
+ export declare function runLocally(cap: LocalCapability, input: unknown, sdk: FixtureSdkSpec, opts: LocalRunOptions): Promise<LocalResult>;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * T2.1.3 (REVITION-CLI-PLAN.md:2021-2024, ported from legacy/src/local-run.ts): run one capability call on the
3
+ * developer's machine exactly as the legacy `test` did (the same program: SDK client before the code, the entrypoint
4
+ * called with the input, ONE result line tagged with a per-run nonce, read back the same way), except that:
5
+ * - the SDK client is the fixture SDK (fixture-sdk.ts): no local SDK server, no network, no credential;
6
+ * - the network is BLOCKED in the child (AC2 :2033 "a network attempt during `test` fails the run with a message"):
7
+ * a TypeScript program runs with a preload that refuses sockets, DNS and fetch; a Python program starts with the
8
+ * same refusal on its socket module.
9
+ * The child's environment is PATH only: nothing of the developer's shell (tokens, cloud credentials) reaches the code.
10
+ */
11
+ import { spawn } from 'node:child_process';
12
+ import { randomBytes } from 'node:crypto';
13
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
14
+ import { tmpdir } from 'node:os';
15
+ import { join } from 'node:path';
16
+ import { pathToFileURL } from 'node:url';
17
+ import { fixtureSdkPrelude } from './fixture-sdk.js';
18
+ const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
19
+ /** The marker of a blocked network attempt, in every refusal the child raises. */
20
+ export const NETWORK_BLOCKED = 'REVITION_TEST_NETWORK_BLOCKED';
21
+ const BLOCK_MESSAGE = 'revition test runs offline: answer SDK calls from fixtures.json';
22
+ export function newNonce() {
23
+ return `__REVITION_RESULT_${randomBytes(16).toString('hex')}__`;
24
+ }
25
+ /** The preload for a TypeScript program: every way out of the machine refuses, with the marker and the fix. */
26
+ export const NODE_NETWORK_BLOCK = [
27
+ "import net from 'node:net';",
28
+ "import tls from 'node:tls';",
29
+ "import dns from 'node:dns';",
30
+ `const blocked = (what) => { throw new Error('${NETWORK_BLOCKED}: ' + what + ' (${BLOCK_MESSAGE})'); };`,
31
+ "net.Socket.prototype.connect = function () { blocked('a network connection'); };",
32
+ "net.connect = net.createConnection = () => blocked('a network connection');",
33
+ "tls.connect = () => blocked('a TLS connection');",
34
+ "dns.lookup = () => blocked('a DNS lookup');",
35
+ "dns.promises.lookup = async () => blocked('a DNS lookup');",
36
+ "globalThis.fetch = async (u) => blocked('fetch ' + String(u));",
37
+ '',
38
+ ].join('\n');
39
+ /** The same refusal at the top of a Python program. */
40
+ export const PYTHON_NETWORK_BLOCK = [
41
+ 'import socket as __rv_net',
42
+ 'def __rv_blocked(*_a, **_k):',
43
+ ` raise OSError('${NETWORK_BLOCKED}: a network connection (${BLOCK_MESSAGE})')`,
44
+ '__rv_net.socket.connect = __rv_blocked',
45
+ '__rv_net.socket.connect_ex = __rv_blocked',
46
+ '__rv_net.create_connection = __rv_blocked',
47
+ '__rv_net.getaddrinfo = __rv_blocked',
48
+ '',
49
+ ].join('\n');
50
+ /** The program for one call, or null when the entrypoint is not a plain identifier (never spliced into code). */
51
+ export function buildProgram(language, source, entrypoint, input, nonce) {
52
+ if (!IDENTIFIER.test(entrypoint))
53
+ return null;
54
+ const json = JSON.stringify(input ?? null);
55
+ if (language === 'python') {
56
+ const b64 = Buffer.from(json, 'utf8').toString('base64');
57
+ return [
58
+ source,
59
+ 'import json as __rv_json, base64 as __rv_b64',
60
+ 'try:',
61
+ ` __rv_out = ${entrypoint}(__rv_json.loads(__rv_b64.b64decode('${b64}').decode('utf-8')))`,
62
+ ` print('${nonce}' + __rv_json.dumps({'ok': True, 'output': __rv_out}))`,
63
+ 'except Exception as __rv_e:',
64
+ ` print('${nonce}' + __rv_json.dumps({'ok': False, 'message': str(__rv_e)}))`,
65
+ '',
66
+ ].join('\n');
67
+ }
68
+ return [
69
+ source,
70
+ ';(async () => {',
71
+ ' try {',
72
+ ` const __rvOut = await ${entrypoint}(JSON.parse(${JSON.stringify(json)}));`,
73
+ ` console.log('${nonce}' + JSON.stringify({ ok: true, output: __rvOut === undefined ? null : __rvOut }));`,
74
+ ' } catch (e) {',
75
+ ` console.log('${nonce}' + JSON.stringify({ ok: false, message: String(e instanceof Error ? e.message : e) }));`,
76
+ ' }',
77
+ '})();',
78
+ '',
79
+ ].join('\n');
80
+ }
81
+ /** Split a run's stdout into log lines and the (last) tagged answer. */
82
+ export function parseRun(stdout, nonce) {
83
+ const logs = [];
84
+ let answer = null;
85
+ for (const line of stdout.split(/\r?\n/)) {
86
+ const at = line.indexOf(nonce);
87
+ if (at < 0) {
88
+ if (line.length > 0)
89
+ logs.push(line);
90
+ continue;
91
+ }
92
+ if (at > 0)
93
+ logs.push(line.slice(0, at));
94
+ try {
95
+ const v = JSON.parse(line.slice(at + nonce.length));
96
+ answer =
97
+ v.ok === true
98
+ ? { ok: true, output: v.output }
99
+ : { ok: false, message: typeof v.message === 'string' ? v.message : 'the extension failed' };
100
+ }
101
+ catch {
102
+ answer = { ok: false, message: 'the extension returned an unreadable result' };
103
+ }
104
+ }
105
+ return { logs, answer };
106
+ }
107
+ /**
108
+ * The most an interpreter may take to START the program (before `timeoutMs` begins). The legacy 10 s per test
109
+ * (legacy/src/commands.ts:58, kept for T2.1.3 AC1 parity) is the program's own time: counted from spawn, a cold Python
110
+ * or Node start on a loaded Windows machine spent it before a line of the user's code ran (PR #11 run 45592049755:
111
+ * a network-attempt test "timed out" instead of reporting the blocked attempt). A hung boot still ends here.
112
+ */
113
+ export const BOOT_CEILING_MS = 60_000;
114
+ /** The first line a program prints: its start, which begins `timeoutMs`. Random per run, never the answer nonce. */
115
+ function startLine(language, marker) {
116
+ return language === 'python' ? `print('${marker}', flush=True)\n` : `console.log('${marker}');\n`;
117
+ }
118
+ /**
119
+ * `--import` takes a module SPECIFIER, not a path: a Windows absolute path (`C:\\...`) parses as a URL with scheme `c:`
120
+ * and Node refuses it (ERR_UNSUPPORTED_ESM_URL_SCHEME, the windows-latest CI run). A file: URL is valid on every OS.
121
+ */
122
+ export function preloadSpecifier(path, windows = process.platform === 'win32') {
123
+ return pathToFileURL(path, { windows }).href;
124
+ }
125
+ /** The environment the code gets: nothing of the developer's shell but PATH. */
126
+ export function childEnv() {
127
+ return { PATH: process.env['PATH'] ?? '' };
128
+ }
129
+ /** Run one call of a capability locally, against the fixture SDK, with the network blocked. */
130
+ export function runLocally(cap, input, sdk, opts) {
131
+ if (cap.language === 'wasm') {
132
+ return Promise.resolve({ ok: false, message: 'WebAssembly runs only in the cloud sandbox: use revition eval', logs: [], networkAttempt: false });
133
+ }
134
+ const language = cap.language === 'ts' ? 'typescript' : 'python';
135
+ const nonce = newNonce();
136
+ const started = `${newNonce()}START`;
137
+ const head = `${startLine(language, started)}${language === 'python' ? `${PYTHON_NETWORK_BLOCK}${fixtureSdkPrelude(language, sdk)}` : fixtureSdkPrelude(language, sdk)}`;
138
+ const program = buildProgram(language, `${head}${cap.source}`, cap.entrypoint, input, nonce);
139
+ if (program === null)
140
+ return Promise.resolve({ ok: false, message: 'the entrypoint is not a plain name', logs: [], networkAttempt: false });
141
+ const dir = mkdtempSync(join(tmpdir(), 'revition-test-'));
142
+ const file = join(dir, language === 'python' ? 'program.py' : 'program.ts');
143
+ writeFileSync(file, program, 'utf8');
144
+ const preload = join(dir, 'no-network.mjs');
145
+ writeFileSync(preload, NODE_NETWORK_BLOCK, 'utf8');
146
+ const [cmd, args] = language === 'python'
147
+ ? [opts.python ?? 'python3', [file]]
148
+ : [process.execPath, ['--experimental-strip-types', '--no-warnings', '--import', preloadSpecifier(preload), file]];
149
+ return new Promise((resolveRun) => {
150
+ const child = spawn(cmd, args, { env: childEnv(), stdio: ['ignore', 'pipe', 'pipe'] });
151
+ let stdout = '';
152
+ let stderr = '';
153
+ const state = { timedOut: null };
154
+ const expire = (which) => setTimeout(() => {
155
+ state.timedOut = which;
156
+ child.kill('SIGKILL');
157
+ }, which === 'boot' ? BOOT_CEILING_MS : opts.timeoutMs);
158
+ // The boot ceiling runs until the program prints its start line; the program's own time runs from there.
159
+ let timer = expire('boot');
160
+ let running = false;
161
+ child.stdout.on('data', (d) => {
162
+ stdout += d.toString('utf8');
163
+ if (!running && stdout.includes(started)) {
164
+ running = true;
165
+ clearTimeout(timer);
166
+ timer = expire('run');
167
+ }
168
+ });
169
+ child.stderr.on('data', (d) => (stderr += d.toString('utf8')));
170
+ let finished = false;
171
+ const done = (r) => {
172
+ if (finished)
173
+ return;
174
+ finished = true;
175
+ clearTimeout(timer);
176
+ rmSync(dir, { recursive: true, force: true });
177
+ const text = `${r.message ?? ''}\n${r.logs.join('\n')}`;
178
+ resolveRun({ ...r, networkAttempt: text.includes(NETWORK_BLOCKED) });
179
+ };
180
+ child.on('error', (e) => done({ ok: false, message: `could not start ${cmd}: ${e.message}`, logs: [] }));
181
+ child.on('close', () => {
182
+ const parsed = parseRun(stdout.split(/\r?\n/).filter((l) => l !== started).join('\n'), nonce);
183
+ const logs = [...parsed.logs, ...stderr.split(/\r?\n/).filter((l) => l !== '')];
184
+ if (state.timedOut === 'boot')
185
+ done({ ok: false, message: `did not start within ${BOOT_CEILING_MS} ms`, logs });
186
+ else if (state.timedOut === 'run')
187
+ done({ ok: false, message: `timed out after ${opts.timeoutMs} ms`, logs });
188
+ else if (parsed.answer === null)
189
+ done({ ok: false, message: 'the program ended without an answer', logs });
190
+ else if (parsed.answer.ok)
191
+ done({ ok: true, output: parsed.answer.output, logs });
192
+ else
193
+ done({ ok: false, message: parsed.answer.message, logs });
194
+ });
195
+ });
196
+ }
197
+ //# sourceMappingURL=local-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-run.js","sourceRoot":"","sources":["../../src/local/local-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK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M,CAAC,MAAM,CAAC,EAAE;gBAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;;gBAC7E,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type ApiClient } from '@revition/cli-core';
2
+ /**
3
+ * T2.1.1 - ownership is the server's answer, never the client's guess: an app must be in the caller's own
4
+ * GET /dev/apps (there is no single-app route), and a cloud project must be readable by the caller
5
+ * (GET /dev/projects/{id} is scoped to the developer's own partition). Anything else: exit 4.
6
+ */
7
+ export declare function assertOwnedApp(api: ApiClient, appId: string): Promise<string>;
8
+ export declare function assertOwnedProject(api: ApiClient, projectId: string): Promise<string>;