@foundocs/foundocs-setup 0.3.16 → 0.3.19
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/README.md +73 -1
- package/dist/bridge.mjs +319 -61
- package/package.json +3 -3
- package/skills/foundocs/SKILL.md +5 -1
- package/skills/foundocs/references/dreaming.md +11 -3
- package/skills/foundocs/references/effect-measurement.md +5 -3
- package/skills/foundocs/scripts/episode-checkpoint.mjs +207 -0
- package/skills/foundocs/scripts/session-start.mjs +17 -5
- package/skills/foundocs-capture-episode/SKILL.md +22 -0
- package/skills/foundocs-capture-episode/references/capture.md +60 -0
- package/src/bridge.mjs +49 -4
- package/src/cli.mjs +4 -4
- package/src/effect-codex-tools.mjs +41 -0
- package/src/effect-codex-worker.mjs +112 -0
- package/src/effect-codex.mjs +45 -0
- package/src/effect-host.mjs +86 -0
- package/src/effect-runner.mjs +13 -3
- package/src/effect-storage.mjs +1 -1
- package/src/effect.mjs +18 -10
- package/src/setup.mjs +80 -24
- package/src/skill-assets.mjs +3 -1
- package/templates/knowledge-policy.md +1 -0
package/dist/bridge.mjs
CHANGED
|
@@ -12994,9 +12994,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
12994
12994
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
12995
12995
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
12996
12996
|
}
|
|
12997
|
-
optimizeNames(names,
|
|
12997
|
+
optimizeNames(names, constants2) {
|
|
12998
12998
|
if (!names[this.name.str]) return;
|
|
12999
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names,
|
|
12999
|
+
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
13000
13000
|
return this;
|
|
13001
13001
|
}
|
|
13002
13002
|
get names() {
|
|
@@ -13013,9 +13013,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13013
13013
|
render({ _n }) {
|
|
13014
13014
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
13015
13015
|
}
|
|
13016
|
-
optimizeNames(names,
|
|
13016
|
+
optimizeNames(names, constants2) {
|
|
13017
13017
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
13018
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
13018
|
+
this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
13019
13019
|
return this;
|
|
13020
13020
|
}
|
|
13021
13021
|
get names() {
|
|
@@ -13074,8 +13074,8 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13074
13074
|
optimizeNodes() {
|
|
13075
13075
|
return `${this.code}` ? this : void 0;
|
|
13076
13076
|
}
|
|
13077
|
-
optimizeNames(names,
|
|
13078
|
-
this.code = optimizeExpr(this.code, names,
|
|
13077
|
+
optimizeNames(names, constants2) {
|
|
13078
|
+
this.code = optimizeExpr(this.code, names, constants2);
|
|
13079
13079
|
return this;
|
|
13080
13080
|
}
|
|
13081
13081
|
get names() {
|
|
@@ -13101,12 +13101,12 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13101
13101
|
}
|
|
13102
13102
|
return nodes.length > 0 ? this : void 0;
|
|
13103
13103
|
}
|
|
13104
|
-
optimizeNames(names,
|
|
13104
|
+
optimizeNames(names, constants2) {
|
|
13105
13105
|
const { nodes } = this;
|
|
13106
13106
|
let i = nodes.length;
|
|
13107
13107
|
while (i--) {
|
|
13108
13108
|
const n = nodes[i];
|
|
13109
|
-
if (n.optimizeNames(names,
|
|
13109
|
+
if (n.optimizeNames(names, constants2)) continue;
|
|
13110
13110
|
subtractNames(names, n.names);
|
|
13111
13111
|
nodes.splice(i, 1);
|
|
13112
13112
|
}
|
|
@@ -13153,11 +13153,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13153
13153
|
if (cond === false || !this.nodes.length) return void 0;
|
|
13154
13154
|
return this;
|
|
13155
13155
|
}
|
|
13156
|
-
optimizeNames(names,
|
|
13156
|
+
optimizeNames(names, constants2) {
|
|
13157
13157
|
var _a3;
|
|
13158
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
13159
|
-
if (!(super.optimizeNames(names,
|
|
13160
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
13158
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
13159
|
+
if (!(super.optimizeNames(names, constants2) || this.else)) return;
|
|
13160
|
+
this.condition = optimizeExpr(this.condition, names, constants2);
|
|
13161
13161
|
return this;
|
|
13162
13162
|
}
|
|
13163
13163
|
get names() {
|
|
@@ -13179,9 +13179,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13179
13179
|
render(opts) {
|
|
13180
13180
|
return `for(${this.iteration})` + super.render(opts);
|
|
13181
13181
|
}
|
|
13182
|
-
optimizeNames(names,
|
|
13183
|
-
if (!super.optimizeNames(names,
|
|
13184
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
13182
|
+
optimizeNames(names, constants2) {
|
|
13183
|
+
if (!super.optimizeNames(names, constants2)) return;
|
|
13184
|
+
this.iteration = optimizeExpr(this.iteration, names, constants2);
|
|
13185
13185
|
return this;
|
|
13186
13186
|
}
|
|
13187
13187
|
get names() {
|
|
@@ -13216,9 +13216,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13216
13216
|
render(opts) {
|
|
13217
13217
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
13218
13218
|
}
|
|
13219
|
-
optimizeNames(names,
|
|
13220
|
-
if (!super.optimizeNames(names,
|
|
13221
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
13219
|
+
optimizeNames(names, constants2) {
|
|
13220
|
+
if (!super.optimizeNames(names, constants2)) return;
|
|
13221
|
+
this.iterable = optimizeExpr(this.iterable, names, constants2);
|
|
13222
13222
|
return this;
|
|
13223
13223
|
}
|
|
13224
13224
|
get names() {
|
|
@@ -13257,11 +13257,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13257
13257
|
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
13258
13258
|
return this;
|
|
13259
13259
|
}
|
|
13260
|
-
optimizeNames(names,
|
|
13260
|
+
optimizeNames(names, constants2) {
|
|
13261
13261
|
var _a3, _b;
|
|
13262
|
-
super.optimizeNames(names,
|
|
13263
|
-
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names,
|
|
13264
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names,
|
|
13262
|
+
super.optimizeNames(names, constants2);
|
|
13263
|
+
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names, constants2);
|
|
13264
|
+
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants2);
|
|
13265
13265
|
return this;
|
|
13266
13266
|
}
|
|
13267
13267
|
get names() {
|
|
@@ -13510,7 +13510,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13510
13510
|
function addExprNames(names, from) {
|
|
13511
13511
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
13512
13512
|
}
|
|
13513
|
-
function optimizeExpr(expr, names,
|
|
13513
|
+
function optimizeExpr(expr, names, constants2) {
|
|
13514
13514
|
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
13515
13515
|
if (!canOptimize(expr)) return expr;
|
|
13516
13516
|
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
@@ -13520,13 +13520,13 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13520
13520
|
return items;
|
|
13521
13521
|
}, []));
|
|
13522
13522
|
function replaceName(n) {
|
|
13523
|
-
const c =
|
|
13523
|
+
const c = constants2[n.str];
|
|
13524
13524
|
if (c === void 0 || names[n.str] !== 1) return n;
|
|
13525
13525
|
delete names[n.str];
|
|
13526
13526
|
return c;
|
|
13527
13527
|
}
|
|
13528
13528
|
function canOptimize(e) {
|
|
13529
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
13529
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
|
|
13530
13530
|
}
|
|
13531
13531
|
}
|
|
13532
13532
|
function subtractNames(names, from) {
|
|
@@ -13559,9 +13559,9 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13559
13559
|
const codegen_1 = require_codegen();
|
|
13560
13560
|
const code_1 = require_code$1();
|
|
13561
13561
|
function toHash(arr) {
|
|
13562
|
-
const
|
|
13563
|
-
for (const item of arr)
|
|
13564
|
-
return
|
|
13562
|
+
const hash2 = {};
|
|
13563
|
+
for (const item of arr) hash2[item] = true;
|
|
13564
|
+
return hash2;
|
|
13565
13565
|
}
|
|
13566
13566
|
exports.toHash = toHash;
|
|
13567
13567
|
function alwaysValidSchema(it, schema) {
|
|
@@ -28585,9 +28585,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28585
28585
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
28586
28586
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
28587
28587
|
}
|
|
28588
|
-
optimizeNames(names,
|
|
28588
|
+
optimizeNames(names, constants2) {
|
|
28589
28589
|
if (!names[this.name.str]) return;
|
|
28590
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names,
|
|
28590
|
+
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
28591
28591
|
return this;
|
|
28592
28592
|
}
|
|
28593
28593
|
get names() {
|
|
@@ -28604,9 +28604,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28604
28604
|
render({ _n }) {
|
|
28605
28605
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
28606
28606
|
}
|
|
28607
|
-
optimizeNames(names,
|
|
28607
|
+
optimizeNames(names, constants2) {
|
|
28608
28608
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
28609
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
28609
|
+
this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
28610
28610
|
return this;
|
|
28611
28611
|
}
|
|
28612
28612
|
get names() {
|
|
@@ -28665,8 +28665,8 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28665
28665
|
optimizeNodes() {
|
|
28666
28666
|
return `${this.code}` ? this : void 0;
|
|
28667
28667
|
}
|
|
28668
|
-
optimizeNames(names,
|
|
28669
|
-
this.code = optimizeExpr(this.code, names,
|
|
28668
|
+
optimizeNames(names, constants2) {
|
|
28669
|
+
this.code = optimizeExpr(this.code, names, constants2);
|
|
28670
28670
|
return this;
|
|
28671
28671
|
}
|
|
28672
28672
|
get names() {
|
|
@@ -28692,12 +28692,12 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28692
28692
|
}
|
|
28693
28693
|
return nodes.length > 0 ? this : void 0;
|
|
28694
28694
|
}
|
|
28695
|
-
optimizeNames(names,
|
|
28695
|
+
optimizeNames(names, constants2) {
|
|
28696
28696
|
const { nodes } = this;
|
|
28697
28697
|
let i = nodes.length;
|
|
28698
28698
|
while (i--) {
|
|
28699
28699
|
const n = nodes[i];
|
|
28700
|
-
if (n.optimizeNames(names,
|
|
28700
|
+
if (n.optimizeNames(names, constants2)) continue;
|
|
28701
28701
|
subtractNames(names, n.names);
|
|
28702
28702
|
nodes.splice(i, 1);
|
|
28703
28703
|
}
|
|
@@ -28744,11 +28744,11 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28744
28744
|
if (cond === false || !this.nodes.length) return void 0;
|
|
28745
28745
|
return this;
|
|
28746
28746
|
}
|
|
28747
|
-
optimizeNames(names,
|
|
28747
|
+
optimizeNames(names, constants2) {
|
|
28748
28748
|
var _a3;
|
|
28749
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
28750
|
-
if (!(super.optimizeNames(names,
|
|
28751
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
28749
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
28750
|
+
if (!(super.optimizeNames(names, constants2) || this.else)) return;
|
|
28751
|
+
this.condition = optimizeExpr(this.condition, names, constants2);
|
|
28752
28752
|
return this;
|
|
28753
28753
|
}
|
|
28754
28754
|
get names() {
|
|
@@ -28770,9 +28770,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28770
28770
|
render(opts) {
|
|
28771
28771
|
return `for(${this.iteration})` + super.render(opts);
|
|
28772
28772
|
}
|
|
28773
|
-
optimizeNames(names,
|
|
28774
|
-
if (!super.optimizeNames(names,
|
|
28775
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
28773
|
+
optimizeNames(names, constants2) {
|
|
28774
|
+
if (!super.optimizeNames(names, constants2)) return;
|
|
28775
|
+
this.iteration = optimizeExpr(this.iteration, names, constants2);
|
|
28776
28776
|
return this;
|
|
28777
28777
|
}
|
|
28778
28778
|
get names() {
|
|
@@ -28807,9 +28807,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28807
28807
|
render(opts) {
|
|
28808
28808
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
28809
28809
|
}
|
|
28810
|
-
optimizeNames(names,
|
|
28811
|
-
if (!super.optimizeNames(names,
|
|
28812
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
28810
|
+
optimizeNames(names, constants2) {
|
|
28811
|
+
if (!super.optimizeNames(names, constants2)) return;
|
|
28812
|
+
this.iterable = optimizeExpr(this.iterable, names, constants2);
|
|
28813
28813
|
return this;
|
|
28814
28814
|
}
|
|
28815
28815
|
get names() {
|
|
@@ -28848,11 +28848,11 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
28848
28848
|
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
28849
28849
|
return this;
|
|
28850
28850
|
}
|
|
28851
|
-
optimizeNames(names,
|
|
28851
|
+
optimizeNames(names, constants2) {
|
|
28852
28852
|
var _a3, _b;
|
|
28853
|
-
super.optimizeNames(names,
|
|
28854
|
-
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names,
|
|
28855
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names,
|
|
28853
|
+
super.optimizeNames(names, constants2);
|
|
28854
|
+
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names, constants2);
|
|
28855
|
+
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants2);
|
|
28856
28856
|
return this;
|
|
28857
28857
|
}
|
|
28858
28858
|
get names() {
|
|
@@ -29101,7 +29101,7 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
29101
29101
|
function addExprNames(names, from) {
|
|
29102
29102
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
29103
29103
|
}
|
|
29104
|
-
function optimizeExpr(expr, names,
|
|
29104
|
+
function optimizeExpr(expr, names, constants2) {
|
|
29105
29105
|
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
29106
29106
|
if (!canOptimize(expr)) return expr;
|
|
29107
29107
|
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
@@ -29111,13 +29111,13 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
29111
29111
|
return items;
|
|
29112
29112
|
}, []));
|
|
29113
29113
|
function replaceName(n) {
|
|
29114
|
-
const c =
|
|
29114
|
+
const c = constants2[n.str];
|
|
29115
29115
|
if (c === void 0 || names[n.str] !== 1) return n;
|
|
29116
29116
|
delete names[n.str];
|
|
29117
29117
|
return c;
|
|
29118
29118
|
}
|
|
29119
29119
|
function canOptimize(e) {
|
|
29120
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
29120
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
|
|
29121
29121
|
}
|
|
29122
29122
|
}
|
|
29123
29123
|
function subtractNames(names, from) {
|
|
@@ -29150,9 +29150,9 @@ var require_util2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
29150
29150
|
const codegen_1 = require_codegen2();
|
|
29151
29151
|
const code_1 = require_code$12();
|
|
29152
29152
|
function toHash(arr) {
|
|
29153
|
-
const
|
|
29154
|
-
for (const item of arr)
|
|
29155
|
-
return
|
|
29153
|
+
const hash2 = {};
|
|
29154
|
+
for (const item of arr) hash2[item] = true;
|
|
29155
|
+
return hash2;
|
|
29156
29156
|
}
|
|
29157
29157
|
exports.toHash = toHash;
|
|
29158
29158
|
function alwaysValidSchema(it, schema) {
|
|
@@ -36131,8 +36131,218 @@ if (process.argv[1] && process.argv[2] === "--headers" && import.meta.url === pa
|
|
|
36131
36131
|
}
|
|
36132
36132
|
|
|
36133
36133
|
// src/bridge.mjs
|
|
36134
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
36135
|
+
import { resolve as resolve2, dirname as dirname2 } from "node:path";
|
|
36136
|
+
|
|
36137
|
+
// skills/foundocs/scripts/episode-checkpoint.mjs
|
|
36138
|
+
import { constants } from "node:fs";
|
|
36139
|
+
import { open as open2, mkdir, lstat as lstat2, readFile as readFile2, realpath, rename, rm } from "node:fs/promises";
|
|
36140
|
+
import { homedir } from "node:os";
|
|
36141
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
36142
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
36134
36143
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
36135
|
-
|
|
36144
|
+
var hash = (value) => createHash("sha256").update(value).digest("hex");
|
|
36145
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
36146
|
+
var TTL = 14 * 864e5;
|
|
36147
|
+
var MAX_CHECKPOINTS = 128;
|
|
36148
|
+
var MAX_OUTBOX = 32;
|
|
36149
|
+
var MAX_BYTES = 64 * 1024;
|
|
36150
|
+
var safeId = (value) => typeof value === "string" && value.length > 0 && value.length <= 200 && !/[\x00-\x1f]/.test(value);
|
|
36151
|
+
var unavailable = () => {
|
|
36152
|
+
throw new Error("unavailable");
|
|
36153
|
+
};
|
|
36154
|
+
async function privateDirectory(path) {
|
|
36155
|
+
if (process.platform === "win32") unavailable();
|
|
36156
|
+
let ancestor = path;
|
|
36157
|
+
while (dirname(ancestor) !== ancestor) {
|
|
36158
|
+
const st2 = await lstat2(ancestor).catch((e) => {
|
|
36159
|
+
if (e.code !== "ENOENT") throw e;
|
|
36160
|
+
return null;
|
|
36161
|
+
});
|
|
36162
|
+
if (st2 && (!st2.isDirectory() || st2.isSymbolicLink())) unavailable();
|
|
36163
|
+
ancestor = dirname(ancestor);
|
|
36164
|
+
}
|
|
36165
|
+
await mkdir(path, { recursive: true, mode: 448 });
|
|
36166
|
+
const st = await lstat2(path);
|
|
36167
|
+
if (st.mode & 63 || st.uid !== process.getuid()) unavailable();
|
|
36168
|
+
}
|
|
36169
|
+
async function readState(path) {
|
|
36170
|
+
let file;
|
|
36171
|
+
try {
|
|
36172
|
+
file = await open2(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
36173
|
+
const st = await file.stat();
|
|
36174
|
+
if (!st.isFile() || st.nlink !== 1 || st.mode & 63 || st.uid !== process.getuid() || st.size > 3 * 1024 * 1024) unavailable();
|
|
36175
|
+
return JSON.parse(await file.readFile("utf8"));
|
|
36176
|
+
} catch (e) {
|
|
36177
|
+
if (e.code === "ENOENT") return { checkpoints: [], outbox: [] };
|
|
36178
|
+
throw e;
|
|
36179
|
+
} finally {
|
|
36180
|
+
await file?.close();
|
|
36181
|
+
}
|
|
36182
|
+
}
|
|
36183
|
+
async function writeState(path, state) {
|
|
36184
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
36185
|
+
let file;
|
|
36186
|
+
try {
|
|
36187
|
+
file = await open2(temporary, "wx", 384);
|
|
36188
|
+
await file.writeFile(JSON.stringify(state));
|
|
36189
|
+
await file.sync();
|
|
36190
|
+
await file.close();
|
|
36191
|
+
file = null;
|
|
36192
|
+
await rename(temporary, path);
|
|
36193
|
+
} finally {
|
|
36194
|
+
await file?.close();
|
|
36195
|
+
await rm(temporary, { force: true });
|
|
36196
|
+
}
|
|
36197
|
+
}
|
|
36198
|
+
async function locked(directory, action) {
|
|
36199
|
+
const lock = join(directory, "checkpoint.lock");
|
|
36200
|
+
const file = await open2(lock, "wx", 384);
|
|
36201
|
+
try {
|
|
36202
|
+
await file.writeFile(String(process.pid));
|
|
36203
|
+
return await action();
|
|
36204
|
+
} finally {
|
|
36205
|
+
await file.close();
|
|
36206
|
+
await rm(lock, { force: true });
|
|
36207
|
+
}
|
|
36208
|
+
}
|
|
36209
|
+
function prune(state, now) {
|
|
36210
|
+
state.outbox = state.outbox.filter((c) => Number.isFinite(c.createdAt) && c.createdAt + TTL > now).slice(-MAX_OUTBOX);
|
|
36211
|
+
const needed = new Set(state.outbox.map((e) => e.checkpoint));
|
|
36212
|
+
const valid = state.checkpoints.filter((c) => Number.isFinite(c.createdAt) && (c.createdAt + TTL > now || needed.has(c.id)));
|
|
36213
|
+
const kept = valid.filter((c) => needed.has(c.id));
|
|
36214
|
+
state.checkpoints = [...kept, ...valid.filter((c) => !needed.has(c.id)).slice(-(MAX_CHECKPOINTS - kept.length))].sort((a, b) => a.createdAt - b.createdAt);
|
|
36215
|
+
}
|
|
36216
|
+
function reminder(checkpoint, client, fallback = false) {
|
|
36217
|
+
const prefix = client === "codex" ? ".agents" : ".claude";
|
|
36218
|
+
return `${fallback ? "One bounded Foundocs checkpoint follow-up. " : ""}Foundocs episode checkpoint: ${checkpoint.id}. Read ${prefix}/skills/foundocs-capture-episode/SKILL.md. During this task, retain only confirmed important decisions, verified results/discoveries, concrete blockers or milestones. Routine lookup/no new fact: local skip only. Before the final response, acknowledge via local MCP episode_checkpoint (operation skip for routine) or the installed episode-checkpoint.mjs helper; do not upload prompts/transcripts or start another model. Missing tools, opt-out or failure must not delay the user task. ${fallback ? "Do this once; do not repeat the user answer or continue just for bookkeeping." : ""}`;
|
|
36219
|
+
}
|
|
36220
|
+
function captureInput(input, checkpoint, slot, projectId, now) {
|
|
36221
|
+
const capture = structuredClone(input);
|
|
36222
|
+
if (!capture || typeof capture !== "object" || Array.isArray(capture)) unavailable();
|
|
36223
|
+
const allowed = ["event", "candidateId", "sourceChangeId", "judgment", "episode", "expectedEpisodeVersion", "expectedCandidateVersion", "correction"];
|
|
36224
|
+
if (Object.keys(capture).some((key) => !allowed.includes(key))) unavailable();
|
|
36225
|
+
if (Boolean(capture.event) === Boolean(capture.candidateId)) unavailable();
|
|
36226
|
+
if (!Number.isInteger(capture.expectedEpisodeVersion) || capture.expectedEpisodeVersion < 0) unavailable();
|
|
36227
|
+
if (capture.event) {
|
|
36228
|
+
if (!safeId(capture.event.taskKey) || !safeId(capture.event.boundaryKey)) unavailable();
|
|
36229
|
+
const eventAllowed = ["taskKey", "boundaryKey", "kind", "observation", "occurredAt", "evidence", "links"];
|
|
36230
|
+
if (Object.keys(capture.event).some((key) => !eventAllowed.includes(key))) unavailable();
|
|
36231
|
+
capture.event.sourceEventId = `host:${checkpoint.id}:${slot}`;
|
|
36232
|
+
capture.event.sessionId = checkpoint.sessionId;
|
|
36233
|
+
capture.event.occurredAt ??= new Date(now).toISOString();
|
|
36234
|
+
if (typeof capture.event.observation !== "string" || capture.event.observation.length > 3e3 || !Array.isArray(capture.event.evidence) || capture.event.evidence.length > 20 || !Array.isArray(capture.event.links) || capture.event.links.length > 20) unavailable();
|
|
36235
|
+
if (capture.event.evidence.some((e) => typeof e.detail !== "string" || e.detail.length > 1e3)) unavailable();
|
|
36236
|
+
}
|
|
36237
|
+
return { ...capture, project_id: projectId, requestId: randomUUID() };
|
|
36238
|
+
}
|
|
36239
|
+
async function episodeCheckpoint(command, rootPath, input, options = {}) {
|
|
36240
|
+
if (Buffer.byteLength(JSON.stringify(input)) > 1024 * 1024) unavailable();
|
|
36241
|
+
const root = await realpath(rootPath);
|
|
36242
|
+
if (!isAbsolute(rootPath)) unavailable();
|
|
36243
|
+
const config2 = JSON.parse(await readFile2(join(root, "foundocs.json"), "utf8"));
|
|
36244
|
+
if (!UUID.test(config2.project_id) || options.projectId && config2.project_id !== options.projectId) unavailable();
|
|
36245
|
+
if (config2.episodes?.enabled === false || process.env.FOUNDOCS_EPISODES === "off") return { status: "disabled" };
|
|
36246
|
+
const client = options.client;
|
|
36247
|
+
if (!["codex", "claude"].includes(client)) return { status: "unsupported_host" };
|
|
36248
|
+
const base = options.storageDir ?? process.env.FOUNDOCS_SETUP_HOME ?? join(homedir(), ".local/share/foundocs/setup");
|
|
36249
|
+
if (!isAbsolute(base)) unavailable();
|
|
36250
|
+
const directory = join(base, "episodes", hash(root));
|
|
36251
|
+
await privateDirectory(directory);
|
|
36252
|
+
return locked(directory, async () => {
|
|
36253
|
+
const path = join(directory, "checkpoints.json"), state = await readState(path), now = options.now ?? Date.now();
|
|
36254
|
+
if (!Array.isArray(state.checkpoints) || !Array.isArray(state.outbox)) unavailable();
|
|
36255
|
+
const counts = [state.checkpoints.length, state.outbox.length];
|
|
36256
|
+
prune(state, now);
|
|
36257
|
+
if (state.checkpoints.length !== counts[0] || state.outbox.length !== counts[1]) await writeState(path, state);
|
|
36258
|
+
let output;
|
|
36259
|
+
if (command === "hook") {
|
|
36260
|
+
if (!safeId(input.session_id) || input.agent_id || input.agent_type || input.stop_hook_active) return null;
|
|
36261
|
+
if (!["UserPromptSubmit", "Stop"].includes(input.hook_event_name)) return null;
|
|
36262
|
+
let checkpoint = state.checkpoints.findLast((c) => c.sessionId === input.session_id);
|
|
36263
|
+
if (input.hook_event_name === "UserPromptSubmit") {
|
|
36264
|
+
if (checkpoint?.fallbackIssued && typeof input.prompt === "string" && input.prompt.startsWith("One bounded Foundocs checkpoint follow-up. ")) return null;
|
|
36265
|
+
const id = client === "codex" && safeId(input.turn_id) ? hash(`${input.session_id}:${input.turn_id}`).slice(0, 40) : randomUUID();
|
|
36266
|
+
checkpoint = state.checkpoints.find((c) => c.id === id);
|
|
36267
|
+
if (!checkpoint) {
|
|
36268
|
+
checkpoint = { id, sessionId: input.session_id, ...safeId(input.turn_id) ? { turnId: input.turn_id } : {}, client, createdAt: now, acknowledged: false, fallbackIssued: false };
|
|
36269
|
+
state.checkpoints.push(checkpoint);
|
|
36270
|
+
}
|
|
36271
|
+
output = { hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: reminder(checkpoint, client) } };
|
|
36272
|
+
} else {
|
|
36273
|
+
if (!checkpoint || checkpoint.acknowledged || checkpoint.fallbackIssued || client === "codex" && checkpoint.turnId !== input.turn_id) return null;
|
|
36274
|
+
checkpoint.fallbackIssued = true;
|
|
36275
|
+
const context = reminder(checkpoint, client, true);
|
|
36276
|
+
output = client === "claude" ? { hookSpecificOutput: { hookEventName: "Stop", additionalContext: context } } : { decision: "block", reason: context };
|
|
36277
|
+
}
|
|
36278
|
+
} else {
|
|
36279
|
+
const checkpoint = state.checkpoints.find((c) => c.id === input.checkpoint);
|
|
36280
|
+
if (!checkpoint) return { status: "checkpoint_unavailable" };
|
|
36281
|
+
if (command === "skip") {
|
|
36282
|
+
checkpoint.acknowledged = true;
|
|
36283
|
+
output = { status: "acknowledged", pending: state.outbox.filter((e) => e.checkpoint === checkpoint.id).length };
|
|
36284
|
+
} else if (command === "prepare") {
|
|
36285
|
+
if (typeof input.slot !== "string" || !/^[a-z0-9_-]{1,40}$/.test(input.slot)) unavailable();
|
|
36286
|
+
const settled = checkpoint.settled?.find((entry) => entry.slot === input.slot);
|
|
36287
|
+
if (settled) return { status: settled.inputHash === hash(JSON.stringify(input.capture)) ? "already_acknowledged" : "payload_conflict", requestId: settled.requestId, disposition: settled.disposition };
|
|
36288
|
+
if ((checkpoint.settled ?? []).length >= 32) return { status: "checkpoint_full" };
|
|
36289
|
+
const previous = state.outbox.find((e) => e.checkpoint === checkpoint.id && e.slot === input.slot);
|
|
36290
|
+
if (previous) {
|
|
36291
|
+
if (previous.inputHash !== hash(JSON.stringify(input.capture))) return { status: "payload_conflict", requestId: previous.payload.requestId };
|
|
36292
|
+
output = { status: "prepared", payload: previous.payload };
|
|
36293
|
+
} else {
|
|
36294
|
+
if (checkpoint.createdAt + TTL <= now) return { status: "checkpoint_expired" };
|
|
36295
|
+
if (state.outbox.length >= MAX_OUTBOX) return { status: "outbox_full" };
|
|
36296
|
+
const payload = captureInput(input.capture, checkpoint, input.slot, config2.project_id, now);
|
|
36297
|
+
if (Buffer.byteLength(JSON.stringify(payload)) > MAX_BYTES) unavailable();
|
|
36298
|
+
state.outbox.push({ checkpoint: checkpoint.id, slot: input.slot, inputHash: hash(JSON.stringify(input.capture)), payload, createdAt: now });
|
|
36299
|
+
output = { status: "prepared", payload };
|
|
36300
|
+
}
|
|
36301
|
+
checkpoint.acknowledged = true;
|
|
36302
|
+
} else if (command === "ack") {
|
|
36303
|
+
const entry = state.outbox.find((e) => e.checkpoint === checkpoint.id && e.payload.requestId === input.requestId);
|
|
36304
|
+
if (!entry) return { status: "request_unavailable" };
|
|
36305
|
+
if (!["created", "updated", "corrected", "deferred", "skipped", "unchanged"].includes(input.result?.disposition) || !UUID.test(input.result?.candidate?.id)) unavailable();
|
|
36306
|
+
checkpoint.settled ??= [];
|
|
36307
|
+
checkpoint.settled.push({ slot: entry.slot, inputHash: entry.inputHash, requestId: entry.payload.requestId, disposition: input.result.disposition });
|
|
36308
|
+
state.outbox = state.outbox.filter((e) => e !== entry);
|
|
36309
|
+
checkpoint.acknowledged = true;
|
|
36310
|
+
output = { status: "acknowledged", disposition: input.result.disposition };
|
|
36311
|
+
} else if (command === "pending") {
|
|
36312
|
+
output = { status: "pending", items: state.outbox.slice(0, 3).map((e) => ({ checkpoint: e.checkpoint, slot: e.slot, payload: e.payload })) };
|
|
36313
|
+
} else if (command === "discard") {
|
|
36314
|
+
state.outbox = state.outbox.filter((e) => e.payload.requestId !== input.requestId || e.checkpoint !== checkpoint.id);
|
|
36315
|
+
checkpoint.acknowledged = true;
|
|
36316
|
+
output = { status: "discarded" };
|
|
36317
|
+
} else unavailable();
|
|
36318
|
+
}
|
|
36319
|
+
prune(state, now);
|
|
36320
|
+
await writeState(path, state);
|
|
36321
|
+
return output;
|
|
36322
|
+
});
|
|
36323
|
+
}
|
|
36324
|
+
if (process.argv[1]?.endsWith("episode-checkpoint.mjs") && pathToFileURL2(process.argv[1]).href === import.meta.url) {
|
|
36325
|
+
const [command, flag, root] = process.argv.slice(2);
|
|
36326
|
+
let output;
|
|
36327
|
+
try {
|
|
36328
|
+
if (flag !== "--root" || !isAbsolute(root)) unavailable();
|
|
36329
|
+
const script = await realpath(process.argv[1]), canonical = await realpath(root);
|
|
36330
|
+
const client = ["codex", "claude"].find((c) => script === join(canonical, c === "codex" ? ".agents" : ".claude", "skills/foundocs/scripts/episode-checkpoint.mjs"));
|
|
36331
|
+
let text = "";
|
|
36332
|
+
for await (const chunk of process.stdin) {
|
|
36333
|
+
text += chunk;
|
|
36334
|
+
if (Buffer.byteLength(text) > 1024 * 1024) unavailable();
|
|
36335
|
+
}
|
|
36336
|
+
output = await episodeCheckpoint(command, root, JSON.parse(text), { client });
|
|
36337
|
+
} catch {
|
|
36338
|
+
output = command === "hook" ? null : { status: "unavailable" };
|
|
36339
|
+
}
|
|
36340
|
+
if (command === "hook" && !output?.hookSpecificOutput && !output?.decision) output = null;
|
|
36341
|
+
if (output) process.stdout.write(`${JSON.stringify(output)}
|
|
36342
|
+
`);
|
|
36343
|
+
}
|
|
36344
|
+
|
|
36345
|
+
// src/bridge.mjs
|
|
36136
36346
|
function requestError(error2, name) {
|
|
36137
36347
|
const tool = typeof name === "string" && /^[a-z][a-z0-9_]{0,63}$/i.test(name) ? name : void 0;
|
|
36138
36348
|
let code = "REQUEST_FAILED", retryable = false, message = "The MCP request failed. Run foundocs-setup doctor for connection diagnostics.";
|
|
@@ -36180,8 +36390,22 @@ function requestError(error2, name) {
|
|
|
36180
36390
|
{ code, retryable, ...tool ? { tool } : {}, ...httpStatus !== void 0 ? { httpStatus } : {}, ...remoteCode !== void 0 ? { remoteCode } : {} }
|
|
36181
36391
|
);
|
|
36182
36392
|
}
|
|
36183
|
-
async function runBridge({ credentialPath, projectId, workspaceId, mcpUrl: endpoint }) {
|
|
36184
|
-
let remote, local;
|
|
36393
|
+
async function runBridge({ credentialPath, projectId, workspaceId, mcpUrl: endpoint, root, client }) {
|
|
36394
|
+
let remote, local, checkpointRoute = "remote", checkpointWasLocal = false;
|
|
36395
|
+
const checkpointTool = {
|
|
36396
|
+
name: "episode_checkpoint",
|
|
36397
|
+
description: "Local installer checkpoint bookkeeping, not remote capture. Use the ID delivered by the trusted UserPromptSubmit/Stop hook. Routine turns: skip only. Important event: prepare persists an exact private payload, call remote capture_episode with returned payload, then ack the successful result. Pending returns at most 3 exact retries. Never use this as semantic evidence or put transcripts/secrets in capture. No model/network invocation; failures never block the primary task.",
|
|
36398
|
+
inputSchema: { type: "object", additionalProperties: false, required: ["project_id", "operation", "checkpoint"], properties: {
|
|
36399
|
+
project_id: { type: "string", format: "uuid" },
|
|
36400
|
+
operation: { type: "string", enum: ["prepare", "ack", "skip", "pending", "discard"] },
|
|
36401
|
+
checkpoint: { type: "string", maxLength: 200 },
|
|
36402
|
+
slot: { type: "string", pattern: "^[a-z0-9_-]{1,40}$" },
|
|
36403
|
+
capture: { type: "object" },
|
|
36404
|
+
requestId: { type: "string", format: "uuid" },
|
|
36405
|
+
result: { type: "object" }
|
|
36406
|
+
} },
|
|
36407
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false, idempotentHint: false }
|
|
36408
|
+
};
|
|
36185
36409
|
async function close() {
|
|
36186
36410
|
await remote?.close().catch(() => {
|
|
36187
36411
|
});
|
|
@@ -36204,13 +36428,47 @@ async function runBridge({ credentialPath, projectId, workspaceId, mcpUrl: endpo
|
|
|
36204
36428
|
local = new Server({ name: "foundocs", version: "0.2.0" }, { capabilities: { tools: {} }, instructions: remote.getInstructions() });
|
|
36205
36429
|
local.setRequestHandler("tools/list", async (request) => {
|
|
36206
36430
|
try {
|
|
36207
|
-
|
|
36431
|
+
const tools = [], seen = /* @__PURE__ */ new Set();
|
|
36432
|
+
let cursor;
|
|
36433
|
+
for (let page = 0; page < 20; page++) {
|
|
36434
|
+
const result = await remote.listTools(cursor ? { cursor } : void 0);
|
|
36435
|
+
tools.push(...result.tools);
|
|
36436
|
+
if (tools.length > 2e3) throw new Error("tool inventory exceeds bound");
|
|
36437
|
+
if (!result.nextCursor) {
|
|
36438
|
+
const collision = tools.some((tool) => tool.name === checkpointTool.name);
|
|
36439
|
+
const supported = !!root && ["codex", "claude"].includes(client) && tools.some((tool) => tool.name === "capture_episode") && !collision;
|
|
36440
|
+
checkpointRoute = supported ? "local" : checkpointWasLocal ? "blocked" : "remote";
|
|
36441
|
+
if (supported) {
|
|
36442
|
+
checkpointWasLocal = true;
|
|
36443
|
+
tools.push(checkpointTool);
|
|
36444
|
+
}
|
|
36445
|
+
return { tools: checkpointRoute === "blocked" ? tools.filter((tool) => tool.name !== checkpointTool.name) : tools };
|
|
36446
|
+
}
|
|
36447
|
+
if (seen.has(result.nextCursor)) throw new Error("tool cursor loop");
|
|
36448
|
+
seen.add(result.nextCursor);
|
|
36449
|
+
cursor = result.nextCursor;
|
|
36450
|
+
}
|
|
36451
|
+
throw new Error("tool inventory exceeds page bound");
|
|
36208
36452
|
} catch (error2) {
|
|
36209
36453
|
throw requestError(error2, "tools_list");
|
|
36210
36454
|
}
|
|
36211
36455
|
});
|
|
36212
36456
|
local.setRequestHandler("tools/call", async (request) => {
|
|
36213
36457
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(request.params.arguments?.project_id)) throw new ProtocolError3(ProtocolErrorCode2.InvalidParams, "Read and pass the explicit project_id from the governing foundocs.json.");
|
|
36458
|
+
if (checkpointRoute !== "remote" && request.params.name === checkpointTool.name) {
|
|
36459
|
+
const args = request.params.arguments;
|
|
36460
|
+
if (args.project_id !== projectId) throw new ProtocolError3(ProtocolErrorCode2.InvalidParams, "Local checkpoint project differs from this installation.");
|
|
36461
|
+
let data;
|
|
36462
|
+
try {
|
|
36463
|
+
if (checkpointRoute !== "local" || !["prepare", "ack", "skip", "pending", "discard"].includes(args.operation)) throw new Error();
|
|
36464
|
+
const storageDir = dirname2(dirname2(dirname2(dirname2(dirname2(credentialPath)))));
|
|
36465
|
+
data = await episodeCheckpoint(args.operation, root, args, { client, storageDir, projectId });
|
|
36466
|
+
} catch {
|
|
36467
|
+
data = { status: "unavailable" };
|
|
36468
|
+
}
|
|
36469
|
+
const response = { ok: true, data };
|
|
36470
|
+
return { structuredContent: response, content: [{ type: "text", text: JSON.stringify(response) }], isError: false };
|
|
36471
|
+
}
|
|
36214
36472
|
try {
|
|
36215
36473
|
return await remote.callTool(request.params);
|
|
36216
36474
|
} catch (error2) {
|
|
@@ -36233,7 +36491,7 @@ async function runBridge({ credentialPath, projectId, workspaceId, mcpUrl: endpo
|
|
|
36233
36491
|
process.exitCode = 1;
|
|
36234
36492
|
}
|
|
36235
36493
|
}
|
|
36236
|
-
if (process.argv[1] && import.meta.url ===
|
|
36494
|
+
if (process.argv[1] && import.meta.url === pathToFileURL3(resolve2(process.argv[1])).href) {
|
|
36237
36495
|
const [credentialPath, projectId, workspaceId, mcpUrl] = process.argv.slice(2);
|
|
36238
36496
|
await runBridge({ credentialPath, projectId, workspaceId, mcpUrl });
|
|
36239
36497
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundocs/foundocs-setup",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "Repeatable project setup and agent skills for the Foundocs remote MCP server",
|
|
5
5
|
"foundocsRelease": {
|
|
6
|
-
"summary": "
|
|
6
|
+
"summary": "Capture important work episodes through bounded Codex and Claude Code checkpoints, with private exact retries and focused recall."
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build": "node build.mjs",
|
|
27
27
|
"prepack": "node build.mjs",
|
|
28
28
|
"test": "node build.mjs && node --test test/*.test.mjs",
|
|
29
|
-
"typecheck": "node --check eval/evaluate-trace.mjs && node --check eval/product-archive-check.mjs && node --check src/cli.mjs && node --check src/setup.mjs && node --check src/auth.mjs && node --check src/bridge.mjs && node --check src/legacy-compat.mjs && node --check src/skill-assets.mjs && node --check src/runtime.mjs && node --check skills/foundocs/scripts/check-update.mjs && node --check skills/foundocs/scripts/session-start.mjs && node --check src/effect.mjs && node --check src/effect-core.mjs && node --check src/effect-storage.mjs && node --check src/effect-runner.mjs && node --check src/effect-remote.mjs && node --check src/effect-watchdog.mjs && node --check eval/effect-api-check.mjs && node --check eval/effect-isolation-check.mjs"
|
|
29
|
+
"typecheck": "node --check eval/evaluate-trace.mjs && node --check eval/product-archive-check.mjs && node --check src/cli.mjs && node --check src/setup.mjs && node --check src/auth.mjs && node --check src/bridge.mjs && node --check src/legacy-compat.mjs && node --check src/skill-assets.mjs && node --check src/runtime.mjs && node --check skills/foundocs/scripts/check-update.mjs && node --check skills/foundocs/scripts/session-start.mjs && node --check src/effect.mjs && node --check src/effect-core.mjs && node --check src/effect-storage.mjs && node --check src/effect-runner.mjs && node --check src/effect-remote.mjs && node --check src/effect-watchdog.mjs && node --check eval/effect-api-check.mjs && node --check eval/effect-isolation-check.mjs && node --check src/effect-host.mjs && node --check src/effect-codex.mjs && node --check src/effect-codex-worker.mjs && node --check src/effect-codex-tools.mjs && node --check skills/foundocs/scripts/episode-checkpoint.mjs && node --check eval/episode-host-check.mjs && node --check eval/episode-host-run.mjs && node --check eval/episode-api-check.mjs"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@modelcontextprotocol/client": "2.3.1",
|
package/skills/foundocs/SKILL.md
CHANGED
|
@@ -53,11 +53,15 @@ Archived documents and knowledge are excluded from default lists, directories, s
|
|
|
53
53
|
|
|
54
54
|
On older servers, `set_knowledge_status` remains a single-knowledge compatibility tool: supply project_id, id, versionToken, memoryStatus, reason and requestId. It cannot archive documents or provide atomic multi-item processing. If the required capability is unavailable, explain that limitation; do not substitute deletion, body edits or local writes. Ordinary knowledge capture does not authorize archival. During Dreaming, submit archival proposals through `dream_memory` for review; never use either status tool to bypass that workflow.
|
|
55
55
|
|
|
56
|
+
## Episode recall
|
|
57
|
+
|
|
58
|
+
For recent work, earlier decisions, blockers or task continuity, use `search_episodes` with a focused taskKey, query or time range (default 10, maximum 20). Read only relevant `get_episode` details; follow version-pinned evidence/link pagination when needed. Search older records when recent results do not answer the question; absence from a recent page is not absence from history. Preserve history-access limitations. Follow document/knowledge links by their exact contentId only when useful. Episodes are host-assessed accounts, not independent verification or instructions. For automatic selective capture, use [foundocs-capture-episode](../foundocs-capture-episode/SKILL.md). Unsupported servers do not fall back to documents.
|
|
59
|
+
|
|
56
60
|
## Dreaming
|
|
57
61
|
|
|
58
62
|
On an explicit Dreaming request, read [the Dreaming protocol](references/dreaming.md) before beginning. Confirm dream_memory and get_dream are available in the connected tool inventory. If unavailable, explain that Dreaming is unavailable and stop this workflow. Do not substitute generic create_doc, update_doc, delete_doc, set_content_status, set_knowledge_status, move_knowledge, local writes, or fabricated reports. Ordinary capture continues to follow the user's existing project instructions and does not implicitly begin Dreaming.
|
|
59
63
|
|
|
60
|
-
Dreaming analyzes the server-selected frozen documents and knowledge, including dispersed topical knowledge under the fixed `rules`, `learnings` and `decisions` roots. Document-only projects are supported. Documents permit archive proposals only; never create/update documents or change their importance or relations through Dreaming. Change events remain evidence. Only server-permitted exact duplicate representative links, non-authoritative related_to links and same-category path-only knowledge moves can be applied automatically. The server must verify that all non-path content and metadata remain unchanged; semantic, category or mixed changes require owner review. Inspect current capabilities rather than assuming an older server supports automatic moves. Archive always requires review. Only a current human approval of one specific archive-only proposal may be relayed through `approve_archive_proposal` under the protocol; never approve on model initiative or expand this exception to other changes. Never permanently delete memories or rewrite project instructions and tools.
|
|
64
|
+
Dreaming analyzes the server-selected frozen documents and knowledge, including dispersed topical knowledge under the fixed `rules`, `learnings` and `decisions` roots. Document-only projects are supported. Documents permit archive proposals only; never create/update documents or change their importance or relations through Dreaming. Change events remain evidence. Only server-permitted exact duplicate representative links, non-authoritative related_to links and same-category path-only knowledge moves can be applied automatically. The server must verify that all non-path content and metadata remain unchanged; semantic, category or mixed changes require owner review. Inspect current capabilities rather than assuming an older server supports automatic moves. Archive review includes content-grounded low future reuse value: factually correct but unnecessary knowledge can be proposed without retrieval history, while rare but useful rules, decisions and recovery lessons remain protected. Archive always requires review. Only a current human approval of one specific archive-only proposal may be relayed through `approve_archive_proposal` under the protocol; never approve on model initiative or expand this exception to other changes. Never permanently delete memories or rewrite project instructions and tools.
|
|
61
65
|
|
|
62
66
|
Persist progress and report server-confirmed results in the user's language. Analysis can finish with review still pending. A blocked, interrupted, or partly inspected run must not be presented as a successful full review.
|
|
63
67
|
|