userforge 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -2
- package/dist/checks.d.ts +20 -0
- package/dist/cite.d.ts +33 -0
- package/dist/cli.js +4 -0
- package/dist/files.d.ts +21 -0
- package/dist/fit.d.ts +77 -0
- package/dist/fit.js +2 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -0
- package/dist/kinds.d.ts +49 -0
- package/dist/map.d.ts +32 -0
- package/dist/map.js +198 -0
- package/dist/mcp.d.ts +9 -0
- package/dist/needs.d.ts +18 -0
- package/dist/notes.d.ts +23 -0
- package/dist/process.d.ts +2 -0
- package/dist/process.js +46 -0
- package/dist/queue.d.ts +9 -0
- package/dist/reporter.d.ts +39 -0
- package/dist/reporter.js +1 -0
- package/dist/results.d.ts +26 -0
- package/dist/results.js +2 -0
- package/dist/setup.d.ts +12 -0
- package/dist/stage.d.ts +24 -0
- package/dist/stage.js +1 -0
- package/dist/store.d.ts +34 -0
- package/dist/test.d.ts +4 -0
- package/dist/test.js +1 -0
- package/dist/tools.d.ts +13 -0
- package/package.json +65 -5
package/README.md
CHANGED
|
@@ -1,3 +1,141 @@
|
|
|
1
|
-
#
|
|
1
|
+
# userforge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The map's tools, command line, file format and test tools for a project built
|
|
4
|
+
the Userforge way. The project keeps a map beside its code, in `spec/`: who it
|
|
5
|
+
is for (personas), what each of them needs to be able to do (abilities, each
|
|
6
|
+
with checks), and where that happens (places), one YAML file per thing,
|
|
7
|
+
holding its data by key. Tests are named after the checks they prove, so the
|
|
8
|
+
map always says what works.
|
|
9
|
+
|
|
10
|
+
It needs nothing else: no account, and no network unless it is given a
|
|
11
|
+
Userforge workspace.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm i -D userforge
|
|
17
|
+
npx userforge init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`init` creates `spec/` with a brief to start from, adds one line to
|
|
21
|
+
`AGENTS.md`, points `CLAUDE.md` at it, and names the map's tools in
|
|
22
|
+
`.mcp.json`. Nothing already there is written over. The line sends every
|
|
23
|
+
coding agent here:
|
|
24
|
+
|
|
25
|
+
> This project is built the Userforge way: run `npx userforge` and follow it.
|
|
26
|
+
|
|
27
|
+
For a codebase that already exists, then ask your coding agent to **map this
|
|
28
|
+
codebase**. It writes the brief, a place for each screen (with a screenshot,
|
|
29
|
+
if it can run the app), personas, abilities with their checks, and names your
|
|
30
|
+
tests after them, on a branch, and opens a pull request. Say "import" if you
|
|
31
|
+
prefer, and add any direction: "Map this codebase, focusing on the admin side."
|
|
32
|
+
|
|
33
|
+
## The map's tools
|
|
34
|
+
|
|
35
|
+
A coding agent reads and changes the map only through its tools, which
|
|
36
|
+
`.mcp.json` names: `npx userforge mcp`, a Model Context Protocol server on
|
|
37
|
+
stdin and stdout. Restart the agent after `init` so it picks them up.
|
|
38
|
+
|
|
39
|
+
| | |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `overview` | The brief, the personas, how many abilities stand at each stage, the places, the code work waiting, and what needs attention: abilities with a check that fails, no checks or no place, places with no picture, decisions still proposed, and code work whose checks all pass or that names none. |
|
|
42
|
+
| `list`, `read` | Every thing of a kind, searched or tied to a persona, place or ability; one thing as its file holds it. |
|
|
43
|
+
| `write_persona`, `write_story`, … | One for each kind, its input that kind's sheet. Makes a thing under the next id, or writes one again by its key. |
|
|
44
|
+
| `change`, `remove` | A line or two changed by its path; a thing removed, and taken out of whatever pointed at it. |
|
|
45
|
+
|
|
46
|
+
What a tool is given is fitted to its kind's sheet exactly as the Userforge
|
|
47
|
+
app fits what a person writes there. What doesn't fit is turned down with what
|
|
48
|
+
would, and nothing is written. Every write leaves `spec/README.md` written
|
|
49
|
+
again.
|
|
50
|
+
|
|
51
|
+
## The map
|
|
52
|
+
|
|
53
|
+
| | |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `spec/why/` | The brief, documents, decisions, research and sources. |
|
|
56
|
+
| `spec/who/` | Personas. |
|
|
57
|
+
| `spec/what/` | Abilities, each with its checks (`S12.2` is check 2 of `S12`). |
|
|
58
|
+
| `spec/where/` | Places: screens, and a website's pages. Screenshots beside them, in `spec/where/shots/`. |
|
|
59
|
+
| `spec/queue/` | Code work waiting for a coding agent, one file each. |
|
|
60
|
+
| `spec/results.json` | The last result of every check. |
|
|
61
|
+
| `spec/README.md` | The front page, written from the files. Never edited by hand. |
|
|
62
|
+
|
|
63
|
+
A file is the thing's data by key, exactly as a workspace holds it:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
stage: planned
|
|
67
|
+
who: [P1]
|
|
68
|
+
what: see tomorrow’s orders
|
|
69
|
+
where: [W1]
|
|
70
|
+
checks:
|
|
71
|
+
- id: "1"
|
|
72
|
+
text: The orders for tomorrow are listed.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
An ability's stage comes from its results. People say idea or planned; it is
|
|
76
|
+
building while a check fails on main or a branch is at work on it, and live
|
|
77
|
+
once every check passes on main.
|
|
78
|
+
|
|
79
|
+
## Commands
|
|
80
|
+
|
|
81
|
+
| | |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `npx userforge` | What the map holds, how work is done here, what is waiting in `spec/queue/`, and where the map stands. |
|
|
84
|
+
| `npx userforge init` | Sets the project up, or gives one that has its map what it lacks. |
|
|
85
|
+
| `npx userforge mcp` | The map's tools, over stdin and stdout. |
|
|
86
|
+
| `npx userforge check` | Says what doesn't hold together: files that don't fit, pointers to nothing, pictures that aren't there, citations of what may not be cited, code work still waiting though its checks all pass, and checks of abilities being built that no test is named after (but those that waiting code work names). |
|
|
87
|
+
| `npx userforge pull` | Writes a workspace's map into `spec/`. |
|
|
88
|
+
| `npx userforge report [file]` | Tells a workspace the results in `spec/results.json`. |
|
|
89
|
+
| `npx userforge site <address> [website]` | Writes a workspace's website into `site/`, for a host of your own. |
|
|
90
|
+
|
|
91
|
+
`pull`, `report` and `site` need `USERFORGE_URL` and `USERFORGE_KEY`, your
|
|
92
|
+
own key from Settings, Code. With them, the tools take each new thing's id
|
|
93
|
+
from the workspace, so two branches never take the same one. `USERFORGE_SPEC` moves the
|
|
94
|
+
map from `spec/`; `USERFORGE_TESTS` says where the tests are when they aren't
|
|
95
|
+
in `tests/`, `test/` or `__tests__/`.
|
|
96
|
+
|
|
97
|
+
## Tests
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { check } from 'userforge/test';
|
|
101
|
+
|
|
102
|
+
check('S12.2', () => {
|
|
103
|
+
// Runs as "S12.2 A booking is confirmed by email".
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
A test whose name starts with a check's id (`test('S12.2 …', …)`) proves it
|
|
108
|
+
too. The vitest reporter keeps every result in `spec/results.json`; commit it
|
|
109
|
+
with the code:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
// vitest.config.ts
|
|
113
|
+
export default { test: { reporters: ['default', 'userforge/reporter'] } };
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## What an agent is told
|
|
117
|
+
|
|
118
|
+
[`map.md`](map.md) says what the map holds and how its tools are used;
|
|
119
|
+
[`process.md`](process.md) says how work is done in a Userforge project,
|
|
120
|
+
mapping an existing codebase included. `npx userforge` prints both, and the
|
|
121
|
+
tools carry both as their instructions. Update this package to get newer ones.
|
|
122
|
+
|
|
123
|
+
## In code
|
|
124
|
+
|
|
125
|
+
`import { … } from 'userforge'`: the tools (`tools`, `call`) over a map kept
|
|
126
|
+
anywhere (`Store`; `filesStore` for `spec/`); fitting a thing to its kind's
|
|
127
|
+
sheet (`fitThing`) and what on it needs someone (`needs`), also alone as
|
|
128
|
+
`userforge/fit` for an app that has viewschema itself; the file format (`fromFile`, `toFile`, `yamlOf`,
|
|
129
|
+
`overview`) and the kinds (`kinds`); a map read and checked (`readMap`,
|
|
130
|
+
`faults`, `init`); checks and results (`checksIn`, `unproved`, `keep`,
|
|
131
|
+
`resultsIn`); stages (`stageOf`, `storyStage`, also alone as
|
|
132
|
+
`userforge/stage`); set-up (`setup`, `lineFor`); and what an agent is told
|
|
133
|
+
(`MAP`, `PROCESS`).
|
|
134
|
+
|
|
135
|
+
## Working on this package
|
|
136
|
+
|
|
137
|
+
`npm test` builds `dist/` and runs the tests, and runs before every
|
|
138
|
+
`npm publish`. What is published is `dist/` alone, minified, with viewschema
|
|
139
|
+
bundled into it; `dist/` is committed too, so the repository installs with no
|
|
140
|
+
build step. `kinds.json` is written by the Userforge app (`npm run userforge:vendor`
|
|
141
|
+
there) and never edited here.
|
package/dist/checks.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Every check by its id, with its words. */
|
|
2
|
+
export type Checks = Record<string, string>;
|
|
3
|
+
/** The checks of abilities as a workspace keeps them, and as the files read back give them. */
|
|
4
|
+
export declare const checksIn: (stories: {
|
|
5
|
+
key: string;
|
|
6
|
+
data: {
|
|
7
|
+
story: {
|
|
8
|
+
checks?: {
|
|
9
|
+
id: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}[]) => Checks;
|
|
15
|
+
/** The test files under a folder, however deep, leaving out what a project installs or hides (`node_modules`, `.git`, …). */
|
|
16
|
+
export declare function testsIn(dir: string): string[];
|
|
17
|
+
/** Where a project keeps its tests, when it doesn't say: `tests/`, `test/` or `__tests__/`, or else anywhere in it. */
|
|
18
|
+
export declare const testsAt: (root?: string) => string;
|
|
19
|
+
/** The checks no test under `dir` is written for: by `check('S12.2', …)`, or by a test named with the check's id first, `test('S12.2 …', …)`. */
|
|
20
|
+
export declare function unproved(checks: Checks, dir?: string): string[];
|
package/dist/cite.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The keys a citation names, each once. */
|
|
2
|
+
export declare const keysOf: (list: string) => string[];
|
|
3
|
+
/** A citation as it is written: the words it is made of, and the keys of what they rest on. */
|
|
4
|
+
export type Citation = {
|
|
5
|
+
words: string;
|
|
6
|
+
keys: string[];
|
|
7
|
+
};
|
|
8
|
+
/** A citation as it is written. */
|
|
9
|
+
export declare const cited: (words: string, keys: string[]) => string;
|
|
10
|
+
/** The citations in a line, in the order they are written. */
|
|
11
|
+
export declare const citationsOf: (text: string) => Citation[];
|
|
12
|
+
/** Every line of a value (a thing's data, a block, a list), each by its path, in order. */
|
|
13
|
+
export declare function eachLine(value: unknown, visit: (path: string, text: string) => void, path?: string): void;
|
|
14
|
+
/** A value with each of its lines changed, by its path. What isn't changed is given back as it was, the same object. */
|
|
15
|
+
export declare function eachChanged<T>(value: T, change: (text: string, path: string) => string, path?: string): T;
|
|
16
|
+
/** Every citation in a value, with the path of the line it is in. */
|
|
17
|
+
export declare function citationsIn(value: unknown): (Citation & {
|
|
18
|
+
path: string;
|
|
19
|
+
})[];
|
|
20
|
+
/** The sources a value cites, each once, in the order first cited. */
|
|
21
|
+
export declare const keysIn: (value: unknown) => string[];
|
|
22
|
+
/** A value read without its citations: their words alone. */
|
|
23
|
+
export declare const uncited: <T>(value: T) => T;
|
|
24
|
+
/** Whether a source's text says a quote, word for word (four words at least, so that finding it means something). */
|
|
25
|
+
export declare function says(text: string, quote: string): boolean;
|
|
26
|
+
/** Words set as a quotation: one quotation, from its opening mark to its closing one, or a line that is a quote (`quote`, a quotation's `said`). */
|
|
27
|
+
export declare const quoted: (words: string, path?: string) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* What a writer wrote, held to the library: a citation keeps only the sources that may be cited (`text` gives a
|
|
30
|
+
* source's words where it may be, and nothing where it may not), and a quotation only those whose words say it. A
|
|
31
|
+
* citation left with no source is its words alone.
|
|
32
|
+
*/
|
|
33
|
+
export declare function heldTo<T>(value: T, text: (key: string) => string | undefined): T;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{spawnSync as e}from"node:child_process";import{existsSync as t,mkdirSync as n,readFileSync as r,writeFileSync as i}from"node:fs";import{dirname as a,join as o,relative as s}from"node:path";import{c,i as l,m as u,n as d,p as f,r as p,s as m,t as h}from"./map.js";import{createInterface as g}from"node:readline";import{a as _,i as v,n as y,r as b,t as x}from"./process.js";import{storyStage as S,workDone as C}from"./stage.js";import{a as w,n as T,o as E,s as D}from"./results.js";var O=`0.1.1`;const k=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`];async function A(e,t){let{id:n,method:r,params:i={}}=t??{};if(n==null)return null;let a=e=>({jsonrpc:`2.0`,id:n,result:e});try{switch(r){case`initialize`:return a({protocolVersion:k.includes(i.protocolVersion)?i.protocolVersion:k[0],capabilities:{tools:{}},serverInfo:{name:`userforge`,version:O},instructions:`${x}\n\n${y}`});case`ping`:return a({});case`tools/list`:return a({tools:v(e)});case`tools/call`:{let{text:t,failed:n}=await b(e,String(i.name??``),i.arguments);return a({content:[{type:`text`,text:t}],...n?{isError:!0}:{}})}default:return{jsonrpc:`2.0`,id:n,error:{code:-32601,message:`Method not found: ${r}`}}}}catch(e){return{jsonrpc:`2.0`,id:n,error:{code:-32603,message:e.message}}}}function j(e=_()){return new Promise(t=>{let n=g({input:process.stdin}),r=Promise.resolve();n.on(`line`,t=>{if(!t.trim())return;let n;try{n=JSON.parse(t)}catch{process.stdout.write(`${JSON.stringify({jsonrpc:`2.0`,id:null,error:{code:-32700,message:`Parse error`}})}\n`);return}r=r.then(()=>A(e,n)).then(e=>e&&process.stdout.write(`${JSON.stringify(e)}\n`))}),n.on(`close`,()=>void r.then(()=>t(0)))})}function M(e=d){let t=c(e);return Object.values(m(e).all).filter(e=>e.kind===`queue`).sort((e,t)=>Number(e.key.slice(1))-Number(t.key.slice(1))).map(e=>{let n=(e.data.queue.done??[]).filter(Boolean);return{id:e.key,asked:String(e.data.queue.asked??``),abilities:e.data.queue.for??[],done:n,finished:C(n,t)}})}const N=process.env.USERFORGE_TESTS??u(),P=s(process.cwd(),d)||`spec`,F=e=>e.length&&console.log(e.join(`
|
|
3
|
+
`)),I=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,L=e=>T()?void 0:(console.error(`usage: USERFORGE_URL=… USERFORGE_KEY=… userforge ${e}`),2);function R(){let{all:e}=m(),t=t=>Object.values(e).filter(e=>e.kind===t),n=t(`story`),r=c(),i=n.filter(e=>S(e,r)===`live`).length,a=p(d,N).length;return[`The map holds ${I(t(`persona`).length,`persona`)}, ${I(n.length,`ability`,`abilities`)} (${i} live) with ${I(Object.keys(f(n)).length,`check`)}, and ${I(t(`place`).length,`place`)};`,a?`${I(a,`thing doesn't`,`things don't`)} hold together: \`npx userforge check\` says which.`:`it holds together.`].join(` `)}const z=e=>[e.abilities.length&&`for ${e.abilities.join(`, `)}`,e.finished?`done: ${e.done.join(`, `)} pass, so remove it`:e.done.length?`done when ${e.done.join(`, `)} pass`:`no checks say when it is done: write them first`].filter(Boolean).join(`; `),B=["The site is changed in Userforge and taken again with this command, never edited here. `_redirects` lists old address, new address, 301.",`Cloudflare Pages: npx wrangler pages deploy site --project-name <name>, then add the domain under the project’s custom domains.`,`Firebase Hosting: point hosting.public at the folder in firebase.json, with "cleanUrls": true, run firebase deploy --only hosting, then add the domain under Hosting’s custom domains and the DNS records it shows.`,`Then open the address: the home page loads, a link to another page works, and the sign-up form answers.`],V={"":()=>{let e=M(d);return F([x,``,y,``,`## Waiting in ${P}/queue/`,``,...e.length?e.map(e=>`- ${e.id}: ${e.asked.split(`
|
|
4
|
+
`)[0]}${z(e)?` (${z(e)})`:``}`):[`Nothing is waiting.`],``,t(d)?R():`There is no map in ${P}/ yet: \`npx userforge init\` sets one up.`]),0},init:()=>{let n=t(d),r=n&&t(o(d,`README.before.md`)),i=[...n?[]:[`${P}/`],...l()],a=!Object.values(m().all).some(e=>[`persona`,`story`,`place`].includes(e.kind)),s=e(`git`,[`check-ignore`,`-q`,o(d,`README.md`)]).status===0;return F([i.length?`Set up ${i.join(`, `)}.`:`It is set up already.`,...!r&&t(o(d,`README.before.md`))?[`The README.md that was in ${P}/ is kept as ${P}/${h}; the map's own front page is ${P}/README.md.`]:[],...s?[`git leaves ${P}/ out (.gitignore): take it out, or the map never reaches the repository, nor a workspace linked to it.`]:[],...a?[``,`Next, ask your coding agent: “Map this codebase.” Add any direction you like, such as “Map this codebase, focusing on the admin side.” It maps it on a branch and opens a pull request.`,"For a new project with no code yet, run `npx userforge` and follow it."]:[]]),0},mcp:()=>j(),check:()=>{let e=p(d,N);return F(e),+!!e.length},async pull(){let e=await w(T());for(let[t,r]of Object.entries(e))n(a(o(d,t)),{recursive:!0}),i(o(d,t),r);return console.log(`${Object.keys(e).length-1} things written to ${P}/.`),0},report:async([e=o(d,`results.json`)])=>(console.log(await E(T(),JSON.parse(r(e,`utf8`)))),0),async site([e,t]){if(!/^https?:\/\/[^/\s]+$/.test(e??``))return console.error(`usage: userforge site <address, such as https://www.example.com> [website id]`),2;let r=await D(T(),e,t);for(let[e,t]of Object.entries(r))n(a(o(`site`,e)),{recursive:!0}),i(o(`site`,e),t);return F([`${I(Object.keys(r).length,`file`)} written to site/.`,``,...B]),0}},[H=``,...U]=process.argv.slice(2),W=V[H];W?Promise.resolve().then(()=>[`pull`,`report`,`site`].includes(H)?L(H)??W(U):W(U)).then(e=>void(process.exitCode=e),e=>(console.error(e.message),process.exitCode=1)):(console.error(`usage: userforge [init | mcp | check | pull | report [results.json] | site <address> [website]]`),process.exitCode=2);export{};
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Kinds, type Thing } from './kinds.ts';
|
|
2
|
+
import type { Results } from './results.ts';
|
|
3
|
+
/** A thing's data as YAML, by its own keys, in one order: what its file holds, whether or not its kind is kept in files. */
|
|
4
|
+
export declare function yamlOf(kinds: Kinds, thing: Thing): string;
|
|
5
|
+
/** A thing as its file says it: its path, and its YAML. Nothing, for a kind kept in the workspace alone. */
|
|
6
|
+
export declare function toFile(kinds: Kinds, thing: Thing): {
|
|
7
|
+
path: string;
|
|
8
|
+
text: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* A file read back into the thing it holds, fitted to its kind's sheet: what doesn't fit is said, by its path. Given
|
|
12
|
+
* everything there is (`all`), what it points at and cites is checked too.
|
|
13
|
+
*/
|
|
14
|
+
export declare function fromFile(kinds: Kinds, path: string, text: string, all?: Record<string, Thing>): {
|
|
15
|
+
thing: Thing;
|
|
16
|
+
problems: string[];
|
|
17
|
+
} | undefined;
|
|
18
|
+
/** The line the map's front page opens with, which says it is written from the files beside it. */
|
|
19
|
+
export declare const FRONT = "<!-- Written from the files beside it; what is changed here is written over. -->";
|
|
20
|
+
/** The map's front page: the idea, the documents, who it is for and what each of them can do (at the stage its results say), and where. Written, never edited. */
|
|
21
|
+
export declare function overview(kinds: Kinds, all: Record<string, Thing>, results?: Results): string;
|
package/dist/fit.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thing fitted to its kind's sheet: the one way for every writer, whoever and wherever (a person in the app, the
|
|
3
|
+
* app's own model work, a coding agent through the tools, a file read back from a repository, the free creator in a
|
|
4
|
+
* browser). Its words are held to the sheet's fields and lengths, what it points at must be there, a citation names a
|
|
5
|
+
* source that may be cited, a block's template can be drawn, and a story's checks keep their ids. What doesn't fit is
|
|
6
|
+
* said, by its path, in a sentence a writer can act on. With it, what a map's things need of someone (`needs`), which
|
|
7
|
+
* the app draws and the tools tell. Nothing here touches a disk or the network.
|
|
8
|
+
*/
|
|
9
|
+
import { type JSONSchemaProperty, type Patch } from 'viewschema';
|
|
10
|
+
import { type Kinds, type Thing } from './kinds.ts';
|
|
11
|
+
/** What didn't fit a kind's sheet, as one message a writer can act on. */
|
|
12
|
+
export declare class Misfit extends Error {
|
|
13
|
+
}
|
|
14
|
+
/** The problems a thing has with its sheet, as one message. */
|
|
15
|
+
export declare const misfitOf: (kind: string, problems: string[]) => string;
|
|
16
|
+
/** Whether a source may be cited: anything that is evidence, never the team's own material. */
|
|
17
|
+
export declare const citable: (thing: Thing | undefined) => boolean;
|
|
18
|
+
/** What a writer wrote, held to the library there is: a citation keeps only the sources that may be cited, and a quotation only those whose words say it (`heldTo`). */
|
|
19
|
+
export declare const held: <T>(all: Record<string, Thing>, value: T) => T;
|
|
20
|
+
/** One line of a thing, by its number: a story's check, a finding of a question, a block of a place, a section of a document or the brief. */
|
|
21
|
+
export declare function lineAt(thing: Thing, n: string): string | undefined;
|
|
22
|
+
/** Whether a pointer names something there is: a thing (S12), or one line of it (S12.2). */
|
|
23
|
+
export declare function pointed(all: Record<string, Thing>, ref: unknown): boolean;
|
|
24
|
+
/** What is wrong with a block's template, as a sentence: held to a short list of tags and attributes. Nothing, when it can be drawn. */
|
|
25
|
+
export declare function faultIn(html: unknown): string | undefined;
|
|
26
|
+
/** What removing a thing changes in the rest: each thing that holds its id, without it, and the fields it was in. */
|
|
27
|
+
export declare function unnamed(kinds: Kinds, all: Record<string, Thing>, key: string): {
|
|
28
|
+
thing: Thing;
|
|
29
|
+
fields: string[];
|
|
30
|
+
}[];
|
|
31
|
+
type Defs = Record<string, JSONSchemaProperty>;
|
|
32
|
+
/**
|
|
33
|
+
* What a writer wrote, with its quotation marks and apostrophes set as type. Addresses are left as they came, and so
|
|
34
|
+
* is anything its schema says is written in a language of its own (a stylesheet, a stack of typefaces).
|
|
35
|
+
*/
|
|
36
|
+
export declare const typeset: <T>(value: T, schema?: JSONSchemaProperty, defs?: Defs) => T;
|
|
37
|
+
/** Whether two values hold the same thing, whatever order their keys come in. */
|
|
38
|
+
export declare function alike(a: unknown, b: unknown): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* A thing's data kept in order, after any change: a story's checks each have an id, and a count of every check it has
|
|
41
|
+
* had (`n`), so an id is never given twice; a table's rows keep one cell under each of its columns, a column added,
|
|
42
|
+
* taken away or moved (the change just made, `patch`) taking its cells in every row with it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function tidy(thing: {
|
|
45
|
+
kind: string;
|
|
46
|
+
data: Record<string, any>;
|
|
47
|
+
}, patch?: Patch): Record<string, any>;
|
|
48
|
+
export interface Fitting {
|
|
49
|
+
/** Everything there is, by key, that what it points at and cites is checked against; left out, nothing is. */
|
|
50
|
+
all?: Record<string, Thing>;
|
|
51
|
+
/** It as it was, when it is written again: its checks keep their ids, and only citations new to it are checked. */
|
|
52
|
+
had?: Thing;
|
|
53
|
+
/** Its id. */
|
|
54
|
+
key?: string;
|
|
55
|
+
/** `all` is everything there is: a pointer to a kind kept elsewhere (a note, which a repository doesn't keep) is checked too. */
|
|
56
|
+
whole?: boolean;
|
|
57
|
+
/** The change just made, when it is one. */
|
|
58
|
+
patch?: Patch;
|
|
59
|
+
}
|
|
60
|
+
/** What a thing points at and cites that isn't there, or may not be cited, as problems. */
|
|
61
|
+
export declare function references(kinds: Kinds, kind: string, value: Record<string, any>, { all, had, key, whole }?: Fitting): string[];
|
|
62
|
+
/**
|
|
63
|
+
* What a writer gave, fitted to its kind's sheet, with what doesn't fit. A story's checks keep the ids given them, then
|
|
64
|
+
* the ids they had, matched by their words; a list written again in words alone keeps them by their place, reworded,
|
|
65
|
+
* so results stay with their check. One new is given the next. A new persona takes a colour no other has, and keeps
|
|
66
|
+
* it. Where a thing stands in its list (`order`) and what the app keeps on it that no writer gives (where a note came
|
|
67
|
+
* from) stay beside its sheet. A block of the project's own, whose sheet the kinds don't hold, is kept whole where it
|
|
68
|
+
* stands.
|
|
69
|
+
*/
|
|
70
|
+
export declare function fitThing(kinds: Kinds, kind: string, given: Record<string, any>, how?: Fitting): {
|
|
71
|
+
value: Record<string, any>;
|
|
72
|
+
problems: string[];
|
|
73
|
+
};
|
|
74
|
+
export { citationsIn, citationsOf, cited, eachChanged, eachLine, heldTo, keysIn, keysOf, quoted, says, uncited, type Citation } from './cite.ts';
|
|
75
|
+
export { called, EXT, kindOf, pathOf, thingAt, type Kind, type Kinds, type Schema, type Thing } from './kinds.ts';
|
|
76
|
+
export { isSite, needs, NEEDS, siteOf, SITE_BLOCK, type Need } from './needs.ts';
|
|
77
|
+
export { spamOf, spammy, waiting } from './notes.ts';
|
package/dist/fit.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{CITATION as e,extractSchema as t,fit as n,resolveSchema as r}from"viewschema";const i=/^[A-Z]\d+$/,a=()=>new RegExp(e.source,`g`),o=e=>[...new Set(e.split(/[,;]/).map(e=>e.trim()).filter(e=>i.test(e)))],s=(e,t)=>`[${e}](cite:${t.join(`,`)})`,c=e=>[...String(e??``).matchAll(a())].map(e=>({words:e[1],keys:o(e[2])}));function l(e,t,n=``){if(typeof e==`string`)t(n,e);else if(Array.isArray(e))e.forEach((e,r)=>l(e,t,n?`${n}.${r}`:String(r)));else if(e&&typeof e==`object`)for(let[r,i]of Object.entries(e))l(i,t,n?`${n}.${r}`:r)}function u(e,t,n=``){if(typeof e==`string`)return t(e,n);if(Array.isArray(e)){let r=e.map((e,r)=>u(e,t,n?`${n}.${r}`:String(r)));return r.some((t,n)=>t!==e[n])?r:e}if(e&&typeof e==`object`){let r=!1,i=Object.fromEntries(Object.entries(e).map(([e,i])=>{let a=u(i,t,n?`${n}.${e}`:e);return r||=a!==i,[e,a]}));return r?i:e}return e}function d(e){let t=[];return l(e,(e,n)=>n.includes(`](cite:`)&&t.push(...c(n).map(t=>({...t,path:e})))),t}const f=e=>[...new Set(d(e).flatMap(e=>e.keys))],p=e=>u(e,e=>e.includes(`](cite:`)?e.replace(a(),`$1`):e),m=e=>String(e??``).normalize(`NFKC`).toLowerCase().replace(/[‘’ʼ']/g,``).replace(/[^\p{L}\p{N}]+/gu,` `).trim();function h(e,t){let n=m(t);return n.split(` `).length>=4&&` ${m(e)} `.includes(` ${n} `)}const g=(e,t=``)=>/^\s*["“«„‘][^"”»“«„]*["”»“’][.,;:!?]?\s*$/.test(e)||/(^|\.)(quote|said)$/.test(t);function _(e,t){return u(e,(e,n)=>e.includes(`](cite:`)?e.replace(a(),(e,r,i)=>{let a=o(i).filter(e=>t(e)!==void 0&&(!g(r,n)||h(t(e),r)));return a.length?s(r,a):r}):e)}const v=`.yaml`,y=(e,t,n)=>{let r=e[t]?.file;return r&&`${r.dir}/${r.name??n}.yaml`};function b(e,t){let[n,r=``]=t.split(`/`).slice(-2);if(!r.endsWith(`.yaml`))return;let i=r.slice(0,-5);for(let[t,r]of Object.entries(e))if(r.file?.dir===n&&(r.file.name?r.file.name===i:RegExp(`^${r.letter}\\d+$`).test(i)))return{kind:t,key:r.file.name?`${r.letter}1`:i}}const x=(e,t)=>Object.keys(e).find(n=>RegExp(`^${e[n].letter}\\d+$`).test(t)),S=e=>{let t=e?.data[e.kind]??{};return String(t.role||t.name||t.title||t.what||t.question||t.summary||t.text||t.asked||e?.key||``).trim()},C=/\bhttps?:\/\/[^\s<>()"']+|\bwww\.[^\s<>()"']+\.[a-z]{2,}[^\s<>()"']*/gi,w=/^([^\n(]{2,80}\(\s*https?:\/\/[^)\s]+\s*\)|\s*https?:\/\/\S+)\s*[-–—:|]/,T=/\[url=|<a\s+href|\b(backlinks?|guest posts?|seo (services|agency|experts?)|link building|rank(ing)? (higher|first) on google|first page of google|website traffic|increase (your )?traffic|casino|viagra|cialis|forex|crypto (signals|investment)|bitcoin investment|whatsapp me|telegram me)\b/i;function E(e){let t=String(e??``).trim();if(!t)return;let n=t.match(C)??[];if(n.length>=3||n.join(``).length>=t.length*.4)return`links`;if(w.test(t))return`advert`;if(T.test(t))return`phrases`}const D=e=>!e.facts?.person&&!!E(e.data.feedback?.text),O=e=>e.data.feedback?.status!==`done`&&!D(e),k=`c-site`,A=e=>(e.data.place?.blocks??[]).some(e=>e?.is===k);function j(e,t){for(let n=t,r=/* @__PURE__ */ new Set;n?.kind===`place`&&!r.has(n.key);r.add(n.key),n=e[n.data.place?.under??``])if(A(n))return n}const M=[`failing`,`unchecked`,`unplaced`,`bare`,`unsorted`,`undecided`];function N(e,t){let n=t=>Object.values(e).filter(e=>e.kind===t),r=e=>e.map(e=>e.key).sort((e,t)=>Number(e.slice(1))-Number(t.slice(1))),i=n(`story`),a=n(`place`),o=e=>e.data.story.checks??[];return{failing:r(i.filter(e=>o(e).some(n=>t[`${e.key}.${n.id}`]?.state===`fail`))),unchecked:r(i.filter(e=>!o(e).length)),unplaced:r(i.filter(t=>!(t.data.story.where??[]).some(t=>e[t]))),bare:r(a.filter(t=>!j(e,t)&&!a.some(e=>e.key!==t.key&&e.data.place.under===t.key)&&!t.data.place.shot&&!t.data.place.blocks?.length)),unsorted:r(n(`feedback`).filter(O)),undecided:r(n(`decision`).filter(e=>(e.data.decision.status??`proposed`)===`proposed`))}}var P=class extends Error{};const F=(e,t)=>`This doesn’t fit the ${e} sheet:\n- ${t.join(`
|
|
2
|
+
- `)}`,I=e=>e?.kind===`source`&&e.data.source.cite!==`no`,L=(e,t)=>_(t,t=>I(e[t])?String(e[t].data.source.text??``):void 0);function R(e,t){let n=e.data[e.kind]??{},r=n.blocks?.[Number(t)-1]??{};if(e.kind===`story`)return n.checks?.find(e=>e.id===t)?.text;if(e.kind===`research`)return n.findings?.[Number(t)-1]?.claim;if(e.kind===`place`)return Object.entries(r).find(([e,t])=>e!==`is`&&typeof t==`string`&&t)?.[1];if(e.kind===`document`||e.kind===`brief`)return r.label||r.left?.label}function z(e,t){let[,n,r]=/^([A-Z]\d+)(?:\.(\d+))?$/.exec(String(t??``).trim())??[],i=e[n??``];return!!i&&(!r||!!R(i,r))}const B=new Set(`section div header footer h2 h3 h4 p ul ol li dl dt dd blockquote figure figcaption table thead tbody tr th td span b strong i em small hr a img template`.split(` `)),V=/* @__PURE__ */ new Set([`img`,`hr`]),H=/^(href|src|alt|datetime|data-[a-z-]+|aria-[a-z-]+)$/,U=/^(class|alt|colspan|rowspan|data-vs-add-label|view-(text|markdown|each|if|object|title|prompt|optional|readonly|static|examples|default|declare|type|format|max-length|min-items|max-items|items))$/,W=e=>U.test(e)||H.test(/^view-(?:attr|optional|readonly|title|prompt):(.+)$/.exec(e)?.[1]??``),G=/<(\/?)([a-zA-Z][\w-]*)((?:\s+[^\s"'=<>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*(\/?)>/g;function K(e){let n=String(e??``).trim();if(!n)return`It has no template yet.`;if(n.length>12e3)return`It is longer than a block can be.`;if(/\{@|<!|<\?/.test(n))return`It holds something only this app writes: {@…}, a comment or a declaration.`;let r=[],i=0,a=0,o=0;if(n.replace(G,(e,t,n,s,c,l)=>{let u=n.toLowerCase();B.has(u)||r.push(`<${u}> can’t be used in a block.`);for(let[,e]of s.matchAll(/\s+([^\s"'=<>/]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/g))W(e.toLowerCase())||r.push(`The attribute “${e}” can’t be used in a block.`);return t?--i===0&&!o&&(o=l+e.length):(i===0&&a++,!V.has(u)&&!c&&i++),``}).includes(`<`)&&r.push(`It holds a tag that isn’t well formed.`),i!==0&&r.push(`A tag is opened and never closed, or closed and never opened.`),a===1&&n.startsWith(`<`)&&o===n.length||r.push(`It needs one element around everything in it.`),r.length)return r[0];try{t(n,{},{emptyStrings:!0})}catch(e){return e.message}}function q(e,t,n){let r=t[n]?.kind,i=[];for(let a of Object.values(t)){if(a.key===n)continue;let t=a.data[a.kind]??{},o=[];for(let[i,s]of Object.entries(e[a.kind]?.refs??{})){let e=t[i];if([s].flat()[0]!==r||(Array.isArray(e)?!e.includes(n):e!==n))continue;let{[i]:a,...c}=t;t=Array.isArray(e)?{...c,[i]:e.filter(e=>e!==n)}:c,o.push(i)}o.length&&i.push({thing:{...a,data:{[a.kind]:t}},fields:o})}return i}const J=(e,t,n=t?.$defs??{})=>{let i=t&&r(t,n,e);return typeof e==`string`?i?.contentMediaType||/^(https?:|\/|#)/.test(e)?e:e.replace(/(^|[\s([{—–-])"/g,`$1“`).replace(/"/g,`”`).replace(/(^|[\s([{—–-])'/g,`$1‘`).replace(/'/g,`’`):Array.isArray(e)?e.map(e=>J(e,i?.items,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,J(t,i?.properties?.[e],n)])):e};function Y(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||!e||!t||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e).filter(t=>e[t]!==void 0),r=Object.keys(t).filter(e=>t[e]!==void 0);return n.length===r.length&&n.every(n=>Y(e[n],t[n]))}function X(e,t){if(e.kind===`place`)return Z(e.data,t);if(e.kind!==`story`)return e.data;let n=e.data.story,r=Math.max(Number(n.n)||0,...(n.checks??[]).map(e=>Number(e.id)||0)),i=(n.checks??[]).map(e=>e.id?e:{...e,id:String(++r)});return r===n.n&&i.every((e,t)=>e===n.checks[t])?e.data:{story:{...n,checks:i,n:r}}}function Z(e,t){let n=e.place?.blocks;if(!n?.some(e=>e?.is===`w-table`))return e;let r=t?.path.match(/^place\.blocks\.(\d+)\.columns\.(\d+)$/),i=n.map((e,n)=>{if(e?.is!==`w-table`)return e;let i=(e.columns??[]).length,a=(e.rows??[]).map(e=>{let a=[...e.cells??[]];if(r&&Number(r[1])===n){let e=Number(r[2]);t.op===`insert`?a.splice(e,0,``):t.op===`remove`?a.splice(e,1):t.op===`move`&&a.splice(t.to,0,...a.splice(e,1))}let o=[...a.slice(0,i),...Array(Math.max(0,i-a.length)).fill(``)];return Y(o,e.cells)?e:{...e,cells:o}});return a.every((t,n)=>t===e.rows[n])?e:{...e,rows:a}});return i.every((e,t)=>e===n[t])?e:{...e,place:{...e.place,blocks:i}}}function Q(e,t,n,{all:r={},had:i,key:a=i?.key,whole:o=!1}={}){let s=[],c=e[t];for(let[e,t]of Object.entries(c.refs??{})){let i=[t].flat()[0];for(let t of[n[e]??[]].flat())t&&r[t]?.kind!==i&&s.push(`${e}: there is no ${i} "${t}". Use \`list\` to see the ones there are.`)}let l=t=>o||!!e[x(e,t.split(`.`)[0])??``]?.file;for(let e of c.points??[])for(let t of[n[e]??[]].flat().filter(Boolean))!z(r,t)&&l(String(t))&&s.push(`${e}: "${t}" points at nothing here. A pointer is a thing’s id (P1, S12, W3, R2, F4), or one line of it: a check (S12.2), a finding (R2.1), a block of a place or a page of the website (W3.2).`);let u=new Set(f(i?.data[t]));for(let e of f(n).filter(e=>!u.has(e)))r[e]?.kind===`source`?I(r[e])||s.push(`cite:${e}: ${e} is the team’s own material, which informs what is written and is never cited.`):s.push(`cite:${e}: there is no source "${e}". A claim cites a source of the library by its key, in the words it rests on: [the words](cite:C1). Use \`list\` to see the sources there are.`);if(t===`place`&&n.under){let e=/* @__PURE__ */ new Set([a]);for(let t=n.under;t;t=r[t]?.data.place?.under)if(e.has(t)){s.push(`under: ${n.under} already stands under this place. A place can’t stand under itself, or under anything that stands under it.`);break}else e.add(t)}return s}function $(e,t,r,i={}){let a=e[t];if(!a)return{value:{},problems:[`there is no kind "${t}".`]};let o=a.schema.$defs??{},s=a.schema.properties??{},c=i.had?.data[t]??{},{order:l,n:u,...d}=r??{},f=Object.fromEntries(Object.keys(c).filter(e=>!(e in s)).map(e=>[e,c[e]]));for(let e of Object.keys(d))!(e in s)&&e in c&&delete d[e];let p=t===`story`&&Array.isArray(d.checks)?d.checks.map(e=>e&&typeof e==`object`?e.id:void 0):[];if(t===`story`&&Array.isArray(d.checks)&&(d.checks=d.checks.map(e=>typeof e==`string`?{text:e}:e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([e])=>e!==`id`)):e)),t===`persona`&&!d.color){let e=Object.values(i.all??{}).filter(e=>e.kind===`persona`&&e.key!==i.key).map(e=>e.data.persona?.color),t=s.color?.enum??[];d.color=c.color??t.find(t=>!e.includes(t))??t[e.length%t.length]}let m={};for(let[e,t]of Object.entries(s))t?.items?.oneOf&&Array.isArray(d[e])&&(m[e]=d[e].map((e,t)=>[t,e]).filter(([,e])=>typeof e?.is==`string`&&!(e.is in o)),m[e].length&&(d[e]=d[e].filter(t=>!m[e].some(([,e])=>e===t))));let{value:h,problems:g}=n(a.schema,d);for(let[e,t]of Object.entries(m))for(let[n,r]of t)h[e].splice(n,0,r);if(t===`block`&&K(h.html)&&g.push(`html: ${K(h.html)}`),i.all&&g.push(...Q(e,t,h,i)),t===`story`){let e=c.checks??[],t=/* @__PURE__ */ new Set,n=e=>/^\d+$/.test(String(e??``))&&!t.has(String(e))?(t.add(String(e)),String(e)):void 0,r=p.map(n),i=!p.some(e=>e!==void 0);h.checks=(h.checks??[]).map((t,a)=>({...t,id:r[a]??n(e.find(e=>e.text===t.text)?.id)??(i&&e[a]&&!h.checks.some(t=>t.text===e[a].text)?n(e[a].id):void 0)}))}return Object.assign(h,f,typeof l==`number`?{order:l}:{}),{value:X({kind:t,data:{[t]:h}},i.patch)[t],problems:g}}export{v as EXT,P as Misfit,M as NEEDS,k as SITE_BLOCK,Y as alike,S as called,I as citable,d as citationsIn,c as citationsOf,s as cited,u as eachChanged,l as eachLine,K as faultIn,$ as fitThing,L as held,_ as heldTo,A as isSite,f as keysIn,o as keysOf,x as kindOf,R as lineAt,F as misfitOf,N as needs,y as pathOf,z as pointed,g as quoted,Q as references,h as says,j as siteOf,E as spamOf,D as spammy,b as thingAt,X as tidy,J as typeset,p as uncited,q as unnamed,O as waiting};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* userforge: the map of a product, wherever it is kept. Its kinds, each thing fitted to its sheet (`userforge/fit`, which
|
|
3
|
+
* a browser can use too), its files, the tools anything that works on it with a model uses, what such a worker is told,
|
|
4
|
+
* and a project set up and checked. The test helper is `userforge/test`, the vitest reporter `userforge/reporter`, the
|
|
5
|
+
* command line `npx userforge`.
|
|
6
|
+
*/
|
|
7
|
+
export * from './fit.ts';
|
|
8
|
+
export { fromFile, overview, toFile, yamlOf } from './files.ts';
|
|
9
|
+
export { faults, init, kinds, nextId, readMap, resultsIn, SPEC, written } from './map.ts';
|
|
10
|
+
export { filesStore, type Store } from './store.ts';
|
|
11
|
+
export { call, tools, type Tool } from './tools.ts';
|
|
12
|
+
export { MAP, PROCESS } from './process.ts';
|
|
13
|
+
export { STAGES, stageOf, storyStage, type Stage } from './stage.ts';
|
|
14
|
+
export { checksIn, testsAt, testsIn, unproved, type Checks } from './checks.ts';
|
|
15
|
+
export { CHECK, door, keep, report, tally, type Door, type Result, type Results } from './results.ts';
|
|
16
|
+
export { lineFor, setup, SETUP_FILES } from './setup.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,Y as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as N,l as P,m as F,n as I,o as L,p as R,q as z,r as B,s as V,u as H,v as U,w as W,x as G,y as K,z as q}from"./map.js";import{a as J,c as Y,d as X,f as Z,i as Q,l as $,n as ee,o as te,p as ne,r as re,s as ie,t as ae,u as oe}from"./process.js";import{STAGES as se,stageOf as ce,storyStage as le}from"./stage.js";import{c as ue,i as de,n as fe,o as pe,t as me}from"./results.js";export{me as CHECK,h as EXT,ae as MAP,G as Misfit,te as NEEDS,ee as PROCESS,H as SETUP_FILES,ie as SITE_BLOCK,I as SPEC,se as STAGES,_ as alike,re as call,a as called,R as checksIn,n as citable,q as citationsIn,t as citationsOf,b as cited,fe as door,s as eachChanged,y as eachLine,W as faultIn,B as faults,J as filesStore,v as fitThing,C as fromFile,i as held,x as heldTo,j as init,Y as isSite,de as keep,o as keysIn,u as keysOf,c as kindOf,w as kinds,r as lineAt,D as lineFor,m as misfitOf,$ as needs,L as nextId,U as overview,d as pathOf,N as pointed,z as quoted,V as readMap,e as references,pe as report,E as resultsIn,l as says,O as setup,oe as siteOf,X as spamOf,Z as spammy,ce as stageOf,le as storyStage,ue as tally,F as testsAt,A as testsIn,g as thingAt,M as tidy,K as toFile,Q as tools,f as typeset,S as uncited,p as unnamed,k as unproved,ne as waiting,P as written,T as yamlOf};
|
package/dist/kinds.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kinds of thing a map holds, as the Userforge app defines them from its sheets (`kinds.json`): each one's letter,
|
|
3
|
+
* where its file is kept, what it points at, and its sheet as a JSON schema, with the guidance a writer is given beside
|
|
4
|
+
* each field. A thing is one of them: its key, its kind, and its data under its kind.
|
|
5
|
+
*/
|
|
6
|
+
export interface Schema {
|
|
7
|
+
type?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
properties?: Record<string, any>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
items?: any;
|
|
13
|
+
$defs?: Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
export interface Kind {
|
|
16
|
+
letter: string;
|
|
17
|
+
/** A map holds exactly one. */
|
|
18
|
+
one?: boolean;
|
|
19
|
+
/** Where its file is kept, and which fields it opens with; a kind kept in the workspace alone has none. */
|
|
20
|
+
file?: {
|
|
21
|
+
dir: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
lines?: string[];
|
|
24
|
+
};
|
|
25
|
+
/** The fields that hold the ids of other things, by the kind they hold (in a list when they hold several). */
|
|
26
|
+
refs?: Record<string, string | string[]>;
|
|
27
|
+
/** The fields that point at a thing or one line of it (S12, S12.2). */
|
|
28
|
+
points?: string[];
|
|
29
|
+
schema: Schema;
|
|
30
|
+
}
|
|
31
|
+
export type Kinds = Record<string, Kind>;
|
|
32
|
+
export interface Thing {
|
|
33
|
+
key: string;
|
|
34
|
+
kind: string;
|
|
35
|
+
data: Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
/** A map file's own ending. */
|
|
38
|
+
export declare const EXT = ".yaml";
|
|
39
|
+
/** Where a thing's file stands, under the map's folder; nothing for a kind kept in the workspace alone. */
|
|
40
|
+
export declare const pathOf: (kinds: Kinds, kind: string, key: string) => string | undefined;
|
|
41
|
+
/** The thing a file holds, from where it stands. */
|
|
42
|
+
export declare function thingAt(kinds: Kinds, path: string): {
|
|
43
|
+
kind: string;
|
|
44
|
+
key: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
/** The kind an id belongs to, by its letter. */
|
|
47
|
+
export declare const kindOf: (kinds: Kinds, key: string) => string | undefined;
|
|
48
|
+
/** What a thing is called where it is named. */
|
|
49
|
+
export declare const called: (thing: Thing | undefined) => string;
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Kinds, type Thing } from './kinds.ts';
|
|
2
|
+
import type { Results } from './results.ts';
|
|
3
|
+
/** The kinds as the Userforge app defines them: what every file of a map is read and written by. */
|
|
4
|
+
export declare const kinds: Kinds;
|
|
5
|
+
/** Where the map is kept: `spec/`, unless `USERFORGE_SPEC` says otherwise. */
|
|
6
|
+
export declare const SPEC: string;
|
|
7
|
+
/** Every file of a map, read: what it holds, and what in it doesn't fit its sheet. */
|
|
8
|
+
export declare function readMap(dir?: string, k?: Kinds): {
|
|
9
|
+
all: Record<string, Thing>;
|
|
10
|
+
problems: string[];
|
|
11
|
+
};
|
|
12
|
+
/** The results of the map's checks, as the test reporter keeps them beside it (`results.json`). */
|
|
13
|
+
export declare const resultsIn: (dir?: string) => Results;
|
|
14
|
+
/** The map's front page, written again from its files. */
|
|
15
|
+
/** The map's front page, written from the files beside it. One the project wrote itself before the map was there is kept beside it, as README.before.md, never written over. */
|
|
16
|
+
export declare const written: (dir?: string, k?: Kinds) => void;
|
|
17
|
+
/** Where a README.md the project wrote in the map's folder before the map was is kept. */
|
|
18
|
+
export declare const BEFORE = "README.before.md";
|
|
19
|
+
/** The id a new thing of a kind is given: the next one the files leave free. */
|
|
20
|
+
export declare const nextId: (k: Kinds, kind: string, all: Record<string, Thing>) => string;
|
|
21
|
+
/**
|
|
22
|
+
* What the map says that isn't so: what doesn't fit its sheet, what points at nothing or cites what may not be cited,
|
|
23
|
+
* a picture named beside the map that isn't there, code work still waiting though every check it names passes, and
|
|
24
|
+
* checks of abilities being built or live (by their results) that no test under `tests` proves. A check that waiting
|
|
25
|
+
* code work names is owed its test by whoever takes that work.
|
|
26
|
+
*/
|
|
27
|
+
export declare function faults(dir?: string, tests?: string): string[];
|
|
28
|
+
/**
|
|
29
|
+
* A project set up: its map's folders, a brief to begin from, the front page, the line in AGENTS.md, CLAUDE.md pointing
|
|
30
|
+
* at it, and `.mcp.json` giving every coding agent that reads it the map's tools. Nothing already there is written over.
|
|
31
|
+
*/
|
|
32
|
+
export declare function init(root?: string, dir?: string): string[];
|