opencode-swarm 7.88.4 → 7.90.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.
- package/.opencode/skills/commit-pr/SKILL.md +548 -0
- package/.opencode/skills/engineering-conventions/SKILL.md +57 -0
- package/.opencode/skills/phase-wrap/SKILL.md +1 -1
- package/.opencode/skills/running-tests/SKILL.md +282 -0
- package/.opencode/skills/writing-tests/SKILL.md +794 -0
- package/dist/cli/{guardrail-explain-xe0wjnxz.js → guardrail-explain-han9f51y.js} +4 -4
- package/dist/cli/{index-rh53rrpt.js → index-1ccnwh54.js} +16 -13
- package/dist/cli/{index-e8pk68cc.js → index-axwxkbdd.js} +166 -23
- package/dist/cli/{index-hs2knbfq.js → index-mz2z7jtn.js} +599 -260
- package/dist/cli/{index-d4hpgf63.js → index-prppjv2q.js} +1 -1
- package/dist/cli/{index-5p1gvn98.js → index-q3265fxa.js} +8 -4
- package/dist/cli/index.js +3 -3
- package/dist/cli/{knowledge-store-n4x6zyk7.js → knowledge-store-gsy6p46z.js} +1 -1
- package/dist/cli/{skill-generator-s0spm65v.js → skill-generator-1hzfyhth.js} +2 -2
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/link.d.ts +19 -0
- package/dist/commands/registry.d.ts +23 -0
- package/dist/commands/unlink.d.ts +13 -0
- package/dist/config/bundled-skills.d.ts +1 -1
- package/dist/config/skill-mirrors.d.ts +87 -0
- package/dist/hooks/knowledge-events.d.ts +3 -3
- package/dist/hooks/knowledge-link.d.ts +82 -0
- package/dist/hooks/knowledge-validator.d.ts +1 -1
- package/dist/index.js +2088 -1561
- package/dist/knowledge/identity.d.ts +9 -0
- package/dist/session/worktree-link-suggestion.d.ts +27 -0
- package/package.json +6 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
handleGuardrailExplain
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-prppjv2q.js";
|
|
5
5
|
import {
|
|
6
6
|
handleGuardrailLog
|
|
7
7
|
} from "./index-gg589mfw.js";
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
handleKnowledgeRetryHardeningCommand,
|
|
52
52
|
handleKnowledgeUnactionableCommand,
|
|
53
53
|
handleLearningCommand,
|
|
54
|
+
handleLinkCommand,
|
|
54
55
|
handleMemoryCommand,
|
|
55
56
|
handleMemoryExportCommand,
|
|
56
57
|
handleMemoryImportCommand,
|
|
@@ -73,14 +74,15 @@ import {
|
|
|
73
74
|
handleStatusCommand,
|
|
74
75
|
handleSyncPlanCommand,
|
|
75
76
|
handleTurboCommand,
|
|
77
|
+
handleUnlinkCommand,
|
|
76
78
|
handleWriteRetroCommand,
|
|
77
79
|
normalizeSwarmCommandInput,
|
|
78
80
|
resolveCommand
|
|
79
|
-
} from "./index-
|
|
81
|
+
} from "./index-mz2z7jtn.js";
|
|
80
82
|
import"./index-6tnmt41c.js";
|
|
81
83
|
import"./index-bm4f0nme.js";
|
|
82
|
-
import"./index-
|
|
83
|
-
import"./index-
|
|
84
|
+
import"./index-1ccnwh54.js";
|
|
85
|
+
import"./index-axwxkbdd.js";
|
|
84
86
|
import"./index-bywt2171.js";
|
|
85
87
|
import {
|
|
86
88
|
AGENT_TOOL_MAP,
|
|
@@ -337,6 +339,7 @@ export {
|
|
|
337
339
|
resolveCommand,
|
|
338
340
|
normalizeSwarmCommandInput,
|
|
339
341
|
handleWriteRetroCommand,
|
|
342
|
+
handleUnlinkCommand,
|
|
340
343
|
handleTurboCommand,
|
|
341
344
|
handleSyncPlanCommand,
|
|
342
345
|
handleStatusCommand,
|
|
@@ -359,6 +362,7 @@ export {
|
|
|
359
362
|
handleMemoryImportCommand,
|
|
360
363
|
handleMemoryExportCommand,
|
|
361
364
|
handleMemoryCommand,
|
|
365
|
+
handleLinkCommand,
|
|
362
366
|
handleLearningCommand,
|
|
363
367
|
handleKnowledgeUnactionableCommand,
|
|
364
368
|
handleKnowledgeRetryHardeningCommand,
|
package/dist/cli/index.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getPluginLockFilePaths,
|
|
8
8
|
package_default,
|
|
9
9
|
resolveCommand
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-mz2z7jtn.js";
|
|
11
11
|
import"./index-6tnmt41c.js";
|
|
12
12
|
import"./index-bm4f0nme.js";
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
13
|
+
import"./index-1ccnwh54.js";
|
|
14
|
+
import"./index-axwxkbdd.js";
|
|
15
15
|
import"./index-bywt2171.js";
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_AGENT_CONFIGS
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
retireSkill,
|
|
23
23
|
sanitizeSlug,
|
|
24
24
|
selectCandidateEntries
|
|
25
|
-
} from "./index-
|
|
26
|
-
import"./index-
|
|
25
|
+
} from "./index-1ccnwh54.js";
|
|
26
|
+
import"./index-axwxkbdd.js";
|
|
27
27
|
import"./index-fjwwrwr5.js";
|
|
28
28
|
import"./index-jtqkh8jf.js";
|
|
29
29
|
import"./index-zgwm4ryv.js";
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { handleHandoffCommand } from './handoff';
|
|
|
32
32
|
export { handleHistoryCommand } from './history';
|
|
33
33
|
export { handleKnowledgeListCommand, handleKnowledgeMigrateCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeRetryHardeningCommand, handleKnowledgeUnactionableCommand, } from './knowledge';
|
|
34
34
|
export { handleLearningCommand } from './learning';
|
|
35
|
+
export { handleLinkCommand } from './link';
|
|
35
36
|
export { handleMemoryCommand, handleMemoryExportCommand, handleMemoryImportCommand, handleMemoryMigrateCommand, handleMemoryStatusCommand, } from './memory';
|
|
36
37
|
export { handlePlanCommand } from './plan';
|
|
37
38
|
export { handlePreflightCommand } from './preflight';
|
|
@@ -51,6 +52,7 @@ export { handleStatusCommand } from './status';
|
|
|
51
52
|
export { handleSyncPlanCommand } from './sync-plan';
|
|
52
53
|
export { classifySwarmCommandChatFallbackUse, classifySwarmCommandToolUse, SWARM_COMMAND_TOOL_ALLOWLIST, SWARM_COMMAND_TOOL_COMMANDS, } from './tool-policy.js';
|
|
53
54
|
export { handleTurboCommand } from './turbo';
|
|
55
|
+
export { handleUnlinkCommand } from './unlink';
|
|
54
56
|
export { handleWriteRetroCommand } from './write-retro';
|
|
55
57
|
export declare function buildHelpText(): string;
|
|
56
58
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the `/swarm link` command.
|
|
3
|
+
*
|
|
4
|
+
* Ties this worktree's swarm knowledge store to a shared "link" store so that
|
|
5
|
+
* several swarms working on the same project (typically separate git worktrees)
|
|
6
|
+
* — or on deliberately "similar" projects — pool their lessons instead of each
|
|
7
|
+
* keeping an isolated `.swarm/knowledge.jsonl`.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* - /swarm link — link using the project hash (ties all worktrees
|
|
11
|
+
* of the same repo to one shared store).
|
|
12
|
+
* - /swarm link <name> — link using an explicit shared name (use the same
|
|
13
|
+
* name in each worktree/repo to tie them together).
|
|
14
|
+
* - /swarm link status — show the current link state for this worktree.
|
|
15
|
+
*
|
|
16
|
+
* On link, this worktree's existing local lessons are merged (deduplicated) into
|
|
17
|
+
* the shared store so nothing already learned is lost.
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleLinkCommand(directory: string, args: string[]): Promise<string>;
|
|
@@ -609,6 +609,29 @@ export declare const COMMAND_REGISTRY: {
|
|
|
609
609
|
readonly category: "config";
|
|
610
610
|
readonly toolPolicy: "none";
|
|
611
611
|
};
|
|
612
|
+
readonly link: {
|
|
613
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
614
|
+
readonly description: "Tie this worktree to a shared swarm knowledge store [name]";
|
|
615
|
+
readonly details: "Links the current worktree to a shared knowledge store so multiple swarms working on the same project (e.g. separate git worktrees) pool their lessons instead of each keeping an isolated .swarm/knowledge.jsonl. With no name, ties all worktrees of the same repo via the project hash; with a name, ties any worktrees/repos that use the same name. Existing local lessons are merged (deduped) into the shared store. Use `/swarm link status` to inspect.";
|
|
616
|
+
readonly args: "[<name> | status]";
|
|
617
|
+
readonly category: "utility";
|
|
618
|
+
readonly toolPolicy: "none";
|
|
619
|
+
};
|
|
620
|
+
readonly 'link status': {
|
|
621
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
622
|
+
readonly description: "Show whether this worktree shares knowledge via a link";
|
|
623
|
+
readonly subcommandOf: "link";
|
|
624
|
+
readonly category: "utility";
|
|
625
|
+
readonly toolPolicy: "none";
|
|
626
|
+
};
|
|
627
|
+
readonly unlink: {
|
|
628
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
629
|
+
readonly description: "Stop sharing swarm knowledge for this worktree [--no-copy]";
|
|
630
|
+
readonly details: "Unlinks the current worktree from its shared knowledge store and returns it to a local .swarm/knowledge.jsonl. By default the shared lessons are copied back into the local store (deduped) so nothing is lost; pass --no-copy to skip the copy-back.";
|
|
631
|
+
readonly args: "[--no-copy]";
|
|
632
|
+
readonly category: "utility";
|
|
633
|
+
readonly toolPolicy: "none";
|
|
634
|
+
};
|
|
612
635
|
readonly promote: {
|
|
613
636
|
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
614
637
|
readonly description: "Manually promote lesson to hive knowledge";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the `/swarm unlink` command.
|
|
3
|
+
*
|
|
4
|
+
* Stops sharing this worktree's swarm knowledge with its link store and returns
|
|
5
|
+
* it to a local `.swarm/knowledge.jsonl`. By default the shared lessons are
|
|
6
|
+
* copied back into the local store (deduplicated) so the worktree keeps the
|
|
7
|
+
* pooled knowledge it had access to; pass `--no-copy` to skip the copy-back.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* - /swarm unlink — unlink and copy shared lessons back to local.
|
|
11
|
+
* - /swarm unlink --no-copy — unlink without copying shared lessons back.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleUnlinkCommand(directory: string, args: string[]): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "design-docs", "swarm-pr-review", "swarm-pr-feedback", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop"];
|
|
1
|
+
export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "design-docs", "swarm-pr-review", "swarm-pr-feedback", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop", "writing-tests", "running-tests", "engineering-conventions", "commit-pr"];
|
|
2
2
|
interface CopyState {
|
|
3
3
|
files: number;
|
|
4
4
|
bytes: number;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for skill mirror contracts between the OpenCode-side
|
|
3
|
+
* (`.opencode/skills/`) and Claude-side (`.claude/skills/`) skill trees, plus
|
|
4
|
+
* Codex/GitHub adapter shims (`.agents/skills/`, `.github/skills/`).
|
|
5
|
+
*
|
|
6
|
+
* Consumed by:
|
|
7
|
+
* - tests/unit/skills/skill-mirrors.test.ts (architect MODE mirror regression)
|
|
8
|
+
* - scripts/drift-check.ts (issue #1497 CI drift detector)
|
|
9
|
+
*
|
|
10
|
+
* Keeping the lists here — rather than inline in the test — means the drift
|
|
11
|
+
* checker and the regression test cannot themselves drift apart.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Architect MODE skills whose `.opencode` and `.claude` mirrors must be
|
|
15
|
+
* byte-identical. `.opencode` is the operative protocol loaded by
|
|
16
|
+
* `src/agents/architect.ts` MODE stubs; the `.claude` mirror must match so
|
|
17
|
+
* Claude Code and OpenCode sessions cannot diverge silently. Tuple shape is
|
|
18
|
+
* `[slug, opencodePath, claudePath]`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MIRRORED_ARCHITECT_MODE_SKILLS: readonly [readonly ["brainstorm", ".opencode/skills/brainstorm/SKILL.md", ".claude/skills/brainstorm/SKILL.md"], readonly ["specify", ".opencode/skills/specify/SKILL.md", ".claude/skills/specify/SKILL.md"], readonly ["clarify-spec", ".opencode/skills/clarify-spec/SKILL.md", ".claude/skills/clarify-spec/SKILL.md"], readonly ["resume", ".opencode/skills/resume/SKILL.md", ".claude/skills/resume/SKILL.md"], readonly ["clarify", ".opencode/skills/clarify/SKILL.md", ".claude/skills/clarify/SKILL.md"], readonly ["discover", ".opencode/skills/discover/SKILL.md", ".claude/skills/discover/SKILL.md"], readonly ["consult", ".opencode/skills/consult/SKILL.md", ".claude/skills/consult/SKILL.md"], readonly ["pre-phase-briefing", ".opencode/skills/pre-phase-briefing/SKILL.md", ".claude/skills/pre-phase-briefing/SKILL.md"], readonly ["council", ".opencode/skills/council/SKILL.md", ".claude/skills/council/SKILL.md"], readonly ["deep-dive", ".opencode/skills/deep-dive/SKILL.md", ".claude/skills/deep-dive/SKILL.md"], readonly ["deep-research", ".opencode/skills/deep-research/SKILL.md", ".claude/skills/deep-research/SKILL.md"], readonly ["issue-ingest", ".opencode/skills/issue-ingest/SKILL.md", ".claude/skills/issue-ingest/SKILL.md"], readonly ["plan", ".opencode/skills/plan/SKILL.md", ".claude/skills/plan/SKILL.md"], readonly ["critic-gate", ".opencode/skills/critic-gate/SKILL.md", ".claude/skills/critic-gate/SKILL.md"], readonly ["execute", ".opencode/skills/execute/SKILL.md", ".claude/skills/execute/SKILL.md"], readonly ["phase-wrap", ".opencode/skills/phase-wrap/SKILL.md", ".claude/skills/phase-wrap/SKILL.md"], readonly ["design-docs", ".opencode/skills/design-docs/SKILL.md", ".claude/skills/design-docs/SKILL.md"]];
|
|
21
|
+
/**
|
|
22
|
+
* Architect MODE skills where `.opencode` is the full operative protocol and
|
|
23
|
+
* `.claude` is an intentionally different surface. Both must exist; byte
|
|
24
|
+
* identity is not required, but the divergence is documented here.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DIVERGENT_ARCHITECT_MODE_SKILLS: Array<{
|
|
27
|
+
slug: string;
|
|
28
|
+
opencodePath: string;
|
|
29
|
+
claudePath: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Architect MODE skills whose `.opencode` SKILL.md is canonical and whose
|
|
34
|
+
* `.claude`/`.agents` surfaces are thin adapter shims that delegate back to the
|
|
35
|
+
* canonical `.opencode` skill.
|
|
36
|
+
*
|
|
37
|
+
* `expectedCanonicalRef` is the relative path that each adapter SKILL.md must
|
|
38
|
+
* contain as a reference back to the canonical `.opencode` skill. All adapter
|
|
39
|
+
* shims live exactly three directory levels deep (`.{runtime}/skills/{slug}/`),
|
|
40
|
+
* so `../../../` always resolves to the repo root from any adapter path. If
|
|
41
|
+
* the directory structure changes (e.g., skills are reorganised to a flat
|
|
42
|
+
* layout), update `expectedCanonicalRef` entries accordingly.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ADAPTER_ARCHITECT_MODE_SKILLS: Array<{
|
|
45
|
+
slug: string;
|
|
46
|
+
canonicalPath: string;
|
|
47
|
+
adapterPaths: string[];
|
|
48
|
+
expectedCanonicalRef: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Architect MODE skills whose `.opencode` protocol is intentionally NOT mirrored
|
|
52
|
+
* to `.claude` (e.g. a `.claude` mirror would shadow a Claude Code built-in
|
|
53
|
+
* skill of the same name, or the mode is only reachable through the OpenCode
|
|
54
|
+
* plugin runtime).
|
|
55
|
+
*/
|
|
56
|
+
export declare const OPENCODE_ONLY_ARCHITECT_MODE_SKILLS: Array<{
|
|
57
|
+
slug: string;
|
|
58
|
+
opencodePath: string;
|
|
59
|
+
reason: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Skill mirror contracts for skill pairs that are NOT architect MODE skills but
|
|
63
|
+
* still exist across the `.opencode`/`.claude` trees. The drift checker
|
|
64
|
+
* (scripts/drift-check.ts) classifies every cross-tree skill pair; without an
|
|
65
|
+
* entry here a both-tree pair is reported as "unclassified" so a human decides
|
|
66
|
+
* its contract. See issue #1497.
|
|
67
|
+
*
|
|
68
|
+
* `kind`:
|
|
69
|
+
* - `identical`: `.opencode` and `.claude` SKILL.md must be byte-identical.
|
|
70
|
+
* `canonical` records which side wins when they drift (fix direction only;
|
|
71
|
+
* detection is symmetric).
|
|
72
|
+
* - `divergent`: both must exist; content intentionally differs per runtime.
|
|
73
|
+
* - `opencode-only`: `.opencode` exists; no `.claude` mirror expected.
|
|
74
|
+
*/
|
|
75
|
+
export declare const ADDITIONAL_SKILL_MIRROR_CONTRACTS: Array<{
|
|
76
|
+
slug: string;
|
|
77
|
+
kind: 'identical' | 'divergent' | 'opencode-only';
|
|
78
|
+
canonical?: '.claude' | '.opencode';
|
|
79
|
+
reason: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Top-level entries under `.opencode/skills/` that are not bundled skills and
|
|
83
|
+
* must be ignored by the drift checker. `generated/` holds user-generated
|
|
84
|
+
* skills produced at runtime (src/services/skill-generator.ts) and has no
|
|
85
|
+
* direct SKILL.md.
|
|
86
|
+
*/
|
|
87
|
+
export declare const NON_SKILL_OPENCODE_DIRS: Set<string>;
|
|
@@ -146,12 +146,12 @@ export type KnowledgeEventInput = KnowledgeEvent extends infer T ? T extends Kno
|
|
|
146
146
|
} : never : never;
|
|
147
147
|
/** Receipt event verbs that reference a single knowledge_id. */
|
|
148
148
|
export declare const RECEIPT_EVENT_TYPES: ReadonlySet<string>;
|
|
149
|
-
/** Returns
|
|
149
|
+
/** Returns the knowledge-events.jsonl path (link-aware via resolveKnowledgeStoreDir). */
|
|
150
150
|
export declare function resolveKnowledgeEventsPath(directory: string): string;
|
|
151
|
-
/** Returns
|
|
151
|
+
/** Returns the knowledge-counter-baseline.json path (link-aware). */
|
|
152
152
|
export declare function resolveKnowledgeCounterBaselinePath(directory: string): string;
|
|
153
153
|
export declare function resolveHiveEventsPath(): string;
|
|
154
|
-
/** Returns
|
|
154
|
+
/** Returns the knowledge-application.jsonl path for legacy v2 audit records (link-aware). */
|
|
155
155
|
export declare function resolveLegacyApplicationLogPath(directory: string): string;
|
|
156
156
|
/** Generate a fresh trace id. One per retrieval; receipts reference it. */
|
|
157
157
|
export declare function newTraceId(): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge "link" resolution for the opencode-swarm knowledge system.
|
|
3
|
+
*
|
|
4
|
+
* Problem: the swarm knowledge tier is rooted at `<directory>/.swarm/`, where
|
|
5
|
+
* `directory` is `ctx.directory`. When several swarms run in separate git
|
|
6
|
+
* worktrees of the same repository, each worktree has its own `.swarm/` and
|
|
7
|
+
* therefore its own isolated knowledge store — lessons one swarm learns are
|
|
8
|
+
* invisible to the others. The hive tier is the opposite extreme: global to
|
|
9
|
+
* EVERY project on the machine.
|
|
10
|
+
*
|
|
11
|
+
* A "link" ties multiple worktrees (or several deliberately "similar" repos)
|
|
12
|
+
* to one shared knowledge store that sits between the per-worktree swarm tier
|
|
13
|
+
* and the global hive tier. Membership is declared by an opt-in pointer file at
|
|
14
|
+
* `<directory>/.swarm/link.json`. When that pointer is active, the swarm
|
|
15
|
+
* knowledge *family* (store, events, rejected, retractions, counters,
|
|
16
|
+
* quarantine, unactionable) redirects from `<directory>/.swarm` to a shared
|
|
17
|
+
* link directory in the platform data dir — co-located with the hive store.
|
|
18
|
+
*
|
|
19
|
+
* Intentionally NOT redirected (stays per-worktree): `.knowledge-shown.json`
|
|
20
|
+
* (phase-keyed, session-local outcome bookkeeping), `plan.json`, evidence, and
|
|
21
|
+
* session state. Only id-keyed / append-only knowledge data is pooled.
|
|
22
|
+
*
|
|
23
|
+
* This module is self-contained (node builtins + the atomic-write helper only)
|
|
24
|
+
* so it can be imported by knowledge-store.ts, knowledge-events.ts, and
|
|
25
|
+
* knowledge-validator.ts without coupling to the heavily test-mocked store
|
|
26
|
+
* module and without import cycles.
|
|
27
|
+
*/
|
|
28
|
+
/** On-disk pointer at `<directory>/.swarm/link.json`. */
|
|
29
|
+
export interface LinkPointer {
|
|
30
|
+
version: 1;
|
|
31
|
+
/** Path-safe identifier of the shared store (projectHash or sanitized name). */
|
|
32
|
+
linkId: string;
|
|
33
|
+
/** Human-friendly name when the link was created from an explicit name. */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** ISO 8601 creation timestamp. */
|
|
36
|
+
createdAt: string;
|
|
37
|
+
/** How the link was established. */
|
|
38
|
+
source: 'manual' | 'auto';
|
|
39
|
+
}
|
|
40
|
+
export declare const LINK_POINTER_FILENAME = "link.json";
|
|
41
|
+
/** Root directory under which all shared link stores live: `<dataDir>/links`. */
|
|
42
|
+
export declare function resolveLinkBaseDir(): string;
|
|
43
|
+
/** Directory of the shared knowledge family for a given link id. */
|
|
44
|
+
export declare function resolveLinkDir(linkId: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Coerce an arbitrary user-supplied name into a single, path-safe directory
|
|
47
|
+
* segment. Returns null when nothing usable remains (caller falls back to the
|
|
48
|
+
* project hash). Lowercased for case-insensitive stability across worktrees.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sanitizeLinkId(name: string): string | null;
|
|
51
|
+
/** Read and validate the link pointer for a worktree. Null if absent/invalid. */
|
|
52
|
+
export declare function readLinkPointer(directory: string): LinkPointer | null;
|
|
53
|
+
/** Write the link pointer atomically and invalidate the resolution cache. */
|
|
54
|
+
export declare function writeLinkPointer(directory: string, pointer: LinkPointer): Promise<void>;
|
|
55
|
+
/** Remove the link pointer (idempotent) and invalidate the resolution cache. */
|
|
56
|
+
export declare function removeLinkPointer(directory: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the directory that holds the swarm knowledge family for `directory`.
|
|
59
|
+
*
|
|
60
|
+
* Returns the shared link directory when an active pointer is present, otherwise
|
|
61
|
+
* the local `<directory>/.swarm`. Fail-open: any read/parse error degrades to the
|
|
62
|
+
* local directory, so a corrupt pointer never strands knowledge. Synchronous and
|
|
63
|
+
* cached so the hot retrieval path pays at most one tiny file read per TTL window.
|
|
64
|
+
*
|
|
65
|
+
* NOTE: when unlinked, the return value is byte-identical to the legacy
|
|
66
|
+
* `path.join(directory, '.swarm')`, so existing callers/tests are unaffected.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveKnowledgeStoreDir(directory: string): string;
|
|
69
|
+
/** Drop cached resolution(s). Pass a directory to invalidate one, omit for all. */
|
|
70
|
+
export declare function invalidateKnowledgeStoreDirCache(directory?: string): void;
|
|
71
|
+
/** True when the worktree currently redirects to a shared link store. */
|
|
72
|
+
export declare function isLinked(directory: string): boolean;
|
|
73
|
+
export declare const _internals: {
|
|
74
|
+
resolveKnowledgeStoreDir: typeof resolveKnowledgeStoreDir;
|
|
75
|
+
readLinkPointer: typeof readLinkPointer;
|
|
76
|
+
writeLinkPointer: typeof writeLinkPointer;
|
|
77
|
+
removeLinkPointer: typeof removeLinkPointer;
|
|
78
|
+
invalidateKnowledgeStoreDirCache: typeof invalidateKnowledgeStoreDirCache;
|
|
79
|
+
resolveLinkDir: typeof resolveLinkDir;
|
|
80
|
+
resolveLinkBaseDir: typeof resolveLinkBaseDir;
|
|
81
|
+
sanitizeLinkId: typeof sanitizeLinkId;
|
|
82
|
+
};
|
|
@@ -68,7 +68,7 @@ export interface ActionabilityResult {
|
|
|
68
68
|
* quarantined rather than activated.
|
|
69
69
|
*/
|
|
70
70
|
export declare function validateActionability(entry: Pick<KnowledgeEntryBase, 'forbidden_actions' | 'required_actions' | 'verification_checks' | 'verification_predicate' | 'applies_to_tools' | 'applies_to_agents'>): ActionabilityResult;
|
|
71
|
-
/** Returns
|
|
71
|
+
/** Returns the knowledge-unactionable.jsonl path for the given directory (link-aware). */
|
|
72
72
|
export declare function resolveUnactionablePath(directory: string): string;
|
|
73
73
|
/** One quarantined-unactionable record. */
|
|
74
74
|
export interface UnactionableRecord extends KnowledgeEntryBase {
|