@warpgogol/forge 6.3.5 → 7.0.0

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 (51) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +2 -1
  3. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  4. package/dist/os/rfc/acceptance.js +15 -1
  5. package/dist/os/rfc/acceptance.js.map +1 -1
  6. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  7. package/dist/os/rfc/handlers/implement-stamp.js +98 -13
  8. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  9. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  10. package/dist/os/rfc/handlers/validate-rules.js +13 -4
  11. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  12. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  13. package/dist/os/rfc/rfc.module.js +11 -6
  14. package/dist/os/rfc/rfc.module.js.map +1 -1
  15. package/dist/os/rfc/types.d.ts +34 -5
  16. package/dist/os/rfc/types.d.ts.map +1 -1
  17. package/dist/os/rfc/types.js +14 -2
  18. package/dist/os/rfc/types.js.map +1 -1
  19. package/dist/os/rfc/verification-evidence.d.ts +16 -0
  20. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  21. package/dist/os/rfc/verification-evidence.js +71 -5
  22. package/dist/os/rfc/verification-evidence.js.map +1 -1
  23. package/dist/src/knowledge/sync.d.ts +1 -1
  24. package/dist/src/knowledge/sync.d.ts.map +1 -1
  25. package/dist/src/knowledge/sync.js +15 -3
  26. package/dist/src/knowledge/sync.js.map +1 -1
  27. package/dist/src/skill-schema.d.ts +2 -0
  28. package/dist/src/skill-schema.d.ts.map +1 -1
  29. package/dist/src/skill-schema.js +9 -1
  30. package/dist/src/skill-schema.js.map +1 -1
  31. package/os/rfc/acceptance.test.ts +111 -0
  32. package/os/rfc/acceptance.ts +20 -1
  33. package/os/rfc/handlers/implement-stamp-stale.test.ts +267 -0
  34. package/os/rfc/handlers/implement-stamp.ts +116 -15
  35. package/os/rfc/handlers/validate-rules.test.ts +42 -0
  36. package/os/rfc/handlers/validate-rules.ts +22 -4
  37. package/os/rfc/rfc-0000-template.md +18 -1
  38. package/os/rfc/rfc.module.ts +12 -6
  39. package/os/rfc/types.ts +48 -5
  40. package/os/rfc/verification-emit-check.test.ts +201 -0
  41. package/os/rfc/verification-evidence.ts +73 -5
  42. package/os/rfc/verification-normalize.test.ts +61 -0
  43. package/package.json +1 -1
  44. package/skills/_shared/agent-operating-model.md +83 -0
  45. package/skills/fo/fo-idea/SKILL.md +6 -3
  46. package/src/knowledge/__tests__/sync.test.ts +40 -0
  47. package/src/knowledge/sync.ts +20 -5
  48. package/src/onboarding/templates/behavioral-layer-core.md +8 -0
  49. package/src/skill-schema.ts +9 -1
  50. package/src/tests/fixtures/agents-generate-business-before.txt +8 -0
  51. package/src/tests/skill-schema.test.ts +39 -0
@@ -10,6 +10,7 @@ bindings:
10
10
  requires: []
11
11
  optional: [paths.invariantsFile]
12
12
  triggerPhrases: ["I have an idea for a change", "analyze this idea and route it", "decompose this feature idea", "does this need an RFC", "should I write an ADR for this"]
13
+ notApplicableWhen: ["The operator already named the decision artifact — a specific RFC/ADR id or 'write an ADR for X' — invoke the creation skill directly", "The intent is not an idea/classification request — review, fix, commit, session-end, or mission work route through the front-door table in fo-idea-i-just-want-to-see-the-result"]
13
14
  ---
14
15
 
15
16
  <!--
@@ -34,6 +35,8 @@ Before starting, read `PREFERENCES.md` at the repository root. If the file is mi
34
35
 
35
36
  Analyze the operator's text to determine whether the task requires a single RFC, a single ADR, or a **series** of documents. When a series is needed, decompose the task into atomic decisions, classify each, and create all documents in dependency order.
36
37
 
38
+ Routing outcomes map to the work modes in `_shared/agent-operating-model.md`: **EXPLORE** → `fo-explore` suggestion (step 1b), **ROUTINE** → direct implementation, **GOVERNED** → RFC/ADR documents.
39
+
37
40
  ## Process
38
41
 
39
42
  ### 1. Analyze the request
@@ -154,9 +157,9 @@ If the classification is ambiguous (e.g. the operator's description is too vague
154
157
 
155
158
  Once classified, take the matching action **inline** — execute it fully without stopping or returning control to the user:
156
159
 
157
- - **RFC** → invoke `/fo-idea-create-rfc`. It will collect metadata, grill the concept, create the file, fill it, validate, and report.
158
- - **ADR** → invoke `/fo-idea-create-adr`. It will collect metadata, grill the concept, create the file, fill it, validate, and report. **On the accepted-decision fast path (step 1a)**, tell `fo-idea-create-adr` to skip grilling and use the operator's justification text directly.
159
- - **Direct implementation** → tell the operator that no RFC or ADR is needed for this change, explain why (which Direct criterion applies), then **climb the minimality ladder** (see `_shared/fo-pipeline-conventions.md` §Minimality ladder) to determine the minimum implementation approach before writing any code. Present the ladder rung you landed on and proceed to implement. Do not create a governance document. The operator may still request an ADR for traceability if they prefer — respect that choice.
160
+ - **RFC** → invoke `/fo-idea-create-rfc` (GOVERNED mode). It will collect metadata, grill the concept, create the file, fill it, validate, and report.
161
+ - **ADR** → invoke `/fo-idea-create-adr` (GOVERNED mode). It will collect metadata, grill the concept, create the file, fill it, validate, and report. **On the accepted-decision fast path (step 1a)**, tell `fo-idea-create-adr` to skip grilling and use the operator's justification text directly.
162
+ - **Direct implementation** → tell the operator that no RFC or ADR is needed for this change (ROUTINE mode), explain why (which Direct criterion applies), then **climb the minimality ladder** (see `_shared/fo-pipeline-conventions.md` §Minimality ladder) to determine the minimum implementation approach before writing any code. Present the ladder rung you landed on and proceed to implement. Do not create a governance document. The operator may still request an ADR for traceability if they prefer — respect that choice.
160
163
 
161
164
  Do not duplicate the creation skill's work — just route to it and let it run.
162
165
 
@@ -57,6 +57,46 @@ test("unchanged when contents are identical", () => {
57
57
  expect(result.action).toBe("unchanged");
58
58
  });
59
59
 
60
+ test("does not report a conflict when duplicate entries are semantically identical", () => {
61
+ const src = join(tempDir, "qa-log.md");
62
+ const dest = join(tempDir, "dest.md");
63
+ const sourceEntry = entry("K-0001", "First", "Body one.");
64
+ const localEntry = sourceEntry.replace(
65
+ "layer: L0\ncreated: 2026-08-03",
66
+ "created: 2026-08-03\nlayer: L0",
67
+ );
68
+ writeFileSync(src, knowledgeFile("L0", [sourceEntry]), "utf8");
69
+ const localContent = knowledgeFile("L0", [localEntry]).replace(
70
+ "# Knowledge (L0)",
71
+ "# Project knowledge",
72
+ );
73
+ writeFileSync(dest, localContent, "utf8");
74
+
75
+ const plan = planKnowledgeSync(src, dest);
76
+
77
+ expect(plan.action).toBe("unchanged");
78
+ expect(plan.conflicts).toEqual([]);
79
+ expect(plan.content).toBeNull();
80
+ expect(readFileSync(dest, "utf8")).toBe(localContent);
81
+ });
82
+
83
+ test.each([
84
+ ["title", entry("K-0001", "Different title", "Body one.")],
85
+ ["body", entry("K-0001", "First", "Different body.")],
86
+ ["metadata", entry("K-0001", "First", "Body one.").replace("status: active", "status: stale")],
87
+ ] as const)("reports a conflict when duplicate entry %s differs", (_difference, sourceEntry) => {
88
+ const src = join(tempDir, "qa-log.md");
89
+ const dest = join(tempDir, "dest.md");
90
+ writeFileSync(src, knowledgeFile("L0", [sourceEntry]), "utf8");
91
+ writeFileSync(dest, knowledgeFile("L0", [entry("K-0001", "First", "Body one.")]), "utf8");
92
+
93
+ const plan = planKnowledgeSync(src, dest);
94
+
95
+ expect(plan.action).toBe("unchanged");
96
+ expect(plan.conflicts).toEqual(["K-0001"]);
97
+ expect(plan.content).toBeNull();
98
+ });
99
+
60
100
  test("merges: local entries preserved, new source entries appended", () => {
61
101
  const src = join(tempDir, "qa-log.md");
62
102
  const dest = join(tempDir, "dest.md");
@@ -20,7 +20,7 @@ import * as fs from "../utils/sync-fs.ts";
20
20
  import path from "node:path";
21
21
  import { parseKnowledgeFile } from "./parse.ts";
22
22
  import { serializeKnowledgeFile } from "./serialize.ts";
23
- import type { ParsedKnowledgeFile } from "./schema.ts";
23
+ import type { KnowledgeEntry, ParsedKnowledgeFile } from "./schema.ts";
24
24
 
25
25
  export type KnowledgeSyncAction = "copied" | "merged" | "unchanged" | "skipped";
26
26
 
@@ -28,7 +28,7 @@ export interface KnowledgeSyncResult {
28
28
  action: KnowledgeSyncAction;
29
29
  /** Entry IDs appended from the source file (merge only). */
30
30
  appended: string[];
31
- /** Entry IDs present in both files — the local version is always kept. */
31
+ /** Entry IDs present in both files with differing content — the local version is kept. */
32
32
  conflicts: string[];
33
33
  }
34
34
 
@@ -56,6 +56,16 @@ function isCumulative(parsed: ParsedKnowledgeFile): boolean {
56
56
  return !parsed.isKnowledgeAdjacent;
57
57
  }
58
58
 
59
+ function sameEntryContent(left: KnowledgeEntry, right: KnowledgeEntry): boolean {
60
+ const leftMeta = Object.entries(left.meta).sort(([a], [b]) => a.localeCompare(b));
61
+ const rightMeta = Object.entries(right.meta).sort(([a], [b]) => a.localeCompare(b));
62
+ return (
63
+ left.title === right.title &&
64
+ left.body === right.body &&
65
+ JSON.stringify(leftMeta) === JSON.stringify(rightMeta)
66
+ );
67
+ }
68
+
59
69
  function planFileSync(srcPath: string, destPath: string): KnowledgeSyncPlan {
60
70
  const none = { appended: [], conflicts: [] };
61
71
  if (!fs.existsSync(srcPath)) {
@@ -78,9 +88,14 @@ function planFileSync(srcPath: string, destPath: string): KnowledgeSyncPlan {
78
88
  // Both files use the cumulative K-NNNN format → append-only merge:
79
89
  // local entries always win; source entries with new IDs are appended.
80
90
  if (isCumulative(srcParsed) && isCumulative(destParsed)) {
81
- const destIds = new Set(destParsed.entries.map((e) => e.meta.id));
82
- const appendedEntries = srcParsed.entries.filter((e) => !destIds.has(e.meta.id));
83
- const conflicts = srcParsed.entries.filter((e) => destIds.has(e.meta.id)).map((e) => e.meta.id);
91
+ const destEntries = new Map(destParsed.entries.map((entry) => [entry.meta.id, entry]));
92
+ const appendedEntries = srcParsed.entries.filter((entry) => !destEntries.has(entry.meta.id));
93
+ const conflicts = srcParsed.entries
94
+ .filter((entry) => {
95
+ const localEntry = destEntries.get(entry.meta.id);
96
+ return localEntry !== undefined && !sameEntryContent(entry, localEntry);
97
+ })
98
+ .map((entry) => entry.meta.id);
84
99
 
85
100
  const destLegacyTexts = new Set(destParsed.legacySections.map((l) => l.text.trim()));
86
101
  const appendedLegacy = srcParsed.legacySections.filter(
@@ -11,6 +11,14 @@ When the operator expresses an intent in natural language, the agent routes to t
11
11
  {{triggersTable}}
12
12
  The agent uses judgment to calibrate routing — minor edits (typo fixes, small CSS changes) do not require skill invocation, while significant changes (new features, architectural decisions) do.
13
13
 
14
+ ### Work modes and completion vocabulary
15
+
16
+ Every task runs in one of three modes: **EXPLORE** (research, audits, prototyping — experiments are allowed, but only inside an isolated scope; no writes to durable repo surfaces), **ROUTINE** (bounded changes inside existing authority — implement and verify autonomously), **GOVERNED** (changes to requirements, contracts, or governance — RFC/ADR pipeline, human acceptance required). The agent selects the mode at task start and states it when the mode is GOVERNED or ambiguous.
17
+
18
+ The agent reports completion with separated vocabulary: **IMPLEMENTED** (code landed), **VERIFIED** (independent checks pass — probes, tests, validation), **ACCEPTED** (human or contract acceptance), **RELEASED** (shipped to consumers). A claim must never exceed the evidence behind it.
19
+
20
+ The full normative model — escalation triggers, verification tiers (STANDARD/HIGH/FORMAL), expectation sources, trust boundaries — lives in `skills/_shared/agent-operating-model.md`.
21
+
14
22
  ### Auto-grilling
15
23
 
16
24
  When the operator describes a significant idea or change, the agent SHOULD proactively invoke grilling to stress-test the plan before building.
@@ -6,11 +6,12 @@
6
6
  </non-goals>
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
- <item>RFC-0374: initial skillFrontmatterSchema with name, description, invocation, category, concerns, dependsOn, languagePolicy.</item>
10
9
  <item>RFC-0393: added optional bindings field (requires/optional arrays of binding keys).</item>
11
10
  <item>RFC-0523: expanded concerns enum from binary to four-level taxonomy (read-only | document-only | content-mutation | code-mutation).</item>
12
11
  <item>RFC-0524: added optional knowledge field (array of file names relative to SKILL.md directory).</item>
13
12
  <item>RFC-0548: added optional triggers field (array of natural-language trigger phrases, max 5 entries, each 5-100 chars) for intent-to-skill routing.</item>
13
+ <item>RFC-1271: added optional notApplicableWhen and costNotes fields — skill applicability metadata for mode-aware routing.</item>
14
+ <history>RFC-0374</history>
14
15
  </CHANGE_SUMMARY>
15
16
  */
16
17
 
@@ -35,6 +36,13 @@ export const skillFrontmatterSchema = z.object({
35
36
  // Windsurf) reserve `triggers` for invocation modes (user/model); a list of
36
37
  // phrases parses to zero valid modes and the skill is dropped entirely.
37
38
  triggerPhrases: z.array(z.string().min(5).max(100)).max(5).optional(),
39
+ // RFC-1271: declares when this skill must NOT run — routing skills (EXPLORE /
40
+ // ROUTINE / GOVERNED outcomes) use it to state exclusion conditions so an
41
+ // agent can skip them without reading the body.
42
+ notApplicableWhen: z.array(z.string().min(5).max(200)).optional(),
43
+ // RFC-1271: free-text cost notes (token/runtime cost, expected probe count) —
44
+ // documentation metadata only; consumers may ignore it.
45
+ costNotes: z.string().max(500).optional(),
38
46
  });
39
47
 
40
48
  export type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>;
@@ -149,6 +149,14 @@ When the operator expresses an intent in natural language, the agent routes to t
149
149
 
150
150
  The agent uses judgment to calibrate routing — minor edits (typo fixes, small CSS changes) do not require skill invocation, while significant changes (new features, architectural decisions) do.
151
151
 
152
+ ### Work modes and completion vocabulary
153
+
154
+ Every task runs in one of three modes: **EXPLORE** (research, audits, prototyping — experiments are allowed, but only inside an isolated scope; no writes to durable repo surfaces), **ROUTINE** (bounded changes inside existing authority — implement and verify autonomously), **GOVERNED** (changes to requirements, contracts, or governance — RFC/ADR pipeline, human acceptance required). The agent selects the mode at task start and states it when the mode is GOVERNED or ambiguous.
155
+
156
+ The agent reports completion with separated vocabulary: **IMPLEMENTED** (code landed), **VERIFIED** (independent checks pass — probes, tests, validation), **ACCEPTED** (human or contract acceptance), **RELEASED** (shipped to consumers). A claim must never exceed the evidence behind it.
157
+
158
+ The full normative model — escalation triggers, verification tiers (STANDARD/HIGH/FORMAL), expectation sources, trust boundaries — lives in `skills/_shared/agent-operating-model.md`.
159
+
152
160
  ### Auto-grilling
153
161
 
154
162
  When the operator describes a significant idea or change, the agent SHOULD proactively invoke grilling to stress-test the plan before building.
@@ -143,4 +143,43 @@ describe("skillFrontmatterSchema", () => {
143
143
  false,
144
144
  );
145
145
  });
146
+
147
+ test("accepts optional notApplicableWhen field (RFC-1271)", () => {
148
+ const result = skillFrontmatterSchema.safeParse({
149
+ ...valid,
150
+ notApplicableWhen: ["Idea already maps to an open RFC in docs/rfcs/."],
151
+ });
152
+ expect(result.success).toBe(true);
153
+ if (result.success) {
154
+ expect(result.data.notApplicableWhen).toEqual([
155
+ "Idea already maps to an open RFC in docs/rfcs/.",
156
+ ]);
157
+ }
158
+ });
159
+
160
+ test("rejects notApplicableWhen entries under 5 chars", () => {
161
+ expect(skillFrontmatterSchema.safeParse({ ...valid, notApplicableWhen: ["n/a"] }).success).toBe(
162
+ false,
163
+ );
164
+ });
165
+
166
+ test("accepts optional costNotes field (RFC-1271)", () => {
167
+ const result = skillFrontmatterSchema.safeParse({
168
+ ...valid,
169
+ costNotes: "Runs 3-5 probes; light token cost.",
170
+ });
171
+ expect(result.success).toBe(true);
172
+ if (result.success) {
173
+ expect(result.data.costNotes).toBe("Runs 3-5 probes; light token cost.");
174
+ }
175
+ });
176
+
177
+ test("accepts frontmatter without RFC-1271 optional fields", () => {
178
+ const result = skillFrontmatterSchema.safeParse(valid);
179
+ expect(result.success).toBe(true);
180
+ if (result.success) {
181
+ expect(result.data.notApplicableWhen).toBeUndefined();
182
+ expect(result.data.costNotes).toBeUndefined();
183
+ }
184
+ });
146
185
  });