@hassangameryt/freeflow 0.7.1 → 0.7.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.md +153 -128
- package/capabilities/cognitive-routing/SKILL.md +126 -274
- package/command-surface.json +7 -1
- package/gemini-extension.json +1 -1
- package/package.json +4 -4
- package/pi-extension/dist/cognitive-routing-v2/budget.js +42 -0
- package/pi-extension/dist/cognitive-routing-v2/config.js +136 -0
- package/pi-extension/dist/cognitive-routing-v2/projection.js +330 -0
- package/pi-extension/dist/cognitive-routing-v2/render.js +252 -0
- package/pi-extension/dist/cognitive-routing-v2/runtime.js +2181 -0
- package/pi-extension/dist/cognitive-routing-v2/schemas.js +173 -0
- package/pi-extension/dist/cognitive-routing-v2/state.js +828 -0
- package/pi-extension/dist/cognitive-routing-v2/tools.js +60 -0
- package/pi-extension/dist/cognitive-routing-v2/types.js +48 -0
- package/pi-extension/dist/context-virtualization/runtime.js +29 -7
- package/pi-extension/dist/freeflow-context/tool.js +12 -6
- package/pi-extension/dist/index.js +302 -626
- package/pi-extension/dist/provider-support/astra/adapter.js +110 -0
- package/pi-extension/dist/provider-support/astra/history.js +125 -0
- package/pi-extension/dist/provider-support/astra/index.js +11 -0
- package/pi-extension/dist/provider-support/astra/session-state.js +114 -0
- package/pi-extension/dist/provider-support/index.js +4 -0
- package/pi-extension/dist/runtime/request-history.js +216 -0
- package/pi-extension/dist/runtime/runtime-context.js +85 -16
- package/pi-extension/dist/session-sources/events.js +217 -0
- package/pi-extension/dist/session-sources/provenance.js +32 -0
- package/pi-extension/dist/session-sources/read-only-session.js +148 -0
- package/pi-extension/dist/session-sources/sources.js +277 -0
- package/pi-extension/dist/settings/settings-ui.js +274 -147
- package/pi-extension/src/cognitive-routing-v2/budget.ts +42 -0
- package/pi-extension/src/cognitive-routing-v2/config.ts +173 -0
- package/pi-extension/src/cognitive-routing-v2/projection.ts +375 -0
- package/pi-extension/src/cognitive-routing-v2/render.ts +277 -0
- package/pi-extension/src/cognitive-routing-v2/runtime.ts +2241 -0
- package/pi-extension/src/cognitive-routing-v2/schemas.ts +180 -0
- package/pi-extension/src/cognitive-routing-v2/state.ts +839 -0
- package/pi-extension/src/cognitive-routing-v2/tools.ts +62 -0
- package/pi-extension/src/cognitive-routing-v2/types.ts +254 -0
- package/pi-extension/src/context-virtualization/runtime.ts +30 -8
- package/pi-extension/src/freeflow-context/tool.ts +12 -6
- package/pi-extension/src/index.ts +308 -675
- package/pi-extension/src/provider-support/astra/adapter.ts +108 -0
- package/pi-extension/src/provider-support/astra/history.ts +145 -0
- package/pi-extension/src/provider-support/astra/index.ts +12 -0
- package/pi-extension/src/provider-support/astra/session-state.ts +113 -0
- package/pi-extension/src/provider-support/index.ts +5 -0
- package/pi-extension/src/runtime/request-history.ts +243 -0
- package/pi-extension/src/runtime/runtime-context.ts +100 -17
- package/pi-extension/src/session-sources/events.ts +230 -0
- package/pi-extension/src/session-sources/provenance.ts +39 -0
- package/pi-extension/src/session-sources/read-only-session.ts +170 -0
- package/pi-extension/src/session-sources/sources.ts +334 -0
- package/pi-extension/src/settings/settings-ui.ts +311 -158
- package/pi-extension/tests/cache-reuse/history.test.js +117 -0
- package/pi-extension/tests/cache-reuse/native.test.js +91 -0
- package/pi-extension/tests/cache-reuse/settings.test.js +211 -0
- package/pi-extension/tests/cognitive-routing-v2/communication.test.js +577 -0
- package/pi-extension/tests/cognitive-routing-v2/compaction-input.test.js +183 -0
- package/pi-extension/tests/cognitive-routing-v2/delegation.test.js +557 -0
- package/pi-extension/tests/cognitive-routing-v2/native.test.js +474 -0
- package/pi-extension/tests/cognitive-routing-v2/performance.test.js +87 -0
- package/pi-extension/tests/cognitive-routing-v2/persistence.test.js +300 -0
- package/pi-extension/tests/cognitive-routing-v2/projection.test.js +241 -0
- package/pi-extension/tests/cognitive-routing-v2/recovery.test.js +1034 -0
- package/pi-extension/tests/cognitive-routing-v2/render.test.js +244 -0
- package/pi-extension/tests/cognitive-routing-v2/runtime.test.js +423 -0
- package/pi-extension/tests/cognitive-routing-v2/stabilization.test.js +521 -0
- package/pi-extension/tests/cognitive-routing-v2/state.test.js +586 -0
- package/pi-extension/tests/context-virtualization/extension.test.js +33 -7
- package/pi-extension/tests/context-virtualization/runtime.test.js +17 -3
- package/pi-extension/tests/fixtures/routing-native.js +191 -0
- package/pi-extension/tests/integration/mode-free-core.test.js +6 -4
- package/pi-extension/tests/integration/pi-extension.test.js +655 -59
- package/pi-extension/tests/integration/prompt-architecture.test.js +127 -30
- package/pi-extension/tests/integration/unaffected-regressions.test.js +78 -11
- package/pi-extension/tests/provider-support/astra-boundaries.test.js +75 -0
- package/pi-extension/tests/provider-support/astra.test.js +306 -0
- package/pi-extension/tests/provider-support/cli.test.js +92 -0
- package/pi-extension/tests/provider-support/native.test.js +183 -0
- package/plugin.json +1 -1
- package/runtime/prompts/cognitive-routing.md +4 -5
- package/runtime/prompts/core.md +51 -45
- package/runtime/prompts/interaction-contract.md +5 -5
- package/skills/action-selection/SKILL.md +57 -97
- package/skills/design-for-depth/SKILL.md +58 -193
- package/skills/design-for-depth/references/implementation-decisions.md +76 -0
- package/skills/diagnose-failure/SKILL.md +64 -196
- package/skills/discuss/SKILL.md +64 -123
- package/skills/discuss/references/discussion-continuity.md +7 -3
- package/skills/execute-work/SKILL.md +69 -88
- package/skills/execute-work/references/execute-work-edges.md +9 -3
- package/skills/handoff/SKILL.md +44 -54
- package/skills/handoff/references/handoff-templates.md +15 -6
- package/skills/review-artifact/SKILL.md +80 -127
- package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +1 -1
- package/skills/review-work/SKILL.md +65 -115
- package/skills/review-work/references/independent-work-reviewer-contract.md +1 -1
- package/skills/simplify-code/SKILL.md +47 -100
- package/skills/track-work/SKILL.md +128 -119
- package/skills/track-work/references/working-record-format.md +14 -2
- package/skills/verify-work/SKILL.md +58 -62
- package/skills/verify-work/references/integration-evidence.md +4 -2
- package/skills/verify-work/references/test-design.md +89 -0
- package/skills/workflow/SKILL.md +73 -119
- package/skills/write-plan/SKILL.md +46 -77
- package/skills/write-plan/references/plan-shapes.md +5 -5
- package/skills/write-spec/SKILL.md +51 -63
- package/skills/write-spec/references/artifact-standards.md +2 -2
- package/skills/write-spec/references/decision-records.md +3 -2
- package/skills/write-spec/references/spec-shapes.md +15 -0
- package/pi-extension/dist/cognitive-routing/commands.js +0 -96
- package/pi-extension/dist/cognitive-routing/config.js +0 -232
- package/pi-extension/dist/cognitive-routing/controller.js +0 -1292
- package/pi-extension/dist/cognitive-routing/history.js +0 -451
- package/pi-extension/dist/cognitive-routing/host.js +0 -188
- package/pi-extension/dist/cognitive-routing/pi-routing-session.js +0 -414
- package/pi-extension/dist/cognitive-routing/pi-session-control.js +0 -320
- package/pi-extension/dist/cognitive-routing/runtime.js +0 -43
- package/pi-extension/dist/cognitive-routing/tool.js +0 -212
- package/pi-extension/dist/cognitive-routing/types.js +0 -6
- package/pi-extension/src/cognitive-routing/commands.ts +0 -129
- package/pi-extension/src/cognitive-routing/config.ts +0 -303
- package/pi-extension/src/cognitive-routing/controller.ts +0 -1628
- package/pi-extension/src/cognitive-routing/history.ts +0 -650
- package/pi-extension/src/cognitive-routing/host.ts +0 -266
- package/pi-extension/src/cognitive-routing/pi-routing-session.ts +0 -538
- package/pi-extension/src/cognitive-routing/pi-session-control.ts +0 -444
- package/pi-extension/src/cognitive-routing/runtime.ts +0 -57
- package/pi-extension/src/cognitive-routing/tool.ts +0 -273
- package/pi-extension/src/cognitive-routing/types.ts +0 -89
- package/pi-extension/tests/cognitive-routing/commands.test.js +0 -134
- package/pi-extension/tests/cognitive-routing/controller.test.js +0 -1128
- package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +0 -1142
- package/pi-extension/tests/cognitive-routing/history.test.js +0 -274
- package/pi-extension/tests/cognitive-routing/host-identity.test.js +0 -63
- package/pi-extension/tests/cognitive-routing/pi-normal-lifecycle.test.js +0 -434
- package/pi-extension/tests/cognitive-routing/pi-session-control.test.js +0 -174
- package/pi-extension/tests/cognitive-routing/pi-session-history.test.js +0 -91
- package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +0 -279
- package/pi-extension/tests/cognitive-routing/tool.test.js +0 -230
- package/skills/tdd/SKILL.md +0 -143
- package/skills/tdd/references/test-design.md +0 -96
- /package/pi-extension/tests/{cognitive-routing/host-fixture.js → fixtures/pi-host.js} +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { isObject } from "./types.js";
|
|
2
|
+
const string = (maxLength = 32768, description) => ({
|
|
3
|
+
type: "string",
|
|
4
|
+
minLength: 1,
|
|
5
|
+
maxLength,
|
|
6
|
+
...(description ? { description } : {}),
|
|
7
|
+
});
|
|
8
|
+
const object = (properties, required = Object.keys(properties), description, title) => ({
|
|
9
|
+
type: "object",
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
properties,
|
|
12
|
+
required,
|
|
13
|
+
...(description ? { description } : {}),
|
|
14
|
+
...(title ? { title } : {}),
|
|
15
|
+
});
|
|
16
|
+
const operation = (value, description) => ({
|
|
17
|
+
type: "string",
|
|
18
|
+
enum: [value],
|
|
19
|
+
...(description ? { description } : {}),
|
|
20
|
+
});
|
|
21
|
+
const evidenceRefs = (description) => ({
|
|
22
|
+
type: "array",
|
|
23
|
+
maxItems: 64,
|
|
24
|
+
items: string(512),
|
|
25
|
+
description,
|
|
26
|
+
});
|
|
27
|
+
const worker = {
|
|
28
|
+
type: "string",
|
|
29
|
+
enum: ["helper", "executor"],
|
|
30
|
+
description: "Worker for this assignment. Required when delegation mode enables both workers.",
|
|
31
|
+
};
|
|
32
|
+
const report = (name) =>
|
|
33
|
+
object(
|
|
34
|
+
{
|
|
35
|
+
operation: operation(name),
|
|
36
|
+
report: string(),
|
|
37
|
+
outcome: { type: "string", enum: ["completed", "partial", "blocked"] },
|
|
38
|
+
limitations: { type: "array", maxItems: 32, items: string(2048) },
|
|
39
|
+
},
|
|
40
|
+
["operation", "report", "outcome"],
|
|
41
|
+
);
|
|
42
|
+
export const ROUTING_SCHEMAS = {
|
|
43
|
+
freeflow_delegate: {
|
|
44
|
+
oneOf: [
|
|
45
|
+
object({ operation: operation("assign"), contract: string(), worker }, ["operation", "contract"]),
|
|
46
|
+
object({ operation: operation("replace"), contract: string(), reason: string(2048), worker }, [
|
|
47
|
+
"operation",
|
|
48
|
+
"contract",
|
|
49
|
+
"reason",
|
|
50
|
+
]),
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
freeflow_return: { oneOf: [report("submit"), report("supplement"), object({ operation: operation("retry") })] },
|
|
54
|
+
freeflow_unit: {
|
|
55
|
+
oneOf: [
|
|
56
|
+
object(
|
|
57
|
+
{
|
|
58
|
+
operation: operation("inspect"),
|
|
59
|
+
view: { type: "string", enum: ["current", "history", "detail"] },
|
|
60
|
+
ref: string(128),
|
|
61
|
+
cursor: string(128),
|
|
62
|
+
limit: { type: "integer", minimum: 1, maximum: 100 },
|
|
63
|
+
},
|
|
64
|
+
["operation"],
|
|
65
|
+
),
|
|
66
|
+
object({ operation: operation("assess") }),
|
|
67
|
+
object(
|
|
68
|
+
{
|
|
69
|
+
operation: operation("recover"),
|
|
70
|
+
request: string(),
|
|
71
|
+
paths: { type: "array", maxItems: 32, items: string(4096) },
|
|
72
|
+
},
|
|
73
|
+
["operation", "request"],
|
|
74
|
+
),
|
|
75
|
+
object({ operation: operation("cancel-recovery"), reason: string(2048) }),
|
|
76
|
+
object({
|
|
77
|
+
operation: operation("close"),
|
|
78
|
+
outcome: { type: "string", enum: ["accepted", "cancelled", "deferred"] },
|
|
79
|
+
assessment: string(),
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
freeflow_project: {
|
|
84
|
+
oneOf: [
|
|
85
|
+
object(
|
|
86
|
+
{
|
|
87
|
+
operation: operation("inspect", "Read current selection and offered evidence candidates."),
|
|
88
|
+
scope: {
|
|
89
|
+
type: "string",
|
|
90
|
+
enum: ["selected", "assignment", "active", "history"],
|
|
91
|
+
description: "Optional candidate scope; omit to inspect the current assignment.",
|
|
92
|
+
},
|
|
93
|
+
cursor: string(128, "Use the nextCursor returned by a previous inspection."),
|
|
94
|
+
},
|
|
95
|
+
["operation"],
|
|
96
|
+
"Inspect selection and candidates without changing evidence state.",
|
|
97
|
+
"Inspect evidence selection",
|
|
98
|
+
),
|
|
99
|
+
object(
|
|
100
|
+
{
|
|
101
|
+
operation: operation("add", "Select eligible worker task-evidence refs; do not include reason."),
|
|
102
|
+
refs: evidenceRefs(
|
|
103
|
+
"Exact eligible visible refs for worker task evidence. Add known eligible refs directly; inspect when identity, eligibility, representation, or selection state is unclear. Never add a ref marked not offered for new evidence selection.",
|
|
104
|
+
),
|
|
105
|
+
},
|
|
106
|
+
["operation", "refs"],
|
|
107
|
+
"Add evidence refs. This shape has no reason field.",
|
|
108
|
+
"Add evidence",
|
|
109
|
+
),
|
|
110
|
+
object(
|
|
111
|
+
{
|
|
112
|
+
operation: operation("remove", "Withdraw selected or unresolved refs; reason is required."),
|
|
113
|
+
refs: evidenceRefs(
|
|
114
|
+
"Currently selected or unresolved refs to withdraw. A non-selectable ref may be removed with a reason to clear its unresolved request.",
|
|
115
|
+
),
|
|
116
|
+
reason: string(2048, "Required only for remove; explain why the selection is being withdrawn."),
|
|
117
|
+
},
|
|
118
|
+
["operation", "refs", "reason"],
|
|
119
|
+
"Remove evidence refs. This is the only operation that accepts reason.",
|
|
120
|
+
"Remove evidence",
|
|
121
|
+
),
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
// Provider function schemas require an object root. Keep operation-specific branches
|
|
126
|
+
// for runtime validation without leaving the provider-facing root untyped.
|
|
127
|
+
for (const schema of Object.values(ROUTING_SCHEMAS)) {
|
|
128
|
+
schema.type = "object";
|
|
129
|
+
schema.additionalProperties = false;
|
|
130
|
+
schema.required = ["operation"];
|
|
131
|
+
schema.properties = Object.assign({}, ...schema.oneOf.map((branch) => branch.properties));
|
|
132
|
+
schema.properties.operation = {
|
|
133
|
+
type: "string",
|
|
134
|
+
enum: schema.oneOf.flatMap((branch) => branch.properties.operation.enum),
|
|
135
|
+
description: "Choose exactly one operation; each operation has a strict shape and rejects unknown fields.",
|
|
136
|
+
};
|
|
137
|
+
if (schema.properties.refs)
|
|
138
|
+
schema.properties.refs = {
|
|
139
|
+
...schema.properties.refs,
|
|
140
|
+
description:
|
|
141
|
+
"For add, use exact eligible visible refs directly when their identity and eligibility are clear; inspect when identity, eligibility, representation, or selection state is unclear. Never add refs marked not offered for new evidence selection. For remove, use currently selected or unresolved refs; a non-selectable ref may be named to clear its unresolved request and requires reason.",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export function matches(value, schema) {
|
|
145
|
+
if (schema.oneOf) return schema.oneOf.filter((branch) => matches(value, branch)).length === 1;
|
|
146
|
+
if (schema.enum && !schema.enum.includes(value)) return false;
|
|
147
|
+
if (schema.type === "object")
|
|
148
|
+
return (
|
|
149
|
+
isObject(value) &&
|
|
150
|
+
Object.keys(value).every((k) => schema.properties[k]) &&
|
|
151
|
+
schema.required.every((k) => Object.hasOwn(value, k)) &&
|
|
152
|
+
Object.entries(value).every(([k, v]) => matches(v, schema.properties[k]))
|
|
153
|
+
);
|
|
154
|
+
if (schema.type === "string")
|
|
155
|
+
return (
|
|
156
|
+
typeof value === "string" &&
|
|
157
|
+
value.length >= (schema.minLength ?? 0) &&
|
|
158
|
+
value.length <= (schema.maxLength ?? Infinity) &&
|
|
159
|
+
(!schema.pattern || new RegExp(schema.pattern).test(value))
|
|
160
|
+
);
|
|
161
|
+
if (schema.type === "array")
|
|
162
|
+
return Array.isArray(value) && value.length <= schema.maxItems && value.every((v) => matches(v, schema.items));
|
|
163
|
+
if (schema.type === "integer")
|
|
164
|
+
return Number.isSafeInteger(value) && value >= schema.minimum && value <= schema.maximum;
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
export function schemaForProfile(name, coordinator) {
|
|
168
|
+
const schema = ROUTING_SCHEMAS[name];
|
|
169
|
+
if (name !== "freeflow_unit" || coordinator) return schema;
|
|
170
|
+
const branches = schema.oneOf.filter((b) => b.properties.operation.enum[0] === "inspect");
|
|
171
|
+
const properties = Object.assign({}, ...branches.map((b) => b.properties));
|
|
172
|
+
return { ...schema, properties, oneOf: branches };
|
|
173
|
+
}
|