@really-knows-ai/foundry 2.3.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +180 -369
  2. package/dist/.opencode/plugins/foundry-tools/appraiser-tools.js +28 -0
  3. package/dist/.opencode/plugins/foundry-tools/artefact-tools.js +58 -0
  4. package/dist/.opencode/plugins/foundry-tools/assay-tools.js +92 -0
  5. package/dist/.opencode/plugins/foundry-tools/attestation-tools.js +191 -0
  6. package/dist/.opencode/plugins/foundry-tools/config-create-tools.js +128 -0
  7. package/dist/.opencode/plugins/foundry-tools/config-law-tools.js +380 -0
  8. package/dist/.opencode/plugins/foundry-tools/config-tools.js +43 -0
  9. package/dist/.opencode/plugins/foundry-tools/feedback-tools.js +234 -0
  10. package/dist/.opencode/plugins/foundry-tools/git-helpers.js +354 -0
  11. package/dist/.opencode/plugins/foundry-tools/git-tools.js +181 -0
  12. package/dist/.opencode/plugins/foundry-tools/helpers.js +340 -0
  13. package/dist/.opencode/plugins/foundry-tools/history-tools.js +20 -0
  14. package/dist/.opencode/plugins/foundry-tools/memory-admin-tools.js +296 -0
  15. package/dist/.opencode/plugins/foundry-tools/memory-helpers.js +104 -0
  16. package/dist/.opencode/plugins/foundry-tools/memory-tools.js +286 -0
  17. package/dist/.opencode/plugins/foundry-tools/orchestrate-tool.js +159 -0
  18. package/dist/.opencode/plugins/foundry-tools/snapshot-tools.js +104 -0
  19. package/dist/.opencode/plugins/foundry-tools/stage-tools.js +186 -0
  20. package/dist/.opencode/plugins/foundry-tools/validate-tools.js +263 -0
  21. package/dist/.opencode/plugins/foundry-tools/workfile-tools.js +102 -0
  22. package/dist/.opencode/plugins/foundry.js +105 -0
  23. package/dist/CHANGELOG.md +533 -0
  24. package/dist/LICENSE +21 -0
  25. package/dist/README.md +278 -0
  26. package/dist/docs/README.md +59 -0
  27. package/dist/docs/architecture.md +433 -0
  28. package/dist/docs/concepts.md +395 -0
  29. package/dist/docs/getting-started.md +344 -0
  30. package/dist/docs/memory-maintenance.md +176 -0
  31. package/dist/docs/tools.md +1411 -0
  32. package/dist/docs/work-spec.md +283 -0
  33. package/dist/scripts/lib/artefacts.js +151 -0
  34. package/dist/scripts/lib/assay/loader.js +151 -0
  35. package/dist/scripts/lib/assay/parse-jsonl.js +102 -0
  36. package/dist/scripts/lib/assay/permissions.js +52 -0
  37. package/dist/scripts/lib/assay/run.js +219 -0
  38. package/dist/scripts/lib/assay/spawn-with-timeout.js +138 -0
  39. package/dist/scripts/lib/attestation/attest.js +111 -0
  40. package/dist/scripts/lib/attestation/canonical-json.js +109 -0
  41. package/dist/scripts/lib/attestation/hash.js +17 -0
  42. package/dist/scripts/lib/attestation/parse.js +14 -0
  43. package/dist/scripts/lib/attestation/payload.js +106 -0
  44. package/dist/scripts/lib/attestation/render.js +16 -0
  45. package/dist/scripts/lib/attestation/verify.js +15 -0
  46. package/dist/scripts/lib/branch-guard.js +72 -0
  47. package/dist/scripts/lib/config-creators/appraiser.js +9 -0
  48. package/dist/scripts/lib/config-creators/artefact-type.js +9 -0
  49. package/dist/scripts/lib/config-creators/cycle.js +11 -0
  50. package/dist/scripts/lib/config-creators/factory.js +49 -0
  51. package/dist/scripts/lib/config-creators/flow.js +11 -0
  52. package/dist/scripts/lib/config-validators/appraiser.js +49 -0
  53. package/dist/scripts/lib/config-validators/artefact-type.js +38 -0
  54. package/dist/scripts/lib/config-validators/cycle.js +131 -0
  55. package/dist/scripts/lib/config-validators/flow.js +57 -0
  56. package/dist/scripts/lib/config-validators/helpers.js +96 -0
  57. package/dist/scripts/lib/config-validators/law.js +96 -0
  58. package/dist/scripts/lib/config.js +328 -0
  59. package/dist/scripts/lib/failed-flow.js +131 -0
  60. package/dist/scripts/lib/feedback-store.js +249 -0
  61. package/dist/scripts/lib/feedback-transitions.js +105 -0
  62. package/dist/scripts/lib/finalize.js +70 -0
  63. package/dist/scripts/lib/foundational-guards.js +13 -0
  64. package/dist/scripts/lib/git-bridge.js +77 -0
  65. package/dist/scripts/lib/git-finish/work-finish.js +233 -0
  66. package/dist/scripts/lib/git-policy.js +101 -0
  67. package/dist/scripts/lib/guards.js +125 -0
  68. package/dist/scripts/lib/history.js +132 -0
  69. package/dist/scripts/lib/memory/admin/create-edge-type.js +91 -0
  70. package/dist/scripts/lib/memory/admin/create-entity-type.js +43 -0
  71. package/dist/scripts/lib/memory/admin/create-extractor.js +67 -0
  72. package/dist/scripts/lib/memory/admin/drop-edge-type.js +40 -0
  73. package/dist/scripts/lib/memory/admin/drop-entity-type.js +172 -0
  74. package/dist/scripts/lib/memory/admin/dump.js +47 -0
  75. package/dist/scripts/lib/memory/admin/helpers.js +31 -0
  76. package/dist/scripts/lib/memory/admin/init.js +170 -0
  77. package/dist/scripts/lib/memory/admin/live-store.js +76 -0
  78. package/dist/scripts/lib/memory/admin/reembed.js +285 -0
  79. package/dist/scripts/lib/memory/admin/rename-edge-type.js +54 -0
  80. package/dist/scripts/lib/memory/admin/rename-entity-type.js +151 -0
  81. package/dist/scripts/lib/memory/admin/reset.js +24 -0
  82. package/dist/scripts/lib/memory/admin/vacuum.js +9 -0
  83. package/dist/scripts/lib/memory/admin/validate.js +19 -0
  84. package/dist/scripts/lib/memory/config.js +149 -0
  85. package/dist/scripts/lib/memory/cozo.js +136 -0
  86. package/dist/scripts/lib/memory/drift.js +71 -0
  87. package/dist/scripts/lib/memory/embeddings.js +128 -0
  88. package/dist/scripts/lib/memory/frontmatter.js +75 -0
  89. package/dist/scripts/lib/memory/ndjson.js +84 -0
  90. package/dist/scripts/lib/memory/paths.js +25 -0
  91. package/dist/scripts/lib/memory/permissions.js +41 -0
  92. package/dist/scripts/lib/memory/prompt.js +109 -0
  93. package/dist/scripts/lib/memory/query.js +56 -0
  94. package/dist/scripts/lib/memory/reads.js +109 -0
  95. package/dist/scripts/lib/memory/schema.js +64 -0
  96. package/dist/scripts/lib/memory/search.js +73 -0
  97. package/dist/scripts/lib/memory/singleton.js +49 -0
  98. package/dist/scripts/lib/memory/store.js +162 -0
  99. package/dist/scripts/lib/memory/types.js +93 -0
  100. package/dist/scripts/lib/memory/validate.js +58 -0
  101. package/dist/scripts/lib/memory/writes.js +40 -0
  102. package/{scripts → dist/scripts}/lib/pending.js +7 -2
  103. package/dist/scripts/lib/secret.js +59 -0
  104. package/{scripts → dist/scripts}/lib/slug.js +3 -2
  105. package/dist/scripts/lib/snapshot/finish.js +103 -0
  106. package/dist/scripts/lib/snapshot/inspect.js +253 -0
  107. package/dist/scripts/lib/snapshot/render.js +55 -0
  108. package/dist/scripts/lib/sort-fs-check.js +121 -0
  109. package/dist/scripts/lib/sort-routing.js +101 -0
  110. package/{scripts → dist/scripts}/lib/stage-guard.js +12 -6
  111. package/{scripts → dist/scripts}/lib/state.js +4 -0
  112. package/dist/scripts/lib/token.js +57 -0
  113. package/dist/scripts/lib/tracing.js +59 -0
  114. package/dist/scripts/lib/ulid.js +100 -0
  115. package/dist/scripts/lib/validator-jsonl.js +162 -0
  116. package/{scripts → dist/scripts}/lib/workfile.js +38 -20
  117. package/dist/scripts/orchestrate-cycle.js +215 -0
  118. package/dist/scripts/orchestrate-phases.js +314 -0
  119. package/dist/scripts/orchestrate.js +163 -0
  120. package/dist/scripts/sort.js +278 -0
  121. package/{skills → dist/skills}/add-appraiser/SKILL.md +39 -9
  122. package/{skills → dist/skills}/add-artefact-type/SKILL.md +62 -40
  123. package/{skills → dist/skills}/add-cycle/SKILL.md +57 -17
  124. package/dist/skills/add-extractor/SKILL.md +133 -0
  125. package/{skills → dist/skills}/add-flow/SKILL.md +36 -10
  126. package/dist/skills/add-law/SKILL.md +191 -0
  127. package/dist/skills/add-memory-edge-type/SKILL.md +52 -0
  128. package/dist/skills/add-memory-entity-type/SKILL.md +74 -0
  129. package/{skills → dist/skills}/appraise/SKILL.md +62 -13
  130. package/dist/skills/assay/SKILL.md +72 -0
  131. package/dist/skills/change-embedding-model/SKILL.md +58 -0
  132. package/dist/skills/drop-memory-edge-type/SKILL.md +54 -0
  133. package/dist/skills/drop-memory-entity-type/SKILL.md +57 -0
  134. package/dist/skills/dry-run/SKILL.md +116 -0
  135. package/{skills → dist/skills}/flow/SKILL.md +15 -2
  136. package/dist/skills/forge/SKILL.md +121 -0
  137. package/dist/skills/human-appraise/SKILL.md +153 -0
  138. package/{skills → dist/skills}/init-foundry/SKILL.md +23 -4
  139. package/dist/skills/init-memory/SKILL.md +92 -0
  140. package/{skills → dist/skills}/orchestrate/SKILL.md +30 -4
  141. package/dist/skills/quench/SKILL.md +99 -0
  142. package/{skills → dist/skills}/refresh-agents/SKILL.md +1 -1
  143. package/dist/skills/rename-memory-edge-type/SKILL.md +50 -0
  144. package/dist/skills/rename-memory-entity-type/SKILL.md +51 -0
  145. package/dist/skills/reset-memory/SKILL.md +54 -0
  146. package/dist/skills/upgrade-foundry/SKILL.md +191 -0
  147. package/package.json +34 -17
  148. package/.opencode/plugins/foundry.js +0 -761
  149. package/CHANGELOG.md +0 -100
  150. package/docs/concepts.md +0 -122
  151. package/docs/getting-started.md +0 -187
  152. package/docs/work-spec.md +0 -207
  153. package/scripts/lib/artefacts.js +0 -124
  154. package/scripts/lib/config.js +0 -175
  155. package/scripts/lib/feedback-transitions.js +0 -25
  156. package/scripts/lib/feedback.js +0 -440
  157. package/scripts/lib/finalize.js +0 -41
  158. package/scripts/lib/history.js +0 -59
  159. package/scripts/lib/secret.js +0 -23
  160. package/scripts/lib/tags.js +0 -108
  161. package/scripts/lib/token.js +0 -26
  162. package/scripts/orchestrate.js +0 -418
  163. package/scripts/sort.js +0 -370
  164. package/scripts/validate-tags.js +0 -54
  165. package/skills/add-law/SKILL.md +0 -111
  166. package/skills/forge/SKILL.md +0 -88
  167. package/skills/human-appraise/SKILL.md +0 -82
  168. package/skills/quench/SKILL.md +0 -62
  169. package/skills/upgrade-foundry/SKILL.md +0 -216
  170. /package/{skills → dist/skills}/list-agents/SKILL.md +0 -0
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: upgrade-foundry
3
+ type: atomic
4
+ description: Rebuilds foundry configuration for the current version from preserved source configuration.
5
+ ---
6
+
7
+ # Upgrade Foundry
8
+
9
+ You upgrade a project by preserving its existing Foundry configuration, creating a clean current-version configuration, and recreating supported concepts through current Foundry tools.
10
+
11
+ This is a rebuild-style upgrade. Treat the old `foundry/` directory as source material. The new `foundry/` directory must be valid for the installed Foundry version.
12
+
13
+ ## Prerequisites
14
+
15
+ Before running this skill, verify that the project root contains `foundry/`. If it does not, stop and tell the user:
16
+
17
+ > Foundry is not initialised in this project. Run the `init-foundry` skill first to create the foundry/ directory structure.
18
+
19
+ Verify a safe base state before making changes:
20
+
21
+ - The worktree is clean, or the user explicitly chooses how to handle dirty files.
22
+ - `WORK.md` is absent from the repository root.
23
+ - The upgrade runs from a config branch such as `config/upgrade-foundry`, or you create one with `foundry_git_branch({ kind: 'config', description: 'upgrade-foundry' })` before making config changes.
24
+ - Use an isolated worktree where practical, matching the normal config-edit workflow.
25
+
26
+ If `WORK.md` exists, stop and tell the user:
27
+
28
+ > An in-flight workfile is present. Complete or discard the active flow before upgrading; active flow state is not migrated.
29
+
30
+ ## Protocol
31
+
32
+ ### 1. Identify versions and source directory
33
+
34
+ Detect the installed Foundry version from the package manager metadata where possible. Detect the source project version from the existing package metadata or preserved configuration clues where possible.
35
+
36
+ Choose the preserved source directory name:
37
+
38
+ - Use a versioned preserved directory when the source version is known, for example `foundry_2.3.2/`.
39
+ - Use `foundry_unknown/` when the source version cannot be determined.
40
+ - If the chosen directory already exists, ask the user for a different suffix before proceeding.
41
+
42
+ Before renaming anything, warn the user:
43
+
44
+ > I will move the existing `foundry/` directory to the preserved source directory, initialise a clean current-version `foundry/`, then recreate supported configuration through current tools. I will not delete the preserved source directory unless you explicitly approve cleanup after review.
45
+
46
+ Wait for explicit user approval before moving the directory.
47
+
48
+ ### 2. Preserve existing configuration
49
+
50
+ Move the existing `foundry/` directory to the approved preserved source directory.
51
+
52
+ Do not modify the preserved source directory after moving it. Read from it as source material only.
53
+
54
+ ### 3. Initialise current-version configuration
55
+
56
+ Run the current `init-foundry` flow to create a fresh `foundry/` directory for the installed Foundry version.
57
+
58
+ After initialisation, confirm the new config directory exists and contains the expected current top-level structure.
59
+
60
+ ### 4. Analyse the preserved source
61
+
62
+ Read source material from the preserved directory:
63
+
64
+ - Flow definitions.
65
+ - Cycle definitions.
66
+ - Artefact type definitions.
67
+ - Type-specific laws (with validators where applicable).
68
+ - Global laws.
69
+ - Appraisers.
70
+ - Memory schema, relations, and extractors when present.
71
+
72
+ Build an inventory with these sections:
73
+
74
+ - Artefact types to recreate.
75
+ - Laws to recreate.
76
+ - Appraisers to recreate.
77
+ - Cycles to recreate.
78
+ - Flows to recreate.
79
+ - Memory schema and extractors to recreate.
80
+ - Items that need clarification.
81
+ - Items with no current-version equivalent.
82
+
83
+ ### 5. Ask clarifying questions
84
+
85
+ Ask the user before proceeding whenever the old configuration does not map safely to current concepts.
86
+
87
+ Ask one question at a time. Continue only after the user answers.
88
+
89
+ Common clarification points:
90
+
91
+ - Flow routing when old cycle order does not define current `targets` semantics.
92
+ - Starting cycles when the old flow has no explicit current-version equivalent.
93
+ - Input contracts when old inputs do not state `any-of` or `all-of` intent.
94
+ - Artefact ownership when file patterns overlap or are missing.
95
+ - Validators whose purpose or failure meaning is unclear.
96
+ - Appraiser selection when old config lacks counts, allowed appraisers, or personality detail.
97
+ - Human appraisal and deadlock settings that map to current fields with changed semantics.
98
+ - Memory permissions, extractor outputs, relation files, or schema details whose current contract is ambiguous.
99
+ - Deprecated concepts that have no current-version equivalent.
100
+
101
+ ### 6. Recreate configuration through current tools
102
+
103
+ Use current Foundry tools wherever they exist. Prefer tool-created config over direct file edits.
104
+
105
+ Recreate concepts in dependency order:
106
+
107
+ 1. Global laws.
108
+ 2. Appraisers.
109
+ 3. Artefact types, including type laws and validators.
110
+ 4. Memory schema and extractors when safely inferable.
111
+ 5. Cycles.
112
+ 6. Flows.
113
+
114
+ Use direct file edits only when current tools do not cover a required current-version configuration field. Record each direct edit in the migration report.
115
+
116
+ Do not recreate active flow state, `WORK.md`, feedback ledgers, branch state, generated artefacts, or historical runtime state.
117
+
118
+ ### 7. Validate current configuration
119
+
120
+ Run current validation tools for every recreated config kind:
121
+
122
+ - `foundry_config_validate_law`
123
+ - `foundry_config_validate_appraiser`
124
+ - `foundry_config_validate_artefact_type`
125
+ - `foundry_config_validate_cycle`
126
+ - `foundry_config_validate_flow`
127
+ - `foundry_memory_validate` when memory is present
128
+
129
+ Fix validation failures by using current tools or by asking the user for clarification when the fix changes migration intent.
130
+
131
+ ### 8. Commit meaningful checkpoints
132
+
133
+ Prefer commits at meaningful checkpoints on the config branch:
134
+
135
+ - Preserved source and fresh initialisation.
136
+ - Recreated laws, appraisers, and artefact types.
137
+ - Recreated cycles and flows.
138
+ - Recreated memory schema and extractors.
139
+ - Final validation/report updates.
140
+
141
+ Use concise commit messages, for example:
142
+
143
+ ```bash
144
+ git commit -m "chore: preserve old foundry config for upgrade"
145
+ git commit -m "chore: recreate foundry config for current version"
146
+ git commit -m "chore: validate upgraded foundry config"
147
+ ```
148
+
149
+ ### 9. Present migration report
150
+
151
+ End with a migration report containing these sections:
152
+
153
+ - Source version and target version.
154
+ - Preserved source directory path.
155
+ - Created artefact types.
156
+ - Created laws.
157
+ - Created appraisers.
158
+ - Created cycles.
159
+ - Created flows.
160
+ - Created memory schema and extractors.
161
+ - Assumptions made.
162
+ - User decisions made during migration.
163
+ - Warnings.
164
+ - Skipped items.
165
+ - Manual follow-up.
166
+ - Validation results.
167
+ - Cleanup recommendation.
168
+
169
+ Warnings must be concrete and actionable. Identify files or concepts that need human review.
170
+
171
+ ### 10. Cleanup policy
172
+
173
+ Do not delete the preserved source directory automatically.
174
+
175
+ After the user reviews the migration report, ask whether they want to keep or remove the preserved source directory. Keeping it is the safest default until the upgraded configuration has been used successfully.
176
+
177
+ ## What You Do
178
+
179
+ - Preserve old configuration before creating current configuration.
180
+ - Recreate supported concepts through current tools.
181
+ - Ask clarifying questions for ambiguous mappings.
182
+ - Report assumptions, skipped items, warnings, validation results, and manual follow-up.
183
+ - Keep cleanup opt-in.
184
+
185
+ ## What You Do Not Do
186
+
187
+ - You do not perform byte-for-byte migration of old config files.
188
+ - You do not migrate active `WORK.md`, feedback state, branch state, or in-flight flow execution.
189
+ - You do not silently infer ambiguous routing, input contracts, memory permissions, or deprecated concepts.
190
+ - You do not delete preserved source configuration without explicit user approval.
191
+ - You do not modify produced artefacts as part of the upgrade.
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@really-knows-ai/foundry",
3
- "version": "2.3.2",
4
- "description": "A structured framework for AI-driven artefact creation with deterministic routing, quality gates, and iterative refinement cycles.",
3
+ "version": "3.0.1",
4
+ "description": "A skill-driven framework for governed artefact generation with AI coding tools. Define your own artefact types, laws, and flows — Foundry handles the forge → quench → appraise pipeline with deterministic routing, quality gates, and iterative refinement.",
5
5
  "type": "module",
6
- "main": ".opencode/plugins/foundry.js",
6
+ "main": "dist/.opencode/plugins/foundry.js",
7
7
  "license": "MIT",
8
8
  "author": "Really Knows AI",
9
9
  "repository": {
@@ -24,23 +24,40 @@
24
24
  "engines": {
25
25
  "node": ">=18.3.0"
26
26
  },
27
- "scripts": {
28
- "test": "node --test"
29
- },
30
27
  "dependencies": {
31
28
  "@opencode-ai/plugin": "^1.4.0",
32
29
  "js-yaml": "^4.1.0",
33
30
  "minimatch": "^10.2.5"
34
31
  },
32
+ "optionalDependencies": {
33
+ "cozo-node": "^0.7.6"
34
+ },
35
35
  "files": [
36
- ".opencode/",
37
- "skills/",
38
- "scripts/",
39
- "docs/work-spec.md",
40
- "docs/concepts.md",
41
- "docs/getting-started.md",
42
- "README.md",
43
- "LICENSE",
44
- "CHANGELOG.md"
45
- ]
46
- }
36
+ "dist/.opencode/",
37
+ "dist/skills/",
38
+ "dist/scripts/",
39
+ "dist/docs/",
40
+ "dist/README.md",
41
+ "dist/LICENSE",
42
+ "dist/CHANGELOG.md"
43
+ ],
44
+ "devDependencies": {
45
+ "@eslint/js": "^9.39.4",
46
+ "eslint": "^9.39.4",
47
+ "eslint-plugin-eslint-comments": "^3.2.0",
48
+ "eslint-plugin-sonarjs": "^4.0.3",
49
+ "globals": "^17.6.0"
50
+ },
51
+ "scripts": {
52
+ "build": "node scripts/build.js",
53
+ "test": "find tests -name '*.test.js' ! -name '*.integration.test.js' ! -name '*.e2e.test.js' -print0 | xargs -0 node --test --test-reporter=dot",
54
+ "test:unit": "pnpm run test",
55
+ "test:integration": "find tests -name '*.integration.test.js' -print0 | xargs -0 node --test --test-reporter=dot",
56
+ "test:e2e": "find tests -name '*.e2e.test.js' -print0 | xargs -0 node --test --test-reporter=dot",
57
+ "test:all": "node --test --test-reporter=dot",
58
+ "test:coverage": "node --test --experimental-test-coverage --test-reporter=dot",
59
+ "lint": "eslint src/ tests/ scripts/",
60
+ "build:full": "pnpm run lint --fix && pnpm run test:all && pnpm run build",
61
+ "build:all": "pnpm run lint && pnpm run test:all && pnpm run build"
62
+ }
63
+ }