@n8r/surface 0.0.0-stage → 0.1.0-experimental.5

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 (181) hide show
  1. package/LICENSE +202 -0
  2. package/LICENSE-DOCS +395 -0
  3. package/LICENSING.md +36 -0
  4. package/README.md +207 -2
  5. package/dist/activity.d.ts +16 -0
  6. package/dist/activity.js +44 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +412 -0
  9. package/dist/codec.d.ts +6 -0
  10. package/dist/codec.js +56 -0
  11. package/dist/codex.d.ts +72 -0
  12. package/dist/codex.js +526 -0
  13. package/dist/contracts.d.ts +235 -0
  14. package/dist/contracts.js +1 -0
  15. package/dist/cyclonedx-schemas/bom-1.7.schema.json +6700 -0
  16. package/dist/cyclonedx-schemas/cryptography-defs.schema.json +576 -0
  17. package/dist/cyclonedx-schemas/jsf-0.82.schema.json +240 -0
  18. package/dist/cyclonedx-schemas/spdx.schema.json +786 -0
  19. package/dist/cyclonedx-validation.d.ts +1 -0
  20. package/dist/cyclonedx-validation.js +45 -0
  21. package/dist/html.d.ts +5 -0
  22. package/dist/html.js +74 -0
  23. package/dist/index.d.ts +7 -0
  24. package/dist/index.js +5 -0
  25. package/dist/notes.d.ts +52 -0
  26. package/dist/notes.js +184 -0
  27. package/dist/portable.d.ts +10 -0
  28. package/dist/portable.js +71 -0
  29. package/dist/recent.d.ts +9 -0
  30. package/dist/recent.js +71 -0
  31. package/dist/revisions.d.ts +2 -0
  32. package/dist/revisions.js +60 -0
  33. package/dist/settings.d.ts +23 -0
  34. package/dist/settings.js +100 -0
  35. package/dist/setup.d.ts +9 -0
  36. package/dist/setup.js +161 -0
  37. package/dist/skill-artifacts-cli.d.ts +1 -0
  38. package/dist/skill-artifacts-cli.js +13 -0
  39. package/dist/skill-artifacts.d.ts +15 -0
  40. package/dist/skill-artifacts.js +184 -0
  41. package/dist/skill-cyclonedx.d.ts +26 -0
  42. package/dist/skill-cyclonedx.js +214 -0
  43. package/dist/skill-presentation.d.ts +10 -0
  44. package/dist/skill-presentation.js +108 -0
  45. package/dist/skill-surface-cli.d.ts +1 -0
  46. package/dist/skill-surface-cli.js +37 -0
  47. package/dist/skill-surface-store.d.ts +7 -0
  48. package/dist/skill-surface-store.js +126 -0
  49. package/dist/source-tools.d.ts +102 -0
  50. package/dist/source-tools.js +201 -0
  51. package/dist/startup.d.ts +7 -0
  52. package/dist/startup.js +74 -0
  53. package/dist/surface-bom.d.ts +73 -0
  54. package/dist/surface-bom.js +139 -0
  55. package/dist/surface-draft.d.ts +22 -0
  56. package/dist/surface-draft.js +112 -0
  57. package/dist/surface-instructions.d.ts +3 -0
  58. package/dist/surface-instructions.js +32 -0
  59. package/dist/surface-overview.d.ts +15 -0
  60. package/dist/surface-overview.js +86 -0
  61. package/dist/surface-store.d.ts +34 -0
  62. package/dist/surface-store.js +213 -0
  63. package/dist/surface-view.d.ts +3 -0
  64. package/dist/surface-view.js +50 -0
  65. package/dist/validate.d.ts +4 -0
  66. package/dist/validate.js +482 -0
  67. package/docs/n8r-surface/README.md +133 -0
  68. package/docs/n8r-surface/cli-bundles.md +72 -0
  69. package/docs/n8r-surface/codex-research-transcript.md +51 -0
  70. package/docs/n8r-surface/codex-research-verification.md +176 -0
  71. package/docs/n8r-surface/command-outcomes.md +711 -0
  72. package/docs/n8r-surface/contracts.md +220 -0
  73. package/docs/n8r-surface/critical-path.md +184 -0
  74. package/docs/n8r-surface/design.md +289 -0
  75. package/docs/n8r-surface/first-use-access.md +143 -0
  76. package/docs/n8r-surface/first-use-overview.md +262 -0
  77. package/docs/n8r-surface/getting-started.md +74 -0
  78. package/docs/n8r-surface/guided-journey-verification.md +137 -0
  79. package/docs/n8r-surface/host-contract.md +176 -0
  80. package/docs/n8r-surface/implementation-decisions.md +96 -0
  81. package/docs/n8r-surface/instance-first-research.md +209 -0
  82. package/docs/n8r-surface/npm-distribution.md +107 -0
  83. package/docs/n8r-surface/npm-release.md +315 -0
  84. package/docs/n8r-surface/product-direction.md +327 -0
  85. package/docs/n8r-surface/recreation-handoff.md +117 -0
  86. package/docs/n8r-surface/researcher-discovery.md +157 -0
  87. package/docs/n8r-surface/researcher-prepared-check.md +117 -0
  88. package/docs/n8r-surface/researcher-reconciliation-trial.md +149 -0
  89. package/docs/n8r-surface/researcher-repository-check.md +95 -0
  90. package/docs/n8r-surface/researcher-skeleton-check.md +84 -0
  91. package/docs/n8r-surface/researcher-skill-verification.md +725 -0
  92. package/docs/n8r-surface/researcher-skill.md +309 -0
  93. package/docs/n8r-surface/researcher-vault.md +134 -0
  94. package/docs/n8r-surface/save-reopen-transcript.md +211 -0
  95. package/docs/n8r-surface/save-reopen-verification.md +152 -0
  96. package/docs/n8r-surface/security-assurance-strategy.md +267 -0
  97. package/docs/n8r-surface/skill-bom-verification.md +142 -0
  98. package/docs/n8r-surface/skill-cyclonedx-verification.md +144 -0
  99. package/docs/n8r-surface/skill-cyclonedx.md +85 -0
  100. package/docs/n8r-surface/skill-manual.md +129 -0
  101. package/docs/n8r-surface/skill-surface-artifacts.md +234 -0
  102. package/docs/n8r-surface/skill-usefulness-verification.md +135 -0
  103. package/docs/n8r-surface/skill-workspace-automation.md +359 -0
  104. package/docs/n8r-surface/startup-human-check.md +172 -0
  105. package/docs/n8r-surface/startup-verification.md +161 -0
  106. package/docs/n8r-surface/startup.md +151 -0
  107. package/docs/n8r-surface/surface-description-contract.md +224 -0
  108. package/docs/n8r-surface/surface-descriptions.md +173 -0
  109. package/docs/n8r-surface/surface-relationships.md +231 -0
  110. package/docs/n8r-surface/surface-revisions-transcript.md +552 -0
  111. package/docs/n8r-surface/surface-revisions-verification.md +161 -0
  112. package/docs/n8r-surface/tester-candidate.md +158 -0
  113. package/docs/n8r-surface/vault-setup-verification.md +210 -0
  114. package/docs/n8r-surface/verification.md +117 -0
  115. package/docs/n8r-surface/versioning.md +172 -0
  116. package/docs/n8r-surface/workspace-human-check.md +101 -0
  117. package/docs/n8r-surface/workspace-installation.md +68 -0
  118. package/docs/n8r-surface/workspace-verification.md +350 -0
  119. package/docs/n8r-surface/workspace.md +83 -0
  120. package/examples/researcher/README.md +100 -0
  121. package/examples/researcher/composed.surface.json +430 -0
  122. package/examples/researcher/composed.surface.yaml +283 -0
  123. package/examples/researcher/cyclonedx/configured/README.md +7 -0
  124. package/examples/researcher/cyclonedx/configured/manifest.json +10 -0
  125. package/examples/researcher/cyclonedx/configured/mapping.json +323 -0
  126. package/examples/researcher/cyclonedx/configured/surface-records.json +1275 -0
  127. package/examples/researcher/cyclonedx/configured/surface.cdx.json +79 -0
  128. package/examples/researcher/descriptions/README.md +29 -0
  129. package/examples/researcher/descriptions/bound-r1.json +141 -0
  130. package/examples/researcher/descriptions/bound-r2.json +153 -0
  131. package/examples/researcher/descriptions/capability.json +167 -0
  132. package/examples/researcher/descriptions/research-r1.json +153 -0
  133. package/examples/researcher/descriptions/research-r2.json +157 -0
  134. package/examples/researcher/descriptions/sources.md +24 -0
  135. package/examples/researcher/harbor-r1.research.html +193 -0
  136. package/examples/researcher/harbor-r2.research.html +226 -0
  137. package/examples/researcher/lumen-manual-edit.pending.html +271 -0
  138. package/examples/researcher/lumen-r1.research.html +271 -0
  139. package/examples/researcher/lumen-r2.research.html +280 -0
  140. package/examples/researcher/relationships/README.md +34 -0
  141. package/examples/researcher/relationships/bound-r1.json +346 -0
  142. package/examples/researcher/relationships/bound-r2.json +358 -0
  143. package/examples/researcher/relationships/capability.json +325 -0
  144. package/examples/researcher/relationships/config/assistant.env.example +4 -0
  145. package/examples/researcher/relationships/research-r1.json +300 -0
  146. package/examples/researcher/relationships/research-r2.json +304 -0
  147. package/examples/researcher/relationships/sources.md +38 -0
  148. package/examples/researcher/sources/harbor-api.md +16 -0
  149. package/examples/researcher/sources/harbor-auth.md +8 -0
  150. package/examples/researcher/sources/lumen-guide.md +28 -0
  151. package/examples/researcher/sources/lumen-settings.md +9 -0
  152. package/examples/researcher/surface-bom/README.md +17 -0
  153. package/examples/researcher/surface-bom/initial.cdx.json +188 -0
  154. package/package.json +45 -4
  155. package/plugins/n8r-surface/.codex-plugin/plugin.json +31 -0
  156. package/plugins/n8r-surface/LICENSE +202 -0
  157. package/plugins/n8r-surface/LICENSE-DOCS +395 -0
  158. package/plugins/n8r-surface/LICENSING.md +39 -0
  159. package/plugins/n8r-surface/assets/icon.svg +5 -0
  160. package/plugins/n8r-surface/plugin.json +27 -0
  161. package/plugins/n8r-surface/skills/research/SKILL.md +163 -0
  162. package/plugins/n8r-surface/skills/research/agents/openai.yaml +4 -0
  163. package/plugins/n8r-surface/skills/research/references/artifacts.md +152 -0
  164. package/plugins/n8r-surface/skills/research/references/cyclonedx.md +207 -0
  165. package/plugins/n8r-surface/skills/research/references/discovery-map.md +178 -0
  166. package/plugins/n8r-surface/skills/research/references/examples/bound-r1.json +346 -0
  167. package/plugins/n8r-surface/skills/research/references/examples/capability.json +325 -0
  168. package/plugins/n8r-surface/skills/research/references/examples/research-r1.json +300 -0
  169. package/plugins/n8r-surface/skills/research/references/examples/surface.cdx.json +188 -0
  170. package/plugins/n8r-surface/skills/research/references/first-use-access.md +97 -0
  171. package/plugins/n8r-surface/skills/research/references/first-use-overview.md +101 -0
  172. package/plugins/n8r-surface/skills/research/references/instance-first.md +125 -0
  173. package/plugins/n8r-surface/skills/research/references/model-meanings.md +55 -0
  174. package/plugins/n8r-surface/skills/research/references/skeleton-surface.md +105 -0
  175. package/plugins/n8r-surface/skills/research/references/working-notes.md +121 -0
  176. package/plugins/n8r-surface/skills/research/references/workspace.md +89 -0
  177. package/plugins/n8r-surface/skills/research/scripts/THIRD-PARTY-NOTICES.txt +273 -0
  178. package/plugins/n8r-surface/skills/research/scripts/artifacts.mjs +8348 -0
  179. package/plugins/n8r-surface/skills/research/scripts/cyclonedx.mjs +28113 -0
  180. package/plugins/n8r-surface/skills/research/scripts/surface.mjs +27800 -0
  181. package/plugins/n8r-surface/skills/research/scripts/workspace.mjs +120 -0
package/README.md CHANGED
@@ -1,3 +1,208 @@
1
- # Temporary Holding Version
1
+ # n8r-surface
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The home of the **AI Surface Model**, an open model for describing the connected
4
+ components, configuration and relationships of an AI system, at the level of
5
+ detail available or useful. This repository also develops the experimental
6
+ `n8r-surface` command and Researcher library.
7
+
8
+ > [!NOTE]
9
+ > **Early draft; experimental tooling.** The model concepts and illustrative
10
+ > fields remain provisional. The library and command are available as the
11
+ > experimental [`@n8r/surface` package](https://www.npmjs.com/package/@n8r/surface/v/0.1.0-experimental.2);
12
+ > there is no universal schema, exporter or deployment engine yet. The Researcher
13
+ > skill supports working research through the host. The standalone command now
14
+ > supports bounded Codex research with numbered Markdown saves and fresh-session reopening.
15
+
16
+ ## Why this is needed
17
+
18
+ An AI model's name does not tell you which services an application calls, how
19
+ authentication is configured, or which setup produced an Experiment result.
20
+ Answering those questions can mean piecing together diagrams, configuration files
21
+ and notes, often with incomplete information.
22
+
23
+ The AI Surface Model aims to make that context explicit and shareable. Start with
24
+ the components and connections you know, record the gaps, and add detail as it
25
+ becomes available. A saved description should help someone investigate a system,
26
+ understand a result or assess what they would need to recreate a setup.
27
+
28
+ ## Who it is for
29
+
30
+ | If you… | The model is intended to help you… |
31
+ | --- | --- |
32
+ | Build or operate AI applications | Describe services, integration settings and dependencies across a setup. |
33
+ | Investigate security or component changes | Find affected components while keeping unknown versions and coverage gaps visible. |
34
+ | Run experiments | Connect results to the definition revision and effective setup actually used. |
35
+ | Build inventory, provenance or analysis tools | Explore exchange of a defined subset with explicit mapping losses. |
36
+
37
+ It is usable independently of Injectionator or any particular application.
38
+ Security investigation, reproducibility and configuration understanding are all
39
+ part of its scope.
40
+
41
+ For a compact security view, start with the provisional
42
+ [Skeleton Surface v0.1](spec/README.md#output-profiles-and-size): key nodes,
43
+ relationships and potential LLM/tool interception points, with linked evidence
44
+ and explicit gaps. Bindings are optional; larger research is not a minimum size.
45
+
46
+ This repository maintains the model and standalone tooling. Application design
47
+ and implementation for `n8r-labs` are maintained in its separate repository.
48
+
49
+ For the agreed professional-service direction, see the
50
+ [AI Surface security assurance strategy](docs/n8r-surface/security-assurance-strategy.md):
51
+ policy, controls, implementation guidance and observable assessment of static and
52
+ live systems. For the proposed first proof of value, see [from source discovery to a verified defensive change](docs/n8r-surface/product-direction.md).
53
+ The installed skill starts with folders and URLs; possible integrations remain
54
+ distinct from configured systems and runtime evidence.
55
+
56
+ ## What it describes
57
+
58
+ An **AI Surface** is the connected system being described: applications, agents,
59
+ AI models, inference services, authentication, tools, data stores and supporting
60
+ infrastructure, together with their configuration and relationships.
61
+
62
+ There is one model: the **AI Surface Model**. A **fragment** is a working term
63
+ for a focused part of a description within it, such as Lab or Experiment; fragment
64
+ boundaries and serialization remain open. A Lab contains Experiments, and each
65
+ Experiment requests its setup directly from the Lab.
66
+
67
+ Definitions stay separate from deployments, dated observations and Experiment
68
+ Runs. A Run refers to the definition revision and effective setup used, so later
69
+ discovery does not silently change what an earlier result refers to.
70
+
71
+ ## Experimental tooling
72
+
73
+ The [Researcher library](docs/n8r-surface/contracts.md) reads and writes bounded
74
+ HTML research records and partial definitions in JSON/YAML, with
75
+ [synthetic acceptance cases](examples/researcher/README.md). These checks do not
76
+ establish universal model conformance or consumer compatibility.
77
+
78
+ **To try the command, follow [Install, run and check research](docs/n8r-surface/getting-started.md).**
79
+
80
+ The [bare-startup command](docs/n8r-surface/startup.md) displays local settings and
81
+ saved artefacts, then offers explicitly confirmed local vault setup or reuses the
82
+ saved vault. The explicit `discover [source]` command now starts a
83
+ [Codex research conversation](docs/n8r-surface/codex-research-verification.md)
84
+ with source evidence, follow-up, explicit Markdown saves and fresh-session reopening.
85
+ See [save/reopen evidence and limits](docs/n8r-surface/save-reopen-verification.md).
86
+ The current candidate adds validated paired research HTML and partial Surface JSON,
87
+ with fresh-session revision; see the [candidate evidence and limits](docs/n8r-surface/surface-revisions-verification.md). See the
88
+ [critical path](docs/n8r-surface/critical-path.md) for the next work and the
89
+ [command outcome specification](docs/n8r-surface/command-outcomes.md) for the
90
+ intended interactions and required evidence.
91
+
92
+ The issue #41 skill candidate adds [standalone workspace setup and recognition](docs/n8r-surface/workspace.md)
93
+ before research, with a minimal identity record and preservation checks. Installed
94
+ candidate PM acceptance is [tracked separately](docs/n8r-surface/workspace-verification.md).
95
+
96
+ The [n8r-surface Researcher skill package](docs/n8r-surface/researcher-skill.md) is now
97
+ available for testing in the existing Codex/ChatGPT harness. It uses the host's
98
+ source access and conversation to produce evidence-backed working notes. The
99
+ [discovery guide](docs/n8r-surface/researcher-discovery.md) focuses on AI-relevant
100
+ graphs, reusable product knowledge and comparing descriptions with evidence. See
101
+ [verification and pending Work-mode checks](docs/n8r-surface/researcher-skill-verification.md).
102
+ Candidate 0.1.16 saves a [self-contained CycloneDX Surface](docs/n8r-surface/skill-cyclonedx.md)
103
+ with a generated brief, connected overview and investigation journal. See the
104
+ [0.1.14 first-use verification](docs/n8r-surface/first-use-overview.md). Follow the [working user manual](docs/n8r-surface/skill-manual.md)
105
+ for multi-component research, saving and continuation.
106
+ The [freeform component journey](docs/n8r-surface/guided-journey-verification.md)
107
+ records installed-skill exploration, later source intake and saved continuation.
108
+ Candidate 0.1.15 adds [instance-first research](docs/n8r-surface/instance-first-research.md)
109
+ through the host harness, with configured and observed evidence kept distinct.
110
+ Candidate 0.1.16 adds [progressive first-use access guidance](docs/n8r-surface/first-use-access.md)
111
+ for users starting with a description, document or inaccessible source.
112
+ The accepted delivery order is skill first, standalone CLI second, then separate
113
+ n8r-labs adaptation.
114
+ The [local vault](docs/n8r-surface/researcher-vault.md) holds research notes, intermediate artifacts
115
+ and Surface descriptions at a user-selected local path. It also includes prepared test material
116
+ and a walkthrough for investigating another chat-system repository.
117
+
118
+ ## Start at the depth you need
119
+
120
+ The levels are reading paths, not prerequisites. Start at 100 for an introduction,
121
+ or jump to the examples, design questions or contribution guidance.
122
+
123
+ | Level | Start here | What you will find |
124
+ | --- | --- | --- |
125
+ | **100 · Understand** | [Model overview](models/ai-surface-model.md), then [Conceptual guide](models/README.md) | The purpose, vocabulary and a walkthrough of one investigation. |
126
+ | **200 · Explore** | [Synthetic examples](examples/README.md) | Compare descriptions at two depths; identify known facts, gaps and recreation requirements. |
127
+ | **300 · Examine** | [Draft concepts](spec/README.md) and [interoperability research](docs/interoperability.md) | Identity, evidence, partial knowledge, open decisions and proposed mappings to other formats. |
128
+ | **400 · Contribute and extend** | [Propose a change or extension](CONTRIBUTING.md#propose-a-change-or-extension) | Turn a use case into a proposal, example or bounded mapping, then follow the contribution workflow. |
129
+
130
+ The [roadmap](docs/roadmap.md) describes the intended sequence of work and the
131
+ evidence needed before a release.
132
+
133
+ ## See progressive detail
134
+
135
+ Both [LibreChat examples](examples/README.md) describe a fictional authentication
136
+ path. These JSON excerpts show the **same component** at two levels of detail.
137
+ Field names are illustrative, not a released schema.
138
+
139
+ In the [minimal description](examples/librechat/minimal.json), its role is known
140
+ but its product is not:
141
+
142
+ ```json
143
+ {
144
+ "id": "component:authentication",
145
+ "kind": "service",
146
+ "role": "authentication",
147
+ "product": { "status": "unknown" }
148
+ }
149
+ ```
150
+
151
+ In the [expanded description](examples/librechat/expanded.json), the same identity
152
+ has more detail:
153
+
154
+ ```json
155
+ {
156
+ "id": "component:authentication",
157
+ "kind": "service",
158
+ "role": "authentication",
159
+ "product": {
160
+ "status": "known",
161
+ "name": "Keycloak",
162
+ "basis": "synthetic example"
163
+ }
164
+ }
165
+ ```
166
+
167
+ The expanded file also describes an OpenID Connect relationship and a supporting
168
+ database. Some settings remain unknown or omitted; inference and other application
169
+ dependencies remain unexplored. Neither example establishes a running integration
170
+ or enough information for recreation. They are alternative synthetic descriptions,
171
+ not a revision history or evidence of a deployment change.
172
+
173
+ Detail can grow along any connection, with shared components and cycles. Depth is
174
+ relative to the starting point and has no fixed two-hop ceiling. Missing detail
175
+ does not establish absence.
176
+
177
+ ## Working with existing standards and tools
178
+
179
+ We have adopted CycloneDX as the standards direction for AI Surface exchange and
180
+ SBOM-first discovery. See the [strategic brief](docs/cyclonedx-adoption.md) for the
181
+ decision, discovery policy and open representation choices. Implementation remains
182
+ future work; SPDX remains an interoperability candidate. Use native constructs
183
+ where suitable and report omitted or transformed information.
184
+ Compatibility and round-trip fidelity still need evidence from named versions and
185
+ consuming tools. See the [interoperability research](docs/interoperability.md) for
186
+ mapping questions and related work, including Prismor and sbom-tools.
187
+
188
+ ## Contribute or cite
189
+
190
+ Start with an issue, use a dedicated branch and open a linked draft PR; see
191
+ [Contributing](CONTRIBUTING.md) for proposals, checks and the full workflow.
192
+
193
+ Use [CITATION.cff](CITATION.cff) for attribution and include the exact commit URL
194
+ you used when citing this evolving draft.
195
+
196
+ ## Licence
197
+
198
+ Machine-readable model assets, schemas, examples, code snippets and tooling use
199
+ [Apache-2.0](LICENSE). Written specification and documentation use
200
+ [CC-BY-4.0](LICENSE-DOCS). See [LICENSING.md](LICENSING.md) for the material split
201
+ and attribution requirements.
202
+
203
+ Commercial and proprietary reuse are welcome under those terms. Users retain
204
+ control of the licensing and publication of their own Surface descriptions and
205
+ Experiment data. Third-party material retains its applicable terms.
206
+
207
+ This is an independent Injectionator project, with no claimed OWASP affiliation
208
+ or endorsement.
@@ -0,0 +1,16 @@
1
+ import type { Writable } from 'node:stream';
2
+ /** Terminal liveness only: elapsed time does not imply remote progress. */
3
+ export declare class Activity {
4
+ private stream;
5
+ private label;
6
+ private started;
7
+ private frame;
8
+ private timer;
9
+ constructor(stream?: Writable & {
10
+ isTTY?: boolean;
11
+ });
12
+ private clear;
13
+ private draw;
14
+ log(text: string): void;
15
+ run<T>(label: string, action: () => Promise<T>): Promise<T>;
16
+ }
@@ -0,0 +1,44 @@
1
+ /** Terminal liveness only: elapsed time does not imply remote progress. */
2
+ export class Activity {
3
+ stream;
4
+ label;
5
+ started = 0;
6
+ frame = 0;
7
+ timer;
8
+ constructor(stream = process.stdout) {
9
+ this.stream = stream;
10
+ }
11
+ clear() { if (this.label && this.stream.isTTY)
12
+ this.stream.write('\r\x1b[2K'); }
13
+ draw() {
14
+ if (this.label && this.stream.isTTY) {
15
+ const frames = ['|', '/', '-', '\\'];
16
+ this.stream.write(`\r\x1b[2K${frames[this.frame++ % frames.length]} ${this.label}… ${Math.floor((Date.now() - this.started) / 1000)}s (Ctrl-C to cancel)`);
17
+ }
18
+ }
19
+ log(text) {
20
+ this.clear();
21
+ this.stream.write(text);
22
+ this.draw();
23
+ }
24
+ async run(label, action) {
25
+ this.label = label;
26
+ this.started = Date.now();
27
+ this.frame = 0;
28
+ if (this.stream.isTTY) {
29
+ this.draw();
30
+ this.timer = setInterval(() => this.draw(), 250);
31
+ this.timer.unref();
32
+ }
33
+ try {
34
+ return await action();
35
+ }
36
+ finally {
37
+ if (this.timer)
38
+ clearInterval(this.timer);
39
+ this.timer = undefined;
40
+ this.clear();
41
+ this.label = undefined;
42
+ }
43
+ }
44
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};