@coloopx/colocad 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (41) hide show
  1. package/NOTICE.md +2 -0
  2. package/README.md +109 -2
  3. package/README.zh-CN.md +129 -0
  4. package/bin/colocad.mjs +28 -4
  5. package/docs/README.md +27 -0
  6. package/docs/README.zh-CN.md +81 -0
  7. package/docs/modeling-history.md +60 -0
  8. package/examples/hiwin-kk60/README.md +55 -0
  9. package/examples/hiwin-kk60/model.mjs +94 -0
  10. package/examples/hiwin-kk60/run.mjs +14 -0
  11. package/examples/hiwin-kk60/sources.json +88 -0
  12. package/kernel/native/darwin-arm64/agent-cad +2 -2
  13. package/kernel/native/darwin-arm64/manifest.json +2 -3
  14. package/kernel/native/linux-arm64/agent-cad +1 -1
  15. package/kernel/native/linux-arm64/manifest.json +2 -3
  16. package/kernel/native/linux-x64/agent-cad +2 -2
  17. package/kernel/native/linux-x64/manifest.json +2 -3
  18. package/kernel/release.json +8 -0
  19. package/package.json +42 -4
  20. package/scripts/check-release.mjs +24 -0
  21. package/skills/colocad/SKILL.md +19 -0
  22. package/skills/colocad/assets/angle-bracket.json +39 -0
  23. package/skills/colocad/assets/ball.json +16 -0
  24. package/skills/colocad/assets/block.json +18 -0
  25. package/skills/colocad/assets/open-housing.json +35 -0
  26. package/skills/colocad/assets/pin.json +18 -0
  27. package/skills/colocad/assets/plate-grid.json +34 -0
  28. package/skills/colocad/assets/sleeve.json +19 -0
  29. package/skills/colocad/assets/taper.json +20 -0
  30. package/skills/colocad/references/history.md +19 -0
  31. package/skills/colocad/references/quick-build.md +44 -0
  32. package/skills/colocad/scripts/assembly.mjs +3 -0
  33. package/skills/colocad/scripts/build.mjs +54 -0
  34. package/src/render.mjs +72 -0
  35. package/src/session.d.mts +34 -0
  36. package/src/session.mjs +140 -0
  37. package/src/view-server.mjs +50 -0
  38. package/viewer/THREE-LICENSE +21 -0
  39. package/viewer/dist/index.js +4236 -0
  40. package/viewer/dist/standalone.js +4236 -0
  41. package/viewer/index.d.ts +18 -0
@@ -0,0 +1,94 @@
1
+ // Catalog interfaces: HIWIN K99TE16-1906 p.22. Internal sections are reconstruction assumptions.
2
+ // X = width, Y = vertical, Z = travel; mm. See sources.json before using for integration.
3
+ export const specification={manufacturer:'HIWIN',series:'KK60 standard',configuration:'5 mm lead / 300 mm rail / A1 / open / no motor',railLength:300,width:60,carriageHeight:33,screwAxisHeight:23,length:370,stroke:210,lead:5,screwDiameter:12};
4
+ export const stages=[
5
+ ['rail-stock','Extrude the U-section rail','geometry'],['rail-races','Cut the four guide raceways','geometry'],['rail-holes','Drill and counterbore the six mounting holes','geometry'],
6
+ ['carriage-stock','Extrude the carriage saddle','geometry'],['carriage-bore','Machine the nut seat and ball tracks','geometry'],['carriage-holes','Drill the M5 mounting pattern and datum slots','geometry'],
7
+ ['screw-blank','Revolve the stepped ballscrew blank','geometry'],['screw-groove','Cut 56 helical turns at 5 mm lead','geometry'],
8
+ ['end-plate','Machine the end bearing plate','geometry'],['motor-bracket','Machine the motor support and register','geometry'],['coupling','Bore and split the coupling hubs','geometry'],
9
+ ['base-assembly','Install the rail and end supports','assembly'],['screw-assembly','Install the ballscrew and support bearings','assembly'],['carriage-installed','Install the carriage and end caps','assembly'],
10
+ ['rolling-assembly','Add the ball nut, guide balls and wipers','assembly'],['complete','Complete the actuator and mounting hardware','assembly'],
11
+ ].map(([id,label,kind])=>({id,label,kind}));
12
+ const p=name=>({param:name}),mul=(a,b)=>({op:'mul',a,b}),add=(a,b)=>({op:'add',a,b});
13
+ export function kk60(stage='complete',{travel=0}={}){
14
+ if(!stages.some(s=>s.id===stage))throw Error('Unknown KK60 stage');
15
+ if(!Number.isFinite(travel)||Math.abs(travel)>105)throw Error('travel must be within -105..105 mm');
16
+ const features=[],all=[],f=(id,op,args)=>(features.push({id,op,...args}),id);
17
+ const box=(id,origin,size)=>f(id,'box',{origin,size});
18
+ const cut=(id,left,right)=>f(id,'cut',{left,right});
19
+ const extrude=(id,points,z,height)=>f(id,'extrude',{profile:{kind:'polygon',points},frame:{origin:[0,0,z],x_axis:[1,0,0],y_axis:[0,1,0]},height});
20
+ const ring=(id,ro,ri,z,h,y=0)=>f(id,'extrude',{profile:{kind:'circle',radius:ro},holes:[{kind:'circle',radius:ri}],frame:{origin:[0,y,z],x_axis:[1,0,0],y_axis:[0,1,0]},height:h});
21
+ const holes=(id,input,positions,r,depth,origin=[0,0,0],axes=[[1,0,0],[0,1,0]],counterbore)=>f(id,'holes',{input,positions,radius:r,depth,frame:{origin,x_axis:axes[0],y_axis:axes[1]},...(counterbore?{counterbore}:{})});
22
+ const faceholes=(id,input,face,positions,r,depth,counterbore)=>f(id,'face_holes',{input,face,positions,radius:r,depth,...(counterbore?{counterbore}:{})});
23
+ const inst=(id,input,translation=[0,0,0],rotation_deg=[0,0,0],phase='complete')=>all.push({id,input,translation,rotation_deg,phase});
24
+ const trackPositions=[[-20.5,12],[-20.5,20],[20.5,12],[20.5,20]];
25
+ const railStock=extrude('railStock',[[-30,0],[30,0],[30,21],[29,22],[21,22],[21,5],[-21,5],[-21,22],[-29,22],[-30,21]],7,300);
26
+ const railRaces=holes('railRaceways',railStock,trackPositions,1.65,302,[0,0,6]);
27
+ // Recessed rail floor is Y=5; explicit inward plane avoids drilling from the top of the sidewalls.
28
+ const railHoles=holes('railMounting',railRaces,[-15,15].flatMap(x=>[57,157,257].map(z=>[x,z])),2.75,6,[0,5,0],[[1,0,0],[0,0,1]],{radius:4.75,depth:4.7});
29
+ const rail=holes('railCoverTaps',railHoles,[-26,26].flatMap(x=>[57,257].map(z=>[x,z])),1.3,4,[0,22,0],[[1,0,0],[0,0,1]]);
30
+ const carriageSection=[[-19.7,8],[19.7,8],[19.7,23],[21,25],[21,32],[20,33],[-20,33],[-21,32],[-21,25],[-19.7,23]];
31
+ const carStock=extrude('carriageStock',carriageSection,-25.5,51);
32
+ const carSeat=holes('carriageNutSeat',carStock,[[0,23]],9.2,53,[0,0,-26.5]);
33
+ const carBore=holes('carriageRaceways',carSeat,trackPositions,1.65,53,[0,0,-26.5]);
34
+ const carHoles=faceholes('carriageMounting',carBore,'pos_y',[-15,15].flatMap(x=>[-15,15].map(z=>[x,z])),2.5,8);
35
+ let car=carHoles;
36
+ for(const z of [-23,23])car=f('datumSlot'+(z<0?'A':'B'),'face_cutout',{input:car,face:'pos_y',center:[0,z],profile:{kind:'rectangle',width:15,depth:5},depth:1.5});
37
+ const capStock=extrude('endCapStock',[[-19.5,8],[19.5,8],[21,25],[21,31.5],[-21,31.5],[-21,25]],0,15.5);
38
+ const capBore=holes('endCapBore',capStock,[[0,23]],6.5,15.5,[0,0,0],undefined,{radius:8.6,depth:1.1});
39
+ const cap=faceholes('endCapWiperSeat',capBore,'pos_z',[[0,23]],8.6,1.1);
40
+ const wiper=ring('wiper',8.5,6.2,0,1,23);
41
+ const nut=ring('ballNut',9,6.05,-21,42,23);
42
+ const shaftBlank=f('shaftBlank','revolve',{profile:{kind:'polygon',points:[[0,-7],[6,-7],[6,286],[4,286],[4,306],[3,306],[3,340],[0,340]]},frame:{origin:[0,0,0],x_axis:[1,0,0],y_axis:[0,0,1]},axis_origin:[0,0,0],axis:[0,0,1],angle_deg:360});
43
+ let screw=shaftBlank;
44
+ // Four cubic lofts approximate a circular helical cutter, then exact native booleans.
45
+ // It is NOT an exact analytical helix, gothic-arch ball race or OEM ground profile.
46
+ for(let q=0;q<4;q++){
47
+ const tool=f('helixQuarter'+q,'profile_loft',{degree:3,sections:Array.from({length:4},(_,i)=>{const theta=(q+i/3)*Math.PI/2;return {profile:{kind:'circle',radius:1},frame:{origin:[6.2*Math.cos(theta),6.2*Math.sin(theta),5+(q+i/3)*1.25],x_axis:[Math.cos(theta),Math.sin(theta),0],y_axis:[0,0,1]}};})});
48
+ const pattern=f('helicalTools'+q,'pattern',{input:tool,positions:Array.from({length:56},(_,i)=>[0,0,i*5])});
49
+ screw=cut('screwGroove'+q,screw,pattern);
50
+ }
51
+ const endStock=box('endPlateStock',[-29.8,.5,0],[59.6,44.5,11]);
52
+ const endBore=holes('endBearingSeat',endStock,[[0,23]],8,13,[0,0,-1]);
53
+ const endPlate=holes('endPlateScrews',endBore,[[-23,9],[23,9],[-23,35],[23,35]],1.5,11,[0,0,0],undefined,{radius:3,depth:3});
54
+ const motorStock=box('motorSupportStock',[-29.8,.5,311],[59.6,44.5,59]);
55
+ const motorWindow=f('motorSupportWindow','face_cutout',{input:motorStock,face:'pos_y',center:[0,340.5],profile:{kind:'rectangle',width:36,depth:39,radius:2},depth:41});
56
+ const motorBore=holes('motorBearingSeat',motorWindow,[[0,23]],10,61,[0,0,310]);
57
+ const motorRegister=faceholes('motorRegister',motorBore,'pos_z',[[0,23]],14,4);
58
+ // Nominal threaded holes: two four-hole patterns on PCD40; no cosmetic thread mesh.
59
+ const motorHoles=faceholes('motorM4Pattern',motorRegister,'pos_z',[45,135,225,315].map(a=>[20*Math.cos(a*Math.PI/180),23+20*Math.sin(a*Math.PI/180)]).filter(([x,y])=>y>.5),2,8);
60
+ const motorM3=faceholes('motorM3Pattern',motorHoles,'pos_z',[30,150,210,330].map(a=>[20*Math.cos(a*Math.PI/180),23+20*Math.sin(a*Math.PI/180)]),1.5,8);
61
+ const motor=faceholes('motorSupportBolts',motorM3,'pos_z',[-23,23].flatMap(x=>[9,35].map(y=>[x,y])),1.5,11,{radius:3,depth:3});
62
+ const couplingStock=ring('couplingHubStock',10,3,0,8);
63
+ const coupling=faceholes('couplingSetScrew',couplingStock,'pos_x',[[0,4]],1.5,7);
64
+ const couplingB=ring('couplingDrivenHub',10,3,0,8);
65
+ const spiderStock=extrude('couplingSpiderStock',Array.from({length:24},(_,i)=>{const a=i*Math.PI/12,r=i%4<2?9.8:6;return [r*Math.cos(a),r*Math.sin(a)];}),0,3);
66
+ const spider=holes('couplingSpider',spiderStock,[[0,0]],3.2,5,[0,0,-1]);
67
+ const boltStock=f('boltStock','revolve',{profile:{kind:'polygon',points:[[0,0],[1.4,0],[1.4,8],[2.7,8],[2.7,10.5],[0,10.5]]},frame:{origin:[0,0,0],x_axis:[1,0,0],y_axis:[0,0,1]},axis_origin:[0,0,0],axis:[0,0,1],angle_deg:360});
68
+ const bolt=f('socketBolt','face_cutout',{input:boltStock,face:'pos_z',center:[0,0],profile:{kind:'polygon',points:Array.from({length:6},(_,i)=>[1.3*Math.cos(i*Math.PI/3),1.3*Math.sin(i*Math.PI/3)])},depth:1.8});
69
+ const smallInner=ring('tailInnerRace',6.4,6,0,5),smallOuter=ring('tailOuterRace',8,7.2,0,5);
70
+ const driveInner=ring('driveInnerRace',5.6,4,0,7),driveOuter=ring('driveOuterRace',10,8.4,0,7);
71
+ const guideBall=f('guideBall','sphere',{center:[0,0,0],radius:1.5});
72
+ const bearingBall=f('bearingBall','sphere',{center:[0,0,0],radius:1.3});
73
+ const tailBall=f('tailBall','sphere',{center:[0,0,0],radius:.35});
74
+ inst('rail-machined',rail,undefined,undefined,'base-assembly');inst('end-bearing-plate',endPlate,undefined,undefined,'base-assembly');inst('motor-bearing-support',motor,undefined,undefined,'base-assembly');
75
+ inst('ballscrew-5mm-lead',screw,[0,23,11],[0,0,mul(p('travel'),72)],'screw-assembly');
76
+ inst('bearing-tail-inner',smallInner,[0,23,4],undefined,'screw-assembly');inst('bearing-tail-outer',smallOuter,[0,23,4],undefined,'screw-assembly');
77
+ inst('bearing-drive-inner',driveInner,[0,23,311],undefined,'screw-assembly');inst('bearing-drive-outer',driveOuter,[0,23,311],undefined,'screw-assembly');
78
+ for(let i=0;i<12;i++){const a=i*Math.PI/6;inst('bearing-drive-ball-'+i,bearingBall,[7*Math.cos(a),23+7*Math.sin(a),314.5],undefined,'screw-assembly');inst('bearing-tail-ball-'+i,tailBall,[6.8*Math.cos(a),23+6.8*Math.sin(a),6.5],undefined,'screw-assembly');}
79
+ const carriageZ=add(157,p('travel'));
80
+ inst('carriage-machined',car,[0,0,carriageZ],undefined,'carriage-installed');
81
+ inst('carriage-end-cap-a',cap,[0,0,add(carriageZ,-41)],undefined,'carriage-installed');inst('carriage-end-cap-b',cap,[0,0,add(carriageZ,25.5)],undefined,'carriage-installed');
82
+ inst('ball-nut',nut,[0,0,carriageZ],undefined,'rolling-assembly');inst('seal-wiper-a',wiper,[0,0,add(carriageZ,-41)],undefined,'rolling-assembly');inst('seal-wiper-b',wiper,[0,0,add(carriageZ,40)],undefined,'rolling-assembly');
83
+ for(let row=0;row<4;row++)for(let i=0;i<8;i++)inst('guide-ball-'+row+'-'+i,guideBall,[...trackPositions[row],add(carriageZ,-21+i*6)],undefined,'rolling-assembly');
84
+ inst('coupling-driven-hub',coupling,[0,23,330]);inst('coupling-spider',spider,[0,23,338]);inst('coupling-motor-hub',couplingB,[0,23,341]);
85
+ for(const x of [-23,23])for(const y of [9,35]){inst('bolt-tail-'+x+'-'+y,bolt,[x,y,10.5],[180,0,0]);inst('bolt-drive-'+x+'-'+y,bolt,[x,y,359.5]);}
86
+ const single={'rail-stock':railStock,'rail-races':railRaces,'rail-holes':rail,'carriage-stock':carStock,'carriage-bore':carBore,'carriage-holes':car,'screw-blank':shaftBlank,'screw-groove':screw,'end-plate':endPlate,'motor-bracket':motor,'coupling':coupling}[stage];
87
+ const at=stages.findIndex(s=>s.id===stage);
88
+ let assembly=all.filter(x=>stages.findIndex(s=>s.id===x.phase)<=at).map(({phase,...x})=>x);
89
+ // Separate inspection revision: carriage envelope at travel endpoints, before installing into whole assembly.
90
+ if(stage==='carriage-installed')assembly=assembly.filter(x=>x.id.startsWith('carriage-'));
91
+ const needed=new Set(single?[single]:assembly.map(x=>x.input));
92
+ for(const feat of [...features].reverse())if(needed.has(feat.id))for(const key of ['input','left','right'])if(feat[key])needed.add(feat[key]);
93
+ return {version:1,units:'mm',parameters:{travel},features:features.filter(x=>needed.has(x.id)),...(single?{output:single}:{assembly})};
94
+ }
@@ -0,0 +1,14 @@
1
+ import { resolve, join } from 'node:path';
2
+ import { writeFile,copyFile } from 'node:fs/promises';
3
+ import { ModelingSession } from '../../src/session.mjs';
4
+ import { kk60, stages } from './model.mjs';
5
+ const directory=resolve(process.argv[2]??'./out/hiwin-kk60');
6
+ const session=await ModelingSession.create(join(directory,'session'),{title:'HIWIN KK60 • catalog-based industrial actuator reconstruction',wallMs:120000});
7
+ for(const stage of stages){
8
+ const result=await session.build({...kk60(stage.id),preview:{chord_mm:.25,view:'iso',width:960,height:640}},stage);
9
+ console.log(JSON.stringify({stage:stage.id,ok:result.ok,solids:result.data?.geometry?.solids,time:result.data?.timing_ms,step:result.session_step,error:result.error}));
10
+ if(!result.ok)throw Error(JSON.stringify(result.error));
11
+ }
12
+ const model=kk60();await writeFile(join(directory,'model.json'),JSON.stringify(model,null,2)+'\n');
13
+ const last=(await session.read()).steps.at(-1);await copyFile(join(session.root,last.artifactDirectory,'model.step'),join(directory,'hiwin-kk60.step'));
14
+ console.log(JSON.stringify({directory,features:model.features.length,instances:model.assembly.length}));
@@ -0,0 +1,88 @@
1
+ {
2
+ "product": "HIWIN KK60 Standard, 5 mm lead, 300 mm rail, one A block, no motor/cover/switch",
3
+ "source": {
4
+ "publisher": "HIWIN Corporation",
5
+ "productUrl": "https://hiwin.com/products/kk-series-ballscrew-stages/kk-series/",
6
+ "catalogUrl": "https://hiwin.com/wp-content/uploads/2026/08/HIWIN-Ballscrew-Driven-Stages-Catalog-1.pdf",
7
+ "documentCode": "K99TE16-1906",
8
+ "downloaded": "2026-11-07",
9
+ "pages": {
10
+ "modelCode": 15,
11
+ "screwDiameterLead": 16,
12
+ "dimensionDrawing": 22
13
+ },
14
+ "pdfPages": {
15
+ "modelCode": 18,
16
+ "screwDiameterLead": 19,
17
+ "dimensionDrawing": 25
18
+ },
19
+ "sha256": "be54c5158ef723dfe2d97be26403b3970f5bc6c9290352e3d6b321d4560481c0"
20
+ },
21
+ "catalogDimensionsMm": {
22
+ "railLength": 300,
23
+ "overallLength": 370,
24
+ "railWidth": 60,
25
+ "carriageHeight": 33,
26
+ "screwAxisHeight": 23,
27
+ "railTopHeight": 22,
28
+ "carriageLength": 82,
29
+ "carriageMetalLength": 51,
30
+ "carriageWidth": 42,
31
+ "stroke": 210,
32
+ "screwDiameter": 12,
33
+ "lead": 5,
34
+ "driveShaftDiameter": 6,
35
+ "railMountHoles": {
36
+ "count": 6,
37
+ "diameter": 5.5,
38
+ "counterboreDiameter": 9.5,
39
+ "counterboreDepth": 4.7,
40
+ "xPitch": 30,
41
+ "zPitch": 100,
42
+ "G": 50
43
+ },
44
+ "carriageMountHoles": {
45
+ "count": 4,
46
+ "thread": "M5 x 0.8",
47
+ "depth": 8,
48
+ "pitch": [
49
+ 30,
50
+ 30
51
+ ]
52
+ },
53
+ "motorSupport": {
54
+ "width": 59.6,
55
+ "height": 44.5,
56
+ "bottomOffset": 0.5,
57
+ "length": 59,
58
+ "registerDiameter": 28,
59
+ "boltCircleDiameter": 40
60
+ },
61
+ "datumSlots": {
62
+ "width": 15,
63
+ "depth": 1.5
64
+ }
65
+ },
66
+ "datumInterpretations": [
67
+ "X is width, Y is vertical, Z is the travel axis; overall Z=0..370.",
68
+ "Rail Z=7..307; three mounting stations Z=57,157,257, measured from the right rail end using G=50.",
69
+ "Mid-stroke carriage center Z=157; travel +/-105 gives full block envelope Z=11..303.",
70
+ "Screw axis Y=23 was checked on the enlarged SECTION A-A, not inferred from the 15 mm side-hole dimension."
71
+ ],
72
+ "assumptions": [
73
+ "U-rail internal wall/floor profile, chamfers, groove radii and guide ball spacing are reconstructed. They are not manufacturing dimensions.",
74
+ "Screw groove uses four cubic circular-section lofts per turn, repeated 56 times. This is a geometric helix approximation, not the manufacturer's gothic-arch ground raceway.",
75
+ "Ball-nut internals and recirculation passages are not disclosed in the catalog. The nut is an annular envelope; no recirculation or load rating is claimed.",
76
+ "Support bearing race dimensions and rolling balls are illustrative and are not a sourced bearing SKU.",
77
+ "Motor bracket window, support screws, coupling/spider and wiper seats use documented example geometry where the catalog does not dimension them.",
78
+ "Threaded holes use nominal diameter cylinders; screws have plain shanks and real hex sockets. Thread geometry and tolerance fits are not modeled.",
79
+ "Motion uses the nominal screw relation 360 degrees per 5 mm; no dynamic/contact or preload simulation is performed.",
80
+ "Colors distinguish components; they do not establish manufacturer materials. No production mass or structural rating is claimed."
81
+ ],
82
+ "notIncluded": [
83
+ "optional motor",
84
+ "optional cover/bellows",
85
+ "optional limit switches",
86
+ "proprietary recirculation geometry"
87
+ ]
88
+ }
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/kernel/native/darwin-arm64/agent-cad
3
- size: 35996880 bytes
4
- sha256: 654d3cf07e093183913f1ed852ba4b944b13c2f0e48eefa960c464207cee2380
3
+ size: 35996736 bytes
4
+ sha256: e3cbc7abf95cc0911e5e9a1dae565c52e7bafe927f5bf7a42901aa9a48f2bca9
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "platform": "darwin-arm64",
3
- "version": "0.5.0",
4
- "bytes": 35996880,
5
- "sha256": "654d3cf07e093183913f1ed852ba4b944b13c2f0e48eefa960c464207cee2380"
3
+ "bytes": 35996736,
4
+ "sha256": "e3cbc7abf95cc0911e5e9a1dae565c52e7bafe927f5bf7a42901aa9a48f2bca9"
6
5
  }
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/kernel/native/linux-arm64/agent-cad
3
3
  size: 35525448 bytes
4
- sha256: e4631cf988a2ceed9fbe87fbe4311bb65d84f530d18de66df337570302f3d73e
4
+ sha256: 9e2e965f2e136d2fe31009738be8c42e98b39ccccf838c6f22b07d7ead39e714
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "platform": "linux-arm64",
3
- "version": "0.5.0",
4
- "sha256": "e4631cf988a2ceed9fbe87fbe4311bb65d84f530d18de66df337570302f3d73e",
5
- "bytes": 35525448
3
+ "bytes": 35525448,
4
+ "sha256": "9e2e965f2e136d2fe31009738be8c42e98b39ccccf838c6f22b07d7ead39e714"
6
5
  }
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/kernel/native/linux-x64/agent-cad
3
- size: 46378104 bytes
4
- sha256: 96dc76748e85928959de684b25e107e45a9e39df46841239d7da084c96554a29
3
+ size: 46383744 bytes
4
+ sha256: 33031163011d5fb73f12366362f74cdb72115e452c66116e5a53bb433eb1779e
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "platform": "linux-x64",
3
- "version": "0.5.0",
4
- "sha256": "96dc76748e85928959de684b25e107e45a9e39df46841239d7da084c96554a29",
5
- "bytes": 46378104
3
+ "bytes": 46383744,
4
+ "sha256": "33031163011d5fb73f12366362f74cdb72115e452c66116e5a53bb433eb1779e"
6
5
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": "0.1.0-alpha.4",
3
+ "sha256": {
4
+ "darwin-arm64": "e3cbc7abf95cc0911e5e9a1dae565c52e7bafe927f5bf7a42901aa9a48f2bca9",
5
+ "linux-arm64": "9e2e965f2e136d2fe31009738be8c42e98b39ccccf838c6f22b07d7ead39e714",
6
+ "linux-x64": "33031163011d5fb73f12366362f74cdb72115e452c66116e5a53bb433eb1779e"
7
+ }
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coloopx/colocad",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.4",
4
4
  "description": "Parametric feature instructions, a local Rust B-rep kernel and an experimental SolidWorks author",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,7 +26,15 @@
26
26
  "types": "./kernel/dist/index.d.ts",
27
27
  "import": "./kernel/dist/index.js"
28
28
  },
29
- "./schema": "./kernel/schemas/model.schema.json"
29
+ "./schema": "./kernel/schemas/model.schema.json",
30
+ "./session": {
31
+ "types": "./src/session.d.mts",
32
+ "import": "./src/session.mjs"
33
+ },
34
+ "./viewer": {
35
+ "types": "./viewer/index.d.ts",
36
+ "import": "./viewer/dist/index.js"
37
+ }
30
38
  },
31
39
  "bin": {
32
40
  "colocad": "bin/colocad.mjs"
@@ -43,14 +51,44 @@
43
51
  "examples/sensor-rail.json",
44
52
  "README.md",
45
53
  "LICENSE",
46
- "NOTICE.md"
54
+ "NOTICE.md",
55
+ "skills/colocad",
56
+ "kernel/release.json",
57
+ "scripts/check-release.mjs",
58
+ "README.zh-CN.md",
59
+ "viewer/dist",
60
+ "viewer/index.d.ts",
61
+ "viewer/THREE-LICENSE",
62
+ "examples/hiwin-kk60/model.mjs",
63
+ "examples/hiwin-kk60/run.mjs",
64
+ "examples/hiwin-kk60/README.md",
65
+ "examples/hiwin-kk60/sources.json",
66
+ "docs/modeling-history.md"
47
67
  ],
48
68
  "scripts": {
49
69
  "test": "node --test test/*.test.mjs",
50
- "build:kernel": "node scripts/build-kernel.mjs"
70
+ "build:kernel": "node scripts/build-kernel.mjs",
71
+ "prepack": "node scripts/check-release.mjs",
72
+ "build:viewer": "node scripts/build-viewer.mjs",
73
+ "test:viewer": "node test/viewer.browser.mjs",
74
+ "test:integrations": "npm test --prefix examples/integrations",
75
+ "test:render": "node test/render.browser.mjs"
51
76
  },
52
77
  "publishConfig": {
53
78
  "access": "public",
54
79
  "registry": "https://registry.npmjs.org"
80
+ },
81
+ "devDependencies": {
82
+ "esbuild": "0.28.2",
83
+ "playwright": "1.65.0",
84
+ "three": "0.187.0"
85
+ },
86
+ "peerDependencies": {
87
+ "playwright": ">=1.50.0 <2"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "playwright": {
91
+ "optional": true
92
+ }
55
93
  }
56
94
  }
@@ -0,0 +1,24 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFile, stat } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const root = fileURLToPath(new URL('../', import.meta.url));
7
+ const readJson = async (name) => JSON.parse(await readFile(join(root, name), 'utf8'));
8
+ const pkg = await readJson('package.json');
9
+ const release = await readJson('kernel/release.json');
10
+ if (release.version !== pkg.version) throw Error('Update the tested kernel hashes for ' + pkg.version);
11
+
12
+ for (const platform of ['darwin-arm64', 'linux-arm64', 'linux-x64']) {
13
+ const dir = join('kernel', 'native', platform);
14
+ const manifest = await readJson(join(dir, 'manifest.json'));
15
+ const binary = join(root, dir, 'agent-cad');
16
+ const bytes = await readFile(binary);
17
+ const hash = createHash('sha256').update(bytes).digest('hex');
18
+ if (manifest.platform !== platform || manifest.bytes !== bytes.length ||
19
+ manifest.sha256 !== hash || release.sha256[platform] !== hash ||
20
+ !((await stat(binary)).mode & 0o111)) {
21
+ throw Error('Missing or incorrect tested kernel for ' + platform);
22
+ }
23
+ }
24
+ await readFile(join(root, 'skills/colocad/SKILL.md'));
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: colocad
3
+ description: Build and verify editable mechanical parts and assemblies from dimensions, engineering drawings or multiple views with @coloopx/colocad. Use for quick parametric construction, fit checks, STEP and previews.
4
+ ---
5
+
6
+ Use the project's installed `@coloopx/colocad` on Node 22+. The agent and harness use the SDK and native executable inside the same sandbox.
7
+
8
+ For a dimensioned part, start with the cross-section or stock that controls its shape. Use the [quick-build guide](references/quick-build.md) for single-feature stock (block, pin, ball, taper) and common structures (hole grid, sleeve, L-section, open housing). Each model has editable dimensions. The guide gives their datums, measurements to check, and an example of reusing a definition in an assembly. Pick only the features the drawing calls for. Guide dimensions are examples.
9
+
10
+ For drawings, identify the views, units, scale and common datum. Separate measured dimensions from hidden or assumed details. Compare projections from the final STEP against the supplied views at the same scale. Flag dimensions that prevent a critical fit from being checked.
11
+
12
+ Choose the entry point that matches the model:
13
+
14
+ - A kernel model (`version: 1`, units `mm`, `parameters`, `features`, and either `output` or named `assembly`) supports arbitrary sketch planes, single solids and placements. Run `node <skill-dir>/scripts/build.mjs MODEL.json NEW_DIR [--set name=value] [--preview]` in the project. Use the returned `directory` to find the effective `model.json`, exact `model.step` and `report.json`. The installed package exports the full schema as `@coloopx/colocad/schema`.
15
+ - For a `colocad/1` XY feature tree use the project's `node_modules/.bin/colocad plan TREE.json` and `node_modules/.bin/colocad build TREE.json NEW_DIR --preview`. Cuts start at `startZ` and travel along +Z. Linear pattern counts include their seed. This entry point also produces the feature tree and native job in `NEW_DIR/part/`.
16
+
17
+ Return the editable model and STEP. Reopen the STEP and check the dimensions that distinguish success for this task, such as a bore's diameter and axis or a cut reaching the cavity. For a long construction, keep inspectable milestones and a fixed camera. An assembly preview establishes appearance. A fit or motion claim needs the corresponding measurement.
18
+
19
+ For human review of construction steps, use the [persistent history workflow](references/history.md). Record real geometry milestones as well as assembly placements, retain failed attempts, and deliver the offline HTML alongside the editable source and STEP.
@@ -0,0 +1,39 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "foot": 40,
6
+ "upright": 32,
7
+ "span": 24,
8
+ "wall": 4,
9
+ "holeDiameter": 5
10
+ },
11
+ "features": [
12
+ {
13
+ "id": "angle",
14
+ "op": "extrude",
15
+ "frame": {"origin": [0, 0, 0], "x_axis": [1, 0, 0], "y_axis": [0, 0, 1]},
16
+ "profile": {"kind": "polygon", "points": [[0, 0], [{"param": "foot"}, 0], [{"param": "foot"}, {"param": "wall"}], [{"param": "wall"}, {"param": "wall"}], [{"param": "wall"}, {"param": "upright"}], [0, {"param": "upright"}]]},
17
+ "height": {"param": "span"}
18
+ },
19
+ {
20
+ "id": "footHole",
21
+ "op": "face_holes",
22
+ "input": "angle",
23
+ "face": "neg_z",
24
+ "positions": [[{"op": "div", "a": {"param": "foot"}, "b": 2}, {"op": "div", "a": {"param": "span"}, "b": -2}]],
25
+ "radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
26
+ "depth": {"param": "wall"}
27
+ },
28
+ {
29
+ "id": "uprightHole",
30
+ "op": "face_holes",
31
+ "input": "footHole",
32
+ "face": "neg_x",
33
+ "positions": [[{"op": "div", "a": {"param": "span"}, "b": -2}, {"op": "div", "a": {"param": "upright"}, "b": 2}]],
34
+ "radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
35
+ "depth": {"param": "wall"}
36
+ }
37
+ ],
38
+ "output": "uprightHole"
39
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "diameter": 16
6
+ },
7
+ "features": [
8
+ {
9
+ "id": "stock",
10
+ "op": "sphere",
11
+ "center": [0, 0, 0],
12
+ "radius": {"op": "div", "a": {"param": "diameter"}, "b": 2}
13
+ }
14
+ ],
15
+ "output": "stock"
16
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "length": 40,
6
+ "width": 25,
7
+ "height": 8
8
+ },
9
+ "features": [
10
+ {
11
+ "id": "stock",
12
+ "op": "box",
13
+ "origin": [0, 0, 0],
14
+ "size": [{"param": "length"}, {"param": "width"}, {"param": "height"}]
15
+ }
16
+ ],
17
+ "output": "stock"
18
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "width": 60,
6
+ "depth": 40,
7
+ "height": 22,
8
+ "wall": 2,
9
+ "floor": 3,
10
+ "portWidth": 12,
11
+ "portHeight": 6,
12
+ "portCenterZ": 12
13
+ },
14
+ "features": [
15
+ {
16
+ "id": "shell",
17
+ "op": "shell_body",
18
+ "profile": {"kind": "rectangle", "width": {"param": "width"}, "depth": {"param": "depth"}},
19
+ "height": {"param": "height"},
20
+ "wall": {"param": "wall"},
21
+ "floor": {"param": "floor"},
22
+ "open_face": "top"
23
+ },
24
+ {
25
+ "id": "port",
26
+ "op": "face_cutout",
27
+ "input": "shell",
28
+ "face": "pos_y",
29
+ "center": [0, {"param": "portCenterZ"}],
30
+ "profile": {"kind": "rectangle", "width": {"param": "portWidth"}, "depth": {"param": "portHeight"}},
31
+ "depth": {"param": "wall"}
32
+ }
33
+ ],
34
+ "output": "port"
35
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "diameter": 8,
6
+ "length": 20
7
+ },
8
+ "features": [
9
+ {
10
+ "id": "stock",
11
+ "op": "cylinder",
12
+ "origin": [0, 0, 0],
13
+ "radius": {"op": "div", "a": {"param": "diameter"}, "b": 2},
14
+ "height": {"param": "length"}
15
+ }
16
+ ],
17
+ "output": "stock"
18
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "length": 80,
6
+ "width": 50,
7
+ "thickness": 6,
8
+ "holeDiameter": 6,
9
+ "xCount": 2,
10
+ "yCount": 2,
11
+ "xPitch": 50,
12
+ "yPitch": 30
13
+ },
14
+ "features": [
15
+ {
16
+ "id": "plate",
17
+ "op": "box",
18
+ "origin": [0, 0, 0],
19
+ "size": [{"param": "length"}, {"param": "width"}, {"param": "thickness"}]
20
+ },
21
+ {
22
+ "id": "mounts",
23
+ "op": "face_hole_grid",
24
+ "input": "plate",
25
+ "face": "pos_z",
26
+ "center": [{"op": "div", "a": {"param": "length"}, "b": 2}, {"op": "div", "a": {"param": "width"}, "b": 2}],
27
+ "count": [{"param": "xCount"}, {"param": "yCount"}],
28
+ "spacing": [{"param": "xPitch"}, {"param": "yPitch"}],
29
+ "radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
30
+ "depth": {"param": "thickness"}
31
+ }
32
+ ],
33
+ "output": "mounts"
34
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "outerDiameter": 12,
6
+ "boreDiameter": 6,
7
+ "length": 16
8
+ },
9
+ "features": [
10
+ {
11
+ "id": "sleeve",
12
+ "op": "extrude",
13
+ "profile": {"kind": "circle", "radius": {"op": "div", "a": {"param": "outerDiameter"}, "b": 2}},
14
+ "holes": [{"kind": "circle", "radius": {"op": "div", "a": {"param": "boreDiameter"}, "b": 2}}],
15
+ "height": {"param": "length"}
16
+ }
17
+ ],
18
+ "output": "sleeve"
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": 1,
3
+ "units": "mm",
4
+ "parameters": {
5
+ "baseDiameter": 16,
6
+ "topDiameter": 8,
7
+ "height": 20
8
+ },
9
+ "features": [
10
+ {
11
+ "id": "stock",
12
+ "op": "cone",
13
+ "origin": [0, 0, 0],
14
+ "base_radius": {"op": "div", "a": {"param": "baseDiameter"}, "b": 2},
15
+ "top_radius": {"op": "div", "a": {"param": "topDiameter"}, "b": 2},
16
+ "height": {"param": "height"}
17
+ }
18
+ ],
19
+ "output": "stock"
20
+ }
@@ -0,0 +1,19 @@
1
+ # Persistent modeling history
2
+
3
+ Use this workflow when the user wants to inspect construction steps or hand off an offline replay. It requires a colocad build that lists `record` and `replay` in `colocad --help`; the older npm alpha.3 CLI does not include these commands.
4
+
5
+ Save each meaningful geometry or assembly milestone as JSON, then run from the project:
6
+
7
+ ```sh
8
+ ./node_modules/.bin/colocad record model.json ./history --label "Bore the hub"
9
+ ./node_modules/.bin/colocad view ./history
10
+ ./node_modules/.bin/colocad replay ./history ./history.html
11
+ ```
12
+
13
+ `record` accepts a kernel model or a `colocad/1` feature tree, appends a real build with a preview, and prints the receipt. Reuse the session directory for later attempts. A failed build exits nonzero and stays in history. Change the cause, then record a corrected attempt; do not delete the failed step to imply uninterrupted success.
14
+
15
+ Choose steps that explain geometry: blank → bore/cut → shaped blade → repeated placements → full assembly. Avoid recording only final part placement if the user asked how the kernel constructed the shape. A milestone is an actual build call; internal feature timings remain in the receipt.
16
+
17
+ The HTML is self-contained and includes orbit/view controls, display-only clipping/explosion, the inputs and receipts, and the final exact STEP. Review playback uses a presentation cadence; recorded call durations are shown separately. Preserve the entire session directory if every intermediate STEP must remain available. A camera change or clipping plane does not modify the saved exact model.
18
+
19
+ For a modeling animation use the same CLI: `colocad render SESSION ./modeling.mp4` (or `.gif`). This requires optional Playwright/Chromium and FFmpeg. It replays actual persisted geometry in four views, preserving measured call times. Review pacing, cutaway and explosion are presentation only. Do not present the film duration as build time or a benchmark.