@mmon-co/ncept-pi 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +55 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +21 -0
- package/dist/events.d.ts +43 -0
- package/dist/events.js +18 -0
- package/dist/extension.d.ts +3 -0
- package/dist/extension.js +702 -0
- package/dist/init.d.ts +2 -0
- package/dist/init.js +14 -0
- package/package.json +58 -4
- package/src/cli.ts +22 -0
- package/src/events.ts +44 -0
- package/src/extension.ts +749 -0
- package/src/init.ts +19 -0
package/dist/init.d.ts
ADDED
package/dist/init.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { init } from "@mmon-co/ncept-local";
|
|
4
|
+
import { tutorSystemPrompt } from "@mmon-co/ncept-default-theory";
|
|
5
|
+
/** Create a learning project without changing the user's pi agent directory. */
|
|
6
|
+
export async function initProject(directory) {
|
|
7
|
+
const dir = resolve(directory);
|
|
8
|
+
await init(dir);
|
|
9
|
+
await mkdir(join(dir, ".pi"), { recursive: true });
|
|
10
|
+
await writeFile(join(dir, ".pi/settings.json"), JSON.stringify({ packages: ["npm:@mmon-co/ncept-pi"], sessionDir: "sessions", codemode: { mode: "on" } }, null, 2) +
|
|
11
|
+
"\n", { flag: "wx" });
|
|
12
|
+
await writeFile(join(dir, ".pi/SYSTEM.md"), tutorSystemPrompt("empty") + "\n", { flag: "wx" });
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmon-co/ncept-pi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Learn in pi from a Profile directory you own",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/mmon-co/ncept.git",
|
|
12
|
+
"directory": "packages/pi"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"ncept-pi": "dist/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/init.d.ts",
|
|
27
|
+
"default": "./dist/init.js"
|
|
28
|
+
},
|
|
29
|
+
"./events": {
|
|
30
|
+
"types": "./dist/events.d.ts",
|
|
31
|
+
"default": "./dist/events.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "bun run --cwd ../local build && bun run --cwd ../default-theory build && tsc -p tsconfig.build.json",
|
|
36
|
+
"prepack": "bun run build"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@mmon-co/ncept-core": "^0.2.0",
|
|
40
|
+
"@mmon-co/ncept-default-theory": "^1.1.0",
|
|
41
|
+
"@mmon-co/ncept-local": "^0.2.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
45
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
46
|
+
"bun-types": "^1.3.14",
|
|
47
|
+
"typescript": "5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=22.19.0"
|
|
54
|
+
},
|
|
55
|
+
"pi": {
|
|
56
|
+
"extensions": [
|
|
57
|
+
"./src/extension.ts"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { initProject } from "./init.js";
|
|
3
|
+
|
|
4
|
+
const [command, directory, ...extra] = process.argv.slice(2);
|
|
5
|
+
if (command !== "init" || !directory || extra.length) {
|
|
6
|
+
console.error("Usage: npx @mmon-co/ncept-pi init <dir>");
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
} else {
|
|
9
|
+
try {
|
|
10
|
+
const dir = await initProject(directory);
|
|
11
|
+
console.log(
|
|
12
|
+
"Profile ready: " +
|
|
13
|
+
dir +
|
|
14
|
+
"\nRun: cd " +
|
|
15
|
+
JSON.stringify(dir) +
|
|
16
|
+
" && pi\nTrust this learning project when pi asks.",
|
|
17
|
+
);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
20
|
+
process.exitCode = 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HostSession, SessionIntent } from "@mmon-co/ncept-local";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Channels on pi's shared extension bus (`pi.events`) that let another front end
|
|
5
|
+
* layered over this extension (a bb thread per Session, say) own where Sessions open.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Emitted when the tutor or a command opens a host Session while the current pi
|
|
10
|
+
* session already holds a conversation. A listener that calls `claim` opens it
|
|
11
|
+
* elsewhere; otherwise this extension starts a new pi session in-process.
|
|
12
|
+
*/
|
|
13
|
+
export const OPEN_SESSION = "ncept:open-session";
|
|
14
|
+
export type OpenSession = {
|
|
15
|
+
/** The opened host Session, already recorded in the Profile. */
|
|
16
|
+
readonly session: string;
|
|
17
|
+
readonly mode: string;
|
|
18
|
+
/** Starting text for the new conversation. */
|
|
19
|
+
readonly kickoff?: string;
|
|
20
|
+
/** The learner supplied this text, rather than a host continuation. */
|
|
21
|
+
readonly learnerKickoff?: boolean;
|
|
22
|
+
/** Context the next tutor needs from this conversation, hidden from the learner. */
|
|
23
|
+
readonly carry?: string;
|
|
24
|
+
/** The previous Session stays open beside the new one. */
|
|
25
|
+
readonly aside: boolean;
|
|
26
|
+
/** Take over opening; return a learner-facing continuation for the tutor's tool result.
|
|
27
|
+
* A rejection closes the new Session and keeps the current one. */
|
|
28
|
+
claim(open: () => Promise<void | string>): void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Emitted by the claiming front end in a fresh pi session, before its first prompt,
|
|
33
|
+
* to continue a claimed host Session there.
|
|
34
|
+
*/
|
|
35
|
+
export const ADOPT_SESSION = "ncept:adopt-session";
|
|
36
|
+
export type AdoptSession = { readonly session: string; readonly carry?: string };
|
|
37
|
+
|
|
38
|
+
/** A front end starts a fresh conversation from a learner entry, after session_start.
|
|
39
|
+
* The tutoring extension alone resolves the entry and writes the Profile. */
|
|
40
|
+
export const BEGIN_SESSION = "ncept:begin-session";
|
|
41
|
+
export type BeginSession = {
|
|
42
|
+
readonly intent: SessionIntent;
|
|
43
|
+
claim(begin: () => Promise<HostSession>): void;
|
|
44
|
+
};
|