pi-harness-runtime 0.10.27 → 0.10.43
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/.pi/plugins/herdr-clipboard/herdr-plugin.toml +22 -0
- package/.pi/plugins/herdr-clipboard/start-bridge.sh +29 -0
- package/.pi/plugins/herdr-clipboard/tmux-watch.sh +39 -0
- package/CHANGELOG.md +19 -0
- package/README.md +87 -1
- package/config.toml.example +35 -0
- package/package.json +5 -3
- package/packages/architecture-generator/dist/adr.d.ts +1 -1
- package/packages/architecture-generator/dist/adr.d.ts.map +1 -1
- package/packages/architecture-generator/dist/adr.js +2 -2
- package/packages/architecture-generator/dist/adr.js.map +1 -1
- package/packages/architecture-generator/dist/index.d.ts +3 -3
- package/packages/architecture-generator/dist/index.js +3 -3
- package/packages/architecture-generator/dist/mermaid.d.ts +1 -1
- package/packages/architecture-generator/dist/mermaid.d.ts.map +1 -1
- package/packages/architecture-generator/dist/mermaid.js +20 -20
- package/packages/architecture-generator/dist/mermaid.js.map +1 -1
- package/packages/architecture-generator/dist/types.d.ts +2 -2
- package/packages/architecture-generator/dist/types.d.ts.map +1 -1
- package/packages/architecture-generator/src/adr.ts +16 -16
- package/packages/architecture-generator/src/index.ts +3 -3
- package/packages/architecture-generator/src/mermaid.ts +48 -54
- package/packages/architecture-generator/src/types.ts +15 -15
- package/packages/capability-registry/src/types.js +10 -0
- package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -1
- package/packages/clipboard/dist/src/copy-sync.js +45 -3
- package/packages/clipboard/dist/src/copy-sync.js.map +1 -1
- package/packages/clipboard/dist/src/index.d.ts +1 -0
- package/packages/clipboard/dist/src/index.d.ts.map +1 -1
- package/packages/clipboard/dist/src/index.js +1 -0
- package/packages/clipboard/dist/src/index.js.map +1 -1
- package/packages/clipboard/dist/src/paste-bridge.d.ts +19 -0
- package/packages/clipboard/dist/src/paste-bridge.d.ts.map +1 -0
- package/packages/clipboard/dist/src/paste-bridge.js +78 -0
- package/packages/clipboard/dist/src/paste-bridge.js.map +1 -0
- package/packages/clipboard/src/copy-sync.ts +52 -3
- package/packages/clipboard/src/index.ts +1 -0
- package/packages/clipboard/src/paste-bridge.ts +86 -0
- package/packages/clipboard-plugin/dist/index.d.ts +28 -0
- package/packages/clipboard-plugin/dist/index.d.ts.map +1 -0
- package/packages/clipboard-plugin/dist/index.js +64 -0
- package/packages/clipboard-plugin/dist/index.js.map +1 -0
- package/packages/clipboard-plugin/dist/types.d.ts +30 -0
- package/packages/clipboard-plugin/dist/types.d.ts.map +1 -0
- package/packages/clipboard-plugin/dist/types.js +5 -0
- package/packages/clipboard-plugin/dist/types.js.map +1 -0
- package/packages/clipboard-plugin/src/index.ts +74 -0
- package/packages/clipboard-plugin/src/types.ts +30 -0
- package/packages/file-copy-helper/dist/src/extension.js +84 -25
- package/packages/file-copy-helper/src/extension.debug.ts +226 -0
- package/packages/file-copy-helper/src/extension.ts +89 -59
- package/packages/knowledge-graph/dist/graph-extractor.d.ts +1 -1
- package/packages/knowledge-graph/dist/graph-extractor.d.ts.map +1 -1
- package/packages/knowledge-graph/dist/graph-extractor.js +46 -55
- package/packages/knowledge-graph/dist/graph-extractor.js.map +1 -1
- package/packages/knowledge-graph/dist/index.d.ts +4 -4
- package/packages/knowledge-graph/dist/index.js +4 -4
- package/packages/knowledge-graph/dist/mcp-client.d.ts +2 -2
- package/packages/knowledge-graph/dist/mcp-client.d.ts.map +1 -1
- package/packages/knowledge-graph/dist/mcp-client.js +22 -22
- package/packages/knowledge-graph/dist/mcp-client.js.map +1 -1
- package/packages/knowledge-graph/dist/provenance-linker.d.ts +1 -1
- package/packages/knowledge-graph/dist/provenance-linker.d.ts.map +1 -1
- package/packages/knowledge-graph/dist/provenance-linker.js +14 -15
- package/packages/knowledge-graph/dist/provenance-linker.js.map +1 -1
- package/packages/knowledge-graph/dist/types.d.ts +2 -2
- package/packages/knowledge-graph/dist/types.d.ts.map +1 -1
- package/packages/knowledge-graph/src/graph-extractor.ts +263 -280
- package/packages/knowledge-graph/src/index.ts +4 -4
- package/packages/knowledge-graph/src/mcp-client.ts +188 -197
- package/packages/knowledge-graph/src/provenance-linker.ts +69 -73
- package/packages/knowledge-graph/src/types.ts +46 -46
- package/packages/milestone-manager/dist/engine.d.ts +1 -1
- package/packages/milestone-manager/dist/engine.d.ts.map +1 -1
- package/packages/milestone-manager/dist/engine.js +7 -9
- package/packages/milestone-manager/dist/engine.js.map +1 -1
- package/packages/milestone-manager/dist/index.d.ts +2 -2
- package/packages/milestone-manager/dist/index.js +2 -2
- package/packages/milestone-manager/dist/types.d.ts +2 -2
- package/packages/milestone-manager/dist/types.d.ts.map +1 -1
- package/packages/milestone-manager/src/engine.ts +83 -91
- package/packages/milestone-manager/src/index.ts +2 -2
- package/packages/milestone-manager/src/types.ts +13 -13
- package/packages/notification/dist/adapters/line-adapter.d.ts +17 -0
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -0
- package/packages/notification/dist/adapters/line-adapter.js +99 -0
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -0
- package/packages/notification/dist/index.d.ts +1 -0
- package/packages/notification/dist/index.d.ts.map +1 -1
- package/packages/notification/dist/index.js +1 -0
- package/packages/notification/dist/index.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +4 -0
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/types.d.ts +6 -2
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/src/adapters/line-adapter.ts +119 -0
- package/packages/notification/src/index.ts +1 -0
- package/packages/notification/src/notification-center.ts +6 -0
- package/packages/notification/src/types.ts +7 -2
- package/packages/project-bootstrap/dist/bootstrap.d.ts +1 -1
- package/packages/project-bootstrap/dist/bootstrap.d.ts.map +1 -1
- package/packages/project-bootstrap/dist/bootstrap.js +37 -45
- package/packages/project-bootstrap/dist/bootstrap.js.map +1 -1
- package/packages/project-bootstrap/dist/frappe.d.ts +1 -1
- package/packages/project-bootstrap/dist/frappe.d.ts.map +1 -1
- package/packages/project-bootstrap/dist/frappe.js +34 -34
- package/packages/project-bootstrap/dist/frappe.js.map +1 -1
- package/packages/project-bootstrap/dist/index.d.ts +5 -5
- package/packages/project-bootstrap/dist/index.js +5 -5
- package/packages/project-bootstrap/dist/minimal.d.ts +1 -1
- package/packages/project-bootstrap/dist/minimal.js +13 -13
- package/packages/project-bootstrap/dist/minimal.js.map +1 -1
- package/packages/project-bootstrap/dist/types.d.ts +1 -1
- package/packages/project-bootstrap/dist/types.d.ts.map +1 -1
- package/packages/project-bootstrap/dist/typescript.d.ts +1 -1
- package/packages/project-bootstrap/dist/typescript.d.ts.map +1 -1
- package/packages/project-bootstrap/dist/typescript.js +38 -38
- package/packages/project-bootstrap/dist/typescript.js.map +1 -1
- package/packages/project-bootstrap/src/bootstrap.ts +121 -136
- package/packages/project-bootstrap/src/frappe.ts +65 -71
- package/packages/project-bootstrap/src/index.ts +5 -5
- package/packages/project-bootstrap/src/minimal.ts +31 -31
- package/packages/project-bootstrap/src/types.ts +38 -38
- package/packages/project-bootstrap/src/typescript.ts +69 -78
- package/packages/provider-router/dist/src/types.js +1 -1
- package/packages/write-review/src/index.ts +47 -0
- package/packages/write-review/src/injection.ts +21 -1
- package/prompts/agents/reviewer.md +57 -0
- package/prompts/agents/writer.md +42 -0
- package/prompts/slash-commands.md +40 -0
- package/prompts/write-review.md +50 -0
- package/scripts/copy-plugins.js +56 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard Bridge Plugin — Main Entry
|
|
3
|
+
*
|
|
4
|
+
* Provides clipboard bridge functionality as a pi plugin.
|
|
5
|
+
* Integrates paste-from-bridge and paste shortcut registration.
|
|
6
|
+
*/
|
|
7
|
+
import { pasteFromBridge, registerPasteShortcut } from "@pi/clipboard";
|
|
8
|
+
/**
|
|
9
|
+
* Create a clipboard bridge tool plugin.
|
|
10
|
+
* Provides paste-from-bridge functionality.
|
|
11
|
+
*/
|
|
12
|
+
export function createClipboardBridgeTool() {
|
|
13
|
+
return {
|
|
14
|
+
capability: "tool",
|
|
15
|
+
name: "Clipboard Bridge",
|
|
16
|
+
tools: [
|
|
17
|
+
{
|
|
18
|
+
name: "paste-from-bridge",
|
|
19
|
+
description: "Read content from the clipboard bridge file (~/.herdr-clipboard)",
|
|
20
|
+
parameters: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {},
|
|
23
|
+
required: [],
|
|
24
|
+
},
|
|
25
|
+
execute: async () => {
|
|
26
|
+
const content = pasteFromBridge();
|
|
27
|
+
return { content };
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
config: {},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a clipboard bridge framework extension.
|
|
36
|
+
* For framework detection compatibility.
|
|
37
|
+
*/
|
|
38
|
+
export function createClipboardBridgePlugin() {
|
|
39
|
+
return {
|
|
40
|
+
capability: "framework",
|
|
41
|
+
name: "Clipboard Bridge Plugin",
|
|
42
|
+
detector: {
|
|
43
|
+
detect: async () => {
|
|
44
|
+
// This plugin doesn't detect frameworks, it's a utility plugin
|
|
45
|
+
return false;
|
|
46
|
+
},
|
|
47
|
+
signals: [],
|
|
48
|
+
},
|
|
49
|
+
config: {},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Register the paste shortcut with pi runtime.
|
|
54
|
+
* Call this during plugin activation.
|
|
55
|
+
*/
|
|
56
|
+
export function registerPasteShortcutHandler(pi, Key) {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
registerPasteShortcut(pi, Key);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Default plugin export.
|
|
62
|
+
*/
|
|
63
|
+
export default createClipboardBridgeTool;
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAIvE;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACxC,OAAO;QACN,UAAU,EAAE,MAAM;QAClB,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE;YACN;gBACC,IAAI,EAAE,mBAAmB;gBACzB,WAAW,EAAE,kEAAkE;gBAC/E,UAAU,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;oBACd,QAAQ,EAAE,EAAE;iBACZ;gBACD,OAAO,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;oBAClC,OAAO,EAAE,OAAO,EAAE,CAAC;gBACpB,CAAC;aACD;SACD;QACD,MAAM,EAAE,EAAE;KACV,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IAC1C,OAAO;QACN,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE,yBAAyB;QAC/B,QAAQ,EAAE;YACT,MAAM,EAAE,KAAK,IAAI,EAAE;gBAClB,+DAA+D;gBAC/D,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,EAAE,EAAE;SACX;QACD,MAAM,EAAE,EAAE;KACV,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC3C,EAAW,EACX,GAAY;IAEZ,8DAA8D;IAC9D,qBAAqB,CAAC,EAAS,EAAE,GAAU,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard Bridge Plugin — Types
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolExtension } from "@pi/framework-plugin-sdk";
|
|
5
|
+
export interface ClipboardBridgeConfig {
|
|
6
|
+
/** Enable the paste shortcut (default: true) */
|
|
7
|
+
enablePasteShortcut?: boolean;
|
|
8
|
+
/** Bridge file path (default: ~/.herdr-clipboard) */
|
|
9
|
+
bridgePath?: string;
|
|
10
|
+
/** Auto-sync to clipboard (default: true) */
|
|
11
|
+
autoSync?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ClipboardBridgeTool extends ToolExtension {
|
|
14
|
+
capability: "tool";
|
|
15
|
+
name: "Clipboard Bridge";
|
|
16
|
+
tools: {
|
|
17
|
+
name: "paste-from-bridge";
|
|
18
|
+
description: "Read content from the clipboard bridge file and return it";
|
|
19
|
+
parameters: {
|
|
20
|
+
type: "object";
|
|
21
|
+
properties: {};
|
|
22
|
+
required: [];
|
|
23
|
+
};
|
|
24
|
+
execute: () => Promise<{
|
|
25
|
+
content: string | null;
|
|
26
|
+
}>;
|
|
27
|
+
}[];
|
|
28
|
+
config: ClipboardBridgeConfig;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,qBAAqB;IACrC,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE;QACN,IAAI,EAAE,mBAAmB,CAAC;QAC1B,WAAW,EAAE,2DAA2D,CAAC;QACzE,UAAU,EAAE;YACX,IAAI,EAAE,QAAQ,CAAC;YACf,UAAU,EAAE,EAAE,CAAC;YACf,QAAQ,EAAE,EAAE,CAAC;SACb,CAAC;QACF,OAAO,EAAE,MAAM,OAAO,CAAC;YAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC,CAAC;KACnD,EAAE,CAAC;IACJ,MAAM,EAAE,qBAAqB,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard Bridge Plugin — Main Entry
|
|
3
|
+
*
|
|
4
|
+
* Provides clipboard bridge functionality as a pi plugin.
|
|
5
|
+
* Integrates paste-from-bridge and paste shortcut registration.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { FrameworkExtension, ToolExtension } from "@pi/framework-plugin-sdk";
|
|
9
|
+
import { pasteFromBridge, registerPasteShortcut } from "@pi/clipboard";
|
|
10
|
+
|
|
11
|
+
export type { ClipboardBridgeConfig } from "./types.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a clipboard bridge tool plugin.
|
|
15
|
+
* Provides paste-from-bridge functionality.
|
|
16
|
+
*/
|
|
17
|
+
export function createClipboardBridgeTool(): ToolExtension {
|
|
18
|
+
return {
|
|
19
|
+
capability: "tool",
|
|
20
|
+
name: "Clipboard Bridge",
|
|
21
|
+
tools: [
|
|
22
|
+
{
|
|
23
|
+
name: "paste-from-bridge",
|
|
24
|
+
description: "Read content from the clipboard bridge file (~/.herdr-clipboard)",
|
|
25
|
+
parameters: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {},
|
|
28
|
+
required: [],
|
|
29
|
+
},
|
|
30
|
+
execute: async () => {
|
|
31
|
+
const content = pasteFromBridge();
|
|
32
|
+
return { content };
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
config: {},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a clipboard bridge framework extension.
|
|
42
|
+
* For framework detection compatibility.
|
|
43
|
+
*/
|
|
44
|
+
export function createClipboardBridgePlugin(): FrameworkExtension {
|
|
45
|
+
return {
|
|
46
|
+
capability: "framework",
|
|
47
|
+
name: "Clipboard Bridge Plugin",
|
|
48
|
+
detector: {
|
|
49
|
+
detect: async () => {
|
|
50
|
+
// This plugin doesn't detect frameworks, it's a utility plugin
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
signals: [],
|
|
54
|
+
},
|
|
55
|
+
config: {},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Register the paste shortcut with pi runtime.
|
|
61
|
+
* Call this during plugin activation.
|
|
62
|
+
*/
|
|
63
|
+
export function registerPasteShortcutHandler(
|
|
64
|
+
pi: unknown,
|
|
65
|
+
Key: unknown,
|
|
66
|
+
): void {
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
registerPasteShortcut(pi as any, Key as any);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Default plugin export.
|
|
73
|
+
*/
|
|
74
|
+
export default createClipboardBridgeTool;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard Bridge Plugin — Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ToolExtension } from "@pi/framework-plugin-sdk";
|
|
6
|
+
|
|
7
|
+
export interface ClipboardBridgeConfig {
|
|
8
|
+
/** Enable the paste shortcut (default: true) */
|
|
9
|
+
enablePasteShortcut?: boolean;
|
|
10
|
+
/** Bridge file path (default: ~/.herdr-clipboard) */
|
|
11
|
+
bridgePath?: string;
|
|
12
|
+
/** Auto-sync to clipboard (default: true) */
|
|
13
|
+
autoSync?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ClipboardBridgeTool extends ToolExtension {
|
|
17
|
+
capability: "tool";
|
|
18
|
+
name: "Clipboard Bridge";
|
|
19
|
+
tools: {
|
|
20
|
+
name: "paste-from-bridge";
|
|
21
|
+
description: "Read content from the clipboard bridge file and return it";
|
|
22
|
+
parameters: {
|
|
23
|
+
type: "object";
|
|
24
|
+
properties: {};
|
|
25
|
+
required: [];
|
|
26
|
+
};
|
|
27
|
+
execute: () => Promise<{ content: string | null }>;
|
|
28
|
+
}[];
|
|
29
|
+
config: ClipboardBridgeConfig;
|
|
30
|
+
}
|
|
@@ -1,39 +1,92 @@
|
|
|
1
|
-
//
|
|
2
|
-
var COPY_KEYWORDS = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
1
|
+
// src/extension.ts
|
|
2
|
+
var COPY_KEYWORDS = ["mimic", "replicate", "clone"];
|
|
3
|
+
var COPY_DEST_CONTEXT = ["to ", "into ", "/dest/", "/target/", "over to"];
|
|
4
|
+
var COPY_SOURCE_CONTEXT = ["from ", "source", "/source/", "orig"];
|
|
5
|
+
var IMPORT_ERROR_TRIGGERS = [
|
|
6
|
+
"import error",
|
|
7
|
+
"import errors",
|
|
8
|
+
"cannot find module",
|
|
9
|
+
"cannot resolve",
|
|
10
|
+
"module not found",
|
|
11
|
+
"missing import",
|
|
12
|
+
"missing file",
|
|
13
|
+
"does not exist",
|
|
14
|
+
"@repo/",
|
|
15
|
+
"error one by one",
|
|
16
|
+
"fix errors one by one",
|
|
17
|
+
"fix imports one by one",
|
|
18
|
+
"roll back"
|
|
13
19
|
];
|
|
14
20
|
var COPY_RULE = `
|
|
15
|
-
##
|
|
21
|
+
## COPY FILES DIRECTLY (CRITICAL)
|
|
16
22
|
|
|
17
|
-
When
|
|
23
|
+
When asked to mimic, copy, clone, or replicate files:
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
1. **DO NOT read the source files** - just copy them directly
|
|
26
|
+
2. **Run \`sudo cp\` immediately** - no reading needed
|
|
27
|
+
3. **If files have different owners**, use sudo
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
Examples:
|
|
30
|
+
\`\`\`bash
|
|
31
|
+
# Copy single file
|
|
32
|
+
sudo cp /source/file.ts /dest/file.ts
|
|
25
33
|
|
|
26
34
|
# Copy entire folder
|
|
27
|
-
sudo cp -r /
|
|
35
|
+
sudo cp -r /source/folder/ /dest/folder/
|
|
36
|
+
|
|
37
|
+
# Copy matching pattern
|
|
38
|
+
sudo cp /source/*.tsx /dest/
|
|
28
39
|
\`\`\`
|
|
29
40
|
|
|
30
|
-
**
|
|
41
|
+
**STOP**: Do NOT use \`read\`, \`expand\`, or \`cat\` on source files. Just copy.
|
|
31
42
|
|
|
32
|
-
The source files
|
|
43
|
+
**Why**: Reading wastes time. The source files are complete - copying preserves everything exactly.
|
|
33
44
|
`;
|
|
34
|
-
|
|
45
|
+
var IMPORT_ERROR_RULE = `
|
|
46
|
+
## IMPORT ERRORS? COPY THOSE FILES TOO!
|
|
47
|
+
|
|
48
|
+
When you see import/module errors after copying a file:
|
|
49
|
+
|
|
50
|
+
1. **STOP fixing imports one by one**
|
|
51
|
+
2. **STOP rolling back**
|
|
52
|
+
3. **LIST all missing import files** for the user
|
|
53
|
+
4. **Ask user which to copy**, then copy them via sudo cp
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
# If error shows missing:
|
|
58
|
+
# - @repo/auth/server
|
|
59
|
+
# - @repo/design-system/components/ui/sidebar
|
|
60
|
+
# - ./components/notifications-provider
|
|
61
|
+
|
|
62
|
+
# Then copy these files the same way:
|
|
63
|
+
sudo cp /source/path/@repo/auth/server.ts /dest/path/@repo/auth/server.ts
|
|
64
|
+
sudo cp -r /source/path/@repo/design-system/components/ui/sidebar /dest/path/@repo/design-system/components/ui/sidebar
|
|
65
|
+
sudo cp /source/path/components/notifications-provider.tsx /dest/path/components/notifications-provider.tsx
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
**NEVER fix imports one by one** - copy the missing files instead!
|
|
69
|
+
**NEVER roll back** - keep the copied file and copy its dependencies!
|
|
70
|
+
`;
|
|
71
|
+
function shouldInjectCopyRule(text) {
|
|
72
|
+
const lower = text.toLowerCase();
|
|
73
|
+
const hasIntent = COPY_KEYWORDS.some((keyword) => lower.includes(keyword));
|
|
74
|
+
if (!hasIntent) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const hasDest = COPY_DEST_CONTEXT.some((ctx) => lower.includes(ctx));
|
|
78
|
+
if (!hasDest) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const hasSource = COPY_SOURCE_CONTEXT.some((ctx) => lower.includes(ctx));
|
|
82
|
+
if (!hasSource) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
function shouldInjectImportErrorRule(text) {
|
|
35
88
|
const lower = text.toLowerCase();
|
|
36
|
-
return
|
|
89
|
+
return IMPORT_ERROR_TRIGGERS.some((t) => lower.includes(t));
|
|
37
90
|
}
|
|
38
91
|
function registerFileCopyHelper(pi) {
|
|
39
92
|
pi.on("input", (event) => {
|
|
@@ -44,12 +97,18 @@ function registerFileCopyHelper(pi) {
|
|
|
44
97
|
if (!text || text.length < 10) {
|
|
45
98
|
return;
|
|
46
99
|
}
|
|
47
|
-
if (
|
|
100
|
+
if (shouldInjectCopyRule(text)) {
|
|
48
101
|
return {
|
|
49
102
|
action: "transform",
|
|
50
103
|
text: text + COPY_RULE
|
|
51
104
|
};
|
|
52
105
|
}
|
|
106
|
+
if (shouldInjectImportErrorRule(text)) {
|
|
107
|
+
return {
|
|
108
|
+
action: "transform",
|
|
109
|
+
text: text + IMPORT_ERROR_RULE
|
|
110
|
+
};
|
|
111
|
+
}
|
|
53
112
|
return;
|
|
54
113
|
});
|
|
55
114
|
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* file-copy-helper extension (DEBUG VERSION)
|
|
3
|
+
*
|
|
4
|
+
* Injects "use cp instead of writing from scratch" reminder when user
|
|
5
|
+
* asks to mimic, copy, clone, or replicate files/folders between locations.
|
|
6
|
+
*
|
|
7
|
+
* DEBUG: All events and rule evaluations logged to /tmp/file-copy-helper-debug.log
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
ExtensionAPI,
|
|
12
|
+
InputEvent,
|
|
13
|
+
InputEventResult,
|
|
14
|
+
} from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import * as fs from "fs";
|
|
16
|
+
|
|
17
|
+
// DEBUG: Write to file instead of TUI
|
|
18
|
+
const DEBUG_LOG = "/tmp/file-copy-helper-debug.log";
|
|
19
|
+
|
|
20
|
+
function debugLog(label: string, data: unknown): void {
|
|
21
|
+
const timestamp = new Date().toISOString();
|
|
22
|
+
const entry = `[${timestamp}] ${label}: ${JSON.stringify(data, null, 2)}\n`;
|
|
23
|
+
fs.appendFileSync(DEBUG_LOG, entry);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Keywords that trigger the copy rule injection
|
|
27
|
+
// MUST have explicit mimic/copy/clone/replicate intent + source/dest context
|
|
28
|
+
const COPY_KEYWORDS = ["mimic", "replicate", "clone"];
|
|
29
|
+
|
|
30
|
+
// Must have destination context to trigger (avoids false positives)
|
|
31
|
+
const COPY_DEST_CONTEXT = ["to ", "into ", "/dest/", "/target/", "over to"];
|
|
32
|
+
|
|
33
|
+
// Must have source context to trigger
|
|
34
|
+
const COPY_SOURCE_CONTEXT = ["from ", "source", "/source/", "orig"];
|
|
35
|
+
|
|
36
|
+
// When agent sees import/module errors (needs to copy those files too)
|
|
37
|
+
const IMPORT_ERROR_TRIGGERS = [
|
|
38
|
+
"import error",
|
|
39
|
+
"import errors",
|
|
40
|
+
"cannot find module",
|
|
41
|
+
"cannot resolve",
|
|
42
|
+
"module not found",
|
|
43
|
+
"missing import",
|
|
44
|
+
"missing file",
|
|
45
|
+
"does not exist",
|
|
46
|
+
"@repo/",
|
|
47
|
+
"error one by one",
|
|
48
|
+
"fix errors one by one",
|
|
49
|
+
"fix imports one by one",
|
|
50
|
+
"roll back",
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
// Extract source and destination from user request
|
|
54
|
+
const COPY_RULE = `
|
|
55
|
+
## COPY FILES DIRECTLY (CRITICAL)
|
|
56
|
+
|
|
57
|
+
When asked to mimic, copy, clone, or replicate files:
|
|
58
|
+
|
|
59
|
+
1. **DO NOT read the source files** - just copy them directly
|
|
60
|
+
2. **Run \`sudo cp\` immediately** - no reading needed
|
|
61
|
+
3. **If files have different owners**, use sudo
|
|
62
|
+
|
|
63
|
+
Examples:
|
|
64
|
+
\`\`\`bash
|
|
65
|
+
# Copy single file
|
|
66
|
+
sudo cp /source/file.ts /dest/file.ts
|
|
67
|
+
|
|
68
|
+
# Copy entire folder
|
|
69
|
+
sudo cp -r /source/folder/ /dest/folder/
|
|
70
|
+
|
|
71
|
+
# Copy matching pattern
|
|
72
|
+
sudo cp /source/*.tsx /dest/
|
|
73
|
+
\`\`\`
|
|
74
|
+
|
|
75
|
+
**STOP**: Do NOT use \`read\`, \`expand\`, or \`cat\` on source files. Just copy.
|
|
76
|
+
|
|
77
|
+
**Why**: Reading wastes time. The source files are complete - copying preserves everything exactly.
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
// When agent sees import errors - copy those files too!
|
|
81
|
+
const IMPORT_ERROR_RULE = `
|
|
82
|
+
## IMPORT ERRORS? COPY THOSE FILES TOO!
|
|
83
|
+
|
|
84
|
+
When you see import/module errors after copying a file:
|
|
85
|
+
|
|
86
|
+
1. **STOP fixing imports one by one**
|
|
87
|
+
2. **STOP rolling back**
|
|
88
|
+
3. **LIST all missing import files** for the user
|
|
89
|
+
4. **Ask user which to copy**, then copy them via sudo cp
|
|
90
|
+
|
|
91
|
+
Example:
|
|
92
|
+
\`\`\`bash
|
|
93
|
+
# If error shows missing:
|
|
94
|
+
# - @repo/auth/server
|
|
95
|
+
# - @repo/design-system/components/ui/sidebar
|
|
96
|
+
# - ./components/notifications-provider
|
|
97
|
+
|
|
98
|
+
# Then copy these files the same way:
|
|
99
|
+
sudo cp /source/path/@repo/auth/server.ts /dest/path/@repo/auth/server.ts
|
|
100
|
+
sudo cp -r /source/path/@repo/design-system/components/ui/sidebar /dest/path/@repo/design-system/components/ui/sidebar
|
|
101
|
+
sudo cp /source/path/components/notifications-provider.tsx /dest/path/components/notifications-provider.tsx
|
|
102
|
+
\`\`\`
|
|
103
|
+
|
|
104
|
+
**NEVER fix imports one by one** - copy the missing files instead!
|
|
105
|
+
**NEVER roll back** - keep the copied file and copy its dependencies!
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Check if text contains copy-related keywords
|
|
110
|
+
* Requires: explicit intent (mimic/copy/clone/replicate) AND destination context
|
|
111
|
+
*/
|
|
112
|
+
function shouldInjectCopyRule(text: string): { triggered: boolean; reason: string } {
|
|
113
|
+
const lower = text.toLowerCase();
|
|
114
|
+
|
|
115
|
+
// Must have explicit mimic/copy/clone/replicate intent
|
|
116
|
+
const hasIntent = COPY_KEYWORDS.some((keyword) => lower.includes(keyword));
|
|
117
|
+
if (!hasIntent) {
|
|
118
|
+
return { triggered: false, reason: `No intent keyword found. Keywords: ${COPY_KEYWORDS.join(", ")}` };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Must have destination context (avoids false positives on "copy this code" etc)
|
|
122
|
+
const hasDest = COPY_DEST_CONTEXT.some((ctx) => lower.includes(ctx));
|
|
123
|
+
if (!hasDest) {
|
|
124
|
+
return { triggered: false, reason: `No destination context found. Dest contexts: ${COPY_DEST_CONTEXT.join(", ")}` };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Should have source context for full mimic behavior
|
|
128
|
+
const hasSource = COPY_SOURCE_CONTEXT.some((ctx) => lower.includes(ctx));
|
|
129
|
+
if (!hasSource) {
|
|
130
|
+
return { triggered: false, reason: `No source context found. Source contexts: ${COPY_SOURCE_CONTEXT.join(", ")}` };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return { triggered: true, reason: `All conditions met: hasIntent=${hasIntent}, hasDest=${hasDest}, hasSource=${hasSource}` };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Check if text contains import error triggers
|
|
138
|
+
*/
|
|
139
|
+
function shouldInjectImportErrorRule(text: string): { triggered: boolean; reason: string } {
|
|
140
|
+
const lower = text.toLowerCase();
|
|
141
|
+
const matchingTriggers = IMPORT_ERROR_TRIGGERS.filter((t) => lower.includes(t));
|
|
142
|
+
|
|
143
|
+
if (matchingTriggers.length === 0) {
|
|
144
|
+
return { triggered: false, reason: "No import error triggers found" };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return { triggered: true, reason: `Matched triggers: ${matchingTriggers.join(", ")}` };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Register the file-copy-helper extension
|
|
152
|
+
*/
|
|
153
|
+
export function registerFileCopyHelper(pi: ExtensionAPI): void {
|
|
154
|
+
// Clear debug log on startup
|
|
155
|
+
fs.writeFileSync(DEBUG_LOG, `[${new Date().toISOString()}] === DEBUG SESSION STARTED ===\n`);
|
|
156
|
+
|
|
157
|
+
pi.on("input", (event: InputEvent): InputEventResult | undefined => {
|
|
158
|
+
// DEBUG: Log what we receive
|
|
159
|
+
debugLog("INPUT_EVENT", {
|
|
160
|
+
source: event.source,
|
|
161
|
+
textLength: event.text?.length,
|
|
162
|
+
textPreview: event.text?.substring(0, 200),
|
|
163
|
+
fullText: event.text,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Only process user input (not from extensions or RPC)
|
|
167
|
+
if (event.source !== "interactive") {
|
|
168
|
+
debugLog("SKIP", "not interactive input - skipping");
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const text = event.text.trim();
|
|
173
|
+
debugLog("PROCESSING_TEXT", {
|
|
174
|
+
text,
|
|
175
|
+
length: text.length,
|
|
176
|
+
hasMinLength: text.length >= 10,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
if (!text || text.length < 10) {
|
|
180
|
+
debugLog("SKIP", "text too short (< 10 chars)");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Check if this is a copy/mimic request
|
|
185
|
+
const copyCheck = shouldInjectCopyRule(text);
|
|
186
|
+
debugLog("COPY_RULE_CHECK", {
|
|
187
|
+
triggered: copyCheck.triggered,
|
|
188
|
+
reason: copyCheck.reason,
|
|
189
|
+
matchingKeywords: COPY_KEYWORDS.filter(k => text.toLowerCase().includes(k)),
|
|
190
|
+
matchingDest: COPY_DEST_CONTEXT.filter(ctx => text.toLowerCase().includes(ctx)),
|
|
191
|
+
matchingSource: COPY_SOURCE_CONTEXT.filter(ctx => text.toLowerCase().includes(ctx)),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
if (copyCheck.triggered) {
|
|
195
|
+
debugLog("INJECT", { rule: "COPY_RULE", reason: copyCheck.reason });
|
|
196
|
+
return {
|
|
197
|
+
action: "transform",
|
|
198
|
+
text: text + COPY_RULE,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Inject import error rule when agent sees missing imports
|
|
203
|
+
const importCheck = shouldInjectImportErrorRule(text);
|
|
204
|
+
debugLog("IMPORT_ERROR_CHECK", {
|
|
205
|
+
triggered: importCheck.triggered,
|
|
206
|
+
reason: importCheck.reason,
|
|
207
|
+
matchingTriggers: IMPORT_ERROR_TRIGGERS.filter(t => text.toLowerCase().includes(t)),
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (importCheck.triggered) {
|
|
211
|
+
debugLog("INJECT", { rule: "IMPORT_ERROR_RULE", reason: importCheck.reason });
|
|
212
|
+
return {
|
|
213
|
+
action: "transform",
|
|
214
|
+
text: text + IMPORT_ERROR_RULE,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
debugLog("NO_INJECTION", "no rule matched - passing through");
|
|
219
|
+
return;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Default export for pi extension loading
|
|
224
|
+
export default function fileCopyHelperExtension(pi: ExtensionAPI): void {
|
|
225
|
+
registerFileCopyHelper(pi);
|
|
226
|
+
}
|