userforge 0.1.0 → 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/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{existsSync as e,mkdirSync as t,readFileSync as n,writeFileSync as r}from"node:fs";import{dirname as i,join as a,relative as o}from"node:path";import{f as s,n as c,o as l,p as u,r as d,s as f,t as p}from"./map.js";import{createInterface as m}from"node:readline";import{a as h,i as g,n as _,r as v,t as y}from"./process.js";import{storyStage as b,workDone as x}from"./stage.js";import{a as S,n as C,o as w,s as T}from"./results.js";var E=`0.1.0`;const D=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`];async function O(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:D.includes(i.protocolVersion)?i.protocolVersion:D[0],capabilities:{tools:{}},serverInfo:{name:`userforge`,version:E},instructions:`${y}\n\n${_}`});case`ping`:return a({});case`tools/list`:return a({tools:g(e)});case`tools/call`:{let{text:t,failed:n}=await v(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 k(e=h()){return new Promise(t=>{let n=m({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(()=>O(e,n)).then(e=>e&&process.stdout.write(`${JSON.stringify(e)}\n`))}),n.on(`close`,()=>void r.then(()=>t(0)))})}function A(e=p){let t=f(e);return Object.values(l(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:x(n,t)}})}const j=process.env.USERFORGE_TESTS??u(),M=o(process.cwd(),p)||`spec`,N=e=>e.length&&console.log(e.join(`
3
- `)),P=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,F=e=>C()?void 0:(console.error(`usage: USERFORGE_URL=… USERFORGE_KEY=… userforge ${e}`),2);function I(){let{all:e}=l(),t=t=>Object.values(e).filter(e=>e.kind===t),n=t(`story`),r=f(),i=n.filter(e=>b(e,r)===`live`).length,a=c(p,j).length;return[`The map holds ${P(t(`persona`).length,`persona`)}, ${P(n.length,`ability`,`abilities`)} (${i} live) with ${P(Object.keys(s(n)).length,`check`)}, and ${P(t(`place`).length,`place`)};`,a?`${P(a,`thing doesn't`,`things don't`)} hold together: \`npx userforge check\` says which.`:`it holds together.`].join(` `)}const L=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(`; `),R=["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.`],z={"":()=>{let t=A(p);return N([y,``,_,``,`## Waiting in ${M}/queue/`,``,...t.length?t.map(e=>`- ${e.id}: ${e.asked.split(`
4
- `)[0]}${L(e)?` (${L(e)})`:``}`):[`Nothing is waiting.`],``,e(p)?I():`There is no map in ${M}/ yet: \`npx userforge init\` sets one up.`]),0},init:()=>{let t=e(p),n=[...t?[]:[`${M}/`],...d()];return N(t?[n.length?`Set up ${n.join(`, `)}.`:`It is set up already.`]:[`Set up ${n.join(`, `)}.`,``,`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:()=>k(),check:()=>{let e=c(p,j);return N(e),+!!e.length},async pull(){let e=await S(C());for(let[n,o]of Object.entries(e))t(i(a(p,n)),{recursive:!0}),r(a(p,n),o);return console.log(`${Object.keys(e).length-1} things written to ${M}/.`),0},report:async([e=a(p,`results.json`)])=>(console.log(await w(C(),JSON.parse(n(e,`utf8`)))),0),async site([e,n]){if(!/^https?:\/\/[^/\s]+$/.test(e??``))return console.error(`usage: userforge site <address, such as https://www.example.com> [website id]`),2;let o=await T(C(),e,n);for(let[e,n]of Object.entries(o))t(i(a(`site`,e)),{recursive:!0}),r(a(`site`,e),n);return N([`${P(Object.keys(o).length,`file`)} written to site/.`,``,...R]),0}},[B=``,...V]=process.argv.slice(2),H=z[B];H?Promise.resolve().then(()=>[`pull`,`report`,`site`].includes(B)?F(B)??H(V):H(V)).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{};
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 CHANGED
@@ -15,5 +15,7 @@ export declare function fromFile(kinds: Kinds, path: string, text: string, all?:
15
15
  thing: Thing;
16
16
  problems: string[];
17
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. -->";
18
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. */
19
21
  export declare function overview(kinds: Kinds, all: Record<string, Thing>, results?: Results): string;
package/dist/index.js CHANGED
@@ -1 +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,_ as S,a as C,b as w,c as T,d as E,f as D,g as O,h as k,i as A,j,k as M,l as N,m as P,n as F,o as I,p as L,q as R,r as z,s as B,t 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,p as EXT,ae as MAP,w as Misfit,te as NEEDS,ee as PROCESS,N as SETUP_FILES,ie as SITE_BLOCK,V as SPEC,se as STAGES,G as alike,re as call,h as called,D as checksIn,_ as citable,g as citationsIn,q as citationsOf,t as cited,fe as door,b as eachChanged,s as eachLine,n as faultIn,F as faults,J as filesStore,W as fitThing,O as fromFile,v as held,y as heldTo,z as init,Y as isSite,de as keep,x as keysIn,o as keysOf,a as kindOf,A as kinds,i as lineAt,H as lineFor,r as misfitOf,$ as needs,C as nextId,S as overview,c as pathOf,m as pointed,u as quoted,I as readMap,M as references,pe as report,B as resultsIn,R as says,E as setup,oe as siteOf,X as spamOf,Z as spammy,ce as stageOf,le as storyStage,ue as tally,L as testsAt,P as testsIn,d as thingAt,e as tidy,U as toFile,Q as tools,j as typeset,l as uncited,f as unnamed,k as unproved,ne as waiting,T as written,K as yamlOf};
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/map.d.ts CHANGED
@@ -12,7 +12,10 @@ export declare function readMap(dir?: string, k?: Kinds): {
12
12
  /** The results of the map's checks, as the test reporter keeps them beside it (`results.json`). */
13
13
  export declare const resultsIn: (dir?: string) => Results;
14
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. */
15
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";
16
19
  /** The id a new thing of a kind is given: the next one the files leave free. */
17
20
  export declare const nextId: (k: Kinds, kind: string, all: Record<string, Thing>) => string;
18
21
  /**