@codeyam/codeyam-cli 0.1.0-staging.dbc742d → 0.1.0-staging.e057775
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/analyzer-template/.build-info.json +6 -6
- package/analyzer-template/log.txt +3 -3
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +45 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/editor.js +177 -80
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +144 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +221 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +51 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +14 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +96 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +17 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorPreview.js +26 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +4 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +17 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/git.js +3 -2
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-0DY_NKil.js → ScenarioViewer-Bd-hxofb.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-Csi0_PMl.js → dev.empty-BsDh6TSF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-PBc_6L9R.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-4FzHlcNn.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BF4oLwaE.js → entity._sha._-BsDXNp45.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-C7YX6r3H.js → entity._sha.scenarios._scenarioId.dev-BgAqUtTZ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Bmshgrij.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-B8vTTNy2.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-65850841.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{root-CHOdrM6Y.js → root-BwX8YgFb.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BE43Hjti.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/{index-BWoRb5RY.js → index-DEEQf4pi.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{init-DbChSUQP.js → init-CkWmyFY2.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BHi-9O8W.js +439 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +26 -4
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +3 -3
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/editor-step-hook.py +11 -6
- package/package.json +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-BBAGP_mE.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-BLQMSKZa.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-COUSHTyZ.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-9c70d1f3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BtbLQkKd.js +0 -433
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as l from"fs/promises";import*as h from"fs";import*as t from"path";import f from"chalk";import{execSync as M}from"child_process";import D from"cli-spinners";import{ab as T,ac as B,ad as E,ae as _,af as R,ag as W,ah as q,ai as Y,F as O,I as U,aj as G,ak as z,al as A,x as P}from"./server-build-
|
|
1
|
+
import*as l from"fs/promises";import*as h from"fs";import*as t from"path";import f from"chalk";import{execSync as M}from"child_process";import D from"cli-spinners";import{ab as T,ac as B,ad as E,ae as _,af as R,ag as W,ah as q,ai as Y,F as O,I as U,aj as G,ak as z,al as A,x as P}from"./server-build-BHi-9O8W.js";import"fetch-retry";import"typescript";import"kysely";import{fileURLToPath as N}from"url";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"os";import"prompts";import"crypto";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";function J(i){try{const s=M("git config --get remote.origin.url",{cwd:i,encoding:"utf8"}).trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);if(s)return`${s[1]}-${s[2]}`}catch{}return t.basename(i)}class k{constructor(e=!1){this.spinnerIndex=0,this.currentMessage="",this.isSpinning=!1,this.spinnerFrames=D.dots.frames,this.spinnerInterval=D.dots.interval,this.isTTY=process.stdout.isTTY,this.quiet=e}start(e){if(this.currentMessage=e,this.isSpinning=!0,this.spinnerIndex=0,k.activeInstance=this,!this.quiet){if(!this.isTTY){console.log(f.cyan("⠿")+" "+this.currentMessage);return}process.stdout.write("\r"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length,this.spinner=setInterval(()=>{process.stdout.write("\r"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length},this.spinnerInterval),this.spinner.unref()}}static pause(){var e;(e=k.activeInstance)==null||e.stop()}static resume(){const e=k.activeInstance;e&&e.currentMessage&&e.start(e.currentMessage)}update(e){this.currentMessage=e,!this.quiet&&(this.isTTY||console.log(f.cyan("⠿")+" "+this.currentMessage))}succeed(e){this.stop();const s=e||this.currentMessage;this.quiet||(this.isTTY||s!==this.currentMessage)&&console.log(f.green("✓")+" "+s)}fail(e){this.stop();const s=e||this.currentMessage;this.quiet||console.log(f.red("✗")+" "+s)}warn(e){this.stop(),!this.quiet&&console.log(f.yellow("⚠")+" "+e)}info(e){this.stop(),!this.quiet&&console.log(f.blue("ℹ")+" "+e)}stop(){this.spinner&&(clearInterval(this.spinner),this.spinner=void 0),this.isSpinning&&this.isTTY&&(process.stdout.write("\r\x1B[K"),this.isSpinning=!1),this===k.activeInstance&&(k.activeInstance=void 0)}}async function L(i){k.pause();try{return await i()}finally{k.resume()}}const x=i=>console.log(f.green("✓")+" "+i),$=i=>console.log(f.red("✗")+" "+i),H=i=>console.log(f.blue("ℹ")+" "+i),K=i=>{console.log(),console.log(f.cyan.bold("🚀 "+i)),console.log()},V=N(import.meta.url),Q=t.dirname(V);async function w(i,e){await l.mkdir(e,{recursive:!0});const s=await l.readdir(i,{withFileTypes:!0});for(const n of s){const a=t.join(i,n.name),o=t.join(e,n.name);n.isDirectory()?await w(a,o):(await l.copyFile(a,o),(n.name.endsWith(".sh")||n.name.endsWith(".mjs"))&&await l.chmod(o,493))}}async function X(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude","skills"),a=t.join(Q,"../../templates"),o=t.join(a,"skills"),r=t.join(a,"commands"),u=t.join(n,"codeyam-memory"),p=t.join(n,"codeyam-new-rule");await w(t.join(o,"codeyam-memory"),u),await w(t.join(o,"codeyam-new-rule"),p);const S=s==="editor"||(e==null?void 0:e.editorMode)===!0;if(S){const c=t.join(n,"codeyam-editor");await w(t.join(o,"codeyam-editor"),c);const y=t.join(i,"CLAUDE.md");try{await l.access(y)}catch{await l.copyFile(t.join(a,"codeyam-editor-claude.md"),y)}}if(s==="full"){const c=t.join(n,"codeyam-setup"),y=t.join(n,"codeyam-sim"),m=t.join(n,"codeyam-test"),g=t.join(n,"codeyam-verify"),b=t.join(n,"codeyam-dev-mode");await w(t.join(o,"codeyam-setup"),c),await w(t.join(o,"codeyam-sim"),y),await w(t.join(o,"codeyam-test"),m),await w(t.join(o,"codeyam-verify"),g),await w(t.join(o,"codeyam-dev-mode"),b);const v=t.join(i,".claude","commands");await l.mkdir(v,{recursive:!0}),await l.copyFile(t.join(r,"codeyam-diagnose.md"),t.join(v,"codeyam-diagnose.md"))}const d=t.join(i,".codeyam","bin");await l.mkdir(d,{recursive:!0});const j=t.join(i,".codeyam","rules");if(await l.mkdir(j,{recursive:!0}),S)try{const c=t.join(d,"editor-step-hook.py");await l.copyFile(t.join(a,"editor-step-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"memory-hook.sh");await l.copyFile(t.join(a,"codeyam-memory-hook.sh"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-reflection-hook.py");await l.copyFile(t.join(a,"rule-reflection-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-notification-hook.py");await l.copyFile(t.join(a,"rule-notification-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"prompts");await l.mkdir(c,{recursive:!0});const y=await l.readdir(t.join(a,"prompts"));for(const m of y)await l.copyFile(t.join(a,"prompts",m),t.join(c,m))}catch{}try{await l.copyFile(t.join(a,"rules-instructions.md"),t.join(j,"instructions.md"))}catch{}return{success:!0,skillsPath:t.relative(i,n)}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}function Z(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude"),a=t.join(n,"settings.local.json");h.existsSync(n)||h.mkdirSync(n,{recursive:!0});let o={};if(h.existsSync(a))try{const c=h.readFileSync(a,"utf8");o=JSON.parse(c)}catch{console.warn(`Warning: Could not parse ${a}, will create new file`)}o.permissions||(o.permissions={}),o.permissions.allow||(o.permissions.allow=[]);const r=["Skill(codeyam-memory)","Skill(codeyam-new-rule)","Bash(codeyam)","Bash(codeyam:*)","Read(.codeyam/**)","Edit(.codeyam/**)","Write(.codeyam/**)","Glob(.codeyam/**)"],u=["Skill(codeyam-setup)","Skill(codeyam-sim)","Skill(codeyam-debug)","Skill(codeyam-test)","Skill(codeyam-verify)","Skill(codeyam-dev-mode)","Read(/tmp/**)","Edit(/tmp/**)","Write(/tmp/**)","Glob(/tmp/**)","Bash(npm install:*)","Bash(npm run:*)","Bash(npx:*)","Bash(node:*)","Bash(cp:*)","Bash(mkdir:*)","Bash(chmod:*)","Bash(rm:*)","Bash(curl:*)","Bash(sleep:*)","Bash(echo:*)","Bash(grep:*)","Bash(python3:*)","Bash(cat:*)","Bash(printf:*)"],p=["Skill(codeyam-editor)","Bash(git:*)","Edit(**)","Write(**)"],S=s==="editor"||(e==null?void 0:e.editorMode)===!0;let d;if(s==="full"?d=[...r,...u]:s==="editor"?d=[...r,...p,...u]:d=r,S&&s!=="editor")for(const c of[...p,...u])d.includes(c)||d.push(c);let j=!1;for(const c of d)o.permissions.allow.includes(c)||(o.permissions.allow.push(c),j=!0);if(S){o.hooks||(o.hooks={});const c='test -f "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py && python3 "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py || true';for(const y of["PostToolUse","Stop","UserPromptSubmit"]){const m=o.hooks[y]||[];m.some(b=>{var v;return(v=b.hooks)==null?void 0:v.some(F=>{var C;return(C=F.command)==null?void 0:C.includes("editor-step-hook")})})||(m.push({hooks:[{type:"command",command:c,timeout:5}]}),o.hooks[y]=m,j=!0)}}return j&&h.writeFileSync(a,JSON.stringify(o,null,2),"utf8"),!0}catch(n){return console.warn(`Warning: Could not configure Claude Code settings: ${n.message}`),!1}}function ee(i){return h.existsSync(i)?h.readFileSync(i,"utf8").split(`
|
|
2
2
|
`).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#")).map(s=>s.startsWith("/")?s.slice(1):s):[]}function te(i){const e=[];function s(n){const a=t.join(n,".gitignore");if(h.existsSync(a)){const o=ee(a),r=t.relative(i,n),u=o.map(p=>r?t.join(r,p):p);e.push(...u)}try{const o=h.readdirSync(n,{withFileTypes:!0});for(const r of o)r.isDirectory()&&r.name!=="node_modules"&&r.name!==".git"&&r.name!=="dist"&&r.name!=="build"&&s(t.join(n,r.name))}catch{}}return s(i),e}function ie(i){let e=i.replace(/\/$/,"");const s=e.startsWith("**/");s&&(e=e.slice(3));const n=e.startsWith("/");return n&&(e=e.slice(1)),e=e.replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),e=e.replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^/]*").replace(/\\\?/g,"."),n&&!s?`^${e}(/.*)?$`:`^(.*/)?${e}(/.*)?$`}function oe(){return["^(.*/)?node_modules/.*$","^(.*/)?dist/.*$","^(.*/)?build/.*$","^(.*/)?\\.next/.*$","^(.*/)?out/.*$","^(.*/)?\\.cache/.*$","^(.*/)?__tests__/.*$","^(.*/)?__mocks__/.*$","^(.*/)?.+\\.test\\.(ts|tsx|js|jsx)$","^(.*/)?.+\\.spec\\.(ts|tsx|js|jsx)$","^(.*/)?test/.*$","^(.*/)?tests/.*$","^(.*/)?__test","^(.*/)?\\.git/.*$","^(.*/)?coverage/.*$","^(.*/)?\\.nyc_output/.*$","^(.*/)?\\.vscode/.*$","^(.*/)?\\.idea/.*$","^(.*/)?\\.DS_Store$"]}function se(i){const e=oe();try{const n=te(i).filter(o=>o.trim().length>0).map(o=>ie(o)),a=[...e,...n];return Array.from(new Set(a))}catch(s){return console.warn("Failed to load gitignore patterns:",s),e}}const tt={command:"init",describe:"Initialize a project for CodeYam CLI analysis",builder:{force:{type:"boolean",alias:"f",describe:"Force initialization even if .codeyam already exists",default:!1},"keep-server":{type:"boolean",describe:"Skip stopping the running CodeYam server (use when running inside the editor)",default:!1}},handler:async i=>{K("Initializing CodeYam CLI project");let e=T();if(e&&!i.force){x("Project already initialized. Use --force to reinitialize.");return}if(e||(e=process.cwd()),B(e)){$("Cannot initialize CodeYam in your home directory or filesystem root."),$("Please run codeyam init from inside a project directory.");return}E(e);const{running:s}=_();s&&!i["keep-server"]&&(R()?x("CodeYam server stopped"):$("Failed to stop CodeYam server - it may have already stopped"));const n=t.join(e,".codeyam"),a=t.join(n,"config.json"),o=new k;try{o.start("Setting up project scaffolding..."),await l.mkdir(n,{recursive:!0}),await re(e),o.succeed("Project scaffolding ready");let r=J(e);try{const m=JSON.parse(h.readFileSync(a,"utf8"));m.projectSlug&&!m.projectSlug.startsWith("local-")&&(r=m.projectSlug)}catch{}const u=ne(e);let p=[];try{p=W(e)}catch{}if(p.length>0){const m=p.map(g=>`${g.path==="."?"Root":g.path} (${g.framework})`).join(", ");H(`Found ${p.length} web application${p.length>1?"s":""}: ${m}`)}o.start("Configuring project...");const S=q(a),d={projectSlug:r,packageManager:u,webapps:p,environmentVariables:[],createdAt:new Date().toISOString(),...S};await l.writeFile(a,JSON.stringify(d,null,2));const j=Y();if(!h.existsSync(j)){const m=O(j);await U(m)}if(!await L(()=>G())){o.fail("Environment validation failed");return}try{const{project:m}=await z({slug:r,packageManager:u,unapprovedPaths:se(e),webapps:p});o.succeed("Project configured"),o.start("Installing Claude Code skills...");const g=!!i["keep-server"],b=await X(e,{mode:g?"editor":"memory",editorMode:g}),{branch:v}=await A(m);d.branchId=v.id,await l.writeFile(a,JSON.stringify(d,null,2)),Z(e,{mode:g?"editor":"memory",editorMode:g}),b.success?o.succeed("Claude Code skills installed"):o.warn("Could not install skills");try{i["keep-server"]?await P({projectSlug:r,metadataUpdate:{editorMode:!0,labs:{simulations:!0}}}):await P({projectSlug:r,metadataUpdate:{labs:{simulations:!1}}})}catch{}d.aiMode="interactive"}catch(m){o.fail("Failed to create project"),$(m.message);return}const y=p.length>0?`, ${p.map(m=>m.framework).join(", ")}`:"";console.log(),x(`✨ Initialized ${r} (${u}${y})`),i.autoInit||(console.log(),console.log(f.bold(' Run "codeyam" to start the dashboard')),console.log(' Run "codeyam --help" for all commands'))}catch(r){o.fail("Failed to initialize project"),$(r.message),process.exit(1)}}};function ne(i){return h.existsSync(t.join(i,"pnpm-lock.yaml"))?"pnpm":h.existsSync(t.join(i,"yarn.lock"))?"yarn":(h.existsSync(t.join(i,"package-lock.json")),"npm")}const I=[".codeyam/db.sqlite3",".codeyam/db.sqlite3-wal",".codeyam/db.sqlite3-shm",".codeyam/secrets.json",".codeyam/server.json",".codeyam/server-state.json",".codeyam/queue.json",".codeyam/active-scenario.json",".codeyam/editor-step.json",".codeyam/editor-user-prompt.txt",".codeyam/editor-mode-context.md",".codeyam/dev-mode-context.md",".codeyam/logs/",".codeyam/llm-calls/",".codeyam/captures/",".codeyam/results/",".codeyam/tmp/",".codeyam/rules/",".codeyam/bin/"];async function re(i){const e=t.join(i,".gitignore");let s="";try{s=await l.readFile(e,"utf8")}catch{}const n=s.split(`
|
|
3
3
|
`),a=n.findIndex(r=>r.trim()===".codeyam"||r.trim()==="/.codeyam");if(a!==-1){const r=a>0&&n[a-1].trim().startsWith("# CodeYam local files")?a-1:a;n.splice(r,a-r+1),s=n.join(`
|
|
4
4
|
`)}if(!I.some(r=>n.some(u=>u.trim()===r))){const r=`
|