@antelopejs/dms 0.18.0 → 0.18.2

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 (61) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +3 -3
  3. package/bin/control/backend-records.test.mjs +276 -0
  4. package/bin/control/backend.mjs +212 -0
  5. package/bin/control/backend.test.mjs +325 -0
  6. package/bin/control/base.mjs +3 -7
  7. package/bin/control/browser-client.mjs +6 -4
  8. package/bin/control/browser.mjs +173 -36
  9. package/bin/control/build-cache.mjs +394 -0
  10. package/bin/control/build-cache.test.mjs +270 -0
  11. package/bin/control/build-inputs.mjs +172 -0
  12. package/bin/control/build-key-refusals.test.mjs +138 -0
  13. package/bin/control/build-key.mjs +479 -0
  14. package/bin/control/build-key.test.mjs +392 -0
  15. package/bin/control/build-layout.test.mjs +314 -0
  16. package/bin/control/commands-stack.mjs +46 -6
  17. package/bin/control/commands-verify.mjs +14 -25
  18. package/bin/control/doctor.mjs +87 -16
  19. package/bin/control/forwarder.mjs +86 -0
  20. package/bin/control/forwarder.test.mjs +141 -0
  21. package/bin/control/frontend-check.mjs +54 -0
  22. package/bin/control/frontend-workspace.mjs +150 -0
  23. package/bin/control/frontend-workspace.test.mjs +133 -0
  24. package/bin/control/helpers/env.mjs +21 -0
  25. package/bin/control/helpers/evidence.mjs +13 -0
  26. package/bin/control/helpers/fake-run.mjs +290 -0
  27. package/bin/control/helpers/key-fixture.mjs +82 -0
  28. package/bin/control/helpers/pids.mjs +27 -0
  29. package/bin/control/helpers/repo.mjs +13 -0
  30. package/bin/control/helpers/tree.mjs +40 -0
  31. package/bin/control/identity.mjs +238 -0
  32. package/bin/control/identity.test.mjs +166 -0
  33. package/bin/control/journey.mjs +64 -16
  34. package/bin/control/journey.test.mjs +60 -2
  35. package/bin/control/namespaces.test.mjs +211 -0
  36. package/bin/control/options.mjs +2 -0
  37. package/bin/control/pid-guard.test.mjs +202 -0
  38. package/bin/control/prepared-workspace.mjs +20 -0
  39. package/bin/control/processes.mjs +122 -33
  40. package/bin/control/processes.test.mjs +255 -0
  41. package/bin/control/renderer.test.mjs +2 -1
  42. package/bin/control/run-copy.mjs +77 -0
  43. package/bin/control/run-state.mjs +142 -16
  44. package/bin/control/stack.mjs +259 -210
  45. package/bin/control/tab.mjs +13 -6
  46. package/bin/control/tab.test.mjs +444 -0
  47. package/bin/control/timing.mjs +244 -0
  48. package/bin/control/timing.test.mjs +197 -0
  49. package/bin/control/verify/decode.mjs +34 -36
  50. package/bin/control/verify/decode.test.mjs +40 -14
  51. package/bin/control/verify/doors.test.mjs +2 -0
  52. package/bin/control/verify/map.mjs +57 -7
  53. package/bin/control/verify/map.test.mjs +264 -0
  54. package/bin/control/verify/skill.mjs +12 -3
  55. package/bin/control/verify/types.mjs +2 -2
  56. package/bin/control/verify/verdict.mjs +34 -37
  57. package/bin/dms-control.mjs +13 -6
  58. package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
  59. package/package.json +1 -1
  60. package/skills/dms-project/SKILL.md +6 -3
  61. package/bin/control/verify/publish.mjs +0 -186
@@ -1,5 +1,11 @@
1
1
  <script setup lang="ts">
2
- import { computed, nextTick, useTemplateRef } from "vue";
2
+ import {
3
+ computed,
4
+ nextTick,
5
+ onBeforeUnmount,
6
+ onMounted,
7
+ useTemplateRef,
8
+ } from "vue";
3
9
  import CommandPaletteAssistantAnswer from "../../build/components/layout/CommandPaletteAssistantAnswer.vue";
4
10
  import { ASSISTANT_MODE_KEY } from "../../build/composables/command-palette/assistantGroups";
5
11
  import { useCommandPaletteAssistantMode } from "../../build/composables/command-palette/useCommandPaletteAssistantMode";
@@ -54,6 +60,23 @@ function switchMode(): void {
54
60
  function close(): void {
55
61
  isOpen.value = false;
56
62
  }
63
+
64
+ /**
65
+ * Set on `<html>` while the palette is mounted, which is while its ⌘ K /
66
+ * Ctrl K shortcut listens. The palette renders nothing until opened and
67
+ * loads after the dashboard around it, so nothing else on the page shows
68
+ * when the shortcut starts to work: a browser test waits for this attribute
69
+ * before it presses the keys.
70
+ */
71
+ const MOUNTED_ATTRIBUTE = "data-dms-command-palette";
72
+
73
+ onMounted(() => {
74
+ document.documentElement.setAttribute(MOUNTED_ATTRIBUTE, "");
75
+ });
76
+
77
+ onBeforeUnmount(() => {
78
+ document.documentElement.removeAttribute(MOUNTED_ATTRIBUTE);
79
+ });
57
80
  </script>
58
81
 
59
82
  <template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "AntelopeJS DMS. Plug in your PostgreSQL, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -17,10 +17,13 @@ the **ajs-cli** skill; full walkthrough: `docs/02.building/01.project-setup.md`.
17
17
 
18
18
  ## Starting a new application
19
19
 
20
- Use [template-dms-demo](https://github.com/AntelopeJS/template-dms-demo) for the default
21
- CLI-owned backend and Nuxt dashboard: `npx @antelopejs/core project init <dir> --template dms-demo` (needs Git on `PATH`).
20
+ Use [template-dms](https://github.com/AntelopeJS/template-dms) for a new project: the DMS, the
21
+ Builder and the AI assistant with no sample data, run with Docker Compose:
22
+ `npx @antelopejs/core project init <dir> --template dms-starter` (needs Git on `PATH`).
22
23
  Follow `docs/01.getting-started/03.quickstart.md` through first-admin setup (the onboarding
23
- address with the setup token that the backend prints) before adding pages. Use
24
+ address with the setup token that the `dms` log prints) before adding pages. Use
25
+ [template-dms-demo](https://github.com/AntelopeJS/template-dms-demo) (`--template dms-demo`)
26
+ to explore Helio and every module; the tutorial in `docs/01.getting-started/04.tutorial.md` runs it. Use
24
27
  [template-dms-adonis](https://github.com/AntelopeJS/template-dms-adonis) only when
25
28
  AdonisJS must own the process (`--template dms-adonis`; **embedded** mode, below; walkthrough:
26
29
  `docs/01.getting-started/07.adonisjs.md`). Evaluate these existing templates before proposing another.
@@ -1,186 +0,0 @@
1
- import { execFileSync, spawnSync } from "node:child_process";
2
- import { cpSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { git } from "../git.mjs";
6
- import { decodeCommitStatuses } from "./decode.mjs";
7
- import { originRepository } from "./verdict.mjs";
8
-
9
- const EVIDENCE_BRANCH = "verify-evidence";
10
- const SCRATCH_BRANCH = "verify-evidence-scratch";
11
-
12
- /**
13
- * @param {string} repo The checkout
14
- * @returns {boolean} Whether origin holds the evidence branch
15
- */
16
- function remoteBranchExists(repo) {
17
- return git(["ls-remote", "--heads", "origin", EVIDENCE_BRANCH], repo) !== "";
18
- }
19
-
20
- /**
21
- * Commits the run's evidence under `pr-<n>/<sha>/` of the orphan
22
- * `verify-evidence` branch and pushes it, from a temporary worktree so the
23
- * checkout under review is never touched.
24
- *
25
- * @param {import("./skill.mjs").Skill} skill The skill
26
- * @param {import("../run-state.mjs").RunState} state The run
27
- * @param {{ pr: number, headSha: string, result: string }} verdict The verdict
28
- * @returns {string} The pushed evidence commit
29
- */
30
- export function pushEvidence(skill, state, verdict) {
31
- const repo = skill.repo;
32
- const worktree = mkdtempSync(join(tmpdir(), "verify-evidence-"));
33
- try {
34
- if (remoteBranchExists(repo)) {
35
- git(
36
- [
37
- "fetch",
38
- "--quiet",
39
- "origin",
40
- `${EVIDENCE_BRANCH}:refs/remotes/origin/${EVIDENCE_BRANCH}`,
41
- ],
42
- repo,
43
- );
44
- git(
45
- [
46
- "worktree",
47
- "add",
48
- "--quiet",
49
- "--detach",
50
- worktree,
51
- `origin/${EVIDENCE_BRANCH}`,
52
- ],
53
- repo,
54
- );
55
- } else {
56
- git(
57
- [
58
- "worktree",
59
- "add",
60
- "--quiet",
61
- "--orphan",
62
- "-B",
63
- SCRATCH_BRANCH,
64
- worktree,
65
- ],
66
- repo,
67
- );
68
- }
69
- const target = join(worktree, `pr-${verdict.pr}`, verdict.headSha);
70
- rmSync(target, { recursive: true, force: true });
71
- mkdirSync(target, { recursive: true });
72
- cpSync(state.evidence, target, { recursive: true });
73
- git(["add", "--all", "."], worktree);
74
- const message = `verify: evidence for #${verdict.pr} at ${verdict.headSha.slice(0, 7)} (${verdict.result})`;
75
- git(
76
- [
77
- "-c",
78
- "commit.gpgsign=false",
79
- "commit",
80
- "--quiet",
81
- "--allow-empty",
82
- "--no-verify",
83
- "-m",
84
- message,
85
- ],
86
- worktree,
87
- );
88
- git(
89
- [
90
- "push",
91
- "--quiet",
92
- "--no-verify",
93
- "origin",
94
- `HEAD:refs/heads/${EVIDENCE_BRANCH}`,
95
- ],
96
- worktree,
97
- );
98
- return git(["rev-parse", "HEAD"], worktree);
99
- } finally {
100
- git(["worktree", "remove", "--force", worktree], repo);
101
- if (git(["branch", "--list", SCRATCH_BRANCH], repo) !== "") {
102
- git(["branch", "--quiet", "-D", SCRATCH_BRANCH], repo);
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * Posts the verdict as a PR comment.
109
- *
110
- * @param {import("./skill.mjs").Skill} skill The skill
111
- * @param {{ pr: number, markdown: string }} verdict The verdict
112
- * @returns {string} The comment URL gh prints
113
- */
114
- export function postComment(skill, verdict) {
115
- return execFileSync(
116
- "gh",
117
- [
118
- "pr",
119
- "comment",
120
- String(verdict.pr),
121
- "--repo",
122
- originRepository(skill.repo),
123
- "--body",
124
- verdict.markdown,
125
- ],
126
- { cwd: skill.repo, encoding: "utf8" },
127
- ).trim();
128
- }
129
-
130
- /**
131
- * Sets the `verify` commit status on the head SHA the verdict judged:
132
- * `success` for PASS and PASS+NOTES, `failure` for FAIL.
133
- *
134
- * @param {import("./skill.mjs").Skill} skill The skill
135
- * @param {{ headSha: string, result: string }} verdict The verdict
136
- * @param {string} targetUrl The comment URL
137
- * @returns {string | null} GitHub's error when the status could not be set
138
- */
139
- export function setStatus(skill, verdict, targetUrl) {
140
- const state = verdict.result === "FAIL" ? "failure" : "success";
141
- const result = spawnSync(
142
- "gh",
143
- [
144
- "api",
145
- "--silent",
146
- `repos/${originRepository(skill.repo)}/statuses/${verdict.headSha}`,
147
- "-f",
148
- `state=${state}`,
149
- "-f",
150
- "context=verify",
151
- "-f",
152
- `description=${skill.name}: ${verdict.result}`,
153
- "-f",
154
- `target_url=${targetUrl}`,
155
- ],
156
- { cwd: skill.repo, encoding: "utf8" },
157
- );
158
- return result.status === 0
159
- ? null
160
- : `${result.stderr}${result.stdout}`.trim() || `gh exited ${result.status}`;
161
- }
162
-
163
- /**
164
- * Reads back the `verify` status GitHub holds for a SHA, so the write is
165
- * checked through a second command.
166
- *
167
- * @param {import("./skill.mjs").Skill} skill The skill
168
- * @param {string} sha The commit
169
- * @returns {string} The status state, or `absent`
170
- */
171
- export function readStatus(skill, sha) {
172
- const answer = execFileSync(
173
- "gh",
174
- ["api", `repos/${originRepository(skill.repo)}/commits/${sha}/statuses`],
175
- {
176
- cwd: skill.repo,
177
- encoding: "utf8",
178
- },
179
- );
180
- /** @type {unknown} */
181
- const stored = JSON.parse(answer);
182
- const statuses = decodeCommitStatuses(stored, "gh api statuses");
183
- return (
184
- statuses.find((status) => status.context === "verify")?.state ?? "absent"
185
- );
186
- }