@rockysoft/opencode-hybrid-workflow 0.3.3-beta.2 → 0.3.3-beta.3

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.
@@ -1,18 +1,20 @@
1
- # Bundled references
2
-
3
- - `assets/skills/frontend-design`: Anthropic skills, commit
4
- `dbd4588f9e1033efb41dad4bef2f7947c8993d44`, Apache-2.0. The included
5
- `LICENSE.txt` applies. Local integration text is adapted for OpenCode and
6
- portable screenshot validation; original design guidance is preserved.
7
- - `assets/skills/ui-ux-pro-max`: Next Level Builder, commit
8
- `1f8857914da3c723d58dab1d609dd0d55a86bf51`, MIT. The included `LICENSE`
9
- applies. Local integration examples use portable Python invocation rather than
10
- a machine-specific executable. Catalogs and search code are preserved.
11
- - `assets/skills/web-design-guidelines/SKILL.md` is a package-authored wrapper
12
- referring to Vercel's public Web Interface Guidelines. It does not redistribute
13
- the fetched guidelines or Vercel's original skill text.
14
-
15
- The package's original code is Copyright (c) 2026 RockySoft and is distributed
16
- under the MIT license in `LICENSE`. Third-party licenses remain in effect for
17
- their respective files; the root license does not replace them. No user
18
- credentials, project memories, session logs or runtime reports are included.
1
+ # Bundled references
2
+
3
+ - `assets/skills/frontend-design`: Anthropic skills, commit
4
+ `dbd4588f9e1033efb41dad4bef2f7947c8993d44`, Apache-2.0. The included
5
+ `LICENSE.txt` applies. Local integration text is adapted for OpenCode and
6
+ portable screenshot validation; original design guidance is preserved.
7
+ - `assets/skills/ui-ux-pro-max`: Next Level Builder, commit
8
+ `1f8857914da3c723d58dab1d609dd0d55a86bf51`, MIT. The included `LICENSE`
9
+ applies. Local integration examples use portable Python invocation rather than
10
+ a machine-specific executable. Catalogs and search code are preserved.
11
+ - `assets/skills/web-design-guidelines/SKILL.md` is a package-authored wrapper
12
+ referring to Vercel's public Web Interface Guidelines. It does not redistribute
13
+ the fetched guidelines or Vercel's original skill text.
14
+
15
+ The package's original code is Copyright (c) 2026 RockySoft and is distributed
16
+ under the MIT license in `LICENSE`. Third-party licenses remain in effect for
17
+ their respective files; the root license does not replace them. No user
18
+ credentials, project memories, session logs or runtime reports are included.
19
+
20
+ - Runtime dependency `diff` (jsdiff) 9.0.0, BSD-3-Clause, https://github.com/kpdecker/jsdiff. Its license is distributed with the dependency.
@@ -0,0 +1,16 @@
1
+ import {parentPort,workerData} from 'node:worker_threads';
2
+ import {structuredPatch} from 'diff';
3
+
4
+ // CPU-heavy comparisons run off the host thread. A difficult comparison falls
5
+ // back to complete text; the computation budget never discards evidence.
6
+ const changed=workerData.files.map(file=>{
7
+ if(file.opaque)return file.metadata;
8
+ const {oldText,newText,metadata}=file;
9
+ const patch=structuredPatch(metadata.file,metadata.file,oldText,newText,undefined,undefined,
10
+ {context:3,timeout:workerData.computeMs,stripTrailingCr:false});
11
+ if(!patch)return {...metadata,format:'full-text',before:oldText,after:newText,
12
+ note:'Diff computation used complete-text fallback. Both versions are exact; no content was truncated.'};
13
+ return {...metadata,format:'hunks',hunks:patch.hunks,
14
+ note:'Exact unified hunks with 3 context lines. Complete current text remains in source.'};
15
+ });
16
+ parentPort.postMessage({version:2,changed});
@@ -0,0 +1,29 @@
1
+ import {Worker} from 'node:worker_threads';
2
+
3
+ export async function changeSet(before,after,{signal,computeMs=1000}={}) {
4
+ signal?.throwIfAborted();
5
+ const files=[];
6
+ for(const file of [...new Set([...Object.keys(before.files),...Object.keys(after.files)])].sort()) {
7
+ const a=before.files[file],b=after.files[file];if(a?.hash===b?.hash)continue;
8
+ const metadata={file,change:!a?'add':!b?'delete':'modify',beforeHash:a?.hash??null,afterHash:b?.hash??null,
9
+ generated:!!(a?.generated||b?.generated)};
10
+ if(a?.hidden||b?.hidden||a?.text===null||b?.text===null)files.push({opaque:true,metadata:{...metadata,
11
+ format:'opaque',kind:b?.kind??a?.kind??'opaque',bytes:b?.bytes??0,
12
+ note:'Binary, linked or sensitive content withheld. Hashes are not correctness evidence; request safe checks, never credentials.'}});
13
+ else files.push({metadata,oldText:a?.text??'',newText:b?.text??''});
14
+ }
15
+ if(!files.length)return {version:2,changed:[]};
16
+ return new Promise((resolve,reject)=>{
17
+ const worker=new Worker(new URL('./change-set-worker.mjs',import.meta.url),{workerData:{files,computeMs}});
18
+ let settled=false;
19
+ const finish=async(error,value)=>{
20
+ if(settled)return;settled=true;signal?.removeEventListener('abort',cancel);
21
+ try{await worker.terminate();}catch(e){error??=e;}
22
+ error?reject(error):resolve(value);
23
+ };
24
+ const cancel=()=>finish(signal.reason??new Error('Change comparison cancelled'));
25
+ worker.once('message',value=>finish(null,value));worker.once('error',error=>finish(error));
26
+ worker.once('exit',code=>{if(!settled)finish(new Error(`Change comparison exited before result (${code})`));});
27
+ signal?.addEventListener('abort',cancel,{once:true});if(signal?.aborted)cancel();
28
+ });
29
+ }
@@ -3,6 +3,7 @@ import { mkdirSync, readFileSync, writeFileSync, renameSync, existsSync, openSyn
3
3
  import path from 'node:path';
4
4
  import { randomUUID } from 'node:crypto';
5
5
  import { snapshot, delta, hash, initializeProject } from './snapshot.mjs';
6
+ import {changeSet} from './change-set.mjs';
6
7
  import { runWorker, validateResult, runProcess, requireSubscription } from './workers.mjs';
7
8
  import { decide } from './decision.mjs';
8
9
  import { design, beginDesign, assertDesign, designPending, pendingRequests } from './design.mjs';
@@ -141,7 +142,7 @@ export class Controller {
141
142
  const designState = beginDesign(this,input,previous);
142
143
  initializeProject(this.directory);
143
144
  const mode = designState.designMode === 'new' && input.mode === 'cosmetic' ? 'small' : input.mode;
144
- const state = { id: randomUUID(), startedAt:new Date().toISOString(), mode, brief: input.brief, phase: mode === 'feature' ? 'plan' : 'implement', ...designState,
145
+ const state = { id: randomUUID(), evidenceVersion:2, startedAt:new Date().toISOString(), mode, brief: input.brief, phase: mode === 'feature' ? 'plan' : 'implement', ...designState,
145
146
  reviewerSettings: this.config.reviewers ? {reviewers:structuredClone(this.config.reviewers),designAuthor:lead(this.config),codex:this.config.codex,claude:this.config.claude} : null,
146
147
  baseline: snapshot(this.directory), calls: 0, corrections: 0, rounds: 0, reports: [], plan: '' };
147
148
  this.save(state);this.trace=new RunTrace(this.folder,state.id,'begin'); return this.status();
@@ -193,8 +194,8 @@ export class Controller {
193
194
  sourceChars:Object.values(tree.files).reduce((sum,file)=>sum+(typeof file.text==='string'?file.text.length:0),0)});
194
195
  }catch(error){evidenceSpan?.end({status:'failed'});throw error;}
195
196
  const transport = evidence.mode === 'file-backed'
196
- ? 'Evidence is FILE-BACKED because it is too large to inline. FIRST read evidence/index.json. Read the packet sections relevant to the assigned scope, including requirements, prior findings and verification evidence; for focused follow-up read followup first and retain earlier coverage for unchanged work. Follow every $evidenceText reference to its raw text. For changes read evidence/changes/index.json and each listed change and its before/after text, including deletions. On follow-up these are the changes since the previous completed review; milestoneFiles identifies the original scope. Use evidence/source-index.json to read affected current files and relevant dependencies under source/. Read long files in ranges until required content is covered; a truncated tool response is not complete evidence. Where readableChunks is present, use that JSONL instead of a truncated long raw line: concatenate text values in offset order to recover the exact original text (chunk boundaries are NOT original newlines). The full original packet is also in packet.json, but section files avoid one huge read. Do not approve solely from the index, hashes, another model report or the implementer summary. State what you inspected and any coverage gap; missing material evidence blocks approval. Do not request scope splitting merely because the inline threshold was reached.'
197
- : 'The packet and handwritten non-secret text source are provided below. Review this supplied evidence directly; shell access is not required. Generated lockfiles are inventoried separately; changed spans are included verbatim, unchanged bodies are not repeated. If omitted context is necessary for a dependency judgment, inspect source/ or mark that judgment blocked; never assume omitted evidence passed review.';
197
+ ? 'Evidence is FILE-BACKED because it is too large to inline. FIRST read evidence/index.json. Read the packet sections relevant to the assigned scope, including requirements, prior findings and verification evidence; for focused follow-up read followup first and retain earlier coverage for unchanged work. Follow every $evidenceText reference to its raw text. For changes read evidence/changes/index.json and each listed change: read every exact hunk or complete before/after fallback, including deletions. On follow-up these are the changes since the previous completed review; milestoneFiles identifies the original scope. Use evidence/source-index.json to read affected current files and relevant dependencies under source/. Read long files in ranges until required content is covered; a truncated tool response is not complete evidence. Where readableChunks is present, use that JSONL instead of a truncated long raw line: concatenate text values in offset order to recover the exact original text (chunk boundaries are NOT original newlines). The full original packet is also in packet.json, but section files avoid one huge read. Do not approve solely from the index, hashes, another model report or the implementer summary. State what you inspected and any coverage gap; missing material evidence blocks approval. Do not request scope splitting merely because the inline threshold was reached.'
198
+ : 'The packet and handwritten non-secret text source are provided below. For evidenceVersion 2, resolve each {$text: id} from texts[id]; shared bodies are exact, not summaries. Read every hunk or complete-text fallback. Review this supplied evidence directly; shell access is not required. Generated lockfiles are inventoried separately; changed spans are included verbatim, unchanged bodies are not repeated. If omitted context is necessary for a dependency judgment, inspect source/ or mark that judgment blocked; never assume omitted evidence passed review.';
198
199
  const instructions = `${RULES}\nStage: ${stage}. Agent: ${who}. ${transport}\n` +
199
200
  (stage === 'design-author' ? 'You are Claude, the sole UI/UX design author. Apply the supplied frontend-design and ui-ux-pro-max skills and actual research outputs. Return the COMPLETE implementable design document in report, or concise direction for a small task. Specify hierarchy, user flows, layouts, tokens/palette, typography, components, responsive behavior, interaction/error/loading/empty states, accessibility, motion, rationale and acceptance checks. Preserve supplied constraints; never delegate design decisions to the implementation model. Fetch current web-design-guidelines with WebFetch. Your author verdict does not approve the design; both models validate next.' :
200
201
  stage === 'design-validate' ? 'Validate ONLY this exact Claude-authored UI/UX design and its artifactHash against user requirements, provided references and design skills. Astra reviews usability/accessibility/consistency and completeness; Claude retains aesthetic ownership. Do not substitute taste for a defect. Verify earlier medium/high/critical findings, never accept claims of fixes without evidence. Return structured findings for this version. This is a document review, not a claim that the unbuilt UI was visually tested.' :
@@ -323,12 +324,16 @@ export class Controller {
323
324
  }
324
325
  const missing = missingResolutions(state.reviewFeedback, resolutions);
325
326
  if (missing.length) return { ...this.status(), missingResolutions: missing, message: 'Complete this consolidated checklist before re-review. No premium calls made; corrections and evidence collection remain allowed.' };
326
- const followup = followupContext(state, current, images);
327
+ // Tasks already in progress keep their packet representation and receipt key.
328
+ const v2=state.evidenceVersion===2;
329
+ const followup = followupContext(state, current, images, v2?{changed:[]}:undefined);
330
+ const exactChanges=v2?await changeSet(followup?state.measureFrom:state.baseline,current,{signal}):followup?.changesSinceReview??changes;
331
+ if(v2&&followup){followup.kind=exactChanges.changed.length?'focused-correction':'evidence-follow-up';delete followup.changesSinceReview;followup.changesReference='packet.changes';}
327
332
  this.checkpoint(state, 'review');
328
333
  const evidenceDigest = hash(JSON.stringify([checks, state.checks ?? [], state.recoveries ?? [], images.map(i=>i.manifest), resolutions ?? null]));
329
334
  if (state.lastReviewFingerprint === current.fingerprint && state.lastReviewChecks === evidenceDigest && ['fix', 'review'].includes(state.phase)) throw new Error('No code or evidence changed since review. Address the focused findings before spending another review pair.');
330
335
  state.phase = 'review'; state.reviewAttempt={id:randomUUID(),artifactHash:current.fingerprint,completed:false}; this.save(state);
331
- const packet = { artifactHash: current.fingerprint, brief: state.brief, plan: state.plan, design: state.designPath ? readFileSync(state.designPath,'utf8') : null, designEvidence: state.designEvidence ?? null, designMode: state.designMode, planAdvisories: this.planAdvisories(state), changes: followup?.changesSinceReview ?? changes, milestoneFiles: changes.changed.map(c=>c.file), followup, resolutions: resolutions ?? [], humanResolutions: state.recoveries ?? [], checks: { suppliedByImplementer: checks, independentlyVerified: false, bridgeRuns: state.checks ?? [] },
336
+ const packet = { ...(v2?{evidenceVersion:2}:{}),artifactHash: current.fingerprint, brief: state.brief, plan: state.plan, design: state.designPath ? readFileSync(state.designPath,'utf8') : null, designEvidence: state.designEvidence ?? null, designMode: state.designMode, planAdvisories: this.planAdvisories(state), changes: exactChanges, milestoneFiles: changes.changed.map(c=>c.file), followup, resolutions: resolutions ?? [], humanResolutions: state.recoveries ?? [], checks: { suppliedByImplementer: checks, independentlyVerified: false, bridgeRuns: state.checks ?? [] },
332
337
  priorFindings: state.reviewFeedback ?? [], visualEvidence: images.map(i=>i.manifest),
333
338
  focus: 'Review the completed functional milestone and its dependencies. Scale depth to actual complexity and risk, never line count. Keep outstanding future work separate; do not approve missing work required for this milestone or claim project completion.' };
334
339
  const [astra,opus] = await this.pair(state,'review',packet,signal,images,current);
@@ -0,0 +1,63 @@
1
+ import {mkdirSync,writeFileSync} from 'node:fs';
2
+ import path from 'node:path';
3
+ import {hash} from './snapshot.mjs';
4
+
5
+ // Preserve the entire captured source set. Deduplication changes representation,
6
+ // never coverage. Legacy packet.json/source paths remain readable for recovery.
7
+ export function prepareEvidenceV2(folder,packet,tree,inlineChars) {
8
+ const bodies=Object.create(null),source=Object.create(null),inventory=[],rawRefs=new Map();
9
+ const save=(name,text)=>{const target=path.join(folder,name);mkdirSync(path.dirname(target),{recursive:true});writeFileSync(target,text);return {path:name,chars:text.length,sha256:hash(text)};};
10
+ const json=(name,value)=>save(name,JSON.stringify(value,null,2));
11
+ const readable=(text,name)=>{
12
+ const key=hash(text);if(rawRefs.has(key))return rawRefs.get(key);
13
+ const ref=save(name,text);rawRefs.set(key,ref);
14
+ if(text.split('\n').some(line=>line.length>1000)) {
15
+ const chunks=[];for(let offset=0;offset<text.length;offset+=200)chunks.push(JSON.stringify({offset,text:text.slice(offset,offset+200)}));
16
+ ref.readableChunks=`evidence/chunks/${key}.jsonl`;save(ref.readableChunks,chunks.join('\n')+'\n');
17
+ }
18
+ return ref;
19
+ };
20
+ const textRef=text=>{const key=hash(text);bodies[key]=text;return {$text:key};};
21
+ for(const [name,file] of Object.entries(tree.files)) {
22
+ if(file.text===null||file.hidden) {inventory.push({file:name,path:null,kind:file.kind,sha256:file.hash,
23
+ evidence:'Content withheld: binary, link or sensitive. Metadata is not correctness evidence.'});continue;}
24
+ // snapshot already validates names; defend this exported transport too.
25
+ const target=path.resolve(folder,'source',name),base=path.resolve(folder,'source')+path.sep;
26
+ if(!target.startsWith(base)||name.includes('\\'))throw Error('Invalid captured source path');
27
+ const ref=readable(file.text,`source/${name}`);
28
+ if(ref.path!==`source/${name}`)save(`source/${name}`,file.text); // Compatibility alias, not a second indexed body.
29
+ inventory.push({file:name,...ref,generated:!!file.generated});
30
+ if(!file.generated)source[name]=textRef(file.text);
31
+ }
32
+ const intern=value=>{
33
+ if(typeof value==='string'&&(value.length>1000||Object.hasOwn(bodies,hash(value))))return textRef(value);
34
+ if(Array.isArray(value))return value.map(intern);
35
+ if(value&&typeof value==='object')return Object.fromEntries(Object.entries(value).map(([key,v])=>[key,intern(v)]));
36
+ return value;
37
+ };
38
+ json('packet.json',packet);
39
+ const encoded=intern(packet);
40
+ const inline=JSON.stringify({evidenceVersion:2,encoding:'Resolve every {$text: id} from texts[id]; bodies are exact and shared, not summaries.',
41
+ packet:encoded,source,texts:bodies,generatedInventory:inventory.filter(f=>f.generated),opaqueInventory:inventory.filter(f=>f.path===null)});
42
+ if(inline.length<=inlineChars)return {mode:'inline',text:inline};
43
+ let next=0;
44
+ const externalize=value=>{
45
+ if(typeof value==='string'&&(value.length>1000||value.includes('\n')||rawRefs.has(hash(value))))
46
+ return {$evidenceText:readable(value,`evidence/text/${next++}.txt`)};
47
+ if(Array.isArray(value))return value.map(externalize);
48
+ if(value&&typeof value==='object')return Object.fromEntries(Object.entries(value).map(([key,v])=>[key,externalize(v)]));
49
+ return value;
50
+ };
51
+ const sections=[];
52
+ for(const [key,value] of Object.entries(packet)) {
53
+ if(value===undefined)continue;
54
+ if(key==='changes') {
55
+ const changes=value.changed.map((change,i)=>({file:change.file,...json(`evidence/changes/${i}.json`,externalize(change))}));
56
+ sections.push({field:key,...json('evidence/changes/index.json',{version:2,changes})});
57
+ } else sections.push({field:key,...json(`evidence/sections/${sections.length}.json`,externalize(value))});
58
+ }
59
+ const index={evidenceVersion:2,transport:'file-backed',artifactHash:packet.artifactHash??null,
60
+ sourceFingerprint:tree.fingerprint,packet:'packet.json',sections,source:json('evidence/source-index.json',inventory)};
61
+ json('evidence/index.json',index);
62
+ return {mode:'file-backed',text:JSON.stringify({transport:'file-backed',evidenceVersion:2,index:'evidence/index.json',artifactHash:index.artifactHash,sourceFingerprint:tree.fingerprint})};
63
+ }
package/core/evidence.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import { mkdirSync, writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { hash } from './snapshot.mjs';
4
+ import {prepareEvidenceV2} from './evidence-v2.mjs';
4
5
 
5
6
  // Size chooses transport, never whether a review is allowed. All content stays
6
7
  // in the captured workspace; no model-generated summary replaces evidence.
7
8
  export function prepareEvidence(folder, packet, tree, inlineChars = 400000) {
9
+ if(packet.evidenceVersion===2)return prepareEvidenceV2(folder,packet,tree,inlineChars);
8
10
  let textID = 0;
9
11
  const readableText = (text, name) => {
10
12
  const target = path.join(folder, name);
@@ -19,12 +19,12 @@ export function reviewContract(state) {
19
19
  state.designEvidence, state.recoveries]));
20
20
  }
21
21
 
22
- export function followupContext(state, current, images) {
22
+ export function followupContext(state, current, images, suppliedChanges) {
23
23
  const previous = state.reviewCoverage;
24
24
  if (!previous || previous.contract !== reviewContract(state) || !state.measureFrom ||
25
25
  previous.artifactHash !== state.measureFrom.fingerprint || state.reviewFeedback?.length !== (state.reviewerSettings?lanes(state.reviewerSettings).length:2)) return null;
26
26
  const oldImages = new Set(previous.images.map(i => i.sha256));
27
- const changes = delta(state.measureFrom, current);
27
+ const changes = suppliedChanges ?? delta(state.measureFrom, current);
28
28
  return { kind: changes.changed.length ? 'focused-correction' : 'evidence-follow-up',
29
29
  previousArtifactHash: previous.artifactHash, previousReports: state.reviewFeedback,
30
30
  changesSinceReview: changes, requiredFindings: blockingChecklist(state.reviewFeedback),
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release notes
2
2
 
3
+ ## 0.3.3-beta.3
4
+
5
+ - Show separate exact hunks for distant edits instead of sending all the unchanged text between them.
6
+ - Share repeated source bodies in review evidence while retaining full source, findings and contract context.
7
+ - Run diff computation outside the host thread; difficult comparisons retain complete text and cancellation remains available.
8
+
9
+ New tasks use the new evidence format. Tasks already in progress retain their existing format and history.
10
+
3
11
  ## 0.3.3-beta.2
4
12
 
5
13
  - View workflow measurements in **Hybrid Workflow settings → Run diagnostics**: observed checkpoint time, reviewer usage, and completed-task elapsed time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockysoft/opencode-hybrid-workflow",
3
- "version": "0.3.3-beta.2",
3
+ "version": "0.3.3-beta.3",
4
4
  "description": "Portable configurable-reviewer planning, design, implementation checkpoints and usage sidebar for OpenCode 2",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -69,5 +69,8 @@
69
69
  "solid-js": {
70
70
  "optional": true
71
71
  }
72
+ },
73
+ "dependencies": {
74
+ "diff": "9.0.0"
72
75
  }
73
76
  }