self-evolving-workflow 0.0.0-stage → 0.1.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.
Files changed (173) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +90 -2
  3. package/dist/agent-memory-prompts.d.ts +13 -0
  4. package/dist/agent-memory-prompts.js +55 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +6 -0
  7. package/dist/closeout.d.ts +105 -0
  8. package/dist/closeout.js +479 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/common.d.ts +9 -0
  12. package/dist/common.js +42 -0
  13. package/dist/context-envelope.d.ts +59 -0
  14. package/dist/context-envelope.js +23 -0
  15. package/dist/host-adapters.d.ts +34 -0
  16. package/dist/host-adapters.js +151 -0
  17. package/dist/http.d.ts +3 -0
  18. package/dist/http.js +90 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.js +13 -0
  21. package/dist/knowledge-cli.d.ts +183 -0
  22. package/dist/knowledge-cli.js +654 -0
  23. package/dist/knowledge-reads.d.ts +71 -0
  24. package/dist/knowledge-reads.js +193 -0
  25. package/dist/memory.d.ts +97 -0
  26. package/dist/memory.js +250 -0
  27. package/dist/retrospective.d.ts +57 -0
  28. package/dist/retrospective.js +248 -0
  29. package/dist/search.d.ts +36 -0
  30. package/dist/search.js +112 -0
  31. package/dist/skill-addition.d.ts +25 -0
  32. package/dist/skill-addition.js +89 -0
  33. package/dist/skill-design.d.ts +96 -0
  34. package/dist/skill-design.js +226 -0
  35. package/dist/skill-replay.d.ts +55 -0
  36. package/dist/skill-replay.js +451 -0
  37. package/dist/skill-route.d.ts +30 -0
  38. package/dist/skill-route.js +75 -0
  39. package/dist/transcript-evidence.d.ts +3 -0
  40. package/dist/transcript-evidence.js +58 -0
  41. package/dist/upstream/chunker.d.ts +24 -0
  42. package/dist/upstream/chunker.js +96 -0
  43. package/dist/upstream/file-protocol.d.ts +45 -0
  44. package/dist/upstream/file-protocol.js +117 -0
  45. package/dist/upstream/frontmatter.d.ts +47 -0
  46. package/dist/upstream/frontmatter.js +86 -0
  47. package/dist/upstream/graph-search.d.ts +33 -0
  48. package/dist/upstream/graph-search.js +67 -0
  49. package/dist/upstream/l1-extraction.d.ts +26 -0
  50. package/dist/upstream/l1-extraction.js +405 -0
  51. package/dist/upstream/llm.d.ts +8 -0
  52. package/dist/upstream/llm.js +1 -0
  53. package/dist/upstream/merge.d.ts +50 -0
  54. package/dist/upstream/merge.js +153 -0
  55. package/dist/upstream/prompts.d.ts +53 -0
  56. package/dist/upstream/prompts.js +185 -0
  57. package/dist/upstream/search-utils.d.ts +34 -0
  58. package/dist/upstream/search-utils.js +55 -0
  59. package/dist/upstream/slug.d.ts +26 -0
  60. package/dist/upstream/slug.js +103 -0
  61. package/dist/upstream/template.d.ts +29 -0
  62. package/dist/upstream/template.js +80 -0
  63. package/dist/upstream/tokenize.d.ts +4 -0
  64. package/dist/upstream/tokenize.js +29 -0
  65. package/dist/wiki-change.d.ts +76 -0
  66. package/dist/wiki-change.js +299 -0
  67. package/dist/wiki-entry.d.ts +26 -0
  68. package/dist/wiki-entry.js +93 -0
  69. package/dist/wiki-ingest.d.ts +12 -0
  70. package/dist/wiki-ingest.js +126 -0
  71. package/dist/wiki-migration.d.ts +16 -0
  72. package/dist/wiki-migration.js +268 -0
  73. package/dist/wiki-tokens.d.ts +1 -0
  74. package/dist/wiki-tokens.js +46 -0
  75. package/dist/wiki.d.ts +103 -0
  76. package/dist/wiki.js +330 -0
  77. package/dist/workflow-cli.d.ts +2 -0
  78. package/dist/workflow-cli.js +258 -0
  79. package/dist/workflow-install.d.ts +36 -0
  80. package/dist/workflow-install.js +148 -0
  81. package/dist/workflow-knowledge.d.ts +16 -0
  82. package/dist/workflow-knowledge.js +24 -0
  83. package/dist/workflow-mcp.d.ts +2 -0
  84. package/dist/workflow-mcp.js +144 -0
  85. package/dist/workflow-names.d.ts +4 -0
  86. package/dist/workflow-names.js +18 -0
  87. package/dist/workflow-runtime.d.ts +622 -0
  88. package/dist/workflow-runtime.js +627 -0
  89. package/dist/workflow-skills.d.ts +48 -0
  90. package/dist/workflow-skills.js +141 -0
  91. package/package.json +76 -4
  92. package/skills/ew-odyssey/SKILL.md +237 -0
  93. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  94. package/skills/ew-odyssey/references/odyssey-base-codex.md +3 -0
  95. package/skills/ew-odyssey/references/odyssey-base.md +278 -0
  96. package/skills/ew-odyssey/references/odyssey-debug.codex.md +305 -0
  97. package/skills/ew-odyssey/references/odyssey-debug.md +283 -0
  98. package/skills/ew-odyssey/references/odyssey-defensive.codex.md +395 -0
  99. package/skills/ew-odyssey/references/odyssey-defensive.md +369 -0
  100. package/skills/ew-odyssey/references/odyssey-improve.codex.md +270 -0
  101. package/skills/ew-odyssey/references/odyssey-improve.md +248 -0
  102. package/skills/ew-odyssey/references/odyssey-planex.codex.md +352 -0
  103. package/skills/ew-odyssey/references/odyssey-planex.md +312 -0
  104. package/skills/ew-odyssey/references/odyssey-review.codex.md +283 -0
  105. package/skills/ew-odyssey/references/odyssey-review.md +251 -0
  106. package/skills/ew-odyssey/references/odyssey-security.md +249 -0
  107. package/skills/ew-odyssey/references/odyssey-ui.codex.md +294 -0
  108. package/skills/ew-odyssey/references/odyssey-ui.md +250 -0
  109. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +105 -0
  110. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +121 -0
  111. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +93 -0
  112. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +104 -0
  113. package/skills/ew-odyssey/references/prepare/odyssey-review.md +98 -0
  114. package/skills/ew-odyssey/references/prepare/odyssey-security.md +94 -0
  115. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +87 -0
  116. package/skills/ew-orchestrate/SKILL.md +236 -0
  117. package/skills/ew-orchestrate/references/auto-policy.md +165 -0
  118. package/skills/ew-orchestrate/references/companion-route.md +52 -0
  119. package/skills/ew-orchestrate/references/ew-orchestrate.md +27 -0
  120. package/skills/ew-orchestrate/references/goal.md +53 -0
  121. package/skills/ew-orchestrate/references/knowledge-route.md +163 -0
  122. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +36 -0
  123. package/skills/ew-orchestrate/references/planning.md +137 -0
  124. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +62 -0
  125. package/skills/ew-orchestrate/steps/ew-analyze/references/boundary-grill.md +50 -0
  126. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +59 -0
  127. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +42 -0
  128. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +401 -0
  129. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +32 -0
  130. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +9 -0
  131. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +71 -0
  132. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +69 -0
  133. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +373 -0
  134. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +102 -0
  135. package/skills/ew-orchestrate/steps/ew-plan/references/boundary-grill.md +50 -0
  136. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +51 -0
  137. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  138. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +278 -0
  139. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +44 -0
  140. package/skills/ew-orchestrate/steps/ew-review/references/odyssey-base-codex.md +3 -0
  141. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +76 -0
  142. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +283 -0
  143. package/skills/ew-skill-design/SKILL.md +28 -0
  144. package/skills/ew-skill-design/references/package-contract.md +28 -0
  145. package/skills/ew-skill-design/references/validation.md +7 -0
  146. package/skills/team-swarm/SKILL.md +231 -0
  147. package/skills/team-swarm/references/mcp-coordination.md +10 -0
  148. package/skills/team-swarm/roles/analyst/role.md +181 -0
  149. package/skills/team-swarm/roles/ant/role.md +149 -0
  150. package/skills/team-swarm/roles/coordinator/commands/converge.md +154 -0
  151. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +134 -0
  152. package/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
  153. package/skills/team-swarm/roles/coordinator/role.md +228 -0
  154. package/skills/team-swarm/roles/scorer/role.md +150 -0
  155. package/skills/team-swarm/scripts/aco.py +646 -0
  156. package/skills/team-swarm/scripts/pheromone.py +144 -0
  157. package/skills/team-swarm/scripts/scoring.py +111 -0
  158. package/skills/team-swarm/scripts/test_aco.py +606 -0
  159. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  160. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  161. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  162. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  163. package/skills/team-swarm/specs/swarm-protocol.md +123 -0
  164. package/skills/workflow-closeout/SKILL.md +10 -0
  165. package/skills/workflow-evolve/SKILL.md +79 -0
  166. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  167. package/skills/workflow-evolve/references/auto-loop.md +20 -0
  168. package/skills/workflow-evolve/references/history-review.md +14 -0
  169. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +76 -0
  170. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  171. package/skills/workflow-evolve/scripts/evolve-loop.mjs +259 -0
  172. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  173. package/workflows/index.json +23 -0
@@ -0,0 +1,48 @@
1
+ export interface ArtifactType {
2
+ kind: string;
3
+ schema: string;
4
+ role: string;
5
+ alias?: string;
6
+ }
7
+ export interface OutputSlot extends ArtifactType {
8
+ path: string;
9
+ required?: boolean;
10
+ }
11
+ export interface InputSlot extends ArtifactType {
12
+ required?: boolean;
13
+ accepts_negative_evidence?: boolean;
14
+ }
15
+ export interface WorkflowSkill {
16
+ skill_id: string;
17
+ commit: string;
18
+ tree: string;
19
+ package_path: string;
20
+ entry: string;
21
+ required_links: string[];
22
+ consumes: InputSlot[];
23
+ produces: OutputSlot[];
24
+ gates: {
25
+ entry: string[];
26
+ exit: string[];
27
+ };
28
+ }
29
+ export declare const commandNames: string[];
30
+ export declare function workflowHash(bytes: Buffer | string): string;
31
+ export declare function workflowHead(root: string): string;
32
+ export declare function workflowPath(value: string, extension?: string): string;
33
+ export declare function workflowBlob(root: string, commit: string, path: string): NonSharedBuffer;
34
+ export declare function workflowHeader(text: string): Record<string, unknown>;
35
+ export declare function workflowRecord(value: unknown, label: string): Record<string, unknown>;
36
+ export declare function workflowStrings(value: unknown, label: string): string[];
37
+ export declare function workflowMeta(value: unknown): ArtifactType;
38
+ export declare function readWorkflowMarkdown(root: string, skill: WorkflowSkill, path: string): {
39
+ path: string;
40
+ markdown: string;
41
+ sha256: string;
42
+ };
43
+ export declare function readWorkflowLink(root: string, skill: WorkflowSkill, from: string, destination: string): {
44
+ path: string;
45
+ markdown: string;
46
+ sha256: string;
47
+ };
48
+ export declare function bindWorkflowSkill(root: string, command: string, commit?: string): WorkflowSkill;
@@ -0,0 +1,141 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { posix } from 'node:path';
4
+ import { parse } from 'yaml';
5
+ import { InputError, requireText } from './common.js';
6
+ import { historicalWorkflowName, odysseyModes, orchestrationSteps, workflowName } from './workflow-names.js';
7
+ const internal = new Set(orchestrationSteps.map(workflowName));
8
+ const odyssey = new Map(odysseyModes.map(mode => ['ew-odyssey-' + mode, mode]));
9
+ export const commandNames = [
10
+ ...internal, ...odyssey.keys(), 'team-swarm',
11
+ ];
12
+ export function workflowHash(bytes) {
13
+ return 'sha256:' + createHash('sha256').update(bytes).digest('hex');
14
+ }
15
+ function git(root, ...args) {
16
+ try {
17
+ return execFileSync('git', args, { cwd: root, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
18
+ }
19
+ catch (error) {
20
+ throw new InputError('Git could not read the workflow revision or path: ' + args.slice(1).join(' '), { cause: error });
21
+ }
22
+ }
23
+ export function workflowHead(root) {
24
+ return git(root, 'rev-parse', 'HEAD^{commit}').toString().trim();
25
+ }
26
+ export function workflowPath(value, extension) {
27
+ if (!value || /[\\:\u0000-\u001f*?[\]]/.test(value) || value.split('/').some(part => !part || part === '.' || part === '..') ||
28
+ (extension && !value.toLowerCase().endsWith(extension))) {
29
+ throw new InputError('Invalid workflow path: ' + value);
30
+ }
31
+ return value;
32
+ }
33
+ function findTreeMember(root, commit, path) {
34
+ workflowPath(path);
35
+ const record = git(root, 'ls-tree', '-z', commit, '--', path).toString();
36
+ if (!record)
37
+ return;
38
+ const match = /^(100644|100755|040000) (blob|tree) ([0-9a-f]{40}|[0-9a-f]{64})\t([^\0]+)\0$/.exec(record);
39
+ if (!match || match[4] !== path)
40
+ throw new InputError('Workflow path is unavailable or is not a regular entry: ' + path);
41
+ return { type: match[2], object: match[3] };
42
+ }
43
+ function treeMember(root, commit, path) {
44
+ const member = findTreeMember(root, commit, path);
45
+ if (!member)
46
+ throw new InputError('Workflow path is unavailable: ' + path);
47
+ return member;
48
+ }
49
+ export function workflowBlob(root, commit, path) {
50
+ const member = treeMember(root, commit, path);
51
+ if (member.type !== 'blob')
52
+ throw new InputError('Expected a regular workflow file: ' + path);
53
+ return git(root, 'cat-file', 'blob', member.object);
54
+ }
55
+ export function workflowHeader(text) {
56
+ const header = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text.replace(/^\uFEFF/, ''));
57
+ if (!header)
58
+ return {};
59
+ return workflowRecord(parse(header[1]), 'YAML frontmatter');
60
+ }
61
+ export function workflowRecord(value, label) {
62
+ if (!value || typeof value !== 'object' || Array.isArray(value))
63
+ throw new InputError('Invalid ' + label);
64
+ return value;
65
+ }
66
+ export function workflowStrings(value, label) {
67
+ if (!Array.isArray(value))
68
+ throw new InputError(label + ' must be an array');
69
+ return value.map(item => requireText(item, label));
70
+ }
71
+ export function workflowMeta(value) {
72
+ const item = workflowRecord(value, 'artifact metadata');
73
+ return {
74
+ kind: requireText(item.kind, 'artifact kind'), schema: requireText(item.schema, 'artifact schema'),
75
+ role: requireText(item.role, 'artifact role'),
76
+ ...(item.alias === undefined ? {} : { alias: requireText(item.alias, 'artifact alias') }),
77
+ };
78
+ }
79
+ function linkPath(from, destination) {
80
+ const path = decodeURI(destination.split('#', 1)[0]);
81
+ if (!path || path.startsWith('/') || /[\\:]/.test(path))
82
+ throw new InputError('Use a package-relative Markdown link');
83
+ return workflowPath(posix.join(posix.dirname(from), path), '.md');
84
+ }
85
+ export function readWorkflowMarkdown(root, skill, path) {
86
+ const bytes = workflowBlob(root, skill.commit, skill.package_path + '/' + workflowPath(path, '.md'));
87
+ return { path, markdown: bytes.toString('utf8'), sha256: workflowHash(bytes) };
88
+ }
89
+ export function readWorkflowLink(root, skill, from, destination) {
90
+ const source = readWorkflowMarkdown(root, skill, from);
91
+ const links = [...source.markdown.matchAll(/\[[^\]]*\]\(\s*(<[^>]+>|[^\s)]+)/g)]
92
+ .map(match => match[1].replace(/^<|>$/g, ''));
93
+ if (!links.includes(destination))
94
+ throw new InputError('Select a declared Markdown link from ' + from);
95
+ return readWorkflowMarkdown(root, skill, linkPath(from, destination));
96
+ }
97
+ export function bindWorkflowSkill(root, command, commit = workflowHead(root)) {
98
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(command) || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(commit)) {
99
+ throw new InputError('Invalid Skill command or Git commit');
100
+ }
101
+ const name = workflowName(command);
102
+ const mode = odyssey.get(name);
103
+ const expectedId = mode ? 'ew-odyssey' : name;
104
+ const isStep = internal.has(name);
105
+ let packagePath = isStep ? 'skills/ew-orchestrate/steps/' + name : 'skills/' + expectedId;
106
+ let tree = findTreeMember(root, commit, packagePath);
107
+ const oldName = historicalWorkflowName(expectedId);
108
+ if (!tree && oldName) {
109
+ packagePath = isStep ? 'skills/maestro/steps/' + oldName : 'skills/' + oldName;
110
+ tree = findTreeMember(root, commit, packagePath);
111
+ }
112
+ if (tree?.type !== 'tree')
113
+ throw new InputError('Workflow package is unavailable: ' + packagePath);
114
+ const entry = 'SKILL.md';
115
+ const header = workflowHeader(workflowBlob(root, commit, packagePath + '/' + entry).toString('utf8'));
116
+ const skillId = requireText(header.name, 'Skill name');
117
+ if (workflowName(skillId) !== expectedId)
118
+ throw new InputError('Skill name does not match ' + name);
119
+ const preparation = mode ? 'references/prepare/odyssey-' + mode + '.md' : undefined;
120
+ const modeHeader = preparation ? workflowHeader(workflowBlob(root, commit, packagePath + '/' + preparation).toString('utf8')) : undefined;
121
+ const contract = workflowRecord(modeHeader?.contract ?? header.contract ?? {}, 'Skill contract');
122
+ const links = preparation ? [preparation, ...workflowStrings(modeHeader?.required_links ?? [], 'required_links')]
123
+ : workflowStrings(header.required_links ?? [], 'required_links');
124
+ const gates = workflowRecord(contract.gates ?? {}, 'Skill gates');
125
+ const consumes = Array.isArray(contract.consumes) ? contract.consumes.map(value => ({
126
+ ...workflowMeta(value), required: value.required === true, accepts_negative_evidence: value.accepts_negative_evidence === true,
127
+ })) : [];
128
+ const produces = Array.isArray(contract.produces) ? contract.produces.map(value => ({
129
+ ...workflowMeta(value), path: workflowPath(requireText(value.path, 'output path')), required: value.required === true,
130
+ })) : [];
131
+ if (produces.some(item => !item.path.startsWith('outputs/')))
132
+ throw new InputError('Skill output slots belong under outputs/');
133
+ const skill = {
134
+ skill_id: skillId, commit, tree: tree.object, package_path: packagePath, entry,
135
+ required_links: [entry, ...links.map(link => linkPath(entry, link))],
136
+ consumes, produces, gates: { entry: workflowStrings(gates.entry ?? [], 'entry gates'), exit: workflowStrings(gates.exit ?? [], 'exit gates') },
137
+ };
138
+ for (const link of links)
139
+ readWorkflowLink(root, skill, entry, link);
140
+ return skill;
141
+ }
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "self-evolving-workflow",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "Self-Evolving Workflow with a local code graph, a Markdown wiki, and agent memory search",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/catlog22/self-evolving-workflow.git"
8
+ },
9
+ "license": "MIT",
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=22.16.0"
13
+ },
14
+ "bin": {
15
+ "agent-memory": "./dist/cli.js",
16
+ "evolve": "./dist/workflow-cli.js"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./code": {
24
+ "types": "./dist/code.d.ts",
25
+ "default": "./dist/code.js"
26
+ },
27
+ "./wiki": {
28
+ "types": "./dist/wiki.d.ts",
29
+ "default": "./dist/wiki.js"
30
+ },
31
+ "./memory": {
32
+ "types": "./dist/memory.d.ts",
33
+ "default": "./dist/memory.js"
34
+ },
35
+ "./http": {
36
+ "types": "./dist/http.d.ts",
37
+ "default": "./dist/http.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "skills",
43
+ "workflows",
44
+ "LICENSE"
45
+ ],
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.json",
48
+ "setup": "npm run build && npm link && node dist/workflow-cli.js install",
49
+ "test": "npm run build && node --test test/*.test.mjs",
50
+ "test:codex-replay": "npm run build && node test/codex-replay.mjs",
51
+ "test:codex-replay-contract": "npm run build && node test/codex-replay-contract.mjs",
52
+ "test:codex-evolve": "npm run build && node test/codex-evolve-native.mjs",
53
+ "test:legacy-codex-evolve": "npm run build && node test/maestro-closeout.mjs --codex-evolve",
54
+ "test:legacy-codex-standalone": "npm run build && node test/codex-standalone.mjs",
55
+ "test:codex-workflow": "npm run build && node test/codex-workflow.mjs",
56
+ "test:codex-chain": "npm run build && node test/codex-workflow.mjs chain",
57
+ "test:codex-campaigns": "npm run build && node test/codex-workflow.mjs odyssey swarm",
58
+ "test:legacy-codex-chain": "node test/codex-chain.mjs",
59
+ "test:legacy-codex-campaigns": "node test/codex-campaigns.mjs",
60
+ "test:release-gate-flow": "npm run build && node test/release-gate-flow.mjs",
61
+ "test:ew-layout": "node test/ew-layout.mjs",
62
+ "test:legacy-closeout": "npm run build && node test/maestro-closeout.mjs",
63
+ "prepack": "npm run build"
64
+ },
65
+ "dependencies": {
66
+ "@colbymchenry/codegraph": "1.2.0",
67
+ "@node-rs/jieba": "2.0.1",
68
+ "@types/emscripten": "^1.41.6",
69
+ "graphology": "0.26.0",
70
+ "ignore": "^7.0.5",
71
+ "web-tree-sitter": "^0.25.3",
72
+ "yaml": "2.8.3"
73
+ },
74
+ "devDependencies": {
75
+ "@types/node": "^22.15.0",
76
+ "typescript": "^5.9.3"
77
+ }
78
+ }
@@ -0,0 +1,237 @@
1
+ ---
2
+ name: ew-odyssey
3
+ disable-model-invocation: true
4
+ description: Long-running iterative cycle — one entry, seven modes
5
+ (debug|improve|planex|review|security|defensive|ui). Shared archaeology/audit
6
+ → fix → verify → generalize → discover → persist skeleton with mode-specific
7
+ dimensions. User-invoked campaign entry; single-step fixes route via
8
+ /ew-orchestrate
9
+ argument-hint: <intent> --mode debug|improve|planex|review|security|defensive|ui [-y] [-c]
10
+ allowed-tools:
11
+ - Bash
12
+ - Edit
13
+ - Glob
14
+ - Grep
15
+ - Read
16
+ - Write
17
+ - followup_task
18
+ - interrupt_agent
19
+ - list_agents
20
+ - request_user_input
21
+ - send_message
22
+ - spawn_agent
23
+ - spawn_agents_on_csv
24
+ - update_plan
25
+ - wait_agent
26
+ session-mode: run
27
+ contract:
28
+ discovery: self-described
29
+ consumes: []
30
+ produces: []
31
+ version: 0.5.93
32
+ ---
33
+
34
+ Use the [Evolve Session execution guide](../ew-orchestrate/references/orchestrator-run-loop.md) for dispatch, decisions and recovery.
35
+
36
+ ## Mode documents
37
+
38
+ - Shared phases — [default](references/odyssey-base.md) or [Codex](references/odyssey-base-codex.md)
39
+ - Debug — [prepare](references/prepare/odyssey-debug.md), [default](references/odyssey-debug.md), [Codex](references/odyssey-debug.codex.md)
40
+ - Improve — [prepare](references/prepare/odyssey-improve.md), [default](references/odyssey-improve.md), [Codex](references/odyssey-improve.codex.md)
41
+ - Plan and execute — [prepare](references/prepare/odyssey-planex.md), [default](references/odyssey-planex.md), [Codex](references/odyssey-planex.codex.md)
42
+ - Review — [prepare](references/prepare/odyssey-review.md), [default](references/odyssey-review.md), [Codex](references/odyssey-review.codex.md)
43
+ - Security — [prepare](references/prepare/odyssey-security.md), [workflow](references/odyssey-security.md)
44
+ - Defensive — [prepare](references/prepare/odyssey-defensive.md), [default](references/odyssey-defensive.md), [Codex](references/odyssey-defensive.codex.md)
45
+ - UI — [prepare](references/prepare/odyssey-ui.md), [default](references/odyssey-ui.md), [Codex](references/odyssey-ui.codex.md)
46
+
47
+ <purpose>
48
+ Long-running, evidence-driven iterative cycle. A single entry dispatches to one of seven modes; all share the same
49
+ skeleton — discovery → domain audit → fix → verify → generalize → discover siblings → persist knowledge —
50
+ and iterate exhaustively until the mode's exit condition is met or escalation is required.
51
+ </purpose>
52
+
53
+ <mode_dispatch>
54
+
55
+ **Mode selection precedence:** explicit `--mode <name>` > intent keyword auto-detection > request_user_input (Normal) / error E000 (`-y`).
56
+
57
+ **Auto-detection from `<intent>` keywords** (first match wins, ordered):
58
+
59
+ Keyword matching: case-insensitive substring match against the intent text. Multi-word keywords require all words present (not necessarily adjacent). First matching row wins (ordered by specificity).
60
+
61
+ | Keywords in intent | Detected mode |
62
+ |--------------------|---------------|
63
+ | bug, crash, error, broken, fails, regression, race, leak, "why does" | `debug` |
64
+ | requirement, implement, build, add feature, I need to implement, I need to build, I need to add, deliver feature, user story | `planex` |
65
+ | ui, visual, layout, style, component, page, responsive, a11y, accessibility, UI design, visual design, design system, design tokens | `ui` |
66
+ | security audit, OWASP, vulnerability, CVE, secrets scan, STRIDE, threat model, supply chain, dependency audit, dependencies, supply chain audit | `security` |
67
+ | defensive programming, defensive code, exception swallowing, silent failure, fallback risk, default value risk, error suppression, 防御性编程, 防御性代码, 异常吞噬, 兜底风险 | `defensive` |
68
+ | improve, optimize, performance, refactor quality, reliability, observability | `improve` |
69
+ | review, audit, code check, check the code, inspect the code, inspect changes, "look over", zero-residual | `review` |
70
+
71
+ Ambiguous / no match → Normal: request_user_input (7-way mode pick) | `-y`: E000.
72
+
73
+ **Mode registry:**
74
+
75
+ | Mode | Purpose | Discovery phases | Audit phase | Fix→verify pair | Unique states |
76
+ |------|---------|------------------|-------------|-----------------|---------------|
77
+ | `debug` | Symptom → root cause → fix → confirm | ARCHAEOLOGY, EXPLORE | DIAGNOSE (hypothesis test) | FIX → CONFIRM | ESCALATE_DIAGNOSIS |
78
+ | `improve` | 6-dimension quality audit → diagnose → fix | SURVEY | AUDIT (6 dims) + DIAGNOSE | FIX → VERIFY | ESCALATE_DIAGNOSIS |
79
+ | `planex` | Requirement → plan → execute → verify loop | (none) | PLAN + EXECUTE | (EXECUTE) → VERIFY → FIX loop | — |
80
+ | `review` | Multi-dimension deep review → zero-residual fix | ARCHAEOLOGY, EXPLORE | REVIEW (4+ dims) | FIX → CONFIRM | — |
81
+ | `security` | Read-only tiered security audit → severity matrix | RECON | SCAN (OWASP + deps + secrets + CI/CD + STRIDE + git) | (none — read-only) | — |
82
+ | `defensive` | Business-anchor → backward-slice → 8-pattern scan → forward-propagate → risk score | ANCHOR, SLICE | SCAN (8 defensive patterns) + PROPAGATE | (none — read-only) | — |
83
+ | `ui` | Visual survey → 6-dim audit → diverge → fix | SURVEY | AUDIT (6 dims) + DIVERGE | FIX → VERIFY | — |
84
+
85
+ CONFIRM and VERIFY are synonymous — both refer to the post-fix validation phase. Mode workflow files use mode-specific naming; semantics are identical.
86
+
87
+ The **back half is identical across all modes**: `GENERALIZE → DISCOVER → RECORD → END` (see odyssey-base.md §Shared Back-Half).
88
+
89
+ For a new campaign, read the selected mode's preparation, one workflow, and the matching shared phases. Resolve every link relative to this Skill entry.
90
+
91
+ For an existing Run, use the exact `ew-odyssey-<mode>` command from its Resume Packet before selecting a mode. Follow the Run's `skill_ref` with `run skill-read` when present. Open `skill_required_links` for the bound mode's preparation and workflow. Refer to the Codex variant when using Codex-specific tools. A legacy Run uses the preparation and workflow in its packet, including a project's override. Resume from its existing domain progress and artifacts.
92
+
93
+ </mode_dispatch>
94
+
95
+ <context>
96
+ $ARGUMENTS
97
+
98
+ **Universal flags:** `--mode <name>` mode selector | `--skip-fix` audit/diagnose only, skip fix+verify | `--skip-generalize` skip GENERALIZE+DISCOVER | `-y` skip all confirmation interactions (including delegate/agent confirmations in execution phases), use default choices; decisions skipped this way are recorded as `deferred`; never bypasses mode ambiguity (E000), INTAKE gate blockers, escalation | `-c` resume the most recent unfinished Session of the SAME mode via exact Session resolution: locate it with `evolve session list --json` + `evolve session status --session {session_id} --json` (both read-only), re-attach context with `evolve session resume-view` and the `Evolve Run brief` Resume Packet via `run brief` (see the Evolve Session execution guide), then continue the chain with fenced `evolve run next` / `run complete`. If `--mode` conflicts with the resumed Session's mode → E003 (mode mismatch); no history → ignore -c, create new Session | `--heartbeat` /loop periodic progress
99
+
100
+ **Mode-scoped flags:**
101
+
102
+ | Flag | Modes | Description | Default |
103
+ |------|-------|-------------|---------|
104
+ | `--template <name>` | debug, planex | Predefined strategy/criteria template | — |
105
+ | `--dimensions <list>` | improve, review, ui | Audit dimension subset | all |
106
+ | `--fix-threshold <sev>` | improve, review, ui | Severity cutoff (critical\|high\|medium\|low\|all) | all |
107
+ | `--tier quick\|standard\|deep` | security, defensive | Audit depth tier | standard |
108
+ | `--sink-depth <list>` | defensive | Explicit sink layer focus (1\|2\|3\|all) | all |
109
+ | `--max-iterations N` | planex | Max verify-fix cycles before escalation | 3 |
110
+ | `--method agent\|cli\|auto` | planex | Task execution method | auto |
111
+ | `--executor <tool>` | planex | Explicit CLI executor | first enabled |
112
+ | `--skip-verify` | planex | Skip post-execution validation gate | false |
113
+
114
+ `--skip-fix` applicability: security and defensive modes ignore (read-only, no fix phase); planex skips FIX loop but retains EXECUTE+VERIFY; debug/review/improve/ui skip FIX+VERIFY/CONFIRM. `--skip-fix` + `--skip-verify` on planex = PLAN only (no execution).
115
+
116
+ Mode-scoped flags passed to inapplicable mode: emit W008 warning and ignore the flag.
117
+
118
+ **Session creation.** Open an Evolve Session, insert the selected ew-odyssey-<mode> step with the mode arguments, then dispatch run next. Supply each argument through --arg and use the returned revision for the next mutation. Read the entry, selected preparation and mode workflow from the bound commit. Resume the same Run and its domain checkpoint on continuation.
119
+
120
+ **Session**: `{run_dir}/outputs/`
121
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md` | `explore.json` (debug/review only) | `anchors.json` (defensive only)
122
+
123
+ **Output boundary**: ALL session artifacts MUST target the run outputs directory (`{run_dir}/outputs/`) only. `.workflow/state.json` and all `sessions/<sid>/` protocol files are runtime-owned — a workflow never writes them. Source code modifications during fix/execute phases are in-scope but MUST be committed per action. NEVER write session artifacts outside `{run_dir}/outputs/`.
124
+
125
+ **session.json — shared core + mode fields:**
126
+ ```json
127
+ { "mode": "debug|improve|planex|review|security|defensive|ui",
128
+ "target": "", "dimensions": [],
129
+ "patterns": [], "confirmation": null, "generalization_stats": null,
130
+ "cross_phase_loops": 0 }
131
+ ```
132
+ Each mode extends the core — see the mode's workflow file for **session fields**.
133
+
134
+ **Commit convention:** `"odyssey-{mode}({slug}): {STATE} — {summary}"` (mode = active mode short name; review mode uses `odyssey-review`).
135
+
136
+ </context>
137
+
138
+ <invariants>
139
+ All base invariants apply (evidence append-only, session-as-state, phase goal tracking, auto-commit per action). Additionally:
140
+
141
+ 1. **Evidence append-only** — never delete or overwrite evidence.ndjson entries.
142
+ 2. **Phase goal tracking** — mark each goal done/failed before transition; no silent skips.
143
+ 3. **Generalize is mandatory** — GENERALIZE and DISCOVER execute unless `skip_generalize == true`. Prior-phase convergence, "no findings / all verified / zero remaining," or context pressure are NOT valid skip reasons. The phase itself determines whether patterns exist.
144
+ 4. **Zero-residual** (improve/review/ui) — every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and blanket "pre-existing" skips are forbidden.
145
+ 5. **Read-only** (security, defensive) — NEVER modify source code, configuration, or dependencies. Security and defensive audits produce reports only; fixes route to `--mode improve`.
146
+ 6. **Acceptance criteria are sacred** (planex) — no "close enough", no manual override without explicit escalation.
147
+ 7. **Browser is truth** (ui) — verify in real rendering, not just code review. Diverge before converge.
148
+ 8. **Goal 跟宿主原生 /goal 走** — session.json 是权威进度。不要为了刷新外观去重建 Goal;用户 clear 之后外观必须保持消失。
149
+ </invariants>
150
+
151
+ <task_tracking>
152
+
153
+ **时机与操作**(plan 是 session 权威状态的 UI 镜像,不替代 session 状态):
154
+
155
+ | 时机 | 操作 | 示例 |
156
+ |------|------|------|
157
+ | Session 创建后 | update_plan 初始化步骤清单 | `update_plan({ plan: [{ step: "Step {index}: {step.skill}", status: "pending" }, ...] })` |
158
+ | Step 派发时 | update_plan 标记当前 step | `update_plan({ plan: [..., 当前 step status: "in_progress"] })` |
159
+ | Step 完成时 | update_plan 标记完成 | `update_plan({ plan: [..., 该 step status: "completed"] })` |
160
+ | Step 失败时 | update_plan + explanation 说明 | `update_plan({ explanation: "Step {index} failed: {reason}", plan: [...] })` |
161
+
162
+ </task_tracking>
163
+
164
+ <self_iteration>
165
+ Self-iteration (logic in odyssey-base.md) applies to each mode's discovery + audit + GENERALIZE stages:
166
+
167
+ | Mode | Self-iterating stages |
168
+ |------|----------------------|
169
+ | debug | S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE |
170
+ | improve | S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE |
171
+ | planex | S_PLAN, S_VERIFY, S_GENERALIZE |
172
+ | review | S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE |
173
+ | security | S_RECON, S_SCAN, S_GENERALIZE |
174
+ | defensive | S_ANCHOR, S_SLICE, S_SCAN, S_PROPAGATE, S_GENERALIZE |
175
+ | ui | S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE |
176
+ </self_iteration>
177
+
178
+ <execution>
179
+ Follow base execution discipline completely. On entry: resolve mode (§mode_dispatch), then read the deferred workflow file for that mode + odyssey-base.md, and run that mode's state machine. All modes converge on the Shared Back-Half in odyssey-base.md.
180
+
181
+ ### Shared Phase Gates (MANDATORY, BLOCKING)
182
+
183
+ - **INTAKE gate:** mode resolved, target/requirement resolved, SESSION_DIR created, session.json initialized (with baseline_metrics for improve; acceptance_criteria for planex), phase_goals[] derived from flags, understanding.md §1 written. BLOCKED if no target (E001) / no requirement (planex E001) / target path not found (E002) / mode unresolved (E000).
184
+ - **GENERALIZE gate:** ALL 3 layers (syntax/semantic/structural) attempted with evidence logged; generalization_stats written with by_layer entries for all 3 layers; generalize goal marked. Any layer not attempted = thoroughness-floor violation (BLOCKED).
185
+ - **DISCOVER gate:** all hits triaged with per-item classification and reason; `remaining_actionable == 0` OR `loops >= max_loops` with per-item reasons logged; discover goal marked. Unclassified hits = BLOCKED.
186
+
187
+ Mode-specific phase gates (Discovery, Audit, FIX, VERIFY/CONFIRM) are defined in each mode's workflow file.
188
+
189
+ </execution>
190
+
191
+ <error_codes>
192
+ | Code | Severity | Condition | Recovery |
193
+ |------|----------|-----------|----------|
194
+ | E000 | error | Mode unresolved (`-y`, ambiguous intent, no `--mode`) | Provide `--mode` |
195
+ | E001 | error | No target / no requirement (planex) / no issue (debug) | Provide target or -c |
196
+ | E002 | error | Target path not found | Check path |
197
+ | E003 | error | -c mode mismatch (resumed session is different mode) | Use correct --mode or omit -c |
198
+ | E004 | error | The selected mode's Markdown link cannot be read | Reinstall the Skill package or restore the Run's original version |
199
+ | W001 | warning | No relevant git history / no dependency manifest / no design system | Proceed with defaults |
200
+ | W002 | warning | Some dimension agents failed / 3 retries exhausted | Partial coverage / INCONCLUSIVE |
201
+ | W003 | warning | Archaeology agent or delegate failure (debug/review) | Proceed with available results, log failed agent |
202
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
203
+ | W005 | warning | Pending decisions | Filter evidence phase=decision |
204
+ | W006 | warning | No CLI tools (debug/review explore) | Skip explore |
205
+ | W007 | warning | planex CLI review regression concern | Review before next iteration |
206
+ | W008 | warning | Mode-scoped flag ignored (not applicable to resolved mode) | Remove flag or use correct mode |
207
+ </error_codes>
208
+
209
+ <success_criteria>
210
+ - [ ] Mode resolved (explicit or auto-detected); session + output files created; prior knowledge searched
211
+ - [ ] Discovery phase(s) for the mode completed with evidence (archaeology/explore/survey)
212
+ - [ ] Domain audit completed with structured findings + severity matrix (or acceptance criteria + plan for planex)
213
+ - [ ] understanding.md sections written progressively per mode
214
+ - [ ] Fix + verify/confirm (unless --skip-fix); zero-residual for improve/review/ui; all criteria pass for planex
215
+ - [ ] Read-only invariant maintained for security and defensive modes — zero source modifications
216
+ - [ ] Multi-layer generalization + discovery triage (unless --skip-generalize); every unfixed finding individually justified
217
+ - [ ] phase_goals derived, tracked, and hardened-audited; goal_mode injected via prepare goal:true; `-y` no blocking prompts
218
+ - [ ] Session resumable via -c; mode-specific completion summary emitted
219
+ </success_criteria>
220
+
221
+ <next_step_routing>
222
+ | Condition | Next |
223
+ |-----------|------|
224
+ | Single-file mechanical fix discovered | Evolve internal Companion route |
225
+ | Discovery issues created | Review the findings in the project issue tracker. |
226
+ | Deeper debug needed (from any mode) | `/ew-odyssey <finding> --mode debug` |
227
+ | Security findings need remediation | `/ew-odyssey <finding> --mode improve` |
228
+ | Defensive findings need remediation | `/ew-odyssey <finding> --mode improve` |
229
+ | Defensive root-cause needed | `/ew-odyssey <finding> --mode debug` |
230
+ | Formal review of changes | `/ew-odyssey <changed-files> --mode review` |
231
+ | UI-related findings | `/ew-odyssey <component> --mode ui` |
232
+ | Document pattern | `Review the module and stage the reusable method via Agent Memory closeout` |
233
+ | Second opinion | `evolve delegate "<review prompt>" --mode analysis` |
234
+ | Related question | `Use an Evolve analyze step for the question` |
235
+ | Design/perf/arch pattern to persist | Follow the [Agent Memory knowledge route](../ew-orchestrate/references/knowledge-route.md). |
236
+ | Pending decisions | Filter evidence phase=decision status=pending |
237
+ </next_step_routing>
@@ -0,0 +1,7 @@
1
+ # Read-only Odyssey audit artifacts
2
+
3
+ Resume the exact Evolve Run, then read `outputs/session.json` for the audit phase, target, tier and findings already recorded. Store audit progress in that file and keep lifecycle state in the Evolve Run store.
4
+
5
+ Use the selected mode's artifact contract for `kind`, `schema`, `role` and `alias`. Put those fields in `_meta` for `session.json` and, in Defensive mode, `anchors.json`. Put `_meta` in the first record of `evidence.ndjson` and append subsequent observations. Put the report metadata in the YAML frontmatter of `understanding.md`.
6
+
7
+ At report time, reconcile the severity counts with the evidenced findings. Record unverified categories and unresolved reviews explicitly. Check that the audited files have the same bytes as at intake, then seal with `evolve run complete` and follow the returned continuation.
@@ -0,0 +1,3 @@
1
+ <!-- session-mode: inherited -->
2
+
3
+ # Odyssey Shared Base (Codex)