@routinerun/form 0.0.0-stage → 0.1.0

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 (66) hide show
  1. package/README.md +53 -2
  2. package/bin/routinerun.js +72 -0
  3. package/package.json +43 -4
  4. package/schema/skin.v1.schema.json +194 -0
  5. package/schema/written-routine.v1.schema.json +1722 -0
  6. package/schema/written-routine.v2.schema.json +2396 -0
  7. package/src/check.js +102 -0
  8. package/src/index.js +47 -0
  9. package/src/link.js +36 -0
  10. package/src/schema-skin.js +196 -0
  11. package/src/schema-v1.js +1724 -0
  12. package/src/schema-v2.js +2398 -0
  13. package/src/skin.js +14 -0
  14. package/src/upgrade.js +118 -0
  15. package/starters/on-call/a-practice-page.json +43 -0
  16. package/starters/on-call/after-it-is-fixed.json +42 -0
  17. package/starters/on-call/handing-the-pager-over.json +41 -0
  18. package/starters/on-call/putting-something-live.json +48 -0
  19. package/starters/on-call/the-alert-that-keeps-coming-back.json +42 -0
  20. package/starters/on-call/when-something-pages-you.json +50 -0
  21. package/starters/starters/a-chapter-at-a-time.json +42 -0
  22. package/starters/starters/a-glass-of-water.json +51 -0
  23. package/starters/starters/a-meeting-you-called.json +47 -0
  24. package/starters/starters/a-post-idea-to-published.json +61 -0
  25. package/starters/starters/a-shoot-shot-by-shot.json +49 -0
  26. package/starters/starters/awake-at-three.json +43 -0
  27. package/starters/starters/before-a-trial-charges-you.json +47 -0
  28. package/starters/starters/before-people-come-round.json +40 -0
  29. package/starters/starters/check-a-purchase.json +43 -0
  30. package/starters/starters/closing-the-day.json +38 -0
  31. package/starters/starters/count-it-without-looking.json +40 -0
  32. package/starters/starters/due-diligence-on-a-deal.json +76 -0
  33. package/starters/starters/fifty-two-and-seventeen.json +37 -0
  34. package/starters/starters/first-half-hour.json +57 -0
  35. package/starters/starters/five-sets.json +41 -0
  36. package/starters/starters/getting-up-when-it-is-dark.json +61 -0
  37. package/starters/starters/good-night-house.json +53 -0
  38. package/starters/starters/home-and-the-house-knows.json +42 -0
  39. package/starters/starters/inbox.json +31 -0
  40. package/starters/starters/into-deep-work.json +53 -0
  41. package/starters/starters/leaving-a-note-for-tomorrow.json +37 -0
  42. package/starters/starters/leaving-it-empty-for-a-week.json +49 -0
  43. package/starters/starters/out-and-the-house-off.json +43 -0
  44. package/starters/starters/out-of-the-door.json +37 -0
  45. package/starters/starters/physio-three-times-a-day.json +60 -0
  46. package/starters/starters/picking-it-back-up.json +37 -0
  47. package/starters/starters/pomodoro-four-rounds.json +50 -0
  48. package/starters/starters/read-it-and-keep-one-thing.json +44 -0
  49. package/starters/starters/reading-somebodys-code.json +48 -0
  50. package/starters/starters/receipts-before-they-are-lost.json +45 -0
  51. package/starters/starters/run-and-walk.json +79 -0
  52. package/starters/starters/something-that-runs-out.json +42 -0
  53. package/starters/starters/something-worth-remembering.json +40 -0
  54. package/starters/starters/standup-before-the-call.json +51 -0
  55. package/starters/starters/sunday-evening.json +45 -0
  56. package/starters/starters/tabata-four-minutes.json +73 -0
  57. package/starters/starters/the-bills-this-month.json +48 -0
  58. package/starters/starters/the-button-one-press-at-a-time.json +94 -0
  59. package/starters/starters/the-week-looked-at.json +46 -0
  60. package/starters/starters/the-weekly-shop.json +50 -0
  61. package/starters/starters/to-read.json +31 -0
  62. package/starters/starters/to-watch.json +31 -0
  63. package/starters/starters/washing-end-to-end.json +43 -0
  64. package/starters/starters/when-something-breaks.json +46 -0
  65. package/starters/starters/winding-down.json +58 -0
  66. package/starters/starters/work-until-you-drift.json +40 -0
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @routinerun/form
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
+ Check and upgrade a routine written for Routine Run, in form 1 or form 2. The same checks
4
+ the relay makes before it hands a routine to a phone, and the same upgrade the app makes when
5
+ it reads form 1.
6
+
7
+ ```bash
8
+ npx @routinerun/form check morning.json
9
+ npx @routinerun/form upgrade morning.json
10
+ npx @routinerun/form new morning
11
+ ```
12
+
13
+ ```js
14
+ import { problems, upgrade } from "@routinerun/form";
15
+
16
+ problems(routine); // [] when it is fine, else one sentence per problem, most useful first
17
+ upgrade(routine); // form 2, from form 1; form 2 comes back as it is
18
+ ```
19
+
20
+ ## The two forms
21
+
22
+ **Form 2** is the routine in the app's own words. Compared with form 1:
23
+ - `about` is `description`;
24
+ - a step's `times` is `repeats`;
25
+ - the ten deadline keys on a step are one `deadline` object;
26
+ - a routine's `times` are `triggers`;
27
+ - form 2 can also say notes, places, a step's tags and check-ins, other triggers, and reactions.
28
+
29
+ **Form 1** is still read for good, and `upgrade` turns it into form 2 by the same table the app
30
+ uses.
31
+
32
+ The app hands out form 2 and, since 15 November 2026, teaches it (`TAUGHT_FORM`): every build
33
+ since 1.3 reads it, and a link or a prompt is read on whatever phone it reaches. A link takes
34
+ form 1 or 2 and nothing newer.
35
+
36
+ ## Where things come from
37
+
38
+ - `schema/`: the JSON Schemas, written by the app's own reader (`WrittenRoutineSchema.swift`),
39
+ never by hand. Form 2's says `$id: https://routinerun.com/schema/routine.v2.json`.
40
+ - `src/schema-v1.js`, `src/schema-v2.js`: the same, as modules, for readers without JSON
41
+ imports.
42
+ - `fixtures/upgrade/`: every example the app shows an assistant and every starter, as form 1
43
+ beside the form 2 the app makes of it, plus one file using every key form 2 renames. The
44
+ app's tests write them; `test/form.test.js` asks this package for the same form 2 from each.
45
+ - The starters are not in this folder. They are the app's own files, which it bundles and
46
+ reads: every routine it ships, in form 2, with where it sits in the catalogue. In the
47
+ public repository they are `routines/<starters|on-call>/<slug>.json`, and `routinerun new`
48
+ reads them from there. The package on npm carries a copy, made as it is packed
49
+ (`scripts/pack-starters.js`).
50
+ - `skins/`: the three skins of the row design, as data (`schema/skin.v1.schema.json`). A skin
51
+ changes how rows look and nothing about what they say.
52
+
53
+ The schemas and the pairs are written by the app, and the starters are the app's; all of
54
+ them are edited there, never here. Published to npm from the public repository.
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // routinerun check <file>... says what is wrong with each routine or skin, or that it is fine
3
+ // routinerun upgrade <file> prints the routine in form 2
4
+ // routinerun link <file> prints a link that opens the routine on an iPhone
5
+ // routinerun new [name] lists the starters, or prints one to start from
6
+ //
7
+ // A file holds one routine or a list of them, in either form, or one skin.
8
+
9
+ import { readFileSync, readdirSync, existsSync } from "node:fs";
10
+ import { problems, upgrade } from "../src/index.js";
11
+ import { problemsWithSkin } from "../src/skin.js";
12
+ import { linkFor } from "../src/link.js";
13
+
14
+ const [command, ...args] = process.argv.slice(2);
15
+
16
+ function read(file) {
17
+ const said = JSON.parse(readFileSync(file, "utf8"));
18
+ return Array.isArray(said) ? said : [said];
19
+ }
20
+
21
+ // The starters are the app's own files here, which it bundles and reads, and they are
22
+ // routines/ in the public repository. An install from npm carries a copy (scripts/pack-starters.js).
23
+ const shelves = [
24
+ new URL("../starters/", import.meta.url),
25
+ new URL("../../RoutineKit/Sources/RoutineKit/Resources/Starters/", import.meta.url),
26
+ new URL("../../../routines/", import.meta.url),
27
+ ].filter((url) => existsSync(url));
28
+ function starters() {
29
+ const seen = new Set();
30
+ return shelves.flatMap((shelf) => readdirSync(shelf).flatMap((group) => {
31
+ const folder = new URL(`${group}/`, shelf);
32
+ return existsSync(folder) ? readdirSync(folder).filter((name) => name.endsWith(".json")).map((name) => ({ group, slug: name.slice(0, -5), url: new URL(name, folder) })) : [];
33
+ })).filter(({ group, slug }) => !seen.has(`${group}/${slug}`) && seen.add(`${group}/${slug}`));
34
+ }
35
+
36
+ if (command === "check" && args.length) {
37
+ let wrong = 0;
38
+ for (const file of args) {
39
+ read(file).forEach((said, index) => {
40
+ const found = "skin" in said ? problemsWithSkin(said) : problems(said);
41
+ const which = `${file}${index ? ` (${index + 1})` : ""}`;
42
+ if (found.length) {
43
+ wrong += 1;
44
+ console.log(`${which}: ${found[0]}${found.length > 1 ? ` (and ${found.length - 1} more)` : ""}`);
45
+ } else {
46
+ console.log(`${which}: fine, ${"skin" in said ? "a skin" : `form ${said.routineRun}`}`);
47
+ }
48
+ });
49
+ }
50
+ process.exit(wrong ? 1 : 0);
51
+ } else if (command === "upgrade" && args.length === 1) {
52
+ const routines = read(args[0]).map(upgrade);
53
+ console.log(JSON.stringify(routines.length === 1 ? routines[0] : routines, null, 2));
54
+ } else if (command === "link" && args.length === 1) {
55
+ const [routine] = read(args[0]);
56
+ const { link, problem } = await linkFor(routine);
57
+ if (problem) { console.log(problem); process.exit(1); }
58
+ console.log(link ?? "Too long for a link. Paste the JSON into the app instead: Ask an AI to write it.");
59
+ } else if (command === "new") {
60
+ const all = starters();
61
+ if (!args.length) {
62
+ for (const { group, slug } of all) console.log(`${group}/${slug}`);
63
+ } else {
64
+ const found = all.find(({ slug, group }) => slug === args[0] || `${group}/${slug}` === args[0]);
65
+ if (!found) { console.log(`No starter called ${args[0]}. Run routinerun new to list them.`); process.exit(1); }
66
+ const { catalogue, ...routine } = JSON.parse(readFileSync(found.url, "utf8"));
67
+ console.log(JSON.stringify(routine, null, 2));
68
+ }
69
+ } else {
70
+ console.log("routinerun check <file>...\nroutinerun upgrade <file>\nroutinerun link <file>\nroutinerun new [name]");
71
+ process.exit(command ? 1 : 0);
72
+ }
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@routinerun/form",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Check and upgrade routines written for Routine Run, in form 1 or form 2.",
5
+ "keywords": [
6
+ "routine-run",
7
+ "routines",
8
+ "checklist",
9
+ "json-schema"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://routinerun.com/developers",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/routinerun/routinerun.git",
16
+ "directory": "packages/form"
17
+ },
18
+ "bugs": "https://github.com/routinerun/routinerun/issues",
19
+ "type": "module",
20
+ "exports": {
21
+ ".": "./src/index.js",
22
+ "./schema/v1": "./schema/written-routine.v1.schema.json",
23
+ "./schema/v2": "./schema/written-routine.v2.schema.json"
24
+ },
25
+ "bin": {
26
+ "routinerun": "./bin/routinerun.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "src",
31
+ "schema",
32
+ "starters",
33
+ "README.md"
34
+ ],
35
+ "engines": {
36
+ "node": ">=20"
37
+ },
38
+ "scripts": {
39
+ "test": "node --test test/*.test.js",
40
+ "prepack": "node scripts/pack-starters.js"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
45
+ }
@@ -0,0 +1,194 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://routinerun.com/schema/skin.v1.json",
4
+ "title": "Routine Run: a skin (version 1)",
5
+ "description": "How the rows of a page look: their density, their type, their radius and the colours of the ground they stand on. A skin changes nothing about what a row says: the kind word, the dot that says whose a thing is, the routine's group under \"From\" and the order in which a long line is cut are the app's, on every skin. Colours only, no code: a skin is data anybody can write and nobody has to trust.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "skin",
10
+ "name",
11
+ "light",
12
+ "dark",
13
+ "rows",
14
+ "type"
15
+ ],
16
+ "properties": {
17
+ "skin": {
18
+ "const": 1,
19
+ "description": "The version of this shape."
20
+ },
21
+ "name": {
22
+ "type": "string",
23
+ "pattern": "\\S"
24
+ },
25
+ "audience": {
26
+ "type": "string",
27
+ "description": "Who it is for, in a sentence."
28
+ },
29
+ "light": {
30
+ "$ref": "#/$defs/palette"
31
+ },
32
+ "dark": {
33
+ "$ref": "#/$defs/palette"
34
+ },
35
+ "rows": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": [
39
+ "padding",
40
+ "minHeight",
41
+ "radius",
42
+ "detailLines",
43
+ "layout"
44
+ ],
45
+ "properties": {
46
+ "padding": {
47
+ "type": "number",
48
+ "minimum": 4,
49
+ "maximum": 16,
50
+ "description": "Points above and below a row's words."
51
+ },
52
+ "minHeight": {
53
+ "type": "number",
54
+ "minimum": 32,
55
+ "maximum": 64,
56
+ "description": "Points. 44 is the system's least for something that is pressed."
57
+ },
58
+ "radius": {
59
+ "type": "number",
60
+ "minimum": 0,
61
+ "maximum": 24,
62
+ "description": "Points, on the card a list of rows sits in."
63
+ },
64
+ "detailLines": {
65
+ "type": "integer",
66
+ "minimum": 1,
67
+ "maximum": 3,
68
+ "description": "How many lines a row's second line may take before it is cut."
69
+ },
70
+ "layout": {
71
+ "enum": [
72
+ "twoLines",
73
+ "oneLine"
74
+ ],
75
+ "description": "\"oneLine\" puts the second line after the name, for a dense screen."
76
+ }
77
+ }
78
+ },
79
+ "type": {
80
+ "type": "object",
81
+ "additionalProperties": false,
82
+ "required": [
83
+ "title",
84
+ "detail"
85
+ ],
86
+ "properties": {
87
+ "title": {
88
+ "$ref": "#/$defs/font"
89
+ },
90
+ "detail": {
91
+ "$ref": "#/$defs/font"
92
+ },
93
+ "value": {
94
+ "$ref": "#/$defs/font"
95
+ }
96
+ }
97
+ }
98
+ },
99
+ "$defs": {
100
+ "palette": {
101
+ "type": "object",
102
+ "additionalProperties": false,
103
+ "required": [
104
+ "page",
105
+ "card",
106
+ "ink",
107
+ "ink2",
108
+ "ink3",
109
+ "line",
110
+ "fill",
111
+ "accent",
112
+ "unanswered"
113
+ ],
114
+ "properties": {
115
+ "page": {
116
+ "type": "string",
117
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
118
+ "description": "The ground every card sits on."
119
+ },
120
+ "card": {
121
+ "type": "string",
122
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
123
+ "description": "A card: a list, a sheet, a row's surface."
124
+ },
125
+ "ink": {
126
+ "type": "string",
127
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
128
+ "description": "Words at full weight: a row's name."
129
+ },
130
+ "ink2": {
131
+ "type": "string",
132
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
133
+ "description": "Secondary words: the second line of a row."
134
+ },
135
+ "ink3": {
136
+ "type": "string",
137
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
138
+ "description": "The quietest words: a chevron, a hint."
139
+ },
140
+ "line": {
141
+ "type": "string",
142
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
143
+ "description": "A separator between rows."
144
+ },
145
+ "fill": {
146
+ "type": "string",
147
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
148
+ "description": "A control's resting fill: a stepper, a chip."
149
+ },
150
+ "accent": {
151
+ "type": "string",
152
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
153
+ "description": "What a press does: a row that acts, a switch that is on."
154
+ },
155
+ "unanswered": {
156
+ "type": "string",
157
+ "pattern": "^(#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\))$",
158
+ "description": "The dot on what is local and nobody has answered for."
159
+ }
160
+ }
161
+ },
162
+ "font": {
163
+ "type": "object",
164
+ "additionalProperties": false,
165
+ "required": [
166
+ "size"
167
+ ],
168
+ "properties": {
169
+ "family": {
170
+ "enum": [
171
+ "system",
172
+ "serif",
173
+ "rounded",
174
+ "mono"
175
+ ],
176
+ "description": "Which of the phone's own families; a skin brings no font files."
177
+ },
178
+ "weight": {
179
+ "enum": [
180
+ 400,
181
+ 500,
182
+ 600
183
+ ]
184
+ },
185
+ "size": {
186
+ "type": "number",
187
+ "minimum": 10,
188
+ "maximum": 20,
189
+ "description": "Points, at the default text size; Dynamic Type scales it."
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }